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

process::Process::cwd for Windows #105

Closed
svartalf opened this issue Aug 11, 2019 · 4 comments · Fixed by #267
Closed

process::Process::cwd for Windows #105

svartalf opened this issue Aug 11, 2019 · 4 comments · Fixed by #267
Labels
A-process Area: heim-process crate C-enhancement Category: new feature or request O-windows Operating system: Windows

Comments

@svartalf
Copy link
Member

No description provided.

@svartalf svartalf added A-process Area: heim-process crate C-enhancement Category: new feature or request O-windows Operating system: Windows labels Aug 11, 2019
@svartalf svartalf added this to the Release 0.0.7 milestone Aug 11, 2019
@svartalf svartalf modified the milestone: Release 0.0.7 Aug 24, 2019
@sandorex
Copy link

sandorex commented Mar 1, 2020

Only way i've found is this https://stackoverflow.com/a/2967713/6251201 but it's not really elegant it may flag be flagged as malware

@svartalf
Copy link
Member Author

svartalf commented Mar 1, 2020

I think heim should does the same to what psutil does, see: https://github.com/giampaolo/psutil/blob/544e9daa4f66a9f80d7bf6c7886d693ee42f0a13/psutil/arch/windows/process_info.c#L53-L371

Nt* functions are provided by ntapi crate, but I had not found any crate that provides PEB structures (meaning we should embed them) and these "WoW" checks looks kinda hard, but it seems to be better option, as PEB could be used for other Process methods too

@sandorex
Copy link

sandorex commented Mar 1, 2020

The api may change in the future unfortunately

[NtQueryInformationProcess may be altered or unavailable in future versions of Windows. Applications should use the alternate functions listed in this topic.] 

@roblabla
Copy link
Contributor

In practice the API is unlikely to change. It has stayed stable for a long time now, and there are a lot of software relying on this trick to acquire the CWD. If this is ever broken, it'll likely come with an API to properly get the CWD without these hacks, which we'll be able to use from this point on.

I'll be implementing this the same way psutil does, and opening a PR soon.

@roblabla roblabla mentioned this issue Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-process Area: heim-process crate C-enhancement Category: new feature or request O-windows Operating system: Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants