BlackBone
Windows memory hacking library
 All Classes Functions
blackbone::Thread Class Reference

Thread management More...

#include <Thread.h>

Public Member Functions

BLACKBONE_API Thread (DWORD id, class ProcessCore *hProcess, DWORD access=DEFAULT_ACCESS_T)
 
BLACKBONE_API Thread (HANDLE handle, class ProcessCore *hProcess)
 
BLACKBONE_API Thread (const Thread &other)
 
BLACKBONE_API DWORD id () const
 Get thread ID More...
 
BLACKBONE_API HANDLE handle () const
 Get thread handle More...
 
BLACKBONE_API bool valid () const
 Check if thread exists More...
 
BLACKBONE_API ptr_t teb (_TEB32 *pteb=nullptr) const
 Get WOW64 TEB More...
 
BLACKBONE_API ptr_t teb (_TEB64 *pteb=nullptr) const
 Get Native TEB More...
 
BLACKBONE_API ptr_t teb () const
 Get TEB More...
 
BLACKBONE_API uint64_t startTime ()
 Get thread creation time More...
 
BLACKBONE_API uint64_t execTime ()
 Get total execution time(user mode and kernel mode) More...
 
BLACKBONE_API bool Suspend ()
 Suspend thread More...
 
BLACKBONE_API bool Resume ()
 Resumes thread. More...
 
BLACKBONE_API bool GetContext (_CONTEXT32 &ctx, DWORD flags=CONTEXT_ALL, bool dontSuspend=false)
 Get WOW64 thread context More...
 
BLACKBONE_API bool GetContext (_CONTEXT64 &ctx, DWORD flags=CONTEXT64_ALL, bool dontSuspend=false)
 Get native thread context More...
 
BLACKBONE_API bool SetContext (_CONTEXT32 &ctx, bool dontSuspend=false)
 Set WOW64 thread context More...
 
BLACKBONE_API bool SetContext (_CONTEXT64 &ctx, bool dontSuspend=false)
 Set native thread context More...
 
BLACKBONE_API bool Terminate (DWORD code=0)
 Terminate thread More...
 
BLACKBONE_API bool Join (int timeout=INFINITE)
 Join thread More...
 
BLACKBONE_API DWORD ExitCode () const
 Get thread exit code More...
 
int BLACKBONE_API AddHWBP (ptr_t addr, HWBPType type, HWBPLength length)
 Add hardware breakpoint to thread More...
 
BLACKBONE_API bool RemoveHWBP (int idx)
 Remove existing hardware breakpoint More...
 
BLACKBONE_API bool RemoveHWBP (ptr_t ptr)
 Remove existing hardware breakpoint More...
 
BLACKBONE_API void Close ()
 Close handle More...
 
BLACKBONE_API bool operator== (const Thread &other)
 
BLACKBONE_API Threadoperator= (const Thread &other)
 

Detailed Description

Thread management

Member Function Documentation

int blackbone::Thread::AddHWBP ( ptr_t  addr,
HWBPType  type,
HWBPLength  length 
)

Add hardware breakpoint to thread

Parameters
addrBreakpoint address
typeBreakpoint type(read/write/execute)
lengthNumber of bytes to include into breakpoint
Returns
Index of used breakpoint; -1 if failed
BLACKBONE_API void blackbone::Thread::Close ( )

Close handle

uint64_t blackbone::Thread::execTime ( )

Get total execution time(user mode and kernel mode)

Returns
Total execution time
DWORD blackbone::Thread::ExitCode ( ) const

Get thread exit code

Returns
Thread exit code
bool blackbone::Thread::GetContext ( _CONTEXT32 ctx,
DWORD  flags = CONTEXT_ALL,
bool  dontSuspend = false 
)

Get WOW64 thread context

Parameters
ctxReturned context
flagsContext flags.
dontSuspendtrue if thread shouldn't be suspended before retrieving context
Returns
true on success
bool blackbone::Thread::GetContext ( _CONTEXT64 ctx,
DWORD  flags = CONTEXT64_ALL,
bool  dontSuspend = false 
)

Get native thread context

Parameters
ctxReturned context
flagsContext flags.
dontSuspendtrue if thread shouldn't be suspended before retrieving context
Returns
true on success
BLACKBONE_API HANDLE blackbone::Thread::handle ( ) const
inline

Get thread handle

Returns
Thread hande
BLACKBONE_API DWORD blackbone::Thread::id ( ) const
inline

Get thread ID

Returns
Thread ID
bool blackbone::Thread::Join ( int  timeout = INFINITE)

Join thread

Parameters
timeoutJoin timeout
Returns
true on success
bool blackbone::Thread::RemoveHWBP ( int  idx)

Remove existing hardware breakpoint

Parameters
idxBreakpoint index
Returns
true on success
bool blackbone::Thread::RemoveHWBP ( ptr_t  ptr)

Remove existing hardware breakpoint

Parameters
ptrBreakpoint address
Returns
true on success
bool blackbone::Thread::Resume ( )

Resumes thread.

Returns
true on success
bool blackbone::Thread::SetContext ( _CONTEXT32 ctx,
bool  dontSuspend = false 
)

Set WOW64 thread context

Parameters
ctxContext to set
dontSuspendtrue if thread shouldn't be suspended before retrieving context
Returns
true on success
bool blackbone::Thread::SetContext ( _CONTEXT64 ctx,
bool  dontSuspend = false 
)

Set native thread context

Parameters
ctxContext to set
dontSuspendtrue if thread shouldn't be suspended before retrieving context
Returns
true on success
uint64_t blackbone::Thread::startTime ( )

Get thread creation time

Returns
Thread creation time
bool blackbone::Thread::Suspend ( )

Suspend thread

Returns
true on success
blackbone::ptr_t blackbone::Thread::teb ( _TEB32 pteb = nullptr) const

Get WOW64 TEB

Parameters
ptebProcess TEB
Returns
TEB pointer
blackbone::ptr_t blackbone::Thread::teb ( _TEB64 pteb = nullptr) const

Get Native TEB

Parameters
ptebProcess TEB
Returns
TEB pointer
BLACKBONE_API ptr_t blackbone::Thread::teb ( ) const
inline

Get TEB

Returns
TEB pointer
bool blackbone::Thread::Terminate ( DWORD  code = 0)

Terminate thread

Parameters
codeExit code
Returns
true on success
BLACKBONE_API bool blackbone::Thread::valid ( ) const
inline

Check if thread exists

Returns
true if thread exists

The documentation for this class was generated from the following files: