public static void WriteRawMemory(this Process process, byte[] buffer, ulong memoryPointer) { //NT.MemoryProtection oldProtect = process.VirtualProtect(memoryPointer, buffer.Length, NT.MemoryProtection.ExecuteReadWrite); if (!NT.WriteProcessMemory(process.Handle, memoryPointer, buffer, (uint)buffer.Length, 0)) { throw new Exception($"WriteBuffer - WriteProcessMemory() failed - {Marshal.GetLastWin32Error().ToString("x2")}"); } //process.VirtualProtect(memoryPointer, buffer.Length, oldProtect); }