-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4dadc3a
commit 26b8aba
Showing
3 changed files
with
285 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="12.0" 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> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="ape.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="ape_helpers.h" /> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>{1FB1F37D-D8B8-45AD-B67D-831DDE6215AF}</ProjectGuid> | ||
<Keyword>Win32Proj</Keyword> | ||
<RootNamespace>BunnyhopAPE</RootNamespace> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v120</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v120</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>MultiByte</CharacterSet> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</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> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
<GenerateManifest>false</GenerateManifest> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<PrecompiledHeader> | ||
</PrecompiledHeader> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>Disabled</Optimization> | ||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<PrecompiledHeader> | ||
</PrecompiledHeader> | ||
<Optimization>MaxSpeed</Optimization> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>false</GenerateDebugInformation> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<AdditionalDependencies>ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||
<ProgramDatabaseFile /> | ||
<ManifestFile /> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#include <Windows.h> | ||
#include <iostream> | ||
#include <stdio.h> | ||
#include <conio.h> | ||
#include "ape_helpers.h" | ||
|
||
HANDLE g_hProcess; | ||
BYTE* g_pJumpPrediction; | ||
BYTE g_patchedBuffer[6]; | ||
BYTE g_nopBuffer[6] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; | ||
bool g_bPatched; | ||
int g_iOldState; | ||
|
||
void Error(char* text) | ||
{ | ||
MessageBox(0, text, "ERROR", 16); | ||
ExitProcess(0); | ||
} | ||
|
||
void UpdateConlole() | ||
{ | ||
system("cls"); | ||
printf("Use SCROLL LOCK to toggle prediction.\nPrediction status: %s\n", g_bPatched ? "ON" : "OFF"); | ||
} | ||
|
||
void EnablePrediction() | ||
{ | ||
ReadProcessMemory(g_hProcess, g_pJumpPrediction, g_patchedBuffer, 6, NULL); | ||
|
||
if (WriteProcessMemory(g_hProcess, g_pJumpPrediction, g_nopBuffer, 6, NULL)) | ||
g_bPatched = true; | ||
else Error("Game is already patched or signatures are outdated!"); | ||
|
||
UpdateConlole(); | ||
} | ||
|
||
void DisablePrediction(bool notify = true) | ||
{ | ||
if (WriteProcessMemory(g_hProcess, g_pJumpPrediction, g_patchedBuffer, 6, NULL)) | ||
{ | ||
if (notify) | ||
g_bPatched = false; | ||
} | ||
else Error("Memory access violation!"); | ||
|
||
UpdateConlole(); | ||
} | ||
|
||
bool WINAPI ConsoleHandler(DWORD dwCtrlType) | ||
{ | ||
if (dwCtrlType == CTRL_CLOSE_EVENT && g_bPatched) | ||
DisablePrediction(false); | ||
else return 1; | ||
return 0; | ||
} | ||
|
||
int main() | ||
{ | ||
SetConsoleTitle("CS:S Autobhop Prediction Enabler by alkatrazbhop"); | ||
|
||
DWORD processID; | ||
printf("Waiting for CS:S to start..."); | ||
while (1) | ||
{ | ||
processID = GetPIDByName("hl2.exe"); | ||
if (processID) break; | ||
Sleep(1000); | ||
} | ||
|
||
g_hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID); | ||
|
||
DWORD pClient; | ||
while (1) | ||
{ | ||
pClient = (DWORD)GetModuleHandleExtern(processID, "client.dll"); | ||
if (pClient) break; | ||
Sleep(100); | ||
} | ||
|
||
DWORD pHL = (DWORD)GetModuleHandleExtern(processID, "hl2.exe"); | ||
DWORD* pCmdLine = (DWORD*)(FindPatternEx(g_hProcess, pHL, 0x4000, (PBYTE)"\x85\xC0\x79\x08\x6A\x08", "xxxxxx") - 0x13); | ||
char* cmdLine = new char[255]; | ||
ReadProcessMemory(g_hProcess, pCmdLine, &pCmdLine, sizeof(DWORD), NULL); | ||
ReadProcessMemory(g_hProcess, pCmdLine, &pCmdLine, sizeof(DWORD), NULL); | ||
ReadProcessMemory(g_hProcess, pCmdLine, cmdLine, 255, NULL); | ||
if (!strstr(cmdLine, " -insecure")) | ||
Error("-insecure key is missing!"); | ||
|
||
g_pJumpPrediction = (BYTE*)(FindPatternEx(g_hProcess, pClient, 0x200000, (PBYTE)"\x85\xC0\x8B\x46\x08\x0F\x84\x00\xFF\xFF\xFF\xF6\x40\x28\x02\x0F\x85\x00\xFF\xFF\xFF", "xxxxxxx?xxxxxxxxx?xxx")) + 15; | ||
|
||
SetConsoleCtrlHandler((PHANDLER_ROUTINE)&ConsoleHandler, true); | ||
UpdateConlole(); | ||
|
||
while (1) | ||
{ | ||
if (GetKeyState(VK_SCROLL) & 1 && !g_bPatched) | ||
EnablePrediction(); | ||
else if (!(GetKeyState(VK_SCROLL) & 1) && g_bPatched) | ||
DisablePrediction(); | ||
Sleep(100); | ||
} | ||
|
||
CloseHandle(g_hProcess); | ||
while (_getch() != VK_RETURN) {} | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#include <TlHelp32.h> | ||
#include <winternl.h> | ||
|
||
DWORD GetPIDByName(const char* ProcName) | ||
{ | ||
PROCESSENTRY32 pe32; | ||
HANDLE hSnapshot = NULL; | ||
|
||
pe32.dwSize = sizeof(PROCESSENTRY32); | ||
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); | ||
|
||
if (Process32First(hSnapshot, &pe32)) | ||
{ | ||
do{ | ||
if (strcmp(pe32.szExeFile, ProcName) == 0) | ||
return pe32.th32ProcessID; | ||
} while (Process32Next(hSnapshot, &pe32)); | ||
} | ||
|
||
if (hSnapshot != INVALID_HANDLE_VALUE) | ||
CloseHandle(hSnapshot); | ||
|
||
return NULL; | ||
} | ||
|
||
DWORD GetModuleHandleExtern(DWORD dwProcessId, LPSTR lpModuleName) | ||
{ | ||
MODULEENTRY32 lpModuleEntry = { 0 }; | ||
HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessId); | ||
if (!hSnapShot) return NULL; | ||
|
||
lpModuleEntry.dwSize = sizeof(lpModuleEntry); | ||
BOOL bModule = Module32First(hSnapShot, &lpModuleEntry); | ||
|
||
while (bModule) | ||
{ | ||
if (!strcmp(lpModuleEntry.szModule, lpModuleName)) | ||
{ | ||
CloseHandle(hSnapShot); | ||
return (DWORD)lpModuleEntry.modBaseAddr; | ||
} | ||
|
||
bModule = Module32Next(hSnapShot, &lpModuleEntry); | ||
} | ||
|
||
CloseHandle(hSnapShot); | ||
return NULL; | ||
} | ||
|
||
bool DataCompare(BYTE* pData, BYTE* bSig, char* szMask) | ||
{ | ||
for (; *szMask; ++szMask, ++pData, ++bSig) | ||
{ | ||
if (*szMask == 'x' && *pData != *bSig) | ||
return false; | ||
} | ||
return (*szMask) == NULL; | ||
} | ||
|
||
DWORD FindPatternEx(HANDLE hProc, DWORD base, DWORD len, BYTE* sig, char* mask) | ||
{ | ||
BYTE* buf = (BYTE*)VirtualAlloc(0, len, MEM_COMMIT, PAGE_EXECUTE_READWRITE); | ||
if (ReadProcessMemory(hProc, (LPCVOID)base, buf, len, NULL)) | ||
{ | ||
for (DWORD i = 0; i <= (len - strlen(mask)); i++) | ||
{ | ||
if ((buf[i] == sig[0] && mask[0] == 'x') || (mask[0] == '?')) | ||
{ | ||
for (int x = 0;; x++) | ||
{ | ||
if (mask[x] == 'x') | ||
{ | ||
if (buf[i + x] == sig[x]) | ||
continue; | ||
else | ||
break; | ||
} | ||
else if (mask[x] == 0x00) | ||
{ | ||
return (DWORD)(base + i); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return NULL; | ||
} |