Advertisement
SonOfABeach

Untitled

Feb 9th, 2015
800
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.98 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3. using PS3Lib;
  4.  
  5. public static class RPC
  6. {
  7. public static PS3API PS3 = new PS3API(SelectAPI.ControlConsole);//Make this public, so you can access it from the other class
  8. public static uint SFA1 = 0x01B73580;//Make this public so we can check if RPC is already enabled, default values 00
  9. private static uint EFA1 = 0x01B73608;
  10. private static uint SFA2 = 0x01B73680;
  11. private static uint EFA2 = 0x01B73708;
  12. private static uint SFA3 = 0x01B73780;
  13. private static uint EFA3 = 0x01B73808;
  14. private static uint BFA1 = 0x185B4;
  15. private static uint BAB1 = 0x185C0;
  16. private static uint BFA2 = 0x1AC3C;
  17. private static uint BAB2 = 0x1AC08;
  18. private static uint BFA3 = 0xB490C;
  19. private static uint BAB3 = 0xB4864;
  20.  
  21. public static uint CBAB(uint F, uint T)
  22. {
  23. if (F > T)
  24. return 0x4C000000 - (F - T);
  25. else if (F < T)
  26. return T - F + 0x48000000;
  27. else
  28. return 0x48000000;
  29. }
  30.  
  31. public static void Enable()
  32. {
  33. byte[] mem = new byte[] { 0xF8, 0x21, 0xFF, 0x91, 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 };
  34. PS3.SetMemory(SFA1, mem);
  35. PS3.SetMemory(SFA2, mem);
  36. PS3.SetMemory(SFA3, mem);
  37. PS3.Extension.WriteUInt32(EFA1, CBAB(EFA1, BAB1));
  38. PS3.Extension.WriteUInt32(BFA1, CBAB(BFA1, SFA1));
  39. PS3.Extension.WriteUInt32(EFA2, CBAB(EFA2, BAB2));
  40. PS3.Extension.WriteUInt32(BFA2, CBAB(BFA2, SFA2));
  41. PS3.Extension.WriteUInt32(EFA3, CBAB(EFA3, BAB3));
  42. PS3.Extension.WriteUInt32(BFA3, CBAB(BFA3, SFA3));
  43. }
  44.  
  45. public static int Call(uint func_address, params object[] parameters)
  46. {
  47. int length = parameters.Length;
  48. int index = 0;
  49. uint num3 = 0;
  50. uint num4 = 0;
  51. uint num5 = 0;
  52. uint num6 = 0;
  53. while (index < length)
  54. {
  55. if (parameters[index] is int)
  56. {
  57. PS3.Extension.WriteInt32(0x10020000 + (num3 * 4), (int)parameters[index]);
  58. num3++;
  59. }
  60. else if (parameters[index] is uint)
  61. {
  62. PS3.Extension.WriteUInt32(0x10020000 + (num3 * 4), (uint)parameters[index]);
  63. num3++;
  64. }
  65. else
  66. {
  67. uint num7;
  68. if (parameters[index] is string)
  69. {
  70. num7 = 0x10022000 + (num4 * 0x400);
  71. PS3.Extension.WriteString(num7, Convert.ToString(parameters[index]));
  72. PS3.Extension.WriteUInt32(0x10020000 + (num3 * 4), num7);
  73. num3++;
  74. num4++;
  75. }
  76. else if (parameters[index] is float)
  77. {
  78. WriteSingle(0x10020024 + (num5 * 4), (float)parameters[index]);
  79. num5++;
  80. }
  81. else if (parameters[index] is float[])
  82. {
  83. float[] input = (float[])parameters[index];
  84. num7 = 0x10021000 + (num6 * 4);
  85. WriteSingle(num7, input);
  86. PS3.Extension.WriteUInt32(0x10020000 + (num3 * 4), num7);
  87. num3++;
  88. num6 += (uint)input.Length;
  89. }
  90. }
  91. index++;
  92. }
  93. PS3.Extension.WriteUInt32(0x1002004C, func_address);
  94. Thread.Sleep(20);
  95. return PS3.Extension.ReadInt32(0x10020050);
  96. }
  97.  
  98. private static void WriteSingle(uint address, float input)
  99. {
  100. byte[] Bytes = new byte[4];
  101. BitConverter.GetBytes(input).CopyTo((Array)Bytes, 0);
  102. Array.Reverse((Array)Bytes, 0, 4);
  103. PS3.SetMemory(address, Bytes);
  104. }
  105.  
  106. private static void WriteSingle(uint address, float[] input)
  107. {
  108. int length = input.Length;
  109. byte[] Bytes = new byte[length * 4];
  110. for (int index = 0; index < length; ++index)
  111. ReverseBytes(BitConverter.GetBytes(input[index])).CopyTo((Array)Bytes, index * 4);
  112. PS3.SetMemory(address, Bytes);
  113. }
  114.  
  115. private static byte[] ReverseBytes(byte[] toReverse)
  116. {
  117. Array.Reverse((Array)toReverse);
  118. return toReverse;
  119. }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement