예제 #1
0
        public void TestProtectMemory()
        {
            var regionAddress = _memoryModule.AllocateVirtualMemory(sizeof(int), MemoryProtection.ReadWrite);

            _memoryModule.ProtectVirtualMemory(regionAddress, sizeof(int), MemoryProtection.NoAccess);

            Assert.Throws <Win32Exception>(() => _memoryModule.ReadVirtualMemory <int>(regionAddress));

            _memoryModule.FreeVirtualMemory(regionAddress);
        }