CmRenameKey
NTSTATUS __stdcall CmRenameKey(CM_KEY_BODY *KeyBody, UNICODE_STRING *NewKeyName, INT8 r8_0){
__int64 v3;
CM_KEY_BODY *v4;
_CM_KEY_CONTROL_BLOCK *KeyControlBlock;
INT64 ParentKcb;
_CM_KEY_CONTROL_BLOCK *v7;
__int64 v8;
NTSTATUS started;
_HHIVE *KeyHive;
INT64 v11;
CM_TRANS *v12;
INT64 v13;
INT64 v14;
INT64 v15;
int v16;
__int64 v17;
CM_KCB_UOW *v18;
CM_KCB_UOW *v19;
CHAR v20;
char v21;
unsigned __int8 v22;
INT16 v23;
INT64 KcbAtLayerHeight;
_CM_KEY_NODE *KeyNodeForKcb;
__int16 v26;
__int64 v27;
__int64 v28;
unsigned int v29;
int v30;
_CM_COMPONENT_HASH ComponentHash;
_CMHIVE *v32;
_CM_PATH_HASH PathHash;
_CM_KEY_CONTROL_BLOCK *KcbInHashEntryByName;
INT64 v35;
volatile INT64 *v36;
char v37;
__int64 v38;
_CM_KCB_UOW *v39;
__int16 LayerHeight;
INT16 v41;
_CM_KEY_CONTROL_BLOCK *v42;
_CM_KEY_CONTROL_BLOCK *v43;
_CM_KEY_CONTROL_BLOCK *v44;
_CM_KEY_CONTROL_BLOCK *v45;
_CM_KEY_NODE *v46;
unsigned int v47;
INT64 v48;
void *v49;
void *v50;
unsigned int v51;
int v52;
INT64 EntryAtLayerHeight;
UINT16 v54;
ULONG_PTR v55;
INT64 v56;
char *v57;
_UNICODE_STRING *v58;
wchar_t *v59;
UINT16 v60;
_UNICODE_STRING *v61;
UINT8 *v62;
__int64 v63;
INT64 v64;
INT64 v65;
unsigned __int64 v66;
__int64 v67;
ULONG_PTR v68;
ULONG_PTR v69;
__int64 v70;
_UNICODE_STRING *v71;
unsigned int Length;
INT64 v73;
char v74;
unsigned int v75;
_CM_KCB_LAYER_INFO *LayerInfo;
_LIST_ENTRY *Flink;
_LIST_ENTRY *Blink;
PVOID v79;
INT64 v80;
_CM_NAME_CONTROL_BLOCK *NameBlock;
char *RealKeyName;
int i;
INT64 v84;
_UNICODE_STRING *v85;
_CM_KCB_UOW *v86;
PVOID v87;
UINT16 v88;
INT64 v89;
VOID *v90;
UINT16 v91;
VOID *v92;
_CM_KEY_CONTROL_BLOCK *v93;
_DWORD *v94;
_CM_KCB_UOW *v95;
CM_KCB_UOW *v96;
unsigned int v97;
_CM_KEY_BODY *v98;
_EPROCESS *v99;
ULONG_PTR v100;
VOID *v101;
VOID *v102;
_HV_GET_CELL_CONTEXT *CellAddressContext;
_UNICODE_STRING *KeyName;
unsigned int v106;
_CM_KCB_UOW *BugCheckParameter4;
_CM_KEY_CONTROL_BLOCK *v108;
char v109;
char v110;
char v111;
INT16 a3;
UINT a3_4;
_UNICODE_STRING *Source;
ULONG_PTR Cell;
ULONG_PTR v116;
INT64 a4[2];
INT64 v118;
__int64 v119;
INT64 v120[2];
UINT v121;
PVOID BugCheckParameter2;
_HV_GET_CELL_CONTEXT v123;
__int64 v124;
PVOID BugCheckParameter3;
INT64 v126;
INT64 v127;
__int64 v128;
PVOID v129;
VOID *CellAddress;
INT64 v131;
CM_TRANS *CmTrans;
_CM_NAME_CONTROL_BLOCK *Ncb;
PVOID UnitOfWork;
UINT64 v135;
_CM_KEY_CONTROL_BLOCK *ResultKcb;
_EPROCESS *KeyBodya;
INT64 v138[2];
__int128 v139;
INT64 a1[2];
__int128 v141;
INT64 v142[14];
LOBYTE(v3) = 0;
LOBYTE(a3) = r8_0;
Source = NewKeyName;
v4 = KeyBody;
KeyBodya = (_EPROCESS *)KeyBody;
CmTrans = 0i64;
v121 = 0;
*(_OWORD *)a4 = 0i64;
memset(v142, 0i64, 0x68u);
*((_WORD *)&v123.BinContext + 1) = 0;
*(_OWORD *)v138 = 0i64;
WORD1(v138[0]) = -1;
KeyControlBlock = 0i64;
*(_OWORD *)a1 = 0i64;
WORD1(a1[0]) = -1;
ParentKcb = 0i64;
v131 = 0i64;
v7 = 0i64;
v123.BinContext = 0;
*(_OWORD *)v120 = 0i64;
UnitOfWork = 0i64;
v139 = 0i64;
BugCheckParameter4 = 0i64;
v141 = 0i64;
v129 = 0i64;
BugCheckParameter3 = 0i64;
v108 = 0i64;
BugCheckParameter2 = 0i64;
v119 = 0i64;
v128 = 0xFFFFFFFFi64;
v126 = 0xFFFFFFFFi64;
v106 = -1;
CellAddress = 0i64;
v123.Cell = -1;
v118 = 0xFFFFFFFFi64;
v124 = 0i64;
v127 = 0xFFFFFFFFi64;
Ncb = 0i64;
Cell = -1;
v116 = -1;
CmpSubtreeEnumeratorInitialize(v142);
CmpInitializeDelayDerefContext(a4);
while( 1 )
{
while( 1 )
{
v8 = *(_QWORD *)&KUSER_SHARED_DATA.SystemTime.LowPart;
v110 = 0;
if( (*(&CmpDummyThreadEvent + 1056) & 1) != 0 )
{
started = -1073741431;
v109 = 0;
goto LABEL_195;
}
CmpLockRegistryExclusive();
KeyControlBlock = v4->KeyControlBlock;
v109 = 1;
ParentKcb = (INT64)KeyControlBlock->ParentKcb;
started = CmpStartKcbStackForTopLayerKcb((INT64)v138, (INT64)KeyControlBlock);
if( started < 0 )
goto LABEL_195;
started = CmpStartKcbStackForTopLayerKcb((INT64)a1, ParentKcb);
if( started < 0 )
goto LABEL_193;
if( (KeyControlBlock->_bf_8 & 0x180) != 0
|| (KeyHive = KeyControlBlock->KeyHash.KeyHive, (KeyHive->HiveFlags & 0x100000) != 0)
|| KeyHive == *(_HHIVE **)&CmpMasterHive
|| (KeyControlBlock->_bf_b8 & 0x40000) != 0 )
{
started = -1073741790;
LABEL_193:
v3 = 0i64;
v39 = 0i64;
goto LABEL_197;
}
started = CmpPerformKeyBodyDeletionCheck(v4, 0i64);
if( started < 0 )
goto LABEL_195;
if( *(_QWORD *)&v4->Trans.0 || v4->KtmUow )
{
started = CmpTransSearchAddTransFromKeyBody(v4, &CmTrans);
if( started < 0 )
goto LABEL_195;
v12 = CmTrans;
started = CmpPerformKeyBodyDeletionCheck(v4, CmTrans);
if( started < 0 )
goto LABEL_77;
}
else
{
v12 = 0i64;
CmTrans = 0i64;
}
if( KeyControlBlock->LayerHeight && v12 )
{
CmpLogUnsupportedOperation(26);
started = -1073741822;
goto LABEL_77;
}
if( v12 )
CmpLogUnsupportedOperation(24);
LOBYTE(v11) = a3;
started = CmpCheckKcbStackAccess((INT64)a1, (INT64)v12, v11);
if( started < 0 )
goto LABEL_77;
LOBYTE(v13) = a3;
LODWORD(KeyName) = 1;
LODWORD(CellAddressContext) = KeyControlBlock->LayerHeight != 0 ? 196633 : 0x10000;
started = CmpDoAccessCheckOnLayeredSubtree(
(INT64)v138,
(INT64)v12,
0i64,
v13,
(INT64)CellAddressContext,
(INT64)KeyName);
if( started < 0 )
goto LABEL_77;
CmpFlushNotifiesOnKeyBodyList((__int64)KeyControlBlock, 0i64, (__int64)a4, 1);
CmpReportNotify((__int64)KeyControlBlock, (__int64)v12, 1i64, 0i64);
if( v12 )
break;
started = CmpTryAcquireKcbIXLocks((INT64)KeyControlBlock, 1, v14, (UINT64 *)v120);
if( started == -1073741267 )
{
LOBYTE(v3) = 1;
v110 = 1;
}
else if( started < 0 )
{
goto LABEL_77;
}
v16 = CmpTryAcquireKcbIXLocks(ParentKcb, 1, v15, (UINT64 *)v120);
started = v16;
if( v16 != -1073741267 )
{
v17 = 0i64;
if( v16 < 0 )
{
LABEL_78:
v7 = v108;
v3 = 0i64;
v39 = 0i64;
goto LABEL_197;
}
if( !(_BYTE)v3 )
goto LABEL_36;
}
CmpLogTransactionAbortedForRollbackPacket((__int64)KeyControlBlock, 4, (unsigned int *)v120, v17);
CmpDrainDelayDerefContext((UINT64 **)a4);
CmpUnlockRegistry();
v3 = 0i64;
v109 = 0;
started = CmpAbortRollbackPacket((INT64)v120);
if( started < 0 )
goto LABEL_79;
CmpCleanupRollbackPacket((INT64)v120);
*(_OWORD *)v120 = 0i64;
CmpCleanupKcbStack((INT64)v138);
CmpCleanupKcbStack((INT64)a1);
v7 = v108;
}
if( KeyControlBlock->KCBUoWListHead[0].Flink != KeyControlBlock->KCBUoWListHead )
goto LABEL_191;
UnitOfWork = CmpAllocateUnitOfWork();
v18 = (CM_KCB_UOW *)UnitOfWork;
if( !UnitOfWork )
goto LABEL_142;
v129 = CmpAllocateUnitOfWork();
v19 = (CM_KCB_UOW *)v129;
if( !v129 )
goto LABEL_142;
CmpTransEnlistUowInKcb((_CM_KCB_UOW *__ptr32)v18, (_CM_KEY_CONTROL_BLOCK *__ptr32)ParentKcb);
CmpTransEnlistUowInKcb((_CM_KCB_UOW *__ptr32)v19, (_CM_KEY_CONTROL_BLOCK *__ptr32)KeyControlBlock);
started = CmpTransEnlistUowInCmTrans(v18, v12);
if( started < 0 )
goto LABEL_77;
started = CmpTransEnlistUowInCmTrans(v19, v12);
if( started < 0 )
goto LABEL_77;
v20 = CmpLockIXLockExclusive(ParentKcb + 248, (INT64)v18, 0i64);
v21 = CmpLockIXLockExclusive(ParentKcb + 264, (INT64)v18, 1i64) & v20;
v22 = CmpLockIXLockExclusive((INT64)&KeyControlBlock->KCBLock, (INT64)v129, 0i64) & v21;
if( ((unsigned __int8)CmpLockIXLockExclusive((INT64)&KeyControlBlock->KeyLock, (INT64)v129, 1i64) & v22) == 0 )
{
LABEL_191:
started = -1072103423;
goto LABEL_77;
}
LABEL_36:
v23 = *(_WORD *)(ParentKcb + 66);
a3_4 = -1;
v119 = 0i64;
if( v23 < 0 )
goto LABEL_49;
while( 1 )
{
KcbAtLayerHeight = CmpGetKcbAtLayerHeight((INT64)a1, v23);
if( (unsigned int)CmpGetEffectiveKcbSemantics(KcbAtLayerHeight) == 1 )
{
LABEL_43:
v26 = -1;
v27 = v119;
goto LABEL_44;
}
if( *(_DWORD *)(KcbAtLayerHeight + 40) != -1 )
break;
LABEL_42:
if( --v23 < 0 )
goto LABEL_43;
}
KeyNodeForKcb = (_CM_KEY_NODE *)CmpGetKeyNodeForKcb(KcbAtLayerHeight, (INT64)&v126, 1);
started = CmpFindSubKeyByNameWithStatus(*(_HHIVE **)(KcbAtLayerHeight + 32), KeyNodeForKcb, Source, &a3_4);
CmpReleaseKeyNodeForKcb(KcbAtLayerHeight);
if( started < 0 )
{
if( started != -1073741772 )
goto LABEL_78;
if( (unsigned int)CmpGetEffectiveKcbSemantics(KcbAtLayerHeight) )
goto LABEL_43;
goto LABEL_42;
}
v27 = *(_QWORD *)(KcbAtLayerHeight + 32);
v26 = v23;
v119 = v27;
LABEL_44:
if( a3_4 == -1 )
{
LABEL_49:
v111 = 0;
goto LABEL_50;
}
v3 = (*(__int64(__fastcall **)(__int64, _QWORD, __int64 *))(v27 + 8))(v27, a3_4, &v128);
if( (unsigned int)CmpGetEffectiveKeyNodeSemantics(v119, v3) != 1 )
{
started = -1073741535;
goto LABEL_82;
}
(*(void(__fastcall **)(__int64, __int64 *))(v28 + 16))(v28, &v128);
v111 = 1;
if( v26 != *(_WORD *)(ParentKcb + 66) )
{
a3_4 = -1;
v119 = 0i64;
}
LABEL_50:
v29 = CmpHashUnicodeComponent(Source);
v30 = 37 * *(_DWORD *)(ParentKcb + 16);
ComponentHash.Hash = v29;
v32 = *(_CMHIVE **)(ParentKcb + 32);
LODWORD(v135) = v29;
PathHash.Hash = v29 + v30;
KcbInHashEntryByName = CmpFindKcbInHashEntryByName(v32, PathHash, (_CM_KEY_CONTROL_BLOCK *)ParentKcb, Source);
v108 = KcbInHashEntryByName;
v36 = (volatile INT64 *)KcbInHashEntryByName;
if( KcbInHashEntryByName )
CmpReferenceKeyControlBlock(KcbInHashEntryByName);
if( v12 )
{
if( v36 )
{
CmpReferenceKeyControlBlockUnsafe(v36);
v85 = Source;
BugCheckParameter3 = (PVOID)v36;
goto LABEL_180;
}
v85 = Source;
started = CmpCreateKeyControlBlock(
*(_CMHIVE **)(ParentKcb + 32),
0xFFFFFFFF,
(_CM_KEY_CONTROL_BLOCK *)ParentKcb,
0i64,
0,
Source,
ComponentHash,
PathHash,
(_CM_KEY_CONTROL_BLOCK **)&BugCheckParameter3);
v3 = 0i64;
if( started >= 0 )
{
LABEL_180:
v86 = CmpAllocateUnitOfWork();
v3 = 0i64;
BugCheckParameter4 = v86;
if( v86 )
{
v87 = BugCheckParameter3;
CmpTransEnlistUowInKcb((_CM_KCB_UOW *__ptr32)v86, (_CM_KEY_CONTROL_BLOCK *__ptr32)BugCheckParameter3);
started = CmpTransEnlistUowInCmTrans(BugCheckParameter4, v12);
if( started < 0 )
goto LABEL_82;
CmpLockIXLockExclusive((INT64)v87 + 248, (INT64)BugCheckParameter4, 0i64);
CmpLockIXLockExclusive((INT64)v87 + 264, (INT64)BugCheckParameter4, 1i64);
v88 = CmpNameSize(v85);
v106 = HvAllocateCell(*(_QWORD *)(ParentKcb + 32), (unsigned int)v88 + 76, 1, &CellAddress, &v123);
v55 = v106;
if( v106 == -1 )
{
v7 = v108;
v39 = BugCheckParameter4;
started = -1073741443;
}
else
{
v89 = CmpGetKeyNodeForKcb((INT64)KeyControlBlock, (INT64)&v118, 1);
v90 = CellAddress;
*(_OWORD *)CellAddress = *(_OWORD *)v89;
*((_OWORD *)v90 + 1) = *(_OWORD *)(v89 + 16);
*((_OWORD *)v90 + 2) = *(_OWORD *)(v89 + 32);
*((_OWORD *)v90 + 3) = *(_OWORD *)(v89 + 48);
*((_QWORD *)v90 + 8) = *(_QWORD *)(v89 + 64);
*((_DWORD *)v90 + 18) = *(_DWORD *)(v89 + 72);
CmpReleaseKeyNodeForKcb((__int64)KeyControlBlock);
v91 = CmpCopyName((PWCHAR)v90 + 38, v85);
*((_WORD *)v90 + 36) = v91;
if( v91 >= v85->Length )
*((_WORD *)v90 + 1) &= ~0x20u;
else
*((_WORD *)v90 + 1) |= 0x20u;
v92 = CellAddress;
v93 = (_CM_KEY_CONTROL_BLOCK *)BugCheckParameter3;
v94 = BugCheckParameter3;
*(_QWORD *)((char *)CellAddress + 4) = *(_QWORD *)&KUSER_SHARED_DATA.SystemTime.LowPart;
v94[10] = v106;
CmpRebuildKcbCacheFromNode(v94, (__int64)v92, (__int64)a4, 1);
(*(void(__fastcall **)(_QWORD, _HV_GET_CELL_CONTEXT *))(*(_QWORD *)(ParentKcb + 32) + 16i64))(
*(_QWORD *)(ParentKcb + 32),
&v123);
v95 = (_CM_KCB_UOW *)UnitOfWork;
v96 = (CM_KCB_UOW *)v129;
*((_DWORD *)UnitOfWork + 17) = 10;
v95->LastWriteTime.QuadPart = (LONGLONG)KeyControlBlock;
v95->NewChildKCB = v93;
v96->ActionType = UoWRenameOldSubKey;
v96->LastWriteTime.QuadPart = (LONGLONG)v93;
BugCheckParameter4->ActionType = UoWRenameNewSubKey;
BugCheckParameter4->LastWriteTime.QuadPart = (LONGLONG)KeyControlBlock;
v97 = KeyControlBlock->KeyHash.KeyCell >> 31;
BugCheckParameter4->ParentUoW = v95;
BugCheckParameter4->StorageType = v97;
started = CmAddLogForAction(v96);
v3 = 0i64;
if( started < 0 )
goto LABEL_82;
v98 = (_CM_KEY_BODY *)KeyBodya;
v99 = KeyBodya;
v93->TransKCBOwner = CmTrans;
DelistKeyBodyFromKCB(v99, 1u);
v98->KeyControlBlock = v93;
EnlistKeyBodyWithKCB(v98, 2ui64);
BugCheckParameter3 = 0i64;
CmpDereferenceKeyControlBlockWithLock((ULONG_PTR)KeyControlBlock, (INT64)a4, 0);
UnitOfWork = 0i64;
v39 = 0i64;
v129 = 0i64;
started = 0;
v3 = 0i64;
v55 = -1;
v7 = v108;
}
goto LABEL_198;
}
started = -1073741670;
}
v7 = v108;
LABEL_196:
v39 = 0i64;
goto LABEL_197;
}
v7 = (_CM_KEY_CONTROL_BLOCK *)v36;
if( !v36 )
{
v37 = v110;
goto LABEL_64;
}
started = CmpTryAcquireKcbIXLocks((INT64)v36, 1, v35, (UINT64 *)v120);
if( started == -1073741267 )
{
v37 = 1;
goto LABEL_58;
}
if( started < 0 )
goto LABEL_195;
v37 = v110;
LABEL_58:
started = CmpPrepareToInvalidateAllHigherLayerKcbs((__int64)v108, 1u, (__int64)v120);
if( started == -1073741267 )
{
v37 = 1;
goto LABEL_61;
}
if( started < 0 )
goto LABEL_77;
LABEL_61:
started = CmpPrepareForSubtreeInvalidation((__int64)v108, (__int64)v120);
if( started == -1073741267 )
{
v37 = 1;
goto LABEL_64;
}
if( started < 0 )
goto LABEL_77;
LABEL_64:
started = CmpPrepareToInvalidateAllHigherLayerKcbs((__int64)KeyControlBlock, 1u, (__int64)v120);
if( started == -1073741267 )
{
v37 = 1;
goto LABEL_68;
}
if( started < 0 )
goto LABEL_77;
LABEL_68:
if( !KeyControlBlock->LayerHeight )
goto LABEL_71;
started = CmpPrepareForSubtreeInvalidation((__int64)KeyControlBlock, (__int64)v120);
if( started != -1073741267 )
break;
LABEL_72:
CmpLogTransactionAbortedForRollbackPacket((__int64)KeyControlBlock, 4, (unsigned int *)v120, v38);
v7 = v108;
v3 = 0i64;
if( v108 )
{
CmpDereferenceKeyControlBlockWithLock((ULONG_PTR)v108, (INT64)a4, 0);
v7 = 0i64;
v108 = 0i64;
}
CmpDrainDelayDerefContext((UINT64 **)a4);
CmpUnlockRegistry();
v109 = 0;
started = CmpAbortRollbackPacket((INT64)v120);
if( started < 0 )
goto LABEL_80;
CmpCleanupRollbackPacket((INT64)v120);
*(_OWORD *)v120 = 0i64;
CmpCleanupKcbStack((INT64)v138);
CmpCleanupKcbStack((INT64)a1);
v4 = (CM_KEY_BODY *)KeyBodya;
}
if( started < 0 )
goto LABEL_77;
LABEL_71:
if( v37 )
goto LABEL_72;
v7 = v108;
if( v108 )
{
CmpInvalidateAllHigherLayerKcbs((INT64)v108, 1u, 8i64, (INT64)a4);
CmpInvalidateSubtree((INT64)v108, 8i64, (INT64)a4, 0i64);
CmpFlushNotifiesOnKeyBodyList((__int64)v108, 8i64, (__int64)a4, 1);
CmpDiscardKcb((UINT64)v108, (INT64)a4);
}
CmpInvalidateAllHigherLayerKcbs((INT64)KeyControlBlock, 1u, 8i64, (INT64)a4);
LayerHeight = KeyControlBlock->LayerHeight;
if( LayerHeight )
{
CmpInvalidateSubtree((INT64)KeyControlBlock, 8i64, (INT64)a4, 0i64);
LayerHeight = KeyControlBlock->LayerHeight;
}
v41 = 0;
a3 = 0;
if( LayerHeight <= 0 )
{
LABEL_104:
if( KeyControlBlock->LayerHeight )
{
started = CmpPromoteKey((__int64)v138, 1, 0);
v3 = 0i64;
if( started < 0 )
goto LABEL_82;
started = CmpPromoteSubtree((__int64)v138, 0i64);
if( started < 0 )
goto LABEL_82;
}
if( !HvMarkCellDirty(*(PVOID *)(ParentKcb + 32), (PVOID)*(unsigned int *)(ParentKcb + 40), 1u)
|| (v48 = CmpGetKeyNodeForKcb(ParentKcb, (INT64)&v127, 1),
v124 = v48,
v49 = (void *)*(unsigned int *)(v48 + 28),
(_DWORD)v49 != -1)
&& !CmpMarkEntireIndexDirty(*(PVOID *)(ParentKcb + 32), v49) )
{
started = -1073741443;
goto LABEL_195;
}
v50 = (void *)*(unsigned int *)(v48 + 32);
if( (_DWORD)v50 == -1 )
{
v3 = 0i64;
}
else
{
v3 = 0i64;
if( !CmpMarkEntireIndexDirty(*(PVOID *)(ParentKcb + 32), v50) )
{
started = -1073741443;
goto LABEL_80;
}
}
if( !HvMarkCellDirty(KeyControlBlock->KeyHash.KeyHive, (PVOID)KeyControlBlock->KeyHash.KeyCell, 1u)
|| (v51 = a3_4, a3_4 != -1) && !HvMarkCellDirty(*(PVOID *)(ParentKcb + 32), (PVOID)a3_4, 1u) )
{
started = -1073741443;
goto LABEL_83;
}
if( v111 )
{
started = CmpSubtreeEnumeratorStartForKcbStack((INT64)v142, (INT64)v138);
if( started < 0 )
goto LABEL_82;
v52 = CmpSubtreeEnumeratorAdvance((INT64)v142);
v3 = 0i64;
while( 1 )
{
if( v52 == -2147483622 )
{
v51 = a3_4;
goto LABEL_129;
}
CmpSubtreeEnumeratorGetCurrentKeyStacks((INT16 *)v142, 0i64, &v131);
EntryAtLayerHeight = CmpKeyNodeStackGetEntryAtLayerHeight(v131, KeyControlBlock->LayerHeight);
if( !HvMarkCellDirty(*(PVOID *)EntryAtLayerHeight, (PVOID)*(unsigned int *)(EntryAtLayerHeight + 8), 1u) )
break;
v52 = CmpSubtreeEnumeratorAdvance((INT64)v142);
}
started = -1073741443;
LABEL_79:
v7 = v108;
LABEL_80:
v39 = 0i64;
goto LABEL_197;
}
if( !CmpMarkAllChildrenDirty(KeyControlBlock->KeyHash.KeyHive, KeyControlBlock->KeyHash.KeyCell) )
{
started = -1073741443;
goto LABEL_82;
}
LABEL_129:
v54 = CmpNameSize(Source);
v106 = HvAllocateCell(
(ULONG_PTR)KeyControlBlock->KeyHash.KeyHive,
(unsigned int)v54 + 76,
KeyControlBlock->KeyHash.KeyCell >> 31,
&CellAddress,
&v123);
if( v106 == -1 )
{
v7 = v108;
started = -1073741443;
v39 = 0i64;
v55 = -1;
goto LABEL_198;
}
v56 = CmpGetKeyNodeForKcb((INT64)KeyControlBlock, (INT64)&v118, 1);
v57 = (char *)CellAddress;
v58 = Source;
v59 = (wchar_t *)((char *)CellAddress + 76);
*(_OWORD *)CellAddress = *(_OWORD *)v56;
*((_OWORD *)v57 + 1) = *(_OWORD *)(v56 + 16);
*((_OWORD *)v57 + 2) = *(_OWORD *)(v56 + 32);
*((_OWORD *)v57 + 3) = *(_OWORD *)(v56 + 48);
*((_QWORD *)v57 + 8) = *(_QWORD *)(v56 + 64);
*((_DWORD *)v57 + 18) = *(_DWORD *)(v56 + 72);
v60 = CmpCopyName(v59, v58);
v61 = Source;
*((_WORD *)v57 + 36) = v60;
if( v60 >= v61->Length )
*((_WORD *)v57 + 1) &= ~0x20u;
else
*((_WORD *)v57 + 1) |= 0x20u;
*(_QWORD *)(v57 + 4) = v8;
if( v111 )
v57[13] |= 3u;
CmpReleaseKeyNodeForKcb((__int64)KeyControlBlock);
KeyControlBlock->KeyHash.KeyHive->ReleaseCellRoutine(KeyControlBlock->KeyHash.KeyHive, &v123);
Ncb = CmpGetNameControlBlock(Source, (CM_COMPONENT_HASH *)&v135, v62);
if( !Ncb )
goto LABEL_138;
v63 = v124;
v64 = *(unsigned int *)(v124 + 28);
if( (_DWORD)v64 != -1 && (Cell = CmpDuplicateIndex(*(_QWORD *)(ParentKcb + 32), v64, 0i64), Cell == -1)
|| (v65 = *(unsigned int *)(v63 + 32), (_DWORD)v65 != -1)
&& (v116 = CmpDuplicateIndex(*(_QWORD *)(ParentKcb + 32), v65, 1ui64), v116 == -1) )
{
LABEL_142:
started = -1073741670;
}
else
{
if( v51 != -1
&& !CmpRemoveSubKeyFromList(*(_QWORD *)(ParentKcb + 32), &Cell + ((unsigned __int64)v51 >> 31), v51) )
{
goto LABEL_147;
}
v66 = (unsigned __int64)v106 >> 31;
if( !CmpAddSubKeyToList(*(_QWORD *)(ParentKcb + 32), (UINT64 *)(&Cell + v66), v106) )
{
LABEL_138:
started = -1073741670;
LABEL_139:
v7 = v108;
v3 = 0i64;
v39 = 0i64;
goto LABEL_197;
}
if( !KeyControlBlock->LayerHeight
&& !CmpRemoveSubKeyFromList(
*(_QWORD *)(ParentKcb + 32),
&Cell + ((unsigned __int64)KeyControlBlock->KeyHash.KeyCell >> 31),
KeyControlBlock->KeyHash.KeyCell) )
{
LABEL_147:
started = -1073741443;
goto LABEL_139;
}
v67 = v124;
v68 = *(_DWORD *)(v124 + 28);
*(_DWORD *)(v124 + 28) = Cell;
Cell = v68;
v69 = *(_DWORD *)(v67 + 32);
*(_DWORD *)(v67 + 32) = v116;
v116 = v69;
if( v51 != -1 )
--*(_DWORD *)(v67 + 4 * ((unsigned __int64)v51 >> 31) + 20);
started = 0;
++*(_DWORD *)(v67 + 4 * v66 + 20);
if( !KeyControlBlock->LayerHeight )
--*(_DWORD *)(v67 + 4 * ((unsigned __int64)KeyControlBlock->KeyHash.KeyCell >> 31) + 20);
CmpCleanUpSubKeyInfo(ParentKcb, 1);
v70 = v124;
v71 = Source;
Length = Source->Length;
if( (unsigned __int16)*(_DWORD *)(v124 + 52) < Length )
{
*(_WORD *)(v124 + 52) = Length;
*(_WORD *)(ParentKcb + 176) = v71->Length;
}
if( KeyControlBlock->LayerHeight )
{
v73 = CmpGetKeyNodeForKcb((INT64)KeyControlBlock, (INT64)&v118, 1);
v74 = *(_BYTE *)(v73 + 13);
*(_WORD *)(v73 + 2) &= 0x20u;
*(_WORD *)(v73 + 52) = 0;
*(_DWORD *)(v73 + 52) &= 0xFF00FFFF;
*(_BYTE *)(v73 + 13) = v74 & 0x7C | 1;
*(_DWORD *)(v73 + 28) = -1;
*(_DWORD *)(v73 + 32) = -1;
*(_DWORD *)(v73 + 40) = -1;
*(_DWORD *)(v73 + 48) = -1;
*(_QWORD *)(v73 + 20) = 0i64;
*(_DWORD *)(v73 + 36) = 0;
*(_BYTE *)(v73 + 55) = 0;
*(_QWORD *)(v73 + 56) = 0i64;
*(_DWORD *)(v73 + 64) = 0;
*(_WORD *)(v73 + 74) = 0;
CmpReleaseKeyNodeForKcb((__int64)KeyControlBlock);
}
else
{
HvFreeCell((ULONG_PTR)KeyControlBlock->KeyHash.KeyHive, KeyControlBlock->KeyHash.KeyCell);
}
v75 = v106;
v106 = -1;
KeyControlBlock->KeyHash.KeyCell = v75;
if( KeyControlBlock->LayerHeight )
{
LayerInfo = KeyControlBlock->LayerInfo;
Flink = LayerInfo->LayerListEntry.Flink;
if( (_CM_KCB_LAYER_INFO *)LayerInfo->LayerListEntry.Flink->Blink != LayerInfo
|| (Blink = LayerInfo->LayerListEntry.Blink, (_CM_KCB_LAYER_INFO *)Blink->Flink != LayerInfo) )
{
__fastfail(3u);
}
Blink->Flink = Flink;
Flink->Blink = Blink;
CmpDereferenceKeyControlBlockWithLock((ULONG_PTR)KeyControlBlock->LayerInfo->LowerLayer->Kcb, (INT64)a4, 0);
v79 = BugCheckParameter2;
KeyControlBlock->LayerInfo->LowerLayer = 0i64;
CmpCreateLayerLink(v79);
}
CmpRemoveKeyControlBlock((__int64)KeyControlBlock);
v80 = (INT64)KeyControlBlock->KeyHash.KeyHive;
KeyControlBlock->KeyHash.ConvKey = PathHash;
CmpInsertKeyHash(v80, &KeyControlBlock->KeyHash.ConvKey.Hash);
NameBlock = KeyControlBlock->NameBlock;
KeyControlBlock->NameBlock = Ncb;
Ncb = NameBlock;
if( KeyControlBlock->_bf_0 )
_InterlockedOr64((volatile signed __int64 *)&KeyControlBlock->296, 1ui64);
RealKeyName = KeyControlBlock->RealKeyName;
if( (unsigned __int64)RealKeyName >= 2 )
ExFreePoolWithTag(RealKeyName, 0x624E4D43u);
KeyControlBlock->RealKeyName = 0i64;
if( v111 )
KeyControlBlock->LayerSemantics = 3;
CmpUpdateParentForEachSon((UINT64)KeyControlBlock->KeyHash.KeyHive, KeyControlBlock->KeyHash.KeyCell, 0);
if( v111 )
{
CmpSubtreeEnumeratorReset((INT64)v142);
CmpSubtreeEnumeratorBeginForKcbStack((INT64)v142, (INT64)v138);
for( i = CmpSubtreeEnumeratorAdvance((INT64)v142); i != -2147483622; i = CmpSubtreeEnumeratorAdvance((INT64)v142) )
{
CmpSubtreeEnumeratorGetCurrentKeyStacks((INT16 *)v142, 0i64, &v131);
v84 = CmpKeyNodeStackGetEntryAtLayerHeight(v131, KeyControlBlock->LayerHeight);
*(_BYTE *)(*(_QWORD *)(v84 + 16) + 13i64) |= 3u;
}
}
*(_QWORD *)(v70 + 4) = v8;
*(_QWORD *)(ParentKcb + 168) = v8;
CmpReleaseKeyNodeForKcb(ParentKcb);
v124 = 0i64;
CmpSearchForOpenSubKeys(KeyControlBlock, 1, 0i64);
++*(_QWORD *)(ParentKcb + 304);
++KeyControlBlock->SequenceNumber;
if( a3_4 != -1 )
HvFreeCell(*(_QWORD *)(ParentKcb + 32), a3_4);
}
LABEL_77:
v7 = v108;
LABEL_195:
v3 = 0i64;
goto LABEL_196;
}
do
{
v42 = (_CM_KEY_CONTROL_BLOCK *)CmpGetKcbAtLayerHeight((INT64)a1, v41);
v43 = CmpFindKcbInHashEntryByName(
*(_CMHIVE **)(ParentKcb + 32),
PathHash,
(_CM_KEY_CONTROL_BLOCK *)ParentKcb,
Source);
ResultKcb = v43;
v44 = v43;
if( v43 )
{
CmpReferenceKeyControlBlock(v43);
CmpDereferenceKeyControlBlockUnsafe((volatile INT64 *)BugCheckParameter2);
v45 = v44;
}
else
{
if( v42->KeyHash.KeyCell == -1
|| (v46 = (_CM_KEY_NODE *)CmpGetKeyNodeForKcb((INT64)v42, (INT64)&v126, 1),
started = CmpFindSubKeyByNameWithStatus(v42->KeyHash.KeyHive, v46, Source, &v121),
CmpReleaseKeyNodeForKcb((__int64)v42),
started == -1073741772) )
{
v47 = -1;
v121 = -1;
}
else
{
if( started < 0 )
goto LABEL_139;
v47 = v121;
}
started = CmpCreateKeyControlBlock(
(_CMHIVE *)v42->KeyHash.KeyHive,
v47,
v42,
(_CM_KEY_CONTROL_BLOCK *)BugCheckParameter2,
0,
Source,
ComponentHash,
PathHash,
&ResultKcb);
if( started < 0 )
goto LABEL_77;
if( BugCheckParameter2 )
CmpDereferenceKeyControlBlockUnsafe((volatile INT64 *)BugCheckParameter2);
v45 = ResultKcb;
}
v41 = a3 + 1;
BugCheckParameter2 = v45;
a3 = v41;
}
while( v41 < KeyControlBlock->LayerHeight );
if( !v45 )
{
v7 = v108;
goto LABEL_104;
}
started = CmpAllocateLayerInfoForKcb(v45);
v3 = 0i64;
if( started >= 0 )
{
v7 = v108;
goto LABEL_104;
}
LABEL_82:
v7 = v108;
LABEL_83:
v39 = BugCheckParameter4;
LABEL_197:
v55 = v106;
LABEL_198:
CmpSubtreeEnumeratorCleanup((INT64)v142);
if( v124 )
CmpReleaseKeyNodeForKcb(ParentKcb);
if( v3 )
(*(void(__fastcall **)(__int64, __int64 *))(v119 + 16))(v119, &v128);
if( Cell != -1 )
CmpFreeIndexByCell(*(_QWORD *)(ParentKcb + 32), Cell);
if( v116 != -1 )
CmpFreeIndexByCell(*(_QWORD *)(ParentKcb + 32), v116);
if( v55 != -1 )
HvFreeCell((ULONG_PTR)KeyControlBlock->KeyHash.KeyHive, v55);
if( Ncb )
CmpDereferenceNameControlBlockWithLock(Ncb);
if( BugCheckParameter2 )
CmpDereferenceKeyControlBlockWithLock((ULONG_PTR)BugCheckParameter2, (INT64)a4, 0);
v100 = (unsigned int)BugCheckParameter3;
if( BugCheckParameter3 )
{
CmpMarkKeyUnbacked((__int64)BugCheckParameter3, (__int64)a4);
CmpDereferenceKeyControlBlockWithLock(v100, (INT64)a4, 0);
}
if( v7 )
CmpDereferenceKeyControlBlockWithLock((ULONG_PTR)v7, (INT64)a4, 0);
if( v39 )
{
CmpRundownUnitOfWork(v39);
CmpFreeUnitOfWork(v39);
}
v101 = v129;
if( v129 )
{
CmpRundownUnitOfWork(v129);
CmpFreeUnitOfWork(v101);
}
v102 = UnitOfWork;
if( UnitOfWork )
{
CmpRundownUnitOfWork(UnitOfWork);
CmpFreeUnitOfWork(v102);
}
CmpDrainDelayDerefContext((UINT64 **)a4);
if( v109 )
CmpUnlockRegistry();
CmpCleanupKcbStack((INT64)v138);
CmpCleanupKcbStack((INT64)a1);
CmpCleanupRollbackPacket((INT64)v120);
return started;
}Referenced by:
NtRenameKey