internal static extern IntPtr PInvoke_VirtualAllocEx(IntPtr hProcess, IntPtr lpBaseAddress, int dwSize, MemoryAllocationTypes flAllocationType, MemoryProtections flProtect);
internal static extern bool PInvoke_VirtualProtectEx(IntPtr hProcess, IntPtr lpBaseAddress, int dwSize, MemoryProtections flNewProtect, out MemoryProtections lpflOldProtect);
/// <summary> /// /// </summary> /// <param name="hProcess"></param> /// <param name="lpBaseAddress"></param> /// <param name="dwSize"></param> /// <param name="flAllocationType"></param> /// <param name="flProtect"></param> /// <returns></returns> public static IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpBaseAddress, int dwSize, MemoryAllocationTypes flAllocationType, MemoryProtections flProtect, [CallerMemberName] string callerName = "") { if (!PInvokeDebugger.LoggingEnabled) { return(PInvoke_VirtualAllocEx(hProcess, lpBaseAddress, dwSize, flAllocationType, flProtect)); } IntPtr returnValue = PInvoke_VirtualAllocEx(hProcess, lpBaseAddress, dwSize, flAllocationType, flProtect); PInvokeDebugInfo debugInfo = PInvokeDebugInfo.TraceDebugInfo( ModuleName, nameof(VirtualAllocEx), callerName, returnValue, IntPtr.Zero, nameof(hProcess), hProcess, nameof(lpBaseAddress), lpBaseAddress, nameof(dwSize), dwSize, nameof(flAllocationType), flAllocationType, nameof(flProtect), flProtect ); PInvokeDebugger.SafeCapture(debugInfo); return(returnValue); }
/// <summary> /// /// </summary> /// <param name="hProcess"></param> /// <param name="lpBaseAddress"></param> /// <param name="dwSize"></param> /// <param name="flNewProtect"></param> /// <param name="lpflOldProtect"></param> /// <returns></returns> public static bool VirtualProtectEx(IntPtr hProcess, IntPtr lpBaseAddress, int dwSize, MemoryProtections flNewProtect, out MemoryProtections lpflOldProtect, [CallerMemberName] string callerName = "") { if (!PInvokeDebugger.LoggingEnabled) { return(PInvoke_VirtualProtectEx(hProcess, lpBaseAddress, dwSize, flNewProtect, out lpflOldProtect)); } bool returnValue = PInvoke_VirtualProtectEx(hProcess, lpBaseAddress, dwSize, flNewProtect, out lpflOldProtect); PInvokeDebugInfo debugInfo = PInvokeDebugInfo.TraceDebugInfo( ModuleName, nameof(VirtualProtectEx), callerName, returnValue, false, nameof(hProcess), hProcess, nameof(lpBaseAddress), lpBaseAddress, nameof(dwSize), dwSize, nameof(flNewProtect), flNewProtect, nameof(lpflOldProtect), lpflOldProtect ); PInvokeDebugger.SafeCapture(debugInfo); return(returnValue); }
internal static extern NTSTATUS PInvoke_NtProtectVirtualMemory(IntPtr ProcessHandle, IntPtr BaseAddress, uint Length, MemoryProtections NewProtection, out MemoryProtections OldProtection);
/// <summary> /// /// </summary> /// <param name="ProcessHandle"></param> /// <param name="BaseAddress"></param> /// <param name="Length"></param> /// <param name="NewProtection"></param> /// <param name="OldProtection"></param> /// <returns></returns> public static NTSTATUS NtProtectVirtualMemory(IntPtr ProcessHandle, IntPtr BaseAddress, uint Length, MemoryProtections NewProtection, out MemoryProtections OldProtection, [CallerMemberName] string callerName = "") { if (!PInvokeDebugger.LoggingEnabled) { return(PInvoke_NtProtectVirtualMemory(ProcessHandle, BaseAddress, Length, NewProtection, out OldProtection)); } NTSTATUS returnValue = PInvoke_NtProtectVirtualMemory(ProcessHandle, BaseAddress, Length, NewProtection, out OldProtection); PInvokeDebugInfo debugInfo = PInvokeDebugInfo.TraceDebugInfo( ModuleName, nameof(NtProtectVirtualMemory), callerName, returnValue, nameof(ProcessHandle), ProcessHandle, nameof(BaseAddress), BaseAddress, nameof(Length), Length, nameof(NewProtection), NewProtection, nameof(OldProtection), OldProtection ); PInvokeDebugger.SafeCapture(debugInfo); return(returnValue); }
internal static extern IntPtr VirtualAlloc( IntPtr lpAddress, UIntPtr dwSize, AllocationTypes flAllocationType, MemoryProtections flProtect);
public static extern bool VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress, IntPtr dwSize, MemoryProtections flNewProtect, out MemoryProtections lpflOldProtect);
public static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, IntPtr dwSize, AllocationTypes flAllocationTypes, MemoryProtections flProtect);