Anybody know how to prevent program from starting unless it is started by parent program. For example, I want to run childprogram.exe only by clicking on button or icon in parentprogram.exe If childprogram.exe is clicked then error message generated like "this program can only be run from parentprogram.exe" Is such a thing possible?

I was thinking of somehow checking to see if parentprogram is running, if yes allow childprogram to run, if no prevent childprogram from running?

Any suggestions appreciated.

best regards,

czDrillard
Posted on 2003-01-12 11:26:46 by czDrillard
for checking wether the parent is running check for things like a mutex. (but beware others could acquire the mutex). Work with passwords maybe.
Posted on 2003-01-12 11:56:08 by Hiroshimator
You could set an environment variable before calling createprocess in the parent process... then check for that variable in the child process initialization.

[B]Parent Process:[/B]

.data
szEnvVar db "YOUMAYRUN", 0

.code
invoke SetEnvironmentVariable, addr szEnvVar, addr szEnvVar
invoke CreateProcess, blah, blah, blah

[B]Child Process:[/B]
.data
szEnvVar db "YOUMAYRUN", 0

.code
WinMain proc
invoke GetEnvironmentVariable, addr szEnvVar, NULL, NULL
test eax, eax
jnz @F
invoke ExitProcess, -1
@@: ; Continue loading
WinMain endp
Posted on 2003-01-12 12:33:00 by BubbaFate
You could also give the child program an argument if it's run from the parent process. A mutex would protect running it without the parent process, but the user can still start it himself, when the parent process is already running.

Thomas
Posted on 2003-01-12 17:02:24 by Thomas
Same line of thought, but the argument should be a handle to an internal structure for data from the parent. That way the child exe is not stand-alone. It should be programmed to extract needed info from the parent to work (kinda like nursing your 'child'). You can use mutex and other stuff as well to beef up its defense.

Im not possitive but global memory handles should pass to child processes for this case...??

:NaN:
Posted on 2003-01-12 22:08:58 by NaN
czDrillard,

You can embed your child program in your main code.

You can check the threads:

http://www.asmcommunity.net/board/index.php?topic=9688&highlight=WinExec

http://www.asmcommunity.net/board/index.php?topic=8699&highlight=dll

Regards,

Vortex
Posted on 2003-01-13 02:48:58 by Vortex
global memory (ie, memory mapped files. no, globalalloc is *not* global),
pipes, mailslots, passing commandline arguments, inheriting handles from
the parent... there's a lot of possibilities. you should probably read up on
IPC in the MSDN archive.
Posted on 2003-01-13 04:51:28 by f0dder
The easiest way I know of doing it is to pass a command line parameter to it and if that is incorrect or not present, the program will not run.

Just think of something that is hard to guess,

"Beware of the ides of March" or anything you like but this technique will work fine and is generally how its done.

Regards,

hutch@movsd.com
Posted on 2003-01-13 05:22:05 by hutch--
Big thanks to everybody for their input:alright:

It seems there are quite a few options to choose from and now I have enough information to at least get going in the right direction. Thanks again.

best regards,

czDrillard
Posted on 2003-01-13 09:51:13 by czDrillard