Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using PS3Lib;
- namespace Gtav
- {
- class RPC
- {
- public static uint function1_address = 0x0;
- private static uint[] one_to_address = { 0x0, 0x0 };
- private static uint[] one_to_bytes = { 0x0, 0x0 };
- private static uint[] one_from_address = { 0x0, 0x0 };
- private static uint[] one_from_bytes = { 0x0, 0x0 };
- private static uint function2_address = 0x0;
- private static uint[] two_to_address = { 0x0, 0x0 };
- private static uint[] two_to_bytes = { 0x0, 0x0 };
- private static uint[] two_from_address = { 0x0, 0x0 };
- private static uint[] two_from_bytes = { 0x0, 0x0 };
- public static void UpdateAddresses()
- {
- function2_address = function1_address + 0x100;
- one_to_address[0] = function1_address - 0x95B338;
- one_to_bytes[0] = function1_address + 0x46DE8338;
- one_from_address[0] = function1_address + 0x88;
- one_from_bytes[0] = function1_address + 0x49B31C4C;
- two_to_address[0] = function2_address - 0x9595D4;
- two_to_bytes[0] = function2_address + 0x46DE64D4;
- two_from_address[0] = function2_address + 0x88;
- two_from_bytes[0] = function2_address + 0x49B338AC;
- one_to_address[1] = function1_address - 0x95FD78;
- one_to_bytes[1] = function1_address + 0x46DD0D78;
- one_from_address[1] = function1_address + 0x88;
- one_from_bytes[1] = function1_address + 0x49B1120C;
- two_to_address[1] = function2_address - 0x95E014;
- two_to_bytes[1] = function2_address + 0x46DCEF14;
- two_from_address[1] = function2_address + 0x88;
- two_from_bytes[1] = function2_address + 0x49B12E6C;
- }
- public static bool InUse = false;
- public static void Enable()
- {
- byte[] memory = new byte[] { 0x7C, 0x08, 0x02, 0xA6, 0xF8, 0x01, 0x00, 0x80, 0x3C, 0x60, 0x10, 0x02, 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, 0x02, 0x38, 0xA0, 0x00, 0x00, 0x90, 0xA4, 0x00, 0x4C, 0x90, 0x64, 0x00, 0x50, 0xE8, 0x01, 0x00, 0x80, 0x7C, 0x08, 0x03, 0xA6, 0x38, 0x21, 0x00, 0x70 };
- PS3.PS3_WriteBytes(function1_address, new byte[] { 0x4E, 0x80, 0x00, 0x20 });
- Thread.Sleep(20);
- PS3.PS3_WriteBytes(function1_address + 4, memory);
- PS3.PS3_WriteBytes(0x10020000, new byte[0x2854]);
- PS3.PS3_WriteBytes(function1_address, new byte[] { 0xF8, 0x21, 0xFF, 0x91 });
- PS3.PS3_WriteUInt32(one_from_address[Addresses.BLESBLUS], one_from_bytes[Addresses.BLESBLUS]);
- PS3.PS3_WriteUInt32(one_to_address[Addresses.BLESBLUS], one_to_bytes[Addresses.BLESBLUS]);
- PS3.PS3_WriteBytes(function2_address, new byte[] { 0x4E, 0x80, 0x00, 0x20 });
- Thread.Sleep(20);
- PS3.PS3_WriteBytes(function2_address + 4, memory);
- PS3.PS3_WriteBytes(function2_address, new byte[] { 0xF8, 0x21, 0xFF, 0x91 });
- PS3.PS3_WriteUInt32(two_from_address[Addresses.BLESBLUS], two_from_bytes[Addresses.BLESBLUS]);
- PS3.PS3_WriteUInt32(two_to_address[Addresses.BLESBLUS], two_to_bytes[Addresses.BLESBLUS]);
- }
- public static void WaitForCall()
- {
- while (InUse)
- {
- }
- }
- public static int Call(string Native, params object[] parameters)
- {
- return Call(Hook.GetNativeFunctionAddr(Natives.GetHash(Native)), parameters);
- }
- public static int Call(uint func_address, params object[] parameters)
- {
- InUse = true;
- int length = parameters.Length;
- int index = 0;
- uint num3 = 0;
- uint num4 = 0;
- uint num5 = 0;
- uint num6 = 0;
- while (index < length)
- {
- if (parameters[index] is int)
- {
- PS3.PS3_WriteInt32(0x10020000 + (num3 * 4), (int)parameters[index]);
- num3++;
- }
- else if (parameters[index] is uint)
- {
- PS3.PS3_WriteUInt32(0x10020000 + (num3 * 4), (uint)parameters[index]);
- num3++;
- }
- else
- {
- uint num7;
- if (parameters[index] is string)
- {
- num7 = 0x10022000 + (num4 * 0x400);
- PS3.PS3_WriteString(num7, Convert.ToString(parameters[index]));
- PS3.PS3_WriteUInt32(0x10020000 + (num3 * 4), num7);
- num3++;
- num4++;
- }
- else if (parameters[index] is float)
- {
- WriteSingle(0x10020024 + (num5 * 4), (float)parameters[index]);
- num5++;
- }
- else if (parameters[index] is float[])
- {
- float[] input = (float[])parameters[index];
- num7 = 0x10021000 + (num6 * 4);
- WriteSingle(num7, input);
- PS3.PS3_WriteUInt32(0x10020000 + (num3 * 4), num7);
- num3++;
- num6 += (uint)input.Length;
- }
- }
- index++;
- }
- PS3.PS3_WriteUInt32(0x1002004C, func_address);
- Thread.Sleep(60);
- int ReturnVal = PS3.PS3_ReadInt32(0x10020050);
- InUse = false;
- return ReturnVal;
- }
- private static void WriteSingle(uint address, float input)
- {
- byte[] Bytes = new byte[4];
- BitConverter.GetBytes(input).CopyTo((Array)Bytes, 0);
- Array.Reverse((Array)Bytes, 0, 4);
- PS3.PS3_WriteBytes(address, Bytes);
- }
- private static void WriteSingle(uint address, float[] input)
- {
- int length = input.Length;
- byte[] Bytes = new byte[length * 4];
- for (int index = 0; index < length; ++index)
- ReverseBytes(BitConverter.GetBytes(input[index])).CopyTo((Array)Bytes, index * 4);
- PS3.PS3_WriteBytes(address, Bytes);
- }
- private static byte[] ReverseBytes(byte[] toReverse)
- {
- Array.Reverse((Array)toReverse);
- return toReverse;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement