Re: Why RosAsm Breaks on a large number of symbols
From: f0dder (f0dder_spicedham_at_flork.dk)
Date: 07/04/04
- Next message: Betov: "Re: Why RosAsm Breaks on a large number of symbols"
- Previous message: Alex McDonald: "Celebrity Death Match"
- In reply to: Beth: "Re: Why RosAsm Breaks on a large number of symbols"
- Next in thread: f0dder: "Re: Why RosAsm Breaks on a large number of symbols"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 4 Jul 2004 22:24:38 +0200
*snip*
>it's an interesting omission not to simply have
>a "waitpid" call, where you block until a particular child
>thread has terminated and it loads the "return code" into a
>supplied variable...
>
WaitForSingleObject (Or the other Wait* variants) can wait on
process and thread handles, and you can then get the return
code by GetExitCodeThread and GetExitCodeProcess. No need for
a specific routine for this when it can be handled generically :)
I think it's nice that you don't have to remember a zillion
different calls for waiting on different objects - too bad the
rest of the win32 API is such a hodge-podgy patchwork, most of
the kernel level stuff of NT is actually pretty well designed.
#######################################################
Oh well, might as well post the routine. First, hutch--'s proc:
#######################################################
shell proc lpfilename:DWORD
LOCAL xc :DWORD ; exit code
LOCAL st_info:STARTUPINFO
LOCAL pr_info:PROCESS_INFORMATION
push edi
; ----------------------------
; zero fill the two structures
; ----------------------------
mov ecx, SIZEOF STARTUPINFO
lea edi, st_info
xor eax, eax
rep stosb
mov st_info.cb, SIZEOF STARTUPINFO ; set the structure size AFTER
; zero filling the rest
mov ecx, SIZEOF PROCESS_INFORMATION
lea edi, pr_info
xor eax, eax
rep stosb
pop edi
invoke CreateProcess,lpfilename,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,
ADDR st_info,
ADDR pr_info
; -------------------------------------------
; loop while created process is still active
; -------------------------------------------
@@:
invoke GetExitCodeProcess,pr_info.hProcess,ADDR xc
invoke Sleep, 0 ; surrender time slice
cmp xc, STILL_ACTIVE
je @B
ret
shell endp
#######################################################
Now, my suggestion. Typed up from memory, so beware of bugs:
#######################################################
shell proc lpfilename:DWORD
LOCAL st_info:STARTUPINFO
LOCAL pr_info:PROCESS_INFORMATION
; copy our own startupinfo structure. You might want to
; zero-fill instead.
mov [st_info.cb], SIZEOF STARTUPINFO
invoke GetStartupInfo, addr st_info
; no need to zero-fill pr_info as it's filled by the
; CreateProcess call
invoke CreateProcess,lpfilename,NULL,NULL,NULL,
FALSE,0,NULL,NULL, ADDR st_info, ADDR pr_info
test eax, eax ; do error checking to avoid workin with
jz @@error ; invalid handle values
; wait for child process termination
invoke WaitForSingleObject, [pr_info.hProcess], INFINITE
; close handles to avoid nasty leaks
invoke CloseHandle, [pr_info.hThread]
invoke CloseHandle, [pr_info.hProcess]
@@error:
ret
shell endp
- Next message: Betov: "Re: Why RosAsm Breaks on a large number of symbols"
- Previous message: Alex McDonald: "Celebrity Death Match"
- In reply to: Beth: "Re: Why RosAsm Breaks on a large number of symbols"
- Next in thread: f0dder: "Re: Why RosAsm Breaks on a large number of symbols"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]