Skip to content

Commit

Permalink
Update dota_sdk.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
tranqu1lizer authored Sep 10, 2023
1 parent 0d69066 commit d0dcd5d
Showing 1 changed file with 110 additions and 1 deletion.
111 changes: 110 additions & 1 deletion core/dota_sdk.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#include <iostream>
#include <format>
#include <xorstr/xorstr.hpp>
#include <BlackBone/Asm/AsmFactory.h>
#include <BlackBone/Asm/AsmHelper64.h>
#include <BlackBone/Asm/IAsmHelper.h>
#include <BlackBone/Process/Process.h>
#include <BlackBone/Process/ProcessMemory.h>
#include <BlackBone/Process/RPC/RemoteHook.h>
#include <BlackBone/Process/RPC/RemoteFunction.hpp>
#include <BlackBone/Patterns/PatternSearch.h>

typedef void* ( *CreateInterface )( const char* pName, int* pReturnCode );
typedef std::uintptr_t( __fastcall* CDOTACamera__Init )( );
typedef void( __fastcall* SetRenderingEnabled )( std::uintptr_t CParticleCollectionPtr, bool render );

Expand All @@ -21,9 +24,95 @@ class DefClass {

return memory->Read<std::uintptr_t>( VMTAddr + idx * 8 ).result( );
}

bool IsValid( ) {
return ( memory && baseAddr ) ? true : false;
}
};

template<typename T>
inline T GetInterface( blackbone::Process* proc, const wchar_t* dllname, const char* interfacename ) {
const auto aCreateInterface = proc->modules( ).GetExport( dllname, (char*)"CreateInterface" ).result( ).procAddress;
auto iRetCode = 0;

blackbone::RemoteFunction<CreateInterface> pFN( *proc, aCreateInterface );
if ( const auto callResult = pFN.Call( interfacename, &iRetCode ); callResult.success( ) ) {
return reinterpret_cast<T>( callResult.result( ) );
}
return nullptr;
}

std::uintptr_t GetAbsoluteAddress( blackbone::ProcessMemory* mem, std::uintptr_t instruction_ptr, int offset = 3, int size = 7 )
{
return instruction_ptr + ( mem->Read<std::int32_t>( instruction_ptr + offset ).result( ) ) + size;
}

class CDOTA_ParticleManager : public DefClass {
public:
CDOTA_ParticleManager( ) {
memory = nullptr;
baseAddr = NULL;
}

CDOTA_ParticleManager( blackbone::ProcessMemory* memory, std::uintptr_t baseAddr ) {
this->memory = memory;
this->baseAddr = baseAddr;
}

class NewParticleEffect : DefClass {
public:
NewParticleEffect( ) {
memory = nullptr;
baseAddr = NULL;
}
NewParticleEffect( blackbone::ProcessMemory* memory, std::uintptr_t baseAddr ) {
this->memory = memory;
this->baseAddr = baseAddr;
}
DefClass GetParticleCollection( ) {
auto partCollection = memory->Read<std::uintptr_t>( baseAddr + 0x20 ).result( );
auto res = DefClass( memory, partCollection );
if ( !baseAddr || !partCollection ) return DefClass( 0, 0 );
return res;
}
};

class ParticleListItem : public DefClass {
public:
ParticleListItem( ) {
memory = nullptr;
baseAddr = NULL;
}
ParticleListItem( blackbone::ProcessMemory* memory, std::uintptr_t baseAddr ) {
this->memory = memory;
this->baseAddr = baseAddr;
}
CDOTA_ParticleManager::NewParticleEffect GetNewParticleEffect( ) {
auto newPartEffect = memory->Read<std::uintptr_t>( baseAddr + 0x10 ).result( );
if ( !newPartEffect || !baseAddr ) return CDOTA_ParticleManager::NewParticleEffect( 0, 0 );
return CDOTA_ParticleManager::NewParticleEffect( memory, newPartEffect );
}
};


std::vector<CDOTA_ParticleManager::ParticleListItem> GetParticleLists( ) {
std::vector<ParticleListItem> list;
auto particlesBase = memory->Read<std::uintptr_t>( baseAddr + 0x88 ).result( );
const auto pCount = this->GetParticleCount( ) * 8;
for ( int idx = 0x0; idx < pCount; idx += 0x8 ) {
CDOTA_ParticleManager::ParticleListItem thisEffect( memory, memory->Read<std::uintptr_t>( particlesBase + idx ).result( ) );
list.push_back( thisEffect );
}

return list;
}

int GetParticleCount( ) {
return memory->Read<int>( baseAddr + 0x80 ).result( );
}
};

class CDOTA_Camera : DefClass {
class CDOTA_Camera : public DefClass {
public:
CDOTA_Camera( ) {
memory = nullptr;
Expand Down Expand Up @@ -104,3 +193,23 @@ class CDOTA_Camera : DefClass {
}
}
};

CDOTA_Camera FindCamera( blackbone::Process& proc ) {
std::vector<blackbone::ptr_t> search_result;
blackbone::PatternSearch aDOTACameraInit_Pattern{ "\x48\x83\xEC\x38\xE8\xCC\xCC\xCC\xCC\x48\x85\xC0\x74\x4D" };
aDOTACameraInit_Pattern.SearchRemote( proc, 0xCC, proc.modules( ).GetModule( L"client.dll" ).get( )->baseAddress, proc.modules( ).GetModule( L"client.dll" ).get( )->size, search_result, 1 );
blackbone::RemoteFunction<CDOTACamera__Init> pFN( proc, search_result.front( ) );

if ( auto result = pFN.Call( ); result.success( ) && result.result( ) ) {
return CDOTA_Camera{ &proc.memory( ), result.result( ) };
}

return CDOTA_Camera{ nullptr, 0 };
}

std::uintptr_t FindEntitySystem( blackbone::Process& process ) {
DefClass interface002{ &process.memory( ), GetInterface<std::uintptr_t>( &process, L"client.dll", "Source2Client002" ) };
const auto GameEntitySystem_result = process.memory( ).Read<std::uintptr_t>( GetAbsoluteAddress( &process.memory( ), interface002.GetVF( 25 ) ) );

return GameEntitySystem_result.success( ) ? GameEntitySystem_result.result( ) : 0;
}

0 comments on commit d0dcd5d

Please sign in to comment.