Skip to content

Bug: IWbemClassObject::Get params are not *mut #1506

@ohadravid

Description

@ohadravid

Which crate is this about?

windows

Crate version

0.46

Summary

Hi!

I'm maintaining a WMI crate, and I tried updating from 0.44 to 0.46.

One of the things I saw was that IWbemClassObject::Get is now defined as:

pub unsafe fn Get<P0>(
    ...
    ptype: Option<*const i32>,
    plflavor: Option<*const i32>
) -> Result<()>

However, according to the docs, ptype and plfavor should be *mut:

HRESULT Get(
  [in]            LPCWSTR wszName,
  [in]            long    lFlags,
  [out]           VARIANT *pVal,
  [out, optional] CIMTYPE *pType,
  [out, optional] long    *plFlavor
);

I also checked emitter.settings.rsp, and both are set to [Optional], which I guess means they should be Option<*mut _>?

The end result is that my code which uses the pType, "works":

let cim_type = -1;

unsafe {
  self.inner.Get(
      PCWSTR::from_raw(name_prop.as_ptr()),
      0,
      &mut vt_prop,
      Some(&cim_type),
      None,
  )?;
}

// cim_type is mutated by `Get`.
assert_ne!(cim_type, -1);

Thanks! 🦀 🪟

Toolchain version/configuration

Default host: aarch64-pc-windows-msvc
rustup home: C:\Users\oravid.rustup

stable-aarch64-pc-windows-msvc (default)
rustc 1.67.1 (d5a82bbd2 2023-02-07)

Reproducible example

No response

Crate manifest

[target.'cfg(target_os = "windows")'.dependencies]
windows = { version = "0.46", features = [
    "implement",
    "Win32_Foundation",
    "Win32_Security",
    "Win32_System_Com",
    "Win32_System_Ole",
    "Win32_System_Rpc",
    "Win32_System_Wmi",
] }

Expected behavior

No response

Actual behavior

No response

Additional comments

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions