示例#1
0
 public MemoryBlock(UIntPtr size)
 {
     size = (UIntPtr)(((long)size + 0xFFFFL) & ~0xFFFFL);
     this.size = size;
     location = VirtualAlloc((IntPtr)0, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
     security = MemoryBlockSecurity.ReadWrite;
 }
示例#2
0
 private static uint GetSecurityFlags(MemoryBlockSecurity mbs)
 {
     switch(mbs)
     {
         case MemoryBlockSecurity.ReadOnly: return PAGE_READONLY;
         case MemoryBlockSecurity.ReadWrite: return PAGE_READWRITE;
         case MemoryBlockSecurity.ExecuteRead: return PAGE_EXECUTE_READ;
         case MemoryBlockSecurity.ExecuteReadWrite: return PAGE_EXECUTE_READWRITE;
         default: goto case MemoryBlockSecurity.ReadWrite;
     }
 }