Author Topic: STARTUPINFO structure for CreateProcess  (Read 4945 times)

Don57

  • Guest
STARTUPINFO structure for CreateProcess
« on: October 07, 2012, 03:48:07 AM »
I am looking for an example for the cp and lpDesktop fields in the STARTUPINFO structure.

qWord

  • Member
  • *****
  • Posts: 1473
  • The base type of a type is the type itself
    • SmplMath macros
Re: STARTUPINFO structure for CreateProcess
« Reply #1 on: October 07, 2012, 03:56:14 AM »
lpDesktop points to a string that holds the desktop name:
Code: [Select]
invoke RtlZeroMemory,ADDR sui,SIZEOF sui
mov sui.cb,SIZEOF sui
mov sui.lpDesktop,chr$("DesktopName")
mov sui.dwFlags,STARTF_USEPOSITION or STARTF_USESHOWWINDOW
mov sui.wShowWindow,SW_SHOWNORMAL
.if !rv(CreateProcess,"C:\Windows\System32\cmd.exe",0,0,0,0,CREATE_NEW_CONSOLE or CREATE_NEW_PROCESS_GROUP,0,0, ADDR sui,ADDR pi)
; error
.endif
MREAL macros - when you need floating point arithmetic while assembling!

Don57

  • Guest
Re: STARTUPINFO structure for CreateProcess
« Reply #2 on: October 07, 2012, 04:24:18 AM »
Thank You. But I am still a little confused by what exactly they mean by desktop name.

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: STARTUPINFO structure for CreateProcess
« Reply #3 on: October 07, 2012, 04:27:58 AM »
my "roll your own stack structure" style - lol
Code: [Select]
;PROCESS_INFORMATION STRUCT
; hProcess             dd ?
; hThread              dd ?
; dwProcessId          dd ?
; dwThreadId           dd ?

;STARTUPINFO         STRUCT
; cb                   dd ?
; lpReserved           dd ?
; lpDesktop            dd ?
; lpTitle              dd ?
; dwX                  dd ?
; dwY                  dd ?
; dwXSize              dd ?
; dwYSize              dd ?
; dwXCountChars        dd ?
; dwYCountChars        dd ?
; dwFillAttribute      dd ?
; dwFlags              dd ?
; wShowWindow          dw ?
; cbReserved2          dw ?
; lpReserved2          dd ?
; hStdInput            dd ?
; hStdOutput           dd ?
; hStdError            dd ?

;EDX = address of command line

        push    edi
        push    (sizeof STARTUPINFO-4)/4
        pop     ecx
        sub     esp,sizeof STARTUPINFO+sizeof PROCESS_INFORMATION-4
        xor     eax,eax
        mov     edi,esp
        rep     stosd
        push    sizeof STARTUPINFO
        xchg    eax,edi
        mov     ecx,esp
        INVOKE  CreateProcess,edi,edx,edi,edi,edi,
                CREATE_NEW_PROCESS_GROUP or NORMAL_PRIORITY_CLASS,
                edi,edi,ecx,eax
        add     esp,sizeof STARTUPINFO+sizeof PROCESS_INFORMATION
        pop     edi

qWord's code is always good
i just thought i would point out the use of the CREATE_NEW_PROCESS_GROUP option

as for lpDesktopName, just use NULL if you want to use the current desktop

Don57

  • Guest
Re: STARTUPINFO structure for CreateProcess
« Reply #4 on: October 07, 2012, 05:15:26 AM »
Thank You. I was filling in the structure completely but i decided to use your first example.  :eusa_clap: