program proxy

Hi.
I'm trying to write a simple program proxy that, once replaced to some executable file, provides a dump of the process environment (command line arguments, environment and so on), executes the original task and returns its exit code.
The purpose of all this is simply analyzing how a frontend program interfaces its son process. Let's have a frontend.exe that fires sonproc.exe and we build this proxy.exe. We rename sonproc.exe as sonproc.exe~, rename proxy.exe as sonproc.exe and let frontend.exe start its son.
The problem is: how can you execute sonproc.exe~ (with CreateProcessExW) as closely as possible to the father's environment? For instance, is it possible to run sonproc.exe~ using sonproc.exe as argument?
Pause and take a step back. What you're proposing is a very primitive debugger, so what you want is the "Image File Execution Options" key in HKLM. https://msdn.microsoft.com/en-us/library/a329t4ed(vs.71).aspx

The "GetStartupInfo()" and "GetEnvironmentStrings()" functions are what you want to call from in your 'debugger' to get all of the environment and startup variables passed in.

- GetStartupInfo: https://msdn.microsoft.com/en-us/library/windows/desktop/ms683230(v=vs.85).aspx
- GetEnvironmentStrings: https://msdn.microsoft.com/en-us/library/windows/desktop/ms683187(v=vs.85).aspx
Last edited on
Good, I'll try it, thanks.
Topic archived. No new replies allowed.