All 509 functions of 12340's Lua block (0x84D390-0x863580) carry an OFFSET and are verified (static evidence; see re/notes/303_lua.md). - Compiled as C++ with extern "C" API, setjmp/longjmp errors. - Taint on GC objects and TValues, taint globals, taint event callback, closure taint in the VM, gctag for new objects. - Profiler: Profile per closure, luaD_precall_profile, luaV_execute_profile; GC size/time accounting per tag. - luaconf: COMPAT_VARARG/MOD/GFIND off, 4-byte max alignment, MAX_SIZET 0x1000000; removed randomseed/print/dofile/loadfile/load, no binary chunks. - UTF-8 string.lower/upper, Blizzard string.format, BOM skip, raw lua_setglobal, table.removemulti/wipe, externalabort. - New: lbitlib.c, lmemPool.cpp/.h, FrameScript_InvalidPtrCheck (Win32/Win64), lua CMake target. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
52 lines
1.6 KiB
C++
52 lines
1.6 KiB
C++
#if defined(WOWDECOMP_ARCH_32)
|
|
|
|
#include <cstdint>
|
|
#include <cstring>
|
|
#include <windows.h>
|
|
#include "Engine/Source/FrameScript/FrameScript.h"
|
|
#include "Engine/Source/Storm/H/storm.h"
|
|
|
|
// STATIC: 0x00D415B8
|
|
static uintptr_t s_textStart;
|
|
|
|
// STATIC: 0x00D415BC
|
|
static uintptr_t s_textEnd;
|
|
|
|
// VERIFY: 9b7c9677 manual
|
|
// OFFSET: 0x0086B510
|
|
void FrameScript_FindTextSectionBounds() {
|
|
uint8_t* image = reinterpret_cast<uint8_t*>(StormGetInstance());
|
|
IMAGE_NT_HEADERS* header = reinterpret_cast<IMAGE_NT_HEADERS*>(image + reinterpret_cast<IMAGE_DOS_HEADER*>(image)->e_lfanew);
|
|
IMAGE_SECTION_HEADER* sections = IMAGE_FIRST_SECTION(header);
|
|
uint16_t i;
|
|
|
|
for (i = 0; i < header->FileHeader.NumberOfSections; i++) {
|
|
if (!strncmp(reinterpret_cast<const char*>(sections[i].Name), ".text", 8)) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (i >= header->FileHeader.NumberOfSections) {
|
|
SErrDisplayAppFatal("Unable to find .text section");
|
|
}
|
|
|
|
s_textStart = header->OptionalHeader.ImageBase + sections[i].VirtualAddress;
|
|
s_textEnd = header->OptionalHeader.ImageBase + sections[i].VirtualAddress + sections[i].Misc.VirtualSize;
|
|
}
|
|
|
|
// VERIFY: b7b0670a auto
|
|
// OFFSET: 0x0086B5A0
|
|
void FrameScript_InvalidPtrCheck(const void* ptr) {
|
|
if (!s_textStart || !s_textEnd) {
|
|
FrameScript_FindTextSectionBounds();
|
|
}
|
|
|
|
if (reinterpret_cast<uintptr_t>(ptr) < s_textStart || reinterpret_cast<uintptr_t>(ptr) >= s_textEnd) {
|
|
char buffer[64];
|
|
SStrPrintf(buffer, sizeof(buffer), "Invalid function pointer: %p", ptr);
|
|
SErrDisplayAppFatal(buffer);
|
|
}
|
|
}
|
|
|
|
#endif
|