public static ulong AllocateAndWrite(this System.Diagnostics.Process process, byte[] buffer, Native.AllocationType allocationType, Native.MemoryProtection memoryProtection) { ulong allocatedMemory = process.AllocateMemory((uint)buffer.Length, allocationType, memoryProtection); process.WriteRawMemory(buffer, allocatedMemory); return(allocatedMemory); }