Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here's my first attempt at implementing cwd for window, mostly based on the code of PSUtil.
Fixes #105
It works by parsing the PEB data structure found in each process. This data structure, along with the APIs used to acquire it, are unstable and, according to microsoft, the APIs may change. In practice, a significant amount of software is built on top of this API, and as such it is unlikely to be broken. If it does break, I expect microsoft to provide a stable API to acquire this information, like they did for the CommandLine.
I tested this with various combination on intel (x86 and x64) CPUs:
I did not implement this under ARM, as it requires using a fairly new API. We'd need to do a runtime check to see if the API is present, I'm not sure what the best way to do this is.
Furthermore, getting a 64-bit process' CWD from a 32-bit Heim is not implemented, as it requires relying on even more unstable APIs, and I don't personally need it.