public byte[] ReadBytes(int address, uint bytesToRead, out int bytesRead) { byte[] buffer = new byte[bytesToRead]; IntPtr pBytesRead; ProcessMemoryReaderApi.ReadProcessMemory(handle, new IntPtr(address), buffer, bytesToRead, out pBytesRead); try { bytesRead = pBytesRead.ToInt32(); } catch (Exception) { bytesRead = (int)bytesToRead; } return(buffer); }
public bool Close() { return(ProcessMemoryReaderApi.CloseHandle(handle) == 0); }
public void Open() { ProcessMemoryReaderApi.ProcessAccessType access = ProcessMemoryReaderApi.ProcessAccessType.PROCESS_QUERY_INFORMATION | ProcessMemoryReaderApi.ProcessAccessType.PROCESS_VM_READ | ProcessMemoryReaderApi.ProcessAccessType.PROCESS_VM_OPERATION; handle = ProcessMemoryReaderApi.OpenProcess((uint)access, 0, (uint)Process.Id); ModuleBaseAddr = Process.Modules[0].BaseAddress.ToInt32(); }