Advertisement
Guest User

XRPC++

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