Given a HANDLE (or ProcessID) to process 'A' is it possible on Win32 for an unrelated process 'B' to determine the current working directory of process 'A' ?
Asked
Active
Viewed 2,678 times
2 Answers
5
Yes, but it's non-trivial. The only way of which I'm aware is to use CreateRemoteThread
to execute GetCurrentDirectory
in the context of the target program.

Jerry Coffin
- 476,176
- 80
- 629
- 1,111
-
1This is the future proof way because the place where this information is stored may change in the future. – poizan42 Jun 22 '16 at 10:25
-
... and risk being detected as malware by AV programs. – zett42 Dec 10 '18 at 22:37
1
I thought this may be possible using the same technique you can use to get an external processes command line and there does seem to be a _RTL_USER_PROCESS_PARAMETERS->CurrentDirectoryPath
which sounds promising.
(The example doesn't state that the APIs are largely undocumented and that they are not future proof, so YMMV)

Alex K.
- 171,639
- 30
- 264
- 288