From d087b9ea5b4fffcd03e3c4925c2eb83ab8d1f39e Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 18 Apr 2022 20:28:42 -0500 Subject: [PATCH] include: Implement vkd3d_dl*() wrappers for Win32 platforms. Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- include/private/vkd3d_common.h | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h index 7aabe8ab..c041b52d 100644 --- a/include/private/vkd3d_common.h +++ b/include/private/vkd3d_common.h @@ -27,6 +27,7 @@ #include #include #include +#include #ifdef _MSC_VER #include @@ -246,7 +247,33 @@ static inline void vkd3d_parse_version(const char *version, int *major, int *min HRESULT hresult_from_vkd3d_result(int vkd3d_result); -#ifdef HAVE_DLFCN_H +#ifdef _WIN32 +static inline void *vkd3d_dlopen(const char *name) +{ + return LoadLibraryA(name); +} + +static inline void *vkd3d_dlsym(void *handle, const char *symbol) +{ + return GetProcAddress(handle, symbol); +} + +static inline int vkd3d_dlclose(void *handle) +{ + return FreeLibrary(handle); +} + +static inline const char *vkd3d_dlerror(void) +{ + unsigned int error = GetLastError(); + static char message[256]; + + if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, message, sizeof(message), NULL)) + return message; + sprintf(message, "Unknown error %u.\n", error); + return message; +} +#elif defined(HAVE_DLFCN_H) #include static inline void *vkd3d_dlopen(const char *name)