Compare commits
No files matched your search
+3
-2
@@ -26,8 +26,9 @@ shown in CONTRIBUTORS.md.
|
||||
|
||||
The build also runs the offline native hook test. For a change meant for a
|
||||
real game build, also run `python tools/verify_build.py <PBZ.exe> <UE4SS.dll>`.
|
||||
3. Write code like the code around it, and keep the mod narrow: it allows only
|
||||
the game's own listed scripts to carry changed content, nothing more.
|
||||
3. Write code like the code around it, and keep the mod scoped to listed project
|
||||
scripts and additional project JS/JSON modules. Preserve original checks for
|
||||
engine scripts and paths outside the project script tree.
|
||||
4. Open the pull request, and say what it changes and why.
|
||||
|
||||
## Credit
|
||||
|
||||
@@ -1,41 +1,55 @@
|
||||
# UE4SS C++ BYPASS
|
||||
|
||||
An independent UE4SS C++ mod by Kintaro. Experimental version 1.0.
|
||||
An independent UE4SS C++ mod by Kintaro. Experimental version 1.3.
|
||||
|
||||
Allows modified contents for the 218 `project/` scripts already listed in Phantom
|
||||
Blade Zero's embedded script validation table. This is intended to let compatible
|
||||
JavaScript pak mods run again after the 2026-11-04 update.
|
||||
Allows modified contents for the 198 listed `project/` scripts and additional
|
||||
project JavaScript/JSON modules supplied by mods. This lets compatible script
|
||||
pak mods run after the 2026-11-04 update, including mods that add new modules.
|
||||
|
||||
**Compiled and tested in a standalone native harness, and confirmed in game on the
|
||||
supported build: the game starts and compatible script pak mods load. Still
|
||||
experimental and pinned to one game and UE4SS build.**
|
||||
**Version 1.3 is re-pinned for game patch 1.0304629 (Steam build 26936481,
|
||||
2026-11-28). It passes the standalone native tests and the offline checks against
|
||||
the new `PBZ.exe`, and was confirmed in game on 2026-11-28 with UE4SS v4.0.0 and
|
||||
no other script loader: a pak with one changed game script broke the main menu
|
||||
without the bypass and loaded with it. Version 1.2 adds UE4SS v4.0.0. It passes the standalone native tests and was
|
||||
confirmed in game on UE4SS v4.0.0, with an existing-script pak replacement
|
||||
(Animation Cancel) and with additional project modules. Version 1.0 was confirmed
|
||||
in game with Animation Cancel on UE4SS build 1195. Pinned to one game build and
|
||||
two verified UE4SS builds.**
|
||||
|
||||
## Supported versions
|
||||
|
||||
- Phantom Blade Zero Steam build 26367565, CL-302256_JKS-17280.
|
||||
- PBZ.exe SHA-256: `4415933ce33476f14c837abb61a1b60af8b78cd81783896501913a7aac69e423`.
|
||||
- UE4SS build 1195, commit `1ceefac8b8c286f0fb3eb62b4aae075ff81df0bd`.
|
||||
- Phantom Blade Zero Steam build 26936481 (patch 1.0304629), CL-304629_JKS-17496.
|
||||
- PBZ.exe SHA-256: `044f0c0436ea59b09c542a06cf7efda6d79513c6694e8718c5dfff57745d4bf7`.
|
||||
- UE4SS v4.0.0, commit `30afe5fff94a94c2313e220b2002059a080da9a0`, `UE4SS.dll` SHA-256
|
||||
`3843d81a8280096b0de3c750eebf15507e374c250dc551cbf07e7be7acc1e2ba` (the official release zip).
|
||||
- UE4SS build 1195 (`v3.0.1-1195-g1ceefac8`), commit `1ceefac8b8c286f0fb3eb62b4aae075ff81df0bd`, `UE4SS.dll`
|
||||
SHA-256 `e1fb9a7e1d868afef6a091c2012e711c3ec47f05d100ba37f9631a4f75f31df2`.
|
||||
- Windows x64, release MSVC runtime (`/MD`).
|
||||
|
||||
The pinned UE4SS SDK headers are byte-identical in both UE4SS builds, and all 17
|
||||
UE4SS functions this mod imports exist in both, so one DLL serves both. The
|
||||
log names the UE4SS build it found.
|
||||
|
||||
The mod checks both executable files by SHA-256 and checks the native validators
|
||||
and lookup code in memory before creating hooks. An unsupported build is left
|
||||
unpatched. Future game or UE4SS updates require a reviewed compatibility update.
|
||||
|
||||
## Install and first game test
|
||||
|
||||
1. Close the game. Use the supported UE4SS build and its working PBZ configuration.
|
||||
1. Close the game. Use a supported UE4SS build and its working PBZ configuration
|
||||
(UE4SS includes a Phantom Blade Zero configuration from the release after v4.0.0;
|
||||
for v4.0.0 itself, add the configuration files yourself).
|
||||
2. Copy the package's `ue4ss/Mods/phantombladezero_cppbypass` folder into the
|
||||
existing `ue4ss/Mods` folder beside the game's platform executable.
|
||||
3. Keep PBZModLoader out of this test. Coexistence has not been tested.
|
||||
3. PBZModLoader may stay installed. It has the same function, so running both is
|
||||
redundant, but it causes no problems.
|
||||
4. Test with one script pak mod that has been updated against this game build.
|
||||
5. Start the game. Inspect
|
||||
`ue4ss/Mods/phantombladezero_cppbypass/compatibility.log`.
|
||||
6. Look for `Both validators hooked` and an `Allowed listed project script` entry
|
||||
for the mod's script. Confirm that menu labels display normally and the mod's
|
||||
6. Look for `Verified UE4SS ...`, `Both validators hooked` and `Allowed listed project script` or
|
||||
`Allowed additional project script` entries for the mod's scripts. Confirm that menu labels display normally and the mod's
|
||||
gameplay change works. A hook log alone does not establish gameplay success.
|
||||
|
||||
This development session has not installed the DLL or changed game files.
|
||||
|
||||
To remove it, close the game and remove only this mod's folder. A full restart
|
||||
is required after enabling, disabling or replacing this mod. Runtime unload
|
||||
disables the hooks but retains trampoline memory and pins the DLL until exit so
|
||||
@@ -43,19 +57,24 @@ in-flight callbacks cannot jump into freed code. Hot reload is unsupported.
|
||||
|
||||
## Scope
|
||||
|
||||
Both the byte-content and text-content validators are hooked. The game's own
|
||||
path normalizer and table lookup decide which entry a requested module names.
|
||||
Only a correctly aligned record in the verified 241-entry table, whose canonical
|
||||
path is a `project/` JavaScript or JSON file, receives the compatibility exception.
|
||||
Other entries and unknown paths use the original validators with unchanged
|
||||
Both the byte-content and text-content validators are hooked. Existing records
|
||||
in the verified 221-entry table retain the project-only exception. For a module
|
||||
absent from that table, the game's own path normalizer must produce a canonical
|
||||
`project/` path ending in `.js` or `.json`. The returned string is released with
|
||||
the matching game allocator. Both additional helper functions are pinned and
|
||||
checked in memory before installation. Engine scripts, paths outside the project
|
||||
script tree and malformed paths use the original validators with unchanged
|
||||
arguments and return values. Each accepted script is logged once per process.
|
||||
|
||||
This permits changed contents for known game scripts. It does not load arbitrary
|
||||
new modules, add a bootstrap, add TypeScript support or enable unrestricted eval.
|
||||
Mods can supply new project modules through their normal pak files and import
|
||||
them from their scripts. This mod adds no bootstrap or TypeScript compiler.
|
||||
It does not change the separate InstallVerify feature. It cannot repair old mod
|
||||
logic or merge two pak mods that replace the same script. Mods still need to be
|
||||
checked against current game scripts.
|
||||
|
||||
Allowing a new module cannot restore a file removed by a game update. A mod whose
|
||||
old startup script imports removed game files still needs updating by its author.
|
||||
|
||||
## Build
|
||||
|
||||
The source package includes the small pinned UE4SS header subset, its license,
|
||||
@@ -82,9 +101,10 @@ the DLL with warnings treated as errors, then compiles and runs the native hook
|
||||
test. Output goes into `dist/`; build files stay in `build/`.
|
||||
|
||||
The native test exercises the actual production adapters through MinHook with
|
||||
fixture validators. It verifies project-script acceptance, engine and unknown
|
||||
path forwarding, preservation of arguments and original true/false results,
|
||||
table bounds and hook removal. It does not run the game.
|
||||
fixture validators and a stand-in normalizer/allocator. It verifies existing and
|
||||
additional project-script acceptance, engine/outside path forwarding, malformed
|
||||
normalized strings, allocation cleanup, original arguments/results, table bounds
|
||||
and hook removal. The in-game test of version 1.2 confirmed the actual game helper ABI.
|
||||
|
||||
Private reverse-engineering evidence and tools stay under `research/` and
|
||||
`tools/`. They are not needed by players and are excluded from the source package.
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 163 KiB |
@@ -2,12 +2,15 @@
|
||||
"name": "UE4SS C++ BYPASS",
|
||||
"folder": "phantombladezero_cppbypass",
|
||||
"author": "Kintaro",
|
||||
"version": "1.0",
|
||||
"status": "experimental-game-test-positive",
|
||||
"version": "1.3",
|
||||
"status": "experimental-ue4ss-v4-game-test-positive",
|
||||
"kind": "ue4ss-cpp",
|
||||
"game": "phantombladezero",
|
||||
"gameVersion": "CL-302256_JKS-17280",
|
||||
"steamBuild": "26367565",
|
||||
"ue4ssCommit": "1ceefac8b8c286f0fb3eb62b4aae075ff81df0bd",
|
||||
"description": "Allows changed contents for the game's 218 listed project scripts through native UE4SS C++ hooks."
|
||||
"gameVersion": "CL-304629_JKS-17496",
|
||||
"steamBuild": "26936481",
|
||||
"ue4ssBuilds": {
|
||||
"v4.0.0": "30afe5fff94a94c2313e220b2002059a080da9a0",
|
||||
"v3.0.1-1195-g1ceefac8": "1ceefac8b8c286f0fb3eb62b4aae075ff81df0bd"
|
||||
},
|
||||
"description": "Allows modified existing project scripts and additional project JavaScript/JSON modules through native UE4SS C++ hooks."
|
||||
}
|
||||
+4
-4
@@ -2,10 +2,10 @@
|
||||
"$schema": "https://openmods.nexus/openmods.schema.json",
|
||||
"openmods": 1,
|
||||
"name": "UE4SS C++ BYPASS",
|
||||
"summary": "Brings script-based pak mods back to Phantom Blade Zero after the game's script check, by letting the game's own listed scripts carry edits.",
|
||||
"summary": "Supports script pak mods that edit existing project scripts or add project JavaScript/JSON modules on the supported Phantom Blade Zero build.",
|
||||
"games": ["phantom-blade-zero"],
|
||||
"tags": ["compatibility", "tools"],
|
||||
"cover": "docs/cover.png",
|
||||
"requires": ["UE4SS for Phantom Blade Zero (built for v3.0.1-1195-g1ceefac8)"],
|
||||
"gameVersions": ["Steam build 26367565"]
|
||||
"cover": "docs/cover.webp",
|
||||
"requires": ["UE4SS for Phantom Blade Zero (v4.0.0 or v3.0.1-1195-g1ceefac8)"],
|
||||
"gameVersions": ["Steam build 26936481"]
|
||||
}
|
||||
+13
-8
@@ -4,15 +4,19 @@ A Phantom Blade Zero update (2026-11-04, Steam build 26367565) made the game ref
|
||||
|
||||
## What it does
|
||||
|
||||
- It re-allows the game's own listed scripts to carry changed content, so a JavaScript pak mod that replaces one of them loads again.
|
||||
- It touches only the game's own listed scripts. It adds no new script and changes nothing else in the game.
|
||||
- It lets JavaScript pak mods replace the game's listed project scripts and supply additional project JavaScript/JSON modules.
|
||||
- It accepts additional modules only when the game's path normalizer places them inside the project script tree. Engine scripts and outside paths keep their original checks.
|
||||
- It checks the exact game and UE4SS build before it does anything, and stays off on a build it does not know, so it never acts on the wrong version.
|
||||
|
||||
It is a helper for other mods. On its own it changes nothing you can see; it only lets compatible pak mods run.
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
## How to install
|
||||
|
||||
1. Install UE4SS for Phantom Blade Zero, for example [UE4SS](https://github.com/KintaroModding/ue4ss) (the build this mod was made for: `v3.0.1-1195-g1ceefac8`).
|
||||
1. Install UE4SS for Phantom Blade Zero, for example [UE4SS](https://github.com/KintaroModding/ue4ss). This mod works with UE4SS `v4.0.0` (the official release) and `v3.0.1-1195-g1ceefac8`.
|
||||
2. Open the latest release on GitHub and download the zip.
|
||||
3. From the zip, copy the `ue4ss` folder into the game's `platform\steam\` folder (next to the game's `PBZ.exe`). It adds `ue4ss\Mods\phantombladezero_cppbypass\`.
|
||||
4. Put the JavaScript pak mods you want into the game's `ProjectPBZ\Content\Paks\~mods\` folder as usual.
|
||||
@@ -22,15 +26,16 @@ To update, replace the folder with the one from the new release. To remove it, d
|
||||
|
||||
## Compatibility
|
||||
|
||||
- Game version: Steam build 26367565 (`CL-302256_JKS-17280`).
|
||||
- Needs UE4SS for Phantom Blade Zero, build `v3.0.1-1195-g1ceefac8`.
|
||||
- Do not run it together with other script loaders such as PBZModLoader: both change the same game check, and the mix is untested.
|
||||
- Game version: Steam build 26936481, patch 1.0304629 of 2026-11-28 (`CL-304629_JKS-17496`). Version 1.2 is for the older Steam build 26367565.
|
||||
- Needs UE4SS for Phantom Blade Zero: `v4.0.0` or `v3.0.1-1195-g1ceefac8`. UE4SS v4.0.0 itself has no Phantom Blade Zero configuration yet (it comes with the next UE4SS release); use a package that adds it.
|
||||
- PBZModLoader has the same function and needs no UE4SS. Running both at the same time is redundant, but it causes no problems. Other script loaders may conflict.
|
||||
- After a game patch or a UE4SS update, this mod needs a new build with new offsets. Until that build exists, it stays off on the new version (safe), and the pak mods do not load.
|
||||
|
||||
## Known issues
|
||||
|
||||
- Experimental. Tested so far: the game starts with no crash, the other UE4SS mods keep working, and two pak mods loaded (Animation Cancel and a map-marker mod).
|
||||
- It is pinned to one exact game build and one UE4SS build. It will not act on any other.
|
||||
- Experimental. Version 1.0 was tested in game with Animation Cancel and a map-marker mod. Version 1.1 adds support for new project modules, and version 1.2 adds UE4SS v4.0.0. Version 1.2 was tested in game on UE4SS v4.0.0, with Animation Cancel and with new project modules. Version 1.3 has the new offsets for patch 1.0304629 and was tested in game on that patch with UE4SS v4.0.0: a pak with a changed game script broke the main menu without the bypass and loaded with it.
|
||||
- Mods must still match the current game scripts. This bypass cannot restore removed modules referenced by an outdated startup script.
|
||||
- It is pinned to one exact game build and two exact UE4SS builds. It will not act on any other.
|
||||
|
||||
## How to build
|
||||
|
||||
|
||||
+21
-12
@@ -2,19 +2,28 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
namespace compat::profile {
|
||||
inline constexpr char game_sha256[] = "4415933ce33476f14c837abb61a1b60af8b78cd81783896501913a7aac69e423";
|
||||
inline constexpr char ue4ss_sha256[] = "e1fb9a7e1d868afef6a091c2012e711c3ec47f05d100ba37f9631a4f75f31df2";
|
||||
inline constexpr std::uint32_t image_size = 0x1e0bb000;
|
||||
inline constexpr std::uint32_t timestamp = 0x6ae7ae3f;
|
||||
inline constexpr std::uint32_t lookup_rva = 0x62ea0e0;
|
||||
inline constexpr std::uint32_t bytes_rva = 0x62f65a0;
|
||||
inline constexpr std::uint32_t text_rva = 0x62f65e0;
|
||||
inline constexpr std::uint32_t table_rva = 0xbec50f0;
|
||||
inline constexpr std::size_t record_count = 241, project_count = 218;
|
||||
inline constexpr char game_sha256[] = "044f0c0436ea59b09c542a06cf7efda6d79513c6694e8718c5dfff57745d4bf7";
|
||||
// Verified UE4SS.dll builds. The pinned SDK headers and all 17 imported UE4SS exports are identical in both.
|
||||
struct Ue4ssBuild { const char* name; const char* sha256; };
|
||||
inline constexpr Ue4ssBuild ue4ss_builds[] = {
|
||||
{"v4.0.0", "3843d81a8280096b0de3c750eebf15507e374c250dc551cbf07e7be7acc1e2ba"},
|
||||
{"v3.0.1-1195-g1ceefac8", "e1fb9a7e1d868afef6a091c2012e711c3ec47f05d100ba37f9631a4f75f31df2"},
|
||||
};
|
||||
inline constexpr std::uint32_t image_size = 0x1d40b000;
|
||||
inline constexpr std::uint32_t timestamp = 0x6b072f6d;
|
||||
inline constexpr std::uint32_t normalize_rva = 0x62b5b00;
|
||||
inline constexpr std::uint32_t free_rva = 0x12e33f0;
|
||||
inline constexpr std::uint32_t lookup_rva = 0x62b83f0;
|
||||
inline constexpr std::uint32_t bytes_rva = 0x62c48b0;
|
||||
inline constexpr std::uint32_t text_rva = 0x62c48f0;
|
||||
inline constexpr std::uint32_t table_rva = 0xbeb09d0;
|
||||
inline constexpr std::size_t record_count = 221, project_count = 198;
|
||||
struct Function { std::uint32_t rva, size; const char* sha256; };
|
||||
inline constexpr Function functions[] = {
|
||||
{0x62ea0e0, 0xc5, "0d48d620658e94f5b2bc61949a3afb33243a815d5d9d170151b5994dbf8d3d10"},
|
||||
{0x62f65a0, 0x3d, "6524f51e4381b0a4451568d0d73ed2166b2c886cce418b5088468938b7ef0b7f"},
|
||||
{0x62f65e0, 0x246, "c43c4152c10face4075bf3f48e6701a2ae65956670460020d66ab13d59bd4ba4"},
|
||||
{0x62b83f0, 0xc5, "a279545f87871515be033d264c60af6e0c569d888a1e0e007e6959aa3b316ca8"},
|
||||
{0x62c48b0, 0x3d, "6524f51e4381b0a4451568d0d73ed2166b2c886cce418b5088468938b7ef0b7f"},
|
||||
{0x62c48f0, 0x246, "e7fca94cf4ec093d5a6bce0a8309f36fa826aa28b5480d7667cf87620ab79aa5"},
|
||||
{0x62b5b00, 0x291, "57e96b845b299247377553fc53cbd7eb36ce023b85f80ac07cca09c366da615b"},
|
||||
{0x12e33f0, 0x34, "5fea0c4dd553f360ee69bf735305a9d4fe9184c820ec7aeff53abcbc39e70529"},
|
||||
};
|
||||
}
|
||||
+47
-6
@@ -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,16 +198,24 @@ 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.3 experimental: startup\r\n");
|
||||
try {
|
||||
auto* image = reinterpret_cast<unsigned char*>(GetModuleHandleW(nullptr));
|
||||
if (file_hash(module_path(nullptr)) != profile::game_sha256)
|
||||
throw std::runtime_error("Unsupported PBZ.exe SHA-256; no hooks installed");
|
||||
auto ue4ss = GetModuleHandleW(L"UE4SS.dll");
|
||||
if (!ue4ss || file_hash(module_path(ue4ss)) != profile::ue4ss_sha256)
|
||||
throw std::runtime_error("Requires the verified UE4SS build 1195 DLL");
|
||||
if (!ue4ss) throw std::runtime_error("UE4SS.dll is not loaded; no hooks installed");
|
||||
const auto ue4ss_hash = file_hash(module_path(ue4ss));
|
||||
const char* ue4ss_build = nullptr;
|
||||
for (const auto& build : profile::ue4ss_builds)
|
||||
if (ue4ss_hash == build.sha256) ue4ss_build = build.name;
|
||||
if (!ue4ss_build)
|
||||
throw std::runtime_error("Requires a verified UE4SS DLL (v4.0.0 or v3.0.1-1195); no hooks installed");
|
||||
log("Verified UE4SS "); log(ue4ss_build); log("\r\n");
|
||||
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 +236,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 +270,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); }
|
||||
|
||||
+2
-2
@@ -10,8 +10,8 @@ class ScriptCompatibility final : public RC::CppUserModBase {
|
||||
public:
|
||||
ScriptCompatibility() {
|
||||
ModName = STR("UE4SS C++ BYPASS");
|
||||
ModVersion = STR("1.0");
|
||||
ModDescription = STR("Compatibility for the game's listed project scripts");
|
||||
ModVersion = STR("1.3");
|
||||
ModDescription = STR("Compatibility for existing and additional project scripts");
|
||||
ModAuthors = STR("Kintaro");
|
||||
HMODULE module{};
|
||||
if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
#include <string_view>
|
||||
|
||||
namespace compat {
|
||||
// The pinned normalizer returns an owning FString; only the game allocator frees it.
|
||||
struct GameString {
|
||||
wchar_t* data{};
|
||||
std::int32_t count{};
|
||||
std::int32_t capacity{};
|
||||
};
|
||||
static_assert(sizeof(GameString) == 16);
|
||||
struct ScriptRecord {
|
||||
const wchar_t* path;
|
||||
std::uint64_t byte_size;
|
||||
@@ -16,6 +23,8 @@ inline bool is_project_script(std::wstring_view path) noexcept {
|
||||
if (!path.ends_with(L".js") && !path.ends_with(L".json")) return false;
|
||||
// Table paths are canonical; refuse traversal and alternate separators.
|
||||
if (path.find(L'\\') != path.npos || path.find(L':') != path.npos) return false;
|
||||
for (const auto character : path)
|
||||
if (character < 32 || character == 127) return false;
|
||||
for (std::size_t i = 0, end; i < path.size(); i = end + 1) {
|
||||
end = path.find(L'/', i);
|
||||
if (end == path.npos) end = path.size();
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Create a small, ABI-preserving SDK include set from UE4SS build 1195."""
|
||||
"""Create a small, ABI-preserving SDK include set from UE4SS v4.0.0 (the same files as build 1195)."""
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
import subprocess
|
||||
@@ -6,7 +6,7 @@ import sys
|
||||
sys.path.insert(0, str(Path(__file__).parent / 'python'))
|
||||
import pefile
|
||||
|
||||
PIN = '1ceefac8b8c286f0fb3eb62b4aae075ff81df0bd'
|
||||
PIN = '30afe5fff94a94c2313e220b2002059a080da9a0' # tag v4.0.0; these files equal build 1195's (1ceefac8)
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('repo', type=Path)
|
||||
parser.add_argument('dll', type=Path)
|
||||
@@ -44,7 +44,8 @@ exports = [s.name.decode('ascii') for s in pe.DIRECTORY_ENTRY_EXPORT.symbols if
|
||||
(root/'build/UE4SS.def').write_text('LIBRARY UE4SS.dll\nEXPORTS\n' +
|
||||
'\n'.join(exports) + '\n', encoding='ascii')
|
||||
(output/'PROVENANCE.txt').write_text(
|
||||
f'UE4SS-RE/RE-UE4SS commit {PIN}\n'
|
||||
f'UE4SS-RE/RE-UE4SS commit {PIN} (tag v4.0.0)\n'
|
||||
'The same files are byte-identical at commit 1ceefac8b8c286f0fb3eb62b4aae075ff81df0bd (build 1195).\n'
|
||||
'CppUserModBase.hpp: GUI include replaced with a forward declaration;\n'
|
||||
'register_tab callback typedef expanded to its identical function-pointer type.\n'
|
||||
'No object fields or virtual methods changed. Other headers unchanged.\n', encoding='utf-8')
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
"""Read-only: find the pin values of build_profile.hpp in a new PBZ.exe.
|
||||
|
||||
Uses PBZModLoader's validator patterns (its signatures.hpp) to find the byte and text
|
||||
validators, then follows their calls to the lookup and disassembles it: its first call
|
||||
is the path normalizer, its last call the free helper, its `lea r13, [rip+...]` the
|
||||
record table and its `mov edi, <n>` the record count. Prints the .pdata ranges and the
|
||||
SHA-256 of their bytes, as build_profile.hpp pins them.
|
||||
|
||||
Usage: python -I tools/repin_scan.py <PBZ.exe> [<normalize rva> <free rva>]
|
||||
"""
|
||||
import hashlib
|
||||
import struct
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).parent / 'python'))
|
||||
import pefile # noqa: E402
|
||||
from capstone import Cs, CS_ARCH_X86, CS_MODE_64 # noqa: E402
|
||||
|
||||
BYTES = [0x20,0x48,0x8b,0xda,0xe8,-1,-1,-1,-1,0x48,0x85,0xc0,0x74,0x22,0x48,0x63,0x53,0x08,0x48,0x3b,0x50,0x08,0x75,0x18,0x48,0x8b,0x0b,0x4c,0x8d,0x40,0x18,0xe8,-1,-1,-1,-1,0x84,0xc0,0x74,0x08,0xb0,0x01,0x48,0x83,0xc4,0x20,0x5b,0xc3,0x32,0xc0,0x48,0x83,0xc4,0x20,0x5b,0xc3]
|
||||
TEXT = [0x55,0x56,0x57,0x41,0x54,0x41,0x55,0x41,0x56,0x41,0x57,0x48,0x81,0xec,0xf0,0x01,0,0,0x48,0x8b,0x05,-1,-1,-1,-1,0x48,0x33,0xc4,0x48,0x89,0x84,0x24,0xe0,0x01,0,0,0x4c,0x8b,0xf2,0xe8,-1,-1,-1,-1,0x48,0x8b,0xf0,0x48,0x85,0xc0,0x0f,0x84,-1,-1,-1,-1,0x41,0x8b,0x4e,0x08,0x8d,0x59,0xff]
|
||||
|
||||
|
||||
def find(data, sec_off, sec_len, pat):
|
||||
first = bytes([pat[0]])
|
||||
hits, at, end = [], sec_off, sec_off + sec_len - len(pat) + 1
|
||||
while True:
|
||||
at = data.find(first, at, end)
|
||||
if at < 0:
|
||||
return hits
|
||||
if all(p < 0 or data[at + j] == p for j, p in enumerate(pat)):
|
||||
hits.append(at)
|
||||
at += 1
|
||||
|
||||
|
||||
def main():
|
||||
exe = Path(sys.argv[1])
|
||||
data = exe.read_bytes()
|
||||
print("sha256", hashlib.sha256(data).hexdigest())
|
||||
pe = pefile.PE(data=data, fast_load=True)
|
||||
print(f"image_size 0x{pe.OPTIONAL_HEADER.SizeOfImage:x} timestamp 0x{pe.FILE_HEADER.TimeDateStamp:x}")
|
||||
base = pe.OPTIONAL_HEADER.ImageBase
|
||||
d = pe.OPTIONAL_HEADER.DATA_DIRECTORY[3]
|
||||
pdata = sorted((s, e) for s, e, _ in struct.iter_unpack("<III", pe.get_data(d.VirtualAddress, d.Size)))
|
||||
|
||||
def frange(rva):
|
||||
for s, e in pdata:
|
||||
if s <= rva < e:
|
||||
return s, e
|
||||
raise ValueError(f"no .pdata range for 0x{rva:x}")
|
||||
|
||||
hits = {"bytes": [], "text": []}
|
||||
for sec in pe.sections:
|
||||
if not sec.Characteristics & 0x20000000:
|
||||
continue
|
||||
for name, pat, entry in (("bytes", BYTES, b"\x40\x53\x48\x83\xec"), ("text", TEXT, b"\x48\x89\x5c\x24\x18")):
|
||||
for o in find(data, sec.PointerToRawData, sec.SizeOfRawData, pat):
|
||||
if data[o - len(entry):o] == entry:
|
||||
hits[name].append(pe.get_rva_from_offset(o - len(entry)))
|
||||
print("bytes validator", [hex(h) for h in hits["bytes"]])
|
||||
print("text validator", [hex(h) for h in hits["text"]])
|
||||
if len(hits["bytes"]) != 1 or len(hits["text"]) != 1:
|
||||
sys.exit("validators missing or ambiguous")
|
||||
b, t = hits["bytes"][0], hits["text"][0]
|
||||
|
||||
def rel(rva, disp, length):
|
||||
return rva + length + struct.unpack("<i", pe.get_data(rva + disp, 4))[0]
|
||||
|
||||
lookup = rel(b + 9, 1, 5)
|
||||
print(f"lookup from bytes 0x{lookup:x}, from text 0x{rel(t + 44, 1, 5):x}")
|
||||
md = Cs(CS_ARCH_X86, CS_MODE_64)
|
||||
s, e = frange(lookup)
|
||||
print(f"\nLOOKUP 0x{s:x}..0x{e:x}")
|
||||
for ins in md.disasm(pe.get_data(s, e - s), base + s):
|
||||
print(f" {ins.address - base:08x} {ins.bytes.hex():24} {ins.mnemonic:8} {ins.op_str}")
|
||||
print("\nPINS (rva, size, sha256 of the .pdata range):")
|
||||
for label, rva in (("lookup", lookup), ("bytes", b), ("text", t)):
|
||||
s, e = frange(rva)
|
||||
print(f" {label:8} start=0x{rva:x} range=0x{s:x}+0x{e - s:x} sha256={hashlib.sha256(pe.get_data(s, e - s)).hexdigest()}")
|
||||
for extra in sys.argv[2:]:
|
||||
rva = int(extra, 0)
|
||||
s, e = frange(rva)
|
||||
print(f" extra start=0x{rva:x} range=0x{s:x}+0x{e - s:x} sha256={hashlib.sha256(pe.get_data(s, e - s)).hexdigest()}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
UE4SS-RE/RE-UE4SS commit 1ceefac8b8c286f0fb3eb62b4aae075ff81df0bd
|
||||
UE4SS-RE/RE-UE4SS commit 30afe5fff94a94c2313e220b2002059a080da9a0 (tag v4.0.0)
|
||||
The same files are byte-identical at commit 1ceefac8b8c286f0fb3eb62b4aae075ff81df0bd (build 1195).
|
||||
CppUserModBase.hpp: GUI include replaced with a forward declaration;
|
||||
register_tab callback typedef expanded to its identical function-pointer type.
|
||||
No object fields or virtual methods changed. Other headers unchanged.
|
||||
+23
-9
@@ -14,28 +14,35 @@ ROOT=Path(__file__).resolve().parents[1]
|
||||
parser=argparse.ArgumentParser()
|
||||
parser.add_argument('game',type=Path)
|
||||
parser.add_argument('ue4ss',type=Path)
|
||||
parser.add_argument('--game-test-result', help='Record an observed game-test result; does not launch the game')
|
||||
args=parser.parse_args()
|
||||
profile=(ROOT/'src/build_profile.hpp').read_text()
|
||||
report={}
|
||||
for key,path in [('game',args.game),('ue4ss',args.ue4ss)]:
|
||||
digest=hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
expected=re.search(rf'{key}_sha256\[\] = "([0-9a-f]+)"',profile)[1]
|
||||
assert digest==expected,(key,'SHA mismatch')
|
||||
report[key+'_sha256']=digest
|
||||
digest=hashlib.sha256(args.game.read_bytes()).hexdigest()
|
||||
assert digest==re.search(r'game_sha256\[\] = "([0-9a-f]+)"',profile)[1],('game','SHA mismatch')
|
||||
report['game_sha256']=digest
|
||||
digest=hashlib.sha256(args.ue4ss.read_bytes()).hexdigest()
|
||||
ue4ss_builds=dict((sha,name) for name,sha in re.findall(r'\{"([^"]+)", "([0-9a-f]{64})"\}',profile))
|
||||
assert digest in ue4ss_builds,('ue4ss','SHA not in ue4ss_builds')
|
||||
report['ue4ss_sha256']=digest
|
||||
report['ue4ss_build']=ue4ss_builds[digest]
|
||||
game=pefile.PE(str(args.game),fast_load=True)
|
||||
function_ranges=[]
|
||||
for rva,size,digest in re.findall(r'\{0x([0-9a-f]+), 0x([0-9a-f]+), "([0-9a-f]+)"\}',profile):
|
||||
rva,size=int(rva,16),int(size,16)
|
||||
assert hashlib.sha256(game.get_data(rva,size)).hexdigest()==digest
|
||||
report[hex(rva)]={'bytes':size,'sha256':digest}
|
||||
function_ranges.append((rva,rva+size))
|
||||
game.parse_data_directories(directories=[pefile.DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_BASERELOC']])
|
||||
for block in getattr(game,'DIRECTORY_ENTRY_BASERELOC',[]):
|
||||
for reloc in block.entries:
|
||||
if reloc.type:
|
||||
for start,end in [(0x62ea0e0,0x62ea1a5),(0x62f65a0,0x62f65dd),(0x62f65e0,0x62f6826)]:
|
||||
for start,end in function_ranges:
|
||||
assert not start<=reloc.rva<end,'Runtime code digest would require ASLR relocation'
|
||||
report['code_digests_are_aslr_independent']=True
|
||||
prologues=ROOT/'build/game-prologues.bin'
|
||||
prologues.write_bytes(game.get_data(0x62f65a0,64)+game.get_data(0x62f65e0,64))
|
||||
bytes_rva,text_rva=(int(re.search(rf'{n}_rva = (0x[0-9a-f]+)',profile)[1],16) for n in ('bytes','text'))
|
||||
prologues.write_bytes(game.get_data(bytes_rva,64)+game.get_data(text_rva,64))
|
||||
native=subprocess.run([str(ROOT/'build/native_hooks.exe'),str(prologues)],cwd=ROOT,
|
||||
capture_output=True,text=True,check=True)
|
||||
report['native_tests']=native.stdout.splitlines()
|
||||
@@ -56,6 +63,13 @@ for dep in mod.DIRECTORY_ENTRY_IMPORT:
|
||||
assert report.get('verified_ue4ss_imports')==17
|
||||
report['dll_sha256']=hashlib.sha256(dll.read_bytes()).hexdigest()
|
||||
report['dll_bytes']=dll.stat().st_size
|
||||
report['game_test']='PENDING; game was not launched or modified'
|
||||
(ROOT/'research/verification.json').write_text(json.dumps(report,indent=2)+'\n',encoding='utf-8')
|
||||
report_path=ROOT/'research/verification.json'
|
||||
previous=json.loads(report_path.read_text(encoding='utf-8')) if report_path.exists() else {}
|
||||
same_dll=previous.get('dll_sha256')==report['dll_sha256']
|
||||
report['game_test']=args.game_test_result or (previous.get('game_test') if same_dll else None) or \
|
||||
'PENDING for this DLL; offline verification does not establish gameplay success'
|
||||
if not same_dll and previous.get('game_test'):
|
||||
report['previous_dll_game_test']={'dll_sha256':previous.get('dll_sha256'),
|
||||
'result':previous['game_test']}
|
||||
report_path.write_text(json.dumps(report,indent=2)+'\n',encoding='utf-8')
|
||||
print('PASS: pinned executable hashes, ASLR-independent code digests, DLL exports and UE4SS imports')
|
||||
Reference in new issue
Block a user