IopChildToRootTranslation

NTSTATUS __stdcall IopChildToRootTranslation(
        _DEVICE_NODE *DeviceNode,
        _INTERFACE_TYPE InterfaceType,
        UINT64 BusNumber,
        _ARBITER_REQUEST_SOURCE ArbiterRequestSource,
        PCM_PARTIAL_RESOURCE_DESCRIPTOR Source,
        PCM_PARTIAL_RESOURCE_DESCRIPTOR *Target){
  NTSTATUS v6; 
  unsigned int v7; 
  char v10; 
  VOID **PoolWithTag; 
  VOID **v12; 
  _DEVICE_OBJECT *PhysicalDeviceObject; 
  _INTERFACE_TYPE v14; 
  _DEVICE_NODE *v15; 
  _LIST_ENTRY *Flink; 
  _LIST_ENTRY *Blink; 
  int v18; 
  VOID **v19; 
  unsigned int BusNumbera; 
  bool v22; 

  BusNumbera = BusNumber;
  v6 = 0;
  v7 = BusNumber;
  v10 = 0;
  v22 = ArbiterRequestSource == ArbiterRequestHalReported;
  PoolWithTag = ExAllocatePoolWithTag(1ui64, 0x14ui64, 538996816i64);
  if( !PoolWithTag )
    return -1073741670;
  v12 = ExAllocatePoolWithTag(1ui64, 0x14ui64, 538996816i64);
  if( !v12 )
  {
    ExFreePoolWithTag(PoolWithTag, 0);
    return -1073741670;
  }
  *(_CM_PARTIAL_RESOURCE_DESCRIPTOR *)PoolWithTag = *Source;
  *((_DWORD *)PoolWithTag + 4) = *(_DWORD *)&Source[1].Type;
  if( DeviceNode )
  {
    PhysicalDeviceObject = DeviceNode->PhysicalDeviceObject;
  }
  else
  {
    DeviceNode = IopFindLegacyBusDeviceNode(InterfaceType, v7);
    PhysicalDeviceObject = 0i64;
  }
  while( 1 )
  {
    while( 1 )
    {
      if( !DeviceNode || v10 )
      {
        *Target = (PCM_PARTIAL_RESOURCE_DESCRIPTOR)PoolWithTag;
        goto LABEL_22;
      }
      if( DeviceNode != (_DEVICE_NODE *)*(&PnpReplaceEvent + 831) || v22 )
        break;
      v22 = 1;
      DeviceNode = IopFindLegacyBusDeviceNode(InterfaceType, BusNumbera);
      if( DeviceNode == v15 && InterfaceType == Internal )
        DeviceNode = IopFindLegacyBusDeviceNode(v14, 0i64);
    }
    Flink = DeviceNode->DeviceTranslatorList.Flink;
    if( Flink != &DeviceNode->DeviceTranslatorList )
    {
      while( LOBYTE(Flink[1].Flink) != Source->Type )
      {
        Flink = Flink->Flink;
        if( Flink == &DeviceNode->DeviceTranslatorList )
          goto LABEL_12;
      }
      Blink = Flink[1].Blink;
      if( Blink )
        break;
    }
LABEL_12:
    DeviceNode = DeviceNode->Parent;
  }
  v18 = ((__int64(__fastcall *)(_LIST_ENTRY *, VOID **, _QWORD, _QWORD, _QWORD, _DEVICE_OBJECT *, VOID **))Blink[2].Flink)(
          Blink->Blink,
          PoolWithTag,
          0i64,
          0i64,
          0i64,
          PhysicalDeviceObject,
          v12);
  v6 = v18;
  v19 = PoolWithTag;
  if( v18 >= 0 )
  {
    v10 = 0;
    PoolWithTag = v12;
    if( v18 == 288 )
      v10 = 1;
    v12 = v19;
    goto LABEL_12;
  }
  ExFreePoolWithTag(PoolWithTag, 0);
LABEL_22:
  ExFreePoolWithTag(v12, 0);
  return v6;
}

Referenced by:

PnpBuildCmResourceList