Advertisement
Mango_Knife

Mw3 FPS RPC - 1.24

May 19th, 2014
1,331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.98 KB | None | 0 0
  1.                 #region Vezah FPS RPC
  2.                 public static uint func_address = 0x0277208; //FPS Address 1.24
  3.                 /*
  4.                  * MW3 FPS RPC by VezahHFH!
  5.                  * This function get written at the FPS Offset!
  6.                  *
  7.                      lis r28, 0x1005
  8.                      lwz r12, 0x48(r28)
  9.                      cmpwi r12, 0
  10.                      beq loc_277290
  11.                      lwz r3, 0x00(r28)
  12.                      lwz r4, 0x04(r28)
  13.                      lwz r5, 0x08(r28)
  14.                      lwz r6, 0x0C(r28)
  15.                      lwz r7, 0x10(r28)
  16.                      lwz r8, 0x14(r28)
  17.                      lwz r9, 0x18(r28)
  18.                      lwz r10, 0x1C(r28)
  19.                      lwz r11, 0x20(r28)
  20.                      lfs f1, 0x24(r28)
  21.                      lfs f2, 0x28(r28)
  22.                      lfs f3, 0x2C(r28)
  23.                      lfs f4, 0x30(r28)
  24.                      lfs f5, 0x34(r28)
  25.                      lfs f6, 0x38(r28)
  26.                      lfs f7, 0x3C(r28)
  27.                      lfs f8, 0x40(r28)
  28.                      lfs f9, 0x44(r28)
  29.                      mtctr r12
  30.                      bctrl
  31.                      li r4, 0
  32.                      stw r4, 0x48(r28)
  33.                      stw r3, 0x4C(r28)
  34.                      stfs f1, 0x50(r28)
  35.                      b loc_277290
  36.                  */
  37.                 public static uint GetFuncReturn()
  38.                 {
  39.                     byte[] ret = new byte[4];
  40.                     GetMemoryR(0x114AE64, ref ret);
  41.                     Array.Reverse(ret);
  42.                     return BitConverter.ToUInt32(ret, 0);
  43.                 }
  44.                 public static void Enable()
  45.                 {
  46.                     byte[] WritePPC = new byte[] {0x3F,0x80,0x10,0x05,0x81,0x9C,0x00,0x48,0x2C,0x0C,0x00,0x00,0x41,0x82,0x00,0x78,
  47.                                         0x80,0x7C,0x00,0x00,0x80,0x9C,0x00,0x04,0x80,0xBC,0x00,0x08,0x80,0xDC,0x00,0x0C,
  48.                                         0x80,0xFC,0x00,0x10,0x81,0x1C,0x00,0x14,0x81,0x3C,0x00,0x18,0x81,0x5C,0x00,0x1C,
  49.                                         0x81,0x7C,0x00,0x20,0xC0,0x3C,0x00,0x24,0xC0,0x5C,0x00,0x28,0xC0,0x7C,0x00,0x2C,
  50.                                         0xC0,0x9C,0x00,0x30,0xC0,0xBC,0x00,0x34,0xC0,0xDC,0x00,0x38,0xC0,0xFC,0x00,0x3C,
  51.                                         0xC1,0x1C,0x00,0x40,0xC1,0x3C,0x00,0x44,0x7D,0x89,0x03,0xA6,0x4E,0x80,0x04,0x21,
  52.                                         0x38,0x80,0x00,0x00,0x90,0x9C,0x00,0x48,0x90,0x7C,0x00,0x4C,0xD0,0x3C,0x00,0x50,
  53.                                         0x48,0x00,0x00,0x14};
  54.                     PS3.SetMemory(func_address, new byte[] { 0x41 });
  55.                     PS3.SetMemory(func_address + 4, WritePPC);
  56.                     PS3.SetMemory(func_address, new byte[] { 0x40 });
  57.                     Thread.Sleep(10);
  58.                     RPC.DestroyAll();
  59.                 }
  60.                 public static Int32 Call(UInt32 address, params Object[] parameters)
  61.                 {
  62.                     Int32 length = parameters.Length;
  63.                     Int32 index = 0;
  64.                     UInt32 count = 0;
  65.                     UInt32 Strings = 0;
  66.                     UInt32 Single = 0;
  67.                     UInt32 Array = 0;
  68.                     while (index < length)
  69.                     {
  70.                         if (parameters[index] is Int32)
  71.                         {
  72.                             PS3.Extension.WriteInt32(0x10050000 + (count * 4), (Int32)parameters[index]);
  73.                             count++;
  74.                         }
  75.                         else if (parameters[index] is UInt32)
  76.                         {
  77.                             PS3.Extension.WriteUInt32(0x10050000 + (count * 4), (UInt32)parameters[index]);
  78.                             count++;
  79.                         }
  80.                         else if (parameters[index] is Int16)
  81.                         {
  82.                             PS3.Extension.WriteInt16(0x10050000 + (count * 4), (Int16)parameters[index]);
  83.                             count++;
  84.                         }
  85.                         else if (parameters[index] is UInt16)
  86.                         {
  87.                             PS3.Extension.WriteUInt16(0x10050000 + (count * 4), (UInt16)parameters[index]);
  88.                             count++;
  89.                         }
  90.                         else if (parameters[index] is Byte)
  91.                         {
  92.                             PS3.Extension.WriteByte(0x10050000 + (count * 4), (Byte)parameters[index]);
  93.                             count++;
  94.                         } //Should work now :D let me try
  95.                         else
  96.                         {
  97.                             UInt32 pointer;
  98.                             if (parameters[index] is String)
  99.                             {
  100.                                 pointer = 0x10052000 + (Strings * 0x400);
  101.                                 PS3.Extension.WriteString(pointer, Convert.ToString(parameters[index]));
  102.                                 PS3.Extension.WriteUInt32(0x10050000 + (count * 4), pointer);
  103.                                 count++;
  104.                                 Strings++;
  105.                             }
  106.                             else if (parameters[index] is Single)
  107.                             {
  108.                                 WriteSingle(0x10050024 + (Single * 4), (Single)parameters[index]);
  109.                                 Single++;
  110.                             }
  111.                             else if (parameters[index] is Single[])
  112.                             {
  113.                                 Single[] Args = (Single[])parameters[index];
  114.                                 pointer = 0x10051000 + Array * 4;
  115.                                 WriteSingle(pointer, Args);
  116.                                 PS3.Extension.WriteUInt32(0x10050000 + count * 4, pointer);
  117.                                 count++;
  118.                                 Array += (UInt32)Args.Length;
  119.                             }
  120.  
  121.                         }
  122.                         index++;
  123.                     }
  124.                     PS3.Extension.WriteUInt32(0x10050048, address);
  125.                     Thread.Sleep(20);
  126.                     return PS3.Extension.ReadInt32(0x1005004c);
  127.                 }
  128.                 private static void WriteSingle(uint address, float input)
  129.                 {
  130.                     byte[] array = new byte[4];
  131.                     BitConverter.GetBytes(input).CopyTo(array, 0);
  132.                     Array.Reverse(array, 0, 4);
  133.                     PS3.SetMemory(address, array);
  134.                 }
  135.                 private static byte[] ReverseBytes(byte[] inArray)
  136.                 {
  137.                     Array.Reverse(inArray);
  138.                     return inArray;
  139.                 }
  140.                 private static void WriteSingle(uint address, float[] input)
  141.                 {
  142.                     int length = input.Length;
  143.                     byte[] array = new byte[length * 4];
  144.                     for (int i = 0; i < length; i++)
  145.                     {
  146.                         ReverseBytes(BitConverter.GetBytes(input[i])).CopyTo(array, (int)(i * 4));
  147.                     }
  148.                     PS3.SetMemory(address, array);
  149.                 }
  150.                 public static void DestroyAll()
  151.                 {
  152.                     Byte[] clear = new Byte[0xB4 * 1024];
  153.                     PS3.SetMemory(0xF0E10C, clear);
  154.                 }
  155.                 private static byte[] ReadBytes(uint address, int length)
  156.                 {
  157.                     return GetMemory(address, length);
  158.                 }
  159.                 public static Single[] ReadSingle(uint address, int length)
  160.                 {
  161.                     byte[] mem = ReadBytes(address, length * 4);
  162.                     Array.Reverse(mem);
  163.                     float[] numArray = new float[length];
  164.                     for (int index = 0; index < length; ++index)
  165.                         numArray[index] = BitConverter.ToSingle(mem, (length - 1 - index) * 4);
  166.                     return numArray;
  167.                 }
  168.                 #endregion
  169.                 #region PlayerFX
  170.                 public static uint PlayFX(float[] Origin, int EffectIndex)
  171.                 {
  172.                     uint ent = (uint)RPC.Call(0x1C0B7C, Origin, 0x56); //G_Temp
  173.                     PS3.Extension.WriteInt32(ent + 0xA0, EffectIndex);
  174.                     PS3.Extension.WriteInt32(ent + 0xD8, 0);
  175.                     PS3.Extension.WriteFloat(ent + 0x40, 0f);
  176.                     PS3.Extension.WriteFloat(ent + 0x44, 0f);
  177.                     PS3.Extension.WriteFloat(ent + 0x3C, 270f);
  178.                     return ent;
  179.                 }
  180.                 #endregion
  181.                 public float[] GetOrigin(uint client)
  182.                 {
  183.                     float[] Origin;
  184.                     Origin = ReadSingle(0x0110A29C + 0x3980 * client, 3);
  185.                     return Origin;
  186.                 }
  187.                 private float[] ReadSingle(uint address, int length)
  188.                 {
  189.                     byte[] memory = GetMemory(address, length * 4);
  190.                     ReverseBytes(memory);
  191.                     float[] numArray = new float[length];
  192.                     for (int i = 0; i < length; i++)
  193.                     {
  194.                         numArray[i] = BitConverter.ToSingle(memory, ((length - 1) - i) * 4);
  195.                     }
  196.                     return numArray;
  197.                 }
  198.                 //Use this to play the FX - Its a Single[]
  199.                 public static void SetFX(UInt32 Client,Int32 FX_Value)
  200.                 {
  201.                     Single[] Origin = GetOrigin(Client);
  202.                     Mw3Library.Multiplayer.RPC.PlayFX(Origin, FX_Value);
  203.                 }
  204.                 public static byte[] GetMemory(uint Offset, int Length)
  205.                 {
  206.                     byte[] buffer = new byte[Length];
  207.                     PS3.GetMemory(Offset, buffer);
  208.                     return buffer;
  209.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement