Ship a self-contained OpenZenLoader.exe (OpenZen.dll embedded as
RCDATA) that injects into a running Minecraft 1.20.1 Forge
javaw.exe and brings up the Zen client without -javaagent or a
mods/ entry. The existing Forge mod path stays intact.
Native (native/):
- DLL: JNI_GetCreatedJavaVMs + JVMTI late-attach via the JDK's
instrument.dll Agent_OnAttach to obtain a real Instrumentation;
URLClassLoader on the game loader loads a single bridge class.
- Loader EXE: Win32 listview of javaw.exe/java.exe processes
with window titles, CreateRemoteThread+LoadLibraryW injection,
embedded DLL extracted to %TEMP%\OpenZenLoader at runtime.
Java:
- shit.zen.dll.GameLoaderBridge re-defines every jar class onto
the Forge GameClassLoader (fixed-point retry for super-class
deps) and extracts non-class resources to
%TEMP%\openzen-resources-<pid>, exposed via the
openzen.resources system property.
- shit.zen.dll.DllBootstrap only runs Bootstrap.init +
registerPatches + installPatchesAndRetransform; ZenClient
construction stays on MinecraftPatch.onTick lazy-init.
- shit.zen.asm.Bootstrap parses mapping.srg, detects SRG vs
mojmap runtime via Minecraft.tick reflection, exposes
remapMethod/remapField used at 5 PatchTransformer match
points and from ReflectionUtil.
- ReflectionUtil.resolveField walks the superclass chain trying
SRG then mojmap on each level so e.g. activeEffects on
LocalPlayer resolves on LivingEntity.
- shit.zen.utils.misc.Assets unifies resource lookup with a
fallback to openzen.resources; fonts, cloud assets and WebUI
static files route through it.
- PatchAgent.installPatchesAndRetransform is now idempotent so
DllBootstrap and ZenClient.init can both call it safely.
Build:
- ./gradlew jar forge mod jar (unchanged)
- ./gradlew dll single-file Loader EXE in build/dist
- CMake auto-located via vswhere when VS 2022 ships it.
- README documents both paths and required toolchain.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
52 lines
1.5 KiB
CMake
52 lines
1.5 KiB
CMake
# Stage the freshly-built OpenZen.dll into the loader's binary dir so rc.exe
|
|
# can pick it up as an RCDATA resource (embedded in the .exe).
|
|
set(EMBED_DIR "${CMAKE_CURRENT_BINARY_DIR}/embedded_dll")
|
|
add_custom_command(
|
|
OUTPUT "${EMBED_DIR}/OpenZen.dll"
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${EMBED_DIR}"
|
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:OpenZen> "${EMBED_DIR}/OpenZen.dll"
|
|
DEPENDS OpenZen
|
|
COMMENT "Staging OpenZen.dll into loader resources"
|
|
)
|
|
add_custom_target(stage_dll_for_loader DEPENDS "${EMBED_DIR}/OpenZen.dll")
|
|
|
|
add_executable(OpenZenLoader WIN32
|
|
src/main.cpp
|
|
src/process_list.cpp
|
|
src/injector.cpp
|
|
src/embedded_dll.cpp
|
|
src/window_title.cpp
|
|
src/ui.cpp
|
|
res/loader.rc
|
|
)
|
|
|
|
add_dependencies(OpenZenLoader stage_dll_for_loader)
|
|
|
|
target_include_directories(OpenZenLoader PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
|
${CMAKE_CURRENT_SOURCE_DIR}/res
|
|
)
|
|
|
|
# Tell rc.exe to look in EMBED_DIR (where OpenZen.dll was staged) when
|
|
# resolving the RCDATA "OpenZen.dll" reference in loader.rc.
|
|
set_source_files_properties(res/loader.rc PROPERTIES
|
|
COMPILE_FLAGS "/I\"${EMBED_DIR}\""
|
|
)
|
|
|
|
target_link_libraries(OpenZenLoader PRIVATE
|
|
comctl32
|
|
psapi
|
|
shlwapi
|
|
user32
|
|
)
|
|
|
|
set_target_properties(OpenZenLoader PROPERTIES
|
|
OUTPUT_NAME "OpenZenLoader"
|
|
)
|
|
|
|
if(MSVC)
|
|
set_target_properties(OpenZenLoader PROPERTIES
|
|
LINK_FLAGS "/SUBSYSTEM:WINDOWS /MANIFESTUAC:\"level='asInvoker' uiAccess='false'\""
|
|
)
|
|
endif()
|