PDA

View Full Version : Shutdown (again)



ihsir
03-17-2002, 08:54 PM
i know , i asked this before but what Bubba said will restart not shutdown form c++ : outp(0x64,0xFE).

so how can i shutdown from c++

PS i read the Ralph Brown listing it good but is way over my head.

ihsir
03-17-2002, 11:34 PM
can i, in the dos make a variable and assign it the 'return 0' of c++

like if the 3 pwd guess are wrong i write return 1 instead of return 0 and do this in the autoexec.bat -->

----
variable answer
answer=c:\tc\bin\passprog.exe
if answer==0
C:\WINDOWS\RUNDLL32.EXE shell32.dll,SHExitWindowsEx 1
----

if yes, what'll be the correct way of doing it...

Fordy
03-19-2002, 12:56 AM
Yes......but your method is windows based anyway....not DOS (SHExitWindowsEx is a Win32 system function....so I guess you need windows up to use it.)

If you do get Bubba's method to work, and you are in DOS mode, then you may want to lookup the old DOS command "choice"....

This allows the user to input a choice, and based on the result you can use GOTO statements in your autoexec to brach out to whatever you want to do........

ihsir
03-19-2002, 03:06 AM
Hmm... ok
so whats the dos command for shutdown

also the question of using CHOICE doesn't arise because the password prog (thats what i want) has to be executed and if the 3 guesses are wrong the program performs shutdown.

VirtualAce
03-19-2002, 11:18 PM
My method will work from any language as long as the keyboard buffer is not full and you are in pure DOS mode.

Another way to reboot the computer is to use assembly and do a JMP to address FFFF:0000 which will cause a reboot.

To do this in C, you could use the emit function which emits bytes into the code stream.

the following sequence of bytes will force a reboot.


db 0EAh
dw 0000h
dw 0FFFFh

The 0EAh is the opcode for the JMP instruction.

VirtualAce
03-19-2002, 11:20 PM
In order to force a shutdown, you will have to look up some docs on how to interface with the BIOS. I'm sure the shutdown mechanism is either BIOS related or is done by outputting bytes to certain ports.

ihsir
03-20-2002, 10:18 AM
thanks for the info Bubba

i'll see what i can get.. or do you know somewhere i can get good info on that??

VirtualAce
03-20-2002, 05:08 PM
No I really don't. Some of that newer stuff is sadly undocumented which makes it hard for small programmers like us to implement very handy features.

Also, I doubt if it is about outputting to ports since that would seem to be hardware dependent. It is probably a BIOS extension similar to the MS INT 13 extensions for the hard drive and CHS to LBA translation.

You can try to look in Ralf Brown's interrupt listing as it might be there. I'm sure it is probably within the first 15 interrupts.

ihsir
03-20-2002, 08:39 PM
Ohh man... now i'll have to read the RBIL thing again..

VBprogrammer
03-31-2002, 01:17 PM
Just out of interest bubba if i put

JMP 0xFFFF:0x0

at the end of my boot sector will it restart???

Hillbillie
03-31-2002, 03:25 PM
ihsir, like Bubba mentioned, there's a few ways of rebooting the computer from any language and any platform. However, shutting down the computer (like Windows can on some computers) is a feature of new BIOS'es. Unfortunately, there is no standard on doing this that I know of. So, until they standardize it, you'll have to support only certain BIOS'es. That's how Windows does it.

VBprogrammer
03-31-2002, 03:40 PM
Yeah it works, but im going to have to right a delay function before it will let me desplay a message then restart!

sean
04-03-2002, 10:09 AM
Is there a place or a website where you can find the offsets to JMP to for all the system actions, like shutting down and stuff?

VBprogrammer
04-03-2002, 12:02 PM
Goto Compuboys site http://www.electrichamster.net/Lucie and look under the downloads section you'll find a file called HelpPC.zip (or something like that) this contains many useful files.

matbrady
04-11-2002, 07:42 PM
I dont know if this will help you but from within windows the command line

rundll.exe user.exe,exitwindows

will shut down the computer. You all probaly all knew this though.

ihsir
04-12-2002, 12:38 PM
matbrady:

yeah, i know that. in fact in one of the above posts of mine i used it.


good link VBp,

Unregistered
05-05-2002, 11:10 PM
okay, can someone make a sample program that does this?