diff options
Diffstat (limited to 'plugins/ShellExt')
-rw-r--r-- | plugins/ShellExt/src/main.cpp | 33 | ||||
-rw-r--r-- | plugins/ShellExt/src/options.cpp | 2 | ||||
-rw-r--r-- | plugins/ShellExt/src/shlcom.cpp | 4 | ||||
-rw-r--r-- | plugins/ShellExt/src/shlext.cpp | 2 | ||||
-rw-r--r-- | plugins/ShellExt/src/stdafx.h | 17 | ||||
-rw-r--r-- | plugins/ShellExt/src/utils.cpp | 16 |
6 files changed, 29 insertions, 45 deletions
diff --git a/plugins/ShellExt/src/main.cpp b/plugins/ShellExt/src/main.cpp index d81a8f416c..ec5076eb8f 100644 --- a/plugins/ShellExt/src/main.cpp +++ b/plugins/ShellExt/src/main.cpp @@ -1,11 +1,22 @@ #include "stdafx.h"
#include "shlcom.h"
-HINSTANCE hInst;
int hLangpack;
+CMPlugin g_plugin;
+
bool bIsVistaPlus;
-wchar_t tszLogPath[MAX_PATH];
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID)
+{
+ if (fdwReason == DLL_PROCESS_ATTACH) {
+ bIsVistaPlus = GetProcAddress( GetModuleHandleA("kernel32.dll"), "GetProductInfo") != nullptr;
+ DisableThreadLibraryCalls(hinstDLL);
+ }
+
+ return TRUE;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
@@ -17,23 +28,9 @@ PLUGININFOEX pluginInfoEx = { __AUTHORWEB,
UNICODE_AWARE,
// {7993AB24-1FDA-428C-A89B-BE377A10BE3A}
- {0x7993ab24, 0x1fda, 0x428c, {0xa8, 0x9b, 0xbe, 0x37, 0x7a, 0x10, 0xbe, 0x3a}}
+ { 0x7993ab24, 0x1fda, 0x428c, { 0xa8, 0x9b, 0xbe, 0x37, 0x7a, 0x10, 0xbe, 0x3a }}
};
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID)
-{
- if (fdwReason == DLL_PROCESS_ATTACH) {
- bIsVistaPlus = GetProcAddress( GetModuleHandleA("kernel32.dll"), "GetProductInfo") != nullptr;
-
- GetTempPath(_countof(tszLogPath), tszLogPath);
- wcscat_s(tszLogPath, _countof(tszLogPath), L"shlext.log");
-
- hInst = hinstDLL;
- DisableThreadLibraryCalls(hinstDLL);
- }
-
- return TRUE;
-}
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
@@ -126,7 +123,7 @@ STDAPI DllRegisterServer() return E_FAIL;
wchar_t tszFileName[MAX_PATH];
- GetModuleFileName(hInst, tszFileName, _countof(tszFileName));
+ GetModuleFileName(g_plugin.getInst(), tszFileName, _countof(tszFileName));
if ( RegSetValueEx(kInprocServer, nullptr, 0, REG_SZ, (LPBYTE)tszFileName, sizeof(wchar_t)*(lstrlen(tszFileName)+1)))
return E_FAIL;
if ( RegSetValueExA(kInprocServer, "ThreadingModel", 0, REG_SZ, (PBYTE)str4, sizeof(str4)))
diff --git a/plugins/ShellExt/src/options.cpp b/plugins/ShellExt/src/options.cpp index aaa3f77f7f..dee192de91 100644 --- a/plugins/ShellExt/src/options.cpp +++ b/plugins/ShellExt/src/options.cpp @@ -115,7 +115,7 @@ int OnOptionsInit(WPARAM wParam, LPARAM) opt.szTitle.a = LPGEN("Shell context menus");
opt.position = -1066;
opt.pszTemplate = MAKEINTRESOURCEA(IDD_SHLOPTS);
- opt.hInstance = hInst;
+ opt.hInstance = g_plugin.getInst();
opt.pfnDlgProc = OptDialogProc;
Options_AddPage(wParam, &opt);
return 0;
diff --git a/plugins/ShellExt/src/shlcom.cpp b/plugins/ShellExt/src/shlcom.cpp index 608b35fd86..c20c5ef069 100644 --- a/plugins/ShellExt/src/shlcom.cpp +++ b/plugins/ShellExt/src/shlcom.cpp @@ -550,7 +550,7 @@ void CheckUnregisterServer() if (bIsVistaPlus) {
// launches regsvr to remove the dll under admin.
wchar_t szFileName[MAX_PATH], szBuf[MAX_PATH * 2];
- GetModuleFileName(hInst, szFileName, _countof(szFileName));
+ GetModuleFileName(g_plugin.getInst(), szFileName, _countof(szFileName));
mir_snwprintf(szBuf, L"/s /u \"%s\"", szFileName);
SHELLEXECUTEINFO sei = { sizeof(sei) };
@@ -579,7 +579,7 @@ void CheckRegisterServer() TranslateT("Shell context menus requires your permission to register with Windows Explorer (one time only)."),
TranslateT("Miranda NG - Shell context menus (shellext.dll)"), MB_OK | MB_ICONINFORMATION);
// /s = silent
- GetModuleFileName(hInst, szFileName, _countof(szFileName));
+ GetModuleFileName(g_plugin.getInst(), szFileName, _countof(szFileName));
mir_snwprintf(szBuf, L"/s \"%s\"", szFileName);
SHELLEXECUTEINFO sei = { sizeof(sei) };
diff --git a/plugins/ShellExt/src/shlext.cpp b/plugins/ShellExt/src/shlext.cpp index 2e5b77fc91..9d887b03e2 100644 --- a/plugins/ShellExt/src/shlext.cpp +++ b/plugins/ShellExt/src/shlext.cpp @@ -633,7 +633,7 @@ typedef HRESULT (__stdcall *pfnDllGetVersion)(DllVersionInfo*); HRESULT TShellExt::QueryContextMenu(HMENU hmenu, UINT, UINT _idCmdFirst, UINT, UINT uFlags)
{
- logA("TShellExt[%p]::QueryContextMenu: %p, %d, %d, %08x\n", this, hmenu, indexMenu, _idCmdFirst, uFlags);
+ logA("TShellExt[%p]::QueryContextMenu: %p, %d, %08x\n", this, hmenu, _idCmdFirst, uFlags);
if (((LOWORD(uFlags) & CMF_VERBSONLY) != CMF_VERBSONLY) && ((LOWORD(uFlags) & CMF_DEFAULTONLY) != CMF_DEFAULTONLY)) {
bool bMF_OWNERDRAW = false;
diff --git a/plugins/ShellExt/src/stdafx.h b/plugins/ShellExt/src/stdafx.h index b01486b518..14bc44366d 100644 --- a/plugins/ShellExt/src/stdafx.h +++ b/plugins/ShellExt/src/stdafx.h @@ -8,9 +8,7 @@ #include <string.h>
#include <stddef.h>
-#define __NO_CMPLUGIN_NEEDED
#include <newpluginapi.h>
-
#include <m_system.h>
#include <m_protocols.h>
#include <m_protosvc.h>
@@ -45,10 +43,15 @@ void InvokeThreadServer(); int IsCOMRegistered();
HRESULT RemoveCOMRegistryEntries();
-extern HINSTANCE hInst;
-extern HANDLE hLogger;
-extern bool bIsVistaPlus;
-extern int DllFactoryCount, DllObjectCount;
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin() :
+ PLUGIN<CMPlugin>(SHLExt_Name)
+ {}
+};
+
+extern bool bIsVistaPlus;
+extern int DllFactoryCount, DllObjectCount;
int OnOptionsInit(WPARAM wParam, LPARAM lParam);
@@ -57,7 +60,7 @@ int OnOptionsInit(WPARAM wParam, LPARAM lParam); #endif
#ifdef LOG_ENABLED
-void logA(const char *format, ...);
+#define logA g_plugin.debugLogA
#else
#define logA(A, ...)
#endif
diff --git a/plugins/ShellExt/src/utils.cpp b/plugins/ShellExt/src/utils.cpp index 275224388e..131ee01dbb 100644 --- a/plugins/ShellExt/src/utils.cpp +++ b/plugins/ShellExt/src/utils.cpp @@ -1,21 +1,5 @@ #include "stdafx.h"
-#ifdef LOG_ENABLED
-extern wchar_t tszLogPath[];
-
-void logA(const char *format, ...)
-{
- FILE *out = _wfopen(tszLogPath, L"a+");
- if (out) {
- va_list args;
- va_start(args, format);
- vfprintf(out, format, args);
- va_end(args);
- fclose(out);
- }
-}
-#endif
-
///////////////////////////////////////////////////////////////////////////////
UINT murmur_hash(const char *str)
|