Allow additional project JavaScript and JSON modules in bypass 1.1

Normalize unlisted module paths with the game's pinned helper and release its
FString output with the matching allocator. Keep engine and outside paths on
original validation, log additional accepted modules, and test malformed paths
and allocation cleanup through the production adapters.

Update scope documentation and keep earlier gameplay results separate from a
new DLL's pending game test. Native tests and offline verification pass.
This commit is contained in:
KintaroModding committed 2026-11-04 17:20:13 +01:00
1 parent f444a5e026
commit 434f11d743
11 files changed
+141 -37

No files matched your search

+42
View File
@@ -8,12 +8,14 @@
#include <filesystem>
#include <fstream>
#include <stdexcept>
#include <cstdlib>
#include "compatibility.hpp"
#include "policy.hpp"
namespace compat {
using Lookup = const ScriptRecord* (*)(const void*);
void test_context(const ScriptRecord*, Lookup);
void test_normalizer(GameString* (*)(GameString*, const void*), void (*)(void*));
void* test_bytes_adapter();
void* test_text_adapter();
void** test_original_bytes();
@@ -24,6 +26,23 @@ std::array<compat::ScriptRecord, 241> records{};
volatile long bytes_calls{}, text_calls{};
const void* last_name{};
const void* last_content{};
long normalized_allocations{}, normalized_frees{};
int malformed{};
compat::GameString* normalize_fixture(compat::GameString* out, const void* input) {
const auto* path=static_cast<const wchar_t*>(input);
const auto size=wcslen(path)+1;
out->data=static_cast<wchar_t*>(std::malloc(size*sizeof(wchar_t)));
if (!out->data) throw std::bad_alloc();
std::memcpy(out->data,path,size*sizeof(wchar_t));
out->count=out->capacity=static_cast<std::int32_t>(size);
++normalized_allocations;
if (malformed==1) --out->count; // No terminating NUL at declared end.
if (malformed==2) out->count=-1;
if (malformed==3) out->capacity=0;
if (malformed==4 && size>8) out->data[7]=L'\0';
return out;
}
void free_fixture(void* value) { ++normalized_frees; std::free(value); }
const compat::ScriptRecord* resolve(const void* name) {
if (name == records[0].path) return &records[0];
if (name == records[1].path) return &records[1];
@@ -91,6 +110,29 @@ int main(int argc, char** argv) {
check(last_name==unknown && last_content==changed, "Byte arguments changed");
check(text(unknown,reinterpret_cast<const void*>(0x5678)), "Original true result lost");
check(last_name==unknown && last_content==reinterpret_cast<const void*>(0x5678), "Text arguments changed");
compat::test_normalizer(&normalize_fixture,&free_fixture);
for (const auto path : {L"project/mods/pbzcodexsilkcorsair.js",
L"project/mods/pbzcodexsilkcorsairbootstrap.js",L"project/extra/nested/new.js",
L"project/mods/settings.json"}) {
const auto before=bytes_calls+text_calls;
check(bytes(path,changed),"Additional project byte script rejected");
check(text(path,changed),"Additional project text script rejected");
check(bytes_calls+text_calls==before,"Additional project script reached original validators");
}
for (const auto path : {L"puerts/new.js", L"engine/new.js", L"project/../new.js",
L"project//new.js",L"project/./new.js",L"project/mods/new.js.map",
L"C:/outside/new.js"}) {
check(!bytes(path,changed),"Outside/invalid byte path bypassed");
check(last_name==path && last_content==changed,"Rejected byte arguments changed");
check(text(path,reinterpret_cast<const void*>(0x5678)),"Rejected text original result lost");
}
for (malformed=1; malformed<=4; ++malformed) {
check(!bytes(unknown,changed),"Malformed normalized FString accepted");
check(!text(unknown,changed),"Malformed normalized text FString accepted");
}
malformed=0;
check(normalized_allocations==normalized_frees,"Normalized strings leaked or used wrong allocator");
std::puts("PASS: additional JS/JSON modules, scope restrictions and paired game-allocation cleanup");
hook_ok(MH_QueueDisableHook(reinterpret_cast<void*>(&bytes_fixture)));
hook_ok(MH_QueueDisableHook(reinterpret_cast<void*>(&text_fixture)));
hook_ok(MH_ApplyQueued());