so i successfully piped the output of ping.exe to my program which displays it in a read-only dialog :
(http://img6.imageshack.us/img6/299/72503316.jpg)
my question is 'cleaning up'. at the moment i simply called TerminateProcess() on the handle returned in the PROCESS_INFORMATION structure from createprocess. but i realised that left a PING.EXE behind. it would seem the best way would be to get a handle to the cmd.exe that i created and send a WM_CLOSE message to it and let it close everything properly. alternatively i could pipe ctrl-c and 'exit' back to the console. unfortunately i don't know how to send key combos, only text
i tried the sendmessage option already but it's not working. i have no clue why either..
invoke EnumWindows, addr EnumFunc, PingProcessInfo.hProcess
invoke CloseHandle, PingProcessInfo.hProcess
EnumFunc proc hwnd:DWORD, lParam:DWORD
LOCAL dwPID:DWORD
invoke GetWindowThreadProcessId, hwnd, addr dwPID
invoke OpenProcess, PROCESS_ALL_ACCESS, TRUE, dwPID
.IF eax == lParam
push eax
invoke SendMessage, hwnd, WM_CLOSE, NULL, NULL
pop eax
invoke CloseHandle, eax
mov eax, FALSE
ret
.ENDIF
invoke CloseHandle, eax
mov eax, TRUE
ret
EnumFunc endp
Good, you saw you the light :wink
So you're calling cmd.exe to call ping.exe? -- I'm guessing that's a leftover from how you were previously trying to do it.
Just call ping.exe directly (no cmd.exe required), then it's 'your' process and you can do what you want with it.
You can call WaitForSingleObject with the process handle (and a small time-out) to check if it's terminated yet; just keep piping until it's finished.
In the case of keep-pinging-until-ctrl+C, it's actually a signal that's generated by the key combination, not the key combination itself. GenerateConsoleCtrlEvent allows you to generate the ctrl+C event.
P.S. you might want to crop your screenshots to remove anything incriminating.
oh sh*t stupid dual screen. THAT WAS NOT WHAT IT LOOKED ! we were messing around.. umm i'm not gonna explain even : [ i'm not gay..
okay lemme try your suggestion, brb
I can only guess...
ROFL
Best regards,
Astro.