public string PointerWrite(IntPtr memoryAddress, byte[] bytesToWrite, int[] Offset, out int bytesWritten) { int iPointerCount = Offset.Length - 1; IntPtr ptrBytesWritten; bytesWritten = 0; byte[] buffer = new byte[4]; // DWORD to hold an Address int tempAddress = 0; if (iPointerCount == 0) { MemoryAPI.ReadProcessMemory(hProcess, memoryAddress, buffer, 4, out _); tempAddress = AddressUtils.ToDec(AddressUtils.MakeAddress(buffer)) + Offset[0]; // Final Address MemoryAPI.WriteProcessMemory(hProcess, (IntPtr)tempAddress, bytesToWrite, (uint)bytesToWrite.Length, out ptrBytesWritten); bytesWritten = ptrBytesWritten.ToInt32(); return(AddressUtils.ToHex(tempAddress)); } for (int i = 0; i <= iPointerCount; i++) { if (i == iPointerCount) { MemoryAPI.ReadProcessMemory(hProcess, (IntPtr)tempAddress, buffer, 4, out _); tempAddress = AddressUtils.ToDec(AddressUtils.MakeAddress(buffer)) + Offset[i]; // Final Address MemoryAPI.WriteProcessMemory(hProcess, (IntPtr)tempAddress, bytesToWrite, (uint)bytesToWrite.Length, out ptrBytesWritten); bytesWritten = ptrBytesWritten.ToInt32(); return(AddressUtils.ToHex(tempAddress)); } else if (i == 0) { MemoryAPI.ReadProcessMemory(hProcess, memoryAddress, buffer, 4, out _); tempAddress = AddressUtils.ToDec(AddressUtils.MakeAddress(buffer)) + Offset[i]; } else { MemoryAPI.ReadProcessMemory(hProcess, (IntPtr)tempAddress, buffer, 4, out _); tempAddress = AddressUtils.ToDec(AddressUtils.MakeAddress(buffer)) + Offset[i]; } } return(AddressUtils.ToHex(tempAddress)); }
public void Write(IntPtr memoryAddress, byte[] bytesToWrite, out int bytesWritten) { MemoryAPI.WriteProcessMemory(hProcess, memoryAddress, bytesToWrite, (uint)bytesToWrite.Length, out IntPtr ptrBytesWritten); bytesWritten = ptrBytesWritten.ToInt32(); }