summaryrefslogtreecommitdiffstats
path: root/src/cinput.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cinput.cpp')
-rw-r--r--src/cinput.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/cinput.cpp b/src/cinput.cpp
index 45e2b04..9cad30d 100644
--- a/src/cinput.cpp
+++ b/src/cinput.cpp
@@ -159,22 +159,18 @@ static void hkdInputCreateMove(void *self, int seq, float frametime,
159static bool install_input_hook() { 159static bool install_input_hook() {
160 if (!g_input) 160 if (!g_input)
161 return false; 161 return false;
162 void **vt = VTABLE((void *)g_input); 162 if (!*(void ***)g_input)
163 if (!vt)
164 return false; 163 return false;
165 constexpr size_t N = 64; 164 VtablePatch patches[] = {
166 void **nvt = vtable_clone((void *)g_input, N); 165 {3, (void *)&hkdInputCreateMove,
167 if (!nvt) { 166 reinterpret_cast<void **>(&oInputCreateMove)},
168 logf("CInput vtable clone failed"); 167 {4, (void *)&hkdInputExtraMouseSample,
168 reinterpret_cast<void **>(&oInputExtraMouseSample)},
169 };
170 if (!hooks_install_vtable((void *)g_input, 64, patches, 2)) {
171 logf("CInput vtable patch failed");
169 return false; 172 return false;
170 } 173 }
171 oInputCreateMove = (InputCreateMoveFn)vt[3];
172 nvt[3] = (void *)&hkdInputCreateMove;
173 if (N > 4) {
174 oInputExtraMouseSample = (InputExtraMouseFn)vt[4];
175 nvt[4] = (void *)&hkdInputExtraMouseSample;
176 }
177 VTABLE((void *)g_input) = nvt;
178 logf("CInput CreateMove hooked: slot 3 orig=%p; ExtraMouseSample slot 4 " 174 logf("CInput CreateMove hooked: slot 3 orig=%p; ExtraMouseSample slot 4 "
179 "orig=%p", 175 "orig=%p",
180 (void *)oInputCreateMove, (void *)oInputExtraMouseSample); 176 (void *)oInputCreateMove, (void *)oInputExtraMouseSample);