CmpPartialPromoteSubkeys
__int64 __fastcall CmpPartialPromoteSubkeys(__int64 a1){
INT16 v2;
INT64 KcbAtLayerHeight;
INT16 v4;
int started;
__int16 v6;
INT64 v7;
INT16 v8;
INT64 EntryAtLayerHeight;
__int64 v10;
unsigned int ComponentNameLength;
wchar_t *v12;
int v13;
INT64 KcbInHashEntryByName;
int v15;
int v16;
int v17;
UNICODE_STRING Component;
INT64 v20[2];
PPRIVILEGE_SET Privileges[2];
INT64 result;
INT16 v23[172];
memset((INT64)&result, 0i64);
Component = 0i64;
CmpKeyEnumStackInitialize();
v2 = *(_WORD *)(a1 + 2);
*(_OWORD *)v20 = 0i64;
WORD1(v20[0]) = -1;
*(_OWORD *)Privileges = 0i64;
KcbAtLayerHeight = CmpGetKcbAtLayerHeight(a1, v2);
started = CmpStartKcbStack((INT64)v20, v4);
if( started >= 0 )
{
started = CmpKeyEnumStackStartFromKcbStack((INT16 *)&result, a1);
if( started >= 0 )
{
while( 1 )
{
v17 = CmpKeyEnumStackAdvance((INT16 *)&result);
started = v17;
if( v17 < 0 )
break;
v6 = *(_WORD *)(KcbAtLayerHeight + 66);
v7 = 0i64;
v8 = v6;
if( v6 >= 0 )
{
while( 1 )
{
EntryAtLayerHeight = CmpKeyNodeStackGetEntryAtLayerHeight((INT64)v23, v8);
if( *(_QWORD *)(EntryAtLayerHeight + 16) )
break;
if( --v8 < 0 )
goto LABEL_9;
}
v7 = EntryAtLayerHeight;
}
LABEL_9:
if( v8 != v6 )
{
v10 = *(_QWORD *)(v7 + 16);
ComponentNameLength = *(unsigned __int16 *)(v10 + 72);
v12 = (wchar_t *)(v10 + 76);
LOBYTE(v10) = *(_BYTE *)(v10 + 2);
Component.Buffer = v12;
Component.Length = ComponentNameLength;
Component.MaximumLength = ComponentNameLength;
if( (v10 & 0x20) != 0 )
{
v13 = CmpHashCompressedComponent((UINT8 *)v12, ComponentNameLength);
CmpFindKcbInHashEntryByCompressedName(
*(_CMHIVE **)(KcbAtLayerHeight + 32),
(_CM_PATH_HASH)(v13 + 37 * *(_DWORD *)(KcbAtLayerHeight + 16)),
(_CM_KEY_CONTROL_BLOCK *)KcbAtLayerHeight,
v12,
ComponentNameLength);
}
else
{
v15 = CmpHashUnicodeComponent(&Component);
KcbInHashEntryByName = CmpFindKcbInHashEntryByName(
*(_QWORD *)(KcbAtLayerHeight + 32),
(unsigned int)(v15 + 37 * *(_DWORD *)(KcbAtLayerHeight + 16)),
KcbAtLayerHeight,
&Component);
}
if( KcbInHashEntryByName )
{
CmpPopulateKcbStack((INT64)v20, KcbInHashEntryByName);
v16 = CmpPromoteSingleKeyFromKcbStacks(a1, (__int64)v20, 0);
}
else
{
v16 = CmpPromoteSingleKeyFromParentKcbAndChildKeyNode(a1, v23, 0);
}
started = v16;
if( v16 < 0 )
goto LABEL_21;
CmpKeyEnumStackNotifyPromotion((INT16 *)&result);
}
}
if( v17 == -2147483622 )
started = 0;
}
}
LABEL_21:
if( Privileges[1] )
CmSiFreeMemory(Privileges[1]);
CmpKeyEnumStackCleanup((INT64)&result);
return(unsigned int)started;
}Referenced by:
CmpSetKeySecurity