News:

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

Any examples of CreateProcess calls

Started by scox48, June 09, 2010, 03:16:53 PM

Previous topic - Next topic

scox48

I have been trying to call  CreateProcess and am getting the error "The System cannot find the file specified". I am assuming that this refers to the lpApplicationName parameter. I have tried several methods of invoking CreateProcess, but continue to get the error.  I am assembling on a desktop running Windows XP Pro.

If anyione out there has successfully invoked CreateProcess, I could really use your help.

Thanks.

qWord

well, my crystal ball is damgaged but this example on using CreateProcess should also help you.include masm32rt.inc
.code
main proc
LOCAL sui:STARTUPINFO
LOCAL pi:PROCESS_INFORMATION
    invoke memfill,ADDR sui,SIZEOF sui,0 ; fill STARTUPINFO
    mov sui.cb,SIZEOF sui ;
    fn CreateProcess,0,"C:\Windows\notepad.exe",0,0,0,0,0,0,ADDR sui,ADDR pi
    ret
main endp
end main
FPU in a trice: SmplMath
It's that simple!

clive

Indeed, post the code you currently have if you want specific suggestions.
It could be a random act of randomness. Those happen a lot as well.

dedndave

this one works for me - it also has command line parameters...
        include \masm32\include\masm32rt.inc

        .DATA

PrcName db '\minint\system32\cmd.exe',0
CmdLine db '/k "echo.&&'
        db 'echo Recover - Recover C:&&'
        db 'echo Wiz [?] - MBRWizard&&'
        db 'echo Exit    - Reboot"',0

        .DATA?

SUInfo  STARTUPINFO <>
PrcInfo PROCESS_INFORMATION <>

        .CODE

_main   proc

        INVOKE  CreateProcess,ADDR PrcName,ADDR CmdLine,
                NULL, NULL,NULL,
                CREATE_NEW_PROCESS_GROUP or NORMAL_PRIORITY_CLASS,
                NULL,NULL,
                ADDR SUInfo,ADDR PrcInfo
        INVOKE  ExitProcess,0

_main   endp

        end     _main

clive

Making sure the program name is terminate with a NUL (0) is important for C, ASCIIZ, or SZ type strings.
It could be a random act of randomness. Those happen a lot as well.

jj2007

Quote from: dedndave on June 09, 2010, 04:06:19 PM
this one works for me - it also has command line parameters...

Cute, Dave. I had forgotten that you can concatenate DOS commands with &&.

scox48

Thanks for your responses. I think I may have over-simplified my problem.

I have been programming for over thirty years and have been a 'mainframe' assembler for the past 15 years.

I understand the parameter data dypes need to be in the api call. I do have Microsoft's SDK documentation. My problem is more with windows parameter values, etc.

After I posted this, I decided to revisit Iczelion's tutorials and did find one (Tut 14) that called Create Process. His Tutorial led me to the solution to my problem.

Again, thanks.