0

Firstly, I do not asking for programming solutions, I just publish this code to show how this program work.

I tried this program below (in Virtual Box):

#include <iostream>
#include <string.h>
#include <windows.h>

using namespace std;

int main(int argc, char **argv){

    //program will create a command string that will be executed by the system console to call itself in another process (create another process): cmd = start program_name.exe
    string cmd = string("start ") + string(*argv);

    //execute cmd: a temporary console will be opened, then execute cmd, finally the console will be closed
    system(cmd.c_str());

    //display a message box (In fact, display many message boxes) which annoying user
    MessageBowW(0, L"Message box content", L"Message box title", MB_OK | MB_ICONEXCLAMATION | MB_TOPMOST);

    //if the user pressed OK button in a message box, the message box will display again (by recursion)
    return main(argc, argv);
}

The compiled executable file here

By repeatedly calling itself, this program open many extremely obtrucsive messagebox and slow down the system. This program also prevent the user to do any manipulation.

I can't do anything better than restart my system.

My question is, if I accidentally open this program (open directly by double clicking), how to stop all there processes without restarting Windows? Any idea?

6
  • Task Manager doesn't work to kill the program? If that's the case you might need to log off.
    – Karan
    Commented May 11, 2015 at 20:08
  • But logging off may cause unsaved data lost
    – DMaster
    Commented May 12, 2015 at 8:37
  • Yes, but when you have an aggressive process hogging all resources by opening multiple instances, pretty soon you'll be able to do nothing as the system will become near-unresponsive. If possible you can quickly close apps and answer Yes when they ask to save, then log off. That, or try and open Task Manager and somehow kill the process, but that might be difficult if it keeps spawning new windows that overlap or steal the focus.
    – Karan
    Commented May 12, 2015 at 17:56
  • It seems Windows does not provides enough tools for secure control, sometimes user must surrender. Where is a helpful tool which help me to undo this accident?
    – DMaster
    Commented May 13, 2015 at 6:20
  • What you've described is basically a fork bomb, and even on Linux it can exhaust resources quickly if ulimit -u is not used. For the record I had Firefox running and Word and Notepad open with unsaved files, and was able to log off. Windows then showed me that it was killing all the instances of your program, and when all were gone I quickly cancelled the log off and was able to continue my work without any problems.
    – Karan
    Commented May 14, 2015 at 1:28

0

You must log in to answer this question.

Browse other questions tagged .