article

SOFTWARE REBOOT UNDER MS-DOS

Email
Submitted on: 1/3/2015 4:18:00 AM
By: Mohit Aggarwal (from psc cd)  
Level: Advanced
User Rating: By 7 Users
Compatibility: C, C++ (general), Borland C++, UNIX C++
Views: 1288
 
     Writing a program in C/C++ for Rebooting Under MS-DOS. PLEASE PROVIDE YOUR FEEDBACK OR VOTE ABOUT THIS ARTICLE.

 
				PLEASE PROVIDE YOUR FEEDBACK OR VOTE ABOUT THIS ARTICLE SO I MAY DECIDE TO WRITE ANY FURTHER ARTICLES.

Why this article?
Most of us have to work under MS-DOS for various reasons like troubleshooting windows, installing sub-operating system, 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.

*****ARTICLE*****


So, in 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:

1)Pointers to Functions
2)ROM BIOS Routine Addresses

So, Here we go:

POINTERS TO FUNCTIONS:-

For many of us this can be a strange topics as we all have dedicated some part of our programming carrier in understanding pointers but never(or very few) came across pointers to functions. So, before going further note that functions do occupies memory and therefore we can assign pointers to those memory locations from which functions get start.
DECLAREING 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 consitutes 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 requires code.

#include"dos.h"

void main()
{
void far(*p)(); //we need 32 bit pointer
p=0xFFFF0000; //this is the location we are pointing to
(*p)(); //calling
}

I dont know, why Microsoft 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 Window, the window you are working under will get closed.
Why didn't i provide just the source code?
I dont think every person out there is able to understand this code. Also begginers like to have many lines of code. They do not see the power behind the code.

Mohit Aggarwal


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Advanced category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.