mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
std: simplify VirtualProtectEx and fix ntdll signature
This commit is contained in:
parent
216badef0b
commit
349349fa01
@ -1514,7 +1514,8 @@ pub fn VirtualProtect(lpAddress: ?LPVOID, dwSize: SIZE_T, flNewProtect: DWORD, l
|
||||
}
|
||||
}
|
||||
|
||||
pub fn VirtualProtectEx(handle: HANDLE, addr: ?LPVOID, size: usize, new_prot: DWORD, old_prot: ?*DWORD) VirtualProtectError!void {
|
||||
pub fn VirtualProtectEx(handle: HANDLE, addr: ?LPVOID, size: SIZE_T, new_prot: DWORD) VirtualProtectError!DWORD {
|
||||
var old_prot: DWORD = undefined;
|
||||
var out_addr = addr;
|
||||
var out_size = size;
|
||||
switch (ntdll.NtProtectVirtualMemory(
|
||||
@ -1522,9 +1523,9 @@ pub fn VirtualProtectEx(handle: HANDLE, addr: ?LPVOID, size: usize, new_prot: DW
|
||||
&out_addr,
|
||||
&out_size,
|
||||
new_prot,
|
||||
old_prot,
|
||||
&old_prot,
|
||||
)) {
|
||||
.SUCCESS => {},
|
||||
.SUCCESS => return old_prot,
|
||||
.INVALID_ADDRESS => return error.InvalidAddress,
|
||||
// TODO: map errors
|
||||
else => |rc| return std.os.windows.unexpectedStatus(rc),
|
||||
|
||||
@ -283,5 +283,5 @@ pub extern "ntdll" fn NtProtectVirtualMemory(
|
||||
BaseAddress: *?PVOID,
|
||||
NumberOfBytesToProtect: *SIZE_T,
|
||||
NewAccessProtection: ULONG,
|
||||
OldAccessProtection: ?*ULONG,
|
||||
OldAccessProtection: *ULONG,
|
||||
) callconv(WINAPI) NTSTATUS;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user