home *** CD-ROM | disk | FTP | other *** search
/ For Beginners & Professional Hackers / cd.iso / hackers / tools / crack-ut.arj / SAVEREAD.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-02-15  |  2.7 KB  |  155 lines

  1. {$A-}
  2. {$M 1024,0,16384}
  3. uses
  4.    DOS, CRT;
  5.  
  6. const
  7.    ReadNum =       256;
  8.  
  9. type
  10.    TResult =
  11.    Array [1..ReadNum] of
  12.    record
  13.       Num          :Word;
  14.  
  15.       Drive, Head  :Byte;
  16.       Sector, Track:Byte;
  17.       Count        :Byte;
  18.  
  19.       Size         :Word;
  20.       Buffer       :Pointer;
  21.  
  22.       DPT          :Array [0..10] of Byte;
  23.    end;
  24.  
  25. var
  26.    Drive, Head     :Byte;
  27.    Sector, Track   :Byte;
  28.    Count           :Byte;
  29.    Buffer          :Pointer;
  30.  
  31.    Id              :String[8];
  32.    RMax,
  33.    RNum, RPos      :Word;
  34.    Result          :TResult;
  35.  
  36.    DPTAddr         :Pointer;
  37.  
  38. procedure BeforeRead;
  39. interrupt;
  40. begin
  41.    Sound(3000); Delay(10); NoSound;
  42.  
  43.    Inc(RNum); Inc(RPos);
  44.    if RPos>ReadNum then RPos:=1;
  45.  
  46.    Result[RPos].Num:=RNum;
  47.    Result[RPos].Drive:=Drive;
  48.    Result[RPos].Head:=Head; Result[RPos].Sector:=Sector;
  49.    Result[RPos].Track:=Track; Result[RPos].Count:=Count;
  50.  
  51.    GetIntVec($1E, DPTAddr); Move(DPTAddr^, Result[RPos].DPT, 11);
  52.  
  53.    Result[RPos].Size:=Count shl (7+Result[RPos].DPT[3]);
  54. end;
  55.  
  56. procedure AfterRead;
  57. interrupt;
  58. begin
  59.    if MaxAvail>=Result[RPos].Size then
  60.    begin
  61.       GetMem(Result[RPos].Buffer, Result[RPos].Size);
  62.       Move(Buffer^, Result[RPos].Buffer^, Result[RPos].Size);
  63.    end
  64.    else Result[RPos].Buffer:=nil;
  65. end;
  66.  
  67. procedure CLast13;
  68. assembler;
  69. asm
  70.    dd   0
  71.    dw   0, 0, 0
  72. end;
  73.  
  74. procedure Int13;
  75. assembler;
  76. asm
  77.    cmp  ah,2
  78.    jne  @@1
  79.    cmp  dl,1
  80.    ja   @@1
  81.  
  82.    push ds
  83.    push ax
  84.    mov  ax,seg @DATA
  85.    mov  ds,ax
  86.    pop  ax
  87.  
  88.    mov  word ptr Drive,dx
  89.    mov  word ptr Sector,cx
  90.    mov  Count,al
  91.    mov  word ptr Buffer,bx
  92.    mov  word ptr Buffer+2,es
  93.  
  94.    pushf
  95.    push cs
  96.    call BeforeRead
  97.  
  98.    pushf
  99.    call dword ptr CLast13
  100.  
  101.    pushf
  102.    push cs
  103.    call AfterRead
  104.  
  105.    pop  ds
  106.    mov  word ptr CLast13+4,ax
  107.    mov  word ptr CLast13+6,bx
  108.    mov  word ptr CLast13+8,cx
  109.    pop  ax
  110.    pop  bx
  111.    pop  cx
  112.    push bx
  113.    push ax
  114.    mov  ax,word ptr CLast13+4
  115.    mov  bx,word ptr CLast13+6
  116.    mov  cx,word ptr CLast13+8
  117.    retf
  118.  
  119. @@1:
  120.    jmp  dword ptr CLast13
  121. end;
  122.  
  123. var
  124.    Last13          :Pointer;
  125.    CId             :^String;
  126.  
  127. begin
  128.    WriteLn('Floppy Drive Reads Saver  Copyright (c) 1994 by Sasha Peslyak');
  129.  
  130.    Id:='SAVEREAD';
  131.  
  132.    GetIntVec($64, Pointer(CId));
  133.    if CId^=Id then
  134.    begin
  135.       WriteLn('Already installed.'); Halt;
  136.    end;
  137.  
  138.    RMax:=ReadNum; RPos:=0; RNum:=0;
  139.  
  140.    GetIntVec($13, Last13);
  141.    asm
  142.       mov  ax,word ptr Last13
  143.       mov  word ptr CLast13,ax
  144.       mov  ax,word ptr Last13+2
  145.       mov  word ptr CLast13+2,ax
  146.    end;
  147.  
  148.    SetIntVec($13, @Int13);
  149.  
  150.    SetIntVec($64, @Id);
  151.  
  152.    SwapVectors;
  153.    Keep(0);
  154. end.
  155.