From 1cacabc4a97dc5303964161dc0e5d8fd53c6e036 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Fri, 26 Sep 2014 21:50:14 +0000 Subject: Crash Dumper: - Removed folders support for CrashLog directory (too dangerous and only available after all plugins have been loaded) - menus are created inside Load() PluginUpdater: - Replace obsioleted plugins git-svn-id: http://svn.miranda-ng.org/main/trunk@10606 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/CrashDumper/src/crshdmp.cpp | 110 ++++++++++++++++++------------------ plugins/CrashDumper/src/utils.cpp | 14 ----- plugins/CrashDumper/src/utils.h | 1 - 3 files changed, 55 insertions(+), 70 deletions(-) (limited to 'plugins/CrashDumper/src') diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp index dfbd7d3557..14e9da4972 100644 --- a/plugins/CrashDumper/src/crshdmp.cpp +++ b/plugins/CrashDumper/src/crshdmp.cpp @@ -23,14 +23,14 @@ int hLangpack; HINSTANCE hInst; DWORD mirandaVersion; LCID packlcid; -HANDLE hCrashLogFolder, hVerInfoFolder; +//HANDLE hCrashLogFolder, hVerInfoFolder; +HANDLE hVerInfoFolder; TCHAR* vertxt; TCHAR* profname; TCHAR* profpath; -TCHAR CrashLogFolder[MAX_PATH]; -TCHAR VersionInfoFolder[MAX_PATH]; +TCHAR CrashLogFolder[MAX_PATH], VersionInfoFolder[MAX_PATH]; bool servicemode; bool clsdates; @@ -156,9 +156,9 @@ static int FoldersPathChanged(WPARAM, LPARAM) FOLDERSGETDATA fgd = { 0 }; fgd.cbSize = sizeof(FOLDERSGETDATA); fgd.nMaxPathSize = MAX_PATH; - fgd.szPathT = CrashLogFolder; fgd.flags = FF_TCHAR; - CallService(MS_FOLDERS_GET_PATH, (WPARAM)hCrashLogFolder, (LPARAM)&fgd); +// fgd.szPathT = CrashLogFolder; +// CallService(MS_FOLDERS_GET_PATH, (WPARAM)hCrashLogFolder, (LPARAM)&fgd); fgd.szPathT = VersionInfoFolder; CallService(MS_FOLDERS_GET_PATH, (WPARAM)hVerInfoFolder, (LPARAM)&fgd); @@ -215,21 +215,66 @@ static int ModulesLoaded(WPARAM, LPARAM) if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) { replaceStrT(profpath, _T("%miranda_userdata%")); - hCrashLogFolder = FoldersRegisterCustomPathT(PluginName, LPGEN("Crash Reports"), CrashLogFolder); + // Removed because it isn't available on Load() +// hCrashLogFolder = FoldersRegisterCustomPathT(PluginName, LPGEN("Crash Reports"), CrashLogFolder); hVerInfoFolder = FoldersRegisterCustomPathT(PluginName, LPGEN("Version Information"), VersionInfoFolder); HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersPathChanged); FoldersPathChanged(0, 0); } + SetExceptionHandler(); + + HookEvent(ME_TTB_MODULELOADED, ToolbarModulesLoaded); + + if (servicemode) + ViewVersionInfo(0, 0); + else if (db_get_b(NULL, PluginName, "UploadChanged", 0) && !ProcessVIHash(false)) + UploadVersionInfo(0, 0xa1); + + return 0; +} + +static int PreShutdown(WPARAM, LPARAM) +{ + DestroyAllWindows(); + UploadClose(); + return 0; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + if (LoadLibraryA("riched20.dll") == NULL) + return 1; + + clsdates = db_get_b(NULL, PluginName, "ClassicDates", 1) != 0; + + dtsubfldr = db_get_b(NULL, PluginName, "SubFolders", 1) != 0; + mir_getLP(&pluginInfoEx); + + profname = Utils_ReplaceVarsT(_T("%miranda_profilename%.dat")); + profpath = Utils_ReplaceVarsT(_T("%miranda_userdata%")); mir_sntprintf(CrashLogFolder, MAX_PATH, TEXT("%s\\CrashLog"), profpath); mir_sntprintf(VersionInfoFolder, MAX_PATH, TEXT("%s"), profpath); - SetExceptionHandler(); + HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); + HookEvent(ME_OPT_INITIALISE, OptionsInit); HookEvent(ME_TTB_MODULELOADED, ToolbarModulesLoaded); + HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown); - UploadInit(); + packlcid = (LCID)Langpack_GetDefaultLocale(); + + InitIcons(); + + InitExceptionHandler(); + + CreateServiceFunction(MS_CRASHDUMPER_STORETOFILE, StoreVersionInfoToFile); + CreateServiceFunction(MS_CRASHDUMPER_STORETOCLIP, StoreVersionInfoToClipboard); + CreateServiceFunction(MS_CRASHDUMPER_VIEWINFO, ViewVersionInfo); + CreateServiceFunction(MS_CRASHDUMPER_UPLOAD, UploadVersionInfo); + CreateServiceFunction(MS_CRASHDUMPER_URL, OpenUrl); + CreateServiceFunction(MS_SERVICEMODE_LAUNCH, ServiceModeLaunch); CLISTMENUITEM mi = { sizeof(mi) }; mi.popupPosition = 2000089999; @@ -302,53 +347,8 @@ static int ModulesLoaded(WPARAM, LPARAM) hk.pszName = "ShowVerInfo"; hk.pszService = MS_CRASHDUMPER_VIEWINFO; Hotkey_Register(&hk); - - if (servicemode) - ViewVersionInfo(0, 0); - else if (db_get_b(NULL, PluginName, "UploadChanged", 0) && !ProcessVIHash(false)) - UploadVersionInfo(0, 0xa1); - - CheckForOtherCrashReportingPlugins(); - return 0; -} - -static int PreShutdown(WPARAM, LPARAM) -{ - DestroyAllWindows(); - UploadClose(); - return 0; -} - -extern "C" int __declspec(dllexport) Load(void) -{ - if (LoadLibraryA("riched20.dll") == NULL) - return 1; - - clsdates = db_get_b(NULL, PluginName, "ClassicDates", 1) != 0; - - dtsubfldr = db_get_b(NULL, PluginName, "SubFolders", 1) != 0; - mir_getLP(&pluginInfoEx); - - profname = Utils_ReplaceVarsT(_T("%miranda_profilename%.dat")); - profpath = Utils_ReplaceVarsT(_T("%miranda_userdata%")); - - HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); - HookEvent(ME_OPT_INITIALISE, OptionsInit); - HookEvent(ME_TTB_MODULELOADED, ToolbarModulesLoaded); - HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown); - - packlcid = (LCID)Langpack_GetDefaultLocale(); - - InitIcons(); - - InitExceptionHandler(); - - CreateServiceFunction(MS_CRASHDUMPER_STORETOFILE, StoreVersionInfoToFile); - CreateServiceFunction(MS_CRASHDUMPER_STORETOCLIP, StoreVersionInfoToClipboard); - CreateServiceFunction(MS_CRASHDUMPER_VIEWINFO, ViewVersionInfo); - CreateServiceFunction(MS_CRASHDUMPER_UPLOAD, UploadVersionInfo); - CreateServiceFunction(MS_CRASHDUMPER_URL, OpenUrl); - CreateServiceFunction(MS_SERVICEMODE_LAUNCH, ServiceModeLaunch); + + UploadInit(); return 0; } diff --git a/plugins/CrashDumper/src/utils.cpp b/plugins/CrashDumper/src/utils.cpp index 4a8feb88b0..83e99f25c9 100644 --- a/plugins/CrashDumper/src/utils.cpp +++ b/plugins/CrashDumper/src/utils.cpp @@ -23,20 +23,6 @@ static HINSTANCE hKernel = GetModuleHandleA("kernel32.dll"); typedef BOOL (WINAPI *tGetProductInfo)(DWORD, DWORD, DWORD, DWORD, PDWORD); tGetProductInfo pGetProductInfo = (tGetProductInfo)GetProcAddress(hKernel, "GetProductInfo"); -void CheckForOtherCrashReportingPlugins(void) -{ - HMODULE hModule = GetModuleHandle(TEXT("attache.dll")); - if (hModule == NULL) - hModule = GetModuleHandle(TEXT("crashrpt.dll")); - if (hModule == NULL) - hModule = GetModuleHandle(TEXT("crashdmp.dll")); - - if (hModule == NULL) return; - - MessageBox(NULL, TranslateT("More then one crash reporting plugin installed. This will result in inability of creating crash reports"), - TEXT("Miranda Crash Dumper"), MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST); -} - void GetOSDisplayString(CMString &buffer) { OSVERSIONINFOEX osvi = { 0 }; diff --git a/plugins/CrashDumper/src/utils.h b/plugins/CrashDumper/src/utils.h index cbb540b039..c02f89abd1 100644 --- a/plugins/CrashDumper/src/utils.h +++ b/plugins/CrashDumper/src/utils.h @@ -139,7 +139,6 @@ void InitExceptionHandler(void); void DestroyExceptionHandler(void); void SetExceptionHandler(void); void RemoveExceptionHandler(void); -void CheckForOtherCrashReportingPlugins(void); INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -- cgit v1.2.3