|
|
@ -52,7 +52,7 @@ public class MethodIdentifier extends Identifier implements Opcodes { |
|
|
|
if (exceptionsattr != null) |
|
|
|
if (exceptionsattr != null) |
|
|
|
readExceptions(exceptionsattr); |
|
|
|
readExceptions(exceptionsattr); |
|
|
|
} catch (IOException ex) { |
|
|
|
} catch (IOException ex) { |
|
|
|
ex.printStackTrace(); |
|
|
|
ex.printStackTrace(Obfuscator.err); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -63,6 +63,22 @@ public class MethodIdentifier extends Identifier implements Opcodes { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Skips the specified number of bytes in the input stream. This calls |
|
|
|
|
|
|
|
* skip as long until the bytes are all skipped. |
|
|
|
|
|
|
|
* @param is the inputstream to skip. |
|
|
|
|
|
|
|
* @param count the number of bytes to skip. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private final static void skip(InputStream is, long count) |
|
|
|
|
|
|
|
throws IOException { |
|
|
|
|
|
|
|
while (count > 0) { |
|
|
|
|
|
|
|
long skipped = is.skip(count); |
|
|
|
|
|
|
|
if (skipped == 0) |
|
|
|
|
|
|
|
throw new EOFException("Can't skip."); |
|
|
|
|
|
|
|
count -= skipped; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Reads the opcodes out of the code info and determine its |
|
|
|
* Reads the opcodes out of the code info and determine its |
|
|
|
* references |
|
|
|
* references |
|
|
@ -84,12 +100,12 @@ public class MethodIdentifier extends Identifier implements Opcodes { |
|
|
|
case opc_istore: case opc_lstore: |
|
|
|
case opc_istore: case opc_lstore: |
|
|
|
case opc_fstore: case opc_dstore: case opc_astore: |
|
|
|
case opc_fstore: case opc_dstore: case opc_astore: |
|
|
|
case opc_ret: |
|
|
|
case opc_ret: |
|
|
|
stream.skip(2); |
|
|
|
skip(stream, 2); |
|
|
|
addr+=4; |
|
|
|
addr+=4; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case opc_iinc: |
|
|
|
case opc_iinc: |
|
|
|
stream.skip(4); |
|
|
|
skip(stream, 4); |
|
|
|
addr+=6; |
|
|
|
addr+=6; |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
@ -98,7 +114,7 @@ public class MethodIdentifier extends Identifier implements Opcodes { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_ret: |
|
|
|
case opc_ret: |
|
|
|
stream.skip(1); |
|
|
|
skip(stream, 1); |
|
|
|
addr+=2; |
|
|
|
addr+=2; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case opc_sipush: |
|
|
|
case opc_sipush: |
|
|
@ -108,28 +124,28 @@ public class MethodIdentifier extends Identifier implements Opcodes { |
|
|
|
case opc_ifnull: case opc_ifnonnull: |
|
|
|
case opc_ifnull: case opc_ifnonnull: |
|
|
|
case opc_putstatic: |
|
|
|
case opc_putstatic: |
|
|
|
case opc_putfield: |
|
|
|
case opc_putfield: |
|
|
|
stream.skip(2); |
|
|
|
skip(stream, 2); |
|
|
|
addr+=3; |
|
|
|
addr+=3; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case opc_jsr_w: |
|
|
|
case opc_jsr_w: |
|
|
|
case opc_goto_w: |
|
|
|
case opc_goto_w: |
|
|
|
stream.skip(4); |
|
|
|
skip(stream, 4); |
|
|
|
addr+=5; |
|
|
|
addr+=5; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case opc_tableswitch: { |
|
|
|
case opc_tableswitch: { |
|
|
|
int length = 7-(addr % 4); |
|
|
|
int length = 7-(addr % 4); |
|
|
|
stream.skip(length); |
|
|
|
skip(stream, length); |
|
|
|
int low = stream.readInt(); |
|
|
|
int low = stream.readInt(); |
|
|
|
int high = stream.readInt(); |
|
|
|
int high = stream.readInt(); |
|
|
|
stream.skip(4*(high-low+1)); |
|
|
|
skip(stream, 4*(high-low+1)); |
|
|
|
addr += 9 + length + 4*(high-low+1); |
|
|
|
addr += 9 + length + 4*(high-low+1); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_lookupswitch: { |
|
|
|
case opc_lookupswitch: { |
|
|
|
int length = 7-(addr % 4); |
|
|
|
int length = 7-(addr % 4); |
|
|
|
stream.skip(length); |
|
|
|
skip(stream, length); |
|
|
|
int npairs = stream.readInt(); |
|
|
|
int npairs = stream.readInt(); |
|
|
|
stream.skip(8*npairs); |
|
|
|
skip(stream, 8*npairs); |
|
|
|
addr += 5 + length + 8*npairs; |
|
|
|
addr += 5 + length + 8*npairs; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -166,7 +182,7 @@ public class MethodIdentifier extends Identifier implements Opcodes { |
|
|
|
clazz.bundle.reachableIdentifier(clName, false); |
|
|
|
clazz.bundle.reachableIdentifier(clName, false); |
|
|
|
addr += 3; |
|
|
|
addr += 3; |
|
|
|
if (opcode == opc_multianewarray) { |
|
|
|
if (opcode == opc_multianewarray) { |
|
|
|
stream.skip(1); |
|
|
|
skip(stream, 1); |
|
|
|
addr ++; |
|
|
|
addr ++; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
@ -184,7 +200,7 @@ public class MethodIdentifier extends Identifier implements Opcodes { |
|
|
|
addr += 3; |
|
|
|
addr += 3; |
|
|
|
|
|
|
|
|
|
|
|
if (opcode == opc_invokeinterface) { |
|
|
|
if (opcode == opc_invokeinterface) { |
|
|
|
stream.skip(2); |
|
|
|
skip(stream, 2); |
|
|
|
addr += 2; |
|
|
|
addr += 2; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
@ -194,10 +210,10 @@ public class MethodIdentifier extends Identifier implements Opcodes { |
|
|
|
if (opcode == opc_newarray |
|
|
|
if (opcode == opc_newarray |
|
|
|
|| (opcode >= opc_bipush && opcode <= opc_aload) |
|
|
|
|| (opcode >= opc_bipush && opcode <= opc_aload) |
|
|
|
|| (opcode >= opc_istore && opcode <= opc_astore)) { |
|
|
|
|| (opcode >= opc_istore && opcode <= opc_astore)) { |
|
|
|
stream.skip(1); |
|
|
|
skip(stream, 1); |
|
|
|
addr += 2; |
|
|
|
addr += 2; |
|
|
|
} else if (opcode >= opc_ifeq && opcode <= opc_jsr) { |
|
|
|
} else if (opcode >= opc_ifeq && opcode <= opc_jsr) { |
|
|
|
stream.skip(2); |
|
|
|
skip(stream, 2); |
|
|
|
addr += 3; |
|
|
|
addr += 3; |
|
|
|
} else if (opcode == opc_xxxunusedxxx |
|
|
|
} else if (opcode == opc_xxxunusedxxx |
|
|
|
|| opcode >= opc_breakpoint) |
|
|
|
|| opcode >= opc_breakpoint) |
|
|
@ -242,7 +258,7 @@ public class MethodIdentifier extends Identifier implements Opcodes { |
|
|
|
try { |
|
|
|
try { |
|
|
|
analyzeCode(); |
|
|
|
analyzeCode(); |
|
|
|
} catch (IOException ex) { |
|
|
|
} catch (IOException ex) { |
|
|
|
ex.printStackTrace(); |
|
|
|
ex.printStackTrace(Obfuscator.err); |
|
|
|
System.exit(0); |
|
|
|
System.exit(0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -557,7 +573,7 @@ public class MethodIdentifier extends Identifier implements Opcodes { |
|
|
|
output.writeShort(0); // No Attributes;
|
|
|
|
output.writeShort(0); // No Attributes;
|
|
|
|
output.close(); |
|
|
|
output.close(); |
|
|
|
} catch (IOException ex) { |
|
|
|
} catch (IOException ex) { |
|
|
|
ex.printStackTrace(); |
|
|
|
ex.printStackTrace(Obfuscator.err); |
|
|
|
code = null; |
|
|
|
code = null; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -590,12 +606,12 @@ public class MethodIdentifier extends Identifier implements Opcodes { |
|
|
|
case opc_istore: case opc_lstore: |
|
|
|
case opc_istore: case opc_lstore: |
|
|
|
case opc_fstore: case opc_dstore: case opc_astore: |
|
|
|
case opc_fstore: case opc_dstore: case opc_astore: |
|
|
|
case opc_ret: |
|
|
|
case opc_ret: |
|
|
|
stream.skip(2); |
|
|
|
skip(stream, 2); |
|
|
|
addr+=4; |
|
|
|
addr+=4; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case opc_iinc: |
|
|
|
case opc_iinc: |
|
|
|
stream.skip(4); |
|
|
|
skip(stream, 4); |
|
|
|
addr+=6; |
|
|
|
addr+=6; |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
@ -605,23 +621,23 @@ public class MethodIdentifier extends Identifier implements Opcodes { |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_tableswitch: { |
|
|
|
case opc_tableswitch: { |
|
|
|
int length = 7-(addr % 4); |
|
|
|
int length = 7-(addr % 4); |
|
|
|
stream.skip(length); |
|
|
|
skip(stream, length); |
|
|
|
int low = stream.readInt(); |
|
|
|
int low = stream.readInt(); |
|
|
|
int high = stream.readInt(); |
|
|
|
int high = stream.readInt(); |
|
|
|
stream.skip(4*(high-low+1)); |
|
|
|
skip(stream, 4*(high-low+1)); |
|
|
|
addr += 9 + length + 4*(high-low+1); |
|
|
|
addr += 9 + length + 4*(high-low+1); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_lookupswitch: { |
|
|
|
case opc_lookupswitch: { |
|
|
|
int length = 7-(addr % 4); |
|
|
|
int length = 7-(addr % 4); |
|
|
|
stream.skip(length); |
|
|
|
skip(stream, length); |
|
|
|
int npairs = stream.readInt(); |
|
|
|
int npairs = stream.readInt(); |
|
|
|
stream.skip(8*npairs); |
|
|
|
skip(stream, 8*npairs); |
|
|
|
addr += 5 + length + 8*npairs; |
|
|
|
addr += 5 + length + 8*npairs; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_ret: |
|
|
|
case opc_ret: |
|
|
|
stream.skip(1); |
|
|
|
skip(stream, 1); |
|
|
|
addr+=2; |
|
|
|
addr+=2; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case opc_sipush: |
|
|
|
case opc_sipush: |
|
|
@ -633,28 +649,28 @@ public class MethodIdentifier extends Identifier implements Opcodes { |
|
|
|
case opc_anewarray: |
|
|
|
case opc_anewarray: |
|
|
|
case opc_checkcast: |
|
|
|
case opc_checkcast: |
|
|
|
case opc_instanceof: |
|
|
|
case opc_instanceof: |
|
|
|
stream.skip(2); |
|
|
|
skip(stream, 2); |
|
|
|
addr+=3; |
|
|
|
addr+=3; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case opc_multianewarray: |
|
|
|
case opc_multianewarray: |
|
|
|
stream.skip(3); |
|
|
|
skip(stream, 3); |
|
|
|
addr += 4; |
|
|
|
addr += 4; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case opc_jsr_w: |
|
|
|
case opc_jsr_w: |
|
|
|
case opc_goto_w: |
|
|
|
case opc_goto_w: |
|
|
|
case opc_invokeinterface: |
|
|
|
case opc_invokeinterface: |
|
|
|
stream.skip(4); |
|
|
|
skip(stream, 4); |
|
|
|
addr+=5; |
|
|
|
addr+=5; |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
if (opcode == opc_newarray |
|
|
|
if (opcode == opc_newarray |
|
|
|
|| (opcode >= opc_bipush && opcode <= opc_aload) |
|
|
|
|| (opcode >= opc_bipush && opcode <= opc_aload) |
|
|
|
|| (opcode >= opc_istore && opcode <= opc_astore)) { |
|
|
|
|| (opcode >= opc_istore && opcode <= opc_astore)) { |
|
|
|
stream.skip(1); |
|
|
|
skip(stream, 1); |
|
|
|
addr += 2; |
|
|
|
addr += 2; |
|
|
|
} else if (opcode >= opc_ifeq && opcode <= opc_jsr |
|
|
|
} else if (opcode >= opc_ifeq && opcode <= opc_jsr |
|
|
|
|| opcode >= opc_getstatic && opcode <= opc_invokestatic) { |
|
|
|
|| opcode >= opc_getstatic && opcode <= opc_invokestatic) { |
|
|
|
stream.skip(2); |
|
|
|
skip(stream, 2); |
|
|
|
addr += 3; |
|
|
|
addr += 3; |
|
|
|
} else if (opcode == opc_xxxunusedxxx |
|
|
|
} else if (opcode == opc_xxxunusedxxx |
|
|
|
|| opcode >= opc_breakpoint) |
|
|
|
|| opcode >= opc_breakpoint) |
|
|
@ -664,7 +680,7 @@ public class MethodIdentifier extends Identifier implements Opcodes { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (IOException ex) { |
|
|
|
} catch (IOException ex) { |
|
|
|
ex.printStackTrace(); |
|
|
|
ex.printStackTrace(Obfuscator.err); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|