mirror of https://github.com/x64dbg/GleeBug
better separation of code and definitions
This commit is contained in:
parent
a3529f8b27
commit
30036a9fb6
|
|
@ -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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -14,14 +14,8 @@ namespace GleeBug
|
||||||
DWORD sizeOfImage;
|
DWORD sizeOfImage;
|
||||||
ULONG_PTR entryPoint;
|
ULONG_PTR entryPoint;
|
||||||
|
|
||||||
DllInfo() {}
|
DllInfo();
|
||||||
|
DllInfo(LPVOID lpBaseOfDll, DWORD sizeOfImage, LPVOID entryPoint);
|
||||||
DllInfo(LPVOID lpBaseOfDll, DWORD sizeOfImage, LPVOID entryPoint)
|
|
||||||
{
|
|
||||||
this->lpBaseOfDll = (ULONG_PTR)lpBaseOfDll;
|
|
||||||
this->sizeOfImage = sizeOfImage;
|
|
||||||
this->entryPoint = (ULONG_PTR)entryPoint;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<Range, DllInfo, RangeCompare> DllMap;
|
typedef std::map<Range, DllInfo, RangeCompare> DllMap;
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,7 @@ namespace GleeBug
|
||||||
void Debugger::createProcessEvent(const CREATE_PROCESS_DEBUG_INFO & createProcess)
|
void Debugger::createProcessEvent(const CREATE_PROCESS_DEBUG_INFO & createProcess)
|
||||||
{
|
{
|
||||||
//process housekeeping
|
//process housekeeping
|
||||||
ProcessInfo process(createProcess.hProcess,
|
ProcessInfo process(_debugEvent.dwProcessId,
|
||||||
createProcess.hThread,
|
|
||||||
_debugEvent.dwProcessId,
|
|
||||||
_debugEvent.dwThreadId);
|
_debugEvent.dwThreadId);
|
||||||
_processes.insert({ process.dwProcessId, process });
|
_processes.insert({ process.dwProcessId, process });
|
||||||
|
|
||||||
|
|
@ -41,7 +39,7 @@ namespace GleeBug
|
||||||
void Debugger::createThreadEvent(const CREATE_THREAD_DEBUG_INFO & createThread)
|
void Debugger::createThreadEvent(const CREATE_THREAD_DEBUG_INFO & createThread)
|
||||||
{
|
{
|
||||||
//thread housekeeping
|
//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 });
|
_curProcess->threads.insert({ thread.dwThreadId, thread });
|
||||||
|
|
||||||
//set the current thread
|
//set the current thread
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -13,7 +13,6 @@ namespace GleeBug
|
||||||
struct ProcessInfo
|
struct ProcessInfo
|
||||||
{
|
{
|
||||||
HANDLE hProcess;
|
HANDLE hProcess;
|
||||||
HANDLE hThread;
|
|
||||||
DWORD dwProcessId;
|
DWORD dwProcessId;
|
||||||
DWORD dwMainThreadId;
|
DWORD dwMainThreadId;
|
||||||
|
|
||||||
|
|
@ -21,16 +20,9 @@ namespace GleeBug
|
||||||
ThreadInfo* curThread;
|
ThreadInfo* curThread;
|
||||||
DllMap dlls;
|
DllMap dlls;
|
||||||
|
|
||||||
ProcessInfo() {} //fixes a 'no default constructor available' error
|
ProcessInfo();
|
||||||
|
ProcessInfo(DWORD dwProcessId, DWORD dwMainThreadId);
|
||||||
ProcessInfo(HANDLE hProcess, HANDLE hThread, DWORD dwProcessId, DWORD dwMainThreadId)
|
~ProcessInfo();
|
||||||
{
|
|
||||||
this->hProcess = hProcess;
|
|
||||||
this->hThread = hThread;
|
|
||||||
this->dwProcessId = dwProcessId;
|
|
||||||
this->dwMainThreadId = dwMainThreadId;
|
|
||||||
this->threads.clear();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<DWORD, ProcessInfo> ProcessMap;
|
typedef std::map<DWORD, ProcessInfo> ProcessMap;
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -15,15 +15,9 @@ namespace GleeBug
|
||||||
ULONG_PTR lpThreadLocalBase;
|
ULONG_PTR lpThreadLocalBase;
|
||||||
ULONG_PTR lpStartAddress;
|
ULONG_PTR lpStartAddress;
|
||||||
|
|
||||||
ThreadInfo() {}
|
ThreadInfo();
|
||||||
|
ThreadInfo(DWORD dwThreadId, LPVOID lpThreadLocalBase, LPVOID lpStartAddress);
|
||||||
ThreadInfo(DWORD dwThreadId, HANDLE hThread, LPVOID lpThreadLocalBase, LPVOID lpStartAddress)
|
~ThreadInfo();
|
||||||
{
|
|
||||||
this->dwThreadId = dwThreadId;
|
|
||||||
this->hThread = hThread;
|
|
||||||
this->lpThreadLocalBase = (ULONG_PTR)lpThreadLocalBase;
|
|
||||||
this->lpStartAddress = (ULONG_PTR)lpStartAddress;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<DWORD, ThreadInfo> ThreadMap;
|
typedef std::map<DWORD, ThreadInfo> ThreadMap;
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,10 @@
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Debugger.cpp" />
|
<ClCompile Include="Debugger.cpp" />
|
||||||
|
<ClCompile Include="Debugger.Dll.cpp" />
|
||||||
<ClCompile Include="Debugger.Loop.cpp" />
|
<ClCompile Include="Debugger.Loop.cpp" />
|
||||||
|
<ClCompile Include="Debugger.Process.cpp" />
|
||||||
|
<ClCompile Include="Debugger.Thread.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Debugger.Dll.h" />
|
<ClInclude Include="Debugger.Dll.h" />
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,15 @@
|
||||||
<ClCompile Include="Debugger.Loop.cpp">
|
<ClCompile Include="Debugger.Loop.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Debugger.h">
|
<ClInclude Include="Debugger.h">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue