Jump to content

Program for crashing or making process/program to freeze?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
9 replies to this topic

#1
net-man

net-man

    Newbie

  • Members
  • Pip
  • 4 posts
Hello.

I have a little question. Is it possible to write a little program that makes a specific program or process to crash, so when looking in task manager, it says "not responding" on the program or process? I hope you understand. Or could this be made with a simple script? Would be very grateful for an answer on this.

Thanks.

#2
Steve.L

Steve.L

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 444 posts
Well, you could just crash everything by making a huge array of null pointers and doing crazy stuff with them. Pretty simple and short.

#3
Termana

Termana

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,057 posts
im pretty sure doing crazy stuff to null pointers will just either throw a heap of exceptions or crash your own program. if you done crazy stuff to random bits of memory then stuff will crash.
Posted via CodeCall Mobile

#4
roboticforest

roboticforest

    Programmer

  • Members
  • PipPipPipPip
  • 110 posts
Why would you want to crash a program? Are you trying to make a virus?

If the program has already crashed use the end task button in the task manager.

Edited by roboticforest, 09 January 2009 - 05:27 AM.

Dave

#5
Aereshaa

Aereshaa

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 790 posts
On unix, just send a SIGSTOP to whatever process it is.
Watches: Nanoha, Haruhi, AzuDai. Listens to: E-Type, Dj Melodie, Nightcore.
"When people are wrong they need to be corrected. And then when they can't accept it, an argument ensues." - MeTh0Dz

#6
net-man

net-man

    Newbie

  • Members
  • Pip
  • 4 posts

Steve.L said:

Well, you could just crash everything by making a huge array of null pointers and doing crazy stuff with them. Pretty simple and short.

Ok, can you give an example?:o I know nothing on programming.

Quote

Why would you want to crash a program? Are you trying to make a virus?

If the program has already crashed use the end task button in the task manager.

I want to crash a strategy game, in experimental purposes.

Quote

On unix, just send a SIGSTOP to whatever process it is.

I use windows.

Thanks.

#7
net-man

net-man

    Newbie

  • Members
  • Pip
  • 4 posts
No one?

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What you are asking is OS specific and may or may not have a "standard" way to do in that OS. You really need to offer some more details.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#9
net-man

net-man

    Newbie

  • Members
  • Pip
  • 4 posts
Hello. Thanks for replying. I am running Windows xp, and the program in question that i want to try to crash is actually the game age of empires II conquers expansion. Hope this helps. Thanks again.

#10
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,713 posts
@vivek: What does this have to do with the question?

I think this is how to do it. I don't know if there's a better way.
#include <windows.h>
#include <tchar.h>

#define     NUM_PIDS    1024
#define     MAX_PATH    1024
#define     __TEXT("C:\\PROGRAM FILES\\AGE OF EMPIRES.EXE")

INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCommandLine, INT nShowMode)
{
    HANDLE  hProcess;
    DWORD   pdwProcessIDs[NUM_PIDS], dwBytesReturned, dwEntries, dwIndex;
    TCHAR   sztExeBuf[MAX_PATH];
    
    if( !EnumProcesses(pdwProcessIDs, sizeof(DWORD)*NUM_PIDS, &dwBytesReturned) )
    {
        MessageBox(NULL,__TEXT("Could not enumerate processes"), __TEXT("ERROR"), MB_OK);
        return -1;
    }
    
    dwEntries = dwBytesReturned / sizeof(DWORD);
    
    for( dwIndex = 0; dwIndex < dwEntries; ++dwIndex)
    {
        /* open process */
        hProcess = OpenProcess(
                                /* requested access rights*/
                                PROCESS_TERMINATE|PROCESS_QUERY_LIMITED_INFORMATION,
                                /* subprocesses can inherit handle */
                                FALSE,
                                /* process ID */
                                dwEntries
                              );
                              
        /* choke on fail */
        if( hProcess == NULL )
        {
            MessageBox(NULL,__TEXT("Could not open process"), __TEXT("ERROR"), MB_OK);
            return -1;
        }
        
        /* get process file name */
        dwBytesReturned = MAX_PATH;
        if( !QueryFullProcessImageName( hProcess, 0, sztExeBuf, &dwBytesReturned) )
        {
            MessageBox(NULL,__TEXT("Could not get process name"), __TEXT("ERROR"), MB_OK);
            return -1;
        }
        
        /* compare process file name to our target file name*/
        if(_tcscmp(sztExeBuf, TARGET_PROCESS) == 0)
        {
            /* a hit! kill it */
            TerminateProcess(hProcess, 0);
            CloseHandle(hProcess);
            return 0;
        }
    }
    return 0;
}

Edited by dargueta, 14 March 2010 - 07:44 PM.
Corrections

sudo rm -rf /