home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 165 / SYSLOCK.ZIP / RELOCK.ASM next >
Assembly Source File  |  1985-08-24  |  11KB  |  213 lines

  1.           PAGE    61,132  ; (Ctrl-O) <--- Insert ASCII 15 for Condensed Print
  2.           TITLE   RELOCK.ASM     (Creates RELOCK.COM)
  3. ;                         Version 1.1, 8/24/85
  4. ;   All Rights Reserved: J. C. Kilday Associates, Peaks Island, ME 04108
  5.  
  6. ; RELOCK.COM is a companion program which interfaces with the device driver,
  7. ; SYSLOCK.SYS.  It allows the user to disable any further use of the PC until
  8. ; the system password is entered.  Ctrl-Break, Ctrl-Alt-Del, and any key
  9. ; strokes involving use of the CTRL, ALT, or right Shift keys are disabled.
  10. ; Type  RELOCK <ENTER>   to secure the PC.
  11.  
  12. ; Since SYSLOCK.SYS is set up as a dummy read-only character device, RELOCK.COM
  13. ; accesses the device driver by issuing a device open and dummy device read
  14. ; commands.  The portion of the driver which requests entry of the system
  15. ; password is re-activated.  If the correct password is entered, the driver
  16. ; returns control to DOS after telling it a lie, i.e., that the correct number
  17. ; input characters were transferred to the requesting application.  Falling
  18. ; for this bit of fiction, DOS transfers control back to the requesting
  19. ; application, RELOCK.COM.  After restoring full keyboard capability this
  20. ; program invokes a normal exit and the DOS prompt appears.
  21.  
  22. ; Version 1.1 incorporates a technique for disabling certain memory resident
  23. ; utilities such as SideKick which insist on regaining control of the keyboard
  24. ; interrupt vector when their control is interrupted.  The disabling of these
  25. ; utilities is necessary to prevent their use to bypass RELOCK operation.
  26. ; RELOCK.COM returns control to them once a password has been correctly entered.
  27.  
  28.  
  29. CSEG      SEGMENT PARA 'CODE'
  30.           ASSUME  CS:CSEG, DS:CSEG
  31.  
  32.           ORG     100H
  33.  
  34. BEGIN:    JMP     SHORT START
  35.  
  36.  
  37.  
  38. DEV_NAME  DB      'SLCK_JCK',0          ;ASCIIZ string: name of device driver
  39.  
  40. DUMMY_BUF DB      ?                     ;Dummy buffer. Really not needed.
  41.  
  42. VECTOR_BUF DB     12 DUP (?)            ;Buffer in which the original boot time
  43.                                         ; vectors for the 08H,1AH, & 1CH time
  44.                                         ; of day and timer interrupts saved
  45.  
  46. CUR_08H_OFF DW    ?                     ;Current INT 08H offset
  47. CUR_08H_SEG DW    ?                     ;  "      "   "  segment
  48. CUR_1AH_OFF DW    ?                     ;Current INT 1AH offset
  49. CUR_1AH_SEG DW    ?                     ;  "      "   "  segment
  50. CUR_1CH_OFF DW    ?                     ;Current INT 1CH offset
  51. CUR_1CH_SEG DW    ?                     ;  "      "   "  segment
  52.  
  53.  
  54. NOT_INST  DB      'The SYSLOCK.SYS'
  55.           DB      ' device driver is not'
  56.           DB      ' installed.',7,13,10,'$';Msg terminated with CR,LF, & BEEP
  57.  
  58. START:    MOV     AX,0                  ;Point ES to segment 0
  59.           MOV     ES,AX
  60.           MOV     AX,CS                 ;Point DS to this code segment
  61.           MOV     DS,AX
  62.  
  63.  ; Save current Time of Day and Timer interrupt vectors before replacing them
  64.  ; with originals which were saved at boot time by SYSLOCK.SYS.  This is the
  65.  ; the first step in process of disabling resident utilities which could be
  66.  ; used to bypass the RELOCK function (e.g., SideKick).
  67.  
  68.           CLI                           ;Turn off interrupts
  69.           MOV     AX,WORD PTR ES:[08H*4];Save offset of INT 08H vector
  70.           MOV     CUR_08H_OFF,AX
  71.           MOV     AX,WORD PTR ES:[08H*4+2] ;Save segment of INT 08H vector
  72.           MOV     CUR_08H_SEG,AX
  73.  
  74.           MOV     AX,WORD PTR ES:[1AH*4];Save offset of INT 1AH vector
  75.           MOV     CUR_1AH_OFF,AX
  76.           MOV     AX,WORD PTR ES:[1AH*4+2] ;Save segment of INT 1AH vector
  77.           MOV     CUR_1AH_SEG,AX
  78.  
  79.           MOV     AX,WORD PTR ES:[1CH*4];Save offset of INT 1CH vector
  80.           MOV     CUR_1CH_OFF,AX
  81.           MOV     AX,WORD PTR ES:[1CH*4+2] ;Save segment of INT 1CH vector
  82.           MOV     CUR_1CH_SEG,AX
  83.           STI                           ;Turn on interrupts
  84.  
  85. ; Invoke the device driver, SYSLOCK.SYS, to ask for the original time-related
  86. ; interrupt vectors saved at boot time.
  87.  
  88.           LEA     DX,DEV_NAME           ;Point DX to ASCIIZ string containing
  89.                                         ; the device name
  90.           MOV     AX,3D00H              ;Open the device for input
  91.           INT     21H
  92.           JNC     DRVR_OK               ;Test for SYSLOCK.SYS installed
  93.           JMP     ERROR_EXIT            ; NO, not installed.
  94. DRVR_OK:  MOV     BX,AX                 ;Put file handle returned by the open
  95.                                         ; into BX to set up for a read request
  96.           PUSH    BX                    ;Save for later
  97.           MOV     CX,12                 ;Request 12 characters to be read
  98.           LEA     DX,VECTOR_BUF         ;Establish buffer to catch vector data
  99.           MOV     AX,3F00H              ;Read from device
  100.           INT     21H
  101.  
  102.  ; Restore original time-related interrupt vectors in effect at system boot to
  103.  ; effectively disable memory resident utilities from restoring their hold on
  104.  ; the keyboard interrupt vector which we're about to take away.
  105.  
  106.           CLI                           ;Turn off interrupts
  107.           MOV     AX,WORD PTR VECTOR_BUF;Get original INT 08H offset
  108.           MOV     WORD PTR ES:[08H*4],AX ;Restore it
  109.           MOV     AX,WORD PTR VECTOR_BUF[2];Get orig INT 08H segment
  110.           MOV     WORD PTR ES:[08H*4+2],AX;Restore it
  111.           MOV     AX,WORD PTR VECTOR_BUF[4];Get original INT 1AH offset
  112.           MOV     WORD PTR ES:[1AH*4],AX;Restore it
  113.           MOV     AX,WORD PTR VECTOR_BUF[6];Get orig INT 1AH segment
  114.           MOV     WORD PTR ES:[1AH*4+2],AX;Restore it
  115.           MOV     AX,WORD PTR VECTOR_BUF[8];Get original INT 1CH offset
  116.           MOV     WORD PTR ES:[1CH*4],AX;Restore it
  117.           MOV     AX,WORD PTR VECTOR_BUF[10];Get orig INT 1CH segment
  118.           MOV     WORD PTR ES:[1CH*4+2],AX;Restore it
  119.  
  120.  
  121.  ; Change keyboard interrupt vector to point to local INT 09H KB handler
  122.  
  123.           MOV     AX,WORD PTR ES:[09H*4];Save offset part of INT 09H vector
  124.           MOV     KBINT_OFF,AX
  125.           MOV     AX,WORD PTR ES:[09H*4+2] ;Save segment part of INT 09H vector
  126.           MOV     KBINT_SEG,AX
  127.           MOV     WORD PTR ES:[09H*4],OFFSET KB_INT ;Insert new vector offset
  128.           MOV     WORD PTR ES:[09H*4+2],CS   ;Insert new vector segment
  129.           STI                                ;Turn interrupts back on
  130.  
  131.  
  132. ; Invoke the device driver, SYSLOCK.SYS, to ask for password
  133.  
  134.           POP     BX                    ;Restore file handle
  135.           MOV     CX,1                  ;Request one character to be read
  136.           LEA     DX,DUMMY_BUF          ;Establish dummy buffer to catch char.
  137.           MOV     AX,3F00H              ;Read from device
  138.           INT     21H
  139.  
  140. ; Note: Control will not return to this program until the device driver
  141. ;       receives the correct password.  When it does .....
  142.  
  143. ; Restore keyboard interrupt vector, various time related interrupt vectors
  144. ; and return to DOS.
  145.  
  146.           CLI                           ;Turn interrupts off
  147.           MOV     AX,0                  ;Point ES to segment 0
  148.           MOV     ES,AX
  149.           MOV     AX,KBINT_OFF          ;Restore offset portion of KB vector
  150.           MOV     WORD PTR ES:[09H*4],AX
  151.           MOV     AX,KBINT_SEG          ;Restore segment portion of KB vector
  152.           MOV     WORD PTR ES:[09H*4+2],AX
  153.           MOV     AX,CUR_08H_OFF        ;Restore offset portion of 08H vector
  154.           MOV     WORD PTR ES:[08H*4],AX
  155.           MOV     AX,CUR_08H_SEG        ;Restore segment portion of 08H vector
  156.           MOV     WORD PTR ES:[08H*4+2],AX
  157.           MOV     AX,CUR_1AH_OFF        ;Restore offset portion of 1AH vector
  158.           MOV     WORD PTR ES:[1AH*4],AX
  159.           MOV     AX,CUR_1AH_SEG        ;Restore segment portion of 1AH vector
  160.           MOV     WORD PTR ES:[1AH*4+2],AX
  161.           MOV     AX,CUR_1CH_OFF        ;Restore offset portion of 1CH vector
  162.           MOV     WORD PTR ES:[1CH*4],AX
  163.           MOV     AX,CUR_1CH_SEG        ;Restore segment portion of 1CH vector
  164.           MOV     WORD PTR ES:[1CH*4+2],AX
  165.           STI                           ;Turn interrupts back on
  166.  
  167.           INT     20H                   ;Return to DOS
  168.  
  169. ERROR_EXIT:
  170.           LEA     DX,NOT_INST            ;Point DX to "Not Installed" message
  171.           MOV     AH,9                   ;Print the message
  172.           INT     21H
  173.           INT     20H                    ;Return to DOS
  174.  
  175. ; New Keyboard Interrupt Handler
  176.  
  177. KB_INT:
  178.           STI                           ;Enable interrupts
  179.           PUSH    DS                    ;Save registers to be used
  180.           PUSH    AX
  181.           MOV     AX,CS                 ;Establish addressability of data
  182.           MOV     DS,AX
  183.           IN      AL,60H                ;Read keyboard input
  184.           TEST    AL,80H                ;Is it a key being released?
  185.           JNZ     NML_KB_INT            ;If yes, go to reg. KB int handler
  186.           CMP     AL,1DH                ;Is the Ctrl key pressed?
  187.           JZ      IGNORE                ;If yes, ignore this keypress
  188.           CMP     AL,38H                ;Is the Alt key pressed?
  189.           JZ      IGNORE                ;If yes, ignore this keypress
  190.           CMP     AL,36H                ;Is the Rt. Shift key pressed?
  191.           JZ      IGNORE                ;If yes, ignore this keypress
  192.           JMP     SHORT NML_KB_INT      ;Do normal KB interrupt
  193. IGNORE:   IN      AL,61H                ;Read 8255 Port PB
  194.           OR      AL,80H                ;Set KB acknowledge signal
  195.           OUT     61H,AL                ;Send acknowledge
  196.           AND     AL,7FH                ;Reset KB acknowledge signal
  197.           OUT     61H,AL                ;Restore original 8255 Port PB
  198.           MOV     AL,20H                ;Send End of Interrupt command to
  199.           OUT     20H,AL                ;   8259 Int. Command Register
  200.           POP     AX                    ;Restore registers
  201.           POP     DS
  202.           IRET                          ;Return to point of interrupt
  203.  
  204. NML_KB_INT:
  205.           POP     AX                    ;Restore registers in preparation
  206.           POP     DS                    ;  for going to normal KB int handler
  207.           DB      0EAH             ;This is op code for a far jump to the
  208. KBINT_OFF DW      ?                ; the normal KB interrupt handler at this
  209. KBINT_SEG DW      ?                ; offset and segment.
  210.  
  211. CSEG      ENDS
  212.           END     BEGIN
  213.