|
@@ -2,11 +2,13 @@
|
|
#+private
|
|
#+private
|
|
package dynlib
|
|
package dynlib
|
|
|
|
|
|
|
|
+import "base:runtime"
|
|
|
|
+
|
|
import win32 "core:sys/windows"
|
|
import win32 "core:sys/windows"
|
|
import "core:strings"
|
|
import "core:strings"
|
|
import "core:reflect"
|
|
import "core:reflect"
|
|
|
|
|
|
-_load_library :: proc(path: string, global_symbols := false, allocator := context.temp_allocator) -> (Library, bool) {
|
|
|
|
|
|
+_load_library :: proc(path: string, global_symbols: bool, allocator: runtime.Allocator) -> (Library, bool) {
|
|
// NOTE(bill): 'global_symbols' is here only for consistency with POSIX which has RTLD_GLOBAL
|
|
// NOTE(bill): 'global_symbols' is here only for consistency with POSIX which has RTLD_GLOBAL
|
|
wide_path := win32.utf8_to_wstring(path, allocator)
|
|
wide_path := win32.utf8_to_wstring(path, allocator)
|
|
defer free(wide_path, allocator)
|
|
defer free(wide_path, allocator)
|
|
@@ -19,7 +21,7 @@ _unload_library :: proc(library: Library) -> bool {
|
|
return bool(ok)
|
|
return bool(ok)
|
|
}
|
|
}
|
|
|
|
|
|
-_symbol_address :: proc(library: Library, symbol: string, allocator := context.temp_allocator) -> (ptr: rawptr, found: bool) {
|
|
|
|
|
|
+_symbol_address :: proc(library: Library, symbol: string, allocator: runtime.Allocator) -> (ptr: rawptr, found: bool) {
|
|
c_str := strings.clone_to_cstring(symbol, allocator)
|
|
c_str := strings.clone_to_cstring(symbol, allocator)
|
|
defer delete(c_str, allocator)
|
|
defer delete(c_str, allocator)
|
|
ptr = win32.GetProcAddress(cast(win32.HMODULE)library, c_str)
|
|
ptr = win32.GetProcAddress(cast(win32.HMODULE)library, c_str)
|
|
@@ -31,4 +33,4 @@ _last_error :: proc() -> string {
|
|
err := win32.System_Error(win32.GetLastError())
|
|
err := win32.System_Error(win32.GetLastError())
|
|
err_msg := reflect.enum_string(err)
|
|
err_msg := reflect.enum_string(err)
|
|
return "unknown" if err_msg == "" else err_msg
|
|
return "unknown" if err_msg == "" else err_msg
|
|
-}
|
|
|
|
|
|
+}
|