home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / progjour / 1991 / 06 / garlic.asm < prev    next >
Assembly Source File  |  1991-07-28  |  3KB  |  76 lines

  1. ;***********************************************************************
  2. ;                              GARLIC.ASM                              *
  3. ;    GARLIC.COM is a tiny TSR that circumvents the midnight vampire,   *
  4. ; sometime known as the lost date problem.  GARLIC intercepts BIOS     *
  5. ; INT 1Ah, AH = 0 (read time) and returns the removed "after midnight" *
  6. ; flag if that interrupt was not requested from inside DOS.            *
  7. ;                   Written by M. L. Lesser, 7/20/91                   *
  8. ; Assembled with Borland TASM 2.5; Linked with TLINK 4.0, switch "/t"  *
  9. ;***********************************************************************
  10.  
  11. CODE    SEGMENT PARA PUBLIC 'CODE'
  12.         ASSUME CS:CODE, DS:CODE, ES:CODE
  13.  
  14.         ORG     100H
  15. BEGIN:  JMP SHORT INIT
  16.  
  17. ALIGN   4
  18. OLDHANDLER DD   0               ;Original INT 1Ah vector
  19.  
  20. NEWHANDLER:                     ;New INT 1Ah handler
  21.         STI
  22.         PUSH    AX
  23.         MOV     AX,DS           ;Did we come from DOS?
  24.         SUB     AX,0070H        ;  if so, DS will hold 0070h
  25.         POP     AX
  26.         JNZ     NODOS           ;If not, check for AH=0
  27. ;-----------------------------------------------------------------------
  28. ;  NOTE:  "Uncommenting" the four statements just below this note
  29. ;         converts GARLIC.ASM to GARLICP.ASM.  The addition removes the
  30. ;         forward tie between the DOS clock and the real-time clock.
  31. ;-----------------------------------------------------------------------
  32. ;       cmp     ah,3            ;AH=3 sets real-time clock time
  33. ;       jz      done
  34. ;       cmp     ah,5            ;AH=5 sets real-time clock date
  35. ;       jz      done
  36. OK:     CLI
  37.         JMP     CS:OLDHANDLER   ;If OK, continue with old interrupt
  38. NODOS:  OR      AH,AH           ;We are looking only for AH=0 calls
  39.         JNZ     OK              ;If not AH=0, use old interrupt
  40.         PUSHF                   ;Simulate INT 1Ah, returning
  41.         CLI                     ;   to this handler
  42.         CALL    CS:OLDHANDLER
  43.         OR      AL,AL           ;Check "after midnight" flag
  44.         JNZ     FIXIT           ;If set, replace flag
  45. DONE:   IRET                    ;Else return to caller
  46. FIXIT:  PUSH    ES              ;Return flag to BIOS data area
  47.         PUSH    DI
  48.         XOR     DI,DI           ;Set ES:DI to address of BIOS
  49.         MOV     ES,DI           ; "after midnight" flag
  50.         MOV     DI,470H
  51.         STOSB                   ; and return flag value
  52.         POP     DI
  53.         POP     ES
  54.         IRET
  55. ALIGN   16                      ;Transient code starts on paragraph
  56. ;  End of resident code
  57. INIT:   MOV     AX,ES:[2CH]     ;Set ES to segment address of
  58.         MOV     ES,AX           ;  GARLIC's environment block
  59.         MOV     AH,49H          ;  and release memory block
  60.         INT     21H
  61.         MOV     AX,351AH        ;Save original INT 1Ah vector
  62.         INT     21H
  63.         MOV     WORD PTR OLDHANDLER,BX
  64.         MOV     WORD PTR OLDHANDLER+2,ES
  65.         MOV     AX,251AH        ; and replace it with NEWHANDLER
  66.         MOV     DX,OFFSET NEWHANDLER
  67.         INT     21H
  68. ;  Terminate and stay resident, freeing memory starting at INIT
  69.         MOV     DX,OFFSET INIT
  70.         MOV     CL,4
  71.         SHR     DX,CL
  72.         MOV     AX,3100H
  73.         INT     21H
  74. CODE    ENDS
  75.         END     BEGIN
  76.