home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / PARADIS1 / PASSWORD.PAS < prev    next >
Pascal/Delphi Source File  |  1992-02-03  |  3KB  |  114 lines

  1. (3362)  Fri 31 Jan 92 20:08
  2. By: Max Maischein
  3. To: Don Waybright
  4. Re: Help wanted....
  5. St:
  6. ---------------------------------------------------------------------------
  7. @MSGID: 2:249/6.17 0f12cff5
  8. @REPLY: 1:264/177 0d95153d
  9. @PID: FM 2.02
  10.  > 1)  How can I disable the user's ability to stop a program's
  11.  > running with a CTRL Break?
  12. Lookup CheckBreak in your manual(s) or press CTRL-F1 on it.
  13.  
  14.  > 2)  Disable the keybaord.  Like if an incorrect passwrod is
  15.  > entered the keyboard locks out.
  16. Let the master speak for himself :
  17.  
  18. (4375)  Fri 10 Jan 92 18:42
  19. By: Trevor Carlsen
  20. To: Johannes Beekhuizen
  21. Re: Re: Locking the Keyboard
  22. St:
  23. ------------------------------------------------------------------------
  24. @EID:0db9 182a955d
  25. @TCID:3e7fabe8 495d
  26.  JB> Does anyone know if/how it's possible to disable the
  27.  JB> keyboard from within a Pascal or Assembler program?
  28.  
  29. Int $09 is the hardware interrupt for the keyboard.  Here is a program that
  30. will disable the keyboard until a 4 character password is entered.
  31.  
  32.  
  33. {$X+}
  34.  
  35. { Author Trevor J Carlsen.  Released into the public domain. Req TP6   }
  36. { Compile and run this program and all keyboard input except keys that }
  37. { make up a valid password will be ignored.  In this case the password }
  38. { is '1234' and the scancodes for those keys are stored in a constant. }
  39. { To change the password compute the scancodes for the desired password}
  40. { and change the password approriately.                                }
  41.  
  42. uses
  43.   Dos,
  44.   Crt;
  45.  
  46. var
  47.   OldInt9       : pointer;   { for storing the old interrupt vector }
  48.   password      : string[4];
  49.   pwdlen        : byte absolute password;
  50.  
  51. procedure RestoreOldInt9;
  52.   { Restores control to the old interrupt handler }
  53.   begin
  54.     SetIntVec($09,OldInt9);
  55.   end;
  56.  
  57. {$F+}
  58. procedure NewInt9; interrupt;
  59.  
  60.   const
  61.     masterpwd :string[4] = #2#3#4#5;  { '1234' scancodes }
  62.   var
  63.     scancode  : byte;
  64.  
  65.   procedure ResetKBD;
  66.     var
  67.        b : byte;
  68.     begin
  69.        b := port[$61];
  70.        port[$61] := b or $80;
  71.        port[$61] := b;
  72.        port[$20] := $20; { Signals EOI to PIC }
  73.     end;
  74.  
  75. begin
  76.   scancode    := port[$60];
  77.   if chr(scancode)  = masterpwd[pwdlen+1] then begin
  78.     password[pwdlen+1]  := chr(scancode);
  79.     inc(pwdlen);
  80.     if password = masterpwd then
  81.       RestoreOldInt9;
  82.   end
  83.   else if not odd(scancode shr 7) then { invalid key }
  84.     pwdlen := 0;
  85.   ResetKBD;
  86. end;
  87. {$F-}
  88.  
  89. begin
  90.   pwdlen := 0;
  91.   GetIntVec($09,OldInt9);
  92.   SetIntVec($09,@NewInt9);
  93.   ReadKey;
  94. end.
  95.  
  96.  
  97.  
  98.  
  99. TeeCee
  100.  
  101.  > 3)  How can I make it so that a computer will not boot from floppy
  102.  > drives?
  103.  
  104. No. If the computer has an QUAD-TEL BIOS, there is some way, but there is no
  105. way for software to intercept the BIOS before DOS has booted ( at least for
  106. TP-programs :-) )
  107.  
  108. M;
  109.  
  110. ---
  111.  * Origin: SUX released on PDN !! THE standart collection (2:249/6.17)
  112.  
  113. @PATH: 249/6 1 2 243/47 13/13 396/1 170/400 512/0 1007 
  114.