CmpGetValueData

bool __fastcall CmpGetValueData(
        _HHIVE *Hive,
        __int64 ValueCell,
        _CM_KEY_VALUE *Value,
        unsigned int *realsize,
        void **Buffer,
        unsigned __int8 *Allocated,
        _HV_GET_CELL_CONTEXT *BufferContext){
  unsigned __int8 *v7; 
  unsigned __int16 v8; 
  void **v9; 
  unsigned int DataLength; 
  unsigned int v13; 
  _CELL_DATA *v14; 
  __int64 Data; 
  VOID **PoolWithTag; 
  _CELL_DATA *(__fastcall *GetCellRoutine)(_HHIVE *, unsigned int, _HV_GET_CELL_CONTEXT *); 
  char v19; 
  __int64 v20; 
  __int64 v21; 
  unsigned int v22; 
  _CELL_DATA *v23; 
  size_t v24; 
  int v25; 
  int v26; 
  _CELL_DATA *v27; 

  v7 = Allocated;
  v8 = 0;
  v9 = Buffer;
  *Allocated = 0;
  *v9 = 0i64;
  DataLength = Value->DataLength;
  v13 = DataLength + 0x80000000;
  if( DataLength < 0x80000000 )
    v13 = Value->DataLength;
  *realsize = v13;
  if( Value->DataLength < 0x80000000 )
  {
    if( Hive->Version < 4 || v13 - 16345 > 0x7FFFC026 )
    {
      v14 = Hive->GetCellRoutine(Hive, Value->Data, BufferContext);
      *v9 = v14;
      return v14 != 0;
    }
    Data = Value->Data;
    v26 = 0;
    PoolWithTag = 0i64;
    GetCellRoutine = Hive->GetCellRoutine;
    v19 = 1;
    v25 = -1;
    Allocated = (unsigned __int8 *)0xFFFFFFFFi64;
    Buffer = (void **)0xFFFFFFFFi64;
    v20 = (__int64)GetCellRoutine(Hive, Data, (_HV_GET_CELL_CONTEXT *)&v25);
    v21 = v20;
    if( !v20 )
      return 0;
    v27 = Hive->GetCellRoutine(Hive, *(unsigned int *)(v20 + 4), &Buffer);
    if( !v27 )
    {
      v19 = 0;
      goto LABEL_19;
    }
    v22 = Value->DataLength;
    PoolWithTag = ExAllocatePoolWithTag(1ui64, v22, 1685474627i64);
    if( PoolWithTag )
    {
      if( !*(_WORD *)(v21 + 2) )
      {
LABEL_18:
        Hive->ReleaseCellRoutine(Hive, (_HV_GET_CELL_CONTEXT *)&Buffer);
LABEL_19:
        Hive->ReleaseCellRoutine(Hive, (_HV_GET_CELL_CONTEXT *)&v25);
        if( v19 )
        {
          *v9 = PoolWithTag;
          *v7 = 1;
          return 1;
        }
        if( PoolWithTag )
          ExFreePoolWithTag(PoolWithTag, 0);
        return 0;
      }
      while( 1 )
      {
        v23 = Hive->GetCellRoutine(Hive, v27->u.KeyList[v8], &Allocated);
        if( !v23 )
          break;
        v24 = v22;
        if( v22 > 0x3FD8 )
          v24 = 16344;
        memmove(&PoolWithTag[2043 * v8], v23, v24);
        v22 -= 16344;
        Hive->ReleaseCellRoutine(Hive, (_HV_GET_CELL_CONTEXT *)&Allocated);
        if( ++v8 >= *(_WORD *)(v21 + 2) )
          goto LABEL_18;
      }
    }
    v19 = 0;
    goto LABEL_18;
  }
  if( Hive->GetCellRoutine(Hive, ValueCell, BufferContext) )
  {
    *v9 = &Value->Data;
    return 1;
  }
  return 0;
}

Referenced by:

CmAddLogForAction
CmQueryMultipleValueForLayeredKey
CmQueryMultipleValueKey
CmpCommitSetValueKeyUoW
CmpCompareNewValueDataAgainstKCBCache
CmpCopyValue
CmpFindTagIndex
CmpGetSymbolicLinkTarget
CmpGetValueForAudit
CmpLightWeightPrepareSetValueKeyUoW
CmpPreserveSystemHiveData
CmpQueryKeyValueData
CmpValueToData