Mathiis95

Hook - Grand Theft Auto V - 1.26 [PS3]

Apr 9th, 2016
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.50 KB | None | 0 0
  1. public class Hook
  2.     {
  3.         public static CCAPI PS3 = new CCAPI();
  4.         private static uint SFA4 = 0x1883210;
  5.  
  6.         public static int Call(uint func_address, params object[] parameters)
  7.         {
  8.             int length = parameters.Length;
  9.             int index = 0;
  10.             uint num3 = 0;
  11.             uint num4 = 0;
  12.             uint num5 = 0;
  13.             uint num6 = 0;
  14.             while (index < length)
  15.             {
  16.                 if (parameters[index] is int)
  17.                 {
  18.                     PS3.Extension.WriteInt32(0x10020000 + (num3 * 4), (int)parameters[index]);
  19.                     num3++;
  20.                 }
  21.                 else if (parameters[index] is uint)
  22.                 {
  23.                     PS3.Extension.WriteUInt32(0x10020000 + (num3 * 4), (uint)parameters[index]);
  24.                     num3++;
  25.                 }
  26.                 else
  27.                 {
  28.                     uint num7;
  29.                     if (parameters[index] is string)
  30.                     {
  31.                         num7 = 0x10022000 + (num4 * 0x400);
  32.                         PS3.Extension.WriteString(num7, Convert.ToString(parameters[index]));
  33.                         PS3.Extension.WriteUInt32(0x10020000 + (num3 * 4), num7);
  34.                         num3++;
  35.                         num4++;
  36.                     }
  37.                     else if (parameters[index] is float)
  38.                     {
  39.                         WriteSingle(0x10020024 + (num5 * 4), (float)parameters[index]);
  40.                         num5++;
  41.                     }
  42.                     else if (parameters[index] is float[])
  43.                     {
  44.                         float[] input = (float[])parameters[index];
  45.                         num7 = 0x10021000 + (num6 * 4);
  46.                         WriteSingle(num7, input);
  47.                         PS3.Extension.WriteUInt32(0x10020000 + (num3 * 4), num7);
  48.                         num3++;
  49.                         num6 += (uint)input.Length;
  50.                     }
  51.                 }
  52.                 index++;
  53.             }
  54.             PS3.Extension.WriteUInt32(0x1002004C, func_address);
  55.             for (;;)
  56.             {
  57.                 if (PS3.Extension.ReadUInt32(0x1002004C) == 0)
  58.                 {
  59.                     System.Threading.Thread.Sleep(8);
  60.                     break;
  61.                 }
  62.             }
  63.             return PS3.Extension.ReadInt32(0x10020050);
  64.         }
  65.  
  66.  
  67.         public static bool IsEnable()
  68.         {
  69.             bool reslut = false;
  70.             if (PS3.GetBytes(0x18831f0, 4).SequenceEqual(new byte[] { 0x3D, 0x60, 0x10, 0x05 }))
  71.                 reslut = true;
  72.             return reslut;
  73.         }
  74.  
  75.         static byte[] patchjmp(uint is_player_online)
  76.         {
  77.             is_player_online += 0xC;
  78.             uint a = 0x18831f0;
  79.  
  80.             uint bytes = a - is_player_online;
  81.             byte[] f = new byte[4];
  82.             byte[] result = new byte[4];
  83.             f[3] = (byte)(bytes >> 24);
  84.             f[2] = (byte)(bytes >> 16);
  85.             f[1] = (byte)(bytes >> 8);
  86.             f[0] = (byte)(bytes);
  87.  
  88.             result[3] = (byte)(f[0] + 1);
  89.             result[2] = f[1];
  90.             result[1] = f[2];
  91.             result[0] = 0x49;
  92.  
  93.             return result;
  94.         }
  95.  
  96.  
  97.         public static void Enable(uint is_player_online)
  98.         {
  99.             byte[] buffer2 = new byte[] { 0xf8, 0x21, 0xfd, 0xA1, 0x7c, 8, 2, 0xa6, 0xf8, 1, 0x02, 0x70, 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, 0x02, 0x70, 0x7c, 8, 3, 0xa6, 0x38, 0x21, 0x02, 0x60, 0x38, 0x60, 0x00, 0x03, 0x4E, 0x80, 0x00, 0x20 };
  100.             PS3.SetMemory(0x18831f0, new byte[] { 0x3D, 0x60, 0x10, 0x05, 0x81, 0x6B, 0x00, 0x00, 0x7D, 0x69, 0x03, 0xA6, 0x4E, 0x80, 0x04, 0x20 });
  101.             PS3.SetMemory(SFA4, buffer2);
  102.             PS3.Extension.WriteUInt32(0x10050000, 0x1883210);
  103.             byte[] on = patchjmp(is_player_online);
  104.             PS3.SetMemory(is_player_online, new byte[] { 0xF8, 0x21, 0xFF, 0x91, 0x7C, 0x08, 0x02, 0xA6, 0xF8, 0x01, 0x00, 0x80, on[0], on[1], on[2], on[3] });
  105.             PS3.SetMemory(is_player_online + 0x18, new byte[] { 0x7C, 0x08, 0x03, 0xA6, 0x38, 0x21, 0x00, 0x70, 0x4E, 0x80, 0x00, 0x20 });
  106.         }
  107.  
  108.         private static byte[] ReverseBytes(byte[] toReverse)
  109.         {
  110.             Array.Reverse(toReverse);
  111.             return toReverse;
  112.         }
  113.  
  114.         private static void WriteSingle(uint address, float input)
  115.         {
  116.             byte[] array = new byte[4];
  117.             BitConverter.GetBytes(input).CopyTo(array, 0);
  118.             Array.Reverse(array, 0, 4);
  119.             PS3.SetMemory(address, array);
  120.         }
  121.  
  122.         private static void WriteSingle(uint address, float[] input)
  123.         {
  124.             int length = input.Length;
  125.             byte[] array = new byte[length * 4];
  126.             for (int i = 0; i < length; i++)
  127.             {
  128.                 ReverseBytes(BitConverter.GetBytes(input[i])).CopyTo(array, (int)(i * 4));
  129.             }
  130.             PS3.SetMemory(address, array);
  131.         }
  132.     }
  133. }
Add Comment
Please, Sign In to add comment