Skip to content

Commit fb54158

Browse files
committed
Move prop count check mid-hook to earlier in function
On Windows this hook overrode instructions at the start of the block, which is a jump target for the extension. This made it jump to invalid binary since the real instructions were moved to the trampoline. There is a debug print block right before it, which functionally doesn't do anything for us, so we can hook there instead.
1 parent 3eb7e9d commit fb54158

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

extension.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,8 +1211,8 @@ void MidHook_SV_DetermineUpdateType_PackCheck(safetyhook::Context &registers)
12111211
}
12121212

12131213
// skip changed prop count check if there is a set edit
1214-
safetyhook::MidHook g_MidHook_SV_DetermineUpdateType_PropCountCheck{};
1215-
void MidHook_SV_DetermineUpdateType_PropCountCheck(safetyhook::Context &registers)
1214+
safetyhook::MidHook g_MidHook_SV_DetermineUpdateType_VCRPrintCheck{};
1215+
void MidHook_SV_DetermineUpdateType_VCRPrintCheck(safetyhook::Context &registers)
12161216
{
12171217
Context context(registers);
12181218

@@ -1548,17 +1548,17 @@ bool SendVarEdit::SDK_OnLoad(char* error, size_t maxlength, bool late)
15481548
g_MidHook_SV_DetermineUpdateType_PackCheck = std::move(*midhook);
15491549
}
15501550

1551-
// create a mid-hook at the SV_DetermineUpdateType positive propcount check that always passes the check if a set edit was made
1551+
// create a mid-hook at the SV_DetermineUpdateType VCR print check that always passes the positive propcount check if a set edit was made
15521552
{
15531553
void* address;
1554-
if (!gameconf->GetAddress("SV_DetermineUpdateType positive propcount check", &address))
1555-
RETURN_ERROR("Failed to find SV_DetermineUpdateType positive propcount check.");
1554+
if (!gameconf->GetAddress("SV_DetermineUpdateType VCR print check", &address))
1555+
RETURN_ERROR("Failed to find SV_DetermineUpdateType VCR print check.");
15561556

1557-
auto midhook = safetyhook::MidHook::create(address, MidHook_SV_DetermineUpdateType_PropCountCheck);
1557+
auto midhook = safetyhook::MidHook::create(address, MidHook_SV_DetermineUpdateType_VCRPrintCheck);
15581558
if (!midhook.has_value())
1559-
RETURN_ERROR("Failed to mid-hook SV_DetermineUpdateType positive propcount check.");
1559+
RETURN_ERROR("Failed to mid-hook SV_DetermineUpdateType VCR print check.");
15601560

1561-
g_MidHook_SV_DetermineUpdateType_PropCountCheck = std::move(*midhook);
1561+
g_MidHook_SV_DetermineUpdateType_VCRPrintCheck = std::move(*midhook);
15621562
}
15631563

15641564
// create a mid-hook at the SendTable_WritePropList loop break condition that skips to the continuation point if an edit was made
@@ -1637,8 +1637,8 @@ void SendVarEdit::SDK_OnUnload()
16371637
if (g_MidHook_SendTable_WritePropList_BreakCondition.enabled())
16381638
g_MidHook_SendTable_WritePropList_BreakCondition = {};
16391639

1640-
if (g_MidHook_SV_DetermineUpdateType_PropCountCheck.enabled())
1641-
g_MidHook_SV_DetermineUpdateType_PropCountCheck = {};
1640+
if (g_MidHook_SV_DetermineUpdateType_VCRPrintCheck.enabled())
1641+
g_MidHook_SV_DetermineUpdateType_VCRPrintCheck = {};
16421642

16431643
if (g_MidHook_SV_DetermineUpdateType_PackCheck.enabled())
16441644
g_MidHook_SV_DetermineUpdateType_PackCheck = {};

gamedata/sendvaredit.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@
136136
// 8B 4E ? 8D 85 ? ? ? ? 68 00 10 00 00
137137
}
138138

139-
"SV_DetermineUpdateType positive propcount check"
139+
"SV_DetermineUpdateType VCR print check"
140140
{
141141
"library" "engine"
142-
"linux" "\x85\xF6\x7F\x2A\x80\xBB\x2A\x2A\x2A\x2A\x00"
143-
// 85 F6 7F ? 80 BB ? ? ? ? 00
144-
"windows" "\x85\xFF\x7E\x2A\x6A\x00"
145-
// 85 FF 7E ? 6A 00
142+
"linux" "\xA1\x2A\x2A\x2A\x2A\x8B\x40\x2A\x85\xC0\x74\x2A\x8D\x04\xB5\x2A\x2A\x2A\x2A"
143+
// A1 ? ? ? ? 8B 40 ? 85 C0 74 ? 8D 04 B5 ? ? ? ?
144+
"windows" "\xA1\x2A\x2A\x2A\x2A\x83\x78\x2A\x00\x74\x2A\xA1\x2A\x2A\x2A\x2A\x8B\x08"
145+
// A1 ? ? ? ? 83 78 ? 00 74 ? A1 ? ? ? ? 8B 08
146146
}
147147

148148
"SV_DetermineUpdateType positive propcount block"
@@ -217,9 +217,9 @@
217217
"signature" "SV_DetermineUpdateType props changed call"
218218
}
219219

220-
"SV_DetermineUpdateType positive propcount check"
220+
"SV_DetermineUpdateType VCR print check"
221221
{
222-
"signature" "SV_DetermineUpdateType positive propcount check"
222+
"signature" "SV_DetermineUpdateType VCR print check"
223223
}
224224

225225
"SV_DetermineUpdateType positive propcount block"

0 commit comments

Comments
 (0)