Advertisement
OhDevOpsNGU

Call Of Duty World At War RPC

Sep 24th, 2015
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.94 KB | None | 0 0
  1.     public class RPC
  2.     {
  3.         public static uint function_address;
  4.  
  5.         public static int Init()
  6.         {
  7.             function_address = Get_func_address();
  8.             if (function_address == 0) return -1;
  9.             Enable_RPC();
  10.             return 0;
  11.         }
  12.  
  13.         public static uint Get_func_address()
  14.         {
  15.             for (uint i = 0x5C615C; i < 0x1000000; i += 4)
  16.             {
  17.                 byte[] bytes = PS3.GetMemory(i, 8);
  18.                 if (((bytes[0] == 0x4B) && (bytes[1] == 0xFF) && (bytes[2] == 0x03) && (bytes[3] == 0x15) && (bytes[4] == 0x60) && (bytes[5] == 0x00) && (bytes[6] == 0x00) && (bytes[7] == 0x00)))
  19.                 {
  20.                     return i + 0xC;
  21.                 }
  22.             }
  23.             return 0;
  24.         }
  25.  
  26.         public static void Enable_RPC()
  27.         {
  28.             PS3.SetMemory(function_address, new byte[] { 0x4E, 0x80, 0x00, 0x20 });
  29.             System.Threading.Thread.Sleep(20);
  30.             byte[] func = new byte[] { 0x7C, 0x08, 0x02, 0xA6, 0xF8, 0x01, 0x00, 0x80, 0x3C, 0x60, 0x10, 0x05, 0x81, 0x83, 0x00, 0x4C, 0x2C, 0x0C, 0x00, 0x00, 0x41, 0x82, 0x00, 0x64, 0x80, 0x83, 0x00, 0x04, 0x80, 0xA3, 0x00, 0x08, 0x80, 0xC3, 0x00, 0x0C, 0x80, 0xE3, 0x00, 0x10, 0x81, 0x03, 0x00, 0x14, 0x81, 0x23, 0x00, 0x18, 0x81, 0x43, 0x00, 0x1C, 0x81, 0x63, 0x00, 0x20, 0xC0, 0x23, 0x00, 0x24, 0xC0, 0x43, 0x00, 0x28, 0xC0, 0x63, 0x00, 0x2C, 0xC0, 0x83, 0x00, 0x30, 0xC0, 0xA3, 0x00, 0x34, 0xC0, 0xC3, 0x00, 0x38, 0xC0, 0xE3, 0x00, 0x3C, 0xC1, 0x03, 0x00, 0x40, 0xC1, 0x23, 0x00, 0x48, 0x80, 0x63, 0x00, 0x00, 0x7D, 0x89, 0x03, 0xA6, 0x4E, 0x80, 0x04, 0x21, 0x3C, 0x80, 0x10, 0x05, 0x38, 0xA0, 0x00, 0x00, 0x90, 0xA4, 0x00, 0x4C, 0x80, 0x64, 0x00, 0x50, 0xE8, 0x01, 0x00, 0x80, 0x7C, 0x08, 0x03, 0xA6, 0x38, 0x21, 0x00, 0x70, 0x4E, 0x80, 0x00, 0x20 };
  31.             PS3.SetMemory(function_address + 0x4, func);
  32.             PS3.SetMemory(0x10050000, new byte[0x2854]);
  33.             PS3.SetMemory(function_address, new byte[] { 0xF8, 0x21, 0xFF, 0x91 });
  34.         }
  35.  
  36.         public static int Call(uint func_address, params object[] parameters)
  37.         {
  38.             int num_params = parameters.Length;
  39.             uint num_floats = 0;
  40.             for (uint i = 0; i < num_params; i++)
  41.             {
  42.                 if (parameters[i] is int)
  43.                 {
  44.                     byte[] val = BitConverter.GetBytes((int)parameters[i]);
  45.                     Array.Reverse(val);
  46.                     PS3.SetMemory(0x10050000 + (i + num_floats) * 4, val);
  47.                 }
  48.                 else if (parameters[i] is uint)
  49.                 {
  50.                     byte[] val = BitConverter.GetBytes((uint)parameters[i]);
  51.                     Array.Reverse(val);
  52.                     PS3.SetMemory(0x10050000 + (i + num_floats) * 4, val);
  53.                 }
  54.                 else if (parameters[i] is string)
  55.                 {
  56.                     byte[] str = Encoding.UTF8.GetBytes(Convert.ToString(parameters[i]) + "\0");
  57.                     PS3.SetMemory(0x10050054 + i * 0x400, str);
  58.                     uint addr = 0x10050054 + i * 0x400;
  59.                     byte[] address = BitConverter.GetBytes(addr);
  60.                     Array.Reverse(address);
  61.                     PS3.SetMemory(0x10050000 + (i + num_floats) * 4, address);
  62.                 }
  63.                 else if (parameters[i] is float)
  64.                 {
  65.                     num_floats++;
  66.                     byte[] val = BitConverter.GetBytes((float)parameters[i]);
  67.                     Array.Reverse(val);
  68.                     PS3.SetMemory(0x10050024 + ((num_floats - 1) * 0x4), val);
  69.                 }
  70.             }
  71.             byte[] fadd = BitConverter.GetBytes(func_address);
  72.             Array.Reverse(fadd);
  73.             PS3.SetMemory(0x1005004C, fadd);
  74.             System.Threading.Thread.Sleep(20);
  75.             byte[] ret = PS3.GetMemory(0x10050050, 4);
  76.             Array.Reverse(ret);
  77.             return BitConverter.ToInt32(ret, 0);
  78.         }
  79.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement