CmpAddToLeaf
INT64 __fastcall CmpAddToLeaf(UINT64 a1, UINT64 a2, INT64 r8_0, UNICODE_STRING *a4){
unsigned int v4;
unsigned int v6;
__int64 v7;
INT64 Child;
int v9;
unsigned int v10;
unsigned int v11;
_WORD *v12;
unsigned int v13;
int SubKeyInLeaf;
__int64 v15;
int v16;
int v17;
UINT64 v18;
UINT8 *v19;
UINT8 *v20;
int FastLeafHintForUnicodeString;
__int64 a5;
INT64 v24;
INT64 v25[2];
int v26;
v26 = r8_0;
v24 = 0xFFFFFFFFi64;
LODWORD(a5) = 0;
v4 = a2;
v6 = 0;
if( !HvMarkCellDirty(a1, a2, 0) )
return 0xFFFFFFFFi64;
v7 = (*(__int64(__fastcall **)(UINT64, _QWORD, INT64 *))(a1 + 8))(a1, v4, &v24);
Child = v7;
if( !v7 )
return 0xFFFFFFFFi64;
v9 = *(unsigned __int16 *)(v7 + 2);
if( (_WORD)v9 == 0xFFFF )
goto LABEL_33;
v10 = -4 - *(_DWORD *)(Child - 4);
if( *(_WORD *)Child == 26988 )
{
v11 = 4;
v12 = 0i64;
v13 = v10 - 4 * v9 - 4;
}
else
{
v12 = (_WORD *)Child;
v11 = 8;
v13 = v10 - 8 * v9 - 4;
}
v6 = v4;
if( v13 < v11 )
{
(*(void(__fastcall **)(UINT64, INT64 *))(a1 + 16))(a1, &v24);
v25[0] = 0i64;
if( (v10 >> 1) + v10 >= v10 + v11 )
v11 = v10 >> 1;
v6 = HvReallocateCell(a1, v4, v10 + v11, 0, v25, &v24);
if( v6 == -1 )
return 0xFFFFFFFFi64;
Child = v25[0];
if( v12 )
v12 = (_WORD *)v25[0];
}
SubKeyInLeaf = CmpFindSubKeyInLeaf(a1, (__int16 *)Child, a4, 0i64, (__int64)&a5);
v15 = (unsigned int)SubKeyInLeaf;
if( SubKeyInLeaf < 0 || (_DWORD)a5 != -1 )
{
LABEL_33:
(*(void(__fastcall **)(UINT64, INT64 *))(a1 + 16))(a1, &v24);
if( v6 != v4 )
HvFreeCell(a1, v6);
return 0xFFFFFFFFi64;
}
if( SubKeyInLeaf != *(unsigned __int16 *)(Child + 2) )
{
v16 = CmpCompareInIndex((_HHIVE *)a1, a4, 0i64, (_CM_KEY_INDEX *)(unsigned int)SubKeyInLeaf, (UINT *)Child);
if( v16 != 2 )
{
if( v16 > 0 )
v15 = (unsigned int)(v15 + 1);
v17 = *(unsigned __int16 *)(Child + 2);
if( (_DWORD)v15 != v17 )
{
if( v12 )
{
v18 = 8i64 * ((unsigned __int16)v12[1] - (unsigned int)v15);
v19 = (UINT8 *)&v12[4 * v15 + 2];
v20 = (UINT8 *)&v12[4 * (unsigned int)(v15 + 1) + 2];
}
else
{
v18 = 4i64 * (unsigned int)(v17 - v15);
v19 = (UINT8 *)(Child + 4 * ((unsigned int)v15 + 1i64));
v20 = (UINT8 *)(Child + 4 * ((unsigned int)(v15 + 1) + 1i64));
}
memmove(v20, v19, v18);
}
goto LABEL_24;
}
goto LABEL_33;
}
LABEL_24:
if( v12 )
{
*(_DWORD *)&v12[4 * v15 + 2] = v26;
if( *v12 == 26732 )
FastLeafHintForUnicodeString = CmpHashUnicodeComponent(a4);
else
FastLeafHintForUnicodeString = CmpGenerateFastLeafHintForUnicodeString(&a4->Length);
*(_DWORD *)&v12[4 * v15 + 4] = FastLeafHintForUnicodeString;
}
else
{
*(_DWORD *)(Child + 4 * v15 + 4) = v26;
}
++*(_WORD *)(Child + 2);
(*(void(__fastcall **)(UINT64, INT64 *))(a1 + 16))(a1, &v24);
if( v6 != v4 )
HvFreeCell(a1, v4);
return v6;
}Referenced by:
CmpAddSubKeyToList