renamed some shit

This commit is contained in:
mrexodia 2016-01-10 22:34:18 +01:00
parent fcc69d311b
commit da7988c71f
16 changed files with 79 additions and 79 deletions

View File

@ -2,7 +2,7 @@
namespace GleeBug namespace GleeBug
{ {
DllInfo::DllInfo(LPVOID lpBaseOfDll, ptr sizeOfImage, LPVOID entryPoint) : Dll::Dll(LPVOID lpBaseOfDll, ptr sizeOfImage, LPVOID entryPoint) :
lpBaseOfDll(ptr(lpBaseOfDll)), lpBaseOfDll(ptr(lpBaseOfDll)),
sizeOfImage(sizeOfImage), sizeOfImage(sizeOfImage),
entryPoint(ptr(entryPoint)) entryPoint(ptr(entryPoint))

View File

@ -8,7 +8,7 @@ namespace GleeBug
/** /**
\brief DLL information structure. \brief DLL information structure.
*/ */
class DllInfo class Dll
{ {
public: public:
ptr lpBaseOfDll; ptr lpBaseOfDll;
@ -21,7 +21,7 @@ namespace GleeBug
\param sizeOfImage Size of the image. \param sizeOfImage Size of the image.
\param entryPoint The entry point. \param entryPoint The entry point.
*/ */
explicit DllInfo(LPVOID lpBaseOfDll, ptr sizeOfImage, LPVOID entryPoint); explicit Dll(LPVOID lpBaseOfDll, ptr sizeOfImage, LPVOID entryPoint);
}; };
}; };

View File

@ -10,9 +10,9 @@ namespace GleeBug
{ {
//forward declarations //forward declarations
class Debugger; class Debugger;
class ProcessInfo; class Process;
class DllInfo; class Dll;
class ThreadInfo; class Thread;
enum class BreakpointType; enum class BreakpointType;
struct BreakpointInfo; struct BreakpointInfo;
@ -27,9 +27,9 @@ namespace GleeBug
typedef std::function<void(const BreakpointInfo & info)> BreakpointCallback; typedef std::function<void(const BreakpointInfo & info)> BreakpointCallback;
//map typedefs //map typedefs
typedef std::map<uint32, ProcessInfo> ProcessMap; typedef std::map<uint32, Process> ProcessMap;
typedef std::map<Range, DllInfo, RangeCompare> DllMap; typedef std::map<Range, Dll, RangeCompare> DllMap;
typedef std::map<uint32, ThreadInfo> ThreadMap; typedef std::map<uint32, 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;
typedef std::unordered_map<ptr, BreakpointMap::iterator> SoftwareBreakpointMap; typedef std::unordered_map<ptr, BreakpointMap::iterator> SoftwareBreakpointMap;

View File

@ -11,7 +11,7 @@ namespace GleeBug
HMODULE(loadDll.lpBaseOfDll), HMODULE(loadDll.lpBaseOfDll),
&modinfo, &modinfo,
sizeof(MODULEINFO)); sizeof(MODULEINFO));
DllInfo dll(loadDll.lpBaseOfDll, modinfo.SizeOfImage, modinfo.EntryPoint); Dll dll(loadDll.lpBaseOfDll, modinfo.SizeOfImage, modinfo.EntryPoint);
mProcess->dlls.insert({ Range(dll.lpBaseOfDll, dll.lpBaseOfDll + dll.sizeOfImage - 1), dll }); mProcess->dlls.insert({ Range(dll.lpBaseOfDll, dll.lpBaseOfDll + dll.sizeOfImage - 1), dll });
//call the debug event callback //call the debug event callback
@ -29,7 +29,7 @@ namespace GleeBug
if (dll != mProcess->dlls.end()) if (dll != mProcess->dlls.end())
cbUnloadDllEvent(unloadDll, dll->second); cbUnloadDllEvent(unloadDll, dll->second);
else else
cbUnloadDllEvent(unloadDll, DllInfo(unloadDll.lpBaseOfDll, 0, nullptr)); cbUnloadDllEvent(unloadDll, Dll(unloadDll.lpBaseOfDll, 0, nullptr));
//DLL housekeeping //DLL housekeeping
if (dll != mProcess->dlls.end()) if (dll != mProcess->dlls.end())

View File

@ -6,14 +6,14 @@ namespace GleeBug
{ {
//process housekeeping //process housekeeping
mProcesses.insert({ mDebugEvent.dwProcessId, mProcesses.insert({ mDebugEvent.dwProcessId,
ProcessInfo(createProcess.hProcess, Process(createProcess.hProcess,
mDebugEvent.dwProcessId, mDebugEvent.dwProcessId,
mDebugEvent.dwThreadId) }); mDebugEvent.dwThreadId) });
mProcess = &mProcesses.find(mDebugEvent.dwProcessId)->second; mProcess = &mProcesses.find(mDebugEvent.dwProcessId)->second;
//thread housekeeping (main thread is created implicitly) //thread housekeeping (main thread is created implicitly)
mProcess->threads.insert({ mDebugEvent.dwThreadId, mProcess->threads.insert({ mDebugEvent.dwThreadId,
ThreadInfo(createProcess.hThread, Thread(createProcess.hThread,
mDebugEvent.dwThreadId, mDebugEvent.dwThreadId,
createProcess.lpThreadLocalBase, createProcess.lpThreadLocalBase,
createProcess.lpStartAddress) }); createProcess.lpStartAddress) });
@ -22,7 +22,7 @@ namespace GleeBug
//read thread context from main thread //read thread context from main thread
if (!mThread->RegReadContext()) if (!mThread->RegReadContext())
cbInternalError("ThreadInfo::RegReadContext() failed!"); cbInternalError("Thread::RegReadContext() failed!");
//call the debug event callback //call the debug event callback
cbCreateProcessEvent(createProcess, *mProcess); cbCreateProcessEvent(createProcess, *mProcess);

View File

@ -6,7 +6,7 @@ namespace GleeBug
{ {
//thread housekeeping //thread housekeeping
mProcess->threads.insert({ mDebugEvent.dwThreadId, mProcess->threads.insert({ mDebugEvent.dwThreadId,
ThreadInfo(createThread.hThread, Thread(createThread.hThread,
mDebugEvent.dwThreadId, mDebugEvent.dwThreadId,
createThread.lpThreadLocalBase, createThread.lpThreadLocalBase,
createThread.lpStartAddress) }); createThread.lpStartAddress) });
@ -15,7 +15,7 @@ namespace GleeBug
mThread = mProcess->thread = &mProcess->threads.find(mDebugEvent.dwThreadId)->second; mThread = mProcess->thread = &mProcess->threads.find(mDebugEvent.dwThreadId)->second;
mRegisters = &mThread->registers; mRegisters = &mThread->registers;
if (!mThread->RegReadContext()) if (!mThread->RegReadContext())
cbInternalError("ThreadInfo::RegReadContext() failed!"); cbInternalError("Thread::RegReadContext() failed!");
//call the debug event callback //call the debug event callback
cbCreateThreadEvent(createThread, *mThread); cbCreateThreadEvent(createThread, *mThread);

View File

@ -2,7 +2,7 @@
namespace GleeBug namespace GleeBug
{ {
bool ProcessInfo::SetBreakpoint(ptr address, bool singleshoot, SoftwareType type) bool Process::SetBreakpoint(ptr address, bool singleshoot, SoftwareType type)
{ {
//check the address //check the address
if (!MemIsValidPtr(address) || if (!MemIsValidPtr(address) ||
@ -43,7 +43,7 @@ namespace GleeBug
return true; return true;
} }
bool ProcessInfo::SetBreakpoint(ptr address, const BreakpointCallback & cbBreakpoint, bool singleshoot, SoftwareType type) bool Process::SetBreakpoint(ptr address, const BreakpointCallback & cbBreakpoint, bool singleshoot, SoftwareType type)
{ {
//check if a callback on this address was already found //check if a callback on this address was already found
if (breakpointCallbacks.find({ BreakpointType::Software, address }) != breakpointCallbacks.end()) if (breakpointCallbacks.find({ BreakpointType::Software, address }) != breakpointCallbacks.end())
@ -56,7 +56,7 @@ namespace GleeBug
return true; return true;
} }
bool ProcessInfo::DeleteBreakpoint(ptr address) bool Process::DeleteBreakpoint(ptr address)
{ {
//find the breakpoint //find the breakpoint
auto found = breakpoints.find({ BreakpointType::Software, address }); auto found = breakpoints.find({ BreakpointType::Software, address });
@ -79,7 +79,7 @@ namespace GleeBug
return true; return true;
} }
bool ProcessInfo::GetFreeHardwareBreakpointSlot(HardwareSlot & slot) const bool Process::GetFreeHardwareBreakpointSlot(HardwareSlot & slot) const
{ {
//find a free hardware breakpoint slot //find a free hardware breakpoint slot
for (int i = 0; i < HWBP_COUNT; i++) for (int i = 0; i < HWBP_COUNT; i++)
@ -93,7 +93,7 @@ namespace GleeBug
return false; return false;
} }
bool ProcessInfo::SetHardwareBreakpoint(ptr address, HardwareSlot slot, HardwareType type, HardwareSize size, bool singleshoot) bool Process::SetHardwareBreakpoint(ptr address, HardwareSlot slot, HardwareType type, HardwareSize size, bool singleshoot)
{ {
//check the address //check the address
if (!MemIsValidPtr(address) || if (!MemIsValidPtr(address) ||
@ -138,7 +138,7 @@ namespace GleeBug
return true; return true;
} }
bool ProcessInfo::SetHardwareBreakpoint(ptr address, HardwareSlot slot, const BreakpointCallback & cbBreakpoint, HardwareType type, HardwareSize size, bool singleshoot) bool Process::SetHardwareBreakpoint(ptr address, HardwareSlot slot, const BreakpointCallback & cbBreakpoint, HardwareType type, HardwareSize size, bool singleshoot)
{ {
//check if a callback on this address was already found //check if a callback on this address was already found
if (breakpointCallbacks.find({ BreakpointType::Hardware, address }) != breakpointCallbacks.end()) if (breakpointCallbacks.find({ BreakpointType::Hardware, address }) != breakpointCallbacks.end())
@ -151,7 +151,7 @@ namespace GleeBug
return true; return true;
} }
bool ProcessInfo::DeleteHardwareBreakpoint(ptr address) bool Process::DeleteHardwareBreakpoint(ptr address)
{ {
//find the hardware breakpoint //find the hardware breakpoint
auto found = breakpoints.find({ BreakpointType::Hardware, address }); auto found = breakpoints.find({ BreakpointType::Hardware, address });
@ -176,7 +176,7 @@ namespace GleeBug
return success; return success;
} }
bool ProcessInfo::DeleteGenericBreakpoint(const BreakpointInfo & info) bool Process::DeleteGenericBreakpoint(const BreakpointInfo & info)
{ {
switch (info.type) switch (info.type)
{ {

View File

@ -2,7 +2,7 @@
namespace GleeBug namespace GleeBug
{ {
bool ProcessInfo::MemRead(ptr address, void* buffer, ptr size, ptr* bytesRead) const bool Process::MemRead(ptr address, void* buffer, ptr size, ptr* bytesRead) const
{ {
ptr read; ptr read;
if (!bytesRead) if (!bytesRead)
@ -10,7 +10,7 @@ namespace GleeBug
return !!ReadProcessMemory(this->hProcess, reinterpret_cast<const void*>(address), buffer, size, (SIZE_T*)bytesRead); return !!ReadProcessMemory(this->hProcess, reinterpret_cast<const void*>(address), buffer, size, (SIZE_T*)bytesRead);
} }
bool ProcessInfo::MemReadSafe(ptr address, void* buffer, ptr size, ptr* bytesRead) const bool Process::MemReadSafe(ptr address, void* buffer, ptr size, ptr* bytesRead) const
{ {
if (!MemRead(address, buffer, size, bytesRead)) if (!MemRead(address, buffer, size, bytesRead))
return false; return false;
@ -54,7 +54,7 @@ namespace GleeBug
return true; return true;
} }
bool ProcessInfo::MemWrite(ptr address, const void* buffer, ptr size, ptr* bytesWritten) bool Process::MemWrite(ptr address, const void* buffer, ptr size, ptr* bytesWritten)
{ {
ptr written; ptr written;
if (!bytesWritten) if (!bytesWritten)
@ -62,12 +62,12 @@ namespace GleeBug
return !!WriteProcessMemory(this->hProcess, reinterpret_cast<void*>(address), buffer, size, (SIZE_T*)bytesWritten); return !!WriteProcessMemory(this->hProcess, reinterpret_cast<void*>(address), buffer, size, (SIZE_T*)bytesWritten);
} }
bool ProcessInfo::MemWriteSafe(ptr address, const void* buffer, ptr size, ptr* bytesWritten) bool Process::MemWriteSafe(ptr address, const void* buffer, ptr size, ptr* bytesWritten)
{ {
return false; return false;
} }
bool ProcessInfo::MemIsValidPtr(ptr address) const bool Process::MemIsValidPtr(ptr address) const
{ {
uint8 byte; uint8 byte;
return MemRead(address, &byte, sizeof(byte)); return MemRead(address, &byte, sizeof(byte));

View File

@ -2,7 +2,7 @@
namespace GleeBug namespace GleeBug
{ {
ProcessInfo::ProcessInfo(HANDLE hProcess, uint32 dwProcessId, uint32 dwMainThreadId) : Process::Process(HANDLE hProcess, uint32 dwProcessId, uint32 dwMainThreadId) :
hProcess(hProcess), hProcess(hProcess),
dwProcessId(dwProcessId), dwProcessId(dwProcessId),
dwMainThreadId(dwMainThreadId), dwMainThreadId(dwMainThreadId),

View File

@ -11,14 +11,14 @@ namespace GleeBug
/** /**
\brief Process information structure. \brief Process information structure.
*/ */
class ProcessInfo class Process
{ {
public: public:
HANDLE hProcess; HANDLE hProcess;
uint32 dwProcessId; uint32 dwProcessId;
uint32 dwMainThreadId; uint32 dwMainThreadId;
ThreadInfo* thread; Thread* thread;
bool systemBreakpoint; bool systemBreakpoint;
ThreadMap threads; //DO NOT COPY THESE OBJECTS! ThreadMap threads; //DO NOT COPY THESE OBJECTS!
@ -34,7 +34,7 @@ namespace GleeBug
\param dwProcessId Identifier for the process. \param dwProcessId Identifier for the process.
\param dwMainThreadId Identifier for the main thread. \param dwMainThreadId Identifier for the main thread.
*/ */
explicit ProcessInfo(HANDLE hProcess, uint32 dwProcessId, uint32 dwMainThreadId); explicit Process(HANDLE hProcess, uint32 dwProcessId, uint32 dwMainThreadId);
/** /**
\brief Read memory from the process. \brief Read memory from the process.
@ -136,7 +136,7 @@ namespace GleeBug
/** /**
\brief Sets a hardware breakpoint. \brief Sets a hardware breakpoint.
\param address The address to set the hardware breakpoint on. \param address The address to set the hardware breakpoint on.
\param slot The hardware breakpoint register slot. Use ProcessInfo::GetFreeHardwareBreakpointSlot. \param slot The hardware breakpoint register slot. Use Process::GetFreeHardwareBreakpointSlot.
\param type (Optional) The hardware breakpoint type. \param type (Optional) The hardware breakpoint type.
\param size (Optional) The hardware breakpoint size. \param size (Optional) The hardware breakpoint size.
\param singleshoot (Optional) True to remove the breakpoint after the first hit. \param singleshoot (Optional) True to remove the breakpoint after the first hit.
@ -147,7 +147,7 @@ namespace GleeBug
/** /**
\brief Sets a hardware breakpoint. \brief Sets a hardware breakpoint.
\param address The address to set the hardware breakpoint on. \param address The address to set the hardware breakpoint on.
\param slot The hardware breakpoint register slot. Use ProcessInfo::GetFreeHardwareBreakpointSlot. \param slot The hardware breakpoint register slot. Use Process::GetFreeHardwareBreakpointSlot.
\param cbBreakpoint The breakpoint callback. Can be written using BIND1(this, MyDebugger::cb). \param cbBreakpoint The breakpoint callback. Can be written using BIND1(this, MyDebugger::cb).
\param type (Optional) The hardware breakpoint type. \param type (Optional) The hardware breakpoint type.
\param size (Optional) The hardware breakpoint size. \param size (Optional) The hardware breakpoint size.
@ -160,7 +160,7 @@ namespace GleeBug
\brief Sets a hardware breakpoint. \brief Sets a hardware breakpoint.
\tparam T Generic type parameter. Must be a subclass of Debugger. \tparam T Generic type parameter. Must be a subclass of Debugger.
\param address The address to set the hardware breakpoint on. \param address The address to set the hardware breakpoint on.
\param slot The hardware breakpoint register slot. Use ProcessInfo::GetFreeHardwareBreakpointSlot. \param slot The hardware breakpoint register slot. Use Process::GetFreeHardwareBreakpointSlot.
\param debugger This pointer to a subclass of Debugger. \param debugger This pointer to a subclass of Debugger.
\param callback Pointer to the callback. Written like: &MyDebugger::cb \param callback Pointer to the callback. Written like: &MyDebugger::cb
\param type (Optional) The hardware breakpoint type. \param type (Optional) The hardware breakpoint type.

View File

@ -180,7 +180,7 @@ namespace GleeBug
} }
} }
bool ThreadInfo::SetHardwareBreakpoint(ptr address, HardwareSlot slot, HardwareType type, HardwareSize size) bool Thread::SetHardwareBreakpoint(ptr address, HardwareSlot slot, HardwareType type, HardwareSize size)
{ {
//check if the alignment is correct //check if the alignment is correct
if ((address % int(size) != 0)) if ((address % int(size) != 0))
@ -216,7 +216,7 @@ namespace GleeBug
return true; return true;
} }
bool ThreadInfo::DeleteHardwareBreakpoint(HardwareSlot slot) bool Thread::DeleteHardwareBreakpoint(HardwareSlot slot)
{ {
//zero the address register //zero the address register
switch (slot) switch (slot)

View File

@ -2,7 +2,7 @@
namespace GleeBug namespace GleeBug
{ {
ThreadInfo::ThreadInfo(HANDLE hThread, uint32 dwThreadId, LPVOID lpThreadLocalBase, LPVOID lpStartAddress) : Thread::Thread(HANDLE hThread, uint32 dwThreadId, LPVOID lpThreadLocalBase, LPVOID lpStartAddress) :
hThread(hThread), hThread(hThread),
dwThreadId(dwThreadId), dwThreadId(dwThreadId),
lpThreadLocalBase(ptr(lpThreadLocalBase)), lpThreadLocalBase(ptr(lpThreadLocalBase)),
@ -13,7 +13,7 @@ namespace GleeBug
{ {
} }
ThreadInfo::ThreadInfo(const ThreadInfo & other) : Thread::Thread(const Thread & other) :
hThread(other.hThread), hThread(other.hThread),
dwThreadId(other.dwThreadId), dwThreadId(other.dwThreadId),
lpThreadLocalBase(other.lpThreadLocalBase), lpThreadLocalBase(other.lpThreadLocalBase),
@ -26,7 +26,7 @@ namespace GleeBug
{ {
} }
ThreadInfo & ThreadInfo::operator=(const ThreadInfo& other) Thread & Thread::operator=(const Thread& other)
{ {
hThread = other.hThread; hThread = other.hThread;
dwThreadId = other.dwThreadId; dwThreadId = other.dwThreadId;
@ -40,7 +40,7 @@ namespace GleeBug
return *this; return *this;
} }
bool ThreadInfo::RegReadContext() bool Thread::RegReadContext()
{ {
SuspendThread(this->hThread); SuspendThread(this->hThread);
memset(&this->mOldContext, 0, sizeof(CONTEXT)); memset(&this->mOldContext, 0, sizeof(CONTEXT));
@ -55,7 +55,7 @@ namespace GleeBug
return bReturn; return bReturn;
} }
bool ThreadInfo::RegWriteContext() const bool Thread::RegWriteContext() const
{ {
//check if something actually changed //check if something actually changed
if (memcmp(&this->mOldContext, this->registers.GetContext(), sizeof(CONTEXT)) == 0) if (memcmp(&this->mOldContext, this->registers.GetContext(), sizeof(CONTEXT)) == 0)
@ -67,13 +67,13 @@ namespace GleeBug
return bReturn; return bReturn;
} }
void ThreadInfo::StepInto() void Thread::StepInto()
{ {
registers.TrapFlag.Set(); registers.TrapFlag.Set();
isSingleStepping = true; isSingleStepping = true;
} }
void ThreadInfo::StepInto(const StepCallback & cbStep) void Thread::StepInto(const StepCallback & cbStep)
{ {
StepInto(); StepInto();
@ -89,7 +89,7 @@ namespace GleeBug
stepCallbacks.push_back(cbStep); stepCallbacks.push_back(cbStep);
} }
void ThreadInfo::StepInternal(const StepCallback & cbStep) void Thread::StepInternal(const StepCallback & cbStep)
{ {
registers.TrapFlag.Set(); registers.TrapFlag.Set();
isInternalStepping = true; isInternalStepping = true;

View File

@ -10,7 +10,7 @@ namespace GleeBug
/** /**
\brief Thread information structure. \brief Thread information structure.
*/ */
class ThreadInfo class Thread
{ {
public: public:
HANDLE hThread; HANDLE hThread;
@ -31,19 +31,19 @@ namespace GleeBug
\param lpThreadLocalBase The thread local base. \param lpThreadLocalBase The thread local base.
\param lpStartAddress The start address. \param lpStartAddress The start address.
*/ */
explicit ThreadInfo(HANDLE hThread, uint32 dwThreadId, LPVOID lpThreadLocalBase, LPVOID lpStartAddress); explicit Thread(HANDLE hThread, uint32 dwThreadId, LPVOID lpThreadLocalBase, LPVOID lpStartAddress);
/** /**
\brief Copy constructor. \brief Copy constructor.
*/ */
ThreadInfo(const ThreadInfo & other); Thread(const Thread & other);
/** /**
\brief Assignment operator. \brief Assignment operator.
\param other The other object. \param other The other object.
\return A shallow copy of this object. \return A shallow copy of this object.
*/ */
ThreadInfo & operator=(const ThreadInfo & other); Thread & operator=(const Thread & other);
/** /**
\brief Read the register context from the thread. This fills the RegistersInfo member. \brief Read the register context from the thread. This fills the RegistersInfo member.
@ -103,7 +103,7 @@ namespace GleeBug
/** /**
\brief Sets a hardware breakpoint. \brief Sets a hardware breakpoint.
\param address The address to set the hardware breakpoint on. \param address The address to set the hardware breakpoint on.
\param slot The hardware breakpoint register slot. Use ProcessInfo::GetFreeHardwareBreakpointSlot. \param slot The hardware breakpoint register slot. Use Process::GetFreeHardwareBreakpointSlot.
\param type The hardware breakpoint type. \param type The hardware breakpoint type.
\param size The hardware breakpoint size. \param size The hardware breakpoint size.
\return true if the hardware breakpoint was set, false otherwise. \return true if the hardware breakpoint was set, false otherwise.

View File

@ -67,44 +67,44 @@ namespace GleeBug
/** /**
\brief Process creation debug event callback. Called after the event is internally processed. Provide an implementation to use this callback. \brief Process creation debug event callback. Called after the event is internally processed. Provide an implementation to use this callback.
\param createProcess Information about the process created. \param createProcess Information about the process created.
\param process ProcessInfo of the created process. \param process Process of the created process.
*/ */
virtual void cbCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO & createProcess, const ProcessInfo & process) {}; virtual void cbCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO & createProcess, const Process & process) {};
/** /**
\brief Process termination debug event callback. Called before the event is internally processed. Provide an implementation to use this callback. \brief Process termination debug event callback. Called before the event is internally processed. Provide an implementation to use this callback.
\param exitProcess Information about the process terminated. \param exitProcess Information about the process terminated.
\param process ProcessInfo of the terminated process. \param process Process of the terminated process.
*/ */
virtual void cbExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO & exitProcess, const ProcessInfo & process) {}; virtual void cbExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO & exitProcess, const Process & process) {};
/** /**
\brief Thread creation debug event callback. Called after the event is internally processed. Provide an implementation to use this callback. \brief Thread creation debug event callback. Called after the event is internally processed. Provide an implementation to use this callback.
\param createThread Information about the thread created. \param createThread Information about the thread created.
\param thread ThreadInfo of the created thread. \param thread Thread of the created thread.
*/ */
virtual void cbCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO & createThread, const ThreadInfo & thread) {}; virtual void cbCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO & createThread, const Thread & thread) {};
/** /**
\brief Thread termination debug event callback. Called before the event is internally processed. Provide an implementation to use this callback. \brief Thread termination debug event callback. Called before the event is internally processed. Provide an implementation to use this callback.
\param exitThread Information about the thread terminated. \param exitThread Information about the thread terminated.
\param thread ThreadInfo of the terminated thread. \param thread Thread of the terminated thread.
*/ */
virtual void cbExitThreadEvent(const EXIT_THREAD_DEBUG_INFO & exitThread, const ThreadInfo & thread) {}; virtual void cbExitThreadEvent(const EXIT_THREAD_DEBUG_INFO & exitThread, const Thread & thread) {};
/** /**
\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 DllInfo of the loaded DLL. \param dll Dll of the loaded DLL.
*/ */
virtual void cbLoadDllEvent(const LOAD_DLL_DEBUG_INFO & loadDll, const DllInfo & dll) {}; virtual void cbLoadDllEvent(const LOAD_DLL_DEBUG_INFO & loadDll, const Dll & dll) {};
/** /**
\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 DllInfo of the unloaded DLL. \param dll Dll of the unloaded DLL.
*/ */
virtual void cbUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll, const DllInfo & dll) {}; virtual void cbUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll, const Dll & dll) {};
/** /**
\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.
@ -254,12 +254,12 @@ namespace GleeBug
/** /**
\brief The current process (can be null in some cases). \brief The current process (can be null in some cases).
*/ */
ProcessInfo* mProcess = nullptr; Process* mProcess = nullptr;
/** /**
\brief The current thread (can be null in some cases). Should be a copy of mProcess->thread. \brief The current thread (can be null in some cases). Should be a copy of mProcess->thread.
*/ */
ThreadInfo* mThread = nullptr; Thread* mThread = nullptr;
/** /**
\brief The current thread registers (can be null in some cases). Should be a copy of mThread->registers. \brief The current thread registers (can be null in some cases). Should be a copy of mThread->registers.

View File

@ -44,7 +44,7 @@ protected:
mRegisters->Gip()); mRegisters->Gip());
} }
void cbCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO & createProcess, const ProcessInfo & process) override void cbCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO & createProcess, const Process & process) override
{ {
ptr entry = ptr(createProcess.lpStartAddress); ptr entry = ptr(createProcess.lpStartAddress);
printf("Process %d created with entry 0x%p\n", printf("Process %d created with entry 0x%p\n",
@ -79,34 +79,34 @@ protected:
puts(""); puts("");
} }
void cbExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO & exitProcess, const ProcessInfo & process) override void cbExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO & exitProcess, const Process & process) override
{ {
printf("Process %u terminated with exit code 0x%08X\n", printf("Process %u terminated with exit code 0x%08X\n",
mDebugEvent.dwProcessId, mDebugEvent.dwProcessId,
exitProcess.dwExitCode); exitProcess.dwExitCode);
} }
void cbCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO & createThread, const ThreadInfo & thread) override void cbCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO & createThread, const Thread & thread) override
{ {
printf("Thread %u created with entry 0x%p\n", printf("Thread %u created with entry 0x%p\n",
mDebugEvent.dwThreadId, mDebugEvent.dwThreadId,
createThread.lpStartAddress); createThread.lpStartAddress);
} }
void cbExitThreadEvent(const EXIT_THREAD_DEBUG_INFO & exitThread, const ThreadInfo & thread) override void cbExitThreadEvent(const EXIT_THREAD_DEBUG_INFO & exitThread, const Thread & thread) override
{ {
printf("Thread %u terminated with exit code 0x%08X\n", printf("Thread %u terminated with exit code 0x%08X\n",
mDebugEvent.dwThreadId, mDebugEvent.dwThreadId,
exitThread.dwExitCode); exitThread.dwExitCode);
} }
void cbLoadDllEvent(const LOAD_DLL_DEBUG_INFO & loadDll, const DllInfo & dll) override void cbLoadDllEvent(const LOAD_DLL_DEBUG_INFO & loadDll, const Dll & dll) 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 DllInfo & dll) override void cbUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll, const Dll & dll) override
{ {
printf("DLL 0x%p unloaded\n", printf("DLL 0x%p unloaded\n",
unloadDll.lpBaseOfDll); unloadDll.lpBaseOfDll);

View File

@ -463,37 +463,37 @@ public:
} }
protected: protected:
void cbCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO & createProcess, const ProcessInfo & process) override void cbCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO & createProcess, const Process & process) override
{ {
if (mCbCREATEPROCESS) if (mCbCREATEPROCESS)
mCbCREATEPROCESS(&createProcess); mCbCREATEPROCESS(&createProcess);
} }
void cbExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO & exitProcess, const ProcessInfo & process) override void cbExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO & exitProcess, const Process & process) override
{ {
if (mCbEXITPROCESS) if (mCbEXITPROCESS)
mCbEXITPROCESS(&exitProcess); mCbEXITPROCESS(&exitProcess);
} }
void cbCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO & createThread, const ThreadInfo & thread) override void cbCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO & createThread, const Thread & thread) override
{ {
if (mCbCREATETHREAD) if (mCbCREATETHREAD)
mCbCREATETHREAD(&createThread); mCbCREATETHREAD(&createThread);
} }
void cbExitThreadEvent(const EXIT_THREAD_DEBUG_INFO & exitThread, const ThreadInfo & thread) override void cbExitThreadEvent(const EXIT_THREAD_DEBUG_INFO & exitThread, const Thread & thread) override
{ {
if (mCbEXITTHREAD) if (mCbEXITTHREAD)
mCbEXITTHREAD(&exitThread); mCbEXITTHREAD(&exitThread);
} }
void cbLoadDllEvent(const LOAD_DLL_DEBUG_INFO & loadDll, const DllInfo & dll) override void cbLoadDllEvent(const LOAD_DLL_DEBUG_INFO & loadDll, const Dll & dll) override
{ {
if (mCbLOADDLL) if (mCbLOADDLL)
mCbLOADDLL(&loadDll); mCbLOADDLL(&loadDll);
} }
void cbUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll, const DllInfo & dll) override void cbUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll, const Dll & dll) override
{ {
if (mCbUNLOADDLL) if (mCbUNLOADDLL)
mCbUNLOADDLL(&unloadDll); mCbUNLOADDLL(&unloadDll);
@ -571,13 +571,13 @@ private: //functions
} }
} }
ThreadInfo* threadFromHandle(HANDLE hThread) const Thread* threadFromHandle(HANDLE hThread) const
{ {
//TODO: properly implement this //TODO: properly implement this
return mThread; return mThread;
} }
ProcessInfo* processFromHandle(HANDLE hProcess) const Process* processFromHandle(HANDLE hProcess) const
{ {
//TODO: properly implement this //TODO: properly implement this
return mProcess; return mProcess;