Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RPC
- {
- private static PS3API DEX = new PS3API();
- #region Functions
- private static uint function_address;
- public static byte[] GetMemory5(uint Address, byte[] length)
- {
- DEX.GetMemory(Address, length);
- return length;
- }
- public static void Connect()
- {
- DEX.ChangeAPI(SelectAPI.ControlConsole);
- DEX.ConnectTarget();
- DEX.AttachProcess();
- }
- public static byte[] GetMemory(uint address, int length)
- {
- byte[] buffer = new byte[length];
- DEX.GetMemory(address, buffer);
- return buffer;
- }
- public static void SetMemory(uint Address, byte[] Bytes)
- {
- DEX.SetMemory(Address, Bytes);
- }
- #endregion
- using PS3Lib;
- #region RPC
- public static uint Call(uint func_address, params object[] parameters)
- {
- int length = parameters.Length;
- for (uint i = 0; i < length; i++)
- {
- if (parameters[i] is int)
- {
- byte[] array = BitConverter.GetBytes((int)parameters[i]);
- Array.Reverse(array);
- SetMemory(0x10050008 + (i * 4), array);
- }
- else if (parameters[i] is uint)
- {
- byte[] buffer2 = BitConverter.GetBytes((uint)parameters[i]);
- Array.Reverse(buffer2);
- SetMemory(0x10050008 + (i * 4), buffer2);
- }
- else if (parameters[i] is string)
- {
- byte[] buffer3 = Encoding.UTF8.GetBytes(Convert.ToString(parameters[i]) + "\0");
- SetMemory(0x1005002c + (i * 0x150), buffer3);
- uint num3 = 0x1005002c + (i * 0x150);
- byte[] buffer4 = BitConverter.GetBytes(num3);
- Array.Reverse(buffer4);
- SetMemory(0x10050008 + (i * 4), buffer4);
- }
- }
- for (int j = 9 - length; j <= 9; j++)
- {
- SetMemory((uint)(0x10050008 + (j * 4)), new byte[4]);
- }
- byte[] bytes = BitConverter.GetBytes(func_address);
- Array.Reverse(bytes);
- SetMemory(0x10050000, bytes);
- System.Threading.Thread.Sleep(20);
- byte[] GetX = new byte[4];
- byte[] memory = GetMemory(0x10050004, 4);
- Array.Reverse(memory);
- return BitConverter.ToUInt32(memory, 0);
- }
- public static void Enable_RPC()
- {
- SetMemory(function_address, new byte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, 0x20, 0x60, 0, 0, 0
- };
- SetMemory(function_address + 4, memory);
- SetMemory(0x10050000, new byte[0xaac]);
- SetMemory(function_address, new byte[] { 0xf8, 0x21, 0xff, 0x41 });
- }
- public static uint Get_func_address()
- {
- for (uint i = 0x7a8e48; i < 0x1000000; i += 4)
- {
- byte[] GetX2 = new byte[9];
- byte[] memory = GetMemory5(i, GetX2);
- 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))))
- {
- return (i + 8);
- }
- }
- return 0;
- }
- public static int Init()
- {
- function_address = Get_func_address();
- if (function_address == 0)
- {
- return -1;
- }
- Enable_RPC();
- DEX.SetMemory(0x7AA240, new byte[] { 0x90, 0x64, 0x00, 0x04 });
- return 0;
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement