Advertisement
cia

Last Team Standing RPC.cs 1.19

cia
May 15th, 2015
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using PS3Lib;
  7.  
  8. namespace Gtav
  9. {
  10.     class RPC
  11.     {
  12.  
  13.         public static uint function1_address = 0x0;
  14.         private static uint[] one_to_address = { 0x0, 0x0 };
  15.         private static uint[] one_to_bytes = { 0x0, 0x0 };
  16.         private static uint[] one_from_address = { 0x0, 0x0 };
  17.         private static uint[] one_from_bytes = { 0x0, 0x0 };
  18.  
  19.         private static uint function2_address = 0x0;
  20.         private static uint[] two_to_address = { 0x0, 0x0 };
  21.         private static uint[] two_to_bytes = { 0x0, 0x0 };
  22.         private static uint[] two_from_address = { 0x0, 0x0 };
  23.         private static uint[] two_from_bytes = { 0x0, 0x0 };
  24.  
  25.         public static void UpdateAddresses()
  26.         {
  27.             function2_address = function1_address + 0x100;
  28.             one_to_address[0] = function1_address - 0x95B338;
  29.             one_to_bytes[0] = function1_address + 0x46DE8338;
  30.             one_from_address[0] = function1_address + 0x88;
  31.             one_from_bytes[0] = function1_address + 0x49B31C4C;
  32.  
  33.             two_to_address[0] = function2_address - 0x9595D4;
  34.             two_to_bytes[0] = function2_address + 0x46DE64D4;
  35.             two_from_address[0] = function2_address + 0x88;
  36.             two_from_bytes[0] = function2_address + 0x49B338AC;
  37.  
  38.             one_to_address[1] = function1_address - 0x95FD78;
  39.             one_to_bytes[1] = function1_address + 0x46DD0D78;
  40.             one_from_address[1] = function1_address + 0x88;
  41.             one_from_bytes[1] = function1_address + 0x49B1120C;
  42.  
  43.             two_to_address[1] = function2_address - 0x95E014;
  44.             two_to_bytes[1] = function2_address + 0x46DCEF14;
  45.             two_from_address[1] = function2_address + 0x88;
  46.             two_from_bytes[1] = function2_address + 0x49B12E6C;
  47.         }
  48.  
  49.         public static bool InUse = false;
  50.  
  51.         public static void Enable()
  52.         {
  53.             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 };
  54.             PS3.PS3_WriteBytes(function1_address, new byte[] { 0x4E, 0x80, 0x00, 0x20 });
  55.             Thread.Sleep(20);
  56.             PS3.PS3_WriteBytes(function1_address + 4, memory);
  57.             PS3.PS3_WriteBytes(0x10020000, new byte[0x2854]);
  58.             PS3.PS3_WriteBytes(function1_address, new byte[] { 0xF8, 0x21, 0xFF, 0x91 });
  59.             PS3.PS3_WriteUInt32(one_from_address[Addresses.BLESBLUS], one_from_bytes[Addresses.BLESBLUS]);
  60.             PS3.PS3_WriteUInt32(one_to_address[Addresses.BLESBLUS], one_to_bytes[Addresses.BLESBLUS]);
  61.  
  62.             PS3.PS3_WriteBytes(function2_address, new byte[] { 0x4E, 0x80, 0x00, 0x20 });
  63.             Thread.Sleep(20);
  64.             PS3.PS3_WriteBytes(function2_address + 4, memory);
  65.             PS3.PS3_WriteBytes(function2_address, new byte[] { 0xF8, 0x21, 0xFF, 0x91 });
  66.             PS3.PS3_WriteUInt32(two_from_address[Addresses.BLESBLUS], two_from_bytes[Addresses.BLESBLUS]);
  67.             PS3.PS3_WriteUInt32(two_to_address[Addresses.BLESBLUS], two_to_bytes[Addresses.BLESBLUS]);
  68.         }
  69.  
  70.         public static void WaitForCall()
  71.         {
  72.             while (InUse)
  73.             {
  74.  
  75.             }
  76.         }
  77.  
  78.         public static int Call(string Native, params object[] parameters)
  79.         {
  80.             return Call(Hook.GetNativeFunctionAddr(Natives.GetHash(Native)), parameters);
  81.         }
  82.  
  83.         public static int Call(uint func_address, params object[] parameters)
  84.         {
  85.             InUse = true;
  86.             int length = parameters.Length;
  87.             int index = 0;
  88.             uint num3 = 0;
  89.             uint num4 = 0;
  90.             uint num5 = 0;
  91.             uint num6 = 0;
  92.             while (index < length)
  93.             {
  94.                 if (parameters[index] is int)
  95.                 {
  96.                     PS3.PS3_WriteInt32(0x10020000 + (num3 * 4), (int)parameters[index]);
  97.                     num3++;
  98.                 }
  99.                 else if (parameters[index] is uint)
  100.                 {
  101.                     PS3.PS3_WriteUInt32(0x10020000 + (num3 * 4), (uint)parameters[index]);
  102.                     num3++;
  103.                 }
  104.                 else
  105.                 {
  106.                     uint num7;
  107.                     if (parameters[index] is string)
  108.                     {
  109.                         num7 = 0x10022000 + (num4 * 0x400);
  110.                         PS3.PS3_WriteString(num7, Convert.ToString(parameters[index]));
  111.                         PS3.PS3_WriteUInt32(0x10020000 + (num3 * 4), num7);
  112.                         num3++;
  113.                         num4++;
  114.                     }
  115.                     else if (parameters[index] is float)
  116.                     {
  117.                         WriteSingle(0x10020024 + (num5 * 4), (float)parameters[index]);
  118.                         num5++;
  119.                     }
  120.                     else if (parameters[index] is float[])
  121.                     {
  122.                         float[] input = (float[])parameters[index];
  123.                         num7 = 0x10021000 + (num6 * 4);
  124.                         WriteSingle(num7, input);
  125.                         PS3.PS3_WriteUInt32(0x10020000 + (num3 * 4), num7);
  126.                         num3++;
  127.                         num6 += (uint)input.Length;
  128.                     }
  129.                 }
  130.                 index++;
  131.             }
  132.             PS3.PS3_WriteUInt32(0x1002004C, func_address);
  133.             Thread.Sleep(60);
  134.             int ReturnVal = PS3.PS3_ReadInt32(0x10020050);
  135.             InUse = false;
  136.             return ReturnVal;
  137.         }
  138.  
  139.         private static void WriteSingle(uint address, float input)
  140.         {
  141.             byte[] Bytes = new byte[4];
  142.             BitConverter.GetBytes(input).CopyTo((Array)Bytes, 0);
  143.             Array.Reverse((Array)Bytes, 0, 4);
  144.             PS3.PS3_WriteBytes(address, Bytes);
  145.         }
  146.  
  147.         private static void WriteSingle(uint address, float[] input)
  148.         {
  149.             int length = input.Length;
  150.             byte[] Bytes = new byte[length * 4];
  151.             for (int index = 0; index < length; ++index)
  152.                 ReverseBytes(BitConverter.GetBytes(input[index])).CopyTo((Array)Bytes, index * 4);
  153.             PS3.PS3_WriteBytes(address, Bytes);
  154.         }
  155.  
  156.         private static byte[] ReverseBytes(byte[] toReverse)
  157.         {
  158.             Array.Reverse((Array)toReverse);
  159.             return toReverse;
  160.         }
  161.     }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement