I am looking for an example for the cp and lpDesktop fields in the STARTUPINFO structure.
lpDesktop points to a string that holds the desktop name:
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
Thank You. But I am still a little confused by what exactly they mean by desktop name.
my "roll your own stack structure" style - lol
;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
Thank You. I was filling in the structure completely but i decided to use your first example. :eusa_clap: