remove useless dll housekeeping

This commit is contained in:
Duncan Ogilvie 2017-12-28 21:06:21 +01:00
parent 61cf4e8672
commit 2dd2cb1e3d
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
6 changed files with 8 additions and 31 deletions

View File

@ -32,7 +32,6 @@ namespace GleeBug
//map typedefs //map typedefs
typedef std::map<uint32, std::unique_ptr<Process>> ProcessMap; typedef std::map<uint32, std::unique_ptr<Process>> ProcessMap;
typedef std::map<Range, Dll, RangeCompare> DllMap;
typedef std::map<uint32, std::unique_ptr<Thread>> ThreadMap; typedef std::map<uint32, std::unique_ptr<Thread>> ThreadMap;
typedef std::map<BreakpointKey, BreakpointInfo> BreakpointMap; typedef std::map<BreakpointKey, BreakpointInfo> BreakpointMap;
typedef std::map<BreakpointKey, BreakpointCallback> BreakpointCallbackMap; typedef std::map<BreakpointKey, BreakpointCallback> BreakpointCallbackMap;

View File

@ -4,18 +4,8 @@ namespace GleeBug
{ {
void Debugger::loadDllEvent(const LOAD_DLL_DEBUG_INFO & loadDll) 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 //call the debug event callback
cbLoadDllEvent(loadDll, dll); cbLoadDllEvent(loadDll);
//close the file handle //close the file handle
if(loadDll.hFile) if(loadDll.hFile)
@ -25,15 +15,6 @@ namespace GleeBug
void Debugger::unloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll) void Debugger::unloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll)
{ {
//call the debug event callback //call the debug event callback
ptr lpBaseOfDll = ptr(unloadDll.lpBaseOfDll); cbUnloadDllEvent(unloadDll);
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);
} }
}; };

View File

@ -25,7 +25,6 @@ namespace GleeBug
bool permanentDep; bool permanentDep;
ThreadMap threads; ThreadMap threads;
DllMap dlls;
BreakpointMap breakpoints; BreakpointMap breakpoints;
SoftwareBreakpointMap softwareBreakpointReferences; SoftwareBreakpointMap softwareBreakpointReferences;
BreakpointCallbackMap breakpointCallbacks; BreakpointCallbackMap breakpointCallbacks;

View File

@ -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. \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 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. \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 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. \brief Exception debug event callback. Called before the event is internally processed. Provide an implementation to use this callback.

View File

@ -159,13 +159,13 @@ protected:
exitThread.dwExitCode); 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", printf("DLL loaded at 0x%p\n",
loadDll.lpBaseOfDll); 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", printf("DLL 0x%p unloaded\n",
unloadDll.lpBaseOfDll); unloadDll.lpBaseOfDll);

View File

@ -764,13 +764,13 @@ protected:
mCbEXITTHREAD(&exitThread); 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) if (mCbLOADDLL)
mCbLOADDLL(&loadDll); 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) if (mCbUNLOADDLL)
mCbUNLOADDLL(&unloadDll); mCbUNLOADDLL(&unloadDll);