CmDeleteLayeredKey
VOID __stdcall CmDeleteLayeredKey(_CM_KEY_BODY *KeyBody, _LIST_ENTRY *DeferredPostAsync){
INT64 v2;
INT64 v4;
_CM_KEY_CONTROL_BLOCK *KeyControlBlock;
char v6;
char v7;
INT64 ParentKcb;
char v9;
char v10;
__int64 v11;
_CM_KCB_LAYER_INFO *LayerInfo;
__int64 *p_UpperLayerListHead;
__int64 KeyCell;
int v15;
UINT64 v16;
INT64 v17;
unsigned int v18;
UINT i;
__int64 v20;
INT64 v21;
int v22;
int v23;
UINT64 v24;
_HHIVE *KeyHive;
INT64 KcbInHashEntryByCellIndex;
char v27;
_CM_KEY_CONTROL_BLOCK *v28;
UINT64 v29;
__int64 v30;
__int64 v31;
INT64 v32[2];
__int128 v33;
INT64 v34[2];
__int128 v35;
UNICODE_STRING Component;
_CMP_DISCARD_AND_REPLACE_KCB_CONTEXT Context;
UINT ChildCell;
LIST_ENTRY *v39;
INT64 v40;
v39 = DeferredPostAsync;
LODWORD(v40) = 0;
*(_OWORD *)v32 = 0i64;
v30 = 0i64;
v4 = v2;
v33 = 0i64;
ChildCell = 0;
*(_OWORD *)v34 = 0i64;
v31 = 0i64;
v35 = 0i64;
Component = 0i64;
memset(&Context, 0, sizeof(Context));
CmpInitializeKcbStack((INT64)v32);
CmpInitializeKcbStack((INT64)v34);
KeyControlBlock = KeyBody->KeyControlBlock;
v7 = v6;
ParentKcb = (INT64)KeyControlBlock->ParentKcb;
HvpGetCellContextInitialize(&v31);
HvpGetCellContextInitialize(&v30);
CmpInitializeDiscardReplaceContext(&Context);
v10 = v9;
if( (*((_DWORD *)KeyControlBlock + 46) & 0x80000) == 0
&& (int)CmpStartKcbStackForTopLayerKcb((INT64)v32, (INT64)KeyControlBlock) >= 0
&& (int)CmpStartKcbStackForTopLayerKcb((INT64)v34, ParentKcb) >= 0 )
{
LABEL_22:
CmpLockHashEntryExclusiveByKcb(KeyControlBlock);
CmpLockKcbStackTopExclusiveRestShared((__int64)v34);
CmpLockKcbStackExclusive((INT64)v32);
while( !CmpIsKeyDeletedForKeyBody((__int64)KeyBody, 0i64)
&& (int)CmpGetSubKeyCountForKcbStack((INT64)v32, &v40) >= 0
&& !(_DWORD)v40 )
{
LayerInfo = KeyControlBlock->LayerInfo;
if( LayerInfo )
{
p_UpperLayerListHead = (__int64 *)&LayerInfo->UpperLayerListHead;
v11 = *p_UpperLayerListHead;
if( (__int64 *)*p_UpperLayerListHead != p_UpperLayerListHead )
{
if( !v7 )
goto LABEL_21;
if( (__int64 *)v11 != p_UpperLayerListHead )
{
v10 = 1;
if( (int)CmpPrepareDiscardAndReplaceKcbAndUnbackedHigherLayers((UINT64)KeyControlBlock, (INT64)&Context) < 0 )
break;
}
}
}
KeyCell = KeyControlBlock->KeyHash.KeyCell;
if( (_DWORD)KeyCell != -1 )
{
if( !v7 )
{
LABEL_21:
CmpUnlockKcbStack((__int64)v32);
CmpUnlockKcbStack((__int64)v34);
CmpUnlockHashEntryByKcb((INT64)KeyControlBlock);
CmpUnlockRegistry();
CmpLockRegistryExclusive();
v7 = 1;
goto LABEL_22;
}
v17 = (INT64)KeyControlBlock->KeyHash.KeyHive->GetCellRoutine(
KeyControlBlock->KeyHash.KeyHive,
KeyCell,
(_HV_GET_CELL_CONTEXT *)&v31);
v18 = 0;
if( *(_DWORD *)(v17 + 24) + *(_DWORD *)(v17 + 20) )
{
while( (int)CmpFindSubKeyByNumber(KeyControlBlock->KeyHash.KeyHive, (_CM_KEY_NODE *)v17, v18, &ChildCell) >= 0
&& CmpMarkKeyDirty((UINT64)KeyControlBlock->KeyHash.KeyHive, ChildCell, 1) )
{
if( ++v18 >= *(_DWORD *)(v17 + 24) + *(_DWORD *)(v17 + 20) )
goto LABEL_33;
}
}
else
{
LABEL_33:
if( CmpMarkKeyDirty((UINT64)KeyControlBlock->KeyHash.KeyHive, KeyControlBlock->KeyHash.KeyCell, 1) )
{
CmpFindSubKeyByNumber(KeyControlBlock->KeyHash.KeyHive, (_CM_KEY_NODE *)v17, 0i64, &ChildCell);
for( i = ChildCell; ChildCell != -1; i = ChildCell )
{
v20 = (__int64)KeyControlBlock->KeyHash.KeyHive->GetCellRoutine(
KeyControlBlock->KeyHash.KeyHive,
i,
(_HV_GET_CELL_CONTEXT *)&v30);
v21 = *(unsigned __int16 *)(v20 + 72);
if( (*(_BYTE *)(v20 + 2) & 0x20) != 0 )
{
v22 = CmpHashCompressedComponent((UINT8 *)(v20 + 76), v21);
}
else
{
Component.Buffer = (wchar_t *)(v20 + 76);
Component.Length = v21;
Component.MaximumLength = v21;
v22 = CmpHashUnicodeComponent(&Component);
}
v23 = v22;
KeyControlBlock->KeyHash.KeyHive->ReleaseCellRoutine(
KeyControlBlock->KeyHash.KeyHive,
(_HV_GET_CELL_CONTEXT *)&v30);
v24 = v23 + 37 * KeyControlBlock->KeyHash.ConvKey.Hash;
KeyHive = KeyControlBlock->KeyHash.KeyHive;
KcbInHashEntryByCellIndex = CmpFindKcbInHashEntryByCellIndex((INT64)KeyHive, v24, i);
if( KcbInHashEntryByCellIndex )
{
*(_DWORD *)(KcbInHashEntryByCellIndex + 40) = -1;
KeyHive = KeyControlBlock->KeyHash.KeyHive;
}
CmpFreeKeyByCell(KeyHive, i, 1u);
CmpFindSubKeyByNumber(KeyControlBlock->KeyHash.KeyHive, (_CM_KEY_NODE *)v17, 0i64, &ChildCell);
}
CmpFreeKeyValues((UINT64)KeyControlBlock->KeyHash.KeyHive, KeyControlBlock->KeyHash.KeyCell, v17);
v27 = *(_BYTE *)(v17 + 13);
*(_WORD *)(v17 + 2) &= 0x20u;
*(_BYTE *)(v17 + 55) = 0;
*(_DWORD *)(v17 + 52) &= 0xFF00FFFF;
*(_BYTE *)(v17 + 13) = v27 & 0xFC | 1;
*(_QWORD *)(v17 + 4) = 0i64;
*(_QWORD *)(v17 + 56) = 0i64;
*(_DWORD *)(v17 + 64) = 0;
*(_WORD *)(v17 + 52) = 0;
CmpIncrementKcbSequenceNumber((INT64)KeyControlBlock);
CmpRebuildKcbCacheFromNode(v28, (_CM_KEY_NODE *)v17);
CmpReportNotifyForKcbStack((INT64)v34, 0i64, 1i64, v39);
CmpFlushNotifiesOnAllUnbackedHigherLayerKcbs(KeyControlBlock, v29, v4);
CmpFlushNotifiesOnKeyBodyList((INT64)KeyControlBlock, 8i64, v4, 1);
if( v10 )
{
CmpCommitDiscardAndReplaceKcbAndUnbackedHigherLayers(KeyControlBlock, &Context);
}
else
{
CmpMarkKeyUnbacked(KeyControlBlock);
CmpDiscardKcb((UINT64)KeyControlBlock, v4);
}
}
}
KeyControlBlock->KeyHash.KeyHive->ReleaseCellRoutine(
KeyControlBlock->KeyHash.KeyHive,
(_HV_GET_CELL_CONTEXT *)&v31);
break;
}
if( *(_DWORD *)(ParentKcb + 40) == -1 )
{
CmpUnlockKcbStack((__int64)v32);
CmpUnlockKcbStack((__int64)v34);
v15 = CmpPromoteKey((__int64)v34, 0, 1);
if( v15 == -1073741444 || v15 < 0 )
goto LABEL_25;
CmpLockKcbStackExclusive((INT64)v32);
if( !v7 )
continue;
}
if( (int)CmpCreateTombstone(v11, (__int64)v32) >= 0 )
{
CmpReportNotifyForKcbStack((INT64)v34, 0i64, 1i64, v39);
CmpFlushNotifiesOnAllUnbackedHigherLayerKcbs(KeyControlBlock, v16, v4);
CmpFlushNotifiesOnKeyBodyList((INT64)KeyControlBlock, 8i64, v4, 0);
if( v10 )
{
CmpCommitDiscardAndReplaceKcbAndUnbackedHigherLayers(KeyControlBlock, &Context);
}
else
{
CmpMarkKeyUnbacked(KeyControlBlock);
CmpDiscardKcb((UINT64)KeyControlBlock, v4);
}
}
break;
}
CmpUnlockKcbStack((__int64)v32);
CmpUnlockKcbStack((__int64)v34);
LABEL_25:
CmpUnlockHashEntryByKcb((INT64)KeyControlBlock);
}
CmpCleanupDiscardReplaceContext((ULONG_PTR *)&Context, v4);
CmpCleanupKcbStack((INT64)v32);
CmpCleanupKcbStack((INT64)v34);
}Referenced by:
No references.