The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: MrBogus on August 13, 2008, 04:05:16 AM

Title: CreateProcess function
Post by: 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...
Title: Re: CreateProcess function
Post by: jj2007 on August 13, 2008, 06:36:22 AM
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 (http://www.masm32.com/board/index.php?topic=9315.msg67757#msg67757).
Title: Re: CreateProcess function
Post by: MrBogus on August 14, 2008, 11:54:41 AM
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


Title: Re: CreateProcess function
Post by: 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
Title: Re: CreateProcess function
Post by: jj2007 on August 31, 2008, 12:01:15 AM
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  ::)