QT now uses the old Windows dynamic loading code when on Windows.

This commit is contained in:
OBattler
2022-07-24 03:37:37 +02:00
parent 5292dcab32
commit b13bb3a263

View File

@@ -431,6 +431,67 @@ void plat_language_code_r(uint32_t lcid, char* outbuf, int len) {
return;
}
#ifdef Q_OS_WINDOWS
#ifdef ENABLE_DYNLD_LOG
int dynld_do_log = ENABLE_DYNLD_LOG;
static void
dynld_log(const char *fmt, ...)
{
va_list ap;
if (dynld_do_log) {
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
}
#else
#define dynld_log(fmt, ...)
#endif
void *
dynld_module(const char *name, dllimp_t *table)
{
HMODULE h;
dllimp_t *imp;
void *func;
/* See if we can load the desired module. */
if ((h = LoadLibrary(name)) == NULL) {
dynld_log("DynLd(\"%s\"): library not found! (%08X)\n", name, GetLastError());
return(NULL);
}
/* Now load the desired function pointers. */
for (imp=table; imp->name!=NULL; imp++) {
func = (void *) GetProcAddress(h, imp->name);
if (func == NULL) {
dynld_log("DynLd(\"%s\"): function '%s' not found! (%08X)\n",
name, imp->name, GetLastError());
FreeLibrary(h);
return(NULL);
}
/* To overcome typing issues.. */
*(char **)imp->func = (char *)func;
}
/* All good. */
dynld_log("loaded %s\n", name);
return((void *)h);
}
void
dynld_close(void *handle)
{
if (handle != NULL)
FreeLibrary((HMODULE)handle);
}
#else
void* dynld_module(const char *name, dllimp_t *table)
{
QString libraryName = name;
@@ -462,6 +523,7 @@ void dynld_close(void *handle)
{
delete reinterpret_cast<QLibrary*>(handle);
}
#endif
void startblit()
{