Skip to content
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

question: why are PATHCCH_OPTIONS: i32 whereas PathCchCanonicalizeEx expect u32 ? #988

Closed
agrandville opened this issue Jul 6, 2022 · 4 comments
Assignees
Labels
bug Something isn't working usability Touch-up to improve the user experience for a language projection

Comments

@agrandville
Copy link

Which crate is this about?

windows

Crate version

0.38

Summary

When calling PathCchCanonicalizeEx API. Value of flags need to be cast unnecessarily.
Is it useful to switch PATHCCH_OPTIONS to u32 ?

Toolchain version/configuration

Default host: x86_64-pc-windows-msvc
rustup home: d:\Users\arnaud.rustup

installed toolchains

stable-x86_64-pc-windows-msvc (default)
nightly-x86_64-pc-windows-msvc

installed targets for active toolchain

i686-pc-windows-msvc
wasm32-unknown-unknown
x86_64-pc-windows-msvc

active toolchain

stable-x86_64-pc-windows-msvc (default)
rustc 1.61.0 (fe5b13d68 2022-05-18)

Reproducible example

let dw_flags = PATHCCH_NONE;
let s = "\\\\?\\UNC\\server\\share\\project\\mysite\\config.toml";
let mut v: Vec<u16> = s.encode_utf16().collect();
v.push(0);
let psz_path_int = PCWSTR(v.as_ptr());

let res = PathCchCanonicalizeEx(&mut psz_path_out, psz_path_int, dw_flags.0);
let text = String::from_utf16_lossy(&psz_path_out);
println!("{}", text);

Crate manifest

No response

Expected behavior

[dependencies.windows]
version = "0.38.0"
features = [
"Win32_Foundation",
"Win32_UI_Shell",
]

Actual behavior

dw_flags.0 expected u32, found i32

Additional comments

No response

@agrandville agrandville added the bug Something isn't working label Jul 6, 2022
@kennykerr
Copy link
Contributor

Looks like something we need to fix in metadata. I'll transfer the issue for you.

@kennykerr kennykerr transferred this issue from microsoft/windows-rs Jul 6, 2022
@Zerowalker
Copy link

Oh nice someone had already run into this:)
Was just looking at the metadata and try to figure out how i can tell if it's a miss in the metadata or the underlying project (windows-rs for example).

So if you have some hints there please do share:)

@kennykerr
Copy link
Contributor

kennykerr commented Jul 29, 2022

You can compare what's in the Windows SDK headers (the source of truth) with the Win32 metadata by using the ILSpy decompiler:

https://github.com/icsharpcode/ILSpy

And the current version of the Win32 metadata used by windows-rs can be found here:

https://github.com/microsoft/windows-rs/tree/master/crates/libs/metadata/default

@mikebattista mikebattista self-assigned this Aug 1, 2022
@mikebattista mikebattista added the usability Touch-up to improve the user experience for a language projection label Aug 1, 2022
@mikebattista
Copy link
Contributor

Windows.Win32.UI.Shell.PATHCCH_OPTIONS.value__...System.Int32 => System.UInt32
Windows.Win32.UI.Shell.PATHCCH_OPTIONS : => [Flags]
Windows.Win32.UI.Shell.Apis.PathCchCanonicalizeEx : dwFlags...UInt32 => PATHCCH_OPTIONS
Windows.Win32.UI.Shell.Apis.PathCchCombineEx : dwFlags...UInt32 => PATHCCH_OPTIONS
Windows.Win32.UI.Shell.Apis.PathCchAppendEx : dwFlags...UInt32 => PATHCCH_OPTIONS
Windows.Win32.UI.Shell.Apis.PathAllocCombine : dwFlags...UInt32 => PATHCCH_OPTIONS
Windows.Win32.UI.Shell.Apis.PathAllocCanonicalize : dwFlags...UInt32 => PATHCCH_OPTIONS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working usability Touch-up to improve the user experience for a language projection
Projects
None yet
Development

No branches or pull requests

4 participants