diff options
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 ) ); } |
