Example #1
0
        public static string RUnicodeStr(Memloc addr, int maxLength)
        {
            System.Text.StringBuilder Str = new System.Text.StringBuilder(maxLength);
            int loc = 0;

            var nextChr = '?';


            if (maxLength != 0)
            {
                byte[] bytes = new byte[3];

                while ((maxLength < 0 || loc < maxLength))
                {
                    Kernel.ReadProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), IntPtr.Add(addr, loc * 2), bytes, 2, IntPtr.Zero);
                    nextChr = System.Text.Encoding.Unicode.GetChars(bytes)[0];

                    if (nextChr == (char)0)
                    {
                        break; // TODO: might not be correct. Was : Exit While
                    }
                    else
                    {
                        Str.Append(nextChr);
                    }

                    loc += 1;
                }
            }

            return(Str.ToString());
        }
Example #2
0
 public static void WUnicodeStr(Memloc addr, string str)
 {
     Kernel.WriteProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), addr, System.Text.Encoding.Unicode.GetBytes(str).Concat(new byte[] {
         0,
         0
     }).ToArray(), str.Length * 2 + 2, IntPtr.Zero);
 }
Example #3
0
 public static void WIntPtr(Memloc addr, IntPtr val)
 {
     if (IntPtr.Size == 4)
     {
         Kernel.WriteProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), addr, BitConverter.GetBytes((Int32)val), IntPtr.Size, IntPtr.Zero);
     }
     else
     {
         Kernel.WriteProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), addr, BitConverter.GetBytes((Int64)val), IntPtr.Size, IntPtr.Zero);
     }
 }
Example #4
0
        //public static T Call<T>(IntPtr address, params dynamic[] args)
        //{
        //    return Call<T>(((IntPtr)address, (IntPtr)address + 0x1590, (IntPtr)address), args);
        //}

        //public static T CallReg<T>(IntPtr address, dynamic[] args,
        //    dynamic eax = null,
        //    dynamic ecx = null,
        //    dynamic edx = null,
        //    dynamic ebx = null,
        //    dynamic esp = null,
        //    dynamic esi = null,
        //    dynamic edi = null)
        //{
        //    return CallReg<T>(((IntPtr)address, (IntPtr)address + 0x1590, (IntPtr)address), args, eax, ecx, edx, ebx, esp, esi, edi);
        //}

        public static T Call <T>(Memloc address, params dynamic[] args)
        {
            if (IntPtr.Size == 4)
            {
                return(ASM.CallIngameFunc <T>(address, args));
            }
            else
            {
                return(ASM.CallIngameFunc64 <T>(address, args));
            }
        }
Example #5
0
 public static T CallReg <T>(Memloc address, dynamic[] args,
                             dynamic eax = null,
                             dynamic ecx = null,
                             dynamic edx = null,
                             dynamic ebx = null,
                             dynamic esp = null,
                             dynamic esi = null,
                             dynamic edi = null)
 {
     return(ASM.CallIngameFuncReg <T>(address, args, eax, ecx, edx, ebx, esp, esi, edi));
 }
Example #6
0
 public static IntPtr RIntPtr(Memloc addr)
 {
     Kernel.ReadProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), addr, ByteBuffer, IntPtr.Size, IntPtr.Zero);
     if (IntPtr.Size == 4)
     {
         return(new IntPtr(BitConverter.ToInt32(ByteBuffer, 0)));
     }
     else
     {
         return(new IntPtr(BitConverter.ToInt64(ByteBuffer, 0)));
     }
 }
Example #7
0
        public static bool RBit(Memloc baseAddr, int bitOffset)
        {
            var state = GetCurrentState();

            state.RBit_actualAddress = IntPtr.Add(baseAddr, bitOffset / 8);
            state.RBit_mask          = 0b10000000 >> (bitOffset % 8);

            if (Kernel.ReadProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), state.RBit_actualAddress, ByteBuffer, 1, IntPtr.Zero))
            {
                byte b = RByte(state.RBit_actualAddress);
                return((b & state.RBit_mask) == state.RBit_mask);
            }
            else
            {
                return(false);
            }
        }
Example #8
0
        public static void WBit(Memloc baseAddr, int bitOffset, bool val)
        {
            var state = GetCurrentState();

            state.WBit_actualAddress = (IntPtr.Add(baseAddr, bitOffset / 8));
            state.WBit_mask          = 0b10000000 >> (bitOffset % 8);

            if (Kernel.ReadProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), state.WBit_actualAddress, ByteBuffer, 1, IntPtr.Zero))
            {
                byte b = RByte(state.WBit_actualAddress);
                // ((b & mask) == mask) is the boolean value of the flag
                if (((b & state.WBit_mask) == state.WBit_mask) != val)
                {
                    if (val)
                    {
                        WByte(state.WBit_actualAddress, (byte)(b | state.WBit_mask));
                    }
                    else
                    {
                        WByte(state.WBit_actualAddress, (byte)(b & (~state.WBit_mask)));
                    }
                }
            }
        }
Example #9
0
 public static void WByte(Memloc addr, byte val)
 {
     Kernel.WriteProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), addr, new byte[] { val }, 1, IntPtr.Zero);
 }
Example #10
0
 public static void WBytes(Memloc addr, byte[] val)
 {
     Kernel.WriteProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), addr, val, val.Length, IntPtr.Zero);
 }
Example #11
0
 public static ushort RUInt16(Memloc addr)
 {
     Kernel.ReadProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), addr, ByteBuffer, 2, IntPtr.Zero);
     return(BitConverter.ToUInt16(ByteBuffer, 0));
 }
Example #12
0
 public static bool RBool(Memloc addr)
 {
     Kernel.ReadProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), addr, ByteBuffer, 1, IntPtr.Zero);
     return(ByteBuffer[0] != 0);
 }
Example #13
0
 public static byte[] RBytes(Memloc addr, int size)
 {
     byte[] _rtnBytes = new byte[size];
     Kernel.ReadProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), addr, _rtnBytes, size, IntPtr.Zero);
     return(_rtnBytes);
 }
Example #14
0
 public static double RDouble(Memloc addr)
 {
     Kernel.ReadProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), addr, ByteBuffer, 8, IntPtr.Zero);
     return(BitConverter.ToDouble(ByteBuffer, 0));
 }
Example #15
0
 public static float RFloat(Memloc addr)
 {
     Kernel.ReadProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), addr, ByteBuffer, 4, IntPtr.Zero);
     return(BitConverter.ToSingle(ByteBuffer, 0));
 }
Example #16
0
 public static void WFloat(Memloc addr, float val)
 {
     Kernel.WriteProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), addr, BitConverter.GetBytes(val), 4, IntPtr.Zero);
 }
Example #17
0
 public static sbyte RInt8(Memloc addr)
 {
     Kernel.ReadProcessMemory_SAFE(DarkSouls3Handle.GetHandle(), addr, ByteBuffer, 1, IntPtr.Zero);
     return((sbyte)ByteBuffer[0]);
 }