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.
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.
-
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...
-
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........
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.
-
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.
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.
thanks for the info Bubba
i'll see what i can get.. or do you know somewhere i can get good info on that??
-
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.
Ohh man... now i'll have to read the RBIL thing again..
-
Just out of interest bubba if i put
JMP 0xFFFF:0x0
at the end of my boot sector will it restart???
VC++ 6
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.
Yeah it works, but im going to have to right a delay function before it will let me desplay a message then restart!
VC++ 6
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?
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.
VC++ 6
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.