Управляемая Тёплая Перезагрузка

Тема в разделе "Другие задачи", создана пользователем kaufman, 27 май 2012.

  1. kaufman

    kaufman Гость

    Репутация:
    0
    Привет. Есть программа, которая, по идее, должна осуществлять эту самую перезагрузку. Но вот есть одно но - она не пашет и я никак не могу понять в чём там дело. Может тут кто-нибудь поможет разобраться?
    Код:
    title TSR-program Hot Reset. 
    
    cseg segment
    assume cs:cseg
    org 80h 	; ­ ç «® áâப¨ ¯ à ¬¥â஢
    CmdLen 	db ? ; ¤«¨­  áâப¨ ¯®  ¤à¥áã 80h
    CmdParams db ? ; áâப  ¯ à ¬¥â஢ ¯®  ¤à¥áã 81 h
    org 100h 	; ­ ç «® ¯à®£à ¬¬ë
    begin:
    jmp ProgStart
    
    sign dw 0F034h ; ᬥ饭¨¥ 103h ®â ­ ç «  PSP
    
    ;*********************************
    ; áâ àë¥ ¢¥ªâ®à  ¯à¥à뢠­¨©
    ;	 ᬥ饭¨¥ ®â ­ ç «  PSP
    old09o dw ?; +105h	
    old09s dw ?; +107h	
    old08o dw ?
    old08s dw ?
    old21o dw ?; +10Dh	
    old21s dw ?; +10Fh	
    old13o dw ?; +111h	
    old13s dw ?; +113h	
    old25o dw ?; +115h	
    old25s dw ?; +117h	
    old26o dw ?; +119h	
    old26s dw ?; +11Bh	
    ;*********************************
    
    is_query	db 0
    is_proc	 db 0
    is_bufready db 0
    
    ; ¯à¨§­ ª¨ à ¡®âë ¯à¥à뢠­¨©
    is_i21 db 0; 21h
    is_i13 db 0; 13h
    is_i25 db 0; 25h
    is_i26 db 0; 26h
    
    BUFFER db 2050 dup(?)
    
    ; ¢à¥¬¥­­®¥ åà ­¥­¨¥ ॣ¨áâ஢
    tax dw ?	
    tes dw ?
    tss dw ?
    tsp dw ?
    
    ; ®¬®éì
    Help db 13, 10, 'reset[.com] [/u]', 13, 10
    db 'TSR program for hot reset.', 13, 10
    db 'Press Ctrl-Alt-R for reset', 13, 10	
    db 'Use /u for unload', 13, 10, '$'
    Info db 'HotReset.', 13, 10, '$'
    
    msgUnl db 'Program was unload', 13, 10, '$'
    IsUnload db 0 ; ¯à¨§­ ª ¢ë£à㧪¨
    
    ;	Msg	db 13, 10, 9, 9, 'RESTART...', 13, 10, '$'
    
    ; ------- ’¨âã«ì­ë© «¨áâ ------		 
    ttl db 20 dup (20h), 'lolo', 13, 10 
    db 15 dup(20h), 'lolo', 13, 10
    db 30 dup(20h), 'lolo"', 13, 10, 13, 10, 13, 10
    db 25 dup(20h), 'lolo', 13, 10
    db 27 dup(20h), '"lolo"', 13, 10, 13, 10
    db 38 dup(20h), 'lolo:', 13, 10
    db 23 dup(20h), '"lolo', 13, 10 
    db 5 dup(20h), 'lololo"', 13, 10, 13, 10, 13, 10
    db 45 dup(20h),'lolo', 13, 10
    db 60 dup(20h),'lolo', 13, 10, 13, 10	 
    db 45 dup(20h),'lolo', 13, 10
    db 60 dup(20h),'lolo.'
    dw 3 dup(0A0Dh)
    db 33 dup(20h),'lolo' 
    dw 5 dup(0A0Dh), '$'
    getkey db 20 dup(20h), ' ¦¬¨â¥ «î¡ãî ª« ¢¨èã ¤«ï ¯à®¤®«¦¥­¨ï...', '$'
    ; -----------------------------
    CurX db ?
    CurY db ?
    
    ; **********************************
    ; ** Ž‹€‘’œ …‡ˆ„…’›• Ž–…„“ **
    ; **********************************
    ; ¯à®æ¥¤ãà  ®¡à ¡®âª¨ ¯à¥à뢠­¨ï ª« ¢¨ âãàv
    KeybInt proc far
    cmp cs:is_query, 1
    jz WASQUERY
    
    mov cs:tax, ax
    mov cs:tes, es
    
    in al, 60h
    cmp al, 13h; ª« ¢¨è  R ?
    
    jz KEYBPRESS
    mov ax, cs:tax
    jmp short WASQUERY
    KEYBPRESS: 
    xor ax, ax
    mov es, ax
    test byte ptr es:[417h], 04h; Ctrl?
    jz NO_CTRL					  
    test byte ptr es:[417h], 08h; Alt?
    jz NO_CTRL
    mov cs:is_query, 1; ᮧ¤ ¥¬ § ¯à®á ­  ¢ë¯®«­¥­¨¥ ®¯¥à æ¨¨
    jmp ISCATCH
    NO_CTRL:
    mov ax, cs:tax
    mov es, cs:tes
    WASQUERY:
    jmp dword ptr cs:[old09o]
    jmp NOTCATCH
    ISCATCH:; ……•‚€—…Ž !!!
    call Reboot
    
    NOTCATCH:
    
    endp KeybInt
    
    ; ¯à¥à뢠­¨¥ 21h
    ; INT 21 - DOS Function Dispatcher
    int21 proc far
    sti
    mov cs:is_i21, 1
    pushf
    call dword ptr cs:[old21o]
    mov cs:is_i21, 0
    
    retf 2
    endp int21
    
    ; ¯à¥à뢠­¨¥ 13h
    ; INT 13 - Diskette BIOS Services
    int13 proc far
    mov cs:is_i13, 1
    pushf
    call dword ptr cs:[old13o]
    mov cs:is_i13, 0
    
    retf 2
    endp int13
    
    ; ¯à¥à뢠­¨¥ 25h
    ; INT 25 - Absolute Disk Read
    int25 proc far
    mov cs:is_i25, 1
    pushf
    call dword ptr cs:[old25o]
    pop si; ã¡à âì «¨è­¥¥ á«®¢®
    mov cs:is_i25, 0
    
    retf; ¯à¨ ¢ë室¥ ®¤­® «¨è­¥¥ á«®¢® ®áâ ¥âáï ¢ á⥪¥
    endp int25
    
    ; ¯à¥à뢠­¨¥ 26h
    ; INT 26 - Absolute Disk Write
    int26 proc far
    mov cs:is_i26, 1
    pushf
    call dword ptr cs:[old26o]
    pop si; ã¡à âì «¨è­¥¥ á«®¢®
    mov cs:is_i26, 0
    
    retf; ¯à¨ ¢ë室¥ ®¤­® «¨è­¥¥ á«®¢® ®áâ ¥âáï ¢ á⥪¥
    endp int26
    
    ; ®¡à ¡®â稪 ªà¨â¨ç¥áª¨å ®è¨¡®ª
    ErrHandler proc far
    mov al, 3
    iret
    endp ErrHandler
    
    BrHandler proc far
    iret
    endp BrHandler
    
    ; ///////////////////////////////////
    ; / „“ƒˆ… …‡ˆ„…’›… Ž–…„“›  /
    ; ///////////////////////////////////
    
    ParsCmd proc
    push di
    
    xor cx, cx
    
    mov cl, cs:CmdLen
    mov di, offset cs:CmdParams
    
    mov IsUnload, 0
    
    cmp cl, 1	; áâப  ¯ãáâ ï
    jz ENDPARS
    FINDPARAM:	; ¨é¥¬ 1© ¯ à ¬¥âà
    cmp byte ptr [di], ' '
    jnz CONTP
    inc di
    loop FINDPARAM
    
    CONTP:
    cmp byte ptr [di], '/'; 
    jnz ENDPARS; ­¥ ª«îç
    
    inc di
    cmp byte ptr [di], 'u' 
    jz RIGHT
    
    cmp byte ptr [di], 'U'
    jnz ENDPARS; ­¥¢¥à­ë© ª«îç
    RIGHT:
    mov IsUnload, 1
    
    ENDPARS:
    pop di
    
    ret
    endp ParsCmd
    
    ; ’¯¥« ï ¯¥à¥§ £à㧪  ª®¬¯ìîâ¥à 
    ; ‡ ¯¨á뢠¥¬ á«®¢® ¯®  ¤à¥áã 0040h:0072h
    ; 0000h ¤«ï 宫®¤­®© ¯¥à¥§ £à㧪¨, 1234h ¤«ï ⥯«®©
    Reboot proc
    mov ax, 40h; ­ áâனª  ES
    mov es, ax; ­  ®¡« áâì BIOS
    mov ax, 1234h; ⥯« ï ¯¥à¥§ £à㧪 
    mov [es:72h], ax
    db 0EAh, 0, 0, 0FFh, 0FFh
    
    ret
    endp Reboot
    
    EndResident:; ª®­¥æ १¨¤¥­â 
    ; **********************************
    ; ***  ……‡ˆ„…’€Ÿ Ž‹€‘’œ	***
    ; **********************************
    
    ; ᪠­¨à㥬 ¯ ¬ïâì
    ; ¥á«¨ ¯à®£à ¬¬  ­ ©¤¥­ , â® ¢ ax - 1, ¨­ ç¥ - 0
    ; ¢ ES à á¯®«®¦¥­  ¯à®£à ¬¬ 
    MemScan proc
    push bx
    push ds
    push dx
    push si
    
    ; ¢ SI ç áâì ­¥à¨§¥¤­â­®© ¯à®£à ¬¬ë
    mov si, cs
    
    mov ax, 5200h;  ¤à¥á ¢¥ªâ®à­®© â ¡«¨æë á¢ï§¨ DOS
    int 21h
    mov es, es:[bx-2]; ¯¥à¥å®¤¨¬ ª ¡«®ªã MCB
    mov ax, 1
    SCANLOOP:
    ; ­ å®¤¨¬ ¢« ¤¥«ìæ ( áá®æ¨¨à®¢ ­­®£® PSP)
    cmp word ptr es:[1], 0; ¥á«¨ 0, â® ¡«®ª ®¯¨á뢠¥â á ¬ ᥡï
    jz LAST
    
    push es
    pop bx
    inc bx
    ; ¤ ­­ë© ᥣ¬¥­â?
    cmp si, bx
    jz CHECKLAST
    mov ds, bx
    ; ¯à®¢¥àª  ­  १¨¤¥­â  ¢ ᥣ¬¥­â¥
    mov bx, cs:sign
    cmp word ptr ds:[103h], bx
    jz ENDSCAN
    CHECKLAST:
    ; ⨯ ¡«®ª  
    cmp byte ptr es:[0], 'M'; 'Œ' - ¡«®ª ­¥¯®á«¥¤­¨©
    jz LAST
    xor ax, ax
    jmp short ENDSCAN
    LAST:
    ; ­ å®¤¨¬  ¤à¥á § £®«®¢ª  á«¥¤ãî饣® ¡«®ª 
    mov dx, es:[3] ; ç¨á«® ¯ à £à ä®¢ ¤ ­­®£® ¡«®ª 
    mov bx, es
    add bx, dx 
    inc bx 	;  ¤à¥á á«¥¤ãî饣® ¡«®ª 
    mov es, bx; ¢ ES
    jmp short SCANLOOP; ᪠­¨à㥬 ¥é¥ à §
    ENDSCAN:
    mov bx, es
    inc bx
    mov es, bx
    
    pop si
    pop dx
    pop ds
    pop bx
    
    ret
    endp MemScan 
    
    ; ãáâ ­ ¢«¨¢ ¥¬ ¢¥ªâ®àë
    SetVect proc
    push ax
    push bx
    push dx
    push es
    
    ; á®å࠭塞 áâ àë¥ ¢¥ªâ®àë
    mov ax, 3509h
    int 21h
    mov cs:old09s, es
    mov cs:old09o, bx
    
    mov ax, 3521h
    int 21h
    mov cs:old21s, es
    mov cs:old21o, bx
    
    mov ax, 3513h
    int 21h
    mov cs:old13s, es
    mov cs:old13o, bx
    
    mov ax, 3525h
    int 21h
    mov cs:old25s, es
    mov cs:old25o, bx
    
    mov ax, 3526h
    int 21h
    mov cs:old26s, es
    mov cs:old26o, bx
    
    ; --- ãáâ ­ ¢«¨¢ ¥¬ ­®¢ë¥ ¢¥ªâ®àë ---
    mov ax, 2509h
    lea dx, KeybInt
    int 21h
    
    mov ax, 2521h
    lea dx, int21	
    int 21h
    
    mov ax, 2513h
    lea dx, int13
    int 21h
    
    mov ax, 2525h
    lea dx, int25
    int 21h
    
    mov ax, 2526h
    lea dx, int26
    int 21h
    ;-------------
    
    pop es
    pop dx
    pop bx
    pop ax
    
    ret
    endp SetVect
    
    ; ¢®ááâ ­®¢¨âì ¢¥ªâ®àë
    RepairVect proc
    push ax
    push dx
    push ds
    
    mov ax, 2509h
    mov dx, word ptr es:[105h]
    mov ds, word ptr es:[107h]
    int 21h
    
    mov ax, 2521h
    mov dx, word ptr es:[10Dh]
    mov ds, word ptr es:[10Fh]
    int 21h
    
    mov ax, 2513h
    mov dx, word ptr es:[111h]
    mov ds, word ptr es:[113h]
    int 21h
    
    mov ax, 2525h
    mov dx, word ptr es:[115h]
    mov ds, word ptr es:[117h]
    int 21h
    
    mov ax, 2526h
    mov dx, word ptr es:[119h]
    mov ds, word ptr es:[11Bh]
    int 21h
    
    pop ds
    pop dx
    pop ax
    
    ret
    endp RepairVect
    
    ; ®á¢®¡®¦¤ ¥¬ ¢v¤¥«¥­­ãî ¯ ¬ïâì
    FreeMem proc
    mov ah, 49h
    int 21h
    
    ret
    endp FreeMem
    
    ; ®á¢®¡®¤¨âì ®ªãà㦥­¨¥ á।ë
    FreeEnv proc
    push ax
    push es
    
    mov es, ds:[2Ch]
    call FreeMem
    
    pop es
    pop ax
    
    ret
    endp FreeEnv
    
    ;------------------------------------------------
    ; ª®¯¨à㥬 ᮤ¥à¦¨¬®¥ ¯ ¬ï⨠¢ ¡ãä¥à
    VID_BUF proc
    
    lea di, cs:BUFFER; DI - ­  ¡ãä¥à
    xor si, si
    mov ax, 0B800h
    mov es, ax; ES - ­  ¢¨¤¥®¯ ¬ïâì
    mov cx, 2000
    xor bl, bl
    VIDLOOP:
    mov ax, es:[si]
    mov cs:[di], ax
    add si, 2
    inc di
    
    loop VIDLOOP
    
    ret
    endp VID_BUF
    
    BUF_VID proc
    
    lea di, cs:BUFFER; DI - ­  ¡ãä¥à
    xor si, si
    mov ax, 0B800h
    mov es, ax; ES - ­  ¢¨¤¥®¯ ¬ïâì
    mov cx, 2000
    BUFLOOP:
    mov ax, cs:[di]
    mov es:[si], ax
    inc si
    inc di
    
    mov byte ptr es:[si], 07h
    inc si
    
    loop BUFLOOP
    
    
    ret
    endp BUF_VID
    ;-------------------------------------------------
    
    
    ; ®á­®¢­ ï ¯à®£à ¬¬ 
    ProgStart:
    xor ax, ax
    
    call ParsCmd
    
    call MemScan
    cmp ax, 1
    jnz NO_TSR; ¯à®£à ¬¬  ¥é¥ ­¥ § ¯ã饭 
    
    cmp IsUnload, 0
    jz EXITPROG
    
    call RepairVect
    call FreeMem
    
    mov dx, offset msgUnl
    mov ah, 09h
    int 21h	
    
    EXITPROG:
    mov ax, 4C00h
    int 21h
    
    NO_TSR:
    cmp IsUnload, 1; ­ ¤® ¢ë£à㦠âì?
    jz EXITPROG
    
    call VID_BUF; á®å࠭塞 ᮤ¥à¦¨¬®¥ íªà ­ 
    ; ¢ë¢®¤ â¨âã«ì­¨ª 	
    mov ax, 03h
    mov CurX, dl
    mov CurY, dh
    int 10h
    
    mov ah, 09h
    lea dx, ttl
    int 21h
    
    mov ah, 09h
    lea dx, getkey
    int 21h
    
    xor ah, ah
    int 16h	
    
    ; ----
    mov ax, 03h
    int 10h
    
    lea dx, Info
    mov ah, 09h
    int 21h
    
    lea dx, Help
    mov ah, 09h
    int 21h
    
    mov ah, 09h
    lea dx, getkey
    int 21h
    
    xor ah, ah
    int 16h
    
    mov ax, 03h
    int 10h
    
    call BUF_VID; ¢®ááâ ­ ¢«¨¢ ¥¬ íªà ­
    
    mov ah, 2
    xor bh, bh
    mov dl, CurX
    mov dh, CurY
    int 10h
    
    call SetVect
    call FreeEnv
    
    ; ®áâ ¢«ï¥¬ १¨¤¥­â 
    lea dx, EndResident
    int 27h
    cseg ends
    end begin
     
Загрузка...
Похожие Темы - Управляемая Тёплая Перезагрузка
  1. RZX
    Ответов:
    0
    Просмотров:
    3.432

Поделиться этой страницей