diff options
Diffstat (limited to 'std/os/windows')
| -rw-r--r-- | std/os/windows/index.zig | 1 | ||||
| -rw-r--r-- | std/os/windows/kernel32.zig | 2 | ||||
| -rw-r--r-- | std/os/windows/util.zig | 31 |
3 files changed, 3 insertions, 31 deletions
diff --git a/std/os/windows/index.zig b/std/os/windows/index.zig index fc64db7c37..9d03cf6625 100644 --- a/std/os/windows/index.zig +++ b/std/os/windows/index.zig @@ -24,6 +24,7 @@ pub const HANDLE = *c_void; pub const HCRYPTPROV = ULONG_PTR; pub const HINSTANCE = *@OpaqueType(); pub const HMODULE = *@OpaqueType(); +pub const FARPROC = *@OpaqueType(); pub const INT = c_int; pub const LPBYTE = *BYTE; pub const LPCH = *CHAR; diff --git a/std/os/windows/kernel32.zig b/std/os/windows/kernel32.zig index 94b339fa6e..7eec5faba9 100644 --- a/std/os/windows/kernel32.zig +++ b/std/os/windows/kernel32.zig @@ -178,6 +178,8 @@ pub extern "kernel32" stdcallcc fn WriteFileEx(hFile: HANDLE, lpBuffer: [*]const pub extern "kernel32" stdcallcc fn LoadLibraryW(lpLibFileName: [*]const u16) ?HMODULE; +pub extern "kernel32" stdcallcc fn GetProcAddress(hModule: HMODULE, lpProcName: [*]const u8) ?FARPROC; + pub extern "kernel32" stdcallcc fn FreeLibrary(hModule: HMODULE) BOOL; pub const FILE_NOTIFY_INFORMATION = extern struct { diff --git a/std/os/windows/util.zig b/std/os/windows/util.zig index 6534d16f5e..7d983421e0 100644 --- a/std/os/windows/util.zig +++ b/std/os/windows/util.zig @@ -188,37 +188,6 @@ pub fn createWindowsEnvBlock(allocator: *mem.Allocator, env_map: *const BufMap) return allocator.shrink(u16, result, i); } -pub fn windowsLoadDllW(dll_path_w: [*]const u16) !windows.HMODULE { - return windows.LoadLibraryW(dll_path_w) orelse { - const err = windows.GetLastError(); - switch (err) { - windows.ERROR.FILE_NOT_FOUND => return error.FileNotFound, - windows.ERROR.PATH_NOT_FOUND => return error.FileNotFound, - windows.ERROR.MOD_NOT_FOUND => return error.FileNotFound, - else => return os.unexpectedErrorWindows(err), - } - }; -} - -pub fn windowsLoadDll(dll_path: []const u8) !windows.HMODULE { - const dll_path_w = try sliceToPrefixedFileW(dll_path); - return windowsLoadDllW(&dll_path_w); -} - -pub fn windowsUnloadDll(hModule: windows.HMODULE) void { - assert(windows.FreeLibrary(hModule) != 0); -} - -test "InvalidDll" { - if (builtin.os != builtin.Os.windows) return error.SkipZigTest; - - const handle = os.windowsLoadDll("asdf.dll") catch |err| { - assert(err == error.FileNotFound); - return; - }; - @panic("Expected error from function"); -} - pub fn windowsFindFirstFile( dir_path: []const u8, find_file_data: *windows.WIN32_FIND_DATAW, |
