summaryrefslogtreecommitdiff
path: root/cheat/internal_rewrite/iface_dllmain_impl.hpp
diff options
context:
space:
mode:
authorboris <wzn@moneybot.cc>2018-11-28 16:00:02 +1300
committerboris <wzn@moneybot.cc>2018-11-28 16:00:02 +1300
commit3d412a4b30a9f7c7f51ea6562e694315948bd3da (patch)
tree26d67dfd1f3e5fd12903ad13e85d0cb8bcf8f21c /cheat/internal_rewrite/iface_dllmain_impl.hpp
parente4729e4393d90271a3814c7a79950a660c48325a (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/iface_dllmain_impl.hpp')
-rw-r--r--cheat/internal_rewrite/iface_dllmain_impl.hpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/cheat/internal_rewrite/iface_dllmain_impl.hpp b/cheat/internal_rewrite/iface_dllmain_impl.hpp
new file mode 100644
index 0000000..f8209ec
--- /dev/null
+++ b/cheat/internal_rewrite/iface_dllmain_impl.hpp
@@ -0,0 +1,82 @@
+#pragma once
+
+namespace factory
+{
+ namespace interfaces
+ {
+ class c_interface_manager {
+ struct reg {
+ char m_key;
+ uintptr_t m_ptr;
+ uintptr_t m_module;
+ char m_module_name[ 64 ];
+ char m_name[ 64 ];
+ };
+
+ size_t m_count;
+ reg* m_regs;
+
+ void decrypt_str( char* buf, size_t size, char key ) {
+ for( size_t i{ }; i < size; ++i ) {
+ buf[ i ] ^= key;
+ }
+ }
+
+ public:
+ void init( uintptr_t iface_addr ) {
+ m_count = *( size_t* )( iface_addr );
+ m_regs = ( reg* )( iface_addr + 4 );
+ }
+
+ template < typename t = void* >
+ t find_interface( const std::string& module_, std::string name ) {
+ if( !::isdigit( name[ name.length( ) - 1 ] ) )
+ name += '0';
+
+ char name_buf[ 64 ];
+ char module_buf[ 64 ];
+
+ for( size_t i{ }; i < m_count; ++i ) {
+ auto& reg = m_regs[ i ];
+
+ memcpy( name_buf, reg.m_name, 64 );
+ memcpy( module_buf, reg.m_module_name, 64 );
+
+ decrypt_str( name_buf, 64, reg.m_key );
+ decrypt_str( module_buf, 64, reg.m_key );
+
+ if( !module_.compare( module_buf ) && strstr( name_buf, name.c_str( ) ) ) {
+ return ( t )( reg.m_ptr );
+ }
+ }
+
+ return t{ };
+ }
+
+ template < typename t = void* >
+ t find_interface( std::string name ) {
+ if( !::isdigit( name[ name.length( ) - 1 ] ) )
+ name += '0';
+
+ char name_buf[ 64 ];
+ char module_buf[ 64 ];
+
+ for( size_t i{ }; i < m_count; ++i ) {
+ auto& reg = m_regs[ i ];
+
+ memcpy( name_buf, reg.m_name, 64 );
+ memcpy( module_buf, reg.m_module_name, 64 );
+
+ decrypt_str( name_buf, 64, reg.m_key );
+ decrypt_str( module_buf, 64, reg.m_key );
+
+ if( strstr( name_buf, name.c_str( ) ) ) {
+ return ( t )( reg.m_ptr );
+ }
+ }
+
+ return t{ };
+ }
+ };
+ }
+} \ No newline at end of file