CmpSplitLeaf
UINT64 __stdcall CmpSplitLeaf(_HHIVE *Hive, UINT64 RootCell, UINT64 RootSelect, HSTORAGE_TYPE Type){
VOID *v4;
unsigned int v5;
_CELL_DATA *(__fastcall *GetCellRoutine)(_HHIVE *, unsigned int, _HV_GET_CELL_CONTEXT *);
__int64 v8;
INT64 v9;
_CELL_DATA *v10;
_CELL_DATA *v11;
unsigned __int16 Flags;
unsigned __int16 v13;
unsigned __int16 v14;
UINT8 *v15;
int v16;
int v17;
unsigned int v18;
UINT8 *v19;
_WORD *v20;
int v21;
unsigned int BugCheckParameter3;
unsigned int BugCheckParameter3a;
VOID *CellAddress;
INT64 v26;
_HV_GET_CELL_CONTEXT CellAddressContext;
INT64 v28;
int v29[2];
__int64 v30;
unsigned __int16 v31;
v26 = 0xFFFFFFFFi64;
v29[0] = -1;
v4 = 0i64;
CellAddressContext.Cell = -1;
v5 = RootCell;
v29[1] = 0;
*(_DWORD *)&CellAddressContext.BinContext = 0;
GetCellRoutine = Hive->GetCellRoutine;
v8 = (unsigned int)RootSelect;
CellAddress = 0i64;
v9 = (__int64)GetCellRoutine(Hive, RootCell, (_HV_GET_CELL_CONTEXT *)&v26);
if( !v9 )
return 0xFFFFFFFFi64;
if( *(_WORD *)(v9 + 2) == 0xFFFF
|| (BugCheckParameter3 = *(_DWORD *)(v9 + 4 * v8 + 4),
v10 = Hive->GetCellRoutine(Hive, BugCheckParameter3, v29),
(v11 = v10) == 0i64) )
{
LABEL_24:
if( v9 )
Hive->ReleaseCellRoutine(Hive, (_HV_GET_CELL_CONTEXT *)&v26);
return 0xFFFFFFFFi64;
}
Flags = v10->u.KeyNode.Flags;
v13 = Flags >> 1;
v14 = Flags - (Flags >> 1);
v31 = v13;
if( ((v11->u.KeyNode.Signature - 26220) & 0xFDFF) != 0 )
{
LODWORD(v28) = 4;
v30 = 4i64;
}
else
{
v28 = 8i64;
v30 = 8i64;
}
if( !HvMarkCellDirty((UINT64)Hive, BugCheckParameter3, 0) )
{
LABEL_22:
Hive->ReleaseCellRoutine(Hive, (_HV_GET_CELL_CONTEXT *)v29);
if( v4 )
Hive->ReleaseCellRoutine(Hive, &CellAddressContext);
goto LABEL_24;
}
BugCheckParameter3a = HvAllocateCell(Hive, (unsigned int)v28 * v14 + 5, Type, &CellAddress, &CellAddressContext);
if( BugCheckParameter3a == -1 )
{
v4 = CellAddress;
goto LABEL_22;
}
v15 = (UINT8 *)CellAddress;
*(_WORD *)CellAddress = v11->u.KeyNode.Signature;
v16 = *(_DWORD *)(v9 - 4);
if( ((-8 - 4 * *(unsigned __int16 *)(v9 + 2) - v16) & 0xFFFFFFFC) < 4 )
{
v17 = -4 - v16;
Hive->ReleaseCellRoutine(Hive, (_HV_GET_CELL_CONTEXT *)&v26);
v28 = 0i64;
v18 = HvReallocateCell((UINT64)Hive, v5, (unsigned int)(v17 + 4), 0, &v28, &v26);
if( v18 == -1 )
{
Hive->ReleaseCellRoutine(Hive, &CellAddressContext);
v4 = 0i64;
HvFreeCell((UINT64)Hive, BugCheckParameter3a);
v9 = v28;
goto LABEL_22;
}
if( v5 != v18 )
{
HvFreeCell((UINT64)Hive, v5);
v5 = v18;
}
v15 = (UINT8 *)CellAddress;
v9 = v28;
}
if( ((v11->u.KeyNode.Signature - 26220) & 0xFDFF) != 0 )
v19 = (UINT8 *)&v11->u.KeyIndex.List[v31];
else
v19 = (UINT8 *)&v11->u.KeyIndex.List[2 * v31];
memmove(v15 + 4, v19, v30 * v14);
v20 = CellAddress;
v11->u.KeyNode.Flags = v31;
v20[1] = v14;
Hive->ReleaseCellRoutine(Hive, (_HV_GET_CELL_CONTEXT *)v29);
Hive->ReleaseCellRoutine(Hive, &CellAddressContext);
v21 = *(unsigned __int16 *)(v9 + 2);
if( (unsigned int)v8 < v21 - 1 )
{
memmove(
(UINT8 *)(v9 + 4 * ((unsigned int)(v8 + 2) + 1i64)),
(UINT8 *)(v9 + 4 * ((unsigned int)(v8 + 1) + 1i64)),
4i64 * (unsigned int)(v21 - v8 - 1));
LOWORD(v21) = *(_WORD *)(v9 + 2);
}
*(_WORD *)(v9 + 2) = v21 + 1;
*(_DWORD *)(v9 + 4i64 * (unsigned int)(v8 + 1) + 4) = BugCheckParameter3a;
Hive->ReleaseCellRoutine(Hive, (_HV_GET_CELL_CONTEXT *)&v26);
return v5;
}Referenced by:
CmpSelectLeaf