News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Synchronous Shell with Buffer

Started by UlliN, January 15, 2007, 05:36:09 PM

Previous topic - Next topic

UlliN

Hi,
yet another synchronous Shell ;-)

Task:
Stand-alone executables are chained together, with possibility of exchanging data (one's output can be the next input).
Each single module can distinguish, if its been started by another module or direct and can change its behavior, say "running as batch" or "with dialog" depending on the way it's been called.

Here's the idea:

Prog1 (caller, chain-controller)
1. Prog1 creates a new process Prog2 in suspended mode
2. Prog1 gets the PID of Prog2 and constructs an unique name by use of this PID
3. Prog1 creates a named MMF (MemoryMappedFile) using this name
4. Prog1 fills the MMF-Buffer with its data
5. Prog1 changes the current dir to the path of Prog2
6. Prog1 resumes Prog2 and waits until Prog2 has finished

Prog2
7. Prog2 gets its own PID and constructs an unique name by use of this PID (same as Prog1 did)
8. Prog2 opens the named MMF created by Prog1
9. If this succeeds, Prog2 can read the buffer-data written by Prog1
    No success: Prog2 was started as stand-alone
10. Prog2 modifies the buffer eventually and stops

11. Prog1 gets the data returned by Prog2 and changes current dir


I've attached the routines with some comments and a simple example to show how it works.
Just run makeit.bat and start "TestShell"
Hope its useful to someone.

Ulli



[attachment deleted by admin]

six_L

good idea. :U

but don't forget to tell  everyone the GetPathOnly should be updated.
regards