Advertisement
OSBotMerccy

Untitled

Jul 8th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. public static int getMultiplier(String clazz, String field) {
  2. HashMap<String, Integer> multipliers = new HashMap<String, Integer>();
  3. for (ClassGen cg : parsedClasses.values()) {
  4. ConstantPoolGen cpg = cg.getConstantPool();
  5. for (Method m : cg.getMethods()) {
  6. if (m.isAbstract() || m.isNative())
  7. continue;
  8. try {
  9. InstructionList il = new InstructionList(m.getCode()
  10. .getCode());
  11. InstructionHandle curr = il.getStart();
  12. while (!curr.equals(il.getEnd())) {
  13. if (curr.getInstruction() instanceof GETFIELD
  14. || curr.getInstruction() instanceof GETSTATIC) {
  15. FieldInstruction fi = (FieldInstruction) curr
  16. .getInstruction();
  17. if (fi.getClassName(cpg).equals(clazz)
  18. && fi.getFieldName(cpg).equals(field)) {
  19. InstructionHandle mulIns = curr;
  20. for (int i = 0; i < ((curr.getInstruction() instanceof GETSTATIC) ? 2
  21. : 5); ++i) {
  22. if (mulIns.getInstruction() instanceof IMUL)
  23. break;
  24. if (mulIns.getNext() == null)
  25. break;
  26. mulIns = mulIns.getNext();
  27. }
  28. if (!(mulIns.getInstruction() instanceof IMUL))
  29. break;
  30. InstructionHandle multi = mulIns;
  31. for (int i = 0; i < ((curr.getInstruction() instanceof GETSTATIC) ? 2
  32. : 5); ++i) {
  33. if (multi.getInstruction() instanceof LDC
  34. || multi.getInstruction() instanceof LDC_W)
  35. break;
  36. if (multi.getPrev() == null)
  37. break;
  38. multi = multi.getPrev();
  39. if (multi.getInstruction() instanceof AALOAD) {
  40. multi = multi.getPrev();
  41. multi = multi.getPrev();
  42. multi = multi.getPrev();
  43. }
  44. }
  45. if (!(multi.getInstruction() instanceof LDC)
  46. && !(multi.getInstruction() instanceof LDC_W))
  47. break;
  48. if (multi.getInstruction() instanceof LDC) {
  49. int temp = (Integer) ((LDC) multi
  50. .getInstruction()).getValue(cpg);
  51. if (temp != 0) {
  52. if (multipliers.containsKey(temp + ""))
  53. multipliers
  54. .put(temp + "", multipliers
  55. .get(temp + "") + 1);
  56. else
  57. multipliers.put(temp + "", 1);
  58. }
  59. }
  60. }
  61. }
  62. curr = curr.getNext();
  63. }
  64. } catch (Exception e) {
  65. }
  66. }
  67. }
  68.  
  69. int max = 0;
  70. int multi = 1;
  71.  
  72. for (String s : multipliers.keySet()) {
  73. if (multipliers.get(s) > max) {
  74. multi = Integer.parseInt(s);
  75. max = multipliers.get(s);
  76. }
  77. }
  78. return multi;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement