diff --git a/README.md b/README.md index ef6e7a7..718c6d1 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,46 @@ # UE4SS C++ BYPASS -An independent UE4SS C++ mod by Kintaro. Experimental version 1.1. +An independent UE4SS C++ mod by Kintaro. Experimental version 1.2. Allows modified contents for the 218 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. -**Version 1.1 passes the standalone native tests; its additional-module support -still needs an in-game test. Version 1.0 was confirmed in game with existing-script -pak replacements. Pinned to one game and UE4SS build.** +**Version 1.2 adds UE4SS v4.0.0 and passes the standalone native tests; it still +needs an in-game test on v4.0.0. Version 1.0 was confirmed in game with +existing-script pak replacements 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`. +- 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. 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 `Allowed listed project script` or +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. diff --git a/mod.json b/mod.json index e349037..3dee91d 100644 --- a/mod.json +++ b/mod.json @@ -2,12 +2,15 @@ "name": "UE4SS C++ BYPASS", "folder": "phantombladezero_cppbypass", "author": "Kintaro", - "version": "1.1", - "status": "experimental-additional-modules-game-test-pending", + "version": "1.2", + "status": "experimental-ue4ss-v4-game-test-pending", "kind": "ue4ss-cpp", "game": "phantombladezero", "gameVersion": "CL-302256_JKS-17280", "steamBuild": "26367565", - "ue4ssCommit": "1ceefac8b8c286f0fb3eb62b4aae075ff81df0bd", + "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." } diff --git a/openmods.json b/openmods.json index 2f06ff1..e3271a6 100644 --- a/openmods.json +++ b/openmods.json @@ -6,6 +6,6 @@ "games": ["phantom-blade-zero"], "tags": ["compatibility", "tools"], "cover": "docs/cover.png", - "requires": ["UE4SS for Phantom Blade Zero (built for v3.0.1-1195-g1ceefac8)"], + "requires": ["UE4SS for Phantom Blade Zero (v4.0.0 or v3.0.1-1195-g1ceefac8)"], "gameVersions": ["Steam build 26367565"] } diff --git a/openmods.md b/openmods.md index 38f269a..63c5f0b 100644 --- a/openmods.md +++ b/openmods.md @@ -12,7 +12,7 @@ It is a helper for other mods. On its own it changes nothing you can see; it onl ## 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. @@ -23,15 +23,15 @@ 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`. +- 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. - Do not run it together with other script loaders such as PBZModLoader: both change the same game check, and the mix is untested. - 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. 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 passes native tests; its new path still needs an in-game test. +- 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 passes native tests; its new path still needs an in-game test. Version 1.2 adds UE4SS v4.0.0 and still needs an in-game test on 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 one UE4SS build. It will not act on any other. +- It is pinned to one exact game build and two exact UE4SS builds. It will not act on any other. ## How to build diff --git a/src/build_profile.hpp b/src/build_profile.hpp index 30b9b59..fa60bcd 100644 --- a/src/build_profile.hpp +++ b/src/build_profile.hpp @@ -3,7 +3,12 @@ #include namespace compat::profile { inline constexpr char game_sha256[] = "4415933ce33476f14c837abb61a1b60af8b78cd81783896501913a7aac69e423"; -inline constexpr char ue4ss_sha256[] = "e1fb9a7e1d868afef6a091c2012e711c3ec47f05d100ba37f9631a4f75f31df2"; +// 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 = 0x1e0bb000; inline constexpr std::uint32_t timestamp = 0x6ae7ae3f; inline constexpr std::uint32_t normalize_rva = 0x62e77f0; diff --git a/src/compatibility.cpp b/src/compatibility.cpp index 5e4b201..3653481 100644 --- a/src/compatibility.cpp +++ b/src/compatibility.cpp @@ -198,14 +198,20 @@ 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.1 experimental: startup\r\n"); + log("\r\nUE4SS C++ BYPASS 1.2 experimental: startup\r\n"); try { auto* image = reinterpret_cast(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(image+profile::lookup_rva); normalize = reinterpret_cast(image+profile::normalize_rva); diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 804a57a..5242594 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -10,7 +10,7 @@ class ScriptCompatibility final : public RC::CppUserModBase { public: ScriptCompatibility() { ModName = STR("UE4SS C++ BYPASS"); - ModVersion = STR("1.1"); + ModVersion = STR("1.2"); ModDescription = STR("Compatibility for existing and additional project scripts"); ModAuthors = STR("Kintaro"); HMODULE module{}; diff --git a/tools/prepare_sdk.py b/tools/prepare_sdk.py index 9528859..a544502 100644 --- a/tools/prepare_sdk.py +++ b/tools/prepare_sdk.py @@ -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') diff --git a/tools/vendor/ue4ss-sdk/PROVENANCE.txt b/tools/vendor/ue4ss-sdk/PROVENANCE.txt index bfef662..321d36d 100644 --- a/tools/vendor/ue4ss-sdk/PROVENANCE.txt +++ b/tools/vendor/ue4ss-sdk/PROVENANCE.txt @@ -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. diff --git a/tools/verify_build.py b/tools/verify_build.py index fea1080..e2de379 100644 --- a/tools/verify_build.py +++ b/tools/verify_build.py @@ -18,11 +18,14 @@ parser.add_argument('--game-test-result', help='Record an observed game-test res 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):