Advertisement
sharkbait263

BO2 1.16 Fixed RPC

Feb 28th, 2014
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.19 KB | None | 0 0
  1. public class RPC
  2.     {
  3.         private static PS3API DEX = new PS3API();
  4.  
  5.         #region Functions
  6.         private static uint function_address;
  7.         public static byte[] GetMemory5(uint Address, byte[] length)
  8.         {
  9.             DEX.GetMemory(Address, length);
  10.             return length;
  11.         }
  12.         public static void Connect()
  13.         {
  14.             DEX.ChangeAPI(SelectAPI.ControlConsole);
  15.             DEX.ConnectTarget();
  16.             DEX.AttachProcess();
  17.         }
  18.         public static byte[] GetMemory(uint address, int length)
  19.         {
  20.             byte[] buffer = new byte[length];
  21.             DEX.GetMemory(address, buffer);
  22.             return buffer;
  23.         }
  24.         public static void SetMemory(uint Address, byte[] Bytes)
  25.         {
  26.             DEX.SetMemory(Address, Bytes);
  27.         }
  28.         #endregion
  29.  
  30. using PS3Lib;
  31.        
  32.         #region RPC
  33.         public static uint Call(uint func_address, params object[] parameters)
  34.         {
  35.             int length = parameters.Length;
  36.             for (uint i = 0; i < length; i++)
  37.             {
  38.                 if (parameters[i] is int)
  39.                 {
  40.                     byte[] array = BitConverter.GetBytes((int)parameters[i]);
  41.                     Array.Reverse(array);
  42.                     SetMemory(0x10050008 + (i * 4), array);
  43.                 }
  44.                 else if (parameters[i] is uint)
  45.                 {
  46.                     byte[] buffer2 = BitConverter.GetBytes((uint)parameters[i]);
  47.                     Array.Reverse(buffer2);
  48.                     SetMemory(0x10050008 + (i * 4), buffer2);
  49.                 }
  50.                 else if (parameters[i] is string)
  51.                 {
  52.                     byte[] buffer3 = Encoding.UTF8.GetBytes(Convert.ToString(parameters[i]) + "\0");
  53.                     SetMemory(0x1005002c + (i * 0x150), buffer3);
  54.                     uint num3 = 0x1005002c + (i * 0x150);
  55.                     byte[] buffer4 = BitConverter.GetBytes(num3);
  56.                     Array.Reverse(buffer4);
  57.                     SetMemory(0x10050008 + (i * 4), buffer4);
  58.                 }
  59.             }
  60.             for (int j = 9 - length; j <= 9; j++)
  61.             {
  62.                 SetMemory((uint)(0x10050008 + (j * 4)), new byte[4]);
  63.             }
  64.             byte[] bytes = BitConverter.GetBytes(func_address);
  65.             Array.Reverse(bytes);
  66.             SetMemory(0x10050000, bytes);
  67.             System.Threading.Thread.Sleep(20);
  68.             byte[] GetX = new byte[4];
  69.             byte[] memory = GetMemory(0x10050004, 4);
  70.             Array.Reverse(memory);
  71.             return BitConverter.ToUInt32(memory, 0);
  72.         }
  73.  
  74.         public static void Enable_RPC()
  75.         {
  76.             SetMemory(function_address, new byte[] { 0x4e, 0x80, 0, 0x20 });
  77.             byte[] memory = new byte[] {
  78.                 0x7c, 8, 2, 0xa6, 0xf8, 1, 0, 0xd0, 0xdb, 0x21, 0, 0x88, 0xdb, 0x41, 0, 0x90,
  79.                 0xdb, 0x61, 0, 0x98, 0xdb, 0x81, 0, 160, 0xdb, 0xa1, 0, 0xa8, 0xdb, 0xc1, 0, 0xb0,
  80.                 0xdb, 0xe1, 0, 0xb8, 0xfb, 0xa1, 0, 0x70, 0xfb, 0xc1, 0, 120, 0xfb, 0xe1, 0, 0x80,
  81.                 0x3d, 0x60, 0x10, 5, 0x80, 0x6b, 0, 0, 0x2c, 3, 0, 0, 0x41, 130, 0, 60,
  82.                 0x80, 0x6b, 0, 8, 0x80, 0x8b, 0, 12, 0x80, 0xab, 0, 0x10, 0x80, 0xcb, 0, 20,
  83.                 0x80, 0xeb, 0, 0x18, 0x81, 11, 0, 0x1c, 0x81, 0x2b, 0, 0x20, 0x81, 0x4b, 0, 0x24,
  84.                 0x81, 0x6b, 0, 40, 0x48, 0, 0, 0x4d, 60, 0x80, 0x10, 5, 0x80, 100, 0, 4,
  85.                 0x38, 160, 0, 0, 0x90, 0xa4, 0, 0, 0xe8, 1, 0, 0xd0, 0x7c, 8, 3, 0xa6,
  86.                 0xcb, 0x21, 0, 0x88, 0xcb, 0x41, 0, 0x90, 0xcb, 0x61, 0, 0x98, 0xcb, 0x81, 0, 160,
  87.                 0xcb, 0xa1, 0, 0xa8, 0xcb, 0xc1, 0, 0xb0, 0xcb, 0xe1, 0, 0xb8, 0xeb, 0xa1, 0, 0x70,
  88.                 0xeb, 0xc1, 0, 120, 0xeb, 0xe1, 0, 0x80, 0x38, 0x21, 0, 0xc0, 0x4e, 0x80, 0, 0x20,
  89.                 0x3d, 0x80, 0x10, 5, 0x81, 140, 0, 0, 0x7c, 8, 2, 0xa6, 0xf8, 1, 0, 0x20,
  90.                 0x7d, 0x89, 3, 0xa6, 0x4e, 0x80, 4, 0x21, 0xe8, 1, 0, 0x20, 0x7c, 8, 3, 0xa6,
  91.                 0x4e, 0x80, 0, 0x20, 0x60, 0, 0, 0
  92.              };
  93.             SetMemory(function_address + 4, memory);
  94.             SetMemory(0x10050000, new byte[0xaac]);
  95.             SetMemory(function_address, new byte[] { 0xf8, 0x21, 0xff, 0x41 });
  96.         }
  97.  
  98.         public static uint Get_func_address()
  99.         {
  100.             for (uint i = 0x7a8e48; i < 0x1000000; i += 4)
  101.             {
  102.                 byte[] GetX2 = new byte[9];
  103.                 byte[] memory = GetMemory5(i, GetX2);
  104.                 if ((((memory[0] == 0x42) && (memory[1] == 200)) && ((memory[2] == 0) && (memory[3] == 0))) && (((memory[4] == 0x40) && (memory[5] == 0)) && ((memory[6] == 0) && (memory[7] == 0))))
  105.                 {
  106.                     return (i + 8);
  107.                 }
  108.             }
  109.             return 0;
  110.         }
  111.  
  112.         public static int Init()
  113.         {
  114.             function_address = Get_func_address();
  115.             if (function_address == 0)
  116.             {
  117.                 return -1;
  118.             }
  119.             Enable_RPC();
  120.             DEX.SetMemory(0x7AA240, new byte[] { 0x90, 0x64, 0x00, 0x04 });
  121.             return 0;
  122.         }
  123.         #endregion
  124.     }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement