Skip to content

Commit be8b8c2

Browse files
committed
-Added everything
1 parent d7306ca commit be8b8c2

5 files changed

Lines changed: 326 additions & 0 deletions

File tree

FakeAngleFix.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FakeAngleFix", "FakeAngleFix.vcxproj", "{C79AB396-1A29-4330-8EF8-31A1A5DD1C01}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Win32 = Debug|Win32
11+
Release|Win32 = Release|Win32
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{C79AB396-1A29-4330-8EF8-31A1A5DD1C01}.Debug|Win32.ActiveCfg = Debug|Win32
15+
{C79AB396-1A29-4330-8EF8-31A1A5DD1C01}.Debug|Win32.Build.0 = Debug|Win32
16+
{C79AB396-1A29-4330-8EF8-31A1A5DD1C01}.Release|Win32.ActiveCfg = Release|Win32
17+
{C79AB396-1A29-4330-8EF8-31A1A5DD1C01}.Release|Win32.Build.0 = Release|Win32
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

FakeAngleFix.vcxproj

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
</ItemGroup>
13+
<PropertyGroup Label="Globals">
14+
<ProjectGuid>{C79AB396-1A29-4330-8EF8-31A1A5DD1C01}</ProjectGuid>
15+
<Keyword>Win32Proj</Keyword>
16+
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
17+
<ProjectName>FakeAngleFix</ProjectName>
18+
</PropertyGroup>
19+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
20+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
21+
<ConfigurationType>DynamicLibrary</ConfigurationType>
22+
<UseDebugLibraries>true</UseDebugLibraries>
23+
<CharacterSet>MultiByte</CharacterSet>
24+
<PlatformToolset>v140</PlatformToolset>
25+
</PropertyGroup>
26+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
27+
<ConfigurationType>DynamicLibrary</ConfigurationType>
28+
<UseDebugLibraries>false</UseDebugLibraries>
29+
<PlatformToolset>v140</PlatformToolset>
30+
<CharacterSet>MultiByte</CharacterSet>
31+
</PropertyGroup>
32+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
33+
<ImportGroup Label="ExtensionSettings">
34+
</ImportGroup>
35+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
36+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
37+
</ImportGroup>
38+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
39+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
40+
</ImportGroup>
41+
<PropertyGroup Label="UserMacros" />
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
43+
<LinkIncremental>true</LinkIncremental>
44+
</PropertyGroup>
45+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
46+
<LinkIncremental>true</LinkIncremental>
47+
</PropertyGroup>
48+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
49+
<ClCompile>
50+
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;HOOK_LAG_COMPENSATION;_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
51+
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
52+
<WarningLevel>Level3</WarningLevel>
53+
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
54+
<Optimization>Disabled</Optimization>
55+
<CallingConvention>Cdecl</CallingConvention>
56+
<AdditionalIncludeDirectories>
57+
</AdditionalIncludeDirectories>
58+
<ObjectFileName>$(IntDir)</ObjectFileName>
59+
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
60+
</ClCompile>
61+
<Link>
62+
<TargetMachine>MachineX86</TargetMachine>
63+
<GenerateDebugInformation>true</GenerateDebugInformation>
64+
<SubSystem>Console</SubSystem>
65+
<FullProgramDatabaseFile>true</FullProgramDatabaseFile>
66+
<AssemblyDebug>true</AssemblyDebug>
67+
<AdditionalDependencies>ws2_32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
68+
</Link>
69+
</ItemDefinitionGroup>
70+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
71+
<ClCompile>
72+
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;HOOK_LAG_COMPENSATION;_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
73+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
74+
<WarningLevel>Level3</WarningLevel>
75+
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
76+
<OmitFramePointers>true</OmitFramePointers>
77+
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
78+
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
79+
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
80+
<RuntimeTypeInfo>false</RuntimeTypeInfo>
81+
<WholeProgramOptimization>true</WholeProgramOptimization>
82+
<StringPooling>true</StringPooling>
83+
<ExceptionHandling>false</ExceptionHandling>
84+
<BufferSecurityCheck>false</BufferSecurityCheck>
85+
<ControlFlowGuard>false</ControlFlowGuard>
86+
<FunctionLevelLinking>true</FunctionLevelLinking>
87+
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
88+
<IntrinsicFunctions>true</IntrinsicFunctions>
89+
</ClCompile>
90+
<Link>
91+
<TargetMachine>MachineX86</TargetMachine>
92+
<GenerateDebugInformation>false</GenerateDebugInformation>
93+
<SubSystem>Console</SubSystem>
94+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
95+
<OptimizeReferences>true</OptimizeReferences>
96+
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
97+
<AdditionalDependencies>ws2_32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
98+
</Link>
99+
</ItemDefinitionGroup>
100+
<ItemGroup>
101+
<ClCompile Include="GameMemory.cpp" />
102+
<ClCompile Include="main.cpp" />
103+
</ItemGroup>
104+
<ItemGroup>
105+
<ClInclude Include="GameMemory.h" />
106+
</ItemGroup>
107+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
108+
<ImportGroup Label="ExtensionTargets">
109+
</ImportGroup>
110+
</Project>

GameMemory.cpp

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#include "GameMemory.h"
2+
#ifdef VISTA
3+
#define PSAPI_VERSION 1
4+
#endif
5+
#include <Psapi.h>
6+
#include <string>
7+
8+
void PlaceJMP(BYTE *bt_DetourAddress, DWORD dw_FunctionAddress, DWORD dw_Size)
9+
{
10+
DWORD dw_OldProtection, dw_Distance;
11+
VirtualProtect(bt_DetourAddress, dw_Size, PAGE_EXECUTE_READWRITE, &dw_OldProtection);
12+
dw_Distance = (DWORD)(dw_FunctionAddress - (DWORD)bt_DetourAddress) - 5;
13+
*bt_DetourAddress = 0xE9;
14+
*(DWORD*)(bt_DetourAddress + 0x1) = dw_Distance;
15+
for (DWORD i = 0x5; i < dw_Size; i++) *(bt_DetourAddress + i) = 0x90;
16+
VirtualProtect(bt_DetourAddress, dw_Size, dw_OldProtection, NULL);
17+
return;
18+
}
19+
20+
uintptr_t FindMemoryPattern(HANDLE ModuleHandle, char* strpattern, int length)
21+
{
22+
//Filter out junk and get a clean hex version of the signature
23+
unsigned char *signature = new unsigned char[length + 1];
24+
bool *skippable = new bool[length + 1];
25+
int signaturelength = 0;
26+
for (int byteoffset = 0; byteoffset < length - 1; byteoffset += 2)
27+
{
28+
char charhex[4]; //4 to keep sscanf happy
29+
*(short*)charhex = *(short*)&strpattern[byteoffset];
30+
if (charhex[0] != ' ')
31+
{
32+
if (charhex[0] == '?')
33+
{
34+
signature[signaturelength] = '?';
35+
skippable[signaturelength] = true;
36+
}
37+
else
38+
{
39+
//Convert ascii to hex
40+
charhex[2] = NULL; //add null terminator
41+
signature[signaturelength] = (unsigned char)std::stoul(charhex, nullptr, 16);
42+
43+
//sscanf(charhex, "%x", &signature[signaturelength]);
44+
skippable[signaturelength] = false;
45+
}
46+
signaturelength++;
47+
}
48+
}
49+
//double timetakentofilter = QPCTime() - startfilter;
50+
51+
//Search for the hex signature in memory
52+
int searchoffset = 0;
53+
int maxoffset = signaturelength - 1;
54+
55+
MODULEINFO dllinfo;
56+
GetModuleInformation(GetCurrentProcess(), (HMODULE)ModuleHandle, &dllinfo, sizeof(MODULEINFO));
57+
DWORD endadr = (DWORD)ModuleHandle + dllinfo.SizeOfImage;
58+
DWORD adrafterfirstmatch = NULL;
59+
for (DWORD adr = (DWORD)ModuleHandle; adr < endadr; adr++)
60+
{
61+
if (skippable[searchoffset] || *(char*)adr == signature[searchoffset] || *(unsigned char*)adr == signature[searchoffset])
62+
{
63+
if (searchoffset == 0)
64+
{
65+
adrafterfirstmatch = adr + 1;
66+
}
67+
searchoffset++;
68+
if (searchoffset > maxoffset)
69+
{
70+
delete[] signature;
71+
delete[] skippable;
72+
return adr - maxoffset; //FOUND OFFSET!
73+
}
74+
}
75+
else if (adrafterfirstmatch)
76+
{
77+
adr = adrafterfirstmatch;
78+
searchoffset = 0;
79+
adrafterfirstmatch = NULL;
80+
}
81+
}
82+
83+
delete[] signature;
84+
delete[] skippable;
85+
return NULL; //NOT FOUND!
86+
}

GameMemory.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
3+
#include <Windows.h>
4+
5+
void PlaceJMP(BYTE *bt_DetourAddress, DWORD dw_FunctionAddress, DWORD dw_Size);
6+
uintptr_t FindMemoryPattern(HANDLE ModuleHandle, char* strpattern, int length);

main.cpp

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#include <iostream>
2+
#include "GameMemory.h"
3+
4+
DWORD RunCmdJMPBackAddress;
5+
DWORD AnimstateUpdateJMPBackAddress;
6+
DWORD MoveHelperServer;
7+
int NumCommandsToRun;
8+
9+
//CBasePlayer::PhysicsSimulate -> RunCommand
10+
__declspec(naked) void OnRunCommand()
11+
{
12+
__asm {
13+
mov NumCommandsToRun, edi //store number of commands left to run
14+
mov eax, MoveHelperServer
15+
push[eax]
16+
jmp RunCmdJMPBackAddress
17+
}
18+
}
19+
20+
//CCSGOPlayerAnimState::Update
21+
__declspec(naked) void AnimStateUpdate()
22+
{
23+
__asm {
24+
cmp byte ptr ss : [ebp + 0x8], 0 //if argument to CCSGOPlayerAnimState::Update says to force update, then do it
25+
jne update
26+
cmp NumCommandsToRun, 1 //if the number of usercmds left to run is more than 1 then don't update animations
27+
jg dontupdateyet
28+
update :
29+
movss xmm1, [ecx + 0x10] //run code that we overwrote when detour hooking
30+
jmp AnimstateUpdateJMPBackAddress //return and update the animations
31+
32+
dontupdateyet : //don't update animations
33+
pop edi
34+
pop esi
35+
mov esp, ebp
36+
pop ebp
37+
retn 4
38+
}
39+
}
40+
41+
void Hook()
42+
{
43+
HMODULE serverhandle = NULL;
44+
while (!serverhandle)
45+
{
46+
serverhandle = GetModuleHandleA("server.dll");
47+
Sleep(50);
48+
}
49+
50+
printf("Hooking CBasePlayer::PhysicsSimulate..\n");
51+
char *physicssimulateruncommandloopsig = "FF 35 ?? ?? ?? ?? 8B 06 8B CE 53";
52+
DWORD adr = FindMemoryPattern(serverhandle, physicssimulateruncommandloopsig, strlen(physicssimulateruncommandloopsig));
53+
54+
if (!adr)
55+
{
56+
printf("ERROR: CAN'T FIND CBasePlayer::PhysicsSimulate SIGNATURE, EXITING!\n");
57+
Sleep(5000);
58+
exit(EXIT_SUCCESS);
59+
}
60+
61+
RunCmdJMPBackAddress = (adr + 6);
62+
MoveHelperServer = *(DWORD*)(adr + 2);
63+
PlaceJMP((BYTE*)adr, (DWORD)&OnRunCommand, 6);
64+
65+
printf("Hooking CCSGOPlayerAnimState::Update..\n");
66+
char *animstateupdatesig = "F3 0F 10 49 10 F3 0F 5C 4F 5C";
67+
adr = FindMemoryPattern(serverhandle, animstateupdatesig, strlen(animstateupdatesig));
68+
69+
if (!adr)
70+
{
71+
printf("ERROR: CAN'T FIND CCSGOPlayerAnimState::Update SIGNATURE, EXITING!\n");
72+
Sleep(5000);
73+
exit(EXIT_SUCCESS);
74+
}
75+
76+
AnimstateUpdateJMPBackAddress = (adr + 5);
77+
PlaceJMP((BYTE*)adr, (DWORD)&AnimStateUpdate, 5);
78+
}
79+
80+
81+
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
82+
{
83+
switch (ul_reason_for_call)
84+
{
85+
case DLL_PROCESS_ATTACH:
86+
{
87+
#if debugmode
88+
AllocConsole();
89+
FILE* fp;
90+
freopen_s(&fp, "CONOUT$", "w", stdout);
91+
#endif
92+
std::cout << "Mutiny Fake Angle Fix Injected" << std::endl;
93+
94+
break;
95+
}
96+
case DLL_THREAD_ATTACH:
97+
case DLL_THREAD_DETACH:
98+
case DLL_PROCESS_DETACH:
99+
break;
100+
}
101+
return TRUE;
102+
}

0 commit comments

Comments
 (0)