当前位置: 首页>>代码示例>>C#>>正文


C# MemoryProtection类代码示例

本文整理汇总了C#中MemoryProtection的典型用法代码示例。如果您正苦于以下问题:C# MemoryProtection类的具体用法?C# MemoryProtection怎么用?C# MemoryProtection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MemoryProtection类属于命名空间,在下文中一共展示了MemoryProtection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VirtualMemorySetProtection

 public static void VirtualMemorySetProtection(void* pointer, IntPtr size, MemoryProtection protection)
 {
     int old;
     switch (protection)
     {
         case MemoryProtection.Execute:
             Kernel32.VirtualProtect(pointer, size, Kernel32.VirtualMemProtectionFlag.PageExecute, out old);
             break;
         case MemoryProtection.ReadWrite:
             Kernel32.VirtualProtect(pointer, size, Kernel32.VirtualMemProtectionFlag.PageReadWrite, out old);
             break;
     }
 }
开发者ID:jethazel,项目名称:jet-compiler,代码行数:13,代码来源:WindowsNativeUtils.cs

示例2: Map

 public PhysicalPagesMapping Map(IntPtr address, MemoryProtection protection)
 {
     IntPtr allocAddress = ProcessHandle.Current.AllocateMemory(
         address,
         _count * Windows.PageSize,
         MemoryFlags.Reserve | MemoryFlags.Physical,
         protection
         );
     if (!Win32.MapUserPhysicalPages(
         allocAddress,
         new IntPtr(_count),
         _pfnArray
         ))
         Win32.ThrowLastError();
     return new PhysicalPagesMapping(this, allocAddress);
 }
开发者ID:RoDaniel,项目名称:featurehouse,代码行数:16,代码来源:PhysicalPages.cs

示例3: MemoryMappedFileStream

        public MemoryMappedFileStream(string name, uint maxLength, MemoryProtection protection)
        {
            if(string.IsNullOrEmpty(name))
            {
                throw(new ArgumentException("Argument_Name"));
            }

            if(maxLength < 0)
            {
                throw(new ArgumentOutOfRangeException("ArgumentOutOfRange_MaxLength"));
            }

            objectName = name;

            if (protection < MemoryProtection.PageNoAccess ||
                protection > MemoryProtection.SecReserve)
            {
                throw new ArgumentOutOfRangeException("ArgumentOutOfRange_Enum");
            }

            if( maxLength == 0 )
            {
                mapLength = 5120;
            }
            else
            {
                mapLength = maxLength;
            }

            memProtection = protection;

            isReadable = true;
            isWritable = true;
            isSeekable = true;

            // Initialize mapViewPointer
            mapViewPointer = new IntPtr(-1);

            SECURITY_ATTRIBUTES sa = SECURITY_ATTRIBUTES.GetNullDacl();
            try
            {
                mapHandle = MemoryMappedFileHelper.CreateFileMapping(
                                                    IntPtr.Zero,
                                                    sa,
                                                    memProtection,
                                                    0,
                                                    mapLength,
                                                    objectName);
            }
            finally
            {
                Marshal.FreeHGlobal(sa.lpSecurityDescriptor);
                sa.lpSecurityDescriptor = IntPtr.Zero;
            }

            if(mapHandle == IntPtr.Zero )
            {
                uint lastError = MemoryMappedFileHelper.GetLastError();
                throw new IOException(
                    MemoryMappedFileHelper.GetWin32ErrorMessage( lastError ) );
            }
        }
开发者ID:dbose,项目名称:QuickIPC,代码行数:62,代码来源:MemoryMappedFileStream.cs

示例4: VirtualAllocEx

 internal static extern IntPtr VirtualAllocEx(SafeProcessHandle processHandle, IntPtr address, SizeT size, AllocationType flAllocationType,
     MemoryProtection flProtect);
开发者ID:ericschultz,项目名称:coapp,代码行数:2,代码来源:Kernel32.cs

示例5: VirtualAllocEx

 static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, IntPtr dwSize, AllocationType flAllocationType, MemoryProtection flProtect);
开发者ID:azsry,项目名称:T6UnitedConsole,代码行数:1,代码来源:Form1.cs

示例6: GetWin32FileMapAccess

        public static Win32FileMapAccess GetWin32FileMapAccess( 
			MemoryProtection protection )
        {
            switch ( protection )
            {
                case MemoryProtection.PageReadOnly:
                    return Win32FileMapAccess.FILE_MAP_READ;
                case MemoryProtection.PageWriteCopy:
                    return Win32FileMapAccess.FILE_MAP_WRITE;
                default:
                    return Win32FileMapAccess.FILE_MAP_ALL_ACCESS;
            }
        }
开发者ID:dbose,项目名称:QuickIPC,代码行数:13,代码来源:MemoryMappedFileHelper.cs

示例7: VirtualProtectEx

 internal static extern bool VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress, IntPtr dwSize, MemoryProtection flNewProtect, ref MemoryProtection lpflOldProtect);
开发者ID:PimentelM,项目名称:extibiabot,代码行数:1,代码来源:NativeMethods.cs

示例8: Map

 public PhysicalPagesMapping Map(MemoryProtection protection)
 {
     return this.Map(IntPtr.Zero, protection);
 }
开发者ID:john-peterson,项目名称:processhacker,代码行数:4,代码来源:PhysicalPages.cs

示例9: VirtualProtectEx

		public static extern bool VirtualProtectEx(
			IntPtr hProcess,
			IntPtr lpAddress,
			uint dwSize,
			MemoryProtection flNewProtect,
			[Out] MemoryProtection lpflOldProtect);
开发者ID:DinrusGroup,项目名称:monodevelop-win32-debugger,代码行数:6,代码来源:Imports.cs

示例10: VirtualMemorySetProtection

 public static void VirtualMemorySetProtection(void* pointer, IntPtr size, MemoryProtection protection)
 {
     NativeUtilsImplementation.VirtualMemorySetProtection(pointer, size, protection);
 }
开发者ID:jethazel,项目名称:jet-compiler,代码行数:4,代码来源:NativeUtils.cs

示例11: VirtualProtect

 public static extern bool VirtualProtect(IntPtr address, uint size, MemoryProtection newProtect, out MemoryProtection oldProtect);
开发者ID:svenslaggare,项目名称:XONEVirtualMachine,代码行数:1,代码来源:WinAPI.cs

示例12: VirtualAllocEx

 public static extern int VirtualAllocEx(IntPtr hProcess, Int32 lpAddress,
    Int32 dwSize, AllocationType flAllocationType, MemoryProtection flProtect);
开发者ID:Lamael,项目名称:tools,代码行数:2,代码来源:WinApi.cs

示例13: VirtualProtectEx

 public static extern bool VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress, int nSize, MemoryProtection flNewProtect, out MemoryProtection lpflOldProtect);
开发者ID:zhuyue1314,项目名称:DllInjectorCS,代码行数:1,代码来源:Kernel32.cs

示例14: VirtualAlloc

 /// <summary>
 /// Reserves, commits, or changes the state of a region of pages in the virtual address space of the calling process.
 /// Memory allocated by this function is automatically initialized to zero.
 /// </summary>
 /// <param name="sizeInBytes">The size of the region, in bytes</param>
 /// <param name="allocationType">The type of memory allocation.</param>
 /// <param name="protection">The memory protection for the region of pages to be allocated.</param>
 /// <returns>The base address of the allocated region of pages.</returns>
 public static void* VirtualAlloc(ulong sizeInBytes, MemoryAllocationType allocationType, MemoryProtection protection)
 {
     var pointer = VirtualAlloc(IntPtr.Zero, new UIntPtr(sizeInBytes), allocationType, protection).ToPointer();
     if (pointer == null)
         throw new InvalidOperationException(Marshal.GetLastWin32Error().ToString());
     return pointer;
 }
开发者ID:Konard,项目名称:LinksPlatform,代码行数:15,代码来源:Kernel32.cs

示例15: VirtualAllocEx

 public static extern DWORD_PTR VirtualAllocEx( IntPtr hProcess, DWORD_PTR lpAddress, uint dwSize, AllocationType flAllocationType, MemoryProtection flProtect );
开发者ID:aghili,项目名称:nwohack,代码行数:1,代码来源:WinAPI.cs


注:本文中的MemoryProtection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。