| ... | @@ -1758,6 +1758,38 @@ pub fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) TerminateProcessError | ... | @@ -1758,6 +1758,38 @@ pub fn TerminateProcess(hProcess: HANDLE, uExitCode: UINT) TerminateProcessError |
| 1758 | } | 1758 | } |
| 1759 | } | 1759 | } |
| 1760 | | 1760 | |
| | 1761 | pub const NtAllocateVirtualMemoryError = error{ |
| | 1762 | AccessDenied, |
| | 1763 | InvalidParameter, |
| | 1764 | NoMemory, |
| | 1765 | Unexpected, |
| | 1766 | }; |
| | 1767 | |
| | 1768 | pub fn NtAllocateVirtualMemory(hProcess: HANDLE, addr: ?*PVOID, zero_bits: ULONG_PTR, size: ?*SIZE_T, alloc_type: ULONG, protect: ULONG) NtAllocateVirtualMemoryError!void { |
| | 1769 | return switch (ntdll.NtAllocateVirtualMemory(hProcess, addr, zero_bits, size, alloc_type, protect)) { |
| | 1770 | .SUCCESS => return, |
| | 1771 | .ACCESS_DENIED => NtAllocateVirtualMemoryError.AccessDenied, |
| | 1772 | .INVALID_PARAMETER => NtAllocateVirtualMemoryError.InvalidParameter, |
| | 1773 | .NO_MEMORY => NtAllocateVirtualMemoryError.NoMemory, |
| | 1774 | else => |st| unexpectedStatus(st), |
| | 1775 | }; |
| | 1776 | } |
| | 1777 | |
| | 1778 | pub const NtFreeVirtualMemoryError = error{ |
| | 1779 | AccessDenied, |
| | 1780 | InvalidParameter, |
| | 1781 | Unexpected, |
| | 1782 | }; |
| | 1783 | |
| | 1784 | pub fn NtFreeVirtualMemory(hProcess: HANDLE, addr: ?*PVOID, size: *SIZE_T, free_type: ULONG) NtFreeVirtualMemoryError!void { |
| | 1785 | return switch (ntdll.NtFreeVirtualMemory(hProcess, addr, size, free_type)) { |
| | 1786 | .SUCCESS => return, |
| | 1787 | .ACCESS_DENIED => NtFreeVirtualMemoryError.AccessDenied, |
| | 1788 | .INVALID_PARAMETER => NtFreeVirtualMemoryError.InvalidParameter, |
| | 1789 | else => NtFreeVirtualMemoryError.Unexpected, |
| | 1790 | }; |
| | 1791 | } |
| | 1792 | |
| 1761 | pub const VirtualAllocError = error{Unexpected}; | 1793 | pub const VirtualAllocError = error{Unexpected}; |
| 1762 | | 1794 | |
| 1763 | pub fn VirtualAlloc(addr: ?LPVOID, size: usize, alloc_type: DWORD, flProtect: DWORD) VirtualAllocError!LPVOID { | 1795 | pub fn VirtualAlloc(addr: ?LPVOID, size: usize, alloc_type: DWORD, flProtect: DWORD) VirtualAllocError!LPVOID { |
| ... | @@ -3539,6 +3571,8 @@ pub const MEM_LARGE_PAGES = 0x20000000; | ... | @@ -3539,6 +3571,8 @@ pub const MEM_LARGE_PAGES = 0x20000000; |
| 3539 | pub const MEM_PHYSICAL = 0x400000; | 3571 | pub const MEM_PHYSICAL = 0x400000; |
| 3540 | pub const MEM_TOP_DOWN = 0x100000; | 3572 | pub const MEM_TOP_DOWN = 0x100000; |
| 3541 | pub const MEM_WRITE_WATCH = 0x200000; | 3573 | pub const MEM_WRITE_WATCH = 0x200000; |
| | 3574 | pub const MEM_RESERVE_PLACEHOLDER = 0x00040000; |
| | 3575 | pub const MEM_PRESERVE_PLACEHOLDER = 0x00000400; |
| 3542 | | 3576 | |
| 3543 | // Protect values | 3577 | // Protect values |
| 3544 | pub const PAGE_EXECUTE = 0x10; | 3578 | pub const PAGE_EXECUTE = 0x10; |