The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: nrdev on June 16, 2009, 01:51:39 PM

Title: starting other programs
Post by: nrdev on June 16, 2009, 01:51:39 PM
How can I start other (console) programs via one program made in masm? I want to make one program that will start another, and save info from it.
Title: Re: starting other programs
Post by: dedndave on June 16, 2009, 01:59:00 PM
truthfully, go "hack" someplace else
Title: Re: starting other programs
Post by: qWord on June 16, 2009, 04:44:58 PM
hi,

Use CreateProcess() and pass a file-handle (CreateFile,OpenFile...) to STARTUPINFO.hStdOutput . The created Process (console-application) will write it output to the specified file.

regards, qWord
Title: Re: starting other programs
Post by: Vortex on June 16, 2009, 05:03:15 PM
Hi nrdev,

Here is a quick example for you :


.386
.model flat,stdcall
option casemap:none

include     \masm32\include\windows.inc
include     \masm32\include\kernel32.inc

includelib  \masm32\lib\kernel32.lib


.data

app         db 'C:\Windows\notepad.exe',0

.data?

startinfo   STARTUPINFO         <?>
processinfo PROCESS_INFORMATION <?>

.code

start:

    invoke  CreateProcess,ADDR app,0,0,0,0,0,0,0,\
            ADDR startinfo,ADDR processinfo
           
    invoke  ExitProcess, 0

END start

Title: Re: starting other programs
Post by: Slugsnack on June 16, 2009, 09:38:31 PM
you could also use shellexecute