Advertisement
Liamm

xrpc++

Dec 3rd, 2014
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.90 KB | None | 0 0
  1. XRPC++:
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using XRPCLib;
  8.  
  9. namespace XRPCPlusPlus
  10. {
  11.     public static class XRPCExtensions
  12.     {
  13.         private static byte[] myBuff = new byte[0x20];
  14.         private static uint outInt;
  15.         private static uint uTemp32;
  16.         private static UInt16 uTemp16;
  17.         private static UInt64 uTemp64;
  18.         private static Int16 Temp16;
  19.         private static Int32 Temp32;
  20.         private static Int64 Temp64;
  21.  
  22.         public static sbyte ReadSByte(this XRPC xpc, uint Offset)
  23.         {
  24.             xpc.xbCon.DebugTarget.GetMemory(Offset, 1, myBuff, out outInt);
  25.             return (sbyte)myBuff[0];
  26.         }
  27.  
  28.         public static bool ReadBool(this XRPC xpc, uint Offset)
  29.         {
  30.             xpc.xbCon.DebugTarget.GetMemory(Offset, 1, myBuff, out outInt);
  31.             return myBuff[0] != 0;
  32.         }
  33.  
  34.         public static short ReadInt16(this XRPC xpc, uint Offset)
  35.         {
  36.             xpc.xbCon.DebugTarget.GetMemory(Offset, 2, myBuff, out outInt);
  37.             Array.Reverse(myBuff,0,2);
  38.             return BitConverter.ToInt16(myBuff, 0);
  39.         }
  40.  
  41.         public static int ReadInt32(this XRPC xpc, uint Offset)
  42.         {
  43.             xpc.xbCon.DebugTarget.GetMemory(Offset, 4, myBuff, out outInt);
  44.             Array.Reverse(myBuff, 0, 4);
  45.             return BitConverter.ToInt32(myBuff, 0);
  46.         }
  47.  
  48.         public static long ReadInt64(this XRPC xpc, uint Offset)
  49.         {
  50.             xpc.xbCon.DebugTarget.GetMemory(Offset, 8, myBuff, out outInt);
  51.             Array.Reverse(myBuff, 0, 8);
  52.             return BitConverter.ToInt64(myBuff, 0);
  53.         }
  54.  
  55.         public static byte ReadByte(this XRPC xpc, uint Offset)
  56.         {
  57.             xpc.xbCon.DebugTarget.GetMemory(Offset, 1, myBuff, out outInt);
  58.             return myBuff[0];
  59.         }
  60.  
  61.         public static ushort ReadUInt16(this XRPC xpc, uint Offset)
  62.         {
  63.             xpc.xbCon.DebugTarget.GetMemory(Offset, 2, myBuff, out outInt);
  64.             Array.Reverse(myBuff, 0, 2);
  65.             return BitConverter.ToUInt16(myBuff, 0);
  66.         }
  67.  
  68.         public static uint ReadUInt32(this XRPC xpc, uint Offset)
  69.         {
  70.             xpc.xbCon.DebugTarget.GetMemory(Offset, 4, myBuff, out outInt);
  71.             Array.Reverse(myBuff, 0, 4);
  72.             return BitConverter.ToUInt32(myBuff, 0);
  73.         }
  74.  
  75.         public static ulong ReadUInt64(this XRPC xpc, uint Offset)
  76.         {
  77.             xpc.xbCon.DebugTarget.GetMemory(Offset, 8, myBuff, out outInt);
  78.             Array.Reverse(myBuff, 0, 8);
  79.             return BitConverter.ToUInt64(myBuff, 0);
  80.         }
  81.  
  82.         public static float ReadFloat(this XRPC xpc, uint Offset)
  83.         {
  84.             xpc.xbCon.DebugTarget.GetMemory(Offset, 4, myBuff, out outInt);
  85.             Array.Reverse(myBuff, 0, 4);
  86.             return BitConverter.ToSingle(myBuff, 0);
  87.         }
  88.  
  89.         public static string ReadString(this XRPC xpc, uint Offset, byte[] readBuffer)
  90.         {
  91.             xpc.xbCon.DebugTarget.GetMemory(Offset, (uint)readBuffer.Length, readBuffer, out outInt);
  92.             return new string(System.Text.Encoding.ASCII.GetChars(readBuffer)).Split('\0')[0];
  93.         }
  94.  
  95.         public static string ReadString(this XRPC xpc, uint Offset)
  96.         {
  97.             return ReadString(xpc, Offset, myBuff);
  98.         }
  99.  
  100.         public static void WriteSByte(this XRPC xpc, uint Offset, sbyte input)
  101.         {
  102.             myBuff[0] = (byte)input;
  103.             xpc.xbCon.DebugTarget.SetMemory(Offset, 1, myBuff, out outInt);
  104.         }
  105.  
  106.         public static void WriteBool(this XRPC xpc, uint Offset, bool input)
  107.         {
  108.             myBuff[0] = input ? (byte)1 : (byte)0;
  109.             xpc.xbCon.DebugTarget.SetMemory(Offset, 1, myBuff, out outInt);
  110.         }
  111.  
  112.         public static void WriteInt16(this XRPC xpc, uint Offset, short input)
  113.         {
  114.             BitConverter.GetBytes(input).CopyTo(myBuff, 0);
  115.             Array.Reverse(myBuff, 0, 2);
  116.             xpc.xbCon.DebugTarget.SetMemory(Offset, 2, myBuff, out outInt);
  117.         }
  118.  
  119.         public static void WriteInt32(this XRPC xpc, uint Offset, int input)
  120.         {
  121.             BitConverter.GetBytes(input).CopyTo(myBuff, 0);
  122.             Array.Reverse(myBuff, 0, 4);
  123.             xpc.xbCon.DebugTarget.SetMemory(Offset, 4, myBuff, out outInt);
  124.         }
  125.  
  126.         public static void WriteInt64(this XRPC xpc, uint Offset, long input)
  127.         {
  128.             BitConverter.GetBytes(input).CopyTo(myBuff, 0);
  129.             Array.Reverse(myBuff, 0, 8);
  130.             xpc.xbCon.DebugTarget.SetMemory(Offset, 8, myBuff, out outInt);
  131.         }
  132.  
  133.         public static void WriteByte(this XRPC xpc, uint Offset, byte input)
  134.         {
  135.             myBuff[0] = input;
  136.             xpc.xbCon.DebugTarget.SetMemory(Offset, 1, myBuff, out outInt);
  137.         }
  138.  
  139.         public static void WriteUInt16(this XRPC xpc, uint Offset, ushort input)
  140.         {
  141.             BitConverter.GetBytes(input).CopyTo(myBuff, 0);
  142.             Array.Reverse(myBuff, 0, 2);
  143.             xpc.xbCon.DebugTarget.SetMemory(Offset, 2, myBuff, out outInt);
  144.         }
  145.  
  146.         public static void WriteUInt32(this XRPC xpc, uint Offset, uint input)
  147.         {
  148.             BitConverter.GetBytes(input).CopyTo(myBuff, 0);
  149.             Array.Reverse(myBuff, 0, 4);
  150.             xpc.xbCon.DebugTarget.SetMemory(Offset, 4, myBuff, out outInt);
  151.         }
  152.  
  153.         public static void WriteUInt64(this XRPC xpc, uint Offset, ulong input)
  154.         {
  155.             BitConverter.GetBytes(input).CopyTo(myBuff, 0);
  156.             Array.Reverse(myBuff, 0, 8);
  157.             xpc.xbCon.DebugTarget.SetMemory(Offset, 8, myBuff, out outInt);
  158.         }
  159.  
  160.         public static void WriteFloat(this XRPC xpc, uint Offset, float input)
  161.         {
  162.             BitConverter.GetBytes(input).CopyTo(myBuff, 0);
  163.             Array.Reverse(myBuff, 0, 4);
  164.             xpc.xbCon.DebugTarget.SetMemory(Offset, 4, myBuff, out outInt);
  165.         }
  166.  
  167.         public static void XOR_Uint16(this XRPC xpc, uint Offset, ushort input)
  168.         {
  169.             uTemp16 = xpc.ReadUInt16(Offset);
  170.             uTemp16 ^= input;
  171.             xpc.WriteUInt16(Offset, input);
  172.         }
  173.  
  174.         public static void XOR_UInt32(this XRPC xpc, uint Offset, uint input)
  175.         {
  176.             uTemp32 = xpc.ReadUInt32(Offset);
  177.             uTemp32 ^= input;
  178.             xpc.WriteUInt32(Offset, uTemp32);
  179.         }
  180.  
  181.         public static void XOR_UInt64(this XRPC xpc, uint Offset, ulong input)
  182.         {
  183.             uTemp64 = xpc.ReadUInt64(Offset);
  184.             uTemp64 ^= input;
  185.             xpc.WriteUInt64(Offset, uTemp64);
  186.         }
  187.  
  188.         public static void XOR_Int16(this XRPC xpc, uint Offset, Int16 input)
  189.         {
  190.             Temp16 = xpc.ReadInt16(Offset);
  191.             Temp16 ^= input;
  192.             xpc.WriteInt16(Offset, Temp16);
  193.         }
  194.  
  195.         public static void XOR_Int32(this XRPC xpc, uint Offset, int input)
  196.         {
  197.             Temp32 = xpc.ReadInt32(Offset);
  198.             Temp32 ^= input;
  199.             xpc.WriteInt32(Offset, Temp32);
  200.         }
  201.  
  202.         public static void XOR_Int64(this XRPC xpc, uint Offset, long input)
  203.         {
  204.             Temp64 = xpc.ReadInt64(Offset);
  205.             Temp64 ^= input;
  206.             xpc.WriteInt64(Offset, Temp64);
  207.         }
  208.  
  209.         public static void AND_UInt16(this XRPC xpc, uint Offset, ushort input)
  210.         {
  211.             uTemp16 = xpc.ReadUInt16(Offset);
  212.             uTemp16 &= input;
  213.             xpc.WriteUInt16(Offset, uTemp16);
  214.         }
  215.  
  216.         public static void AND_UInt32(this XRPC xpc, uint Offset, uint input)
  217.         {
  218.             uTemp32 = xpc.ReadUInt32(Offset);
  219.             uTemp32 &= input;
  220.             xpc.WriteUInt32(Offset, uTemp32);
  221.         }
  222.  
  223.         public static void AND_UInt64(this XRPC xpc, uint Offset, ulong input)
  224.         {
  225.             uTemp64 = xpc.ReadUInt64(Offset);
  226.             uTemp64 &= input;
  227.             xpc.WriteUInt64(Offset, uTemp64);
  228.         }
  229.  
  230.         public static void AND_Int16(this XRPC xpc, uint Offset, short input)
  231.         {
  232.             Temp16 = xpc.ReadInt16(Offset);
  233.             Temp16 &= input;
  234.             xpc.WriteInt16(Offset, Temp16);
  235.         }
  236.  
  237.         public static void AND_Int32(this XRPC xpc, uint Offset, int input)
  238.         {
  239.             Temp32 = xpc.ReadInt32(Offset);
  240.             Temp32 &= input;
  241.             xpc.WriteInt32(Offset, Temp32);
  242.         }
  243.  
  244.         public static void AND_Int64(this XRPC xpc, uint Offset, long input)
  245.         {
  246.             Temp64 = xpc.ReadInt64(Offset);
  247.             Temp64 &= input;
  248.             xpc.WriteInt64(Offset, Temp64);
  249.         }
  250.  
  251.         public static void OR_UInt16(this XRPC xpc, uint Offset, ushort input)
  252.         {
  253.             uTemp16 = xpc.ReadUInt16(Offset);
  254.             uTemp16 |= input;
  255.             xpc.WriteUInt16(Offset, uTemp16);
  256.         }
  257.  
  258.         public static void OR_UInt32(this XRPC xpc, uint Offset, uint input)
  259.         {
  260.             uTemp32 = xpc.ReadUInt32(Offset);
  261.             uTemp32 |= input;
  262.             xpc.WriteUInt32(Offset, uTemp32);
  263.         }
  264.  
  265.         public static void OR_UInt64(this XRPC xpc, uint Offset, ulong input)
  266.         {
  267.             uTemp64 = xpc.ReadUInt64(Offset);
  268.             uTemp64 |= input;
  269.             xpc.WriteUInt64(Offset, uTemp64);
  270.         }
  271.  
  272.         public static void OR_Int16(this XRPC xpc, uint Offset, short input)
  273.         {
  274.             Temp16 = xpc.ReadInt16(Offset);
  275.             Temp16 |= input;
  276.             xpc.WriteInt16(Offset, Temp16);
  277.         }
  278.  
  279.         public static void OR_Int32(this XRPC xpc, uint Offset, int input)
  280.         {
  281.             Temp32 = xpc.ReadInt32(Offset);
  282.             Temp32 |= input;
  283.             xpc.WriteInt32(Offset, Temp32);
  284.         }
  285.  
  286.         public static void OR_Int64(this XRPC xpc, uint Offset, long input)
  287.         {
  288.             Temp64 = xpc.ReadInt64(Offset);
  289.             Temp64 |= input;
  290.             xpc.WriteInt64(Offset, Temp64);
  291.         }
  292.     }
  293. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement