home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / t / tcsel003.zip / LOCKKBD.PAS < prev    next >
Pascal/Delphi Source File  |  1992-10-16  |  2KB  |  73 lines

  1. {$X+}
  2.  
  3. { Author Trevor J Carlsen.  Released into the public domain. Req TP6   }
  4. { Compile and run this program and all keyboard input except keys that }
  5. { make up a valid password will be ignored.  In this case the password }
  6. { is '1234' and the scancodes for those keys are stored in a constant. }
  7. { To change the password compute the scancodes for the desired password}
  8. { and change the password approriately.                                }
  9.  
  10. uses
  11.   Dos,
  12.   Crt;
  13.  
  14. var
  15.   OldInt9       : pointer;   { for storing the old interrupt vector }
  16.   password      : string[4];
  17.   pwdlen        : byte absolute password;
  18.   
  19. procedure RestoreOldInt9;
  20.   { Restores control to the old interrupt handler }
  21.   begin
  22.     SetIntVec($09,OldInt9);
  23.   end;
  24.  
  25. {$F+}
  26. procedure NewInt9; interrupt;
  27.  
  28.   const
  29.     masterpwd :string[4] = #2#3#4#5;  { '1234' scancodes }
  30.   var 
  31.     scancode  : byte;
  32.  
  33.   procedure ResetKBD;
  34.     var
  35.        b : byte;
  36.     begin
  37.        b := port[$61]; 
  38.        port[$61] := b or $80;
  39.        port[$61] := b;
  40.        port[$20] := $20; { Signals EOI to PIC }
  41.     end;
  42.   
  43. begin
  44.   scancode    := port[$60]; 
  45.   if chr(scancode)  = masterpwd[pwdlen+1] then begin
  46.     password[pwdlen+1]  := chr(scancode);
  47.     inc(pwdlen);
  48.     if password = masterpwd then
  49.       RestoreOldInt9;
  50.   end
  51.   else if not odd(scancode shr 7) then { invalid key }
  52.     pwdlen := 0;
  53.   ResetKBD;
  54. end; 
  55. {$F-}
  56.  
  57. begin
  58.   pwdlen := 0;
  59.   GetIntVec($09,OldInt9);
  60.   SetIntVec($09,@NewInt9);
  61.   ReadKey;
  62. end.  
  63.  
  64.      
  65.  
  66.  
  67. TeeCee
  68.  
  69.  
  70. --- TC-ED   v2.01  
  71.  * Origin: The Pilbara's Pascal Centre (+61 91 732569) (3:690/644)
  72.  
  73.