vst3 bug fix in dllmain

This commit is contained in:
Paolo 2024-06-20 17:47:16 +02:00
parent 9dcf07147d
commit 0421f5dec9

View File

@ -66,6 +66,7 @@ typedef struct {
// https://github.com/rubberduck-vba/Rubberduck/wiki/COM-in-plain-C // https://github.com/rubberduck-vba/Rubberduck/wiki/COM-in-plain-C
// https://devblogs.microsoft.com/oldnewthing/20040205-00/?p=40733 // https://devblogs.microsoft.com/oldnewthing/20040205-00/?p=40733
//#define TIBIA_TRACE
#ifdef TIBIA_TRACE #ifdef TIBIA_TRACE
# define TRACE(...) printf(__VA_ARGS__); fflush(stdout); # define TRACE(...) printf(__VA_ARGS__); fflush(stdout);
#else #else
@ -2167,14 +2168,17 @@ DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) {
EXPORT EXPORT
# if defined(__APPLE__) # if defined(__APPLE__)
char bundleEntry(CFBundleRef ref) { char bundleEntry(CFBundleRef ref) {
(void)ref;
# else # else
char ModuleEntry(void *handle) { char ModuleEntry(void *handle) {
(void)handle;
# endif # endif
(void)ref;
char *file; char *file;
if (refs == 0) { if (refs == 0) {
Dl_info info; Dl_info info;
if (dladdr((void*) bindir, &info) == 0) union { void* d; char (*f)(); } v;
v.f = vstExit;
if (dladdr((void*) v.d, &info) == 0)
return 0; return 0;
file = realpath(info.dli_fname, NULL); file = realpath(info.dli_fname, NULL);
if (file == NULL) if (file == NULL)