diff --git a/core/main.cpp b/core/main.cpp index 56ac393..0eac1fc 100644 --- a/core/main.cpp +++ b/core/main.cpp @@ -1,56 +1,54 @@ #include "dota_sdk.hpp" +[[nodiscard]] inline byte req_action( byte w ) { + if ( w == 0 ) { + byte act1; + + std::cout << "=================================\n[0] Change camera distance\n[1] Patch ZFar\n[2] Toggle Fog\n=> "; + std::cin >> act1; + return act1; + } + else { + float dist; + std::system( "cls" ); + std::cout << "=> "; + std::cin >> dist; + + return dist; + } +} + +void process( blackbone::Process& dota_proc, blackbone::ProcessMemory& pDOTAMemory ) { + std::cout << "PID: " << std::dec << dota_proc.pid( ) << std::endl << "client.dll base: " << (void*)dota_proc.modules( ).GetModule( L"client.dll" ).get( )->baseAddress << std::endl; + + auto DOTACamera = FindCamera( dota_proc ); + const auto pGameEntitySystem = FindEntitySystem( dota_proc ); + + if ( DOTACamera.IsValid( ) ) { + const auto act = req_action( 0 ); + + switch ( act ) + { + case 0: + DOTACamera.SetDistance( req_action( 1 ) ); + case 1: + DOTACamera.ToggleMaxZFar( ); + case 2: + DOTACamera.ToggleFog( ); + default: + exit( 0 ); + } + } + std::system( "cls" ); +} + int main( ) { blackbone::Process dota; - if ( NT_SUCCESS( dota.Attach( L"dota2.exe" ) ) ) { - auto pClientModule = dota.modules( ).GetModule( L"client.dll" ); - auto& pDOTAMemory = dota.memory( ); - - if ( pClientModule ) { - std::cout << "Attached to dota2.exe " << std::endl; - std::vector search_result; - blackbone::PatternSearch aDOTACameraInit_Pattern{ "\x48\x83\xEC\x38\xE8\xCC\xCC\xCC\xCC\x48\x85\xC0\x74\x4D" }; - - while ( 1 ) { - std::cout << "PID: " << std::dec << dota.pid( ) << std::endl << "client.dll base: " << (void*)pClientModule.get( )->baseAddress << std::endl; - aDOTACameraInit_Pattern.SearchRemote( dota, 0xCC, pClientModule.get( )->baseAddress, pClientModule.get( )->size, search_result, 1 ); - const auto aGetCamera = search_result[0]; - - if ( aGetCamera /* && pDOTAParticleManager */ ) { - std::cout << "=================================\n[0] Change camera distance\n[1] Patch ZFar\n[2] Toggle Fog\n=> "; - int act; - std::cin >> act; - blackbone::RemoteFunction pFN( dota, aGetCamera ); - if ( auto result = pFN.Call( ); result.success( ) && result.result( ) ) { - - CDOTA_Camera DOTACamera( &pDOTAMemory, result.result( ) ); - - if ( act == 0 ) { - float dist; - std::system( "cls" ); - std::cout << "=> "; - std::cin >> dist; - DOTACamera.SetDistance( dist ); - } - else if ( act == 1 ) { - DOTACamera.ToggleMaxZFar( ); - } - else if ( act == 2 ) { - DOTACamera.ToggleFog( ); - } - else exit( 0 ); - } - else { - std::cout << "CDOTACamera not found" << std::endl; - std::system( "pause" ); - exit( 1 ); - } - } - std::system( "cls" ); - } - } + if ( NT_SUCCESS( dota.Attach( L"dota2.exe" ) ) && dota.modules( ).GetModule( L"client.dll" ) ) { + std::cout << "Attached to dota2.exe " << std::endl; + while ( 1 ) process( dota, dota.memory( ) ); } else { std::cout << "dota2.exe not found" << std::endl;