forked from eeveelo/PapyrusUtil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Offsets.cpp
126 lines (104 loc) · 4.08 KB
/
Offsets.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include "Offsets.h"
// N.B. The IDs below were used in the official v4.3 mod, which
// supported SKSE2.1.5 / Skyrim 1.6.353. My reading of
// https://www.nexusmods.com/skyrimspecialedition/mods/32444?tab=posts
// is that the IDs for all 1.6.x version remain the same (they *were*
// broken between 1.5.97 to 1.6.x). So as long as you are using
// the All In One (Anniversary Edition) of the Address Library,
// which contains versionlib-1-6-659-0.bin (GOG), looking up
// these hardcoded address IDs below should still give us the correct
// offsets from the module base addresses.
// - noxsidereum, nov 2022
// ---------------------------------------------------
// Offsets used by MiscUtil.cpp:
// ---------------------------------------------------
// ToggleFreeCamera(PlayerCamera *, bool stopTime)
// where PlayerCamera is defined in skse64/GameCamera.h
unsigned long long Offset_ToggleFreeCam = 0; // 50809
// ---------------------------------------------------
// Offsets used by PackageData.cpp:
// ---------------------------------------------------
// Packages::IsValidPackage(TESPackage *PackageID, Actor *ActorID)
unsigned long long Offset_IsValidPackage = 0; // 29619
// TESPackage *PackageStartOrig(void *pthis, Actor *actor)
unsigned long long Offset_PackageStartOrig = 0; // 12057
// UInt64 PackageEndOrig(void *pthis, void *arg1, Actor *actor, int PackID)
unsigned long long Offset_PackageEndOrig = 0; // 69166
// Used by InitPlugin()
// While the offsets returned by FindOffsetByID(37398) and
// FindOffsetByID(53984) should still be valid for the GOG
// version, it's not necessarily true that the increments
// +0x47 and +0x103 are. Let's just hope that hasn't
// changed between 1.6.353 and 1.6.659...
unsigned long long Offset_PackageStart_Enter = 0; // 37398 + 0x47
unsigned long long Offset_PackageEnd_Enter = 0; // 53984 + 0x103
namespace Plugin {
bool InitializeOffsets()
{
// This function is based on the sample code in the "How to Use" section at
// https://www.nexusmods.com/skyrimspecialedition/mods/32444
VersionDb db;
// Load database with current executable version.
if (!db.Load())
{
_FATALERROR("Failed to load version database for current executable!");
return false;
}
else
{
_MESSAGE("Loaded database for %s version %s.",
db.GetModuleName().c_str(), db.GetLoadedVersionString().c_str());
}
if (!db.FindOffsetById(50809, Offset_ToggleFreeCam))
{
_FATALERROR("Failed to find version database address for ToggleFreeCam!");
return false;
}
if (!db.FindOffsetById(29619, Offset_IsValidPackage))
{
_FATALERROR("Failed to find version database address for IsValidPackage!");
return false;
}
if (!db.FindOffsetById(12057, Offset_PackageStartOrig))
{
_FATALERROR("Failed to find version database address for PackageStartOrig!");
return false;
}
if (!db.FindOffsetById(69166, Offset_PackageEndOrig))
{
_FATALERROR("Failed to find version database address for PackageEndOrig!");
return false;
}
if (!db.FindOffsetById(37398, Offset_PackageStart_Enter))
{
_FATALERROR("Failed to find version database address for PackageStartEnter!");
return false;
}
Offset_PackageStart_Enter += 0x47;
if (!db.FindOffsetById(53984, Offset_PackageEnd_Enter))
{
_FATALERROR("Failed to find version database address for PackageEndEnter!");
return false;
}
Offset_PackageEnd_Enter += 0x103;
return true;
}
// DEBUGGING FUNCTIONS
// Based on the sample code in the "How to Use" section at
// https://www.nexusmods.com/skyrimspecialedition/mods/32444
bool DumpSpecificVersion()
{
VersionDb db;
// Try to load database of version 1.6.659.0 regardless of running executable version.
if (!db.Load(1, 6, 659, 0))
{
_FATALERROR("Failed to load database for 1.6.659.0!");
return false;
}
// Write out a file called offsets-1.6.659.0.txt where each line is the ID and offset.
// This file will be saved in the main Skyrim folder.
db.Dump("offsets-1.6.659.0.txt");
_MESSAGE("Dumped offsets for 1.6.659.0");
return true;
}
}