News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CreateProcess function

Started by MrBogus, August 13, 2008, 04:05:16 AM

Previous topic - Next topic

MrBogus

Hi, I wanted to create a system process but still i couldn't get it. Any help? Thanks...

jj2007

Quote from: MrBogus on August 13, 2008, 04:05:16 AM
Hi, I wanted to create a system process but still i couldn't get it. Any help? Thanks...
Usually some piece of code indicating where your problem is would be required to get an answer. Anyway try this thread.

MrBogus

Thanks for the reply. Sorry for the late reply, I'm just renting a computer to connect to the internet. Btw, here is a part of my code. I wanted to run it as a system process but i just can't get it right.


.data
programname db "Tutorial7-mouse.exe",0
processInfo PROCESS_INFORMATION <>

.code

startProcess proc

local startInfo:STARTUPINFO

invoke GetStartupInfo,ADDR startInfo
invoke CreateProcess,ADDR programname,NULL,NULL,NULL,TRUE,\
        REALTIME_PRIORITY_CLASS,\
        NULL,NULL,ADDR startInfo,ADDR processInfo

ret

startProcess endp



donkey

Since GetStartupInfo and CreateProcess are extensible functions (ie can be expanded in future versions without breaking code) you have to tell Windows the size of the STARTUPINFO structure before passing it to GetStartupInfo. Add the following line...

mov startInfo.cb, SIZEOF STARTUPINFO

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

jj2007

Quote from: donkey on August 30, 2008, 11:42:57 PM
Since GetStartupInfo and CreateProcess are extensible functions (ie can be expanded in future versions without breaking code) you have to tell Windows the size of the STARTUPINFO structure before passing it to GetStartupInfo. Add the following line...

mov startInfo.cb, SIZEOF STARTUPINFO

Donkey

What you say sounds plausible, Donkey. From the other thread:

LOCAL pinfo:PROCESS_INFORMATION
  invoke GetStartupInfo, addr sinfo ; fill the structure, then change the two members:
  ; NO mov sinfo.cb, sizeof sinfo ; Windows hopefully knows the STARTUPINFO version
  mov sinfo.dwFlags, STARTF_USESHOWWINDOW ; these two are
  mov sinfo.wShowWindow, SW_MAXIMIZE ; optional but useful


What happens if, hypothetically, Masm32 features an old version; would Windows react to the size member and use the legacy version to fill the structure? I am asking because I did NOT fill the .cb member, and it still worked  ::)