Click here to Skip to main content
15,885,546 members
Articles / Programming Languages / C
Article

Soft Reboot under MS-DOS

Rate me:
Please Sign up or sign in to vote.
1.22/5 (5 votes)
7 Jan 20022 min read 72.2K   19   5
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


Written By
Web Developer
India India
Mail me at:mohitaggarwal@bitbis.com

Comments and Discussions

 
GeneralMy vote of 1 Pin
Alexandre GRANVAUD11-Mar-10 5:24
Alexandre GRANVAUD11-Mar-10 5:24 
omg !
Questionhow about to reboot under windows2000 Pin
30-May-02 17:09
suss30-May-02 17:09 
GeneralFlush hard disk first Pin
Henk Devos14-Jan-02 2:53
Henk Devos14-Jan-02 2:53 
Generalthis is same as ... Pin
Nish Nishant8-Jan-02 21:23
sitebuilderNish Nishant8-Jan-02 21:23 
GeneralAnd if... Pin
CMFC6.0VS.NETUser8-Jan-02 8:43
CMFC6.0VS.NETUser8-Jan-02 8:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.