Created
December 21, 2015 22:07
-
-
Save royhaddad/2ca33dde39c53ab6a0e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace CSharpNatural | |
{ | |
unsafe static class Program | |
{ | |
[System.Runtime.InteropServices.DllImport("kernel32.dll")] | |
static extern void* VirtualAlloc(void* lpAddress, | |
uint dwSize, | |
uint flAllocationType, | |
uint flProtect); | |
const uint MEM_COMMIT = 0x00001000; | |
const uint MEM_RESERVE = 0x00002000; | |
const uint PAGE_READWRITE = 0x04; | |
static int Main() | |
{ | |
const uint MemoryToAllocate = 64 * 1048576; | |
int ExitCode = 0; | |
byte *Memory = (byte*) VirtualAlloc((void*) 0, | |
MemoryToAllocate, | |
MEM_COMMIT | MEM_RESERVE, | |
PAGE_READWRITE); | |
if (Memory != (byte*) 0) | |
{ | |
// YESSSSSSS | |
} | |
else | |
{ | |
ExitCode = 1; | |
} | |
return ExitCode; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment