From 31d3a6408d045eadaff094d4c11bf017817743d7 Mon Sep 17 00:00:00 2001 From: sje Date: Wed, 1 Nov 2006 14:28:18 +0000 Subject: git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@4 4f64403b-2f21-0410-a795-97e2b3489a10 --- attache/MiniDump.cpp | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 attache/MiniDump.cpp (limited to 'attache/MiniDump.cpp') diff --git a/attache/MiniDump.cpp b/attache/MiniDump.cpp new file mode 100644 index 0000000..e565c10 --- /dev/null +++ b/attache/MiniDump.cpp @@ -0,0 +1,152 @@ +// MiniDump.cpp : Defines the entry point for the DLL application. +// + +#include "common.h" +#include "MiniDump.h" +#include "DebugTools.h" +#include "str_utils.h" +#include "options.h" + +HINSTANCE hInst = 0; +PLUGINLINK *pluginLink = 0; +HANDLE hNetlibUser = 0; + +MM_INTERFACE mmi; + +HANDLE hDumpPath = 0; +TCHAR stzDumpPath[MAX_PATH] = ""; + +DWORD mirandaVersion = 0; + +extern "C" BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { + DisableThreadLibraryCalls(hModule); + hInst = (HINSTANCE)hModule; + return TRUE; +} + +PLUGININFO pluginInfo={ + sizeof(PLUGININFO), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESC, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + 0, //not transient + 0 //doesn't replace anything built-in +}; + +extern "C" MINIDUMP_API PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +void InitNetlib() { + NETLIBUSER nl_user = {0}; + nl_user.cbSize = sizeof(nl_user); + nl_user.szSettingsModule = MODULE; + nl_user.flags = NUF_OUTGOING | NUF_HTTPCONNS; + nl_user.szDescriptiveName = MODULE; + + hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user); +} + +void DeinitNetlib() { + if(hNetlibUser) + CallService(MS_NETLIB_CLOSEHANDLE, (WPARAM)hNetlibUser, 0); +} + +int FoldersPathChanged(WPARAM wParam, LPARAM lParam) { + FOLDERSGETDATA fgd = {0}; + fgd.cbSize = sizeof(fgd); + fgd.nMaxPathSize = MAX_PATH; + + fgd.szPathT = stzDumpPath; + CallService(MS_FOLDERS_GET_PATH, (WPARAM)hDumpPath, (WPARAM)&fgd); + + return 0; +} + +int ModulesLoaded(WPARAM wParam, LPARAM lParam) { + InitNetlib(); + + if(ServiceExists(MS_UPDATE_REGISTER)) { + // register with updater + Update update = {0}; + char szVersion[16]; + + update.cbSize = sizeof(Update); + + update.szComponentName = pluginInfo.shortName; + update.pbVersion = (BYTE *)CreateVersionString(pluginInfo.version, szVersion); + update.cpbVersion = strlen((char *)update.pbVersion); + + update.szUpdateURL = UPDATER_AUTOREGISTER; + + // these are the three lines that matter - the archive, the page containing the version string, and the text (or data) + // before the version that we use to locate it on the page + // (note that if the update URL and the version URL point to standard file listing entries, the backend xml + // data will be used to check for updates rather than the actual web page - this is not true for beta urls) + update.szBetaUpdateURL = "http://www.scottellis.com.au/miranda_plugins/attache.zip"; + update.szBetaVersionURL = "http://www.scottellis.com.au/miranda_plugins/ver_attache.html"; + update.pbBetaVersionPrefix = (BYTE *)"Attache version "; + + update.cpbBetaVersionPrefix = strlen((char *)update.pbBetaVersionPrefix); + + CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update); + } + + if(ServiceExists(MS_FOLDERS_GET_PATH)) { + FOLDERSDATA fd = {0}; + fd.cbSize = sizeof(fd); +#ifdef _UNICODE + fd.flags = FF_UNICODE; +#endif + strncpy(fd.szSection, Translate("Attache"), 64); + + strncpy(fd.szName, Translate("Crash Dumps"), 64); + fd.szFormatT = _T(PROFILE_PATH) _T(DEFAULT_DUMP_PATH); + hDumpPath = (HANDLE)CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM)&fd); + + HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersPathChanged); + FoldersPathChanged(0, 0); + } + + return 0; +} + +extern "C" MINIDUMP_API int Load(PLUGINLINK *link) { + pluginLink = link; + + InitializeDebug(); + + mmi.cbSize = sizeof(mmi); + CallService(MS_SYSTEM_GET_MMI, 0, (LPARAM)&mmi); + + LoadOptions(); + set_codepage(); + + mirandaVersion = CallService(MS_SYSTEM_GETVERSION, 0, 0); + + HookEvent(ME_OPT_INITIALISE, OptInit); + + HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); + + SetErrorMode(SEM_NOGPFAULTERRORBOX); + +//#define CRASH_ME +#ifdef CRASH_ME + // test crash + int *i = 0; + *i = 10; +#endif + + return 0; +} + +extern "C" MINIDUMP_API int Unload() { + UninitializeDebug(); + DeinitNetlib(); + return 0; +} -- cgit v1.2.3