CmpRefreshHive
__int64 __fastcall CmpRefreshHive(__int64 a1){
char v2;
char v3;
struct _PRIVILEGE_SET *a12;
UINT64 v5;
ULONG_PTR v6;
int Hive;
__int64 v9;
_CHILD_LIST *v10;
INT64 v11;
int v12;
UINT64 v13;
UINT64 v14;
__int64 v15;
__int64 v16;
int v17;
UINT64 Flags;
__int64 v19;
__int64 v20;
INT64 a1a[2];
INT64 a6[13];
char v23;
bool v24;
PVOID P;
__int64 v26;
v26 = 0xFFFFFFFFi64;
v19 = 0xFFFFFFFFi64;
v2 = 0;
P = 0i64;
memset(a6, 0, 32);
v3 = 0;
a12 = 0i64;
v20 = 0i64;
*(_OWORD *)a1a = 0i64;
CmpInitializeDelayDerefContext(a1a);
v5 = *(_QWORD *)(a1 + 8);
v6 = *(_QWORD *)(v5 + 32);
v24 = ExAcquireRundownProtection((PEX_RUNDOWN_REF)(v6 + 1632));
if( !v24 )
{
Hive = -1073740763;
goto LABEL_7;
}
CmpBecomeActiveFlusherAndReconciler(v6);
v2 = 1;
CmpLockRegistry();
CmpLockKcbShared((_CM_KEY_CONTROL_BLOCK *)v5);
v23 = 1;
Hive = CmpPerformKeyBodyDeletionCheck(a1, 0i64);
if( Hive < 0 )
goto LABEL_6;
if( *(_BYTE *)(v6 + 2936) == 1 )
{
Hive = -1073741431;
LABEL_6:
CmpUnlockKcb(v5);
v3 = 1;
goto LABEL_7;
}
if( (*(_DWORD *)(v6 + 160) & 2) == 0 )
{
LABEL_19:
Hive = -1073741811;
goto LABEL_6;
}
HvLockHiveFlusherShared(v6);
HvLockHiveWriter(v6);
if( *(_DWORD *)(v6 + 904) )
{
Hive = -1073741823;
HvUnlockHiveWriter(v6);
HvUnlockHiveFlusherShared(v6);
v9 = 0i64;
LABEL_45:
if( v20 )
(*(void(__fastcall **)(ULONG_PTR, __int64 *))(v6 + 16))(v6, &v26);
if( v9 )
(*((void(__fastcall **)(PVOID, __int64 *))P + 2))(P, &v19);
v3 = 1;
if( v23 )
goto LABEL_6;
goto LABEL_7;
}
HvUnlockHiveWriter(v6);
HvUnlockHiveFlusherShared(v6);
if( (*(_DWORD *)(v5 + 184) & 0x40000) == 0 )
goto LABEL_19;
if( *(_DWORD *)(v6 + 2912) )
{
Hive = -1073741823;
goto LABEL_6;
}
CmpUnlockKcb(v5);
v23 = 0;
CmpUnlockRegistry();
CmpAllocateTransientPoolWithTag((_HHIVE *)1, 0x1B0ui64, 0x33394D43ui64, v10);
a12 = (struct _PRIVILEGE_SET *)v11;
if( !v11 )
{
Hive = -1073741670;
goto LABEL_7;
}
memset(v11, 0i64);
memset(&a6[1], 0, 24);
a6[0] = *(_QWORD *)(v6 + 1536);
v12 = *(_DWORD *)(v6 + 164);
if( v12 )
{
if( v12 == 1 )
{
v13 = 1i64;
a6[1] = *(_QWORD *)(v6 + 1544);
}
else
{
v13 = 2i64;
*(_OWORD *)&a6[1] = *(_OWORD *)(v6 + 1568);
}
}
else
{
v13 = 0i64;
}
v14 = *(unsigned int *)(v6 + 160);
LODWORD(v14) = v14 & 0xFFFEFFFF;
LODWORD(Flags) = 17825794;
Hive = CmpCreateHive((INT64)&P, 2ui64, v14, v13, 0i64, (INT64)a6, 0i64, Flags, 0i64, 0i64, 0i64, (INT64)a12);
if( Hive >= 0 )
{
CmpLockRegistryExclusive();
v3 = 1;
Hive = CmpPerformKeyBodyDeletionCheck(a1, 0i64);
if( Hive >= 0 )
{
if( *(_BYTE *)(v6 + 2936) == 1 )
{
Hive = -1073741431;
goto LABEL_7;
}
if( (*(_DWORD *)(v6 + 160) & 2) == 0 )
goto LABEL_37;
if( *(_DWORD *)(v6 + 904) )
{
LABEL_39:
Hive = -1073741823;
goto LABEL_7;
}
if( (*(_DWORD *)(v5 + 184) & 0x40000) != 0 )
{
if( *(_DWORD *)(v6 + 2912) )
goto LABEL_39;
v15 = *(unsigned int *)(*((_QWORD *)P + 8) + 36i64);
if( (_DWORD)v15 == *(_DWORD *)(*(_QWORD *)(v6 + 64) + 36i64) )
{
v9 = (*((__int64(__fastcall **)(PVOID, __int64, __int64 *))P + 1))(P, v15, &v19);
v16 = (*(__int64(__fastcall **)(ULONG_PTR, _QWORD, __int64 *))(v6 + 8))(
v6,
*(unsigned int *)(*(_QWORD *)(v6 + 64) + 36i64),
&v26);
v20 = v16;
if( HvMarkCellDirty((UINT64)P, *(unsigned int *)(*((_QWORD *)P + 8) + 36i64), 0) )
{
v17 = *(_DWORD *)(v16 + 16);
*(_WORD *)(v9 + 2) |= 0xCu;
*(_DWORD *)(v9 + 16) = v17;
(*(void(__fastcall **)(ULONG_PTR, __int64 *))(v6 + 16))(v6, &v26);
(*((void(__fastcall **)(PVOID, __int64 *))P + 2))(P, &v19);
CmpCleanUpKCBCacheTable(v6);
CmpSearchKeyControlBlockTreeEx(
(__int64(__fastcall *)(ULONG_PTR, ULONG_PTR, __int64, __int64))CmpRefreshWorkerRoutine,
v6,
(__int64)a1a,
0i64,
1);
CmpFlushNotifiesOnKeyBodyList(v5, 0i64, (INT64)a1a, 1);
CmpSwapHiveStorage(v6, (INT64)P);
CmpRebuildKcbCache((_CM_KEY_CONTROL_BLOCK *)v5);
++*(_DWORD *)(v6 + 204);
Hive = 0;
goto LABEL_7;
}
Hive = -1073741443;
goto LABEL_45;
}
}
LABEL_37:
Hive = -1073741811;
}
}
LABEL_7:
CmpDrainDelayDerefContext((UINT64 **)a1a);
if( v3 )
CmpUnlockRegistry();
if( v2 )
CmpFinishBeingActiveFlusherAndReconciler(v6);
if( v24 )
ExReleaseRundownProtection((PEX_RUNDOWN_REF)(v6 + 1632));
if( P )
CmpDestroyHive(P);
if( a12 )
CmSiFreeMemory(a12);
return(unsigned int)Hive;
}Referenced by:
CmRestoreKey