IoTranslateBusAddress

UINT8 __stdcall IoTranslateBusAddress(
        _INTERFACE_TYPE InterfaceType,
        UINT64 BusNumber,
        _LARGE_INTEGER BusAddress,
        UINT64 *AddressSpace,
        _LARGE_INTEGER *TranslatedAddress){
  int v5; 
  UINT64 *v6; 
  unsigned int v7; 
  int v9; 
  __int16 v10; 
  __int64 *LegacyBusDeviceNode; 
  unsigned __int8 v12; 
  char ResourceHandlerInfo; 
  PVOID v14; 
  int v15; 
  PVOID P; 
  __int64 v18; 
  UINT64 *v19; 
  __int128 v20; 
  int v21; 
  __int128 v22; 
  int v23; 
  v5 = 0;
  v19 = AddressSpace;
  v23 = 0;
  v6 = AddressSpace;
  P = 0i64;
  v7 = BusNumber;
  v18 = 0i64;
  v21 = 0;
  v22 = 0i64;
  if( KeGetCurrentIrql() || !IopRootDeviceNode )
  {
    *TranslatedAddress = BusAddress;
    return 1;
  }
  v9 = *(_DWORD *)AddressSpace;
  if( *(_DWORD *)AddressSpace )
  {
    if( v9 != 1 )
      return 0;
    v10 = 1;
  }
  else
  {
    v10 = 0;
    LOBYTE(v9) = 3;
  }
  WORD1(v20) = v10;
  LOBYTE(v20) = v9;
  BYTE1(v20) = 3;
  *(_LARGE_INTEGER *)((char *)&v20 + 4) = BusAddress;
  HIDWORD(v20) = 1;
  PpDevNodeLockTree(0);
  LegacyBusDeviceNode = IopFindLegacyBusDeviceNode(InterfaceType, v7);
  if( LegacyBusDeviceNode == IopRootDeviceNode )
  {
LABEL_21:
    PpDevNodeUnlockTree(0);
    if( (unsigned __int8)v20 != 3 && (unsigned __int8)v20 != 7 )
    {
      if( (unsigned __int8)v20 != 1 )
        return 0;
      v5 = 1;
    }
    *(_DWORD *)v6 = v5;
    *TranslatedAddress = *(_LARGE_INTEGER *)((char *)&v20 + 4);
    return 1;
  }
  v12 = v20;
  while( 1 )
  {
    ResourceHandlerInfo = IopFindResourceHandlerInfo(1, LegacyBusDeviceNode, v12, &v18);
    if( !ResourceHandlerInfo )
    {
      if( (int)IopQueryResourceHandlerInterface(1, LegacyBusDeviceNode[4], v12, &P) >= 0 )
      {
        v14 = P;
        goto LABEL_14;
      }
LABEL_18:
      v12 = v20;
      goto LABEL_19;
    }
    if( v18 )
      break;
LABEL_19:
    LegacyBusDeviceNode = (__int64 *)LegacyBusDeviceNode[2];
    if( LegacyBusDeviceNode == IopRootDeviceNode )
    {
LABEL_20:
      v6 = v19;
      goto LABEL_21;
    }
  }
  v14 = *(PVOID *)(v18 + 24);
LABEL_14:
  v15 = (*((__int64(__fastcall **)(_QWORD, __int128 *, _QWORD, _QWORD, _QWORD, _QWORD, __int128 *))v14 + 4))(
          *((_QWORD *)v14 + 1),
          &v20,
          0i64,
          0i64,
          0i64,
          0i64,
          &v22);
  if( !ResourceHandlerInfo )
  {
    (*((void(__fastcall **)(_QWORD))v14 + 3))(*((_QWORD *)v14 + 1));
    ExFreePoolWithTag(v14, 0);
  }
  if( v15 >= 0 )
  {
    v21 = v23;
    v20 = v22;
    if( v15 == 288 )
      goto LABEL_20;
    goto LABEL_18;
  }
  PpDevNodeUnlockTree(0);
  return 0;
}

Referenced by:

No references.