internal class RPC
{
// Fields
private static uint five_from_address = 0x1b6b088;
private static uint five_from_bytes = 0x4a54974c;
private static uint five_to_address = 0xb487c;
private static uint five_to_bytes = 0x49ab6784;
private static uint four_from_address = 0x1b6af88;
private static uint four_from_bytes = 0x4b6aab94;
private static uint four_to_address = 0x1215b14;
private static uint four_to_bytes = 0x489553ec;
private static uint function_address = 0x1b6ac00;
private static uint function2_address = 0x1b6ad00;
private static uint function3_address = 0x1b6ae00;
private static uint function4_address = 0x1b6af00;
private static uint function5_address = 0x1b6b000;
private static uint one_from_address = 0x1b6ac88;
private static uint one_from_bytes = 0x4a4aff80;
private static uint one_to_address = 0x1ac3c;
private static uint one_to_bytes = 0x49b4ffc4;
public static PS3API PS3 = new PS3API(SelectAPI.ControlConsole);
private static uint three_from_address = 0x1b6ae88;
private static uint three_from_bytes = 0x4b6aab4c;
private static uint three_to_address = 0x12159cc;
private static uint three_to_bytes = 0x48955434;
private static uint two_from_address = 0x1b6ad88;
private static uint two_from_bytes = 0x4b6aa5f0;
private static uint two_to_address = 0x1215370;
private static uint two_to_bytes = 0x48955990;
// Methods
public static int Call(uint func_address, params object[] parameters)
{
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.Extension.WriteInt32(0x10020000 + (num3 * 4), (int) parameters[index]);
num3++;
}
else if (parameters[index] is uint)
{
PS3.Extension.WriteUInt32(0x10020000 + (num3 * 4), (uint) parameters[index]);
num3++;
}
else
{
uint num7;
if (parameters[index] is string)
{
num7 = 0x10022000 + (num4 * 0x400);
PS3.Extension.WriteString(num7, Convert.ToString(parameters[index]));
PS3.Extension.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.Extension.WriteUInt32(0x10020000 + (num3 * 4), num7);
num3++;
num6 += (uint) input.Length;
}
}
index++;
}
PS3.Extension.WriteUInt32(0x1002004c, func_address);
Thread.Sleep(20);
return PS3.Extension.ReadInt32(0x10020050);
}
public static void Enable()
{
byte[] buffer = new byte[] {
0x7c, 8, 2, 0xa6, 0xf8, 1, 0, 0x80, 60, 0x60, 0x10, 2, 0x81, 0x83, 0, 0x4c,
0x2c, 12, 0, 0, 0x41, 130, 0, 100, 0x80, 0x83, 0, 4, 0x80, 0xa3, 0, 8,
0x80, 0xc3, 0, 12, 0x80, 0xe3, 0, 0x10, 0x81, 3, 0, 20, 0x81, 0x23, 0, 0x18,
0x81, 0x43, 0, 0x1c, 0x81, 0x63, 0, 0x20, 0xc0, 0x23, 0, 0x24, 0xc0, 0x43, 0, 40,
0xc0, 0x63, 0, 0x2c, 0xc0, 0x83, 0, 0x30, 0xc0, 0xa3, 0, 0x34, 0xc0, 0xc3, 0, 0x38,
0xc0, 0xe3, 0, 60, 0xc1, 3, 0, 0x40, 0xc1, 0x23, 0, 0x48, 0x80, 0x63, 0, 0,
0x7d, 0x89, 3, 0xa6, 0x4e, 0x80, 4, 0x21, 60, 0x80, 0x10, 2, 0x38, 160, 0, 0,
0x90, 0xa4, 0, 0x4c, 0x90, 100, 0, 80, 0xe8, 1, 0, 0x80, 0x7c, 8, 3, 0xa6,
0x38, 0x21, 0, 0x70
};
PS3.SetMemory(function_address, new byte[] { 0x4e, 0x80, 0, 0x20 });
Thread.Sleep(20);
PS3.SetMemory(function_address + 4, buffer);
PS3.SetMemory(0x10020000, new byte[0x2854]);
PS3.SetMemory(function_address, new byte[] { 0xf8, 0x21, 0xff, 0x91 });
PS3.Extension.WriteUInt32(one_from_address, one_from_bytes);
PS3.Extension.WriteUInt32(one_to_address, one_to_bytes);
PS3.SetMemory(function2_address, new byte[] { 0x4e, 0x80, 0, 0x20 });
Thread.Sleep(20);
PS3.SetMemory(function2_address + 4, buffer);
PS3.SetMemory(function2_address, new byte[] { 0xf8, 0x21, 0xff, 0x91 });
PS3.Extension.WriteUInt32(two_from_address, two_from_bytes);
PS3.Extension.WriteUInt32(two_to_address, two_to_bytes);
PS3.SetMemory(function3_address, new byte[] { 0x4e, 0x80, 0, 0x20 });
Thread.Sleep(20);
PS3.SetMemory(function3_address + 4, buffer);
PS3.SetMemory(function3_address, new byte[] { 0xf8, 0x21, 0xff, 0x91 });
PS3.Extension.WriteUInt32(three_from_address, three_from_bytes);
PS3.Extension.WriteUInt32(three_to_address, three_to_bytes);
PS3.SetMemory(function4_address, new byte[] { 0x4e, 0x80, 0, 0x20 });
Thread.Sleep(20);
PS3.SetMemory(function4_address + 4, buffer);
PS3.SetMemory(function4_address, new byte[] { 0xf8, 0x21, 0xff, 0x91 });
PS3.Extension.WriteUInt32(four_from_address, four_from_bytes);
PS3.Extension.WriteUInt32(four_to_address, four_to_bytes);
PS3.SetMemory(function5_address, new byte[] { 0x4e, 0x80, 0, 0x20 });
Thread.Sleep(20);
PS3.SetMemory(function5_address + 4, buffer);
PS3.SetMemory(function5_address, new byte[] { 0xf8, 0x21, 0xff, 0x91 });
PS3.Extension.WriteUInt32(five_from_address, five_from_bytes);
PS3.Extension.WriteUInt32(five_to_address, five_to_bytes);
}
public static void IsCCAPI(bool op)
{
if (op)
{
PS3.ChangeAPI(SelectAPI.ControlConsole);
}
else
{
PS3.ChangeAPI(SelectAPI.TargetManager);
}
}
private static byte[] ReverseBytes(byte[] toReverse)
{
Array.Reverse(toReverse);
return toReverse;
}
private static void WriteSingle(uint address, float input)
{
byte[] array = new byte[4];
BitConverter.GetBytes(input).CopyTo(array, 0);
Array.Reverse(array, 0, 4);
PS3.SetMemory(address, array);
}
private static void WriteSingle(uint address, float[] input)
{
int length = input.Length;
byte[] array = new byte[length * 4];
for (int i = 0; i < length; i++)
{
ReverseBytes(BitConverter.GetBytes(input[i])).CopyTo(array, (int) (i * 4));
}
PS3.SetMemory(address, array);
}
}