Files
pbz-cppbypass/tools/prepare_sdk.py
T
KintaroModding c29aeef1df Add experimental PBZ script compatibility C++ mod 1.0
Hook the byte and text validators for the supported game build while retaining
original validation for unknown paths and non-project records. Pin executable
and UE4SS hashes, provide an MIT-licensed source package, and verify native
adapters, supported prologues, import symbols and unsupported-build refusal.

In-game startup and gameplay verification remain pending.
2026-11-04 14:14:14 +01:00

52 lines
2.6 KiB
Python

"""Create a small, ABI-preserving SDK include set from UE4SS build 1195."""
from pathlib import Path
import argparse
import subprocess
import sys
sys.path.insert(0, str(Path(__file__).parent / 'python'))
import pefile
PIN = '1ceefac8b8c286f0fb3eb62b4aae075ff81df0bd'
parser = argparse.ArgumentParser()
parser.add_argument('repo', type=Path)
parser.add_argument('dll', type=Path)
args = parser.parse_args()
root = Path(__file__).resolve().parents[1]
output = root / 'tools/vendor/ue4ss-sdk'
files = {
'UE4SS/include/Mod/CppUserModBase.hpp': 'Mod/CppUserModBase.hpp',
'UE4SS/include/Common.hpp': 'Common.hpp',
'UE4SS/include/LibBoundaryWrappers.hpp': 'LibBoundaryWrappers.hpp',
'deps/first/File/include/File/Macros.hpp': 'File/Macros.hpp',
'deps/first/String/include/String/StringType.hpp': 'String/StringType.hpp',
'deps/first/Input/include/Input/Handler.hpp': 'Input/Handler.hpp',
'deps/first/Input/include/Input/Common.hpp': 'Input/Common.hpp',
'deps/first/Input/include/Input/KeyDef.hpp': 'Input/KeyDef.hpp',
'LICENSE': 'LICENSE',
}
for source, destination in files.items():
raw = subprocess.check_output(['git', '-c', f'safe.directory={args.repo.resolve().as_posix()}',
'-C', str(args.repo), 'show', f'{PIN}:{source}'])
text = raw.decode('utf-8')
if destination == 'Mod/CppUserModBase.hpp':
# GUITab is used only through shared_ptr and a callback typedef. Keep all
# fields, virtual slots and function types; avoid pulling in the GUI SDK.
text = text.replace('#include <GUI/GUITab.hpp>',
'namespace RC::GUI { class GUITab; }')
text = text.replace('GUI::GUITab::RenderFunctionType', 'void (*)(CppUserModBase*)')
target = output / destination
target.parent.mkdir(parents=True, exist_ok=True)
target.write_text(text, encoding='utf-8')
pe = pefile.PE(str(args.dll), fast_load=True)
pe.parse_data_directories(directories=[pefile.DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_EXPORT']])
exports = [s.name.decode('ascii') for s in pe.DIRECTORY_ENTRY_EXPORT.symbols if s.name]
(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'
'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')
print('Prepared pinned SDK headers and import-library definition.')