Skip to content

Commit bc0af4c

Browse files
committed
Support ordinal lookup in dlsym_hook on Windows
1 parent 3472fef commit bc0af4c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/hooks.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ const bootstrap = @import("bootstrap.zig");
211211
const runtimes = @import("runtimes.zig");
212212

213213
fn dlsym_hook(handle: util.Module(false), name_ptr: [*:0]const u8) callconv(if (builtin.os.tag == .windows) .winapi else .c) ?*anyopaque {
214+
if (builtin.os.tag == .windows and @intFromPtr(name_ptr) >> 16 == 0) {
215+
// documented that if the "HIWORD" is 0, the name_ptr actually specifies an ordinal.
216+
logger.debug("dlsym({}, {})", .{ util.fmtAddress(handle), @intFromPtr(name_ptr) });
217+
return std.os.windows.kernel32.GetProcAddress(handle, name_ptr);
218+
}
219+
214220
const name = std.mem.span(name_ptr);
215221

216222
logger.debug("dlsym({}, \"{s}\")", .{ util.fmtAddress(handle), name });

0 commit comments

Comments
 (0)