Advertisement
gopro2027

Easy branch absolute PPC generator (PatchInJump)

Apr 16th, 2021
1,462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. package com.main;
  2.  
  3. public class GenerateBlaBa {
  4.  
  5.     public static void main(String[] args) {
  6.         //the only two instructions it supports lmao
  7.         gen("bla 0x1234567");
  8.         gen("ba 0xAB1234");
  9.        
  10.         //same output as above
  11.         gen("bl 0x1234567");
  12.         gen("b 0xAB1234");
  13.     }
  14.    
  15.     public static void gen(String instruction) {
  16.         String spacesplit[] = instruction.split(" ");
  17.         String l = spacesplit[0].contains("l")?"l":"";
  18.         String firstHalf = spacesplit[1].substring(0, spacesplit[1].length() - 4);
  19.         String secondHalf =  "0x"+instruction.substring(instruction.length() - 4);
  20.         System.out.println("__asm(\"lis %r11, "+firstHalf+"\");\r\n" +
  21.                 "__asm(\"addi %r11, %r11, "+secondHalf+"\");\r\n" +
  22.                 "__asm(\"mtctr %r11\");\r\n" +
  23.                 "__asm(\"bctr"+l+"\");");
  24.         System.out.println();
  25.     }
  26.  
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement