Skip to content

Commit

Permalink
Support roothide
Browse files Browse the repository at this point in the history
  • Loading branch information
NyaMisty committed Nov 11, 2023
1 parent 04ca476 commit 2a800bd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ jobs:
make clean
TAGNAME=${{ steps.tag.outputs.tag }}
make package ROOTLESS=1 FINALPACKAGE=1 PACKAGE_VERSION=${TAGNAME#v}+rootless
- name: Build Release package - Rootless Roothide Substrate
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
make clean
TAGNAME=${{ steps.tag.outputs.tag }}
make package ROOTHIDE=1 FINALPACKAGE=1 PACKAGE_VERSION=${TAGNAME#v}+roothide
- name: Upload to GitHub Actions artifact
uses: NyaMisty/upload-artifact-as-is@master
Expand Down
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
TARGET := iphone:clang:latest:7.0
INSTALL_TARGET_PROCESSES = Surge-iOS Surge-iOS-NE

ifndef ROOTLESS
$(info Build as a ROOTFUL Substrate Tweak)
PACKAGE_BUILDNAME := rootful
else # ROOTLESS
ifdef ROOTLESS
$(info Build as a ROOTLESS Substrate Tweak)
THEOS_PACKAGE_SCHEME=rootless
PACKAGE_BUILDNAME := rootless
endif # ROOTLESS
else ifdef ROOTHIDE
$(info Build as a ROOTHIDE Substrate Tweak)
# THEOS_PACKAGE_ARCH := iphoneos-arm64e # must set afterwards
PACKAGE_BUILDNAME := roothide
else # ROOTLESS / ROOTHIDE
$(info Build as a ROOTFUL Substrate Tweak)
PACKAGE_BUILDNAME := rootful
endif # ROOTLESS / ROOTHIDE

ifneq ($(findstring DEBUG,$(THEOS_SCHEMA)),)
PACKAGE_BUILDNAME := $(PACKAGE_BUILDNAME)debug
endif

include $(THEOS)/makefiles/common.mk

ifdef ROOTHIDE
THEOS_PACKAGE_ARCH := iphoneos-arm64e
endif

TWEAK_NAME = Surge4Advanced

Surge4Advanced_FILES = Tweak.x
Expand Down
21 changes: 17 additions & 4 deletions Tweak.x
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,23 @@ void *pEVP_DigestVerifyFinal = NULL;
unsigned char needle[] = "\xff\x83\x02\xd1\xf8\x5f\x06\xa9\xf6\x57\x07\xa9\xf4\x4f\x08\xa9\xfd\x7b\x09\xa9\xfd\x43\x02\x91\xf3\x03\x02\xaa\xf4\x03\x01\xaa\xf5\x03\x00\xaa"; // Surge5
int needleOffset = 0;

int imgIndex = 0;
if (!strcmp(_dyld_get_image_name(0), "/usr/lib/systemhook.dylib")) {
imgIndex = 1; // dopamiqne fix
int imgIndex = -1;
const char surgeImagePath[] = "/private/var/containers/Bundle/Application";
for (int i = 0; i < _dyld_image_count(); i++) {
// traditional: none
// dopamine: "/usr/lib/systemhook.dylib"
// rootHide: "/usr/lib/systemhook-D836C275A53415DD.dylib"
NSLog(@"Finding Surge module: %s", _dyld_get_image_name(i));
if (!strncmp(_dyld_get_image_name(i), surgeImagePath, sizeof(surgeImagePath)-1)) {
imgIndex = i;
break;
}
}
if (imgIndex == -1) {
NSLog(@"Cannot find surge main executable under %s", surgeImagePath);
exit(1);
}
NSLog(@"Got Surge module at index %d: %s", imgIndex, _dyld_get_image_name(imgIndex));
intptr_t imgBase = (intptr_t)_dyld_get_image_vmaddr_slide(imgIndex) + 0x100000000LL;
intptr_t imgBase2 = (intptr_t)_dyld_get_image_header(imgIndex);
NSLog(@"Surge image base at %p %p (%s)", (void *)imgBase, (void *)imgBase2, _dyld_get_image_name(imgIndex));
Expand All @@ -184,7 +197,7 @@ void *pEVP_DigestVerifyFinal = NULL;
char *pNeedle = (char *)memmem((void *)imgBase, 0x400000, needle, sizeof(needle) - 1);
NSLog(@"found pNeedle at %p", pNeedle);
if(pNeedle == NULL) {
exit(0);
exit(1);
}
pEVP_DigestVerifyFinal = pNeedle + needleOffset;
} else {
Expand Down

0 comments on commit 2a800bd

Please sign in to comment.