使用 IOCTL_VIDEO_QUERY_AVAIL_MODES 获取视频适配器支持的模式列表

问题描述

我正在尝试从视频适配器驱动程序中查询支持的模式列表:

// IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES - Retrieve the count of modes on the display adapter
// Input-Buffer: none
// Output-Buffer: VIDEO_NUM_MODES

VIDEO_NUM_MODES videoNumModes{};

// Send the IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES control code directly to the device driver
ULONG bytesReturned{};
if (::DeviceIoControl(
        hDevice,// Handle to the display adapter device
        IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES,// IOCTL code
        nullptr,// No input param struct
        &videoNumModes,sizeof videoNumModes,// Address/size of output param struct
        &bytesReturned,// Bytes returned in the output param struct
        nullptr))                               // Optional OVERLAPPED structure
{
    // Allocate a buffer to receive the array of supported modes
    const auto bufferSizeInBytes = videoNumModes.NumModes * videoNumModes.ModeinformationLength;
    pVideoModeInfo = new VIDEO_MODE_informatION[videoNumModes.NumModes];

    // IOCTL_VIDEO_QUERY_AVAIL_MODES - Retrieve the array of supported modes
    // Input-Buffer: none
    // Output-Buffer: <allocated buffer>

    // Send the IOCTL_VIDEO_QUERY_AVAIL_MODES control code directly to the device driver
    if (::DeviceIoControl(
            hDevice,IOCTL_VIDEO_QUERY_AVAIL_MODES,nullptr,pVideoModeInfo,bufferSizeInBytes,&bytesReturned,nullptr))

在 LastError 设置为 FALSE (0x1) 的第一次 DeviceIoControl 调用中,我得到 ERROR_INVALID_FUNCTION

我成功地使用相同的代码在我的驱动程序中调用自定义 IOCTL 内容,所以我相信实现本身是合理的。但是,当我打开设备的句柄时,我应该使用一个字符串,其中包含有关我将要使用的设备和接口的信息。我为我的自定义 IOCTL 接口定义了 GUID,并使用类似以下内容发送自定义 IOCTL 命令:

hDevice = ::CreateFileW(L"\\\\?\\ROOT#disPLAY#0000#{5f2f2b485bbd-5201-f1f9-4520-30f4bf353599}",...);

但是 IOCTL_VIDEO_QUERY_NUM_AVAIL_MODESIOCTL_VIDEO_QUERY_AVAIL_MODES 的文档没有提到它们属于哪个界面 (GUID)。

我假设我必须用 GUID_DEVINTERFACE_DISPLAY_ADAPTER 接口打开适配器设备,但我在第一次 DeviceIoControl 调用中得到不正确的函数。如果我使用 GUID_DEVINTERFACE_MONITOR 打开适配器或其显示器之一,结果相同。

我已经在网上搜索过任何代码示例,但我找到的都是驱动程序端,响应查询

我针对此问题发出的显示适配器驱动程序是 iddcx 驱动程序(如果有帮助的话)。有什么线索吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)