Advertisement
BaSs_HaXoR

MW2 Cex/Dex Compatible RPC Source (.cs)

Feb 26th, 2015
798
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 17.17 KB | None | 0 0
  1. /* ----------------------------------------------------------------------------------- */
  2.  
  3. //           MW2 CEX / DEX compatible RPC (Remote Procedure Calls) .cs Source          //
  4.  
  5. /* ----------------------------------------------------------------------------------- */
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using PS3Lib;
  11. using System.Threading;
  12. namespace Yourprogram
  13. {
  14. /* ----------------------------------------------------------------------------------- */
  15.     /*
  16. Yb        dP 8           w      .d88b.                       w  w          dP"Yb
  17.  Yb  db  dP  8d8b. .d88 w8ww    YPwww. .d88b .d8b 8   8 8d8b w w8ww Yb  dP "  d8
  18.   YbdPYbdP   8P Y8 8  8  8          d8 8.dP' 8    8b d8 8P   8  8    YbdP    dP  
  19.    YP  YP    8   8 `Y88  Y8P    `Y88P' `Y88P `Y8P `Y8P8 8    8  Y8P   dP     w  
  20.                                                                      dP      x  
  21.      */
  22.     //BaSs_HaXoR was here.
  23.     class CDRPC
  24.     {
  25.         public static PS3API PS3 = new PS3API(SelectAPI.ControlConsole);
  26.         public static uint fxBirthTime = 0x90;
  27.         public static uint fxDecayDuration = 0x9c;
  28.         public static uint fxDecayStartTime = 0x98;
  29.         public static uint fxLetterTime = 0x94;
  30.  
  31.         private static uint function_address = 0x38EDE8;
  32.  
  33.         public static int Call(UInt32 func_address, params object[] parameters)
  34.         {
  35.             int length = parameters.Length;
  36.             int index = 0;
  37.             UInt32 num3 = 0;
  38.             UInt32 num4 = 0;
  39.             UInt32 num5 = 0;
  40.             UInt32 num6 = 0;
  41.             while (index < length)
  42.             {
  43.                 if (parameters[index] is int)
  44.                 {
  45.                     PS3.Extension.WriteInt32(0x10050000 + (num3 * 4), (int)parameters[index]);
  46.                     num3++;
  47.                 }
  48.                 else if (parameters[index] is UInt32)
  49.                 {
  50.                     PS3.Extension.WriteUInt32(0x10050000 + (num3 * 4), (UInt32)parameters[index]);
  51.                     num3++;
  52.                 }
  53.                 else
  54.                 {
  55.                     UInt32 num7;
  56.                     if (parameters[index] is string)
  57.                     {
  58.                         num7 = 0x10052000 + (num4 * 0x400);
  59.                         PS3.Extension.WriteString(num7, Convert.ToString(parameters[index]));
  60.                         PS3.Extension.WriteUInt32(0x10050000 + (num3 * 4), num7);
  61.                         num3++;
  62.                         num4++;
  63.                     }
  64.                     else if (parameters[index] is float)
  65.                     {
  66.                         PS3.Extension.WriteFloat(0x10050024 + (num5 * 4), (float)parameters[index]);
  67.                         num5++;
  68.                     }
  69.                     else if (parameters[index] is float[])
  70.                     {
  71.                         float[] input = (float[])parameters[index];
  72.                         num7 = 0x10051000 + (num6 * 4);
  73.                         CDRPC.WriteSingle(num7, input);
  74.                         PS3.Extension.WriteUInt32(0x10050000 + (num3 * 4), num7);
  75.                         num3++;
  76.                         num6 += (UInt32)input.Length;
  77.                     }
  78.                 }
  79.                 index++;
  80.             }
  81.             PS3.Extension.WriteUInt32(0x1005004C, func_address);
  82.             Thread.Sleep(20);
  83.             return PS3.Extension.ReadInt32(0x10050050);
  84.         }
  85.  
  86.         public static void EnableRPC()
  87.         {
  88.             byte[] RPC = { 0xF8, 0x21, 0xFF, 0x91, 0x7C, 0x08, 0x02, 0xA6, 0xF8, 0x01, 0x00, 0x80, 0x3C, 0x40, 0x00, 0x72, 0x30, 0x42, 0x4C, 0x38, 0x3C, 0x60, 0x10, 0x05, 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, 0x05, 0x38, 0xA0, 0x00, 0x00, 0x90, 0xA4, 0x00, 0x4C, 0x90, 0x64, 0x00, 0x50, 0x3C, 0x40, 0x00, 0x73, 0x30, 0x42, 0x4B, 0xE8, 0xE8, 0x01, 0x00, 0x80, 0x7C, 0x08, 0x03, 0xA6, 0x38, 0x21, 0x00, 0x70, 0x4E, 0x80, 0x00, 0x20 };
  89.             PS3.SetMemory(function_address, RPC);
  90.             PS3.SetMemory(0x10050000, new byte[0x2854]);
  91.         }
  92.         public class HudStruct
  93.         {
  94.             public static uint
  95.             xOffset = 0x08,
  96.             yOffset = 0x04,
  97.             textOffset = 0x84,
  98.             GlowColor = 0x8C,
  99.             fxBirthTime = 0x90,
  100.             fxLetterTime = 0x94,
  101.             fadeStartTime = 0x3C,
  102.             fadeTime = 0x40,
  103.             fromColor = 0x38,
  104.             fxDecayStartTime = 0x98,
  105.             fxDecayDuration = 0x9C,
  106.             fontOffset = 0x28,
  107.             fontSizeOffset = 0x14,
  108.             colorOffset = 0x34,
  109.             scaleStartTime = 0x58,
  110.             fromFontScale = 0x18,
  111.             fontScaleTime = 0x20,
  112.             relativeOffset = 0x2c,
  113.             widthOffset = 0x48,
  114.             heightOffset = 0x44,
  115.             shaderOffset = 0x4C,
  116.             alignOffset = 0x30,
  117.             fromAlignOrg = 0x68,
  118.             fromAlignScreen = 0x6C,
  119.             alignOrg = 0x2C,
  120.             alignScreen = 0x30,
  121.             fromY = 0x60,
  122.             fromX = 0x64,
  123.             moveStartTime = 0x70,
  124.             moveTime = 0x74,
  125.             flags = 0xA4,
  126.             clientIndex = 0xA8;
  127.         }
  128.  
  129.  
  130.         public static class HudAlloc
  131.         {
  132.             public static uint
  133.                 IndexSlot = 50,
  134.                 g_hudelem = 0x012E9858;
  135.  
  136.  
  137.             public static bool
  138.                 Start = true;
  139.         }
  140.  
  141.  
  142.         public static class HUDAlign
  143.         {
  144.             public static uint
  145.                 RIGHT = 2,
  146.                 CENTER = 5,
  147.                 LEFT = 1;
  148.         }
  149.  
  150.  
  151.         public class HudTypes
  152.         {
  153.             public static uint
  154.                 Text = 1,
  155.                 Shader = 6,
  156.                 Null = 0;
  157.         }
  158.         public static void ChangeFont(uint elem, uint font)
  159.         {
  160.             PS3.Extension.WriteUInt32(elem + HudStruct.fontOffset, font);
  161.         }
  162.         public class Material
  163.         {
  164.             public static uint
  165.                 White = 1,
  166.                 Black = 2,
  167.                 Prestige0 = 0x1A,
  168.                 Prestige1 = 0x1B,
  169.                 Prestige2 = 0x1C,
  170.                 Prestige3 = 0x1D,
  171.                 Prestige4 = 0x1E,
  172.                 Prestige5 = 0x1F,
  173.                 Prestige6 = 0x20,
  174.                 Prestige7 = 0x21,
  175.                 Prestige8 = 0x22,
  176.                 Prestige9 = 0x23,
  177.                 Prestige10 = 0x24,
  178.                 WhiteRectangle = 0x25,
  179.                 NoMap = 0x29;
  180.         }
  181.         public static int RGB2INT(int r, int g, int b, int a)
  182.         {
  183.             byte[] newRGB = new byte[4];
  184.             newRGB[0] = (byte)r;
  185.             newRGB[1] = (byte)g;
  186.             newRGB[2] = (byte)b;
  187.             newRGB[3] = (byte)a;
  188.             Array.Reverse(newRGB);
  189.             return BitConverter.ToInt32(newRGB, 0);
  190.         }
  191.         public static void SetText(uint clientIndex, uint elem, string text, uint font, float fontScale, float x, float y, uint alignText, uint align, int r = 255, int g = 255, int b = 255, int a = 255, int GlowR = 255, int GlowG = 0, int GlowB = 0, int GlowA = 0)
  192.         {
  193.             PS3.Extension.WriteInt32(elem, 0);
  194.             PS3.Extension.WriteInt32(elem + HudStruct.flags, 1);
  195.             PS3.Extension.WriteUInt32(elem + HudStruct.clientIndex, clientIndex);
  196.             PS3.Extension.WriteUInt32(elem + HudStruct.textOffset, G_LocalizedString(text));
  197.             PS3.Extension.WriteUInt32(elem + HudStruct.relativeOffset, alignText);
  198.             PS3.Extension.WriteUInt32(elem + HudStruct.relativeOffset - 4, 6);
  199.             PS3.Extension.WriteUInt32(elem + HudStruct.fontOffset, font);
  200.             PS3.Extension.WriteUInt32(elem + HudStruct.alignOffset, align);
  201.             PS3.Extension.WriteInt16(elem + HudStruct.textOffset + 4, 0x4000);
  202.             PS3.Extension.WriteFloat(elem + HudStruct.fontSizeOffset, fontScale);
  203.             PS3.Extension.WriteFloat(elem + HudStruct.xOffset, x);
  204.             PS3.Extension.WriteFloat(elem + HudStruct.yOffset, y);
  205.             PS3.Extension.WriteInt32(elem + HudStruct.colorOffset, RGB2INT(r, g, b, a));
  206.             PS3.Extension.WriteInt32(elem + HudStruct.GlowColor, RGB2INT(GlowR, GlowG, GlowB, GlowA));
  207.             setClientJustDvar((int)clientIndex, "loc_warnings 0");
  208.             setClientJustDvar((int)clientIndex, "loc_warningsAsErrors 0");
  209.         }
  210.  
  211.  
  212.  
  213.         public static void SetShader(uint clientIndex, uint elem, string shader, int width, int height, float x, float y, uint align, float sort = 0, int r = 255, int g = 255, int b = 255, int a = 255)
  214.         {
  215.             PS3.Extension.WriteInt32(elem, 0);
  216.             PS3.Extension.WriteInt32(elem + HudStruct.flags, 1);
  217.             PS3.Extension.WriteUInt32(elem + HudStruct.clientIndex, clientIndex);
  218.             PS3.Extension.WriteUInt32(elem + HudStruct.shaderOffset, G_MaterialIndex(shader));
  219.             PS3.Extension.WriteUInt32(elem + HudStruct.relativeOffset, 5);
  220.             PS3.Extension.WriteUInt32(elem + HudStruct.relativeOffset - 4, HUDAlign.RIGHT);
  221.             PS3.Extension.WriteInt32(elem + HudStruct.heightOffset, height);
  222.             PS3.Extension.WriteInt32(elem + HudStruct.alignOrg, 0);
  223.             PS3.Extension.WriteInt32(elem + HudStruct.alignScreen, 0);
  224.             PS3.Extension.WriteInt32(elem + HudStruct.widthOffset, width);
  225.             PS3.Extension.WriteUInt32(elem + HudStruct.alignOffset, align);
  226.             PS3.Extension.WriteFloat(elem + HudStruct.xOffset, x);
  227.             PS3.Extension.WriteFloat(elem + HudStruct.yOffset, y);
  228.             PS3.Extension.WriteInt32(elem + HudStruct.colorOffset, RGB2INT(r, g, b, a));
  229.             PS3.Extension.WriteFloat(elem + HudStruct.textOffset + 4, sort);
  230.         }
  231.         public static void FadeOverTime(uint elem, int Time, int R, int G, int B, int A)
  232.         {
  233.             PS3.Extension.WriteInt32(elem + HudStruct.fadeStartTime, getLevelTime());
  234.             PS3.Extension.WriteBytes(elem + HudStruct.fromColor, PS3.Extension.ReadBytes(elem + HudStruct.colorOffset, 4));
  235.             PS3.Extension.WriteInt32(elem + HudStruct.fadeTime, Time);
  236.             PS3.Extension.WriteInt32(elem + HudStruct.colorOffset, RGB2INT(R, G, B, A));
  237.         }
  238.         public static void FadeGlowOverTime(uint elem, int Time, int GlowR, int GlowG, int GlowB, int GlowA)
  239.         {
  240.             PS3.Extension.WriteInt32(elem + HudStruct.fadeStartTime, getLevelTime());
  241.             PS3.Extension.WriteBytes(elem + HudStruct.fromColor, PS3.Extension.ReadBytes(elem + HudStruct.colorOffset, 4));
  242.             PS3.Extension.WriteInt32(elem + HudStruct.fadeTime, Time);
  243.             PS3.Extension.WriteInt32(elem + HudStruct.GlowColor, RGB2INT(GlowR, GlowG, GlowB, GlowA));
  244.         }
  245.  
  246.         public static void MoveOverTime(uint elem, Int32 time, float x, float y)
  247.         {
  248.             PS3.Extension.WriteInt32(elem + HudStruct.fromAlignOrg, PS3.Extension.ReadInt32(elem + HudStruct.alignOrg));
  249.             PS3.Extension.WriteInt32(elem + HudStruct.fromAlignScreen, PS3.Extension.ReadInt32(elem + HudStruct.alignScreen));
  250.             PS3.Extension.WriteFloat(elem + HudStruct.fromY, PS3.Extension.ReadFloat(elem + HudStruct.yOffset));
  251.             PS3.Extension.WriteFloat(elem + HudStruct.fromX, PS3.Extension.ReadFloat(elem + HudStruct.xOffset));
  252.             PS3.Extension.WriteInt32(elem + HudStruct.moveStartTime, getLevelTime());
  253.             PS3.Extension.WriteInt32(elem + HudStruct.moveTime, time);
  254.             PS3.Extension.WriteFloat(elem + HudStruct.xOffset, x);
  255.             PS3.Extension.WriteFloat(elem + HudStruct.yOffset, y);
  256.         }
  257.         public static void setPulseFX(uint elem, int speed, int decayStart, int decayDuration)
  258.         {
  259.             PS3.Extension.WriteInt32(elem + HudStruct.fxBirthTime, getLevelTime());
  260.             PS3.Extension.WriteInt32(elem + HudStruct.fxLetterTime, speed);
  261.             PS3.Extension.WriteInt32(elem + HudStruct.fxDecayStartTime, decayStart);
  262.             PS3.Extension.WriteInt32(elem + HudStruct.fxDecayDuration, decayDuration);
  263.         }
  264.         public static void DestroyElem(uint elem)
  265.         {
  266.             PS3.SetMemory(elem, new byte[0xB4]);
  267.         }
  268.  
  269.         public static void SetElement(uint Element, uint HudTypes)
  270.         {
  271.             PS3.Extension.WriteUInt32(Element, HudTypes);
  272.         }
  273.         public static uint HudElemAlloc(bool Reset = false)
  274.         {
  275.             if (Reset == true)
  276.                 HudAlloc.IndexSlot = 50;
  277.             uint Output = HudAlloc.g_hudelem + (HudAlloc.IndexSlot * 0xB4);
  278.             HudAlloc.IndexSlot++;
  279.             return Output;
  280.         }
  281.         public static uint HudElemAlloc_Game(int clientNumber)
  282.         {
  283.             return (uint)Call(0x001806E0, clientNumber);
  284.         }
  285.         public static uint G_LocalizedString(string newText)
  286.         {
  287.             return (uint)Call(0x001BE7C8, newText);
  288.         }
  289.         public static uint G_MaterialIndex(string shader)
  290.         {
  291.             return (uint)Call(0x001BE758, shader);
  292.         }
  293.         public static Int32 getLevelTime()
  294.         {
  295.             return (Int32)PS3.Extension.ReadUInt32(0x12E0304);
  296.         }
  297.  
  298.  
  299.  
  300.         private static byte[] ReverseBytes(byte[] inArray)
  301.         {
  302.             Array.Reverse(inArray);
  303.             return inArray;
  304.         }
  305.         public static void WriteSingle(uint address, float[] input)
  306.         {
  307.             int length = input.Length;
  308.             byte[] array = new byte[length * 4];
  309.             for (int i = 0; i < length; i++)
  310.             {
  311.                 ReverseBytes(BitConverter.GetBytes(input[i])).CopyTo(array, (int)(i * 4));
  312.             }
  313.             PS3.SetMemory(address, array);
  314.         }
  315.         public static void ChangeText(uint Element, string newText)
  316.         {
  317.             PS3.Extension.WriteUInt32(Element + HudStruct.textOffset, G_LocalizedString(newText));
  318.         }
  319.         public static UInt32 client_s(Int32 clientIndex)
  320.         {
  321.             return 0x34740000 + (0x97F80 * (UInt32)clientIndex);
  322.         }
  323.         public static UInt32 G_Entity(Int32 clientIndex)
  324.         {
  325.             return 0x1319800 + (0x280 * (UInt32)clientIndex);
  326.         }
  327.         public static UInt32 G_Client(Int32 clientIndex)
  328.         {
  329.             return 0x14E2200 + (0x3700 * (UInt32)clientIndex);
  330.         }
  331.         public class Buttons
  332.         {
  333.             public static string
  334.                 DpadUp = "+actionslot 1",
  335.                 DpadDown = "+actionslot 2",
  336.                 DpadRight = "+actionslot 4",
  337.                 DpadLeft = "+actionslot 3",
  338.                 Cross = "+gostand",
  339.                 Circle = "+stance",
  340.                 Triangle = "weapnext",
  341.                 Square = "+usereload",
  342.                 R3 = "+melee",
  343.                 R2 = "+frag",
  344.                 R1 = "+attack",
  345.                 L3 = "+breath_sprint",
  346.                 L2 = "+smoke",
  347.                 L1 = "+speed_throw",
  348.                 Select = "togglescores",
  349.                 Start = "togglemenu";
  350.         }
  351.         public static bool ButtonPressed(int client, string Button)
  352.         {
  353.             if (PS3.Extension.ReadString(0x34750E9F + ((uint)client * 0x97F80)) == Button)
  354.                 return true;
  355.             else return false;
  356.         }
  357.         public static Boolean IsMW2()
  358.         {
  359.             foreach (String temp in new String[] { "BLUS30377", "BLKS20159", "BLES00683", "BLES00686", "BLES00685", "BLES00684", "BLES00687" })
  360.                 if (temp == PS3.Extension.ReadString(0x10010251))
  361.                     return true;
  362.             return false;
  363.         }
  364.         public static void cBuff_AddText(int clientNum, string command)
  365.         {
  366.             Call(0x001D9EC0, clientNum, command);
  367.         }
  368.         public static void SV_GameSendServerCommand(Int32 clientIndex, String Cmd)
  369.         {
  370.             Call(0x0021A0A0, clientIndex, 0, Cmd);
  371.         }
  372.  
  373.         public static void setClientDvar(int clientNumber, string dvar, string Val)
  374.         {
  375.             SV_GameSendServerCommand(clientNumber, "v " + dvar + " \"" + Val + "\"");
  376.         }
  377.         public static void setClientJustDvar(int clientNumber, string dvar)
  378.         {
  379.             SV_GameSendServerCommand(clientNumber, "v " + dvar);
  380.         }
  381.         public static void iPrintln(int clientNumber, string Txt)
  382.         {
  383.             SV_GameSendServerCommand(clientNumber, "f \"" + Txt + "\"");
  384.         }
  385.         public static void iPrintlnBold(int clientNumber, string Txt)
  386.         {
  387.             SV_GameSendServerCommand(clientNumber, "g \"" + Txt + "\"");
  388.         }
  389.         public static void playSound(int clientNumber, string soundName)
  390.         {
  391.             SV_GameSendServerCommand(clientNumber, "o \"" + soundName + "\"");
  392.         }
  393.     }
  394. }
  395. /* ----------------------------------------------------------------------------------- */
  396. //BaSs_HaXoR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement