

#include "versiondb.h"
void * MyAddress = NULL;
unsigned long long MyOffset = 0;
bool InitializeOffsets()
{
// Allocate on stack so it will be unloaded when we exit this function.
// No need to have the whole database loaded and using up memory for no reason.
VersionDb db;
// Load database with current executable version.
if (!db.Load())
{
_FATALERROR("Failed to load version database for current executable!");
}
else
{
// "SkyrimSE.exe", "1.5.97.0"
_MESSAGE("Loaded database for %s version %s.", db.GetModuleName().c_str(), db.GetLoadedVersionString().c_str());
}
// This address already includes the base address of module so we can use the address directly.
MyAddress = db.FindAddressById(123);
if (MyAddress == NULL)
{
_FATALERROR("Failed to find address!");
return false;
}
// This offset does not include base address. Actual address would be ModuleBase + MyOffset.
if (!db.FindOffsetById(123, MyOffset))
{
_FATALERROR("Failed to find offset for my thing!");
}
// Everything was successful.
return true;
}
#include "versiondb.h"
Boolean dump SpecificVersion ()
{
VersionDb db;
// Try to load database of version 1.5.62.0 regardless of running executable version.
if (!db.Load(1, 5, 62, 0))
{
_FATALERROR("Failed to load database for 1.5.62.0!");
return false;
}
// Write out a file called offsets-1.5.62.0.txt where each line is the ID and offset.
db.Dump("offsets-1.5.62.0.txt");
_MESSAGE("Dumped offsets for 1.5.62.0");
return true;
}
void* addressOf142F4DEF8 = db.FindAddressById(517014);
bool Dump(const std::string& path); // Dump currently loaded database to file
bool Load(int major, int minor, int revision, int build); // Load a specific version if the db-major-minor-revision-build.bin exists in Data/SKSE/Plugins directory
bool Load(); // Load the version for current application
void Clear(); // Clear currently loaded database
void GetLoadedVersion(int& major, int& minor, int& revision, int& build) const; // Get the version of database file we have loaded right now
bool GetExecutableVersion(int& major, int& minor, int& revision, int& build) const; // Get the version of currently executing application
const std::string& GetModuleName() const; // Get the name of currently loaded database module, this should show "SkyrimSE.exe"
const std::string& GetLoadedVersionString() const; // Get the currently loaded version as string, e.g. "1.5.62.0"
const std::map& GetOffsetMap() const; // Get the map of ID to offset if you need to iterate it manually
void* FindAddressById(unsigned long long id) const; // Find address by ID, this will already include base and be correct address. It will return NULL if not found!
bool FindOffsetById(unsigned long long id, unsigned long long& result) const; // Find offset by ID, this will just be offset without base included.
bool FindIdByAddress(void* ptr, unsigned long long& result) const; // Find ID by address, this will attempt a reverse lookup to convert address to ID
bool FindIdByOffset(unsigned long long offset, unsigned long long& result) const; // Find ID by offset, this will attempt a reverse lookup to convert offset to ID
bool LoadAll(std::vector& all)
{
static int versions[] = { 3, 16, 23, 39, 50, 53, 62, 73, 80, 97, -1 };
for (int i = 0; versions [i] > = 0; i + +)
{
VersionDb * db = new VersionDb();
if (!db->Load(1, 5, versions[i], 0))
{
delete db;
return false;
}
all.push_back(db);
}
return true;
}
bool ExistsInAll(std::vector& all, unsigned long long id)
{
unsigned long long result = 0;
{
if (!db->FindOffsetById(id, result))
}
return true;
}
void FreeAll(std::vector& all)
{
for (auto db : all)
delete db;
all.clear();
}
bool IsOk ()
{
std::vector all;
if (!LoadAll(all))
{
_FATALERROR("Failed to load one or more version databases for current executable!");
FreeAll(all);
return false;
}
if (!ExistsInAll(all, 517014))
{
_FATALERROR("517014 does not exist in all versions of the database!");
}
FreeAll(all);
// Ok!
return true;
}
int major = 0, minor = 0, revision = 0, build = 0;
if (!db.GetExecutableVersion(major, minor, revision, build))
{
_FATALERROR("Something went wrong!");
return false;
}
// Running game is 1.5.x and at least version 1.5.39.0
if (major == 1 && minor == 5 && revision >= 39)
{
// Stuff ... ?
}
Need help with download or installation? Join our Discord community for support.
Gaming solutions
Resources
Partners
Follow us on
Larvas Limited
Room 1201, 12/F Tai Sang Bank Building 130-132 Des Voeux Road Central HK