Esempio n. 1
0
        public void WriteMemory(IntPtr memoryAddress, byte[] buffer, out int bytesWritten)
        {
            IntPtr pBytesWritten = IntPtr.Zero;

            ProcessMemoryReaderApi.WriteProcessMemory(handle, memoryAddress, buffer, (uint)buffer.Length, out pBytesWritten);
            bytesWritten = pBytesWritten.ToInt32();
        }
Esempio n. 2
0
 public void OpenProcess()
 {
     ProcessMemoryReaderApi.ProcessAccessType access = ProcessMemoryReaderApi.ProcessAccessType.PROCESS_QUERY_INFORMATION |
                                                       ProcessMemoryReaderApi.ProcessAccessType.PROCESS_VM_READ |
                                                       ProcessMemoryReaderApi.ProcessAccessType.PROCESS_VM_WRITE |
                                                       ProcessMemoryReaderApi.ProcessAccessType.PROCESS_VM_OPERATION;
     handle = ProcessMemoryReaderApi.OpenProcess((uint)access, 1, (uint)ReadProcess.Id);
 }
Esempio n. 3
0
        public byte[] ReadMemory(IntPtr memoryAddress, uint bytesToRead, out int bytesRead)
        {
            byte[] buffer     = new byte[bytesToRead];
            IntPtr pBytesRead = IntPtr.Zero;

            ProcessMemoryReaderApi.ReadProcessMemory(handle, memoryAddress, buffer, bytesToRead, out pBytesRead);
            bytesRead = pBytesRead.ToInt32();
            return(buffer);
        }
Esempio n. 4
0
        public void CloseHandle()
        {
            int returnValue = ProcessMemoryReaderApi.CloseHandle(handle);

            if (returnValue != 0)
            {
                throw new Exception("Close handling failed.");
            }
        }