/* TakeDat.java by Mark D. LaDue */

/* December 7, 1997 */

/* Copyright (c) 1997 Mark D. LaDue
   You may study, use, modify, and distribute this example for any purpose.
   This example is provided WITHOUT WARRANTY either expressed or implied.  */

/* This Java application hacks the class ClassReader.class of Wingsoft's
   WingDis 2.11 trial version.  These are the results:

   1. The trial version license no longer expires after 5 days; indeed,
      for the hacked version the license never expires.

   2. The hacked version of WingDis 2.11 can now decompile itself
      (to the best of its ability, that is).

   To use it, do the following:

   1. Compile TakeDat.java to obtain TakeDat.class.

   2. Place TakeDat.class in the "wingdis211" folder, where you'll see
      other folders such as "wingsoft" and "wingdis.doc".

   3. Run the program with the command "java TakeDat".

   This changes the necessary 6 bytes in ClassReader.class. */

import java.io.*;

class TakeDat {
    public static void main(String[] argv) {

        String sep = System.getProperty("file.separator");
        String hack = "wingsoft" + sep + "javadis" + sep + "ClassReader.class";

        try {

// Start by opening the file for reading and writing
            RandomAccessFile victim = new RandomAccessFile(hack, "rw");

// Now put a "goto" instruction (opcode 167) at bytes 13187, 14412, 23342,
// 23364, 23423, and 23566
            victim.seek(13186);
            victim.writeByte(167);
            victim.seek(14411);
            victim.writeByte(167);
            victim.seek(23341);
            victim.writeByte(167);
            victim.seek(23363);
            victim.writeByte(167);
            victim.seek(23422);
            victim.writeByte(167);
            victim.seek(23565);
            victim.writeByte(167);

// That's all for now
            victim.close();
        } catch (IOException ioe) {System.err.println("Oops!");}
    System.out.println("WingDis 2.11 has been hacked successfully.");
    }
}
