diff --git a/engine/common/qvm.c b/engine/common/qvm.c index 2fb6f9f8a..10e190d37 100644 --- a/engine/common/qvm.c +++ b/engine/common/qvm.c @@ -73,7 +73,8 @@ struct vm_s { dllhandle_t *QVM_LoadDLL(const char *name, void **vmMain, sys_calldll_t syscall) { void (EXPORT_FN *dllEntry)(sys_calldll_t syscall); - char dllname[MAX_OSPATH]; + char dllname_arch[MAX_OSPATH]; //id compatible + char dllname_anycpu[MAX_OSPATH];//simple dllhandle_t *hVM; dllfunction_t funcs[] = @@ -89,17 +90,23 @@ dllhandle_t *QVM_LoadDLL(const char *name, void **vmMain, sys_calldll_t syscall) #endif #ifdef _WIN32 - sprintf(dllname, "%sx86.dll", name); + snprintf(dllname_arch, sizeof(dllname_arch), "%sx86.dll", name); + snprintf(dllname_anycpu, sizeof(dllname_anycpu), "%s.dll", name); #elif defined(__amd64__) - sprintf(dllname, "%samd.so", name); + snprintf(dllname_arch, sizeof(dllname_arch), "%samd.so", name); + snprintf(dllname_anycpu, sizeof(dllname_anycpu), "%s.so", name); #elif defined(_M_IX86) || defined(__i386__) - sprintf(dllname, "%sx86.so", name); + snprintf(dllname_arch, sizeof(dllname_arch), "%sx86.so", name); + snprintf(dllname_anycpu, sizeof(dllname_anycpu), "%s.so", name); #elif defined(__powerpc__) - sprintf(dllname, "%sppc.so", name); + snprintf(dllname_arch, sizeof(dllname_arch), "%sppc.so", name); + snprintf(dllname_anycpu, sizeof(dllname_anycpu), "%s.so", name); #elif defined(__ppc__) - sprintf(dllname, "%sppc.so", name); + snprintf(dllname_arch, sizeof(dllname_arch), "%sppc.so", name); + snprintf(dllname_anycpu, sizeof(dllname_anycpu), "%s.so", name); #else - sprintf(dllname, "%sunk.so", name); + snprintf(dllname_arch, sizeof(dllname_arch), "%sunk.so", name); + snprintf(dllname_anycpu, sizeof(dllname_anycpu), "%s.so", name); #endif hVM=NULL; @@ -114,7 +121,7 @@ dllhandle_t *QVM_LoadDLL(const char *name, void **vmMain, sys_calldll_t syscall) if (!gpath) return NULL; // couldn't find one anywhere - snprintf (fname, sizeof(fname), "%s/%s", gpath, dllname); + snprintf (fname, sizeof(fname), "%s/%s", gpath, dllname_arch); Con_DPrintf("Loading native: %s\n", fname); hVM = Sys_LoadLibrary(fname, funcs); @@ -123,7 +130,7 @@ dllhandle_t *QVM_LoadDLL(const char *name, void **vmMain, sys_calldll_t syscall) break; } - snprintf (fname, sizeof(fname), "%s/%s", gpath, name); + snprintf (fname, sizeof(fname), "%s/%s", gpath, dllname_anycpu); Con_DPrintf("Loading native: %s\n", fname); hVM = Sys_LoadLibrary(fname, funcs);