Sign in to follow this  
silverphyre673

force crash program

Recommended Posts

There isn't any way to exit a function without returning from main() or actually crashing it, for instance by accessing protected memory or something, is there? Like there isn't an "exit" command of some sort? Thanks, whatever the answer is.

Share this post


Link to post
Share on other sites

unsigned char *ptr = NULL;

ptr[0] = 0xff;




That will crash the program in protected-mode. Not on 16-bit DOS, though.
Or
void exit(int status),
where status is 0 for normal exit and > 0 for error.
You can use
int atexit ( void (*function) (void) )
to stack functions you want to be called automatically after exit is called.

ch.

Share this post


Link to post
Share on other sites
Quote:
Original post by silverphyre673
There isn't any way to exit a function without returning from main() or actually crashing it, for instance by accessing protected memory or something, is there? Like there isn't an "exit" command of some sort? Thanks, whatever the answer is.


The way I am reading this, is you are trying to find a way NOT to crash it or exit from the program correct? You can simply call return if that is the case:

void MyFunction()
{
...
if( Monkeys_Have_Ran_Amok )
return;
...
}

One thing is that if your function 'returns' something, you need to return like 0 or something to match it.


int MyFunction2()
{
...
if( Noobs_Have_Ran_Amok )
return 0;
...
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this