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

Update to windows 0.58 #98

Merged
merged 6 commits into from
Aug 28, 2024
Merged

Conversation

Jasper-Bekkers
Copy link
Contributor

Not a huge change, this updates wmi-rs to windows 0.58

Copy link
Owner

@ohadravid ohadravid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to work on this 🎉

src/safearray.rs Outdated Show resolved Hide resolved
src/variant.rs Outdated Show resolved Hide resolved
src/variant.rs Outdated Show resolved Hide resolved
@@ -63,7 +63,7 @@ impl COMLibrary {
/// `CoInitialize`s the COM library for use by the calling thread, but without setting the security context.
///
pub fn without_security() -> WMIResult<Self> {
unsafe { CoInitializeEx(None, COINIT_MULTITHREADED)? }
unsafe { CoInitializeEx(None, COINIT_MULTITHREADED).ok()? }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will lose the original error code - would you mind adding the needed variant to the WMIError?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's slightly misleading but this calls https://docs.rs/windows-core/latest/windows_core/struct.HRESULT.html#method.ok which does retain the error code.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤯

@Jasper-Bekkers
Copy link
Contributor Author

Addressed all feedback, this should (tm) make the tests run again as well.

Copy link
Owner

@ohadravid ohadravid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@ohadravid ohadravid enabled auto-merge (squash) August 21, 2024 15:41
@Jasper-Bekkers
Copy link
Contributor Author

LGTM 🎉

Would you mind spinning a release if/when this lands?

@ohadravid
Copy link
Owner

Oh no:

> cargo test -- --nocapture --test-threads 1 it_can_desr_newtype_enum_field
...

Caused by:
  process didn't exit successfully: `... --nocapture --test-threads 1 _enum_fi` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

@Jasper-Bekkers
Copy link
Contributor Author

My first guess would be a problem I've seen before with the implement macro but this requires a bit more investigation.

@ohadravid
Copy link
Owner

@Jasper-Bekkers - seems like an issue with IUnknown::from_raw, which should be the _borrowed version.

Can you merge the changes from my branch (https://github.com/ohadravid/wmi-rs/tree/update-win-0.58-fixes) into yours?

auto-merge was automatically disabled August 27, 2024 20:11

Head branch was pushed to by a user without write access

@Jasper-Bekkers
Copy link
Contributor Author

@Jasper-Bekkers - seems like an issue with IUnknown::from_raw, which should be the _borrowed version.

Can you merge the changes from my branch (https://github.com/ohadravid/wmi-rs/tree/update-win-0.58-fixes) into yours?

Done - looks like it needed a cargo fmt still, so I pushed that. Thanks for taking the time to look into this.

@ohadravid ohadravid enabled auto-merge (squash) August 28, 2024 04:22
@ohadravid ohadravid merged commit b22a209 into ohadravid:main Aug 28, 2024
4 checks passed
let bstr_ptr: &BSTR = unsafe { &vt.Anonymous.Anonymous.Anonymous.bstrVal };

Variant::String(bstr_ptr.try_into()?)
let bstr_ptr = unsafe { BSTR::from_raw(vt.Anonymous.Anonymous.Anonymous.bstrVal) };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider replacing this with

let bstr_borrow = ManuallyDrop::new(unsafe { BSTR::from_raw(vt.Anonymous.Anonymous.Anonymous.bstrVal) });
Variant::Sting(bstr_borrow.to_string())

This creates a non-owning BSTR from the get-go, so you do not have to remember and cannot forget to manually release ownership later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants