call external.exe
if external is not running
terminate myself
Posted on 2006-03-10 02:24:57 by asmd
Posted on 2006-03-10 02:29:34 by Shoo
start like this:

1.find handle of exe in memory
  a. if found, jump @end
  b. if not found... exe to start
  a. if sucesfull open, jump @end
  b. if not, wait some time and jump again to 2



Posted on 2006-03-11 04:20:18 by xanthos
Finding a process that is running on your system is not as easy as it might appear, you can ofcourse just find the window using FindWindow but if the other process does not have a GUI element then you're rooked. The most reliable way I can think of is to walk all of the processes looking for the one you want. This is an example of a process walk for NT/2K/XP/2K3 only as it uses NTDLL.DLL...

FindProcessByNameNT FRAME pszProcess,StartID
uses edi,esi,ebx
LOCAL pProcessSnap :D
LOCAL buffer[256] :W

mov edi,
sub eax,eax
mov ecx,256
repne scasb
not cl
or ecx,ecx
jnz >
sub eax,eax
dec eax

mov al, "\"
repne scasb
add edi,2
or ecx,ecx
jnz >
mov edi,

// Use unicode strings
invoke MultiByteToWideChar,0,0,edi,-1,offset buffer,256

invoke VirtualAlloc,0,020000h,MEM_COMMIT,PAGE_READWRITE
mov ,eax
mov esi,eax
or eax,eax
jnz >
sub eax,eax
dec eax

invoke NtQuerySystemInformation,5,esi,20000h,0

; Find our processID
mov esi,
mov ebx,
cmp ebx,
jle >L1
; Do a quick compare to weed out the impossible ones by
; checking the first 2 characters to see if they match
lea eax, buffer
mov eax,
mov ecx,
or ecx,ecx
jz >L1
mov ecx,
cmp eax,ecx
jne >L1
invoke lstrcmpiW,,offset buffer
jz >.FOUND
mov eax,
add esi,eax
or eax,eax
jnz <L0
dec eax
push eax
jmp >.DONE

push ebx

invoke VirtualFree,,0,MEM_RELEASE
pop eax
or eax,eax

Returns -1 if the process was not found, otherwise it returns the PID.

Posted on 2006-03-11 07:52:54 by donkey
To find the process you can use EnumProcesses or CreateToolhelp32Snapshot. There's a tutorial for the latter.

Both methods work on XP and 2k but only EnumProcesses on NT4 and only CreateToolhelp32Snapshot on 9x.
Posted on 2006-03-11 13:00:08 by stormix

Welcome on board.

You can embed external executables in your main module , there are some occasions to do it :
Posted on 2006-03-11 14:28:13 by Vortex
Did someone say eggdrop?
Posted on 2006-03-12 00:13:10 by Homer
Spawn the child program with CreateProcess. Check return value, terminate on error. CloseHandle on process_information.hThread. WaitForSingleObject on process_information.hProcess with INFINITE timeout. If WaitForSingleObject returns, the child process has terminated.

...And perhaps be a bit more clearer about what you want to do :)
Posted on 2006-03-16 07:01:24 by f0dder