mirror of https://github.com/x64dbg/GleeBug
generic debug event pre/post callbacks + bytesRead/written in memory functions
This commit is contained in:
parent
81bb985c5b
commit
e4ebc742ae
|
|
@ -48,6 +48,9 @@ namespace GleeBug
|
|||
}
|
||||
}
|
||||
|
||||
//call the pre debug event callback
|
||||
cbPostDebugEvent(_debugEvent);
|
||||
|
||||
//dispatch the debug event
|
||||
switch (_debugEvent.dwDebugEventCode)
|
||||
{
|
||||
|
|
@ -83,6 +86,9 @@ namespace GleeBug
|
|||
break;
|
||||
}
|
||||
|
||||
//call the post debug event callback
|
||||
cbPostDebugEvent(_debugEvent);
|
||||
|
||||
//write the register context
|
||||
if (_thread)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace GleeBug
|
||||
{
|
||||
bool ProcessInfo::MemRead(ptr address, void* buffer, ptr size) const
|
||||
bool ProcessInfo::MemRead(ptr address, void* buffer, ptr size, ptr* bytesRead) const
|
||||
{
|
||||
return !!ReadProcessMemory(this->hProcess, reinterpret_cast<const void*>(address), buffer, size, nullptr);
|
||||
}
|
||||
|
||||
bool ProcessInfo::MemReadSafe(ptr address, void* buffer, ptr size) const
|
||||
bool ProcessInfo::MemReadSafe(ptr address, void* buffer, ptr size, ptr* bytesRead) const
|
||||
{
|
||||
if (!MemRead(address, buffer, size))
|
||||
return false;
|
||||
|
|
@ -51,12 +51,12 @@ namespace GleeBug
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ProcessInfo::MemWrite(ptr address, const void* buffer, ptr size)
|
||||
bool ProcessInfo::MemWrite(ptr address, const void* buffer, ptr size, ptr* bytesWritten)
|
||||
{
|
||||
return !!WriteProcessMemory(this->hProcess, reinterpret_cast<void*>(address), buffer, size, nullptr);
|
||||
}
|
||||
|
||||
bool ProcessInfo::MemWriteSafe(ptr address, const void* buffer, ptr size)
|
||||
bool ProcessInfo::MemWriteSafe(ptr address, const void* buffer, ptr size, ptr* bytesWritten)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,36 +41,40 @@ namespace GleeBug
|
|||
\param address The virtual address to read from.
|
||||
\param [out] buffer Destination buffer. Cannot be null. May be filled partially on failure.
|
||||
\param size The size to read.
|
||||
\param bytesRead (Optional) Number of bytes read (should be equal to size on success).
|
||||
\return true if it succeeds, false if it fails.
|
||||
*/
|
||||
bool MemRead(ptr address, void* buffer, ptr size) const;
|
||||
bool MemRead(ptr address, void* buffer, ptr size, ptr* bytesRead = nullptr) const;
|
||||
|
||||
/**
|
||||
\brief Safely read memory from the process, filtering out breakpoint bytes.
|
||||
\param address The virtual address to read from.
|
||||
\param [out] buffer Destination buffer. Cannot be null. May be filled partially on failure.
|
||||
\param size The size to read.
|
||||
\param bytesRead (Optional) Number of bytes read (should be equal to size on success).
|
||||
\return true if it succeeds, false if it fails.
|
||||
*/
|
||||
bool MemReadSafe(ptr address, void* buffer, ptr size) const;
|
||||
bool MemReadSafe(ptr address, void* buffer, ptr size, ptr* bytesRead = nullptr) const;
|
||||
|
||||
/**
|
||||
\brief Write memory to the process.
|
||||
\param address The virtual address to write to.
|
||||
\param [in] buffer Source buffer. Cannot be null.
|
||||
\param size The size to write.
|
||||
\param bytesWritten (Optional) Number of bytes written (should be equal to size on success).
|
||||
\return true if it succeeds, false if it fails.
|
||||
*/
|
||||
bool MemWrite(ptr address, const void* buffer, ptr size);
|
||||
bool MemWrite(ptr address, const void* buffer, ptr size, ptr* bytesWritten = nullptr);
|
||||
|
||||
/**
|
||||
\brief Safely write memory to the process, preserving breakpoint bytes.
|
||||
\param address The virtual address to write to.
|
||||
\param [in] buffer Source buffer. Cannot be null.
|
||||
\param size The size to write.
|
||||
\param bytesWritten (Optional) Number of bytes written (should be equal to size on success).
|
||||
\return true if it succeeds, false if it fails.
|
||||
*/
|
||||
bool MemWriteSafe(ptr address, const void* buffer, ptr size);
|
||||
bool MemWriteSafe(ptr address, const void* buffer, ptr size, ptr* bytesWritten = nullptr);
|
||||
|
||||
/**
|
||||
\brief Check if an address is a valid read pointer.
|
||||
|
|
|
|||
|
|
@ -52,6 +52,18 @@ namespace GleeBug
|
|||
void Start();
|
||||
|
||||
protected: //debug event callbacks
|
||||
/**
|
||||
\brief Generic pre debug event callback. Called before the event is internally processed. Provide an implementation to use this callback.
|
||||
\param debugEvent The debug event.
|
||||
*/
|
||||
virtual void cbPreDebugEvent(const DEBUG_EVENT & debugEvent) {};
|
||||
|
||||
/**
|
||||
\brief Generic post debug event callback. Called after the event is internally processed. Provide an implementation to use this callback.
|
||||
\param debugEvent The debug event.
|
||||
*/
|
||||
virtual void cbPostDebugEvent(const DEBUG_EVENT & debugEvent) {};
|
||||
|
||||
/**
|
||||
\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.
|
||||
|
|
|
|||
Loading…
Reference in New Issue