-
Notifications
You must be signed in to change notification settings - Fork 30
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
Conversation
There was a problem hiding this 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 🎉
@@ -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()? } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤯
Addressed all feedback, this should (tm) make the tests run again as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
Would you mind spinning a release if/when this lands? |
Oh no:
|
My first guess would be a problem I've seen before with the |
@Jasper-Bekkers - seems like an issue with Can you merge the changes from my branch (https://github.com/ohadravid/wmi-rs/tree/update-win-0.58-fixes) into yours? |
Head branch was pushed to by a user without write access
Done - looks like it needed a cargo fmt still, so I pushed that. Thanks for taking the time to look into this. |
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) }; |
There was a problem hiding this comment.
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.
Not a huge change, this updates
wmi-rs
towindows 0.58