From fcaef90fd4f92d78be230f6b9f40005ced72a415 Mon Sep 17 00:00:00 2001 From: panikon Date: Fri, 4 Jul 2014 07:19:47 -0300 Subject: Ported dbghelp to HPM --- src/plugins/dbghelpplug.c | 69 ++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 43 deletions(-) (limited to 'src/plugins/dbghelpplug.c') diff --git a/src/plugins/dbghelpplug.c b/src/plugins/dbghelpplug.c index 0f1690f4b..108922bdd 100644 --- a/src/plugins/dbghelpplug.c +++ b/src/plugins/dbghelpplug.c @@ -1,20 +1,28 @@ // Copyright (c) Hercules Dev Team, licensed under GNU GPL. -// Ported from eAthena Dev Team's version @ http://eathena-project.googlecode.com/svn/trunk/src/plugins/dbghelpplug.c // See the LICENSE file -// dbghelpplug.dll Hercules Plugin +// Portions Copyright (c) Athena Dev Teams + +// Ported from eAthena Dev Team's version @ http://eathena-project.googlecode.com/svn/trunk/src/plugins/dbghelpplug.c #include #include #include "../common/HPMi.h" +#include "../common/HPMDataCheck.h" + +/** + * Plugin basic information + **/ HPExport struct hplugin_info pinfo = { - "DBGHelpPlug", // Plugin name - SERVER_TYPE_MAP,// Which server types this plugin works with? - "0.3", // Plugin version - HPM_VERSION, // HPM Version (don't change, macro is automatically updated) + "Debug Help", + SERVER_TYPE_ALL, + "0.4", + HPM_VERSION, }; -#ifdef _WIN32 +#ifndef WIN32 +#error This plugin is only compatible with windows! +#endif ///////////////////////////////////////////////////////////////////// // Include files @@ -1767,49 +1775,24 @@ Dhp__UnhandledExceptionFilter(PEXCEPTION_POINTERS ptrs) return EXCEPTION_EXECUTE_HANDLER; } - ///////////////////////////////////////////////////////////////////// -// DLL stuff -#if !defined(DBG_EMBEDDED) +// Plugin /// Previous exception filter. static LPTOP_LEVEL_EXCEPTION_FILTER previousFilter; -#if defined(__GNUC__) -// GNU : define DLL load/unload functions -static void Dhp__OnStartup(void) __attribute__((constructor)); -static void Dhp__OnExit(void) __attribute__((destructor)); -#endif /* defined(__GNUC__) */ - -/// Installs as the unhandled exception handler. -void Dhp__OnStartup(void) -{ - // Install the unhandled exception filter function +/** + * Initializes plugin + * Installs a new unhandled exception filter (Dhp__UnhandledExceptionFilter) + **/ +HPExport void plugin_init (void) { previousFilter = SetUnhandledExceptionFilter(Dhp__UnhandledExceptionFilter); } -/// Uninstalls the handler. -void Dhp__OnExit(void) -{ +/** + * Finalizes plugin + * Uninstalls the handler + **/ +HPExport void plugin_final (void) { SetUnhandledExceptionFilter(previousFilter); } - -#if !defined(__GNUC__) -// Windows : invoke DLL load/unload functions -BOOL APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) -{ - switch( dwReason ) - { - case DLL_PROCESS_ATTACH: Dhp__OnStartup(); break; - case DLL_PROCESS_DETACH: Dhp__OnExit(); break; - } - return TRUE; -} -#endif /* !defined(__GNUC__) */ -#endif /* !defined(DBG_EMBEDDED) */ - -HPExport void plugin_init (void) { -} - -#endif /* _WIN32 */ - -- cgit v1.2.3-60-g2f50