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:
1 parent
f444a5e026
commit
434f11d743
11 files changed
+141
-37
No files matched your search
+39
-4
@@ -12,18 +12,23 @@
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_set>
|
||||
#include "compatibility.hpp"
|
||||
#include "policy.hpp"
|
||||
#include "build_profile.hpp"
|
||||
|
||||
namespace compat {
|
||||
namespace {
|
||||
// FString/TArray headers are passed opaquely. Their allocations and ownership
|
||||
// stay entirely inside the game; the adapters never manufacture Unreal values.
|
||||
// Content stays opaque. New names use the game's own FString normalizer and
|
||||
// matching allocator, as the original table lookup does.
|
||||
using Validator = bool (*)(const void*, const void*);
|
||||
using Lookup = const ScriptRecord* (*)(const void*);
|
||||
using Normalize = GameString* (*)(GameString*, const void*);
|
||||
using GameFree = void (*)(void*);
|
||||
Validator original_bytes{}, original_text{};
|
||||
Lookup lookup{};
|
||||
Normalize normalize{};
|
||||
GameFree game_free{};
|
||||
const ScriptRecord* table{};
|
||||
void* bytes_target{};
|
||||
void* text_target{};
|
||||
@@ -32,6 +37,8 @@ HANDLE logfile = INVALID_HANDLE_VALUE;
|
||||
std::mutex log_mutex;
|
||||
std::array<std::atomic_bool, profile::record_count> seen{};
|
||||
std::atomic_uint64_t accepted{}, retained{};
|
||||
std::mutex additional_mutex;
|
||||
std::unordered_set<std::wstring> additional_seen;
|
||||
|
||||
void log(const char* message) noexcept {
|
||||
std::lock_guard guard(log_mutex);
|
||||
@@ -99,6 +106,31 @@ std::filesystem::path module_path(HMODULE module) {
|
||||
|
||||
bool permitted(const void* name) {
|
||||
const auto* record = lookup(name);
|
||||
if (!record) {
|
||||
if (!normalize || !game_free) return false;
|
||||
struct Normalized {
|
||||
GameString value;
|
||||
~Normalized() { if (value.data) game_free(value.data); }
|
||||
} canonical{};
|
||||
normalize(&canonical.value, name);
|
||||
const auto& value = canonical.value;
|
||||
if (!value.data || value.count < 2 || value.count > 32768 ||
|
||||
value.capacity < value.count || value.data[value.count-1] != L'\0') return false;
|
||||
const std::wstring_view path(value.data, static_cast<std::size_t>(value.count-1));
|
||||
if (!is_project_script(path)) return false;
|
||||
++accepted;
|
||||
std::lock_guard guard(additional_mutex);
|
||||
if (additional_seen.emplace(path).second) {
|
||||
const auto size = WideCharToMultiByte(CP_UTF8, 0, value.data, -1, nullptr, 0, nullptr, nullptr);
|
||||
if (size > 0) {
|
||||
std::vector<char> utf8(static_cast<std::size_t>(size));
|
||||
WideCharToMultiByte(CP_UTF8, 0, value.data, -1, utf8.data(), size, nullptr, nullptr);
|
||||
const auto message = std::string("Allowed additional project script: ")+utf8.data()+"\r\n";
|
||||
log(message.c_str());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!contains_record(record, table, profile::record_count)) return false;
|
||||
// A pointer into the verified executable's immutable table; not user input.
|
||||
if (!record->path || !is_project_script(record->path)) return false;
|
||||
@@ -166,7 +198,7 @@ bool install(const std::filesystem::path& directory) {
|
||||
attempted = true;
|
||||
logfile = CreateFileW((directory/L"compatibility.log").c_str(), FILE_APPEND_DATA,
|
||||
FILE_SHARE_READ|FILE_SHARE_WRITE, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
log("\r\nUE4SS C++ BYPASS 1.0 experimental: startup\r\n");
|
||||
log("\r\nUE4SS C++ BYPASS 1.1 experimental: startup\r\n");
|
||||
try {
|
||||
auto* image = reinterpret_cast<unsigned char*>(GetModuleHandleW(nullptr));
|
||||
if (file_hash(module_path(nullptr)) != profile::game_sha256)
|
||||
@@ -176,6 +208,8 @@ bool install(const std::filesystem::path& directory) {
|
||||
throw std::runtime_error("Requires the verified UE4SS build 1195 DLL");
|
||||
verify_memory(image);
|
||||
lookup = reinterpret_cast<Lookup>(image+profile::lookup_rva);
|
||||
normalize = reinterpret_cast<Normalize>(image+profile::normalize_rva);
|
||||
game_free = reinterpret_cast<GameFree>(image+profile::free_rva);
|
||||
table = reinterpret_cast<const ScriptRecord*>(image+profile::table_rva);
|
||||
bytes_target = image+profile::bytes_rva;
|
||||
text_target = image+profile::text_rva;
|
||||
@@ -196,7 +230,7 @@ bool install(const std::filesystem::path& directory) {
|
||||
enable_attempted = true;
|
||||
require(MH_ApplyQueued(), "Enable hooks");
|
||||
active = true;
|
||||
log("Both validators hooked; scope=218 listed project scripts.\r\n");
|
||||
log("Both validators hooked; scope=listed and additional project JS/JSON scripts.\r\n");
|
||||
return true;
|
||||
} catch (const std::exception& error) {
|
||||
log(error.what()); log("\r\n");
|
||||
@@ -230,6 +264,7 @@ void shutdown() noexcept {
|
||||
}
|
||||
#ifdef COMPAT_TESTING
|
||||
void test_context(const ScriptRecord* records, Lookup resolve) { table = records; lookup = resolve; }
|
||||
void test_normalizer(Normalize canonicalize, GameFree release) { normalize=canonicalize; game_free=release; }
|
||||
void* test_bytes_adapter() { return reinterpret_cast<void*>(&validate_bytes); }
|
||||
void* test_text_adapter() { return reinterpret_cast<void*>(&validate_text); }
|
||||
void** test_original_bytes() { return reinterpret_cast<void**>(&original_bytes); }
|
||||
|
||||
Reference in new issue
Block a user