better separation of code and definitions

This commit is contained in:
Mr. eXoDia 2015-03-28 03:45:48 +01:00
parent a3529f8b27
commit 30036a9fb6
9 changed files with 84 additions and 32 deletions

15
GleeBug/Debugger.Dll.cpp Normal file
View File

@ -0,0 +1,15 @@
#include "Debugger.Dll.h"
namespace GleeBug
{
DllInfo::DllInfo()
{
}
DllInfo::DllInfo(LPVOID lpBaseOfDll, DWORD sizeOfImage, LPVOID entryPoint)
{
this->lpBaseOfDll = (ULONG_PTR)lpBaseOfDll;
this->sizeOfImage = sizeOfImage;
this->entryPoint = (ULONG_PTR)entryPoint;
}
};

View File

@ -14,14 +14,8 @@ namespace GleeBug
DWORD sizeOfImage;
ULONG_PTR entryPoint;
DllInfo() {}
DllInfo(LPVOID lpBaseOfDll, DWORD sizeOfImage, LPVOID entryPoint)
{
this->lpBaseOfDll = (ULONG_PTR)lpBaseOfDll;
this->sizeOfImage = sizeOfImage;
this->entryPoint = (ULONG_PTR)entryPoint;
}
DllInfo();
DllInfo(LPVOID lpBaseOfDll, DWORD sizeOfImage, LPVOID entryPoint);
};
typedef std::map<Range, DllInfo, RangeCompare> DllMap;

View File

@ -5,9 +5,7 @@ namespace GleeBug
void Debugger::createProcessEvent(const CREATE_PROCESS_DEBUG_INFO & createProcess)
{
//process housekeeping
ProcessInfo process(createProcess.hProcess,
createProcess.hThread,
_debugEvent.dwProcessId,
ProcessInfo process(_debugEvent.dwProcessId,
_debugEvent.dwThreadId);
_processes.insert({ process.dwProcessId, process });
@ -41,7 +39,7 @@ namespace GleeBug
void Debugger::createThreadEvent(const CREATE_THREAD_DEBUG_INFO & createThread)
{
//thread housekeeping
ThreadInfo thread(_debugEvent.dwThreadId, createThread.hThread, createThread.lpThreadLocalBase, createThread.lpStartAddress);
ThreadInfo thread(_debugEvent.dwThreadId, createThread.lpThreadLocalBase, createThread.lpStartAddress);
_curProcess->threads.insert({ thread.dwThreadId, thread });
//set the current thread

View File

@ -0,0 +1,24 @@
#include "Debugger.Process.h"
namespace GleeBug
{
ProcessInfo::ProcessInfo()
{
this->curThread = nullptr;
this->hProcess = INVALID_HANDLE_VALUE;
}
ProcessInfo::ProcessInfo(DWORD dwProcessId, DWORD dwMainThreadId)
{
this->hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessId);
this->dwProcessId = dwProcessId;
this->dwMainThreadId = dwMainThreadId;
this->threads.clear();
}
ProcessInfo::~ProcessInfo()
{
if (this->hProcess != INVALID_HANDLE_VALUE)
CloseHandle(hProcess);
}
};

View File

@ -13,7 +13,6 @@ namespace GleeBug
struct ProcessInfo
{
HANDLE hProcess;
HANDLE hThread;
DWORD dwProcessId;
DWORD dwMainThreadId;
@ -21,16 +20,9 @@ namespace GleeBug
ThreadInfo* curThread;
DllMap dlls;
ProcessInfo() {} //fixes a 'no default constructor available' error
ProcessInfo(HANDLE hProcess, HANDLE hThread, DWORD dwProcessId, DWORD dwMainThreadId)
{
this->hProcess = hProcess;
this->hThread = hThread;
this->dwProcessId = dwProcessId;
this->dwMainThreadId = dwMainThreadId;
this->threads.clear();
}
ProcessInfo();
ProcessInfo(DWORD dwProcessId, DWORD dwMainThreadId);
~ProcessInfo();
};
typedef std::map<DWORD, ProcessInfo> ProcessMap;

View File

@ -0,0 +1,23 @@
#include "Debugger.Thread.h"
namespace GleeBug
{
ThreadInfo::ThreadInfo()
{
this->hThread = INVALID_HANDLE_VALUE;
}
ThreadInfo::ThreadInfo(DWORD dwThreadId, LPVOID lpThreadLocalBase, LPVOID lpStartAddress)
{
this->dwThreadId = dwThreadId;
this->hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, dwThreadId);
this->lpThreadLocalBase = (ULONG_PTR)lpThreadLocalBase;
this->lpStartAddress = (ULONG_PTR)lpStartAddress;
}
ThreadInfo::~ThreadInfo()
{
if (this->hThread != INVALID_HANDLE_VALUE)
CloseHandle(hThread);
}
};

View File

@ -15,15 +15,9 @@ namespace GleeBug
ULONG_PTR lpThreadLocalBase;
ULONG_PTR lpStartAddress;
ThreadInfo() {}
ThreadInfo(DWORD dwThreadId, HANDLE hThread, LPVOID lpThreadLocalBase, LPVOID lpStartAddress)
{
this->dwThreadId = dwThreadId;
this->hThread = hThread;
this->lpThreadLocalBase = (ULONG_PTR)lpThreadLocalBase;
this->lpStartAddress = (ULONG_PTR)lpStartAddress;
}
ThreadInfo();
ThreadInfo(DWORD dwThreadId, LPVOID lpThreadLocalBase, LPVOID lpStartAddress);
~ThreadInfo();
};
typedef std::map<DWORD, ThreadInfo> ThreadMap;

View File

@ -147,7 +147,10 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Debugger.cpp" />
<ClCompile Include="Debugger.Dll.cpp" />
<ClCompile Include="Debugger.Loop.cpp" />
<ClCompile Include="Debugger.Process.cpp" />
<ClCompile Include="Debugger.Thread.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Debugger.Dll.h" />

View File

@ -21,6 +21,15 @@
<ClCompile Include="Debugger.Loop.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Debugger.Thread.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Debugger.Process.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Debugger.Dll.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Debugger.h">