IopAllocateLegacyBootResources

INT64 __fastcall IopAllocateLegacyBootResources(_INTERFACE_TYPE InterfaceType, UINT64 BusNumber){
  int v2; 
  UINT8 *v4; 
  PVOID *v5; 
  PVOID v6; 
  void *v8; 
  CM_RESOURCE_LIST *v9; 
  _DWORD *v10; 
  void *v11; 
  v2 = BusNumber;
  if( IopInitHalDeviceNode )
  {
    if( IopInitHalResources )
    {
      v11 = 0i64;
      v4 = IopCreateCmResourceList(*(INT64 *)&InterfaceType, (unsigned int)InterfaceType, (unsigned int)BusNumber, &v11);
      if( v4 )
      {
        v8 = v11;
        if( v11 )
          ExFreePoolWithTag(IopInitHalResources, 0);
        IopInitHalResources = v8;
        v9 = *(CM_RESOURCE_LIST **)(IopInitHalDeviceNode + 544);
        PipSetDevNodeFlags(IopInitHalDeviceNode, 64);
        IopAllocateBootResources(
          ArbiterRequestHalReported,
          *(DEVICE_OBJECT **)(IopInitHalDeviceNode + 32),
          (CM_RESOURCE_LIST *)v4);
        *(_QWORD *)(IopInitHalDeviceNode + 544) = IopCombineCmResourceList(v9, (CM_RESOURCE_LIST *)v4);
        if( v9 )
          ExFreePoolWithTag(v9, 0);
      }
    }
  }
  v5 = 0i64;
LABEL_5:
  v6 = IopInitReservedResourceList;
  while( v6 )
  {
    v10 = (_DWORD *)*((_QWORD *)v6 + 2);
    if( v10[1] == InterfaceType && v10[2] == v2 )
    {
      IopAllocateBootResources(ArbiterRequestPnpEnumerated, *((DEVICE_OBJECT **)v6 + 1), *((CM_RESOURCE_LIST **)v6 + 2));
      if( !*((_QWORD *)v6 + 1) )
        ExFreePoolWithTag(v10, 0);
      if( v5 )
        *v5 = *(PVOID *)v6;
      else
        IopInitReservedResourceList = *(PVOID *)v6;
      ExFreePoolWithTag(v6, 0);
      if( !v5 )
        goto LABEL_5;
      v6 = *v5;
    }
    else
    {
      v5 = (PVOID *)v6;
      v6 = *(PVOID *)v6;
    }
  }
  return 0i64;
}

Referenced by:

IopInitializeBootDrivers
PipProcessStartPhase2