The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Troy Lundin on June 07, 2006, 04:23:37 AM

Title: Question about CreateProcess
Post by: Troy Lundin on June 07, 2006, 04:23:37 AM
I currently use the following to find the handle of a running process.

FindHandle PROC lpBaseAddress:DWORD, nValue:DWORD, iSize:BYTE
LOCAL phandle:DWORD
LOCAL pid:DWORD
LOCAL whandle:DWORD
Invoke FindWindow, NULL, addr wnd_name
mov whandle,eax
Invoke GetWindowThreadProcessId, whandle, addr pid
Invoke OpenProcess,PROCESS_ALL_ACCESS, 0, pid
mov phandle,eax
ret
FindHandle ENDP

Now, I want to use a button to open a create a new process using CreateProcess.
My question is do I need to go through all the same steps above to find the handle of the process I created?
Or, is there an easier way to do it.

Thank you.
Title: Re: Question about CreateProcess
Post by: miaomiao on June 07, 2006, 09:39:44 AM
I think that once created the process handle will not changed, so you can used it until the process was ended or deleted.
Title: Re: Question about CreateProcess
Post by: Ossa on June 07, 2006, 10:23:17 AM
As miaomiao says, the handle of a process remains the same until it terminates, at which point it no longer exists (but you can still use the handle for useful things). The handle is returned by CreateProcess (in the PROCESS_INFORMATION structure). So, no you don't have to do that for any process that you create.

Ossa