You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been playing around with some rust -> windows interop again. I have a method exported from a native windows dll I want to call, but it takes an LPCWSTR. It turns out that this is non trivial to do over rust's FFI boundary (convert String/&str to encoded u16[], terminate with 0, pass over FFI as *const u16, etc.)
I was hoping rust would make this easier but it doesn't look like it. windows-rs can easily generate bindings for things like this in win32 (GetEnvironmentVariableW is the example I looked at). It has solved this with the PWSTR type and the IntoParam defs, etc.
Is there any way to easily leverage this for something not defined in winmd? It'd be nice if I could use some of the binding primitives to make a nice binding for my FFI, but PWSTR is only generated into a bindings file.
Any thoughts?
The text was updated successfully, but these errors were encountered:
@chuckries Hey Chuck. While you could write all the goop for this manually... [[gets closer]] let me show ya something cool. In a PR to the windows-app-rs repo, I've got win32metadata's winmdgenerator all wired up and ready to go. It scrapes some headers/libs I feed it and pops out a winmd that's ready for windows crate consumption. Saves so much time.
the first run may blow up as it dotnet installs some tools, puts .bin into path; restart your shell/app to bring in new env vars
if you don't have any import/static libs to scan, use the dummy.lib in that repo
make absolutely sure the importlib path has \x64\ in the path; if that doesn't match your layout, don't fret, just cheat the system with a relative path (e.g. \x64\..\ as a no-op)
ping me if you get stuck, happy to help (am on Teams too if needed)
Yep, Rafael's suggestion is your best bet today. You can of course produce your own winmd by some other means, but this is probably simpler.
Once #81 is complete, you'll be able to define your own APIs directly in Rust and it will thus be able to generate custom bindings without resorting to external tools.
I've been playing around with some rust -> windows interop again. I have a method exported from a native windows dll I want to call, but it takes an LPCWSTR. It turns out that this is non trivial to do over rust's FFI boundary (convert String/&str to encoded u16[], terminate with 0, pass over FFI as *const u16, etc.)
I was hoping rust would make this easier but it doesn't look like it. windows-rs can easily generate bindings for things like this in win32 (GetEnvironmentVariableW is the example I looked at). It has solved this with the PWSTR type and the IntoParam defs, etc.
Is there any way to easily leverage this for something not defined in winmd? It'd be nice if I could use some of the binding primitives to make a nice binding for my FFI, but PWSTR is only generated into a bindings file.
Any thoughts?
The text was updated successfully, but these errors were encountered: