Advertisement
BaSs_HaXoR

SnaY's COD Ghosts Library SOURCE C#

Feb 27th, 2014
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 40.58 KB | None | 0 0
  1. namespace Ghosts_Library
  2. {
  3.     using PS3Lib;
  4.     using System;
  5.     using System.Linq;
  6.     using System.Text;
  7.     using System.Threading;
  8.  
  9.     public class Ghosts
  10.     {
  11.         public class Buttons
  12.         {
  13.             public static uint Crouch = 0x20000;
  14.             public static uint L1 = 0x80800;
  15.             public static uint L2 = 0x800000;
  16.             public static uint L3 = 0x2200000;
  17.             public static uint Prone = 0x10000;
  18.             public static uint R1 = 0x1000000;
  19.             public static uint R2 = 0x400000;
  20.             public static uint R3 = 0x4000004;
  21.             public static uint Square = 0x30000000;
  22.             public static uint StartButton = 0x8000;
  23.             public static uint X = 0x40000;
  24.  
  25.             public static uint DetectButton(int clientIndex)
  26.             {
  27.                 byte[] bytes = new byte[4];
  28.                 Ghosts.PS3.GetMemoryR(Ghosts.Offsets.ButtonMonitoring + ((uint) (clientIndex * 0x3600)), ref bytes);
  29.                 return BitConverter.ToUInt32(bytes, 0);
  30.             }
  31.  
  32.             public static bool PressCross(int client)
  33.             {
  34.                 uint num = DetectButton(client);
  35.                 return (((num == X) || (num == (X + Crouch))) || (num == (X + Prone)));
  36.             }
  37.  
  38.             public static bool PressL1(int client)
  39.             {
  40.                 uint num = DetectButton(client);
  41.                 return (((num == L1) || (num == (L1 + Crouch))) || (num == (L1 + Prone)));
  42.             }
  43.  
  44.             public static bool PressR1(int client)
  45.             {
  46.                 uint num = DetectButton(client);
  47.                 return (((num == R1) || (num == (R1 + Crouch))) || (num == (R1 + Prone)));
  48.             }
  49.  
  50.             public static bool PressR3(int client)
  51.             {
  52.                 uint num = DetectButton(client);
  53.                 return (((num == R3) || (num == (R3 + Crouch))) || (num == (R3 + Prone)));
  54.             }
  55.  
  56.             public static bool PressSquare(int client)
  57.             {
  58.                 uint num = DetectButton(client);
  59.                 return (((num == Square) || (num == (Square + Crouch))) || (num == (Square + Prone)));
  60.             }
  61.         }
  62.  
  63.         public class Hud
  64.         {
  65.             public static int Huds_Speed = 100;
  66.  
  67.             public static void ActivateIndex(int index, int type)
  68.             {
  69.                 byte[] bytes = BitConverter.GetBytes(type);
  70.                 Array.Reverse(bytes);
  71.                 Ghosts.PS3.SetMemory(HElems.ELEM + ((uint) (0xb8 * index)), bytes);
  72.             }
  73.  
  74.             public static void ChangeAlpha(int index, int r, int g, int b, int alpha)
  75.             {
  76.                 uint num = Ghosts.Offsets.G_HudElems + (Convert.ToUInt32(index) * 0xb8);
  77.                 Ghosts.PS3.SetMemory(num + HElems.color, RGBA(r, g, b, alpha));
  78.             }
  79.  
  80.             public static void ChangeFontScaleOverTime(uint elemIndex, short Time, double OldFont, double NewFont)
  81.             {
  82.                 uint num = Ghosts.Offsets.G_HudElems + (elemIndex * 0xb8);
  83.                 Ghosts.PS3.Extension.WriteFloat(num + HElems.fromFontScale, (float) OldFont);
  84.                 Ghosts.PS3.Extension.WriteUInt32(num + HElems.fontScaleStartTime, (uint) getLevelTime());
  85.                 Ghosts.PS3.Extension.WriteInt32(num + HElems.fontScaleTime, Time);
  86.                 Ghosts.PS3.Extension.WriteFloat(num + HElems.fontScale, (float) NewFont);
  87.             }
  88.  
  89.             public static void ChangeText(int index, string text, float X)
  90.             {
  91.                 uint num = Ghosts.Offsets.G_HudElems + (Convert.ToUInt32(index) * 0xb8);
  92.                 Ghosts.PS3.Extension.WriteFloat(num + HElems.xOffset, X);
  93.                 Ghosts.PS3.Extension.WriteInt16(num + HElems.text, G_LocalizedStringIndex(text));
  94.             }
  95.  
  96.             public static void ChangeTextSub(int index, string text)
  97.             {
  98.                 uint num = Ghosts.Offsets.G_HudElems + (Convert.ToUInt32(index) * 0xb8);
  99.                 Ghosts.PS3.Extension.WriteInt16(num + HElems.text, G_LocalizedStringIndex(text));
  100.             }
  101.  
  102.             public static void ChangeWidth(int elemIndex, short width)
  103.             {
  104.                 uint num = Ghosts.Offsets.G_HudElems + (Convert.ToUInt32(elemIndex) * 0xb8);
  105.                 Ghosts.PS3.Extension.WriteInt16(num + HElems.width, width);
  106.             }
  107.  
  108.             public static void doTypeWriter(uint ElemIndex, int client, string text, double fontScale, short font, float X, float Y, int fxLetterTime, int fxDecayStartTime, int fxDecayDuration, int r, int g, int b, int a, int r1, int b1, int g1, int a1)
  109.             {
  110.                 uint address = HElems.ELEM + (Convert.ToUInt32(ElemIndex) * 0xb8);
  111.                 Ghosts.PS3.SetMemory(address, new byte[0xb8]);
  112.                 byte[] bytes = new byte[4];
  113.                 bytes[3] = 1;
  114.                 Ghosts.PS3.SetMemory(address, bytes);
  115.                 Ghosts.PS3.Extension.WriteInt16(address + HElems.text, G_LocalizedStringIndex(text));
  116.                 Ghosts.PS3.Extension.WriteInt16(address + HElems.font, font);
  117.                 Ghosts.PS3.Extension.WriteInt32(address + HElems.clientOffset, client);
  118.                 Ghosts.PS3.Extension.WriteInt16(address + HElems.alignScreen, 0);
  119.                 Ghosts.PS3.Extension.WriteInt16(address + HElems.alignOrg, 0);
  120.                 Ghosts.PS3.Extension.WriteFloat(address + HElems.fontScale, (float) fontScale);
  121.                 Ghosts.PS3.Extension.WriteFloat(address + HElems.xOffset, X);
  122.                 Ghosts.PS3.Extension.WriteFloat(address + HElems.yOffset, Y);
  123.                 Ghosts.PS3.SetMemory(address + HElems.color, RGBA(r, g, b, a));
  124.                 Ghosts.PS3.SetMemory(address + HElems.glowColor, RGBA(r1, g1, b1, a1));
  125.                 Ghosts.PS3.Extension.WriteInt32(address + HElems.fxBirthTime, getLevelTime());
  126.                 Ghosts.PS3.Extension.WriteInt32(address + HElems.fxLetterTime, fxLetterTime);
  127.                 Ghosts.PS3.Extension.WriteInt32(address + HElems.fxDecayStartTime, fxDecayStartTime);
  128.                 Ghosts.PS3.Extension.WriteInt32(address + HElems.fxDecayDuration, fxDecayDuration);
  129.             }
  130.  
  131.             public static void doTypeWriterCustom(uint Index, ushort fxLetterTime, ushort fxDecayStartTime, ushort fxDecayDuration)
  132.             {
  133.                 uint num = HElems.ELEM + (Index * 0xb8);
  134.                 Ghosts.PS3.Extension.WriteInt32(num + HElems.fxBirthTime, getLevelTime());
  135.                 Ghosts.PS3.Extension.WriteInt32(num + HElems.fxLetterTime, fxLetterTime);
  136.                 Ghosts.PS3.Extension.WriteInt32(num + HElems.fxDecayStartTime, fxDecayStartTime);
  137.                 Ghosts.PS3.Extension.WriteInt32(num + HElems.fxDecayDuration, fxDecayDuration);
  138.             }
  139.  
  140.             public static void Enable_Huds()
  141.             {
  142.                 Ghosts.PS3.SetMemory(Ghosts.Offsets.FPS, new byte[] {
  143.                     60, 0x60, 2, 0x10, 0x80, 0x83, 0, 0, 0x2c, 4, 0, 0, 0x41, 130, 0, 140,
  144.                     0x4b, 0xcc, 0xe1, 0xe1, 60, 0x80, 2, 0x10, 0x90, 100, 80, 0, 0x38, 0x60, 0, 0,
  145.                     0x90, 100, 0, 0, 0x48, 0, 0, 0x74, 0x3b, 0xe4, 0x4e, 0xbc, 0x38, 0x80, 0, 0
  146.                  });
  147.                 Ghosts.PS3.SetMemory(Ghosts.Offsets.Huds_Fix, new byte[] { 1 });
  148.             }
  149.  
  150.             public static void FadeAlphaOverTime(uint elemIndex, short Time, int OldAlpha, int NewAlpha)
  151.             {
  152.                 uint num = Ghosts.Offsets.G_HudElems + (elemIndex * 0xb8);
  153.                 byte[] bytes = BitConverter.GetBytes(Convert.ToInt32(OldAlpha));
  154.                 Ghosts.PS3.SetMemory(num + 0x37, bytes);
  155.                 Ghosts.PS3.Extension.WriteUInt32(num + HElems.fadeStartTime, (uint) getLevelTime());
  156.                 Ghosts.PS3.Extension.WriteInt32(num + HElems.fadeTime, Time);
  157.                 byte[] buffer2 = BitConverter.GetBytes(Convert.ToInt32(NewAlpha));
  158.                 Ghosts.PS3.SetMemory(num + 0x33, buffer2);
  159.             }
  160.  
  161.             public static void FadeOverTime(uint elem, short Time, int R, int G, int B, int A)
  162.             {
  163.                 uint num = Ghosts.Offsets.G_HudElems + (elem * 0xb8);
  164.                 byte[] memory = Ghosts.PS3.GetMemory(num + HElems.color, 1);
  165.                 byte[] bytes = Ghosts.PS3.GetMemory((num + HElems.color) + 1, 1);
  166.                 byte[] buffer3 = Ghosts.PS3.GetMemory((num + HElems.color) + 2, 1);
  167.                 byte[] buffer4 = Ghosts.PS3.GetMemory((num + HElems.color) + 3, 1);
  168.                 Ghosts.PS3.SetMemory(num + HElems.fromColor, memory);
  169.                 Ghosts.PS3.SetMemory((num + HElems.fromColor) + 1, bytes);
  170.                 Ghosts.PS3.SetMemory((num + HElems.fromColor) + 2, buffer3);
  171.                 Ghosts.PS3.SetMemory((num + HElems.fromColor) + 3, buffer4);
  172.                 Ghosts.PS3.Extension.WriteUInt32(num + HElems.fadeStartTime, (uint) getLevelTime());
  173.                 Ghosts.PS3.Extension.WriteInt32(num + HElems.fadeTime, Time);
  174.                 Ghosts.PS3.SetMemory(num + HElems.color, RGBA(R, G, B, A));
  175.             }
  176.  
  177.             public static short G_LocalizedStringIndex(string Text)
  178.             {
  179.                 Ghosts.PS3.SetMemory(Ghosts.Offsets.Huds_Text, Encoding.ASCII.GetBytes(Text + "\0"));
  180.                 Thread.Sleep(Huds_Speed);
  181.                 return (short) Ghosts.PS3.Extension.ReadInt32(Ghosts.Offsets.Huds_Return);
  182.             }
  183.  
  184.             public static int getLevelTime()
  185.             {
  186.                 return Ghosts.PS3.Extension.ReadInt32(Ghosts.Offsets.LevelTime);
  187.             }
  188.  
  189.             private static uint HudElem_Alloc()
  190.             {
  191.                 for (int i = 0; i < 0x400; i++)
  192.                 {
  193.                     uint offset = Ghosts.Offsets.G_HudElems + ((uint) (i * 0xb8));
  194.                     if (Ghosts.PS3.GetMemory(offset, 4)[3] == 0)
  195.                     {
  196.                         Ghosts.PS3.SetMemory(offset + HElems.type, new byte[0xb8]);
  197.                         return offset;
  198.                     }
  199.                 }
  200.                 return 0;
  201.             }
  202.  
  203.             public static uint MoveOverTime(uint elemIndex, short Time, float X, float Y)
  204.             {
  205.                 uint num = Ghosts.Offsets.G_HudElems + (elemIndex * 0xb8);
  206.                 Ghosts.PS3.Extension.WriteFloat(num + HElems.fromX, Ghosts.PS3.Extension.ReadFloat(num + HElems.xOffset));
  207.                 Ghosts.PS3.Extension.WriteFloat(num + HElems.fromY, Ghosts.PS3.Extension.ReadFloat(num + HElems.yOffset));
  208.                 Ghosts.PS3.Extension.WriteInt32(num + HElems.moveTime, Time);
  209.                 Ghosts.PS3.Extension.WriteInt32(num + HElems.moveStartTime, getLevelTime());
  210.                 Ghosts.PS3.Extension.WriteFloat(num + HElems.xOffset, X);
  211.                 Ghosts.PS3.Extension.WriteFloat(num + HElems.yOffset, Y);
  212.                 return num;
  213.             }
  214.  
  215.             public static void MoveShaderXY(uint index, float X, float Y)
  216.             {
  217.                 Ghosts.PS3.Extension.WriteFloat((Ghosts.Offsets.G_HudElems + (index * 0xb8)) + HElems.xOffset, X);
  218.                 Ghosts.PS3.Extension.WriteFloat((Ghosts.Offsets.G_HudElems + (index * 0xb8)) + HElems.yOffset, Y);
  219.             }
  220.  
  221.             public static void MoveShaderY(uint index, float Y)
  222.             {
  223.                 Ghosts.PS3.Extension.WriteFloat((Ghosts.Offsets.G_HudElems + (index * 0xb8)) + HElems.yOffset, Y);
  224.             }
  225.  
  226.             public static byte[] RGBA(decimal R, decimal G, decimal B, decimal A)
  227.             {
  228.                 byte[] buffer = new byte[4];
  229.                 byte[] bytes = BitConverter.GetBytes(Convert.ToInt32(R));
  230.                 byte[] buffer3 = BitConverter.GetBytes(Convert.ToInt32(G));
  231.                 byte[] buffer4 = BitConverter.GetBytes(Convert.ToInt32(B));
  232.                 byte[] buffer5 = BitConverter.GetBytes(Convert.ToInt32(A));
  233.                 buffer[0] = bytes[0];
  234.                 buffer[1] = buffer3[0];
  235.                 buffer[2] = buffer4[0];
  236.                 buffer[3] = buffer5[0];
  237.                 return buffer;
  238.             }
  239.  
  240.             public static void ScaleOverTime(uint elemIndex, short Time, short Width, short Height)
  241.             {
  242.                 uint num = Ghosts.Offsets.G_HudElems + (elemIndex * 0xb8);
  243.                 Ghosts.PS3.Extension.WriteFloat(num + HElems.fromHeight, Ghosts.PS3.Extension.ReadFloat(num + HElems.height));
  244.                 Ghosts.PS3.Extension.WriteFloat(num + HElems.fromWidth, Ghosts.PS3.Extension.ReadFloat(num + HElems.width));
  245.                 Ghosts.PS3.Extension.WriteInt32(num + HElems.scaleTime, Time);
  246.                 Ghosts.PS3.Extension.WriteInt32(num + HElems.scaleStartTime, getLevelTime());
  247.                 Ghosts.PS3.Extension.WriteInt16(num + HElems.height, Height);
  248.                 Ghosts.PS3.Extension.WriteInt16(num + HElems.width, Width);
  249.             }
  250.  
  251.             public static void SetGlow(uint elemIndex, int r, int g, int b, int a)
  252.             {
  253.                 uint num = HElems.ELEM + (elemIndex * 0xb8);
  254.                 Ghosts.PS3.SetMemory(num + HElems.glowColor, RGBA(r, g, b, a));
  255.             }
  256.  
  257.             public static void SetGlowText(uint elemIndex, int client, string Text, short font, double fontScale, int x, int y, uint align, float sort, int r, int g, int b, int a, int r1, int g1, int b1, int a1)
  258.             {
  259.                 uint address = HElems.ELEM + (elemIndex * 0xb8);
  260.                 Ghosts.PS3.SetMemory(address, new byte[0xb8]);
  261.                 byte[] bytes = new byte[4];
  262.                 bytes[3] = 1;
  263.                 Ghosts.PS3.SetMemory(address, bytes);
  264.                 Ghosts.PS3.Extension.WriteInt16(address + HElems.text, G_LocalizedStringIndex(Text));
  265.                 Ghosts.PS3.Extension.WriteInt16(address + HElems.font, font);
  266.                 Ghosts.PS3.Extension.WriteInt16(address + HElems.alignScreen, 0);
  267.                 Ghosts.PS3.Extension.WriteInt16(address + HElems.alignOrg, 0);
  268.                 Ghosts.PS3.Extension.WriteFloat(address + HElems.fontScale, (float) fontScale);
  269.                 Ghosts.PS3.Extension.WriteFloat(address + HElems.xOffset, (float) x);
  270.                 Ghosts.PS3.Extension.WriteFloat(address + HElems.yOffset, (float) y);
  271.                 Ghosts.PS3.SetMemory(address + HElems.color, RGBA(r, g, b, a));
  272.                 Ghosts.PS3.SetMemory(address + HElems.glowColor, RGBA(r1, g1, b1, a1));
  273.                 Ghosts.PS3.Extension.WriteInt32(address + HElems.clientOffset, client);
  274.             }
  275.  
  276.             public static void SpinText(uint Index, int Radius, int X, int Y)
  277.             {
  278.                 int num = X;
  279.                 int num2 = Y;
  280.                 int num3 = Radius;
  281.                 int num4 = 0;
  282.                 while (true)
  283.                 {
  284.                     double num5 = num + (Math.Sin((double) num4) * num3);
  285.                     double num6 = num2 + (Math.Cos((double) num4) * num3);
  286.                     MoveShaderXY(Index, (float) ((int) num5), (float) ((int) num6));
  287.                     Thread.Sleep(100);
  288.                     num4++;
  289.                 }
  290.             }
  291.  
  292.             public static void StoreIcon(int elemIndex, uint client, int shader, int width, int height, float x, float y, uint align, float sort, int r, int g, int b, int a)
  293.             {
  294.                 uint address = Ghosts.Offsets.G_HudElems + ((uint) (elemIndex * 0xb8));
  295.                 Ghosts.PS3.SetMemory(address, new byte[0xb8]);
  296.                 byte[] bytes = new byte[4];
  297.                 bytes[3] = 4;
  298.                 Ghosts.PS3.SetMemory(address, bytes);
  299.                 Ghosts.PS3.Extension.WriteInt32(address + HElems.materialIndex, shader);
  300.                 Ghosts.PS3.Extension.WriteInt32(address + HElems.clientOffset, (int) client);
  301.                 Ghosts.PS3.Extension.WriteInt32(address + HElems.width, width);
  302.                 Ghosts.PS3.Extension.WriteInt32(address + HElems.height, height);
  303.                 Ghosts.PS3.Extension.WriteInt32(address + HElems.alignScreen, 0);
  304.                 Ghosts.PS3.Extension.WriteInt32(address + HElems.alignOrg, 0);
  305.                 Ghosts.PS3.Extension.WriteFloat(address + HElems.xOffset, x);
  306.                 Ghosts.PS3.Extension.WriteFloat(address + HElems.yOffset, y);
  307.                 Ghosts.PS3.SetMemory(address + HElems.color, RGBA(r, g, b, a));
  308.             }
  309.  
  310.             public static void StoreTextElem(int elemIndex, int client, string Text, short font, double fontScale, float x, float y, uint align, float sort, int r, int g, int b, int a)
  311.             {
  312.                 uint address = HElems.ELEM + (Convert.ToUInt32(elemIndex) * 0xb8);
  313.                 Ghosts.PS3.SetMemory(address, new byte[0xb8]);
  314.                 byte[] bytes = new byte[4];
  315.                 bytes[3] = 1;
  316.                 Ghosts.PS3.SetMemory(address, bytes);
  317.                 Ghosts.PS3.Extension.WriteInt16(address + HElems.text, G_LocalizedStringIndex(Text));
  318.                 Ghosts.PS3.Extension.WriteInt32(address + HElems.font, font);
  319.                 Ghosts.PS3.Extension.WriteInt32(address + HElems.clientOffset, client);
  320.                 Ghosts.PS3.Extension.WriteFloat(address + HElems.fontScale, (float) fontScale);
  321.                 Ghosts.PS3.Extension.WriteFloat(address + HElems.xOffset, x);
  322.                 Ghosts.PS3.Extension.WriteFloat(address + HElems.yOffset, y);
  323.                 Ghosts.PS3.SetMemory(address + HElems.color, RGBA(r, g, b, a));
  324.             }
  325.  
  326.         /*    public static void ZigZagText(uint elemIndex, short Speed)
  327.             {
  328.                 uint num = Ghosts.Offsets.G_HudElems + (elemIndex * 0xb8);
  329.                 float num2 = 0f;
  330.                 Ghosts.PS3.SetMemory(num + HElems.xOffset, Ghosts.PS3.Extension.ToHexFloat(-400f));
  331.                 while (true)
  332.                 {
  333.                     float num4;
  334.                     float num5;
  335.                     float num3 = Ghosts.PS3.Extension.ReadFloat(num + HElems.xOffset);
  336.                     if (num2 == 480f)
  337.                     {
  338.                         return;
  339.                     }
  340.                     switch (num3)//switch has to be bool, char, string, integral, enum, null
  341.                     {
  342.                         case -400f:
  343.                             num4 = num2 += 120f;
  344.                             num5 = 800f;
  345.                             MoveOverTime(elemIndex, Speed, num5, num4);
  346.                             break;
  347.  
  348.                         case 800f:
  349.                             num4 = num2 += 120f;
  350.                             num5 = -400f;
  351.                             MoveOverTime(elemIndex, Speed, num5, num4);
  352.                             break;
  353.                     }
  354.                     Thread.Sleep(Speed);
  355.                 }
  356.             }
  357.             */
  358.             public static class HElems
  359.             {
  360.                 public static uint alignOrg = 40;
  361.                 public static uint alignScreen = 0x2c;
  362.                 public static uint clientOffset = 0xa8;
  363.                 public static uint color = 0x30;
  364.                 public static uint duration = 0x7c;
  365.                 public static uint ELEM = Ghosts.Offsets.G_HudElems;
  366.                 public static uint fadeStartTime = 0x38;
  367.                 public static uint fadeTime = 60;
  368.                 public static uint flags = 0xa4;
  369.                 public static uint font = 0x24;
  370.                 public static uint fontScale = 20;
  371.                 public static uint fontScaleStartTime = 0x1c;
  372.                 public static uint fontScaleTime = 0x20;
  373.                 public static uint fromAlignOrg = 0x68;
  374.                 public static uint fromAlignScreen = 0x6c;
  375.                 public static uint fromColor = 0x34;
  376.                 public static uint fromFontScale = 0x18;
  377.                 public static uint fromHeight = 0x54;
  378.                 public static uint fromWidth = 80;
  379.                 public static uint fromX = 0x60;
  380.                 public static uint fromY = 100;
  381.                 public static uint fxBirthTime = 0x90;
  382.                 public static uint fxDecayDuration = 0x9c;
  383.                 public static uint fxDecayStartTime = 0x98;
  384.                 public static uint fxLetterTime = 0x94;
  385.                 public static uint glowColor = 140;
  386.                 public static uint height = 0x48;
  387.                 public static uint label = 0x40;
  388.                 public static uint materialIndex = 0x4c;
  389.                 public static uint moveStartTime = 0x70;
  390.                 public static uint moveTime = 0x74;
  391.                 public static uint scaleStartTime = 0x58;
  392.                 public static uint scaleTime = 0x5c;
  393.                 public static uint sort = 0x88;
  394.                 public static uint soundID = 160;
  395.                 public static uint targetEntNum = 0x10;
  396.                 public static uint text = 0x42;
  397.                 public static uint time = 120;
  398.                 public static uint type = 0;
  399.                 public static uint value = 0x80;
  400.                 public static uint width = 0x44;
  401.                 public static uint xOffset = 4;
  402.                 public static uint yOffset = 8;
  403.                 public static uint zOffset = 12;
  404.             }
  405.         }
  406.  
  407.         public class Offsets
  408.         {
  409.             public static uint ButtonMonitoring = (G_Client + 0x2ee0);
  410.             public static uint Cbufaddtext = 0;
  411.             public static uint ClientName = (G_Client + 0x2f9c);
  412.             public static uint FPS = 0x364f58;
  413.             public static uint G_Client = 0xf21c00;
  414.             public static uint G_ClientSize = 0x3600;
  415.             public static uint G_Entity = 0xdd4c68;
  416.             public static uint G_EntitySize = 640;
  417.             public static uint G_HudElems = 0xd64f08;
  418.             public static uint G_LocalizedStringIndex = 0x33148;
  419.             public static uint G_MaterialIndex = 0x31154;
  420.             public static uint HudelemSize = 0xb8;
  421.             public static uint Huds_Fix = 0x3318f;
  422.             public static uint Huds_Return = 0x2105000;
  423.             public static uint Huds_Text = 0x2100000;
  424.             public static uint Level_locals_t = 0xd92f84;
  425.             public static uint LevelTime = (Level_locals_t + 0x540);
  426.             public static uint mFlag = (G_Client + 0x321f);
  427.             public static uint NoHud = (G_Client + 0x321b);
  428.             public static uint PlayerName = 0x17449b8;
  429.             public static uint RPC = 0x495d10;
  430.             public static uint SV_GameSendServerCommand = 0x4fdc90;
  431.         }
  432.  
  433.         public class Player
  434.         {
  435.             public static void Akimbo()
  436.             {
  437.                 Ghosts.PS3.SetMemory(0xf21f41, new byte[] { 1 });
  438.             }
  439.  
  440.             public static void Godmode()
  441.             {
  442.                 Ghosts.PS3.SetMemory(0xde1daa, new byte[] { 0xff });
  443.             }
  444.  
  445.             public static void KillClient()
  446.             {
  447.                 Ghosts.PS3.SetMemory(0xf21c0f, new byte[] { 0xff });
  448.             }
  449.  
  450.             public static void Noclip()
  451.             {
  452.                 Ghosts.PS3.SetMemory(0xf24e1f, new byte[] { 1 });
  453.             }
  454.  
  455.             public static void SkateMod()
  456.             {
  457.                 Ghosts.PS3.SetMemory(0xf21c0e, new byte[] { 1 });
  458.             }
  459.  
  460.             public static void SuperJump()
  461.             {
  462.                 byte[] bytes = new byte[2];
  463.                 bytes[0] = 0x45;
  464.                 Ghosts.PS3.SetMemory(0xe80fc, bytes);
  465.             }
  466.  
  467.             public static void SuperSpeed()
  468.             {
  469.                 byte[] bytes = new byte[2];
  470.                 bytes[0] = 5;
  471.                 Ghosts.PS3.SetMemory(0x22807e, bytes);
  472.             }
  473.  
  474.             public static void UnlimitedAmmo()
  475.             {
  476.                 Ghosts.PS3.SetMemory(0xf220d6, new byte[] { 0xff });
  477.             }
  478.         }
  479.  
  480.         public class PS3
  481.         {
  482.             private static PS3API DEX = new PS3API(SelectAPI.TargetManager);
  483.  
  484.             public static void ChangeAPI(SelectAPI API)
  485.             {
  486.                 DEX.ChangeAPI(API);
  487.             }
  488.  
  489.             public static void Connect()
  490.             {
  491.                 DEX.ConnectTarget(0);
  492.                 DEX.AttachProcess();
  493.             }
  494.  
  495.             public static SelectAPI GetCurrentAPI()
  496.             {
  497.                 return DEX.GetCurrentAPI();
  498.             }
  499.  
  500.             public static byte[] GetMemory(uint offset, int length)
  501.             {
  502.                 byte[] buffer = new byte[length];
  503.                 DEX.GetMemory(offset, buffer);
  504.                 return buffer;
  505.             }
  506.  
  507.             public static byte[] GetMemoryL(uint address, int length)
  508.             {
  509.                 byte[] buffer = new byte[length];
  510.                 DEX.GetMemory(address, buffer);
  511.                 return buffer;
  512.             }
  513.  
  514.             public static void GetMemoryR(uint Address, ref byte[] Bytes)
  515.             {
  516.                 DEX.GetMemory(Address, Bytes);
  517.             }
  518.  
  519.             public static void SetMemory(uint Address, byte[] Bytes)
  520.             {
  521.                 DEX.SetMemory(Address, Bytes);
  522.             }
  523.  
  524.             private class Conversions
  525.             {
  526.                 public static byte[] RandomizeRGBA()
  527.                 {
  528.                     byte[] buffer = new byte[4];
  529.                     Random random = new Random();
  530.                     buffer[0] = BitConverter.GetBytes(random.Next(0, 0xff))[0];
  531.                     buffer[1] = BitConverter.GetBytes(random.Next(0, 0xff))[0];
  532.                     buffer[2] = BitConverter.GetBytes(random.Next(0, 0xff))[0];
  533.                     buffer[3] = BitConverter.GetBytes(random.Next(0, 0xff))[0];
  534.                     return buffer;
  535.                 }
  536.  
  537.                 public static byte[] ReverseBytes(byte[] input)
  538.                 {
  539.                     Array.Reverse(input);
  540.                     return input;
  541.                 }
  542.             }
  543.  
  544.             public class Extension
  545.             {
  546.                 private static SelectAPI CurrentAPI;
  547.  
  548.                 private static byte[] GetBytes(uint offset, int length, SelectAPI API)
  549.                 {
  550.                     byte[] bytes = new byte[length];
  551.                     if (API == SelectAPI.ControlConsole)
  552.                     {
  553.                         CurrentAPI = Ghosts.PS3.GetCurrentAPI();
  554.                         return Ghosts.PS3.DEX.GetBytes(offset, length);
  555.                     }
  556.                     if (API == SelectAPI.TargetManager)
  557.                     {
  558.                         CurrentAPI = Ghosts.PS3.GetCurrentAPI();
  559.                         bytes = Ghosts.PS3.DEX.GetBytes(offset, length);
  560.                     }
  561.                     return bytes;
  562.                 }
  563.  
  564.                 private static void GetMem(uint offset, byte[] buffer, SelectAPI API)
  565.                 {
  566.                     if (API == SelectAPI.ControlConsole)
  567.                     {
  568.                         Ghosts.PS3.GetMemoryR(offset, ref buffer);
  569.                     }
  570.                     else if (API == SelectAPI.TargetManager)
  571.                     {
  572.                         Ghosts.PS3.GetMemoryR(offset, ref buffer);
  573.                     }
  574.                 }
  575.  
  576.                 public static bool ReadBool(uint offset)
  577.                 {
  578.                     byte[] buffer = new byte[1];
  579.                     GetMem(offset, buffer, CurrentAPI);
  580.                     return (buffer[0] != 0);
  581.                 }
  582.  
  583.                 public static byte ReadByte(uint offset)
  584.                 {
  585.                     return GetBytes(offset, 1, CurrentAPI)[0];
  586.                 }
  587.  
  588.                 public static byte[] ReadBytes(uint offset, int length)
  589.                 {
  590.                     return GetBytes(offset, length, CurrentAPI);
  591.                 }
  592.  
  593.                 public static float ReadFloat(uint offset)
  594.                 {
  595.                     byte[] array = GetBytes(offset, 4, CurrentAPI);
  596.                     Array.Reverse(array, 0, 4);
  597.                     return BitConverter.ToSingle(array, 0);
  598.                 }
  599.  
  600.                 public static short ReadInt16(uint offset)
  601.                 {
  602.                     byte[] array = GetBytes(offset, 2, CurrentAPI);
  603.                     Array.Reverse(array, 0, 2);
  604.                     return BitConverter.ToInt16(array, 0);
  605.                 }
  606.  
  607.                 public static int ReadInt32(uint offset)
  608.                 {
  609.                     byte[] array = GetBytes(offset, 4, CurrentAPI);
  610.                     Array.Reverse(array, 0, 4);
  611.                     return BitConverter.ToInt32(array, 0);
  612.                 }
  613.  
  614.                 public static long ReadInt64(uint offset)
  615.                 {
  616.                     byte[] array = GetBytes(offset, 8, CurrentAPI);
  617.                     Array.Reverse(array, 0, 8);
  618.                     return BitConverter.ToInt64(array, 0);
  619.                 }
  620.  
  621.                 public static sbyte ReadSByte(uint offset)
  622.                 {
  623.                     byte[] buffer = new byte[1];
  624.                     GetMem(offset, buffer, CurrentAPI);
  625.                     return (sbyte) buffer[0];
  626.                 }
  627.  
  628.                 public static string ReadString(uint offset)
  629.                 {
  630.                     int length = 40;
  631.                     int num2 = 0;
  632.                     string source = "";
  633.                     do
  634.                     {
  635.                         byte[] bytes = ReadBytes(offset + ((uint) num2), length);
  636.                         source = source + Encoding.UTF8.GetString(bytes);
  637.                         num2 += length;
  638.                     }
  639.                     while (!source.Contains<char>('\0'));
  640.                     int index = source.IndexOf('\0');
  641.                     string str2 = source.Substring(0, index);
  642.                     source = string.Empty;
  643.                     return str2;
  644.                 }
  645.  
  646.                 public static ushort ReadUInt16(uint offset)
  647.                 {
  648.                     byte[] array = GetBytes(offset, 2, CurrentAPI);
  649.                     Array.Reverse(array, 0, 2);
  650.                     return BitConverter.ToUInt16(array, 0);
  651.                 }
  652.  
  653.                 public static uint ReadUInt32(uint offset)
  654.                 {
  655.                     byte[] array = GetBytes(offset, 4, CurrentAPI);
  656.                     Array.Reverse(array, 0, 4);
  657.                     return BitConverter.ToUInt32(array, 0);
  658.                 }
  659.  
  660.                 public static ulong ReadUInt64(uint offset)
  661.                 {
  662.                     byte[] array = GetBytes(offset, 8, CurrentAPI);
  663.                     Array.Reverse(array, 0, 8);
  664.                     return BitConverter.ToUInt64(array, 0);
  665.                 }
  666.  
  667.                 public static byte[] ReverseArray(float float_0)
  668.                 {
  669.                     byte[] bytes = BitConverter.GetBytes(float_0);
  670.                     Array.Reverse(bytes);
  671.                     return bytes;
  672.                 }
  673.  
  674.                 public static byte[] ReverseBytes(byte[] inArray)
  675.                 {
  676.                     Array.Reverse(inArray);
  677.                     return inArray;
  678.                 }
  679.  
  680.                 private static void SetMem(uint Address, byte[] buffer, SelectAPI API)
  681.                 {
  682.                     Ghosts.PS3.DEX.SetMemory(Address, buffer);
  683.                 }
  684.  
  685.                 public static byte[] ToHexFloat(float Axis)
  686.                 {
  687.                     byte[] bytes = BitConverter.GetBytes(Axis);
  688.                     Array.Reverse(bytes);
  689.                     return bytes;
  690.                 }
  691.  
  692.                 public static byte[] uintBytes(uint input)
  693.                 {
  694.                     byte[] bytes = BitConverter.GetBytes(input);
  695.                     Array.Reverse(bytes);
  696.                     return bytes;
  697.                 }
  698.  
  699.                 public static void WriteBool(uint offset, bool input)
  700.                 {
  701.                     byte[] buffer = new byte[] { input ? ((byte) 1) : ((byte) 0) };
  702.                     SetMem(offset, buffer, CurrentAPI);
  703.                 }
  704.  
  705.                 public static void WriteByte(uint offset, byte input)
  706.                 {
  707.                     byte[] buffer = new byte[] { input };
  708.                     SetMem(offset, buffer, CurrentAPI);
  709.                 }
  710.  
  711.                 public static void WriteBytes(uint offset, byte[] input)
  712.                 {
  713.                     byte[] buffer = input;
  714.                     SetMem(offset, buffer, CurrentAPI);
  715.                 }
  716.  
  717.                 public static void WriteFloat(uint offset, float input)
  718.                 {
  719.                     byte[] array = new byte[4];
  720.                     BitConverter.GetBytes(input).CopyTo(array, 0);
  721.                     Array.Reverse(array, 0, 4);
  722.                     SetMem(offset, array, CurrentAPI);
  723.                 }
  724.  
  725.                 public static void WriteInt16(uint offset, short input)
  726.                 {
  727.                     byte[] array = new byte[2];
  728.                     BitConverter.GetBytes(input).CopyTo(array, 0);
  729.                     Array.Reverse(array, 0, 2);
  730.                     SetMem(offset, array, CurrentAPI);
  731.                 }
  732.  
  733.                 public static void WriteInt32(uint offset, int input)
  734.                 {
  735.                     byte[] array = new byte[4];
  736.                     BitConverter.GetBytes(input).CopyTo(array, 0);
  737.                     Array.Reverse(array, 0, 4);
  738.                     SetMem(offset, array, CurrentAPI);
  739.                 }
  740.  
  741.                 public static void WriteInt64(uint offset, long input)
  742.                 {
  743.                     byte[] array = new byte[8];
  744.                     BitConverter.GetBytes(input).CopyTo(array, 0);
  745.                     Array.Reverse(array, 0, 8);
  746.                     SetMem(offset, array, CurrentAPI);
  747.                 }
  748.  
  749.                 public static void WriteSByte(uint offset, sbyte input)
  750.                 {
  751.                     byte[] buffer = new byte[] { (byte) input };
  752.                     SetMem(offset, buffer, CurrentAPI);
  753.                 }
  754.  
  755.                 public static void WriteSingle(uint address, float input)
  756.                 {
  757.                     byte[] array = new byte[4];
  758.                     BitConverter.GetBytes(input).CopyTo(array, 0);
  759.                     Array.Reverse(array, 0, 4);
  760.                     Ghosts.PS3.SetMemory(address, array);
  761.                 }
  762.  
  763.                 public static void WriteSingle(uint address, float[] input)
  764.                 {
  765.                     int length = input.Length;
  766.                     byte[] array = new byte[length * 4];
  767.                     for (int i = 0; i < length; i++)
  768.                     {
  769.                         ReverseBytes(BitConverter.GetBytes(input[i])).CopyTo(array, (int) (i * 4));
  770.                     }
  771.                     Ghosts.PS3.SetMemory(address, array);
  772.                 }
  773.  
  774.                 public static void WriteString(uint offset, string input)
  775.                 {
  776.                     byte[] bytes = Encoding.UTF8.GetBytes(input);
  777.                     Array.Resize<byte>(ref bytes, bytes.Length + 1);
  778.                     SetMem(offset, bytes, CurrentAPI);
  779.                 }
  780.  
  781.                 public static void WriteUInt16(uint offset, ushort input)
  782.                 {
  783.                     byte[] array = new byte[2];
  784.                     BitConverter.GetBytes(input).CopyTo(array, 0);
  785.                     Array.Reverse(array, 0, 2);
  786.                     SetMem(offset, array, CurrentAPI);
  787.                 }
  788.  
  789.                 public static void WriteUInt32(uint offset, uint input)
  790.                 {
  791.                     byte[] array = new byte[4];
  792.                     BitConverter.GetBytes(input).CopyTo(array, 0);
  793.                     Array.Reverse(array, 0, 4);
  794.                     SetMem(offset, array, CurrentAPI);
  795.                 }
  796.  
  797.                 public static void WriteUInt64(uint offset, ulong input)
  798.                 {
  799.                     byte[] array = new byte[8];
  800.                     BitConverter.GetBytes(input).CopyTo(array, 0);
  801.                     Array.Reverse(array, 0, 8);
  802.                     SetMem(offset, array, CurrentAPI);
  803.                 }
  804.             }
  805.         }
  806.  
  807.         public class RPC
  808.         {
  809.             private static uint function_address;
  810.  
  811.             public static uint Call(uint func_address, params object[] parameters)
  812.             {
  813.                 int length = parameters.Length;
  814.                 uint num2 = 0;
  815.                 for (uint i = 0; i < length; i++)
  816.                 {
  817.                     if (parameters[i] is int)
  818.                     {
  819.                         byte[] array = BitConverter.GetBytes((int) parameters[i]);
  820.                         Array.Reverse(array);
  821.                         Ghosts.PS3.SetMemory(0x10050000 + ((i + num2) * 4), array);
  822.                     }
  823.                     else if (parameters[i] is uint)
  824.                     {
  825.                         byte[] buffer2 = BitConverter.GetBytes((uint) parameters[i]);
  826.                         Array.Reverse(buffer2);
  827.                         Ghosts.PS3.SetMemory(0x10050000 + ((i + num2) * 4), buffer2);
  828.                     }
  829.                     else if (parameters[i] is string)
  830.                     {
  831.                         byte[] buffer3 = Encoding.UTF8.GetBytes(Convert.ToString(parameters[i]) + "\0");
  832.                         Ghosts.PS3.SetMemory(0x10050054 + (i * 0x400), buffer3);
  833.                         uint num4 = 0x10050054 + (i * 0x400);
  834.                         byte[] buffer4 = BitConverter.GetBytes(num4);
  835.                         Array.Reverse(buffer4);
  836.                         Ghosts.PS3.SetMemory(0x10050000 + ((i + num2) * 4), buffer4);
  837.                     }
  838.                     else if (parameters[i] is float)
  839.                     {
  840.                         num2++;
  841.                         byte[] buffer5 = BitConverter.GetBytes((float) parameters[i]);
  842.                         Array.Reverse(buffer5);
  843.                         Ghosts.PS3.SetMemory(0x10050024 + ((num2 - 1) * 4), buffer5);
  844.                     }
  845.                 }
  846.                 byte[] bytes = BitConverter.GetBytes(func_address);
  847.                 Array.Reverse(bytes);
  848.                 Ghosts.PS3.SetMemory(0x1005004c, bytes);
  849.                 Thread.Sleep(20);
  850.                 byte[] memory = Ghosts.PS3.GetMemory(0x10050050, 4);
  851.                 Array.Reverse(memory);
  852.                 return BitConverter.ToUInt32(memory, 0);
  853.             }
  854.  
  855.             public static void Enable_RPC()
  856.             {
  857.                 Ghosts.PS3.SetMemory(function_address, new byte[] { 0x4e, 0x80, 0, 0x20 });
  858.                 Thread.Sleep(20);
  859.                 byte[] bytes = new byte[] {
  860.                     0x7c, 8, 2, 0xa6, 0xf8, 1, 0, 0x80, 60, 0x60, 0x10, 5, 0x81, 0x83, 0, 0x4c,
  861.                     0x2c, 12, 0, 0, 0x41, 130, 0, 100, 0x80, 0x83, 0, 4, 0x80, 0xa3, 0, 8,
  862.                     0x80, 0xc3, 0, 12, 0x80, 0xe3, 0, 0x10, 0x81, 3, 0, 20, 0x81, 0x23, 0, 0x18,
  863.                     0x81, 0x43, 0, 0x1c, 0x81, 0x63, 0, 0x20, 0xc0, 0x23, 0, 0x24, 0xc0, 0x43, 0, 40,
  864.                     0xc0, 0x63, 0, 0x2c, 0xc0, 0x83, 0, 0x30, 0xc0, 0xa3, 0, 0x34, 0xc0, 0xc3, 0, 0x38,
  865.                     0xc0, 0xe3, 0, 60, 0xc1, 3, 0, 0x40, 0xc1, 0x23, 0, 0x48, 0x80, 0x63, 0, 0,
  866.                     0x7d, 0x89, 3, 0xa6, 0x4e, 0x80, 4, 0x21, 60, 0x80, 0x10, 5, 0x38, 160, 0, 0,
  867.                     0x90, 0xa4, 0, 0x4c, 0x80, 100, 0, 80, 0xe8, 1, 0, 0x80, 0x7c, 8, 3, 0xa6,
  868.                     0x38, 0x21, 0, 0x70, 0x4e, 0x80, 0, 0x20
  869.                  };
  870.                 Ghosts.PS3.SetMemory(function_address + 4, bytes);
  871.                 Ghosts.PS3.SetMemory(0x10050000, new byte[0x2854]);
  872.                 Ghosts.PS3.SetMemory(function_address, new byte[] { 0xf8, 0x21, 0xff, 0x91 });
  873.             }
  874.  
  875.             public static uint Get_func_address()
  876.             {
  877.                 for (uint i = 0x489bd4; i < 0x1000000; i += 4)
  878.                 {
  879.                     byte[] memory = Ghosts.PS3.GetMemory(i, 8);
  880.                     if (((((memory[0] == 60) && (memory[1] == 0x8e)) && ((memory[2] == 250) && (memory[3] == 0x35))) && (((memory[4] == 0x42) && (memory[5] == 200)) && (memory[6] == 0))) && (memory[7] == 0))
  881.                     {
  882.                         return (i + 12);
  883.                     }
  884.                 }
  885.                 return 0;
  886.             }
  887.  
  888.             public static int Init()
  889.             {
  890.                 function_address = Ghosts.Offsets.RPC;
  891.                 Enable_RPC();
  892.                 return 0;
  893.             }
  894.  
  895.             public static void iPrintln(int client, string TextiPrintIn)
  896.             {
  897.                 SV_GameSendServerCommand(client, "e \"" + TextiPrintIn + "\"");
  898.             }
  899.  
  900.             public static void iPrintlnBold(int clientNumber, string TextiPrintinBold)
  901.             {
  902.                 SV_GameSendServerCommand(clientNumber, "c \"" + TextiPrintinBold + "\"");
  903.             }
  904.  
  905.             public static void SV_GameSendServerCommand(int Client, string Command)
  906.             {
  907.                 Call(Ghosts.Offsets.SV_GameSendServerCommand, new object[] { Client, 0, Command });
  908.             }
  909.         }
  910.     }
  911. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement