Closed rokups closed 4 years ago
The idea is interesting, but I'm a bit unsure about it. I mean, it will mostly be dead-code inside cr.h as cr itself will not use this, so this looks like an extension or misc functionality useful for some cases but not always enabled. It could be gated, but then it would require specific tests to run in the CI. I'm open to it, but not entirely sold on it.
Ah but it does not have to be a dead code. cr_plugin_load
should use such function to evaluate plugin file before loading it. This would allow user to naively throw anything at cr without risk of executing any code of non-plugins (DllMain, static initialization). Unless there is a way to utilize LoadLibrary
/dlopen
to do the same thing? Any idea?
Right, that could work. If you're willing to do it, this looks good to me! :)
Once i finish MachO parsing part ill submit a PR then :+1:
Closing due inactivity, thank you.
Do you think it would be useful to have a function to test plugin file validity before it is actually loaded? Im thinking it would be very useful in cases where plugin files and there names are not known at a build time and there is no distinction between plugin files and other libraries (like special plugin folder or something). I know we can try to load library and look up cr_main, however this may cause execution of code and depending on library it may even lead to crashes or some other nasty side effects.
What i am proposing is to have
cr_is_valid_plugin(file_path)
. This function should read dynamic library file, parse it's headers and look forcr_main
export. If export is found then we can be reasonably sure it is a plugin.Good thing about this is that i already have implementation for linux and windows here. So just MacOS bit is missing.