home *** CD-ROM | disk | FTP | other *** search
/ For Beginners & Professional Hackers / cd.iso / hackers / tools / ip.arj / IP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-21  |  1.8 KB  |  52 lines

  1. // Immortal Player's Runtime Library  Copyright (c) 1991 IP Makers
  2.  
  3. #include <dos.h>
  4. #include <process.h>
  5. #define MAX_N_BYTES 256
  6.  
  7. typedef struct {                //  Information about each byte
  8.   unsigned long offset;                     //  that will be corrected will
  9.   unsigned char value;                  //  be saved in this structure:
  10. } OffsetAndValue;                   //  OFFSET from PSP,
  11.                     //  VALUE  to put there
  12. typedef struct {
  13.   unsigned long delay;                  //  DataIP contains data
  14.   OffsetAndValue change[ MAX_N_BYTES ]; //  for whole crack;
  15. } DataIP;                               //  Timer will send a byte
  16.                     //  every DELAY/18.2 seconds for
  17. #pragma warn -inl                       //  every array's CHANGE element
  18.  
  19. class IP {
  20.   private:
  21.     static DataIP *data;
  22.     static void interrupt ( *OldTimer )(...);
  23.     static void interrupt Timer(...)
  24.     {
  25.         static ticks = data->delay;
  26.         OldTimer();
  27.         enable();
  28.         if( !ticks-- ){
  29.         unsigned psp = getpsp();
  30.         int i = 0;
  31.         while(( data->change[i].offset != 0 ) && i < MAX_N_BYTES ){
  32.              unsigned long& offset = data->change[i].offset;
  33.              unsigned seg_offset = *(( unsigned* )&offset + 1 );
  34.              *( char far* )MK_FP( psp + ( seg_offset << 12 ),
  35.              ( unsigned )offset ) = data->change[i++].value;
  36.              }
  37.         ticks = data->delay;
  38.         }
  39.     }
  40.   public:
  41.     IP( char* CommandLine, DataIP* p )
  42.     {
  43.         data = p;                //  Constructor prepares
  44.         OldTimer = getvect( 8 );        //  interrupt environment
  45.         setvect( 8, IP::Timer );        //  and makes system call
  46.         system( CommandLine );
  47.     }
  48.     ~IP(){ setvect( 8, OldTimer ); }        //  Destructor restores
  49. };                                              //  old interrupt vector
  50.  
  51. void    interrupt ( *IP::OldTimer )(...);
  52. DataIP* IP::data;