The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: scox48 on June 09, 2010, 03:16:53 PM

Title: Any examples of CreateProcess calls
Post by: scox48 on June 09, 2010, 03:16:53 PM
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.
Title: Re: Any examples of CreateProcess calls
Post by: qWord on June 09, 2010, 03:51:54 PM
well, my crystal ball is damgaged but this example on using CreateProcess (http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx) 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
Title: Re: Any examples of CreateProcess calls
Post by: clive on June 09, 2010, 03:53:47 PM
Indeed, post the code you currently have if you want specific suggestions.
Title: Re: Any examples of CreateProcess calls
Post by: dedndave on June 09, 2010, 04:06:19 PM
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
Title: Re: Any examples of CreateProcess calls
Post by: clive on June 09, 2010, 04:23:05 PM
Making sure the program name is terminate with a NUL (0) is important for C, ASCIIZ, or SZ type strings.
Title: Re: Any examples of CreateProcess calls
Post by: jj2007 on June 09, 2010, 05:22:07 PM
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 &&.
Title: Re: Any examples of CreateProcess calls
Post by: scox48 on June 09, 2010, 05:56:46 PM
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.