IopChildToRootTranslation

INT64 __fastcall IopChildToRootTranslation(
        _DEVICE_NODE *DeviceNode,
        _INTERFACE_TYPE InterfaceType,
        UINT64 BusNumber,
        _ARBITER_REQUEST_SOURCE ArbiterRequestSource,
        _CM_PARTIAL_RESOURCE_DESCRIPTOR *Source,
        _CM_PARTIAL_RESOURCE_DESCRIPTOR **Target){
  unsigned int v6; 
  unsigned int v7; 
  char v10; 
  _CM_PARTIAL_RESOURCE_DESCRIPTOR *PoolWithTag; 
  _CM_PARTIAL_RESOURCE_DESCRIPTOR *v12; 
  __int64 v13; 
  unsigned int v14; 
  _DEVICE_NODE *v15; 
  __int64 *v16; 
  __int64 v17; 
  int v18; 
  _CM_PARTIAL_RESOURCE_DESCRIPTOR *v19; 
  unsigned int v21; 
  bool v22; 
  v21 = BusNumber;
  v6 = 0;
  v7 = BusNumber;
  v10 = 0;
  v22 = ArbiterRequestSource == ArbiterRequestHalReported;
  PoolWithTag = (_CM_PARTIAL_RESOURCE_DESCRIPTOR *)ExAllocatePoolWithTag(PagedPool, 0x14ui64, 0x20207050ui64);
  if( !PoolWithTag )
    return 3221225626i64;
  v12 = (_CM_PARTIAL_RESOURCE_DESCRIPTOR *)ExAllocatePoolWithTag(PagedPool, 0x14ui64, 0x20207050ui64);
  if( !v12 )
  {
    ExFreePoolWithTag(PoolWithTag, 0);
    return 3221225626i64;
  }
  *(_OWORD *)PoolWithTag = *(_OWORD *)Source;
  *((_DWORD *)PoolWithTag + 4) = *((_DWORD *)Source + 4);
  if( DeviceNode )
  {
    v13 = *((_QWORD *)DeviceNode + 4);
  }
  else
  {
    DeviceNode = (_DEVICE_NODE *)IopFindLegacyBusDeviceNode(InterfaceType, v7);
    v13 = 0i64;
  }
  while( 1 )
  {
    while( 1 )
    {
      if( !DeviceNode || v10 )
      {
        *Target = PoolWithTag;
        goto LABEL_22;
      }
      if( DeviceNode != IopRootDeviceNode || v22 )
        break;
      v22 = 1;
      DeviceNode = (_DEVICE_NODE *)IopFindLegacyBusDeviceNode(InterfaceType, v21);
      if( DeviceNode == v15 && InterfaceType == Internal )
        DeviceNode = (_DEVICE_NODE *)IopFindLegacyBusDeviceNode(v14, 0);
    }
    v16 = (__int64 *)*((_QWORD *)DeviceNode + 63);
    if( v16 != (__int64 *)((char *)DeviceNode + 504) )
    {
      while( *((_BYTE *)v16 + 16) != *(_BYTE *)Source )
      {
        v16 = (__int64 *)*v16;
        if( v16 == (__int64 *)((char *)DeviceNode + 504) )
          goto LABEL_12;
      }
      v17 = v16[3];
      if( v17 )
        break;
    }
LABEL_12:
    DeviceNode = (_DEVICE_NODE *)*((_QWORD *)DeviceNode + 2);
  }
  v18 = (*(__int64(__fastcall **)(_QWORD, _CM_PARTIAL_RESOURCE_DESCRIPTOR *, _QWORD, _QWORD, _QWORD, __int64, _CM_PARTIAL_RESOURCE_DESCRIPTOR *))(v17 + 32))(
          *(_QWORD *)(v17 + 8),
          PoolWithTag,
          0i64,
          0i64,
          0i64,
          v13,
          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