Reboot a PC with C code

Discussion in 'C Programming' started by Antonio, Nov 19, 2005.

  1. Antonio

    Antonio Guest

    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)();
    }
    Antonio, Nov 19, 2005
    #1
    1. Advertising

  2. Antonio

    Skarmander Guest

    Antonio wrote:
    > 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.

    > Tnks.
    >

    These days people can't even spell "thanks" out in full anymore.

    S.
    Skarmander, Nov 19, 2005
    #2
    1. Advertising

  3. Antonio

    Simon Biber Guest

    Antonio wrote:
    > 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.

    --
    Simon.
    Simon Biber, Nov 19, 2005
    #3
  4. Antonio

    Randy Howard Guest

    Simon Biber wrote
    (in article <437eab15$0$27014$>):

    > 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.



    --
    Randy Howard (2reply remove FOOBAR)
    "The power of accurate observation is called cynicism by those
    who have not got it." - George Bernard Shaw
    Randy Howard, Nov 19, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe Longo

    How to Reboot ?

    Joe Longo, Oct 14, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    536
    Kumar Gaurav Khanna [C# MVP]
    Oct 16, 2003
  2. Ken Tucker
    Replies:
    0
    Views:
    1,645
    Ken Tucker
    Jul 5, 2003
  3. =?Utf-8?B?VGVycnk=?=

    Want to Reboot server from ASPX page

    =?Utf-8?B?VGVycnk=?=, Apr 18, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    374
    Sharon
    Apr 19, 2004
  4. Wagner Dias
    Replies:
    3
    Views:
    3,035
    Andre Kostur
    Mar 28, 2005
  5. Antonio

    Reboot a PC with C++ code

    Antonio, Nov 19, 2005, in forum: C++
    Replies:
    1
    Views:
    1,047
    W Marsh
    Nov 19, 2005
Loading...

Share This Page