Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
tranqu1lizer authored Apr 9, 2023
1 parent 990381e commit 1745fda
Show file tree
Hide file tree
Showing 3 changed files with 415 additions and 0 deletions.
157 changes: 157 additions & 0 deletions camera_patch.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="core\main.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="core\include\BlackBone\BlackBone.vcxproj">
<Project>{a2c53563-46f5-4d87-903f-3f1f2fdb2deb}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClInclude Include="core\include\xorstr\xorstr.hpp" />
<ClInclude Include="core\dota_sdk.hpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{c15e6bb1-4a30-4d37-9b96-3fc80e58cd4b}</ProjectGuid>
<RootNamespace>camerapatch</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<AdditionalIncludeDirectories>$(ProjectDir)core\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<AdditionalIncludeDirectories>$(ProjectDir)core\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>false</GenerateDebugInformation>
<UACExecutionLevel>AsInvoker</UACExecutionLevel>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
172 changes: 172 additions & 0 deletions core/dota_sdk.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
#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/RPC/RemoteHook.h>
#include <BlackBone/Process/RPC/RemoteFunction.hpp>
#include <BlackBone/Patterns/PatternSearch.h>

typedef std::uintptr_t( __fastcall* CDOTACamera__Init )( );
typedef void( __fastcall* SetRenderingEnabled )( std::uintptr_t CParticleCollectionPtr, bool render );

class DefClass {
public:
blackbone::ProcessMemory* memory;
std::uintptr_t baseAddr;

std::uintptr_t GetVF( unsigned short idx ) noexcept {
const auto VMTAddr = memory->Read<std::uintptr_t>( baseAddr ).result( );

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

class CDOTA_ParticleManager : 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 : 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 {
public:
CDOTA_Camera( ) {
memory = nullptr;
baseAddr = NULL;
}

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

void SetDistance( float distance ) noexcept { // 0x270
memory->Write<float>( baseAddr + 0x270, distance );
}

void SetFOWAmount( float amount ) // 0x70
{
memory->Write<float>( baseAddr + 0x70, amount );
}

auto GetDistance( ) noexcept {
return memory->Read<float>( baseAddr + 0x270 ).result( );
}

auto GetFOWAmount( )
{
return memory->Read<float>( baseAddr + 0x70 ).result( );
}

void ToggleFog( ) {
const auto aGetFog = this->GetVF( 18 );
const auto instructionBytes = memory->Read<uintptr_t>( aGetFog ).result( );

if ( instructionBytes == 0x83485708245c8948 ) { // not patched

// 0x0F, 0x57, 0xC0 | xorps xmm0, xmm0
// 0xC3 | ret
constexpr const char* bytePatch = "\x0F\x57\xC0\xC3";
memory->Write( aGetFog, 4, bytePatch );
// std::cout << "Fog instructions patched" << std::endl;
}
else if ( instructionBytes == 0x83485708c3c0570f ) { // already patched

// 0x48, 0x89, 0x5C, 0x24, 0x08 | mov qword ptr ss:[rsp+8], rbx
// 0x57 | push rdi
constexpr const char* byteRestore = "\x48\x89\x5C\x24\x08\x57";
memory->Write( aGetFog, 6, byteRestore );
// std::cout << "Fog instructions restored" << std::endl;
}
else {
std::cout << "Error, unknown fog instructions: " << instructionBytes << std::endl;
std::system( "pause" );
exit( 1 );
}
}

void ToggleMaxZFar( ) {
const auto aGetZFar = this->GetVF( 19 );
const auto instructionBytes = memory->Read<uintptr_t>( aGetZFar ).result( );

if ( instructionBytes == 0x83485708245c8948 ) { // not patched

// 0xB8, 0x50, 0x46, 0x00, 0x00 | mov eax, 18000
// 0xF3, 0x0F, 0x2A, 0xC0 | cvtsi2ss xmm0, eax
// 0xC3 | ret
constexpr const char* bytePatch = "\xB8\x50\x46\x00\x00\xF3\x0F\x2A\xC0\xC3";
memory->Write( aGetZFar, 10, bytePatch );
//std::cout << "ZFar instructions patched" << std::endl;
}
else if ( instructionBytes == 0x2a0ff300004650b8 ) { // already patched

// 0x48, 0x89, 0x5C, 0x24, 0x08 | mov qword ptr ss:[rsp+8], rbx
// 0x57 | push rdi
// 0x48, 0x83, 0xEC, 0x40 | sub rsp, 40
constexpr const char* byteRestore = "\x48\x89\x5C\x24\x08\x57\x48\x83\xEC\x40";
memory->Write( aGetZFar, 10, byteRestore );
//std::cout << "ZFar instructions restored" << std::endl;
}
}
};
Loading

0 comments on commit 1745fda

Please sign in to comment.