Пример #1
0
            public override unsafe bool ChangeProtection(ProtectionEnums.ProtectionTypes protection)
            {
                uint dummy;

                return(MemNativeMethods.VirtualProtect(
                           handle, (IntPtr)PageSize, (uint)protection, &dummy));
            }
Пример #2
0
 protected override bool ReleaseHandle()
 {
     return(MemNativeMethods.VirtualFree(
                handle,
                (IntPtr)0,
                (uint)MemFreeEnums.MemFreeTypeFlags.MEM_RELEASE));
 }
Пример #3
0
            public MemoryPageImpl(bool commit = true)
            {
                var flags = MemAllocEnums.MemAllocTypeFlags.MEM_RESERVE;

                if (commit)
                {
                    flags |= MemAllocEnums.MemAllocTypeFlags.MEM_COMMIT;
                }

                handle = MemNativeMethods.VirtualAlloc(IntPtr.Zero,
                                                       (IntPtr)PageSize,
                                                       (uint)flags,
                                                       (uint)ProtectionEnums.ProtectionTypes.PAGE_EXECUTE_READWRITE
                                                       );
            }