I've been working on some C code to send a Ctrl-C to a Windows console process. Consider the following code snippet:
print "PID: $$\n";
while(1){
print "Looping\n";
sleep(5);
}
The problem is in the way the GenerateConsoleCtrlEvent() works. In short, you can't kill a remote console process like that. So, I've been researching the hell out of this trying to figure out how it can be done. I'm pretty sure it CAN be done, but it's been rough going so far.
My research leads me to believe that this can be accomplished with something along the lines of this abbreviated code:
PS - I have no idea why there's a space showing up in "WriteProcessMemory" above. It's not that way in my text.
update: I have been told that the latter approach still won't work. It *might* be possible with AttachConsole(), but that would XP or later only. We shall see.