Advertisement
Guest User

Untitled

a guest
Jul 8th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. else if ((m.name.equals(targetMethod3Name) && m.desc
  2. .equals("(Ljava/awt/image/BufferedImage;)Ljava/awt/image/BufferedImage;"))) {
  3. System.out
  4. .println("********* [ImageBufferDowload] Inside target3 method!");
  5.  
  6. AbstractInsnNode currentNode = null;
  7. AbstractInsnNode targetNode = null;
  8. AbstractInsnNode targetNode2 = null;
  9.  
  10. @SuppressWarnings("unchecked")
  11. Iterator<AbstractInsnNode> iter = m.instructions.iterator();
  12. int index = -1;
  13. int passage = 0;
  14. // On boucle jusqu'a trouver le premier bipush (16)
  15. while (iter.hasNext()) {
  16. index++;
  17. currentNode = iter.next();
  18. System.out.println("line " + index + " : " + currentNode.getOpcode());
  19. // Found it! save the index location of instruction FDIV and
  20. // the node for this instruction
  21. if (currentNode.getOpcode() == BIPUSH) {
  22. passage++;
  23. if(passage == 1){
  24. System.out.println("1er Bipush");
  25. targetNode = currentNode;
  26. bipush_index = index;
  27. }
  28. if (passage == 2 ){
  29. System.out.println("2eme Bipush");
  30. targetNode = currentNode;
  31. break;
  32. }
  33.  
  34. }
  35. }
  36.  
  37. // on créer les variables à supprimer pour la hauteur
  38. AbstractInsnNode remNode3 = m.instructions
  39. .get(bipush_index + 5);
  40. AbstractInsnNode remNode4 = m.instructions
  41. .get(bipush_index + 6);
  42.  
  43. // on les supprime
  44. m.instructions.remove(remNode3);
  45. m.instructions.remove(remNode4);
  46.  
  47. // on créer les instruction à insérer
  48. InsnList toInject2 = new InsnList();
  49. toInject2.add(new VarInsnNode(ALOAD, 1));
  50. toInject2.add(new MethodInsnNode(INVOKEVIRTUAL,
  51. "java/awt/image/BufferedImage", "getHeight", "()I"));
  52. toInject2.add(new FieldInsnNode(PUTFIELD,
  53. "net/minecraft/client/renderer/ImageBufferDownload",
  54. "imageHeight", "I"));
  55.  
  56. // on les insère
  57. m.instructions.insert(targetNode2, toInject2);
  58.  
  59. // on créer les variables à supprimer pour la largeur
  60. AbstractInsnNode remNode1 = m.instructions.get(bipush_index);
  61. AbstractInsnNode remNode2 = m.instructions
  62. .get(bipush_index + 1);
  63.  
  64. // on les supprime
  65. m.instructions.remove(remNode1);
  66. m.instructions.remove(remNode2);
  67.  
  68. // on créer les instruction à insérer
  69. InsnList toInject = new InsnList();
  70. toInject.add(new VarInsnNode(ALOAD, 1));
  71. toInject.add(new MethodInsnNode(INVOKEVIRTUAL,
  72. "java/awt/image/BufferedImage", "getWidth", "()I"));
  73. toInject.add(new FieldInsnNode(PUTFIELD,
  74. "net/minecraft/client/renderer/ImageBufferDownload",
  75. "imageWidth", "I"));
  76. // on les insère
  77. m.instructions.insert(targetNode, toInject);
  78. System.out
  79. .println("[ImageBufferDownload] Patching Method3 Complete!");
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement