summaryrefslogtreecommitdiff
path: root/include/m_plugin.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/m_plugin.h')
-rw-r--r--include/m_plugin.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/include/m_plugin.h b/include/m_plugin.h
index 592aa565bf..ae56eeb49a 100644
--- a/include/m_plugin.h
+++ b/include/m_plugin.h
@@ -4,6 +4,8 @@
#include <m_database.h>
#include <m_protocols.h>
+extern HINSTANCE g_hInstance;
+
class MIR_APP_EXPORT CMPluginBase
{
void tryOpenLog();
@@ -11,8 +13,9 @@ class MIR_APP_EXPORT CMPluginBase
protected:
const char *m_szModuleName;
HANDLE m_hLogger = nullptr;
+ HINSTANCE m_hInst;
- CMPluginBase(const char *moduleName);
+ CMPluginBase(HINSTANCE, const char *moduleName);
~CMPluginBase();
// pass one of PROTOTYPE_* constants as type
@@ -26,6 +29,8 @@ public:
void debugLogA(LPCSTR szFormat, ...);
void debugLogW(LPCWSTR wszFormat, ...);
+ __forceinline HINSTANCE getInst() const { return m_hInst; }
+
__forceinline INT_PTR delSetting(const char *name)
{
return db_unset(0, m_szModuleName, name);
@@ -158,13 +163,22 @@ extern struct CMPlugin g_plugin;
/////////////////////////////////////////////////////////////////////////////////////////
// Basic class for plugins (not protocols) written in C++
+typedef BOOL(WINAPI * const _pfnCrtInit)(HINSTANCE, DWORD, LPVOID);
+
template<class T> class PLUGIN : public CMPluginBase
{
typedef CMPluginBase CSuper;
+public:
+ static BOOL WINAPI RawDllMain(HINSTANCE hInstance, DWORD, LPVOID)
+ {
+ g_hInstance = hInstance;
+ return TRUE;
+ }
+
protected:
PLUGIN(const char *moduleName)
- : CSuper(moduleName)
+ : CSuper(g_hInstance, moduleName)
{}
__forceinline HANDLE CreatePluginEvent(const char *name)