Permalink
Browse files

allocation flags defined as constant identifier.

  • Loading branch information...
1 parent 8210f71 commit f339d782ea389da12c696de04b2213e4f1e56231 @0ffffffffh committed Jul 21, 2011
Showing with 7 additions and 2 deletions.
  1. +7 −2 SharpAsm/x86Executer.cs
View
@@ -17,6 +17,11 @@ class x86Executer
private const int PAGE_SIZE = 0x1000;
+ private const uint MEM_COMMIT = 0x1000;
+ private const uint MEM_RELEASE = 0x8000;
+ private const uint PAGE_EXECUTE_READWRITE = 0x40;
+
+
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr VirtualAlloc(IntPtr addr, UIntPtr size, uint allocType, uint prot);
@@ -41,14 +46,14 @@ class x86Executer
private bool AllocPage()
{
- codePage = VirtualAlloc(IntPtr.Zero, new UIntPtr(PAGE_SIZE), 0x1000, 0x40);
+ codePage = VirtualAlloc(IntPtr.Zero, new UIntPtr(PAGE_SIZE), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
return codePage != IntPtr.Zero;
}
private void FreePage()
{
- VirtualFree(codePage,UIntPtr.Zero,0x8000);
+ VirtualFree(codePage,UIntPtr.Zero,MEM_RELEASE);
codePage = IntPtr.Zero;
}

0 comments on commit f339d78

Please sign in to comment.