ohadravid / wmi-rs

WMI crate for rust
Apache License 2.0
84 stars 27 forks source link

Calling methods on WMI objects #87

Closed ydirson closed 10 months ago

ydirson commented 10 months ago

I am trying to get the Rust equivalent to this python code (intended to run in a Xen guest with the Xen PV drivers installed):

import wmi
wmi_connection = wmi.WMI(namespace="root\\wmi")
xs_base = wmi_connection.CitrixXenStoreBase()[0]
sid = xs_base.AddSession("MyNewSession")[0]
session = wmi_connection.query(f"select * from CitrixXenStoreSession where SessionId={sid}")[0]
session.GetValue("domid")
session.EndSession()

I am able to retrieve xs_base through a query() call, but that's filling a user-specified struct, and does not appear to allow keeping a handle on the object for later use, and I did not find an API for such calls in the crate.

How could I make those calls?

Edit: I finally found out exec_query_native_wrapper, which IIUC returns the objects handles. But that seems to be a long shot to actually call any methods on this. Looks like this should get through IWbemServices::ExecMethod(), which is not actually called in this crate.

ydirson commented 10 months ago

dup of #58, after all