From 2dd2cb1e3dc945f8669cd761e9db1d37cdada792 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Thu, 28 Dec 2017 21:06:21 +0100 Subject: [PATCH] remove useless dll housekeeping --- GleeBug/Debugger.Global.h | 1 - GleeBug/Debugger.Loop.Dll.cpp | 23 ++--------------------- GleeBug/Debugger.Process.h | 1 - GleeBug/Debugger.h | 6 ++---- MyDebugger/MyDebugger.h | 4 ++-- TitanEngineEmulator/Emulator.h | 4 ++-- 6 files changed, 8 insertions(+), 31 deletions(-) diff --git a/GleeBug/Debugger.Global.h b/GleeBug/Debugger.Global.h index 3ffc3e3..534f48e 100644 --- a/GleeBug/Debugger.Global.h +++ b/GleeBug/Debugger.Global.h @@ -32,7 +32,6 @@ namespace GleeBug //map typedefs typedef std::map> ProcessMap; - typedef std::map DllMap; typedef std::map> ThreadMap; typedef std::map BreakpointMap; typedef std::map BreakpointCallbackMap; diff --git a/GleeBug/Debugger.Loop.Dll.cpp b/GleeBug/Debugger.Loop.Dll.cpp index 1603180..c559623 100644 --- a/GleeBug/Debugger.Loop.Dll.cpp +++ b/GleeBug/Debugger.Loop.Dll.cpp @@ -4,18 +4,8 @@ namespace GleeBug { void Debugger::loadDllEvent(const LOAD_DLL_DEBUG_INFO & loadDll) { - //DLL housekeeping - MODULEINFO modinfo; - memset(&modinfo, 0, sizeof(MODULEINFO)); - GetModuleInformation(mProcess->hProcess, - HMODULE(loadDll.lpBaseOfDll), - &modinfo, - sizeof(MODULEINFO)); - Dll dll(loadDll.lpBaseOfDll, modinfo.SizeOfImage, modinfo.EntryPoint, loadDll); - mProcess->dlls.insert({ Range(dll.lpBaseOfDll, dll.lpBaseOfDll + dll.sizeOfImage - 1), dll }); - //call the debug event callback - cbLoadDllEvent(loadDll, dll); + cbLoadDllEvent(loadDll); //close the file handle if(loadDll.hFile) @@ -25,15 +15,6 @@ namespace GleeBug void Debugger::unloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll) { //call the debug event callback - ptr lpBaseOfDll = ptr(unloadDll.lpBaseOfDll); - auto dll = mProcess->dlls.find(Range(lpBaseOfDll, lpBaseOfDll)); - if (dll != mProcess->dlls.end()) - cbUnloadDllEvent(unloadDll, dll->second); - else - cbUnloadDllEvent(unloadDll, Dll(unloadDll.lpBaseOfDll, 0, nullptr, LOAD_DLL_DEBUG_INFO())); - - //DLL housekeeping - if (dll != mProcess->dlls.end()) - mProcess->dlls.erase(dll); + cbUnloadDllEvent(unloadDll); } }; \ No newline at end of file diff --git a/GleeBug/Debugger.Process.h b/GleeBug/Debugger.Process.h index 2321247..77c1161 100644 --- a/GleeBug/Debugger.Process.h +++ b/GleeBug/Debugger.Process.h @@ -25,7 +25,6 @@ namespace GleeBug bool permanentDep; ThreadMap threads; - DllMap dlls; BreakpointMap breakpoints; SoftwareBreakpointMap softwareBreakpointReferences; BreakpointCallbackMap breakpointCallbacks; diff --git a/GleeBug/Debugger.h b/GleeBug/Debugger.h index 4088115..8b44897 100644 --- a/GleeBug/Debugger.h +++ b/GleeBug/Debugger.h @@ -123,16 +123,14 @@ namespace GleeBug /** \brief DLL load debug event callback. Called after event is internally processed. Provide an implementation to use this callback. \param loadDll Information about the DLL loaded. - \param dll Dll of the loaded DLL. */ - virtual void cbLoadDllEvent(const LOAD_DLL_DEBUG_INFO & loadDll, const Dll & dll) {}; + virtual void cbLoadDllEvent(const LOAD_DLL_DEBUG_INFO & loadDll) {}; /** \brief DLL unload debug event callback. Called before event is internally processed. Provide an implementation to use this callback. \param unloadDll Information about the DLL unloaded. - \param dll Dll of the unloaded DLL. */ - virtual void cbUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll, const Dll & dll) {}; + virtual void cbUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll) {}; /** \brief Exception debug event callback. Called before the event is internally processed. Provide an implementation to use this callback. diff --git a/MyDebugger/MyDebugger.h b/MyDebugger/MyDebugger.h index b2253b5..80b777d 100644 --- a/MyDebugger/MyDebugger.h +++ b/MyDebugger/MyDebugger.h @@ -159,13 +159,13 @@ protected: exitThread.dwExitCode); } - void cbLoadDllEvent(const LOAD_DLL_DEBUG_INFO & loadDll, const Dll & dll) override + void cbLoadDllEvent(const LOAD_DLL_DEBUG_INFO & loadDll) override { printf("DLL loaded at 0x%p\n", loadDll.lpBaseOfDll); } - void cbUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll, const Dll & dll) override + void cbUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll) override { printf("DLL 0x%p unloaded\n", unloadDll.lpBaseOfDll); diff --git a/TitanEngineEmulator/Emulator.h b/TitanEngineEmulator/Emulator.h index d6b15bb..efff014 100644 --- a/TitanEngineEmulator/Emulator.h +++ b/TitanEngineEmulator/Emulator.h @@ -764,13 +764,13 @@ protected: mCbEXITTHREAD(&exitThread); } - void cbLoadDllEvent(const LOAD_DLL_DEBUG_INFO & loadDll, const Dll & dll) override + void cbLoadDllEvent(const LOAD_DLL_DEBUG_INFO & loadDll) override { if (mCbLOADDLL) mCbLOADDLL(&loadDll); } - void cbUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll, const Dll & dll) override + void cbUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll) override { if (mCbUNLOADDLL) mCbUNLOADDLL(&unloadDll);