IopQueryResourceHandlerInterface

VOID __fastcall IopQueryResourceHandlerInterface(
        _RESOURCE_HANDLER_TYPE HandlerType,
        _DEVICE_OBJECT *DeviceObject,
        UINT8 ResourceType,
        VOID **Interface){
  _DEVOBJ_EXTENSION *DeviceObjectExtension; 
  __int64 v6; 
  __int32 v9; 
  GUID v10; 
  unsigned __int16 v11; 
  VOID **PoolWithTag; 
  VOID **v13; 
  NTSTATUS v14; 
  __int32 v15; 
  __int32 v16; 
  __int32 v17; 
  bool v18; 
  _IO_STACK_LOCATION TopStackLocation; 
  GUID v20; 

  DeviceObjectExtension = DeviceObject->DeviceObjectExtension;
  v6 = ResourceType;
  v20 = 0i64;
  if( (_DRIVER_OBJECT *)*((_QWORD *)DeviceObjectExtension->DeviceNode + 54) != DeviceObject->DriverObject
    && (DeviceObject->Flags & 0x1000) != 0 )
  {
    v9 = HandlerType - 1;
    if( v9 )
    {
      v15 = v9 - 1;
      if( v15 )
      {
        if( v15 != 1 )
          return;
        v10 = GUID_LEGACY_DEVICE_DETECTION_STANDARD;
        v11 = 40;
      }
      else
      {
        v10 = GUID_ARBITER_INTERFACE_STANDARD;
        v11 = 48;
      }
    }
    else
    {
      v10 = GUID_TRANSLATOR_INTERFACE_STANDARD;
      v11 = 52;
    }
    v20 = v10;
    PoolWithTag = ExAllocatePoolWithTag(1ui64, v11, 538996816i64);
    v13 = PoolWithTag;
    if( PoolWithTag )
    {
      memset(PoolWithTag, 0i64, v11);
      *(_WORD *)v13 = v11;
      memset(&TopStackLocation, 0i64, sizeof(TopStackLocation));
      *(_WORD *)&TopStackLocation.MajorFunction = 2075;
      LOWORD(TopStackLocation.Parameters.Options) = v11;
      TopStackLocation.Parameters.SecurityContext = (_IO_SECURITY_CONTEXT *)&v20;
      *((_WORD *)v13 + 1) = 0;
      HIWORD(TopStackLocation.Parameters.Options) = 0;
      *(_QWORD *)&TopStackLocation.Parameters.FileAttributes = v13;
      *(_QWORD *)&TopStackLocation.Parameters.EaLength = v6;
      v14 = IopSynchronousCall(DeviceObject, &TopStackLocation, 3221225659i64, 0i64, 0i64);
      if( v14 < 0 )
      {
LABEL_7:
        ExFreePoolWithTag(v13, 0);
        return;
      }
      v16 = HandlerType - 1;
      if( v16 )
      {
        v17 = v16 - 1;
        if( v17 && v17 != 1 )
          goto LABEL_7;
        v18 = v13[4] == 0i64;
      }
      else
      {
        if( !v13[4] )
          goto LABEL_20;
        v18 = v13[5] == 0i64;
      }
      if( !v18 )
      {
LABEL_14:
        if( v14 < 0 )
          goto LABEL_7;
        *Interface = v13;
        return;
      }
LABEL_20:
      v14 = -1073741823;
      goto LABEL_14;
    }
  }
}

Referenced by:

IoTranslateBusAddress
IopDuplicateDetection
IopSetupArbiterAndTranslators