示例#1
0
        private void WriteValue(IntPtr handle, IntPtr pointer, object value, byte[] buffer)
        {
            int bytesWritten = 0;

            if (Win32Memory.WriteProcessMemory(handle, pointer, buffer, IntPtr.Size, ref bytesWritten))
            {
                logger.Debug($"Wrote value {value} to address {pointer}");
            }
        }
示例#2
0
        internal IntPtr OpenProcess(int processId)
        {
            IntPtr processHandle = Win32Memory.OpenProcess(PROCESS_VM_READ
                                                           | PROCESS_VM_WRITE
                                                           | PROCESS_VM_OPERATION,
                                                           false,
                                                           processId);

            logger.Info($"Opened handle #{processHandle} for process #{processId}");

            return(processHandle);
        }
示例#3
0
        internal long ReadInt64(IntPtr handle, IntPtr pointer)
        {
            byte[] buffer    = new byte[8];
            int    bytesRead = 0;

            Win32Memory.ReadProcessMemory(handle, pointer, buffer, 8, ref bytesRead);

            var value = BitConverter.ToInt64(buffer, 0);

            logger.Debug($"Returning long value {value}");

            return(value);
        }
示例#4
0
        internal IntPtr ReadPointer(IntPtr handle, IntPtr pointer)
        {
            byte[] buffer    = new byte[IntPtr.Size];
            int    bytesRead = 0;

            Win32Memory.ReadProcessMemory(handle, pointer, buffer, IntPtr.Size, ref bytesRead);

            var value = BitConverter.ToInt64(buffer, 0);

            logger.Debug($"Returning pointer 0x{value:X}");

            return(new IntPtr(value));
        }