diff options
| author | navewindre <boneyaard@gmail.com> | 2018-09-09 18:28:04 +0200 |
|---|---|---|
| committer | navewindre <boneyaard@gmail.com> | 2018-09-09 18:28:04 +0200 |
| commit | 215818ddedc02be3a1a5c2be3912abdbcd29dd72 (patch) | |
| tree | 16453999d9380f43a6f436e491e63aa58ac7e764 /internal_rewrite/vmt.hpp | |
| parent | 620f39df29fed446ab007e03c7b071f635379f1f (diff) | |
detours etc
Diffstat (limited to 'internal_rewrite/vmt.hpp')
| -rw-r--r-- | internal_rewrite/vmt.hpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/internal_rewrite/vmt.hpp b/internal_rewrite/vmt.hpp index 2ea9d72..03409ce 100644 --- a/internal_rewrite/vmt.hpp +++ b/internal_rewrite/vmt.hpp @@ -24,6 +24,7 @@ namespace hooks class c_vmt { uintptr_t* m_table; uintptr_t* m_original; + bool m_copied; std::vector< uintptr_t > m_new; public: int count( ) { @@ -48,8 +49,7 @@ namespace hooks this->m_new.push_back( this->m_original[ i ] ); } - auto data = this->m_new.data( ); - *this->m_table = uintptr_t( &data[ 1 ] ); + m_copied = false; } ~c_vmt( ) { } @@ -63,6 +63,13 @@ namespace hooks } void hook( int index, uintptr_t new_func ) { + if( !m_copied ) { + auto data = this->m_new.data( ); + *this->m_table = uintptr_t( &data[ 1 ] ); + + m_copied = true; + } + this->m_new.at( index + 1 ) = new_func; } @@ -71,6 +78,13 @@ namespace hooks } void hook( int index, void* new_func ) { + if( !m_copied ) { + auto data = this->m_new.data( ); + *this->m_table = uintptr_t( &data[ 1 ] ); + + m_copied = true; + } + hook( index, reinterpret_cast< uintptr_t >( new_func ) ); } |
