Function getBaseAddress [src]
Prototype
pub fn getBaseAddress() usize
Source
pub fn getBaseAddress() usize {
switch (native_os) {
.linux => {
const base = std.os.linux.getauxval(std.elf.AT_BASE);
if (base != 0) {
return base;
}
const phdr = std.os.linux.getauxval(std.elf.AT_PHDR);
return phdr - @sizeOf(std.elf.Ehdr);
},
.macos, .freebsd, .netbsd => {
return @intFromPtr(&std.c._mh_execute_header);
},
.windows => return @intFromPtr(windows.kernel32.GetModuleHandleW(null)),
else => @compileError("Unsupported OS"),
}
}