New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: couldn't call QueryDisplayConfig except QDC_DATABASE_CURRENT, with 0.40.0 #1260
Comments
Not sure I understand the bug. Here's the output I get:
|
Thank you for your attention to reproducing this. |
Thanks @topia. Looks like metadata is missing an WINUSERAPI
_Success_(return == ERROR_SUCCESS) LONG
WINAPI
QueryDisplayConfig(
_In_ UINT32 flags,
_Inout_ UINT32* numPathArrayElements,
_Out_writes_to_(*numPathArrayElements, *numPathArrayElements) DISPLAYCONFIG_PATH_INFO* pathArray,
_Inout_ UINT32* numModeInfoArrayElements,
_Out_writes_to_(*numModeInfoArrayElements, *numModeInfoArrayElements) DISPLAYCONFIG_MODE_INFO* modeInfoArray,
+ _When_(!(flags & QDC_DATABASE_CURRENT), _Pre_null_)
+ _When_(flags & QDC_DATABASE_CURRENT, _Out_)
DISPLAYCONFIG_TOPOLOGY_ID* currentTopologyId); Will transfer this to win32metadata. @kennykerr Heads up, others may hit this elsewhere and we'll need some sort of workaround/story. |
Yes, I think I'll have to remove the pointer to reference conversion in Rust as these sorts of metadata bugs are pretty widespread. |
As of microsoft/windows-rs#2036 you can now once again call this API and pass a null pointer. I'll leave this issue to deal with the SAL parsing bugs. |
From @sotteson1, parsing conditionals is problematic but we can investigate adding a nullable annotation if we detect null SAL annotations. See microsoft/CsWin32#130 for requests for this from C#/Win32. |
Which crate is this about?
windows
Crate version
0.40.0
Summary
I don't know that this is an issue by win32metadata, or by windows-rs, or by design.
By its definition, QueryDisplayConfig's last parameter must be
NULL
forQDC_DATABASE_CURRENT
, but must not beNULL
otherwise.Current win32metadata (checked with 32.0.17-preview), it defined as
[Out] DISPLAYCONFIG_TOPOLOGY_ID* currentTopologyId
.without microsoft/windows-rs#1939, I called the function with
null_mut()
. but for now, I don't know how I can call it.I found I can call it with
#[allow(deref_nullptr)] &mut *null_mut::<DISPLAYCONFIG_TOPOLOGY_ID>()
while writing this issue. Is this the correct way?I saw the conditional is used in its definition, but I don't believe win32metadata can utilize it.
Could you help me? I want to know a workaround and/or the long-term solution for that.
Toolchain version/configuration
Default host: x86_64-pc-windows-msvc
rustup home: D:\data\depot\rustup
installed toolchains
stable-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-msvc
installed targets for active toolchain
aarch64-apple-darwin
aarch64-apple-ios
aarch64-linux-android
aarch64-unknown-linux-gnu
nvptx64-nvidia-cuda
wasm32-unknown-emscripten
wasm32-unknown-unknown
wasm32-wasi
x86_64-apple-darwin
x86_64-pc-windows-gnu
x86_64-pc-windows-msvc
x86_64-unknown-linux-gnu
x86_64-unknown-linux-musl
active toolchain
stable-x86_64-pc-windows-msvc (default)
rustc 1.63.0 (4b91a6ea7 2022-08-08)
Reproducible example
Crate manifest
Expected behavior
Can compile and run correctly.
Actual behavior
failed to compile with expected
&mut DISPLAYCONFIG_TOPOLOGY_ID
, found *-ptr error.Additional comments
By the way, using ref over pointer is an awesome change. Thank you for your work and I'm migrating it happily.
The text was updated successfully, but these errors were encountered: