News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

CreateProcess lpCommandLine

Started by Don57, October 10, 2012, 11:06:53 AM

Previous topic - Next topic

Don57

I'm using qWords code snippet for CreateProcess


                .if !rv(CreateProcess,"c:\Windows\System32\wevtutil.exe","el",0,0,0,CREATE_NEW_CONSOLE or CREATE_NEW_PROCESS_GROUP,0,0, ADDR sui,ADDR pi)
   

which works fine how ever if I add commands to the lpCommandLine I get syntax errors or nesting errors.

I've tried  ,"el"">>test.txt",
                ,"el" ">>test.txt",
                , "el" ">>" "test.txt",
                and many more

I'm trying to pipe the output to a file so that I can parse it.

qWord

That kind of nesting with quoted strings is not possible with MASM. However, you can use escape sequences with the rvc or rvcx macros:

rvc(CreateProcess,"\\Windows\\System32\\cmd.exe","/K \q\\Windows\\System32\\ping.exe www.masmforum.com \r xyz.txt\q",0,0,0,CREATE_NEW_CONSOLE,0,0, ADDR sui,ADDR pi)

For the syntax of the macros, please take a look into hlhelp.chm.
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

there are several caveats when passing the command line with parameters
read the documentation for CreateProcess - lpCommandLine in particular
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx

what i find works best is to pass a NULL for lpApplicationName and
create the complete command line as a single string - for example...
'c:\masm32\ml.exe parm',0
of course, you don't need the full path if the file is in the same folder or in the environment PATH