Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Manager.h"
- #include <detours.h>
- /*----- Main Globals ---------------------------------------*/
- DWORD g_dwAddress = 0;
- bool g_bDone = false;
- vector<int> g_Addresses;
- /*----- Add an Address to the Vector ---------------------------------------*/
- void AddAddress( int Addy )
- {
- g_Addresses.push_back( Addy );
- }
- /*----- Check if the Address isn't in the Vector yet ---------------------------------------*/
- bool IsUnique( int Addy )
- {
- for ( int i = 0; i < g_Addresses.size(); i++ )
- if( g_Addresses[ i ] == Addy )
- return false;
- return true;
- }
- /*----- Hook the function which gets the Class-addresses by Name ---------------------------------------*/
- typedef int( __stdcall* o_GetClassByName )( string* strClassName );
- o_GetClassByName pGetClassByName = 0;
- int __stdcall hkGetClassByName( string* strClassName )
- {
- _asm pushad;
- int iTmpAddress = pGetClassByName( strClassName );//iTmpAddress is the Address of the Class
- /*----- If we don't have the Address yet ---------------------------------------*/
- if( IsUnique( iTmpAddress ) && iTmpAddress != NULL )
- {
- DWORD dwBase = (DWORD)GetModuleHandle( NULL ) + 0x56EF58;//<- Change 0x56EF58 to what you want. It defines the Scan Start
- for ( DWORD dwCur = dwBase; dwCur <= dwBase + 0xEEEEE/*<- Scan Range*/; dwCur += 0x4 )//Scan for a Direct Pointer to the Current Class-Address
- {
- if( *(DWORD*)dwCur == (DWORD)iTmpAddress )//If the Current Address we scan points to the Class-address -> Log it
- {
- /*Change that to what you want. For example:*/
- /*
- CManager::Log( "#define: CLASS_%s 0x%X", strClassName->c_str(), dwCur );
- */
- Manager::Log( "Class: %s Address: 0x%X TempAddress: 0x%X", strClassName->c_str(), dwCur, iTmpAddress );
- break;
- }
- }
- /*----- We logged it, add it to the Vector so we don't log it all the Time ---------------------------------------*/
- AddAddress( iTmpAddress );
- }
- _asm popad;
- return iTmpAddress;//Return the Return of the 'Real' function
- }
- DWORD __stdcall Start( LPVOID )
- {
- /*----- Let's go sure we got the Address of the function ---------------------------------------*/
- for( ;g_dwAddress == 0; Sleep( 300 ) )
- g_dwAddress = Manager::ClassByNameAddress();
- Manager::Log( "Address Found! (0x%X)", g_dwAddress );
- Manager::Log( "Hooking Function...." );
- /*----- Hook the Function ---------------------------------------*/
- pGetClassByName = (o_GetClassByName)DetourFunction( (PBYTE)g_dwAddress, (PBYTE)hkGetClassByName );
- return 0;
- }
- bool __stdcall DllMain( HANDLE _HDllHandle, DWORD _Reason, LPVOID _Reserved)
- {
- if( _Reason == 1 )
- CreateThread( 0, 0, Start, 0, 0, 0 );
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement