diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-04-04 00:25:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-04 00:25:03 +0200 |
commit | 46bc14e66fe90430f1d74cdab6cca6acb5b2a3f6 (patch) | |
tree | 6d761531804ce9bb8e78b297598e06bea57dbe7b /platform/windows | |
parent | 57badfd1df3a554b7f47793e73a887874e5ca2b1 (diff) | |
parent | fd553087867187220d4f6b8217854dd8e9be2667 (diff) |
Merge pull request #8246 from GodotNativeTools/dlscript-module
DLScript module
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/os_windows.cpp | 26 | ||||
-rw-r--r-- | platform/windows/os_windows.h | 4 |
2 files changed, 30 insertions, 0 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 83a6aa6079..992e50a2e6 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1582,6 +1582,32 @@ bool OS_Windows::get_borderless_window() { return video_mode.borderless_window; } +Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_handle) { + p_library_handle = (void *)LoadLibrary(p_path.utf8().get_data()); + if (!p_library_handle) { + ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + String::num(GetLastError())); + ERR_FAIL_V(ERR_CANT_OPEN); + } + return OK; +} + +Error OS_Windows::close_dynamic_library(void *p_library_handle) { + if (!FreeLibrary((HMODULE)p_library_handle)) { + return FAILED; + } + return OK; +} + +Error OS_Windows::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle) { + char *error; + p_symbol_handle = (void *)GetProcAddress((HMODULE)p_library_handle, p_name.utf8().get_data()); + if (!p_symbol_handle) { + ERR_EXPLAIN("Can't resolve symbol " + p_name + ". Error: " + String::num(GetLastError())); + ERR_FAIL_V(ERR_CANT_RESOLVE); + } + return OK; +} + void OS_Windows::request_attention() { FLASHWINFO info; diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 25c3102ee6..050067ad7d 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -222,6 +222,10 @@ public: virtual void set_borderless_window(int p_borderless); virtual bool get_borderless_window(); + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle); + virtual Error close_dynamic_library(void *p_library_handle); + virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle); + virtual MainLoop *get_main_loop() const; virtual String get_name(); |