Hi there, my second question to the MASM32 community :)

MyProgram db "MyProgram.EXE",0

invoke CreateProcess,NULL,ADDR MyProgram,NULL,NULL,TRUE,NULL,NULL,NULL,ADDR ParentStruct,ADDR ProcessInfo

I have seen this done elsewhere, but am having problems. If MyProgram is "NOTEPAD.EXE" or "NET SEND LOCALHOST TEST", it works great - you can see it on TASK MANAGER

but if MyProgram = "CMD.EXE" or "TELNET.EXE", CreateProcess returns OK but process is clearly not running, non-existent on TASK MANAGER.

Platform I am running on is Windows XP Professional.
Can someone enlighten me ?

* I am new to MASM and programming so my assumed knowledge is low. Just learning :)
Posted on 2002-01-16 17:30:15 by prana
just to elaborate some more.

also tried this

invoke CreateProcess,ADDR MyProgram, NULL,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,ADDR ParentStruct,ADDR ProcessInfo

CreateProcess returns 0 with this


invoke CreateProcess,ADDR MyProgram, NULL,NULL,NULL,TRUE,NULL,NULL,NULL,ADDR ParentStruct,ADDR ProcessInfo

and could not get it to work.

hehehe :stupid:

So anyone got any ideas ? Is it a Windows XP thing ?
Posted on 2002-01-16 22:31:37 by prana
To what end do you attempt such things. I don't know the answers to your specific questions, but I should be able to help in a general sense if I knew your goal. And I would like to provoke more dialog in the hopes you would know that you are not only welcome here, but your presents required. ;) Sorry, I am feeling a bit light and philosophical.
Posted on 2002-01-16 22:39:39 by bitRAKE
aww thanks man ! :alright:

Goals -
1. Well I am learning about pipes and CreatingProcesses and since I am an administrator, it would be cool to be able to administer PC's remotely.

2. I can write my own TALK like client, whereby I can talk to someone else on another IP.

More importantly, I can learn and that is my main goal. I want to learn how to use Win32 to do things C or other programs find difficult.

Thanks, but why would you want a dumbum like me roaming this board ?

EDIT: Here is something I found in my code that could be the cause.

invoke CreatePipe,addr PipeInR, addr PipeInW, addr SA, NULL
invoke CreatePipe,addr PipeOutR, addr PipeOutW, addr SA, NULL

invoke GetStartupInfo, ADDR ParentStruct
mov ParentStruct.hStdOutput,PipeOutR ; This is ILLEGAL
mov ParentStruct.hStdError,PipeOutR ; THIS IS ILLEGAL

mov ParentStruct.hStdInput,PipeInW ; THIS IS ILLEGAL
mov ParentStruct.wShowWindow,SW_HIDE

So how do I legally parse the file handle ?
Posted on 2002-01-16 23:53:30 by prana
I think this is because you are using pipes. CMD.exe creates a console for its input and output but when you create the process you have created a pipe to handle the input and output somewhere else so CMD.exe console won't apear because there is no need. Have you tried reading to and reading from the pipe to see if the program is responding. I don't think programs like notepad will respond to a pip as all of there output is in a window.
Posted on 2002-01-17 05:54:59 by Quantum
Afternoon, All.

Just to elaberate a little on this:

Prana jumped on the irc #win32asm channel and asked the same question (it's always good to see a Newbie join in).

From what I understand (and correct me where I'm wrong, Prana), The idea is to be able to execute one of those proggys (cmd.exe or telnet.exe - or even command.com for 9x 'puters), and send them data/info/commands/whatever.:alright:

I modified the SHELLEX example so that it executed those proggys (which he now has).

The main problem now:
How to send input to cmd.exe/telnet.exe/etc ?
Do you use a *pipe*?
If so; does anyone know how to do that?

If not; How would you send input to them?:confused:

I'm interested in the answer, myself.:tongue:

Posted on 2002-01-17 06:22:41 by Scronty
Piping is easy for console programs - check out iczelion's tutorial
on how to do it.

Piping across the network is a LOT more bothersome... it seems that
even though you can use ReadFile and WriteFile on a socket, a
socket is *NOT* inheritable unless the target process is written
especially to support it. Bummer.
Posted on 2002-01-17 06:28:27 by f0dder
thanks everyone for the kindness :)

I too, think it could be a problem with the pipes and the startupinfo structure being wrong. err I taken a look at Iczellion's code. Let me his code....

invoke CreatePipe,addr hRead,addr hWrite,addr sat,NULL

mov startupinfo.cb,sizeof STARTUPINFO (My code does not have this line)
invoke GetStartupInfo,addr startupinfo
mov eax, hWrite <---- Notice this
mov startupinfo.hStdOutput,eax
mov startupinfo.hStdError,eax <----- Notice this
mov startupinfo.wShowWindow,SW_HIDE
invoke CreateProcess, NULL, addr CommandLine, NULL, NULL, TRUE, NULL, NULL, NULL, addr startupinfo, addr pinfo

See where I wrote, "Notice this", this is where the problem is for me. WHen I compile with that format... here is the result from the compiler.

invoke GetStartupInfo, ADDR ParentStruct
mov eax, PipeOutR
mov ParentStruct.hStdOutput,eax
mov ParentStruct.hStdError,eax
mov eax, PipeInW
mov ParentStruct.hStdInput,eax
mov ParentStruct.wShowWindow,SW_HIDE
invoke MessageBox,NULL,,ADDR RMsg,MB_OK ; debugging !!!

Compiler output
Test.asm(80) : error A2022: instruction operands must be the same size
Test.asm(83) : error A2022: instruction operands must be the same size

Why I cant move my FileHandle into EAX like he did ?

How come Iczellion managed to do it and I couldn't ? Did I set up my compile settings wrong ? I am quite confident that if I know how to move the filehandles into EAX, then move EAX to the structure, that all will be great. But what is it I am doing wrong ?

Remember, :stupid: so use beginners words :)
Posted on 2002-01-17 17:43:03 by prana
How are you defining PipeOutR and PipeInW?

MASM will report an error if they aren't 32-bit (4-byte) types like DWORD or REAL4.
Posted on 2002-01-18 18:20:12 by tank
heheh silly me, I actually thought DW is the same as DWORD. But that is all fixed. But the process still wont Create hehhe looks like I am in the gully...

Thanks all for your help. :alright:
Posted on 2002-01-20 16:59:23 by prana