CmpIsLoadType

INT64 __fastcall CmpIsLoadType(
        _HHIVE *Hive,
        INT64 Cell,
        _CM_SERVICE_LOAD_TYPE LoadType,
        _UNICODE_STRING *HardwareConfigurationNumber,
        _CM_KEY_NODE *ManufacturingServicesNode,
        UINT64 *Flags){
  char v7; 
  unsigned int ValueByName; 
  _HHIVE *v9; 
  _CELL_DATA *(__fastcall *GetCellRoutine)(_HHIVE *, unsigned int, _HV_GET_CELL_CONTEXT *); 
  INT64 result; 
  UINT64 *v12; 
  _CM_KEY_VALUE *v13; 
  _CELL_DATA *v14; 
  void(__fastcall *ReleaseCellRoutine)(_HHIVE *, _HV_GET_CELL_CONTEXT *); 
  _WCHAR *NodeName; 
  _WCHAR *v17; 
  unsigned int SubKeyByName; 
  __int64 v19; 
  unsigned int v20; 
  _CELL_DATA *v21; 
  _CELL_DATA *v22; 
  unsigned int v23; 
  __int64 *v24; 
  unsigned int v25; 
  __int64 v26; 
  int v27[2]; 
  int v28[4]; 
  _UNICODE_STRING DestinationString; 
  int v30; 
  int v31; 
  _CM_SERVICE_LOAD_TYPE v32; 
  _UNICODE_STRING *realsize; 
  __int64 v34; 
  __int64 v35; 
  _HV_GET_CELL_CONTEXT CellContext; 
  __int64 v37; 

  realsize = HardwareConfigurationNumber;
  v32 = LoadType;
  v28[1] = 0;
  v7 = 0;
  ManufacturingServicesNode = (_CM_KEY_NODE *)0xFFFFFFFFi64;
  v28[0] = -1;
  v28[2] = -1;
  ValueByName = -1;
  v28[3] = 0;
  v9 = 0i64;
  v30 = -1;
  v31 = 0;
  CellContext.Cell = -1;
  *(_DWORD *)&CellContext.BinContext._bf_0 = 0;
  v35 = 0xFFFFFFFFi64;
  v27[0] = -1;
  v27[1] = 0;
  GetCellRoutine = Hive->GetCellRoutine;
  LODWORD(realsize) = 0;
  DestinationString = 0i64;
  LOWORD(v32) = 0;
  result = (__int64)GetCellRoutine(Hive, Cell, (_HV_GET_CELL_CONTEXT *)v28);
  v37 = result;
  if( result )
  {
    v12 = Flags;
    if( Flags && v34 )
    {
      NodeName = CmpGetNodeName((INT64)Hive, result, (UINT16 *)&v32);
      v17 = NodeName;
      if( NodeName )
      {
        if( RtlInitUnicodeStringEx(&DestinationString, NodeName) >= 0 )
        {
          SubKeyByName = CmpFindSubKeyByName((__int64)v12, v34, &DestinationString);
          if( SubKeyByName != -1 )
          {
            v19 = ((__int64(__fastcall *)(UINT64 *, _QWORD, int *))v12[1])(v12, SubKeyByName, &v30);
            if( v19 )
            {
              v9 = (_HHIVE *)v12;
              ValueByName = CmpFindValueByName((__int64)v12, v19, (__int64)&CmpStartString);
              ((void(__fastcall *)(UINT64 *, int *))v12[2])(v12, &v30);
            }
          }
        }
        Hive->Free(v17, (unsigned __int16)v32);
        if( ValueByName != -1 )
          goto LABEL_4;
      }
      v20 = CmpFindValueByName((__int64)Hive, v37, (__int64)L"\b\n");
      if( v20 == -1 )
        goto LABEL_8;
      v21 = Hive->GetCellRoutine(Hive, v20, &v35);
      if( !v21 )
        goto LABEL_8;
      v22 = CmpValueToData(Hive, v20, (_CM_KEY_VALUE *)v21, (UINT *)&realsize, &CellContext);
      Hive->ReleaseCellRoutine(Hive, (_HV_GET_CELL_CONTEXT *)&v35);
      if( !v22 )
        goto LABEL_8;
      v23 = v22->u.KeyList[0];
      Hive->ReleaseCellRoutine(Hive, &CellContext);
      v24 = &CmpDriverWildcardString;
      if( (v23 & 0xB) == 0 )
        v24 = &CmpServiceWildcardString;
      v25 = CmpFindSubKeyByName((__int64)v12, v34, (_UNICODE_STRING *)v24);
      if( v25 != -1 )
      {
        v26 = ((__int64(__fastcall *)(UINT64 *, _QWORD, int *))v12[1])(v12, v25, &v30);
        if( v26 )
        {
          v9 = (_HHIVE *)v12;
          ValueByName = CmpFindValueByName((__int64)v12, v26, (__int64)&CmpStartString);
          ((void(__fastcall *)(UINT64 *, int *))v12[2])(v12, &v30);
          if( ValueByName != -1 )
            goto LABEL_4;
        }
      }
    }
    v9 = Hive;
    ValueByName = CmpFindValueByName((__int64)Hive, v37, (__int64)&CmpStartString);
    if( ValueByName != -1 )
    {
LABEL_4:
      v13 = (_CM_KEY_VALUE *)v9->GetCellRoutine(v9, ValueByName, (_HV_GET_CELL_CONTEXT *)v27);
      if( v13 )
      {
        v14 = CmpValueToData(
                v9,
                ValueByName,
                v13,
                (UINT *)&realsize,
                (_HV_GET_CELL_CONTEXT *)&ManufacturingServicesNode);
        v9->ReleaseCellRoutine(v9, (_HV_GET_CELL_CONTEXT *)v27);
        if( v14 )
        {
          ReleaseCellRoutine = v9->ReleaseCellRoutine;
          if( v14->u.KeyList[0] == 1 )
          {
            ReleaseCellRoutine(v9, (_HV_GET_CELL_CONTEXT *)&ManufacturingServicesNode);
            v7 = 1;
          }
          else
          {
            ReleaseCellRoutine(v9, (_HV_GET_CELL_CONTEXT *)&ManufacturingServicesNode);
          }
        }
      }
    }
LABEL_8:
    result = ((__int64(__fastcall *)(_HHIVE *, int *))Hive->ReleaseCellRoutine)(Hive, v28);
    LOBYTE(result) = v7;
  }
  return result;
}

Referenced by:

CmpFindDrivers