-
Notifications
You must be signed in to change notification settings - Fork 2
/
Hooks.cpp
74 lines (55 loc) · 1.51 KB
/
Hooks.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "skse/SafeWrite.h"
#include "skse/GameMenus.h"
#include "Hooks.h"
TESObjectREFR* g_pickedLock = (TESObjectREFR*)0x01B3FB88; // used by vanilla lockpicking menu
TESObjectREFR* g_stolenHorse;
TESObjectREFR* g_discoveredMarker;
BGSLocation* g_clearedLocation;
// ======================================================
// Gameplay
// ======================================================
const UInt32 kClearedCheck = 0x004B15B0;
const UInt32 kClearedEnt = kClearedCheck + 0x3;
const UInt32 kClearedRet = kClearedCheck + 0x8;
__declspec(naked) void HookLocationCleared()
{
__asm
{
mov g_clearedLocation, ecx
cmp [esp+2Ch], 0
jmp [kClearedRet]
}
}
const UInt32 kDiscoveryCheck = 0x00744660;
const UInt32 kDiscoveryEnt = kDiscoveryCheck + 0xCC;
const UInt32 kDiscoveryRet = kDiscoveryCheck + 0xD1;
__declspec(naked) void HookLocationDiscovery()
{
__asm
{
mov g_discoveredMarker, edi
add esp, 8
test edi, edi
jmp [kDiscoveryRet]
}
}
const UInt32 kHorseStealCheck = 0x006CC0D0;
const UInt32 kHorseStealEnt = kHorseStealCheck + 0x326;
const UInt32 kHorseStealRet = kHorseStealCheck + 0x32B;
__declspec(naked) void HookHorseSteal()
{
__asm
{
mov eax, [esp+18h]
mov g_stolenHorse, eax
mov eax, g_thePlayer
jmp [kHorseStealRet]
}
}
void WriteHooks()
{
_MESSAGE("Writing hooks...");
WriteRelJump(kClearedEnt, (UInt32)HookLocationCleared);
// WriteRelJump(kDiscoveryEnt, (UInt32)HookLocationDiscovery);
WriteRelJump(kHorseStealEnt, (UInt32)HookHorseSteal);
}