public byte[] ReadAMem(int MemoryAddress, uint bytesToRead, out int bytesReaded) { byte[] buffer = new byte[bytesToRead]; IntPtr ptrBytesReaded; ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, (IntPtr)MemoryAddress, buffer, bytesToRead, out ptrBytesReaded); bytesReaded = ptrBytesReaded.ToInt32(); return(buffer); }
public byte[] ReadtoMem(int MemoryAddress, uint bytesToRead, out int bytesReaded) { if (bytesToRead > buffersize) { readeDestBuffer = new byte[bytesToRead]; buffersize = bytesToRead; } IntPtr ptrBytesReaded; ProcessMemoryReaderApi.ReadProcessMemory(m_hProcess, (IntPtr)MemoryAddress, readeDestBuffer, bytesToRead, out ptrBytesReaded); bytesReaded = ptrBytesReaded.ToInt32(); return(readeDestBuffer); }
public int ReadMem(int MemoryAddress, uint bytesToRead, out byte[] buffer) { IntPtr procHandle = ProcessMemoryReaderApi.OpenProcess(ProcessMemoryReaderApi.PROCESS_VM_READ | ProcessMemoryReaderApi.PROCESS_VM_WRITE | ProcessMemoryReaderApi.PROCESS_VM_OPERATION, 1, (uint)m_processID); if (procHandle == IntPtr.Zero) { buffer = new byte[0]; return(0); } buffer = new byte[bytesToRead]; IntPtr ptrBytesReaded; ProcessMemoryReaderApi.ReadProcessMemory(procHandle, (IntPtr)MemoryAddress, buffer, bytesToRead, out ptrBytesReaded); ProcessMemoryReaderApi.CloseHandle(procHandle); return(ptrBytesReaded.ToInt32()); }
//We use this to public int ReadMultiLevelPointer(int MemoryAddress, uint bytesToRead, Int32[] offsetList) { IntPtr procHandle = ProcessMemoryReaderApi.OpenProcess(ProcessMemoryReaderApi.PROCESS_VM_READ | ProcessMemoryReaderApi.PROCESS_VM_WRITE | ProcessMemoryReaderApi.PROCESS_VM_OPERATION, 1, (uint)m_processID); IntPtr pointer = (IntPtr)0x0; //IF THE PROCESS isnt available we return nothing if (procHandle == IntPtr.Zero) { return(0); } byte[] btBuffer = new byte[bytesToRead]; IntPtr lpOutStorage = IntPtr.Zero; int pointerAddy = MemoryAddress; //int pointerTemp = 0; for (int i = 0; i < (offsetList.Length); i++) { if (i == 0) { ProcessMemoryReaderApi.ReadProcessMemory( procHandle, (IntPtr)(pointerAddy), btBuffer, (uint)btBuffer.Length, out lpOutStorage); } pointerAddy = (BitConverter.ToInt32(btBuffer, 0) + offsetList[i]); //string pointerAddyHEX = pointerAddy.ToString("X"); Console.WriteLine("pointerAddy>>{0}", pointerAddy); ProcessMemoryReaderApi.ReadProcessMemory( procHandle, (IntPtr)(pointerAddy), btBuffer, (uint)btBuffer.Length, out lpOutStorage); } return(pointerAddy); }