The MASM Forum

General => The Workshop => Topic started by: nidud on February 18, 2016, 08:01:36 AM

Title: Accessing the environment of a child process
Post by: nidud on February 18, 2016, 08:01:36 AM
deleted
Title: Re: Accessing the environment of a child process
Post by: jj2007 on February 18, 2016, 03:25:37 PM
If you have its source code, WM_COPYDATA is a good option. Otherwise code injection (but watch the forum rules...)
Title: Re: Accessing the environment of a child process
Post by: Zen on February 20, 2016, 06:00:38 AM
NIDUD,
Child Processes, MSDN (https://msdn.microsoft.com/en-us/library/windows/desktop/ms682015(v=vs.85).aspx)
...But, this is probably what you're most interested in: Process Security and Access Rights, MSDN (https://msdn.microsoft.com/en-us/library/windows/desktop/ms684880(v=vs.85).aspx)
You will notice that this is the MSDN documentation for the current version of the Windows Operating System. As I recall, access of child process memory from the parent process works differently on older versions of the Windows Operating System.

...If you visit Raymond Chen's Windows Blog site, search for the term: child process,...Child Process Search (https://social.msdn.microsoft.com/search/en-US?rq=site%3Ablogs.msdn.microsoft.com%2Foldnewthing&rn=oldnewthing&query=child+process)
A process inherits its environment from its parent, and the consequences of this simple statement, Raymond Chen (https://blogs.msdn.microsoft.com/oldnewthing/20150915-00/?p=91591/)
Title: Re: Accessing the environment of a child process
Post by: nidud on February 20, 2016, 11:18:44 PM
deleted
Title: Re: Accessing the environment of a child process
Post by: dedndave on February 21, 2016, 01:26:57 AM
there are numerous batch tricks

tell us exactly what you are trying to do
it sounds like you could just pass the current directory on the command line
(you can get that from API too - lol)
Title: Re: Accessing the environment of a child process
Post by: dedndave on February 21, 2016, 01:55:22 AM
in other words...

make me understand why GetCurrentDirectory won't work for you
Title: Re: Accessing the environment of a child process
Post by: nidud on February 21, 2016, 03:36:06 AM
deleted
Title: Re: Accessing the environment of a child process
Post by: dedndave on February 21, 2016, 05:06:58 AM
ok - i am still not clear on what you are trying to accomplish

are you writing a program or a batch file or both ?

maybe you want to...

1) GetEnvironmentStrings - create an environment block of the current process
2) modify the environment strings, as desired
3) CreateProcess and pass the address of the new environment block
4) FreeEnvironmentStrings - release the environment memory block

the environment functions may be ANSI or UNICODE - use the same type for both
Title: Re: Accessing the environment of a child process
Post by: dedndave on February 21, 2016, 05:12:39 AM
for batch files, there are many little tricks to use

the SET command has a lot of info in the help

C:\> SET /?>temp.txt

there are a few others, too
i don't remember what they are, but i can probably find them if you're interested
Title: Re: Accessing the environment of a child process
Post by: nidud on February 21, 2016, 07:28:26 AM
deleted
Title: Re: Accessing the environment of a child process
Post by: nidud on February 22, 2016, 04:38:20 AM
deleted
Title: Re: Accessing the environment of a child process
Post by: nidud on February 22, 2016, 07:25:04 AM
deleted