Esempio n. 1
0
        public static bool VirtualProtect(IntPtr pid, IntPtr address, uint size, PageAccessProtectionFlags flags, out PageAccessProtectionFlags oldFlags)
        {
            IntPtr handle = GetProcessHandle(pid, ProcessAccessFlags.VMOperation);
            bool   result = VirtualProtectEx(handle, address, size, flags, out oldFlags);

            CloseHandle(handle);
            return(result);
        }
Esempio n. 2
0
        public static bool VirtualProtect(
            IntPtr pid,
            IntPtr address,
            uint size,
            PageAccessProtectionFlags flags,
            out PageAccessProtectionFlags oldFlags)
        {
            IntPtr processHandle = Kernel32.GetProcessHandle(pid, ProcessAccessFlags.VMOperation);
            int    num           = Kernel32.VirtualProtectEx(processHandle, address, size, flags, out oldFlags) ? 1 : 0;

            Kernel32.CloseHandle(processHandle);
            return(num != 0);
        }
Esempio n. 3
0
        public static IntPtr VirtualAlloc(
            Process p,
            IntPtr address,
            uint size,
            AllocationType type,
            PageAccessProtectionFlags flags)
        {
            IntPtr processHandle = Kernel32.GetProcessHandle(p, ProcessAccessFlags.VMOperation);
            IntPtr num           = Kernel32.VirtualAllocEx(processHandle, address, size, type, flags);

            if (num == IntPtr.Zero)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            Kernel32.CloseProcessHandle(processHandle);
            return(num);
        }
Esempio n. 4
0
 private static extern IntPtr VirtualAllocEx(
     IntPtr hProcess,
     IntPtr lpAddress,
     uint dwSize,
     AllocationType flAllocationType,
     PageAccessProtectionFlags flProtect);
Esempio n. 5
0
 private static extern bool VirtualProtectEx(
     IntPtr hProcess,
     IntPtr lpAddress,
     uint dwSize,
     PageAccessProtectionFlags flags,
     out PageAccessProtectionFlags oldFlags);