HalpQueryResources

NTSTATUS __stdcall HalpQueryResources(DEVICE_OBJECT *DeviceObject, CM_RESOURCE_LIST **Resources){
  __int64 v2; 
  unsigned int v3; 
  int v5; 
  NTSTATUS result; 
  _DWORD *v7; 
  CM_RESOURCE_LIST *PoolWithTag; 
  CM_RESOURCE_LIST *v9; 
  __int64 v10; 
  __int64 v11; 
  __int16 v12; 
  PVOID P; 
  v2 = *((_QWORD *)DeviceObject + 8);
  v3 = 0;
  P = 0i64;
  v5 = *(_DWORD *)(v2 + 32);
  if( v5 != 129 )
    return(unsigned int)(v5 - 130) > 1 ? 0xC00000BB : 0;
  result = HalpQueryAcpiResourceRequirements((IO_RESOURCE_REQUIREMENTS_LIST **)&P);
  if( result >= 0 )
  {
    v7 = P;
    PoolWithTag = (CM_RESOURCE_LIST *)ExAllocatePoolWithTag(
                                        PagedPool,
                                        (unsigned int)(20 * *((_DWORD *)P + 9) + 39),
                                        0x206C6148ui64);
    v9 = PoolWithTag;
    if( PoolWithTag )
    {
      *((_QWORD *)PoolWithTag + 2) = 0i64;
      *((_QWORD *)PoolWithTag + 3) = 0i64;
      *((_QWORD *)PoolWithTag + 4) = 0i64;
      *((_DWORD *)PoolWithTag + 2) = -1;
      *(_DWORD *)PoolWithTag = 1;
      *((_DWORD *)PoolWithTag + 1) = 15;
      *((_DWORD *)PoolWithTag + 3) = 65537;
      *((_DWORD *)PoolWithTag + 4) = v7[9];
      if( v7[9] )
      {
        do
        {
          v10 = 8i64 * v3;
          v11 = 5i64 * v3;
          *((_BYTE *)v9 + 4 * v11 + 20) = BYTE1(v7[v10 + 10]);
          *((_BYTE *)v9 + 4 * v11 + 21) = BYTE2(v7[v10 + 10]);
          *((_WORD *)v9 + 2 * v11 + 11) = v7[v10 + 11];
          ++v3;
          *((_WORD *)v9 + 2 * v11 + 12) = (unsigned __int8)HalConvertDeviceIdtToIrql((unsigned int)v7[v10 + 12]);
          *((_DWORD *)v9 + v11 + 7) = v7[v10 + 12];
          v12 = HIWORD(v7[v10 + 14]);
          *(_QWORD *)((char *)v9 + 4 * v11 + 32) = -1i64;
          *((_WORD *)v9 + 2 * v11 + 13) = v12;
        }
        while( v3 < v7[9] );
      }
      *Resources = v9;
      ExFreePoolWithTag(v7, 0);
      return 0;
    }
    else
    {
      ExFreePoolWithTag(v7, 0);
      return -1073741670;
    }
  }
  return result;
}

Referenced by:

HalpDispatchPnp