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

Build fails because PCWSTR content expires and overwritten before it is used #57

Closed
IcedLance opened this issue Jun 16, 2023 · 1 comment · Fixed by #58
Closed

Build fails because PCWSTR content expires and overwritten before it is used #57

IcedLance opened this issue Jun 16, 2023 · 1 comment · Fixed by #58

Comments

@IcedLance
Copy link

In build.rs the function fn into_pcwstr(self) -> PCWSTR returns PCWSTR which is basically a pointer to an internal variable that expires immediately after function returns, and even though it's used immediately it's apparently enough for the data it points to get corrupted.

I believe windows-rs library it relies on has already addressed this issue and provided some workaround in release 0.44.0.
Right now winpty-rs is using windows 0.43.0

This is the description of the change microsoft/windows-rs#2239 and apparently you can use HSTRING instead of PCWSTR in most cases now, which is safer.
This seems to work:

GetModuleHandleW(&HSTRING::from("kernel32.dll"))
@andfoy
Copy link
Owner

andfoy commented Jun 28, 2023

Thanks for raising this up @IcedLance, I'll produce a new release once I update the windows-rs requirement

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 a pull request may close this issue.

2 participants