Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Soft Reboot under MS-DOS

0.00/5 (No votes)
7 Jan 2002 1  
Get a program to avoid hardware reboot under DOS

Why this article?

Most of us have to work under MS-DOS for various reasons like troubleshooting windows, installing other operating systems, altering windows default settings and many more. But didn't you miss something there? Yes, you are right - restart. We always have to use hardware reset while working under MS-DOS. This article will solve your problem.

Details

So, here we will write a program in C/C++ to make our system reboot when executed. Before the code I would like to explain some topics which we have to consider before writing. These are:

  • Pointers to Functions
  • ROM BIOS Routine Addresses

So, Here we go:

Pointers to functions

For many of us this can be a strange topic as we all have dedicated some part of our programming career in understanding pointers but never or very few came across pointers to functions. So, before going further note that functions do occupy memory and therefore we can assign pointers to those memory locations from which functions get start.

Declaring a pointer to a function

int (*function_ptr)() is a pointer to a function whose return type is integer. Mind you, we always have to look for memory usage while dealing with pointers.

ROM BIOS routine addresses

Now we all know, ROM Chips constitutes Read Only Memory which contains programs which cannot be altered. But have you ever thought that the ROM Chips contains those programs which loads into memory before anything else and these gets loaded into memory RAM) unless we turn off our computer. Therefore to write a program which reboot our computer we just need the memory address of first ROM BIOS Routine which get executed the moment we boot our computer. This address is 0xFFFF0000. I think, now we are in the position of writing code.

void main()
{
    void far(*p)(); //we need 32 bit pointer

    p=0xFFFF0000; //this is the location we are pointing to

    (*p)(); //calling

}

I don't know, why Microsoft didn't put DOS reboot by themselves. But you can do so by the .exe file of above code.

Why this code is not working under windows?

This code cannot work under windows as window work above DOS's 1MB memory. If you run this code under Windows, the window you are working under will get closed. Why didn't I provide just the source code? I thought a little description will make above code more easy to understand.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here