Progrmr
Progrmr

Reputation: 1621

run another program from assembly language

I'm learning x86 assembly language at the moment in Windows 7 MASM32 and I want to make a script that can open notepad. I've looked on Google and can't seem to find anything. How can I do this?

Any help would be appreciated.

Thanks

Upvotes: 4

Views: 1824

Answers (1)

theqbit
theqbit

Reputation: 149

look at the CreateProcess or ShellExecute

push    offset proc_info        ;; lpProcessInformation
        push    offset startup_info     ;; lpStartupInfo
        push    offset new_dir          ;; lpCurrentDirectory
        push    00h             ;; lpEnviroment (get from calling process)
        push    00h             ;; dwCreatingFlags
        push    00h             ;; lpInheritHandles = FALSE
        push    00h             ;; lpThreadAttributes
        push    00h             ;; lpProcessAttributes (default process descriptor)
        push    offset params           ;; lpCommandLine =
        push    offset app          ;; lpApplicationName
                extrn    CreateProcessA: proc
        call    CreateProcessA

;; ...

proc_info:
pi_hProcess     dd      ?
pi_hThread      dd      ?
pi_dwProcessId      dd      ?
pi_dwThreadId       dd      ?
;;---------------------------------------------------------------
startup_info:
si_cb           dd      si_len
si_lpReserved       dd      0   ;; NULL
si_lpDesktop        dd      0   ;; NULL
si_lpTitle      dd      0   ;; NULL
si_dwX          dd      0
si_dwY          dd      0
si_dwXSize      dd      0
si_dwYSize      dd      0
si_XCountsChar      dd      0
si_YCountsChar      dd      0
si_dwFillAttribute           dd     0
si_dwFlags      dd      0  
si_wShowWindow      dw      0   ;; SW_HIDE
si_cbReserved2      dw      0
si_lpReserved2      dd      0   ;; NULL
si_hStdInput        dd      0   ;;
si_hStdOutput       dd      0   ;;   IGNORED
si_hStdError        dd      0   ;;
si_len          equ     $-startup_info

Upvotes: 2

Related Questions