Reboot a PC with C code

A

Antonio

Hi,
i would write a C program (with Microsoft VC) to reboot a win 98 pc. I found
this code but didn't work

Tnks.

#define MAGIC 0 /* for cold restart */
/* #define MAGIC 0x1234 /* for warm restart */

#define BOOT_SEG 0xffffL
#define BOOT_OFF 0x0000L
#define BOOT_ADR ((BOOT_SEG << 16) | BOOT_OFF)

#define DOS_SEG 0x0040L
#define RESET_FLAG 0x0072L
#define RESET_ADR ((DOS_SEG << 16) | RESET_FLAG)

main()
{
void ((far *fp)()) = (void (far *)()) BOOT_ADR;

*(int far *)RESET_ADR = MAGIC;
(*fp)();
}
 
S

Skarmander

Antonio said:
Hi,
i would write a C program (with Microsoft VC) to reboot a win 98 pc. I found
this code but didn't work
<snip>
Go to comp.os.ms-windows.programmer.win32. This newsgroup deals with the
C language, not arbitrary code written in C.

You are a barbarian, by the way. Use the Win32 function ExitWindows() or
ExitWindowsEx(), not magical mystery calls.
These days people can't even spell "thanks" out in full anymore.

S.
 
S

Simon Biber

Antonio said:
Hi,
i would write a C program (with Microsoft VC) to reboot a win 98 pc. I found
this code but didn't work

Tnks.

#define MAGIC 0 /* for cold restart */
/* #define MAGIC 0x1234 /* for warm restart */

#define BOOT_SEG 0xffffL
#define BOOT_OFF 0x0000L
#define BOOT_ADR ((BOOT_SEG << 16) | BOOT_OFF)

#define DOS_SEG 0x0040L
#define RESET_FLAG 0x0072L
#define RESET_ADR ((DOS_SEG << 16) | RESET_FLAG)

main()
{
void ((far *fp)()) = (void (far *)()) BOOT_ADR;

*(int far *)RESET_ADR = MAGIC;
(*fp)();
}

This is MS-DOS code, not Windows code. I'm sure there's some CamelCase
function in the Windows API that'll do the job for you.
 
R

Randy Howard

Simon Biber wrote
(in article said:
This is MS-DOS code, not Windows code. I'm sure there's some CamelCase
function in the Windows API that'll do the job for you.

IIRC,

outb(0x64, 0xfe);

works fairly efficiently, but can be painful. Nevertheless, it
isn't standard C by any stretch of the imagination.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top