IoReportHalResourceUsage

NTSTATUS __stdcall IoReportHalResourceUsage(
        UNICODE_STRING *HalName,
        CM_RESOURCE_LIST *RawResourceList,
        CM_RESOURCE_LIST *TranslatedResourceList,
        UINT64 ResourceListSize){
  UINT64 v4; 
  _CM_RESOURCE_LIST *v7; 
  NTSTATUS v8; 
  WCHAR v9; 
  int v10; 
  PVOID v11; 
  int v12; 
  CM_RESOURCE_LIST *v13; 
  WCHAR v14; 
  PVOID v15; 
  int v16; 
  void *PoolWithTag; 
  UINT64 CreateOptions; 
  UINT64 *Disposition; 
  UINT64 *Dispositiona; 
  UINT64 NewListSize; 
  HANDLE Handle; 
  PVOID v24; 
  PVOID P; 
  UNICODE_STRING DeviceName; 
  struct _UNICODE_STRING DestinationString; 
  v4 = (unsigned int)ResourceListSize;
  Handle = 0i64;
  v24 = 0i64;
  NewListSize = 0i64;
  P = 0i64;
  v7 = TranslatedResourceList;
  DestinationString = 0i64;
  DeviceName = 0i64;
  RtlInitUnicodeString(&DestinationString, L"Hardware Abstraction Layer", (WCHAR)TranslatedResourceList);
  LODWORD(CreateOptions) = 1;
  v8 = IopCreateRegistryKeyEx(
         &Handle,
         0i64,
         &CmRegistryMachineHardwareResourceMapName,
         0x2001Fui64,
         CreateOptions,
         0i64);
  if( v8 >= 0 )
  {
    RtlInitUnicodeString(&DeviceName, L".Raw", v9);
    v10 = HeadlessTerminalAddResources(RawResourceList, (unsigned int)v4, 0, (_CM_RESOURCE_LIST **)&v24, &NewListSize);
    v11 = v24;
    v8 = v10;
    if( v10 >= 0 )
    {
      v12 = v4;
      if( v24 )
        v12 = NewListSize;
      v13 = RawResourceList;
      LODWORD(Disposition) = v12;
      if( v24 )
        v13 = (CM_RESOURCE_LIST *)v24;
      v8 = IopWriteResourceList(Handle, &DestinationString, HalName, &DeviceName, v13, (UINT64)Disposition);
      if( v8 >= 0 )
      {
        RtlInitUnicodeString(&DeviceName, L".Translated", v14);
        v8 = HeadlessTerminalAddResources(
               v7,
               (unsigned int)v4,
               1u,
               (_CM_RESOURCE_LIST **)&P,
               (UINT64 *)((char *)&NewListSize + 4));
        if( v8 >= 0 )
        {
          v15 = P;
          v16 = v4;
          if( P )
            v16 = HIDWORD(NewListSize);
          if( P )
            v7 = (_CM_RESOURCE_LIST *)P;
          LODWORD(Dispositiona) = v16;
          v8 = IopWriteResourceList(Handle, &DestinationString, HalName, &DeviceName, v7, (UINT64)Dispositiona);
          if( v15 )
            ExFreePoolWithTag(v15, 0);
        }
      }
    }
    ZwClose(Handle);
    if( v8 < 0 )
    {
      if( v11 )
        ExFreePoolWithTag(v11, 0);
    }
    else if( v11 )
    {
      IopInitHalResources = v11;
    }
    else
    {
      PoolWithTag = ExAllocatePoolWithTag(PagedPool, v4, 0x20207050ui64);
      IopInitHalResources = PoolWithTag;
      if( PoolWithTag )
        memmove((UINT8 *)PoolWithTag, (UINT8 *)RawResourceList, v4);
      else
        return -1073741670;
    }
  }
  return v8;
}

Referenced by:

HalpReportResourceUsage