[comp.sources.wanted] Is it possible to re-boot a PC from a program ?

alexc@psu-cs.cs.pdx.edu (Alex Chan) (03/14/89)

Hi there,

	Is it possible to write a program to reboot a PC ?
	( I mean a " cold boot " with memory check. ) and how
	could I do it ?

	If someone have the binary or the sources for such
	program " reboot " program, could you please e-mail
	to me. Thank you in advance.

------------
Alex M. Chan
UUCP: uunet!tektronix!{psu-cs,reed,ogccse}!qiclab!tanya!root
DISCLAIMER : The above stated is only my personal opinion, in no way                         it represent my employer or my organization....
Alex M. Chan
AMC Microsystems Inc. ( Private research and developement )
UUCP: uunet!tektronix!{psu-cs,reed,ogccse}!qiclab!tanya!root
DISCLAIMER : The above stated is only my personal opinion, in no way                         it represent my employer or my organization....

todd@stiatl.UUCP (Todd Merriman) (03/15/89)

In article <830@psueea.UUCP> alexc@psu-cs.cs.pdx.edu (Alex Chan) writes:
>
>	Is it possible to write a program to reboot a PC ?



ifdef DOCUMENTATION
; ****************************************************************************
   REBOOT.ASM
   12/18/87
   Todd Merriman

.MODULE           reboot
.LIBRARY          clib
.TYPE             function
.APPLICATION      system
.SYSTEM           msdos
.AUTHOR           Todd Merriman
.LANGUAGE         Assembly
.DESCRIPTION
   Reboot the computer
.ARGUMENTS
   void reboot();
.NARRATIVE
   The reboot function transfers program control to the CPU reset vector, and
   a system reset is performed.  This could be used in a case where a device
   driver was modified.
.CAUTION
   Be sure there are no open files, or any I/O not completed.
.RETURNS
   void
.NOTICE
   Copyright (c) 1987 Future Communications, Atlanta, Georgia
.ENDOC            END DOCUMENTATION
; ****************************************************************************
endif

	.XLIST
	INCLUDE	\HEADER\C.MAC		; symbols and macros for Microsoft
	.LIST

; ****************************************************************************
; data
; ****************************************************************************

	DSEG				; begin data section
RES_VEC	DW	0FFF0H,0F000H           ; reset vector
	ENDDS				; end data section

; ****************************************************************************
; code
; ****************************************************************************

	PSEG				; begin program section

	CFUN reboot                     ; C function declaration

	PUSH 	BP
	MOV	BP,SP

	LEA	SI,RES_VEC              ; load reset vector
	JMP	DWORD PTR DS:[SI]       ; jump there

	POP	BP                      ; this code for good form only
	RET

	CFEND	reboot                  ; end C function

	ENDPS				; end program section


	END				; end assembly


; ****************************************************************************
;  reboot program
;     this is a test for the reboot function
; ****************************************************************************

	PAGE	59,132
;
; Outline for assembly programs to .COM files
;
	.XLIST
	INCLUDE \LAT\HEADER\CSUB.MAC
	.LIST

CODE 	SEGMENT PUBLIC

ASSUME	CS:CODE, DS:CODE, SS:CODE, ES:CODE

	ORG	100H			; .COM origin

MAIN	PROC	FAR

START:	
        CCALL   reboot
	INT	20H			; to DOS
MAIN	ENDP
	
CODE	ENDS

	END	START

; ****************************************************************************
; End REBOOT.ASM
; ****************************************************************************


	...!gatech!stiatl!todd
	Todd Merriman 404-377-TOFU
	Atlanta, GA

nclamber@ndsuvax.UUCP (Pete Lambertz) (03/17/89)

CSEG    SEGMENT
        org     100h
        .MODEL  TINY
        ASSUME  CS:CSEG, DS:CSEG, SS:CSEG
        org     100h
PARK:   mov     ah,25h
        mov     al,6ah
        mov     dx,0ffffh
        mov     ds,dx
        xor     dx,dx
        int     21h
        int     6ah
        int     20h
CSEG    ENDS
END     PARK

this can then be assembled and linked to a .com file.
 If you wanted to reboot from Turbo C you could write

void reboot(void)
{
    setvector(0x6a, MK_FP(FP_SEG(0xFFFF), FP_OFF(0x0000));
    geninterrupt(0x6a);
}

main()
{
        reboot();
}
--
Pete Lambertz           North Dakota State University,  Fargo, ND  58105
  UUCP:                 ...!uunet!ndsuvax!nclamber
  BITNET:               nclamber@ndsuvax.bitnet
  INTERNET:             nclamber@plains.NoDak.edu


#! rnews           1580
Path: psuvm.bitnet!cunyvm!ndsuvm1!nd

davidsen@steinmetz.ge.com (Wm. E. Davidsen) (03/17/89)

In order to cold boot your computer you must change the value of a byte
in memory and jump to FFFF:0000. I can't find the byte offhand, but it
determines warm or cold boot. The program posted in response to your
inquery doesn't seem to diddle the flag byte, and may just give a warm
boot. You can get that with one instruction:
	JMPF	FFFF:0000

I freely admit that I might have missed the byte diddling, but I don't
think so. There was a program called reboot which took an argument W or
C and performed the correct boot.

================================================================
New mailing address: wedu@crd.ge.com

We are no longer ge-crd.arpa and mail will stop working to that address
in the *very* near future.

Note: flames and hate mail may still use the old address ;-{
================================================================
We now return you to our regularly scheduled signature...

-- 
	bill davidsen		(wedu@crd.GE.COM)
  {uunet | philabs}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me

mvp@v7fs1.UUCP (Mike Van Pelt) (03/17/89)

Other people have mentioned that you just jump to FFFF:0.  The other
trick is location 0:0472.  If you store hex 1234 into that word
location, you will get a warm boot.  If you store anything else 
there, you will get a cold boot.

Quickie Debug script:  (Real hackers don't use MASM!)

    debug
    a 100
    push ds
    mov ax,0
    mov ds,ax
    mov ax,1234  (make this zero or something for cold boot.)
    mov [0472],ax
    pop ds
    jmp ffff:0
    
    nreboot.com
    r cx
    12
    w
    
-- 
I would like to electrocute everyone who uses the    | Mike Van Pelt
word 'fair' in connection with income tax policies.  | Video 7
           -- William F. Buckley                     | ...ames!vsi1!v7fs1!mvp

simcha@humming.UUCP (Simcha Lerner) (03/18/89)

In article <830@psueea.UUCP> alexc@psu-cs.cs.pdx.edu (Alex Chan) writes:
>
>Hi there,
>
>	Is it possible to write a program to reboot a PC ?
>	( I mean a " cold boot " with memory check. ) and how
>	could I do it ?
>

This is quite easy.  A cold boot is initiated by jumping to address
FFFF:0000 in real mode - this being the address that the processor
goes to in the event of a reset.

If you wish a warm boot, load 1234 into 40:72 (all of these numbers are
hex).  This will cause the POST (Power On Self Test) to be skipped.

Given the tiny size of this program, you can easily create it via debug.

Simcha Lerner
harvard!humming!simcha

alexc@psueea.uucp (Alex Chan) (03/19/89)

	I have received quite a few postings / e-mail on how to do
	a reboot from a program in C, ASM and using DEBUG.COM.
	I would like to say a sincerely thank you to those who have
	contributed the solution(s). So here it comes....
	
	+---------------------------------------------------+	
	|  ______                                          /|
	|     /   /              /                         /|
	|  --/   /_  __.  ____  /_      __  , ____. .     ' |
	| (_/   / /_(_/|_/ / <_/ <_    / (_/_(_) (_/_    o  |
	|                                /		    |
	|                               '		    |
	+---------------------------------------------------+


Alex M. Chan
AMC Microsystems Inc. ( Private research and developement )
UUCP: uunet!tektronix!{psu-cs,reed,ogccse}!qiclab!tanya!root
DISCLAIMER : The above stated is only my personal opinion, in no way                         .....it represent my employer or my organization....

brown@nicmad.UUCP (Vidiot) (03/20/89)

In article <265@humming.UUCP> simcha@humming.UUCP (Simcha Lerner) writes:
<In article <830@psueea.UUCP> alexc@psu-cs.cs.pdx.edu (Alex Chan) writes:
<>
<>Hi there,
<>
<>	Is it possible to write a program to reboot a PC ?
<>	( I mean a " cold boot " with memory check. ) and how
<>	could I do it ?
<>
<
<This is quite easy.  A cold boot is initiated by jumping to address
<FFFF:0000 in real mode - this being the address that the processor
<goes to in the event of a reset.
<
<If you wish a warm boot, load 1234 into 40:72 (all of these numbers are
<hex).  This will cause the POST (Power On Self Test) to be skipped.
<
<Given the tiny size of this program, you can easily create it via debug.

Yep, it is very easy.  Attached is an assembly listing that you run through
MASM to create a stand-alone program and an object file that can be linked
in with other programs (which I have done).


                page    60,132
                title   REBOOT.ASM = Performs a Warm System Boot =

                PUBLIC REBOOT

;=======================================================================;
;                                                                       ;
;       This segment is used to reference a "JMP" instruction in        ;
;       ROM which branch to the reboot code in ROM.                     ;
;                                                                       ;
;=======================================================================;

rom_seg         segment at 0ffffH
boot_jmp        label   far
rom_seg         ends

;=======================================================================;
;                                                                       ;
;       This segment is used to reference a word in the BIOS data       ;
;       area which is used to determine if a WARM or COLD reboot        ;
;       should be performed by the reboot code in ROM.                  ;
;                                                                       ;
;=======================================================================;

bios_seg        segment at 0040H
                org     bios_seg+72H
boot_flags      label   word
bios_seg        ends

cold_boot       equ     0000H           ;Value to indicate COLD reboot
warm_boot       equ     1234H           ;Value to indicate WARM reboot


                page
;=======================================================================;
;                                                                       ;
;       The following lines set the boot flags in the BIOS Data         ;
;       Area and then invoke the boot code in the BIOS ROM.             ;
;                                                                       ;
;=======================================================================;

code_seg        segment
                assume  CS:code_seg, DS:code_seg
                org     code_seg+100H

reboot          proc
                mov     AX,bios_seg
                mov     DS,AX           ;Point to BIOS Data Area
                assume  DS:bios_seg
                mov     boot_flags,warm_boot

                assume  DS:rom_seg
                jmp     boot_jmp        ;Jump to Reboot Code
reboot          endp

code_seg        ends

                end
-- 
	       harvard-\	 att--\
Vidiot            ucbvax!uwvax!astroatc!nicmad!brown
	       rutgers-/      decvax--/
	ARPA/INTERNET: nicmad!brown%astroatc.UUCP@spool.cs.wisc.edu

wws@rruxd.UUCP (W W Scott) (03/22/89)

In article <830@psueea.UUCP>, alexc@psu-cs.cs.pdx.edu (Alex Chan) writes:
> 
> 	Is it possible to write a program to reboot a PC ?
> 	( I mean a " cold boot " with memory check. ) and how
> 	could I do it ?
> 
> 	If someone have the binary or the sources for such
> 	program " reboot " program, could you please e-mail
> 	to me. Thank you in advance.

Please mail the source to me also.

malloy@nprdc.arpa (Sean Malloy) (03/23/89)

In article <375@rruxd.UUCP> wws@rruxd.UUCP (W W Scott) writes:
>In article <830@psueea.UUCP>, alexc@psu-cs.cs.pdx.edu (Alex Chan) writes:
>> 
>> 	Is it possible to write a program to reboot a PC ?
>> 	( I mean a " cold boot " with memory check. ) and how
>> 	could I do it ?
>> 
>> 	If someone have the binary or the sources for such
>> 	program " reboot " program, could you please e-mail
>> 	to me. Thank you in advance.
>
>Please mail the source to me also.

I got this out of the MSDOS archives at SIMTEL20:
 >     
 >     From: hplabs!hpcea!hpfcdc!hpldola!hp-lsd!nmsu-ee!rusty (Rusty Baldwin)
 >     Newsgroups: comp.sys.ibm.pc
 >     Subject: Re: how do i do a pc warm boot	from software?
 >     Date: 7	Oct 87 22:00:50	GMT
 >     
 >     The following are two short routines to	do a warm or a coldboot.
 >     Hope they help you out.
 >     
 >     
 >     COLDBOOT:
 >     70A2:0100 BA4000	MOV	DX,0040
 >     70A2:0103 8EDA		MOV	DS,DX
 >     70A2:0105 BB7200	MOV	BX,0072
 >     70A2:0108 C7070000	MOV	WORD PTR [BX],0000
 >     70A2:010C EA0000FFFF	JMP	FFFF:0000
 >     
 >     WARMBOOT:
 >     70A2:0100 BA4000	MOV	DX,0040
 >     70A2:0103 8EDA		MOV	DS,DX
 >     70A2:0105 BB7200	MOV	BX,0072
 >     70A2:0108 C7073412	MOV	WORD PTR [BX],1234
 >     70A2:010C EA0000FFFF	JMP	FFFF:0000
 >     
 >     
 >     			       Rusty Baldwin
 >     			       nmsu-ee!rusty


	Sean Malloy
	Navy Personnel Research & Development Center
	San Diego, CA 92152-6800
	malloy@nprdc.navy.mil