예제 #1
0
        /// <summary>
        /// Allocate memory in the remote process
        /// </summary>
        /// <param name="hProcess"></param>
        /// <param name="dwRegionSize"></param>
        /// <param name="allocationType"></param>
        /// <param name="protectionFlags"></param>
        /// <returns></returns>
        public static IntPtr AllocateVirtualMemory(IntPtr hProcess, int dwRegionSize, Enumerations.AllocationType allocationType, Enumerations.MemoryProtectionFlags protectionFlags)
        {
            IntPtr lpAddress = new IntPtr(0);

            fNtAllocateVirtualMemory(hProcess, &lpAddress, 0, &dwRegionSize, (uint)allocationType, (uint)protectionFlags);
            return(lpAddress);
        }
예제 #2
0
 /// <summary>
 /// Change memory protection in the remote process
 /// </summary>
 /// <param name="hProcess"></param>
 /// <param name="lpAddress"></param>
 /// <param name="numberOfBytesToProtect"></param>
 /// <param name="newAccessProtection"></param>
 /// <param name="oldAccessProtection"></param>
 /// <returns></returns>
 public static bool ProtectVirtualMemory(IntPtr hProcess, IntPtr lpAddress, int numberOfBytesToProtect, Enumerations.MemoryProtectionFlags newAccessProtection, out Enumerations.MemoryProtectionFlags oldAccessProtection)
 {
     return(fNtProtectVirtualMemory(hProcess, &lpAddress, &numberOfBytesToProtect, newAccessProtection, out oldAccessProtection) == Enumerations.Ntstatus.Success);
 }
예제 #3
0
 public static extern IntPtr VirtualAlloc(IntPtr lpAddress, int size, Enumerations.AllocationType flAllocationType, Enumerations.MemoryProtectionFlags flProtect);