sharkbait263

BO2 Scrolling News Bar [C#]

Nov 23rd, 2013
731
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.12 KB | None | 0 0
  1. public class Ps3Memory
  2.     {
  3.         public static byte[] BIND = new byte[4];
  4.         public static uint ProcessID;
  5.         public static uint[] processIDs;
  6.         private static string usage;
  7.         public static PS3TMAPI.ConnectStatus connectStatus;
  8.         public static string Status;
  9.  
  10. public static void SetMemory(uint Address, byte[] Bytes)
  11.         {
  12.             PS3TMAPI.ProcessSetMemory(0, PS3TMAPI.UnitType.PPU, ProcessID, 0, Address, Bytes);
  13.         }
  14.      }
  15.  
  16. public class HElems
  17.         {
  18.             public static uint
  19.             type = 0x6D,
  20.             xOffset = 0x00,
  21.             yOffset = 0x04,
  22.             textOffset = 0x62,
  23.             sort = 32,
  24.             fontSizeOffset = 0x0C,
  25.             clientOffset = 0x7C,
  26.             colorOffset = 0x18,
  27.             GlowColor = 0x1c,
  28.             widthOffset = 0x58,
  29.             heightOffset = 0x5A,
  30.             shaderOffset = 0x74,
  31.             Material = 0x71;
  32.         }
  33.  
  34. public class Hudelem //Hud Elements
  35.         {
  36.             public static uint
  37.                 type = 0x6D,
  38.                 xOffset = 0x00,
  39.                 yOffset = 0x04,
  40.                 textOffset = 0x62,
  41.                 sort = 32,
  42.                 fontSizeOffset = 0x0C,
  43.                 clientOffset = 0x7C,
  44.                 colorOffset = 0x18,
  45.                 GlowColor = 0x44,
  46.                 widthOffset = 0x58,
  47.                 heightOffset = 0x5A,
  48.                 shaderOffset = 0x74,
  49.                 Material = 0x71;
  50.  
  51.             public class HUD
  52.             {
  53.                 public static byte[] SetText(string Text)
  54.                 {
  55.                     byte[] clean = new byte[250];
  56.                     SetMemory(0x2000000, clean);
  57.                     SetMemory(0x2000000, Encoding.ASCII.GetBytes(Text + "\0"));
  58.                     byte[] Patch = new byte[] { 0x48, 0x44, 0xB3, 0x1D, 0x3C, 0x60, 0x00, 0xD8,
  59.  
  60. 0x80, 0x63, 0xBC, 0xD8, 0x2C, 0x03, 0x00, 0x00, 0x40, 0x82, 0x00, 0x7C, 0x3C, 0x60, 0x02, 0x00,
  61.  
  62. 0x30, 0x63, 0x00, 0x00, 0x4B, 0xED, 0xE4, 0xED, 0x3c, 0x80, 0x02, 0x00, 0x90, 0x64, 0x50, 0x00,
  63.  
  64. 0x48, 0x00, 0x00, 0x68, 0x4B, 0xFD, 0x80, 0x61 };
  65.                     byte[] Unpatch = new byte[] { 0x48, 0x44, 0xB3, 0x1D, 0x3C, 0x60, 0x00,
  66.  
  67. 0xD8, 0x80, 0x63, 0xBC, 0xD8, 0x2C, 0x03, 0x00, 0x00, 0x41, 0x82, 0x00, 0x7C, 0x3C, 0x60, 0x00,
  68.  
  69. 0x39, 0x38, 0x80, 0x00, 0x00, 0x3B, 0xE3, 0x70, 0xE4, 0x63, 0x43, 0x00, 0x00, 0xC3, 0xFF, 0x00,
  70.  
  71. 0x08, 0xFC, 0x20, 0xF8, 0x90, 0x4B, 0xFD, 0x80, 0x61 };
  72.                     SetMemory(0X03976DC, Patch);
  73.                     Thread.Sleep(15);
  74.                     SetMemory(0X03976DC, Unpatch);
  75.                     byte[] GetX = new byte[4];
  76.                     GetMemoryHUD(0x2005000, ref GetX);
  77.                     return GetX;
  78.  
  79.                 }
  80.  
  81.                 public static byte[] uintBytes(uint input)
  82.                 {
  83.                     byte[] data = BitConverter.GetBytes(input);
  84.                     Array.Reverse(data);
  85.                     return data;
  86.                 }
  87.  
  88.                 private class MenuItems
  89.                 {
  90.                     public static uint Shader = 0, ScrollBarBackGround = 1;
  91.                 }
  92.  
  93.                 public static byte[] ReverseBytes(byte[] inArray)
  94.                 {
  95.                     Array.Reverse(inArray);
  96.                     return inArray;
  97.                 }
  98.  
  99.                 public static byte[] ToHexFloat(float Axis)
  100.                 {
  101.                     byte[] bytes = BitConverter.GetBytes(Axis);
  102.                     Array.Reverse(bytes);
  103.                     return bytes;
  104.                 }
  105.  
  106.                 public static byte[] RGBA(decimal R, decimal G, decimal B, decimal A)
  107.                 {
  108.                     byte[] RGBA = new byte[4];
  109.                     byte[] RVal = BitConverter.GetBytes(Convert.ToInt32(R));
  110.                     byte[] GVal = BitConverter.GetBytes(Convert.ToInt32(G));
  111.                     byte[] BVal = BitConverter.GetBytes(Convert.ToInt32(B));
  112.                     byte[] AVal = BitConverter.GetBytes(Convert.ToInt32(A));
  113.                     RGBA[0] = RVal[0];
  114.                     RGBA[1] = GVal[0];
  115.                     RGBA[2] = BVal[0];
  116.                     RGBA[3] = AVal[0];
  117.                     return RGBA;
  118.                 }
  119.  
  120.                 public static void StoreIcon1(int elemIndex, uint client, int shader, int width, int height, int x, int y, uint align, float sort, int r, int g, int b, int a)
  121.                 {
  122.                     byte[] Material_ = BitConverter.GetBytes(shader);
  123.                     Array.Reverse(Material_);
  124.                     byte[] Height_ = BitConverter.GetBytes(Convert.ToInt32(height));
  125.                     Array.Resize(ref Height_, 2);
  126.                     Array.Reverse(Height_);
  127.                     byte[] width_ = BitConverter.GetBytes(Convert.ToInt32(width));
  128.                     Array.Resize(ref width_, 2);
  129.                     Array.Reverse(width_);
  130.                     uint elem = 0x15D8400 + ((Convert.ToUInt32(elemIndex)) * 0x88);
  131.                     byte[] ClientID = ReverseBytes(BitConverter.GetBytes(client));
  132.                     SetMemory(elem, new byte[0x88]);
  133.                     SetMemory(elem + Hudelem.type, ReverseBytes(BitConverter.GetBytes(8)));
  134.                     SetMemory(elem + 0x79, new byte[] { 0xFF });
  135.                     SetMemory(elem + 0xC, new byte[] { 0x3f, 0xc0 });
  136.                     SetMemory(elem + Hudelem.Material, Material_);
  137.                     SetMemory(elem + Hudelem.heightOffset, Height_);
  138.                     SetMemory(elem + Hudelem.widthOffset, width_);
  139.                     SetMemory(elem + Hudelem.textOffset + 4, ReverseBytes(BitConverter.GetBytes(sort)));
  140.                     SetMemory(elem + Hudelem.xOffset, ToHexFloat(x));
  141.                     SetMemory(elem + Hudelem.yOffset, ToHexFloat(y));
  142.                     SetMemory(elem + Hudelem.colorOffset, RGBA(r, g, b, a));
  143.                     SetMemory(elem + Hudelem.clientOffset, ClientID);
  144.                     System.Threading.Thread.Sleep(20);
  145.                 }
  146.  
  147.                 public static void StoreTextElem1(int elemIndex, int client, string text, int font, int fontScale, int x, int y, uint align, int sort, int R, int V, int B, int a)
  148.                 {
  149.                     string setText = text + "\0";
  150.                     byte[] TextIndex = SetText(setText);
  151.                     uint elem = 0x15D8400 + ((Convert.ToUInt32(elemIndex)) * 0x88);
  152.                     byte[] ClientID = ReverseBytes(BitConverter.GetBytes(Convert.ToInt32(client)));
  153.             int typez = a;
  154.                     Ps3Memory.SetMemory(elem + HElems.type, ReverseBytes(BitConverter.GetBytes(typez)));
  155.                     SetMemory(elem, new byte[0x88]);
  156.                     SetMemory(elem + Hudelem.type, ReverseBytes(BitConverter.GetBytes(1)));
  157.  
  158.  
  159.                     SetMemory(elem + 0x79, new byte[] { 0xFF });
  160.                     SetMemory(elem + 0xC, new byte[] { 0x3f, 0xc0 });
  161.                     SetMemory(elem + Hudelem.textOffset, TextIndex);
  162.                     SetMemory(elem + Hudelem.fontSizeOffset,
  163.                               ReverseBytes(BitConverter.GetBytes(Convert.ToSingle(font))));
  164.                     SetMemory(elem + Hudelem.xOffset, ToHexFloat(x));
  165.                     SetMemory(elem + Hudelem.yOffset, ToHexFloat(y));
  166.                     SetMemory(elem + Hudelem.colorOffset, RGBA(R, V, B, a));
  167.                     SetMemory(elem + Hudelem.clientOffset, ClientID);
  168.                     System.Threading.Thread.Sleep(20);
  169.          }
  170.                 public static void SetGlow(int elemIndex, int client, string text, int font, int fontScale, int x, int y, uint align, int sort, int R, int V, int B, int a, int GlowR, int GlowG, int GlowB, int GlowA)
  171.                 {
  172.                     string setText = text + "\0";
  173.                     byte[] TextIndex = SetText(setText);
  174.                     uint elem = 0x15D8400 + ((Convert.ToUInt32(elemIndex)) * 0x88);
  175.                     byte[] ClientID = ReverseBytes(BitConverter.GetBytes(Convert.ToInt32(client)));
  176.                     SetMemory(elem, new byte[0x88]);
  177.                     SetMemory(elem + Hudelem.type, ReverseBytes(BitConverter.GetBytes(1)));
  178.  
  179.  
  180.                     SetMemory(elem + 0x79, new byte[] { 0xFF });
  181.                     SetMemory(elem + 0xC, new byte[] { 0x3f, 0xc0 });
  182.                     SetMemory(elem + Hudelem.textOffset, TextIndex);
  183.                     SetMemory(elem + Hudelem.fontSizeOffset,
  184.                               ReverseBytes(BitConverter.GetBytes(Convert.ToSingle(font))));
  185.                     SetMemory(elem + Hudelem.xOffset, ToHexFloat(x));
  186.                     SetMemory(elem + Hudelem.yOffset, ToHexFloat(y));
  187.                     SetMemory(elem + Hudelem.colorOffset, RGBA(R, V, B, a));
  188.                     SetMemory(elem + Hudelem.GlowColor,
  189.                               new byte[]
  190.                                   {
  191.                                       BitConverter.GetBytes(GlowR)[0], BitConverter.GetBytes (GlowG)[0],
  192.                                       BitConverter.GetBytes(GlowB)[0], BitConverter.GetBytes (GlowA)[0]
  193.                                   });
  194.                     SetMemory(elem + Hudelem.clientOffset, ClientID);
  195.                     System.Threading.Thread.Sleep(20);
  196.                 }
  197.  
  198.                 public static void MoveShader1(uint index, int X_, int Y_, float TextSize_)
  199.                 {
  200.                     byte[] X = new byte[4];
  201.                     byte[] Y = new byte[4];
  202.                     byte[] TextSize = new byte[4];
  203.                     X = BitConverter.GetBytes(Convert.ToSingle(X_));
  204.                     Y = BitConverter.GetBytes(Convert.ToSingle(Y_));
  205.                     TextSize = BitConverter.GetBytes(Convert.ToSingle(TextSize_));
  206.                     byte[] Width = new byte[4];
  207.                     byte[] Height = new byte[4];
  208.  
  209.  
  210.                     Array.Reverse(X);
  211.                     Array.Reverse(Y);
  212.                     Array.Reverse(TextSize);
  213.                     SetMemory(0x15D8400 + (index * 0x88) + 0, X);
  214.                     SetMemory(0x15D8400 + (index * 0x88) + 4, Y);
  215.                     SetMemory(0x15D8400 + (index * 0x88) + 12, TextSize);
  216.  
  217.                 }
  218.  
  219.                 public static void MoveShader2(uint index, int X_, int Y_, int Width_, int Height_)
  220.                 {
  221.  
  222.  
  223.                     byte[] X = new byte[4];
  224.                     byte[] Y = new byte[4];
  225.                     X = BitConverter.GetBytes(Convert.ToSingle(X_));
  226.                     Y = BitConverter.GetBytes(Convert.ToSingle(Y_));
  227.                     byte[] Width = new byte[4];
  228.                     byte[] Height = new byte[4];
  229.                     Width = BitConverter.GetBytes(Width_);
  230.                     Height = BitConverter.GetBytes(Height_);
  231.                     Array.Reverse(X);
  232.                     Array.Reverse(Y);
  233.                     Array.Reverse(Width);
  234.                     Array.Reverse(Height);
  235.                     SetMemory(0x15D8400 + (index * 0x88) + 0, X);
  236.                     SetMemory(0x15D8400 + (index * 0x88) + 4, Y);
  237.                     SetMemory(0x15D8400 + (index * 0x88) + 68, Width);
  238.                     SetMemory(0x15D8400 + (index * 0x88) + 72, Height);
  239.  
  240.                 }
  241.  
  242.                 public static void DestroyElem(int index)
  243.                 {
  244.                     uint elem = 0x15D8400 + ((Convert.ToUInt32(index)) * 0x88);
  245.                     SetMemory(elem, new byte[0x88]);
  246.                 }
  247.             }
  248.         }
  249.  
  250. //Functions
  251. public byte[] GetMemory2(uint address, int length)
  252.         {
  253.             byte[] buffer = new byte[length];
  254.             PS3TMAPI.ProcessGetMemory(0, PS3TMAPI.UnitType.PPU, Ps3Memory.ProcessID, 0L, (ulong)address, ref buffer);
  255.             return buffer;
  256.         }
  257.  
  258.         public static void SetMemory(uint Address, byte[] Bytes)
  259.         {
  260.             PS3TMAPI.ProcessSetMemory(0, PS3TMAPI.UnitType.PPU, Ps3Memory.ProcessID, 0L, (ulong)Address, Bytes);
  261.         }
  262.  
  263.         public static void GetMemoryHUD(uint Address, ref byte[] Bytes)
  264.         {
  265.             PS3TMAPI.ProcessGetMemory(0, PS3TMAPI.UnitType.PPU, Ps3Memory.ProcessID, 0, Address, ref Bytes);
  266.         }
  267.  
  268. private class MenuItems
  269.                 {
  270.                     public static uint Shader = 0, ScrollBarBackGround = 1;
  271.                 }
  272.  
  273. public void NewsBar(uint client, bool state, string Text)
  274.         {
  275.         PS3TMAPI.InitTargetComms();
  276.                 PS3TMAPI.Connect(0, null);
  277.                 PS3TMAPI.GetProcessList(0, out Ps3Memory.processIDs);
  278.                 ulong uProcess = Ps3Memory.processIDs[0];
  279.                 Ps3Memory.ProcessID = Convert.ToUInt32(uProcess);
  280.                 PS3TMAPI.ProcessAttach(0, PS3TMAPI.UnitType.PPU, Ps3Memory.ProcessID);
  281.                 PS3TMAPI.ProcessContinue(0, Ps3Memory.ProcessID);
  282.  
  283.                 if (state == false)
  284.                 {
  285.                     Hudelem.HUD.DestroyElem(600);
  286.                     Hudelem.HUD.DestroyElem(601);
  287.                     Hudelem.HUD.DestroyElem(602);
  288.                     Hudelem.HUD.DestroyElem(603);
  289.                 }
  290.                 else
  291.                 {
  292.                     //Red, Green, Blue, Alpha (transparency)
  293.                     var scrollspeed = 1; //Scrolling Speed                                                      
  294.                     Hudelem.HUD.StoreIcon1(600, client, 4, 2000, 30, -120, 403, 0, MenuItems.ScrollBarBackGround, 255, 255, 255, 240); //Background
  295.                     Hudelem.HUD.StoreIcon1(601, client, 3, 2000, 3, -120, 402, 0, MenuItems.ScrollBarBackGround, 255, 20, 0, 150); //Background
  296.                     Hudelem.HUD.StoreIcon1(602, client, 3, 2000, 3, -120, 432, 0, MenuItems.ScrollBarBackGround, 255, 20, 0, 150); //Background
  297.                     Hudelem.HUD.StoreTextElem1(603, (int)client, Text, 3, 1, 300, 453, MenuItems.Shader, 0, 255, 255, 255, 255); //Text
  298.  
  299.                     for (int i = 800; i > -400; )
  300.                     {
  301.                         i = i - scrollspeed; //Speed
  302.                         Hudelem.HUD.MoveShader2(603, i, 400, 0, 0);
  303.                         if (i == -300)
  304.                         {
  305.                             i = 800;
  306.                         }
  307.                     }
  308.                 }
  309.             }
Advertisement
Add Comment
Please, Sign In to add comment