Skip to content

Commit 836536e

Browse files
committed
It Just Works:tm:
1 parent a01f2a4 commit 836536e

File tree

2 files changed

+17
-42
lines changed

2 files changed

+17
-42
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Includes **BunnyhopAPE** from [alkatrazbhop](https://github.com/alkatrazbhop/Bun
2222
* Download the latest RawInput2BunnyhopAPE.exe from the [Releases](https://github.com/rtldg/RawInput2BunnyhopAPE/releases) page.
2323
* Run RawInput2BunnyhopAPE.exe
2424
* Make sure to set ``m_rawinput 2`` in game for it to take effect.
25-
* `F5` to toggle autohop prediction (on by default)
25+
* `F5` to toggle autohop prediction (OFF by default) (you shouldn't need this anymore now that bhoptimer supports sv_autobunnyhopping)
2626
* `F6` to toggle the fullscreen hook thing which keeps the game open in fullscreen when you alt-tab (which is nice if you have two monitors) (off by default)
2727
* `F7` to toggle the viewpunch remover. Basically a client-side [SuppressViewpunch](https://github.com/xen-000/SuppressViewpunch) (on by default)
2828

RawInput2/main.cpp

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#define DO_FASTDL_THINGS 0
44
#define DO_FULLSCREEN_PATCH 1
55
#define DO_VIEWPUNCH_PATCH 1
6-
#define TESTING_ON_TF2 1
76

87
#define _CRT_SECURE_NO_WARNINGS
98
#include <Windows.h>
@@ -210,7 +209,7 @@ void GetAccumulatedMouseDeltasAndResetAccumulators(CInput* thisptr, float* mx, f
210209

211210
int m_rawinput = *m_rawinput_cvar;
212211

213-
ConMsg("GetAccumulatedMouseDeltasAndResetAccumulators: %.3f | %.3f | %d\n", *(float*)m_flAccumulatedMouseXMovement, *(float*)m_flAccumulatedMouseYMovement, m_rawinput);
212+
//ConMsg("GetAccumulatedMouseDeltasAndResetAccumulators: %.3f | %.3f | %d\n", *(float*)m_flAccumulatedMouseXMovement, *(float*)m_flAccumulatedMouseYMovement, m_rawinput);
214213

215214
if (m_flMouseSampleTime > 0.0)
216215
{
@@ -680,18 +679,10 @@ DWORD InjectionEntryPoint(DWORD processID)
680679

681680
// Search for CallWindowProc[A] in inputsystem.dll. You should find it called from `CInputSystem::ChainWindowMessage()` (which is called by `CInputSystem::WindowProc()`).
682681
// On x64 (and maybe x32) you'll probably find `ChainWindowMessage` inlined into `CInputSystem::WindowProc()`.
683-
#if TESTING_ON_TF2
684682
oWindowProc = (WindowProcFn)(FindPattern("inputsystem.dll", "44 89 44 24 ? 48 89 54 24"));
685-
#else
686-
oWindowProc = (WindowProcFn)(FindPattern("inputsystem.dll", ""));
687-
#endif
688683

689684
// You can find this function by searching for the string that starts with "setpos_exact %f %f %f".
690-
#if TESTING_ON_TF2
691685
oCHostState_OnClientConnected = (CHostState_OnClientConnectedFn)(FindPattern("engine.dll", "40 53 48 83 EC 60 80 B9 ? ? ? ? 00 48 8B D9 0F 84"));
692-
#else
693-
oCHostState_OnClientConnected = (CHostState_OnClientConnectedFn)(FindPattern("engine.dll", ""));
694-
#endif
695686

696687
#if DO_RAWINPUT2
697688
auto inputsystem_factory = reinterpret_cast<CreateInterfaceFn>(GetProcAddress(GetModuleHandleA("inputsystem.dll"), "CreateInterface"));
@@ -725,6 +716,7 @@ DWORD InjectionEntryPoint(DWORD processID)
725716
oGetAccumulatedMouseDeltasAndResetAccumulators = (GetAccumulatedMouseDeltasAndResetAccumulatorsFn)(FindPattern("client.dll", "48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 20 8B 41 ? 49 8B F8"));
726717
// actually the instruction is a MOV here 😇
727718
m_rawinput_cvar = (int*)((uintptr_t)AddrFromLea((uintptr_t)oGetAccumulatedMouseDeltasAndResetAccumulators + 35) + 0x20);
719+
// TODO: This is AWFUL!!!! Will probably break one day... just use Safetyhook inline/mid-function hooks when that happens and hope for the best lol...
728720
/*
729721
Thunk:
730722
push rcx
@@ -850,22 +842,22 @@ DWORD InjectionEntryPoint(DWORD processID)
850842

851843
BYTE nopBuffer[6] = { 0x90,0x90,0x90,0x90,0x90,0x90 };
852844
BYTE jumpPredOriginalBytes[6];
853-
// Search for the float32 268.3281572999747 in client.dll and then find the `// don't pogo stick` if-statement
854-
#if TESTING_ON_TF2
855-
auto jumpPred = reinterpret_cast<void*>(FindPattern("client.dll", "F6 40 ? 02 0F 85 ? ? ? ? 80 B9 ? ? ? ? 00") + 4);
856-
#else
857-
auto jumpPred = reinterpret_cast<void*>(FindPattern("client.dll", "") + 0);
858-
#endif
845+
// Search for float64 (DOUBLE!!) 301.993377410829964447 to find the place where sv_autobunnyhopping & the `// don't pogo stick` if-statment used to be...
846+
// Might be easier to follow the sv_autobunnyhopping cvar than this f64 but whatever...
847+
// then sig the `TEST byte ptr [REGISTER + 0xOFFSET], 0x2` instruction.
848+
auto jumpPred = reinterpret_cast<void*>(FindPattern("client.dll", "F6 40 ? 02 75 ? 48 8B 05"));
859849
ConMsg("jumpPred = 0x%llx\n", jumpPred);
860850
memcpy(jumpPredOriginalBytes, jumpPred, sizeof(jumpPredOriginalBytes));
861851
DWORD jumpPredOriginalProtect;
862852
VirtualProtect(jumpPred, sizeof(jumpPredOriginalBytes), PAGE_EXECUTE_READWRITE, &jumpPredOriginalProtect);
863-
memcpy(jumpPred, nopBuffer, sizeof(nopBuffer));
853+
//memcpy(jumpPred, nopBuffer, sizeof(nopBuffer));
864854

865855
#if DO_FULLSCREEN_PATCH
866-
// Find CVideoMode_MaterialSystem::RestoreVideo() by searching for winapi the `ShowWindow(hwnd,6);` (SW_MINIMIZE) call.
867-
// Then try scroll up to the previous function in the assembly... and hopefully you found ::ReleaseVideo()...
856+
// Search for `ShowWindow(hwnd,6);` (SW_MINIMIZE) call to find CVideoMode_MaterialSystem::ReleaseVideo() (with an inlined ReleaseFullScreen).
857+
// Add X bytes to get to the first JNZ...
868858
auto pReleaseVideo = (void*)(FindPattern("engine.dll", "40 53 48 83 EC 20 48 8B 01 48 8B D9 FF 90 ? ? ? ? 84 C0 75 ? 48 8B 03 48 8B CB 48 83 C4 20 5B 48 FF A0 ? ? ? ? 48 83 C4 20 5B C3") + 20);
859+
DWORD pReleaseVideoOriginalProtect;
860+
VirtualProtect(pReleaseVideo, 1, PAGE_EXECUTE_READWRITE, &pReleaseVideoOriginalProtect);
869861
/*
870862
Find this (by searching for the ShowWindow(hwnd,7) call):
871863
if (((*(uint *)(*(longlong *)(param_1 + 0x10) + 0x78) & 0x800) == 0) && (param_2 != 0)) {
@@ -880,8 +872,7 @@ DWORD InjectionEntryPoint(DWORD processID)
880872
And get the sig of the jz instruction around the ShowWindow(hwnd,7) call.
881873
*/
882874
auto pFUCKD3D9 = (void*)FindPattern("d3d9.dll", "0F 84 ? ? ? ? 48 8B 8B ? ? ? ? BA 07 00 00 00");
883-
DWORD pReleaseVideoOriginalProtect, pFUCKD3D9OriginalProtect;
884-
VirtualProtect(pReleaseVideo, 1, PAGE_EXECUTE_READWRITE, &pReleaseVideoOriginalProtect);
875+
DWORD pFUCKD3D9OriginalProtect;
885876
VirtualProtect(pFUCKD3D9, 2, PAGE_EXECUTE_READWRITE, &pFUCKD3D9OriginalProtect);
886877
#endif
887878

@@ -934,7 +925,7 @@ DWORD InjectionEntryPoint(DWORD processID)
934925
#endif
935926
DetourTransactionCommit();
936927

937-
bool jumpPredPatched = true;
928+
bool jumpPredPatched = false;
938929
bool fullScreenPatched = false;
939930
bool fuckViewpunch = true;
940931

@@ -983,7 +974,7 @@ DWORD InjectionEntryPoint(DWORD processID)
983974
m_vecPunchAngle_RecvProp[6] = RecvProxy_ZeroToVector;
984975
}
985976
fuckViewpunch = !fuckViewpunch;
986-
CBaseHudChat_ChatPrintf(CHud_FindElement((void*)gHUD, "CHudChat"), 0, 0, "Viewpunch: %d", !fuckViewpunch);
977+
CBaseHudChat_ChatPrintf(CHud_FindElement((void*)gHUD, "CHudChat"), 0, 0, "Viewpunch: %s", fuckViewpunch ? "BLOCKED" : "YES");
987978
}
988979
#endif
989980
}
@@ -1126,22 +1117,14 @@ std::string GetCSSPath(std::string const & steampath)
11261117
library_path = ReplaceString(library_path, "\\\\", "\\");
11271118
}
11281119

1129-
#if TESTING_ON_TF2
1130-
if (line.rfind("\t\t\t\"440\"", 0) == 0)
1131-
#else
11321120
if (line.rfind("\t\t\t\"240\"", 0) == 0)
1133-
#endif
11341121
{
11351122
css_path = library_path;
11361123
break;
11371124
}
11381125
}
11391126
if (css_path != "")
1140-
#if TESTING_ON_TF2
1141-
css_path += "\\steamapps\\common\\Team Fortress 2\\";
1142-
#else
11431127
css_path += "\\steamapps\\common\\Counter-Strike Source\\";
1144-
#endif
11451128
return css_path;
11461129
}
11471130

@@ -1162,11 +1145,7 @@ std::string GetCSSLaunchOptions(std::string const & steampath, std::string const
11621145
bool in_css = false;
11631146
while (std::getline(localconfig, line))
11641147
{
1165-
#if TESTING_ON_TF2
1166-
if (line.rfind("\t\t\t\t\t\"440\"", 0) == 0)
1167-
#else
11681148
if (line.rfind("\t\t\t\t\t\"240\"", 0) == 0)
1169-
#endif
11701149
in_css = true;
11711150
if (line.rfind("\t\t\t\t\t}", 0) == 0)
11721151
in_css = false;
@@ -1203,15 +1182,11 @@ int main()
12031182
auto steam_path = GetSteamPath();
12041183
printf("steampath = %s\n", steam_path.c_str());
12051184
auto launch_options = GetCSSLaunchOptions(steam_path, steamid3);
1206-
launch_options = "-steam -insecure -novid -console " + launch_options;
1185+
launch_options = "-insecure -novid -console " + launch_options;
12071186
printf("launchopt = %s\n", launch_options.c_str());
12081187
auto css_path = GetCSSPath(steam_path);
12091188
printf("css path = %s\n\n", css_path.c_str());
1210-
#if TESTING_ON_TF2
1211-
auto css_exe = css_path + "tf_win64.exe";
1212-
#else
12131189
auto css_exe = css_path + "cstrike_win64.exe";
1214-
#endif
12151190

12161191
PROCESS_INFORMATION pi = {};
12171192
STARTUPINFOA si = {};
@@ -1246,7 +1221,7 @@ int main()
12461221
}
12471222

12481223
//system("cls");
1249-
printf("Set \"m_rawinput 2\" in game for it to take effect\n\nPress F5 to toggle BunnyhopAPE autobhop prediction (on by default)\nPress F6 to toggle the fullscreen hook (you probably don't want this)\nPress F7 to toggle the viewpunch remover (e.g. from fall-damage) (on by default)\n");
1224+
printf("Set \"m_rawinput 2\" in game for it to take effect\n\nPress F5 to toggle BunnyhopAPE autobhop prediction (OFF by default)\n (you shouldn't need this now that bhoptimer supports sv_autobunnyhopping)\nPress F6 to toggle the fullscreen hook (you probably don't want this)\nPress F7 to toggle the viewpunch remover (e.g. from fall-damage) (on by default)\n");
12501225

12511226
PEInjector(pi.hProcess, InjectionEntryPoint);
12521227

0 commit comments

Comments
 (0)