diff options
| author | boris <wzn@moneybot.cc> | 2018-11-28 16:00:02 +1300 |
|---|---|---|
| committer | boris <wzn@moneybot.cc> | 2018-11-28 16:00:02 +1300 |
| commit | 3d412a4b30a9f7c7f51ea6562e694315948bd3da (patch) | |
| tree | 26d67dfd1f3e5fd12903ad13e85d0cb8bcf8f21c /cheat/internal_rewrite/mem.hpp | |
| parent | e4729e4393d90271a3814c7a79950a660c48325a (diff) | |
cleaned up
in short, the cheat and loader are now separate solutions. unused stuff was moved into the legacy solution in case anyone wants to compile it or whatever.
i can change this back if you want to. also, i configured the loader to compile in x64, and have separate build types for linux and win64
Diffstat (limited to 'cheat/internal_rewrite/mem.hpp')
| -rw-r--r-- | cheat/internal_rewrite/mem.hpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/cheat/internal_rewrite/mem.hpp b/cheat/internal_rewrite/mem.hpp new file mode 100644 index 0000000..37db3ad --- /dev/null +++ b/cheat/internal_rewrite/mem.hpp @@ -0,0 +1,66 @@ +#pragma once +#include <intrin.h> +#include "util.hpp" + +#define get_baseptr( ) ( ( uintptr_t )( _AddressOfReturnAddress( ) ) - sizeof( uintptr_t ) ) + +class stack_t { + uintptr_t m_ptr; + +public: + __forceinline stack_t( ) : m_ptr( get_baseptr( ) ) { } + + __forceinline stack_t( uintptr_t ptr ) : m_ptr( ptr ) { } + + template < typename t = uintptr_t > + __forceinline t get( ) { + return ( t )m_ptr; + } + + template < typename t = uintptr_t > + __forceinline t return_address( ) { + return *( t* )( m_ptr + sizeof( void* ) ); + } + + template < typename t = uintptr_t > + __forceinline t address_of_return_address( ) { + return ( t )( m_ptr + sizeof( uintptr_t ) ); + } + + __forceinline stack_t& next( ) { + return *( stack_t* )( m_ptr ); + } + + template < typename t = uintptr_t > + __forceinline t local( size_t at ) { + return ( t )( m_ptr - at ); + } + + template < typename t = uintptr_t > + __forceinline t arg( size_t at ) { + return ( t )( m_ptr + at ); + } +}; + +namespace util { + template < typename t = uint8_t > + __forceinline t* memcpy( t* dst, t* src, size_t size = sizeof( t ) ) { + __movsb( + ( uint8_t* )dst, + ( uint8_t* )src, + size + ); + + return dst; + } + + __forceinline void* memset( uint8_t* dst, uint8_t val, size_t size ) { + __stosb( + dst, + val, + size + ); + + return dst; + } +}
\ No newline at end of file |
