You need to approach differently.
If you are dynamically loading the library, you should also use GetProcAddress () and dlsym () to actually do anything with it. dlsym () is your way forward.
You clearly control the plugin code, because otherwise you could not even add these APIs to it. Thus, all of your dllmain on any of these platforms should set some global "valid" status information. Then you simply call the well-known API like "ModuleIsValid ()", whose task is to simply read this status information and return true / false. If it returns false, you close the library and refuse the report.
source share