3 #include "../ProcessCore.h"
4 #include "../ProcessMemory.h"
5 #include "../Threads/Thread.h"
6 #include "../../Include/Macro.h"
29 , _wordSize( wordSize )
30 , _frame_ptr( frame_ptr != 0 ? frame_ptr : ctx.Rsp )
34 BLACKBONE_API ~RemoteContext()
60 _memory.
Read( _frame_ptr, _wordSize, &val );
72 return (_memory.
Write( _frame_ptr, _wordSize, &val ) == STATUS_SUCCESS);
82 memcpy( &_ctx.Rax, &val, _wordSize );
92 SET_BIT( val, (_wordSize * 8 - 1) );
106 RESET_BIT( val, (_wordSize * 8 - 1) );
121 BLACKBONE_API DWORD64
getArg(
int index )
137 return _memory.
Read<DWORD64>( _ctx.Rsp + 0x30 + (index - 4 ) * _wordSize );
143 _memory.
Read( _ctx.Rsp + 4 + index * _wordSize, _wordSize, &val );
156 BLACKBONE_API
bool setArg(
int index, DWORD64 val )
179 return (_memory.
Write( _ctx.Rsp + 0x30 + (index - 4) * _wordSize, val ) == STATUS_SUCCESS);
186 return (_memory.
Write( _ctx.Rsp + 4 + index * _wordSize, _wordSize, &val ) == STATUS_SUCCESS);
203 offset = FIELD_OFFSET(
_TEB64, LastErrorValue );
208 offset = FIELD_OFFSET(
_TEB32, LastErrorValue );
212 return _memory.
Read<DWORD>( pteb + offset );
229 offset = FIELD_OFFSET(
_TEB64, LastErrorValue );
234 offset = FIELD_OFFSET(
_TEB32, LastErrorValue );
238 return _memory.
Write( pteb + offset, newError );
250 auto pteb = _thd.
teb( (
_TEB64*)
nullptr );
264 auto pteb = _thd.
teb( (
_TEB64*)
nullptr );
267 if (_memory.
Write( pteb + FIELD_OFFSET(
_NT_TIB_T<DWORD64>, ArbitraryUserPointer ), context ) == STATUS_SUCCESS)
276 RemoteContext(
const RemoteContext& ) =
delete;
277 RemoteContext& operator = (
const RemoteContext& ) =
delete;
284 BOOL _x64Target = FALSE;
286 ptr_t _frame_ptr = 0;
BLACKBONE_API ptr_t getUserContext()
Get arbitrary thread data
Definition: RemoteContext.hpp:248
BLACKBONE_API Thread & getThread()
Get current process thread where exception occurred
Definition: RemoteContext.hpp:48
BLACKBONE_API ptr_t hookReturn()
Raise exception on function return
Definition: RemoteContext.hpp:89
BLACKBONE_API DWORD lastError(DWORD newError)
Set last thread error code
Definition: RemoteContext.hpp:221
BLACKBONE_API NTSTATUS Read(ptr_t dwAddress, size_t dwSize, PVOID pResult, bool handleHoles=false)
Read data
Definition: ProcessMemory.cpp:81
Definition: NativeStructures.h:82
BLACKBONE_API bool setArg(int index, DWORD64 val)
Set argument value. For x86 function works only with stack arguments. For x64 only integer arguments ...
Definition: RemoteContext.hpp:156
Definition: NativeStructures.h:55
BLACKBONE_API bool setUserContext(ptr_t context)
Set arbitrary thread data
Definition: RemoteContext.hpp:262
Definition: ProcessMemory.h:13
BLACKBONE_API const ptr_t returnAddress() const
Definition: RemoteContext.hpp:57
BLACKBONE_API NTSTATUS Write(ptr_t pAddress, size_t dwSize, const void *pData)
Write data
Definition: ProcessMemory.cpp:131
Remote function context during hook breakpoint.
Definition: RemoteContext.hpp:14
BLACKBONE_API bool returnAddress(ptr_t val) const
Set return address of current frame
Definition: RemoteContext.hpp:70
BLACKBONE_API DWORD64 getArg(int index)
Get argument value. Argument index is 0 based. For x86 function works only with stack arguments For x...
Definition: RemoteContext.hpp:121
BLACKBONE_API ptr_t teb(_TEB32 *pteb=nullptr) const
Get WOW64 TEB
Definition: Thread.cpp:41
BLACKBONE_API DWORD lastError()
Get last thread error code
Definition: RemoteContext.hpp:195
Thread management
Definition: Thread.h:91
Definition: NativeStructures.h:498
Definition: AsmHelper32.cpp:6
BLACKBONE_API void setReturnValue(ptr_t val) const
Set new integer return value. Has no effect on FPU. Has effect only if called in return callback ...
Definition: RemoteContext.hpp:80
BLACKBONE_API ptr_t unhookReturn()
Remove exception on return
Definition: RemoteContext.hpp:103