commit 0f0b524d95e7f017ee7314063a912818a3c6d9b8 parent e4c4af8a6390f3ec767c2fc4b4d52ea640eb7947 Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:52:46 +0200 feat(core): custom shared library Diffstat:
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json @@ -976,9 +976,9 @@ "name": "Custom Emoji Font", "description": "Allows you to use a custom emoji font. Only works with .ttf fonts" }, - "remap_executable": { - "name": "Remap Executable", - "description": "Remaps executable regions in memory" + "custom_shared_library": { + "name": "Custom Shared Library", + "description": "Loads a custom shared library into Snapchat. This feature is only for testing purposes" } } }, diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/Experimental.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/Experimental.kt @@ -40,6 +40,12 @@ class Experimental : ConfigContainer() { addFlags(ConfigFlag.USER_IMPORT) filenameFilter = { it.endsWith(".ttf") } } + val customSharedLibrary = string("custom_shared_library") { + requireRestart() + addNotices(FeatureNotice.INTERNAL_BEHAVIOR) + addFlags(ConfigFlag.USER_IMPORT) + filenameFilter = { it.endsWith(".so") } + } } class E2EEConfig : ConfigContainer(hasGlobalState = true) { diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/SnapEnhance.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/SnapEnhance.kt @@ -222,6 +222,17 @@ class SnapEnhance { } } + appContext.config.experimental.nativeHooks.customSharedLibrary.get().takeIf { it.isNotEmpty() }?.let { + runCatching { + appContext.native.loadSharedLibrary( + appContext.fileHandlerManager.getFileHandle(FileHandleScope.USER_IMPORT.key, it).toWrapper().readBytes() + ) + appContext.log.verbose("loaded custom shared library") + }.onFailure { + appContext.log.error("Failed to load custom shared library", it) + } + } + if (appContext.bridgeClient.getDebugProp("disable_sif", "false") != "true") { runCatching { appContext.native.loadSharedLibrary(