PnpReallocateResources

void __fastcall PnpReallocateResources(_DEVICE_NODE *DeviceNode){
  _ETHREAD *CurrentThread; 
  unsigned int v3; 
  _DEVICE_OBJECT *PhysicalDeviceObject; 
  int ResourceRequirementsForAssignTable; 
  unsigned int v6; 
  int BestConfiguration; 
  int started; 
  int v9; 
  int v10; 
  __int64 v11; 
  int v12; 
  _LIST_ENTRY ArbiterList; 
  INT64 RequestTable[8]; 
  char vars0[24]; 
  UINT64 RequestTableCount; 

  memset(RequestTable, 0i64, sizeof(RequestTable));
  LODWORD(RequestTableCount) = 0;
  ArbiterList = 0i64;
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  --CurrentThread->Tcb.KernelApcDisable;
  KeWaitForSingleObject((UINT64)&PnpReplaceEvent + 6016, 4, 0, 0, 0i64);
  if( (DeviceNode->Flags & 0x400) == 0 )
    goto LABEL_17;
  v3 = DeviceNode->Flags & 0x100;
  PipClearDevNodeFlags(DeviceNode, 0x100ui64);
  if( (DeviceNode->Flags & 0x800) != 0 )
  {
    PhysicalDeviceObject = DeviceNode->PhysicalDeviceObject;
    RequestTable[3] = 0i64;
    LODWORD(RequestTable[1]) |= 0x280u;
    RequestTable[0] = (INT64)PhysicalDeviceObject;
    HIDWORD(RequestTable[1]) = 4;
    ResourceRequirementsForAssignTable = PnpGetResourceRequirementsForAssignTable(
                                           (unsigned __int64)RequestTable,
                                           (unsigned __int64)vars0,
                                           (int *)&RequestTableCount);
    v6 = RequestTableCount;
    BestConfiguration = ResourceRequirementsForAssignTable;
    if( !(_DWORD)RequestTableCount )
      goto LABEL_15;
    if( DeviceNode->ResourceList )
      PnpReleaseResourcesInternal(DeviceNode);
    BestConfiguration = PnpFindBestConfiguration((INT64)RequestTable, v6, &ArbiterList);
    if( BestConfiguration < 0 || (BestConfiguration = IopCommitConfiguration(&ArbiterList), BestConfiguration < 0) )
    {
      v12 = PnpRestoreResourcesInternal(DeviceNode);
      if( v12 < 0 )
      {
        PnpUpdateRebootRequiredReason((INT64)DeviceNode->InstancePath.Buffer, v11, 0x4000i64);
        v9 = v12;
        v10 = 14;
        goto LABEL_12;
      }
    }
    else
    {
      PipClearDevNodeFlags(DeviceNode, 0xC00ui64);
      PnpBuildCmResourceLists((unsigned __int64)RequestTable, (unsigned __int64)vars0, 1);
      started = PnpStartDeviceNode(DeviceNode, 1, 1);
      BestConfiguration = started;
      if( started < 0 )
      {
        v9 = started;
        v10 = 12;
LABEL_12:
        PnpRequestDeviceRemoval((__int64)DeviceNode, 0, v10, v9);
      }
    }
    PnpFreeResourceRequirementsForAssignTable((unsigned __int64)RequestTable, (unsigned __int64)vars0);
    goto LABEL_15;
  }
  BestConfiguration = PnpRebalance((__int64)DeviceNode, 0i64, 0, 0);
LABEL_15:
  if( BestConfiguration < 0 )
  {
    PipClearDevNodeFlags(DeviceNode, 0x100ui64);
    PipSetDevNodeFlags(DeviceNode, v3);
  }
LABEL_17:
  KeReleaseSemaphore((_KSEMAPHORE *)&PnpReplaceEvent + 188, 0i64, 1i64, 0);
  KeLeaveCriticalRegion();
}

Referenced by:

PiProcessResourceRequirementsChanged