Пример #1
0
        public void CloseProcess()
        {
            int returnValue = ProcessMemoryReaderApi.CloseHandle(handle);

            if (returnValue != 0)
            {
                throw new Exception("Closing handle failed!");
            }
        }
Пример #2
0
        public byte[] ReadMemory(IntPtr memoryAddress, uint bytesToRead, out int bytesRead)
        {
            byte[] buffer           = new byte[bytesToRead];
            IntPtr pointerBytesRead = IntPtr.Zero;

            ProcessMemoryReaderApi.ReadProcessMemory(handle, memoryAddress, buffer, bytesToRead, out pointerBytesRead);
            bytesRead = pointerBytesRead.ToInt32();
            return(buffer);
        }
Пример #3
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);
        }
Пример #4
0
        public void WriteMemory(IntPtr memoryAddress, byte[] bytesToWrite, out int bytesWritten, uint bytesLength = 0)
        {
            if (bytesLength == 0)
            {
                bytesLength = (uint)bytesToWrite.Length;
            }
            IntPtr pointerBytesWritten = IntPtr.Zero;

            ProcessMemoryReaderApi.WriteProcessMemory(handle, memoryAddress, bytesToWrite, bytesLength, out pointerBytesWritten);
            bytesWritten = pointerBytesWritten.ToInt32();
        }