Advertisement
Mango_Knife

Mw3 RPC Class

Apr 13th, 2014
1,582
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 22.57 KB | None | 0 0
  1.             //Mw3 RPC Class
  2.             public static class RPC
  3.             {
  4.                 #region RPC
  5.                 public static uint func_address = 0x0277208; //FPS Address 1.24
  6.                 /*
  7.                  * MW3 FPS RPC by VezahMoDz!
  8.                  * This function get written at the FPS Offset!
  9.                  *
  10.                      lis r28, 0x1005
  11.                      lwz r12, 0x48(r28)
  12.                      cmpwi r12, 0
  13.                      beq loc_277290
  14.                      lwz r3, 0x00(r28)
  15.                      lwz r4, 0x04(r28)
  16.                      lwz r5, 0x08(r28)
  17.                      lwz r6, 0x0C(r28)
  18.                      lwz r7, 0x10(r28)
  19.                      lwz r8, 0x14(r28)
  20.                      lwz r9, 0x18(r28)
  21.                      lwz r10, 0x1C(r28)
  22.                      lwz r11, 0x20(r28)
  23.                      lfs f1, 0x24(r28)
  24.                      lfs f2, 0x28(r28)
  25.                      lfs f3, 0x2C(r28)
  26.                      lfs f4, 0x30(r28)
  27.                      lfs f5, 0x34(r28)
  28.                      lfs f6, 0x38(r28)
  29.                      lfs f7, 0x3C(r28)
  30.                      lfs f8, 0x40(r28)
  31.                      lfs f9, 0x44(r28)
  32.                      mtctr r12
  33.                      bctrl
  34.                      li r4, 0
  35.                      stw r4, 0x48(r28)
  36.                      stw r3, 0x4C(r28)
  37.                      stfs f1, 0x50(r28)
  38.                      b loc_277290
  39.                  */
  40.                 public static uint GetFuncReturn()
  41.                 {
  42.                     byte[] ret = new byte[4];
  43.                     GetMemoryR(0x114AE64, ref ret);
  44.                     Array.Reverse(ret);
  45.                     return BitConverter.ToUInt32(ret, 0);
  46.                 }
  47.                 private static void GetMemoryR(uint Address, ref byte[] Bytes)
  48.                 {
  49.                     PS3.GetMemory(Address, Bytes);
  50.                 }
  51.                 public static void Enable()
  52.                 {
  53.                     if (PS3.Extension.ReadByte(0x27720C) == 0x80)
  54.                     {
  55.                         byte[] WritePPC = new byte[] {0x3F,0x80,0x10,0x05,0x81,0x9C,0x00,0x48,0x2C,0x0C,0x00,0x00,0x41,0x82,0x00,0x78,
  56.                                         0x80,0x7C,0x00,0x00,0x80,0x9C,0x00,0x04,0x80,0xBC,0x00,0x08,0x80,0xDC,0x00,0x0C,
  57.                                         0x80,0xFC,0x00,0x10,0x81,0x1C,0x00,0x14,0x81,0x3C,0x00,0x18,0x81,0x5C,0x00,0x1C,
  58.                                         0x81,0x7C,0x00,0x20,0xC0,0x3C,0x00,0x24,0xC0,0x5C,0x00,0x28,0xC0,0x7C,0x00,0x2C,
  59.                                         0xC0,0x9C,0x00,0x30,0xC0,0xBC,0x00,0x34,0xC0,0xDC,0x00,0x38,0xC0,0xFC,0x00,0x3C,
  60.                                         0xC1,0x1C,0x00,0x40,0xC1,0x3C,0x00,0x44,0x7D,0x89,0x03,0xA6,0x4E,0x80,0x04,0x21,
  61.                                         0x38,0x80,0x00,0x00,0x90,0x9C,0x00,0x48,0x90,0x7C,0x00,0x4C,0xD0,0x3C,0x00,0x50,
  62.                                         0x48,0x00,0x00,0x14};
  63.                         PS3.SetMemory(func_address, new byte[] { 0x41 });
  64.                         PS3.SetMemory(func_address + 4, WritePPC);
  65.                         PS3.SetMemory(func_address, new byte[] { 0x40 });
  66.                         Thread.Sleep(10);
  67.                         RPC.DestroyAll();
  68.                     }
  69.                     else
  70.                     {
  71.                     }
  72.                 }
  73.                 public static Int32 Call(UInt32 address, params Object[] parameters)
  74.                 {
  75.                     Int32 length = parameters.Length;
  76.                     Int32 index = 0;
  77.                     UInt32 count = 0;
  78.                     UInt32 Strings = 0;
  79.                     UInt32 Single = 0;
  80.                     UInt32 Array = 0;
  81.                     while (index < length)
  82.                     {
  83.                         if (parameters[index] is Int32)
  84.                         {
  85.                             PS3.Extension.WriteInt32(0x10050000 + (count * 4), (Int32)parameters[index]);
  86.                             count++;
  87.                         }
  88.                         else if (parameters[index] is UInt32)
  89.                         {
  90.                             PS3.Extension.WriteUInt32(0x10050000 + (count * 4), (UInt32)parameters[index]);
  91.                             count++;
  92.                         }
  93.                         else if (parameters[index] is Int16)
  94.                         {
  95.                             PS3.Extension.WriteInt16(0x10050000 + (count * 4), (Int16)parameters[index]);
  96.                             count++;
  97.                         }
  98.                         else if (parameters[index] is UInt16)
  99.                         {
  100.                             PS3.Extension.WriteUInt16(0x10050000 + (count * 4), (UInt16)parameters[index]);
  101.                             count++;
  102.                         }
  103.                         else if (parameters[index] is Byte)
  104.                         {
  105.                             PS3.Extension.WriteByte(0x10050000 + (count * 4), (Byte)parameters[index]);
  106.                             count++;
  107.                         }
  108.                         else
  109.                         {
  110.                             UInt32 pointer;
  111.                             if (parameters[index] is String)
  112.                             {
  113.                                 pointer = 0x10052000 + (Strings * 0x400);
  114.                                 PS3.Extension.WriteString(pointer, Convert.ToString(parameters[index]));
  115.                                 PS3.Extension.WriteUInt32(0x10050000 + (count * 4), pointer);
  116.                                 count++;
  117.                                 Strings++;
  118.                             }
  119.                             else if (parameters[index] is Single)
  120.                             {
  121.                                 WriteSingle(0x10050024 + (Single * 4), (Single)parameters[index]);
  122.                                 Single++;
  123.                             }
  124.                             else if (parameters[index] is Single[])
  125.                             {
  126.                                 Single[] Args = (Single[])parameters[index];
  127.                                 pointer = 0x10051000 + Array * 4;
  128.                                 WriteSingle(pointer, Args);
  129.                                 PS3.Extension.WriteUInt32(0x10050000 + count * 4, pointer);
  130.                                 count++;
  131.                                 Array += (UInt32)Args.Length;
  132.                             }
  133.  
  134.                         }
  135.                         index++;
  136.                     }
  137.                     PS3.Extension.WriteUInt32(0x10050048, address);
  138.                     Thread.Sleep(20);
  139.                     return PS3.Extension.ReadInt32(0x1005004c);
  140.                 }
  141.                 public static void DestroyAll()
  142.                 {
  143.                     Byte[] clear = new Byte[0xB4 * 1024];
  144.                     PS3.SetMemory(0xF0E10C, clear);
  145.                 }
  146.                 #endregion
  147.                 #region WriteSingle & ReverseBytes [Needed For RPC]
  148.                     public static void WriteSingle(uint address, float[] input)
  149.                     {
  150.                         int length = input.Length;
  151.                         byte[] array = new byte[length * 4];
  152.                         for (int i = 0; i < length; i++)
  153.                         {
  154.                             ReverseBytes(BitConverter.GetBytes(input[i])).CopyTo(array, (int)(i * 4));
  155.                         }
  156.                         PS3.SetMemory(address, array);
  157.                     }
  158.                     public static void WriteSingle(uint address, float input)
  159.                     {
  160.                         byte[] numArray = new byte[4];
  161.                         BitConverter.GetBytes(input).CopyTo(numArray, 0);
  162.                         Array.Reverse(numArray, 0, 4);
  163.                         PS3.SetMemory(address, numArray);
  164.                     }
  165.                     private static byte[] ReverseBytes(byte[] inArray)
  166.                     {
  167.                         Array.Reverse(inArray);
  168.                         return inArray;
  169.                     }
  170.                 #endregion
  171.                 #region Clone Player
  172.                 public static void clonePlayer(Int32 client)
  173.                 {
  174.                     RPC.Call(0x180F48, new Object[] { client << 16 });
  175.                 }
  176.                 #endregion
  177.                 #region PlayerFX
  178.                 public static uint PlayFX(float[] Origin, int EffectIndex)
  179.                 {
  180.                     uint ent = (uint)RPC.Call(0x1C0B7C, Origin, 0x56); //G_Temp
  181.                     PS3.Extension.WriteInt32(ent + 0xA0, EffectIndex);
  182.                     PS3.Extension.WriteInt32(ent + 0xD8, 0);
  183.                     PS3.Extension.WriteFloat(ent + 0x40, 0f);
  184.                     PS3.Extension.WriteFloat(ent + 0x44, 0f);
  185.                     PS3.Extension.WriteFloat(ent + 0x3C, 270f);
  186.                     return ent;
  187.                 }
  188.                 #endregion
  189.                 #region Cbuf_AddText
  190.                 public static void CBuf_AddText(int client, string command)
  191.                 {
  192.                     Call(Addresses.CBuf_AddText, (uint) client,command);
  193.                 }
  194.                 #endregion
  195.                 #region SV_GameSendServerCommand
  196.                 public static void SV_GameSendServerCommand(int client, string command)
  197.                 {
  198.                     Call(Addresses.SV_GameSendServerCommand, (uint)client, 0,command);
  199.                 }
  200.                 #endregion
  201.                 #region iPrintln
  202.                 public static void iPrintln(int client, string Text)
  203.                 {
  204.                     SV_GameSendServerCommand(client, "f \"" + Text + "\"");
  205.                     Thread.Sleep(20);
  206.                 }
  207.                 #endregion
  208.                 #region iPrintlnBold
  209.                 public static void iPrintlnBold(int client, string Text)
  210.                 {
  211.                     SV_GameSendServerCommand(client, "c \"" + Text + "\"");
  212.                     Thread.Sleep(20);
  213.                 }
  214.                 #endregion
  215.                 #region Set_ClientDvar
  216.                 public static void Set_ClientDvar(int client, string Text)
  217.                 {
  218.                     SV_GameSendServerCommand(client, "q \"" + Text + "\"");
  219.                     Thread.Sleep(20);
  220.                 }
  221.                 #endregion
  222.                 #region Fov
  223.                 public static void Fov(int client, string Text)
  224.                 {
  225.                     SV_GameSendServerCommand(client, "q \"cg_fov \"" + Text + "\"");
  226.                     Thread.Sleep(20);
  227.                 }
  228.                 #endregion
  229.                 #region Vision
  230.                 public static void Vision(int client, string Text)
  231.                 {
  232.                     SV_GameSendServerCommand(client, "J \"" + Text + "\"");
  233.                     Thread.Sleep(20);
  234.                 }
  235.                 #endregion
  236.                 #region KickWithError
  237.                 public static void Kick(int client, string Text)
  238.                 {
  239.                     SV_GameSendServerCommand(client, "r \"" + Text + "\"");
  240.                     Thread.Sleep(20);
  241.                 }
  242.                 #endregion
  243.                 #region GiveWeapon
  244.                 public static void GiveWeapon(int client, int weapon,int akimbo)
  245.                 {
  246.                     Call(Addresses.G_GivePlayerWeapon, (uint)G_ClientFunction(client), (uint)weapon, 0);
  247.                     Call(Addresses.Add_Ammo, (uint)(Addresses.G_Entity + (client * 0x280)), (uint)weapon, 0, 9999, 1);
  248.                 }
  249.                 #endregion
  250.                 #region G_ClientFunction
  251.                 public static uint G_ClientFunction(int client)
  252.                 {
  253.                     return Addresses.G_Client + ((uint)client * 0x3980);
  254.                 }
  255.                 #endregion
  256.                 #region SetModel
  257.                 public static void SetModel(int client, string model)
  258.                 {
  259.                     Call(Addresses.G_SetModel, (uint)(Addresses.G_Entity + (client * 640)), model);
  260.                 }
  261.                 #endregion
  262.                 #region Cmd_ExecuteSingleCommand
  263.                 public static void Cmd_ExecuteSingleCommand(uint client, string command)
  264.                 {
  265.                     Call(Addresses.Cmd_ExecuteSingleCommand, (uint)client, command);
  266.                 }
  267.                 #endregion
  268.                 #region G_EntityFunction
  269.                 public static UInt32 G_EntityFunction(Int32 clientIndex, UInt32 Mod = 0)
  270.                 {
  271.                     return ((0xfca280 + Mod) + ((UInt32)(0x280 * clientIndex)));
  272.                 }
  273.                 #endregion
  274.                 #region GiveWeapon
  275.                 public static void G_GivePlayerWeapon(int client,int ammo, int weapon, int akimbo)
  276.                 {
  277.                     for (int i = 0; i < 18; i++)
  278.                     {
  279.                         long GClients = Addresses.G_Client + (i * 0x3980);
  280.                         Call(Addresses.G_GivePlayerWeapon, GClients, (uint)weapon, akimbo);
  281.                         Call(Addresses.Add_Ammo, (uint)(Addresses.G_Entity + (i * 640)), (uint)weapon, 0, ammo, 1);
  282.                         Call(Addresses.SV_GameSendServerCommand, i, 0, "a \"" + weapon + "\"");
  283.                     }
  284.                     long GClient = Addresses.G_Client + (client * 0x3980);
  285.                     Call(Addresses.G_GivePlayerWeapon, GClient, (uint)weapon, akimbo);
  286.                     Call(Addresses.Add_Ammo, (uint)(Addresses.G_Entity + (client * 0x280)), (uint)weapon, 0, ammo, 1);
  287.                     Call(Addresses.SV_GameSendServerCommand, client, 0, "a \"" + weapon + "\"");
  288.                 }
  289.                 #endregion
  290.             }
  291.                 #region Addresses
  292.                 public static class Addresses
  293.                 {
  294.                     public static uint
  295.                        G_Client = 0x110A280,
  296.                        g_client = 0x110A280,
  297.                        G_ClientIndex = 0x3980,
  298.                        EntityIndex = 0x280,
  299.                        G_Entity = 0xFCA280,
  300.                        MapBrushModel = 0x7F80,
  301.                        BG_GetPerkIndexForName = 0x210B0,
  302.                        BG_GetNumWeapons = 0x3CFBC,
  303.                        BG_FindWeaponIndexForName = 0x3CFD0,
  304.                        BG_GetWeaponIndexForName = 0x3D434,
  305.                        BG_GetViewModelWeaponIndex = 0x3D7D8,
  306.                        Cmd_ExecuteSingleCommand = 0x1DB240,
  307.                        BG_WeaponFireRecoil = 0x3FBD0,
  308.                        CG_FireWeapon = 0xBE498,
  309.                        Key_IsDown = 0xD1CD8,
  310.                        Key_StringToKeynum = 0xD1D18,
  311.                        Key_IsValidGamePadChar = 0xD1E64,
  312.                        Key_KeyNumToString = 0xD1EA4,
  313.                        Key_Unbind_f = 0xD2368,
  314.                        Key_Bind_f = 0xD247C,
  315.                        BG_TakePlayerWeapon = 0x1C409C,
  316.                        G_GivePlayerWeapon = 0x1C3034,
  317.                        SV_GameSendServerCommand = 0x228FA8,
  318.                        SV_GetConfigString = 0x22A4A8,
  319.                        SV_SetConfigString = 0x22A208,
  320.                        va = 0x299490,
  321.                        G_SetModel = 0x1BEF5C,
  322.                        G_LocalizedStringIndex = 0x1BE6CC,
  323.                        G_MaterialIndex = 0x1BE744,
  324.                        G_ModelIndex = 0x1BE7A8,
  325.                        G_ModelName = 0x1BE8A0,
  326.                        Add_Ammo = 0x18A29C,
  327.                        PlayerCmd_SetPerk = 0x17EBE8,
  328.                        G_Damage = 0x183E18,
  329.                        G_RadiusDamage = 0x185600,
  330.                        G_GetClientScore = 0x18EA74,
  331.                        G_GetClientDeaths = 0x18EA98,
  332.                        Cmd_AddCommandInternal = 0x1DC4FC,
  333.                        CBuf_AddText /*(int localClientNum, const char *text)*/ = 0x001DB240,
  334.                        SV_SendDisconnect /*(client_s *client, int state, const char *reason)*/ = 0x0022472C,
  335.                        SV_SendClientGameState /*(client_s *client)*/ = 0x002284F8,
  336.                        SV_KickClient /*(client_s *cl, char *playerName, int maxPlayerNameLen)*/ = 0x00223BD0,
  337.                        G_CallSpawnEntity /*(gentity_s *ent)*/ = 0x001BA730,
  338.                        Player_Die /*(unsigned int *self, unsigned int *inflictor, unsigned int *attacker, int damage, int meansOfDeath, int iWeapon, const float *vDir, unsigned int hitLoc, int psTimeOffset)*/  = 0x00183748,
  339.                        SV_DropClient /*(client_s *drop, const char *reason, bool tellThem)*/ = 0x002249FC,
  340.                        SV_SendServerCommand /*(client_s *,svscmd_type,char const *,...)*/ = 0x0022CEBC,
  341.                        Scr_Notify /*(gentity_s *ent, unsigned __int16 stringValue, unsigned int paramcount)*/ = 0x001BB1B0,
  342.                        Sv_SetGametype /*(void)*/ = 0x00229C1C,
  343.                        Sv_Maprestart /*(int fast_restart)*/ = 0x00223774,
  344.                        sv_maprestart_f = 0x00223B20,
  345.                        sv_spawnsever /*(const char *server)*/ = 0x0022ADF8,
  346.                        sv_map_f = 0x002235A0,
  347.                        sv_matchend /*(void)*/ = 0x0022F7A8,
  348.                        R_AddCmdDrawText /*(const char *text, int maxChars, void *font, float x, float y, float xScale, float yScale, float rotation, const float *color, int style)*/ = 0x00393640,
  349.                        R_RegisterFont /*(char* asset, int imagetrack)*/ /*(const char *name, int imageTrack)*/ = 0x003808B8,
  350.                        R_AddCmdDrawStretchPic /*(float x, float y, float w, float h, float xScale, float yScale, float xay, float yay, const float *color, int material)*/ = 0x00392D78,
  351.                        CL_DrawTextHook /*(const char *text, int maxChars, void *font, float x, float y, float xScale, float yScale, const float *color, int style)*/ = 0x000D93A8,
  352.                        R_AddCmdDrawTextWithEffects /*(char const *,int,Font_s *,float,float,float,float,float,float const * const,int,float const * const,Material *,Material *,int,int,int,int)*/ = 0x003937C0,
  353.                        CG_BoldGameMessage /*(int LocalClientNum, const char *Message)*/ = 0x0007A5C8,
  354.                        UI_FillRectPhysical /*(float x, float y, float width, float height, const float *color)*/ = 0x0023A810,
  355.                        UI_DrawLoadBar /*(ScreenPlacement *scrPlace, float x, float y, float w, float h, int horzAlign, int vertAlign, const float *color, Material *material)*/ = 0x0023A730,
  356.                        Scr_MakeGameMessage /*(int iClientNum, const char *pszCmd)*/ = 0x001B07F0,
  357.                        Scr_ConstructMessageString /*(int firstParmIndex, int lastParmIndex, const char *errorContext, char *string, unsigned int stringLimit)*/ = 0x001B04F4,
  358.                        R_NormalizedTextScale /*(Font_s *font, float scale)*/ = 0x003808F0,
  359.                        TeleportPlayer /*(gentity_s *player, float *origin, float *angles)*/ = 0x00191B00,
  360.                        CL_DrawText /*(ScreenPlacement *scrPlace, const char *text, int maxChars, Font_s *font, float x, float y, int horzAlign, int vertAlign, float xScale, float yScale, const float *color, int style)*/ = 0x000D9490,
  361.                        CL_DrawTextRotate /*(ScreenPlacement *scrPlace, const char *text, int maxChars, Font_s *font, float x, float y, float rotation, int horzAlign, int vertAlign, float xScale, float yScale, const float *color, int style)*/ = 0x000D9554,
  362.                        SV_GameDropClient /*(int clientNum, const char *reason)*/ = 0x00229020,
  363.                        Dvar_GetBool /*(const char *dvarName)*/ = 0x00291060,
  364.                        Dvar_GetInt /*(const char *dvarName)*/ = 0x002910DC,
  365.                        Dvar_GetFloat /*(const char *dvarName)*/ = 0x00291148,
  366.                        Dvar_RegisterBool /*(const char *dvarName, bool value, unsigned __int16 flags, const char *description)*/ = 0x002933F0,
  367.                        Dvar_IsValidName /*(const char *dvarName)*/ = 0x0029019C,
  368.                        Material_RegisterHandle /*(const char *name, int imageTrack)*/ = 0x0038B044,
  369.                        CL_RegisterFont /*(const char *fontName, int imageTrack)*/ = 0x000D9734,
  370.                        SetClientViewAngle /*(gentity_s *ent, const float *angle)*/ = 0x001767E0,
  371.                        R_RegisterDvars /*(void)*/ = 0x0037E420,
  372.                        PlayerCmd_SetClientDvar /*(scr_entref_t entref)*/ = 0x0017CB4C,
  373.                        Jump_RegisterDvars /*(void)*/ = 0x00018E20,
  374.                        AimTarget_RegisterDvars = 0x00012098,
  375.                        G_FreeEntity /*(gentity_s *ed)*/ = 0x001C0840,
  376.                        G_EntUnlink /*(gentity_s *ent)*/ = 0x001C4A5C,
  377.                        SV_DObjGetTree /*(gentity_s *ent)*/ = 0x00229A68,
  378.                        BG_GetEntityTypeName /*(const int eType)*/ = 0x0001D1F0,
  379.                        CL_GetClientState /*(int localClientNum, uiClientState_s *state)*/ = 0x000E26A8,
  380.                         CL_GetConfigString /*(int localClientNum, int configStringIndex)*/ = 0x000C5E7C,
  381.                        Info_ValueForKey /*(const char *s, const char *key)*/ = 0x00299604,
  382.                        Scr_GetInt /*(unsigned int index)*/ = 0x002201C4,
  383.                        ClientSpawn /*(gentity_s *ent, const float *spawn_origin, const float *spawn_angles)*/ = 0x00177468,
  384.                        Sv_ClientCommand /*(client_s *cl, msg_t *msg)*/ = 0x00228178,
  385.                        Sv_ExecuteClientMessage /*(client_s *cl, msg_t *msg)*/ = 0x00228B50,
  386.                        Sv_ExecuteClientCommand /*(client_s *cl, const char *s, int clientOK)*/ = 0x00182DEC,
  387.                        ClientCommand /*(int clientNum)*/ = 0x00182440,
  388.                        CalculateRanks /*(void)*/ = 0x0019031C,
  389.                        ClientScr_SetScore /*(gclient_s *pSelf, client_fields_s *pField)*/ = 0x00176150,
  390.                        ClientScr_SetMaxHealth /*(gclient_s *pSelf, client_fields_s *pField)*/ = 0x00176094,
  391.                        Sv_ReceiveStats /*(netadr_t from, msg_t *msg)*/ = 0x002244E0,
  392.                        ClientConnect /*(int clientNum, unsigned __int16 scriptPersId)*/ = 0x001771A0,
  393.                        Sv_DirectConnect /*(netadr_t from)*/ = 0x00255BB4,
  394.                        Sv_SetConfigstring /*(int index, const char *val)*/ = 0x0022A208,
  395.                        Sv_AddServerCommand /*(client_s *client, svscmd_type type, const char *cmd)*/ = 0x0022CBA0,
  396.                        IntermissionClientEndFrame /*(gentity_s *ent)*/ = 0x001745F8,
  397.                        memset = 0x0049B928,
  398.                        str_pointer = 0x523b30,
  399.                        g_gametype = 0x8360d5;
  400.                 }
  401.                 #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement