Skip to content

Commit

Permalink
Merge SandHook and YAHFA into one zip
Browse files Browse the repository at this point in the history
  • Loading branch information
MlgmXyysd committed Jan 17, 2021
1 parent c75907b commit 0ffff4b
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 217 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '0.5.1.4_{build}-{branch}'
version: '0.5.2.0_{build}-{branch}'

environment:
ANDROID_HOME: C:\android-sdk-windows
Expand Down
239 changes: 111 additions & 128 deletions edxp-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ apply plugin: 'com.android.library'
static def calcSha256(file) {
def md = MessageDigest.getInstance("SHA-256")
file.eachByte 4096, { bytes, size ->
md.update(bytes, 0, size);
md.update(bytes, 0, size)
}
return md.digest().encodeHex()
}

// Values set here will be overriden by AppVeyor, feel free to modify during development.
def buildVersionName = 'v0.5.1.4'
def buildVersionName = 'v0.5.2.0'
def buildVersionCode = 233

if (System.env.APPVEYOR_BUILD_VERSION != null) {
Expand All @@ -34,11 +34,8 @@ ext {
module_name = "EdXposed"
jar_dest_dir = "${projectDir}/template_override/system/framework/"
is_windows = OperatingSystem.current().isWindows()
backends = ["YAHFA", "SandHook"]
yahfa_module_id = "riru_edxposed"
sandhook_module_id = yahfa_module_id + "_sandhook"
yahfa_authors = "solohsu, MlgmXyysd & rk700"
sandhook_authors = "solohsu, MlgmXyysd & ganyao114"
module_id = "riru_edxposed"
authors = "solohsu, MlgmXyysd"

riruModuleId = "edxp"

Expand Down Expand Up @@ -118,140 +115,126 @@ afterEvaluate {
def variantCapped = variant.name.capitalize()
def variantLowered = variant.name.toLowerCase()

backends.each { backend ->
def backendLowered = backend.toLowerCase()
def backendCapped = backendLowered.capitalize()
def authorList = property("${backendLowered}" + "_authors")
def magiskModuleId = property("${backendLowered}" + "_module_id")
delete file(zipPathMagiskReleasePath)

delete file(zipPathMagiskReleasePath)
def prepareJarsTask = task("prepareJars${variantCapped}") {
dependsOn cleanTemplate
dependsOn tasks.getByPath(":dexmaker:copyDex${variantCapped}")
dependsOn tasks.getByPath(":dalvikdx:copyDex${variantCapped}")
dependsOn tasks.getByPath(":edxp-service:copyDex${variantCapped}")
dependsOn tasks.getByPath(":edxp-yahfa:copyDex${variantCapped}")
dependsOn tasks.getByPath(":edxp-sandhook:copyDex${variantCapped}")
}

def prepareJarsTask = task("prepareJars${backendCapped}${variantCapped}") {
dependsOn cleanTemplate
dependsOn tasks.getByPath(":dexmaker:copyDex${variantCapped}")
dependsOn tasks.getByPath(":dalvikdx:copyDex${variantCapped}")
dependsOn tasks.getByPath(":edxp-service:copyDex${variantCapped}")
dependsOn tasks.getByPath(":edxp-${backendLowered}:copyDex${variantCapped}")
def prepareMagiskFilesTask = task("prepareMagiskFiles${variantCapped}", type: Delete) {
dependsOn prepareJarsTask, "assemble${variantCapped}"
doFirst {
copy {
from "${projectDir}/tpl/edconfig.tpl"
into templateFrameworkPath
rename "edconfig.tpl", "edconfig.jar"
expand(version: "$version", apiCode: "$apiCode")
}
copy {
from "${projectDir}/tpl/module.prop.tpl"
into templateRootPath
rename "module.prop.tpl", "module.prop"
expand(moduleId: module_id,
versionName: "$version",
versionCode: "$versionCode", authorList: authors,
apiCode: "$apiCode", minApi: "$moduleMinRiruApiVersion")
filter(FixCrLfFilter.class, eol: FixCrLfFilter.CrLf.newInstance("lf"))
}
}

def prepareMagiskFilesTask = task("prepareMagiskFiles${backendCapped}${variantCapped}", type: Delete) {
dependsOn prepareJarsTask, "assemble${variantCapped}"
doFirst {
copy {
from "${projectDir}/tpl/edconfig.tpl"
into templateFrameworkPath
rename "edconfig.tpl", "edconfig.jar"
expand(version: "$version", backend: "$backend", apiCode: "$apiCode")
}
copy {
from "${projectDir}/tpl/module.prop.tpl"
into templateRootPath
rename "module.prop.tpl", "module.prop"
expand(moduleId: "$magiskModuleId", backend: "$backendCapped",
versionName: "$version" + " ($backend)",
versionCode: "$versionCode", authorList: "$authorList",
apiCode: "$apiCode", minApi: "$moduleMinRiruApiVersion")
filter(FixCrLfFilter.class, eol: FixCrLfFilter.CrLf.newInstance("lf"))
}
def libPathRelease = "${buildDir}/intermediates/cmake/${variantLowered}/obj"
def exclude_list = ["riru.sh"]
doLast {
copy {
from "${projectDir}/template_override"
into zipPathMagiskReleasePath
exclude exclude_list
}
def libPathRelease = "${buildDir}/intermediates/cmake/${variantLowered}/obj"
def exclude_list = ["riru.sh"]
doLast {
copy {
from "${projectDir}/template_override"
into zipPathMagiskReleasePath
exclude exclude_list
}
copy {
from "${projectDir}/template_override"
into zipPathMagiskReleasePath
include 'util_functions.sh'
filter { line ->
line.replaceAll('%%%RIRU_MODULE_ID%%%', riruModuleId)
.replaceAll('%%%RIRU_MIN_API_VERSION%%%', moduleMinRiruApiVersion.toString())
.replaceAll('%%%RIRU_MIN_VERSION_NAME%%%', moduleMinRiruVersionName)
}
filter(FixCrLfFilter.class,
eol: FixCrLfFilter.CrLf.newInstance("lf"))
}
copy {
include "libriru_edxp.so"
from "$libPathRelease/armeabi-v7a"
into "$zipPathMagiskReleasePath/system/lib"
}
copy {
include "libriru_edxp.so"
from "$libPathRelease/arm64-v8a"
into "$zipPathMagiskReleasePath/system/lib64"
}
copy {
include "libriru_edxp.so"
from "$libPathRelease/x86"
into "$zipPathMagiskReleasePath/system_x86/lib"
}
copy {
include "libriru_edxp.so"
from "$libPathRelease/x86_64"
into "$zipPathMagiskReleasePath/system_x86/lib64"
}
// generate sha1sum
fileTree(zipPathMagiskReleasePath).matching {
exclude "README.md", "META-INF"
}.visit { f ->
if (f.directory) return
file(f.file.path + ".s").text = calcSha256(f.file)
copy {
from "${projectDir}/template_override"
into zipPathMagiskReleasePath
include 'util_functions.sh'
filter { line ->
line.replaceAll('%%%RIRU_MODULE_ID%%%', riruModuleId)
.replaceAll('%%%RIRU_MIN_API_VERSION%%%', moduleMinRiruApiVersion.toString())
.replaceAll('%%%RIRU_MIN_VERSION_NAME%%%', moduleMinRiruVersionName)
}
filter(FixCrLfFilter.class,
eol: FixCrLfFilter.CrLf.newInstance("lf"))
}
}

def zipTask = task("zip${backendCapped}${variantCapped}", type: Zip) {
dependsOn prepareMagiskFilesTask
archiveName "${module_name}-${backend}-${project.version}-${variantLowered}.zip"
destinationDir file("$projectDir/release")
from "$zipPathMagiskReleasePath"
}

task("push${backendCapped}${variantCapped}", type: Exec) {
dependsOn zipTask
workingDir "${projectDir}/release"
def commands = [android.adbExecutable, "push",
"${module_name}-${backend}-${project.version}-${variantLowered}.zip",
"/data/local/tmp/"]
if (is_windows) {
commandLine 'cmd', '/c', commands.join(" ")
} else {
commandLine commands
copy {
include "libriru_edxp.so"
from "$libPathRelease/armeabi-v7a"
into "$zipPathMagiskReleasePath/system/lib"
}
}
task("flash${backendCapped}${variantCapped}", type: Exec) {
dependsOn tasks.getByPath("push${backendCapped}${variantCapped}")
workingDir "${projectDir}/release"
def commands = [android.adbExecutable, "shell", "su", "-c",
"magisk --install-module /data/local/tmp/${module_name}-${backend}-${project.version}-${variantLowered}.zip"]
if (is_windows) {
commandLine 'cmd', '/c', commands.join(" ")
} else {
commandLine commands
copy {
include "libriru_edxp.so"
from "$libPathRelease/arm64-v8a"
into "$zipPathMagiskReleasePath/system/lib64"
}
}
task("flashAndReboot${backendCapped}${variantCapped}", type: Exec) {
dependsOn tasks.getByPath("flash${backendCapped}${variantCapped}")
workingDir "${projectDir}/release"
def commands = [android.adbExecutable, "shell", "reboot"]
if (is_windows) {
commandLine 'cmd', '/c', commands.join(" ")
} else {
commandLine commands
copy {
include "libriru_edxp.so"
from "$libPathRelease/x86"
into "$zipPathMagiskReleasePath/system_x86/lib"
}
copy {
include "libriru_edxp.so"
from "$libPathRelease/x86_64"
into "$zipPathMagiskReleasePath/system_x86/lib64"
}
// generate sha1sum
fileTree(zipPathMagiskReleasePath).matching {
exclude "README.md", "META-INF"
}.visit { f ->
if (f.directory) return
file(f.file.path + ".s").text = calcSha256(f.file)
}
}
}

// backward compatible
task("zip${variantCapped}") {
dependsOn "zipYahfa${variantCapped}"
def zipTask = task("zip${variantCapped}", type: Zip) {
dependsOn prepareMagiskFilesTask
archiveName "${module_name}-${project.version}-${variantLowered}.zip"
destinationDir file("$projectDir/release")
from "$zipPathMagiskReleasePath"
}
task("push${variantCapped}") {
dependsOn "pushYahfa${variantCapped}"

task("push${variantCapped}", type: Exec) {
dependsOn zipTask
workingDir "${projectDir}/release"
def commands = [android.adbExecutable, "push",
"${module_name}-${project.version}-${variantLowered}.zip",
"/data/local/tmp/"]
if (is_windows) {
commandLine 'cmd', '/c', commands.join(" ")
} else {
commandLine commands
}
}
task("flash${variantCapped}", type: Exec) {
dependsOn tasks.getByPath("push${variantCapped}")
workingDir "${projectDir}/release"
def commands = [android.adbExecutable, "shell", "su", "-c",
"magisk --install-module /data/local/tmp/${module_name}-${project.version}-${variantLowered}.zip"]
if (is_windows) {
commandLine 'cmd', '/c', commands.join(" ")
} else {
commandLine commands
}
}
task("flashAndReboot${variantCapped}", type: Exec) {
dependsOn tasks.getByPath("flash${variantCapped}")
workingDir "${projectDir}/release"
def commands = [android.adbExecutable, "shell", "reboot"]
if (is_windows) {
commandLine 'cmd', '/c', commands.join(" ")
} else {
commandLine commands
}
}
}

Expand Down
43 changes: 18 additions & 25 deletions edxp-core/template_override/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,10 @@ LANG_UTIL_ERR_RIRU_NOT_FOUND_1="is not installed"
LANG_UTIL_ERR_RIRU_NOT_FOUND_2="Please install Riru from Magisk Manager"
LANG_UTIL_ERR_RIRU_LOW_1="or above is required"
LANG_UTIL_ERR_RIRU_LOW_2="Please upgrade Riru from Magisk Manager"
LANG_UTIL_ERR_REQUIRE_YAHFA_1="Architecture x86 or x86_64 detected"
LANG_UTIL_ERR_REQUIRE_YAHFA_2="Only YAHFA variant supports x86 or x86_64 architecture devices"
LANG_UTIL_ERR_REQUIRE_YAHFA_3="You can download from 'Magisk Manager' or 'EdXposed Manager'"
LANG_UTIL_ERR_ANDROID_UNSUPPORT_1="Unsupported Android version"
LANG_UTIL_ERR_ANDROID_UNSUPPORT_2="(below Oreo)"
LANG_UTIL_ERR_ANDROID_UNSUPPORT_3="Learn more from our GitHub Wiki"
LANG_UTIL_ERR_PLATFORM_UNSUPPORT="Unsupported platform"
LANG_UTIL_ERR_DUPINST_1="Duplicate installation is now allowed"
LANG_UTIL_ERR_DUPINST_2="Remove"
LANG_UTIL_ERR_DUPINST_3="and reboot to install again"

# Load lang
if [[ ${BOOTMODE} == true ]]; then
Expand Down Expand Up @@ -136,6 +130,9 @@ edxp_check_architecture
ui_print "- ${LANG_CUST_INST_EXT_FILES}"

# extract module files
rm -rf "${MODPATH}/../../${MODULES_PATH}/riru_edxposed_sandhook"
mkdir -p /data/adb/edxp || abortC "! ${LANG_CUST_ERR_CONF_CREATE}"

extract "${ZIPFILE}" 'EdXposed.apk' "${MODPATH}"
extract "${ZIPFILE}" 'module.prop' "${MODPATH}"
extract "${ZIPFILE}" 'system.prop' "${MODPATH}"
Expand All @@ -147,7 +144,8 @@ extract "${ZIPFILE}" 'system/framework/edconfig.jar' "${MODPATH}"
extract "${ZIPFILE}" 'system/framework/eddalvikdx.dex' "${MODPATH}"
extract "${ZIPFILE}" 'system/framework/eddexmaker.dex' "${MODPATH}"
extract "${ZIPFILE}" 'system/framework/edservice.dex' "${MODPATH}"
extract "${ZIPFILE}" 'system/framework/edxp.dex' "${MODPATH}"
extract "${ZIPFILE}" 'system/framework/sandhook.dex' "/data/adb/edxp" true
extract "${ZIPFILE}" 'system/framework/yahfa.dex' "/data/adb/edxp" true

if [ "$ARCH" = "x86" ] || [ "$ARCH" = "x64" ]; then
ui_print "- ${LANG_CUST_INST_EXT_LIB_X86}"
Expand All @@ -162,16 +160,12 @@ if [ "$ARCH" = "x86" ] || [ "$ARCH" = "x64" ]; then
else
ui_print "- ${LANG_CUST_INST_EXT_LIB_ARM}"
extract "$ZIPFILE" 'system/lib/libriru_edxp.so' "${MODPATH}"
if [[ "${VARIANT}" == "SandHook" ]]; then
extract "$ZIPFILE" 'system/lib/libsandhook.edxp.so' "${MODPATH}"
fi
extract "$ZIPFILE" 'system/lib/libsandhook.edxp.so' "${MODPATH}"

if [ "$IS64BIT" = true ]; then
ui_print "- ${LANG_CUST_INST_EXT_LIB_ARM64}"
extract "$ZIPFILE" 'system/lib64/libriru_edxp.so' "${MODPATH}"
if [[ "${VARIANT}" == "SandHook" ]]; then
extract "$ZIPFILE" 'system/lib64/libsandhook.edxp.so' "${MODPATH}"
fi
extract "$ZIPFILE" 'system/lib64/libsandhook.edxp.so' "${MODPATH}"
fi
fi

Expand All @@ -181,7 +175,7 @@ fi

if [[ ${BOOTMODE} == true && ${NO_MANAGER} == true ]]; then
ui_print "- ${LANG_CUST_INST_STUB}"
cp "${MODPATH}/EdXposed.apk" "/data/local/tmp/EdXposed.apk"
cp -f "${MODPATH}/EdXposed.apk" "/data/local/tmp/EdXposed.apk"
LOCAL_PATH_INFO=$(ls -ldZ "/data/local/tmp")
LOCAL_PATH_OWNER=$(echo "${LOCAL_PATH_INFO}" | awk -F " " '{print $3":"$4}')
LOCAL_PATH_CONTEXT=$(echo "${LOCAL_PATH_INFO}" | awk -F " " '{print $5}')
Expand All @@ -199,7 +193,6 @@ else
MISC_RAND=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16)
MISC_PATH="edxp_${MISC_RAND}"
ui_print " - ${LANG_CUST_INST_CONF_NEW} ${MISC_RAND}"
mkdir -p /data/adb/edxp || abortC "! ${LANG_CUST_ERR_CONF_CREATE}"
echo "$MISC_PATH" > /data/adb/edxp/misc_path || abortC "! ${LANG_CUST_ERR_CONF_STORE}"
if [[ -d /data/user_de/0/org.meowcat.edxposed.manager/conf/ ]]; then
mkdir -p /data/misc/$MISC_PATH/0/conf
Expand All @@ -211,21 +204,23 @@ touch /data/adb/edxp/new_install || abortC "! ${LANG_CUST_ERR_CONF_FIRST}"
set_perm_recursive /data/adb/edxp root root 0700 0600 "u:object_r:magisk_file:s0" || abortC "! ${LANG_CUST_ERR_PERM}"
mkdir -p /data/misc/$MISC_PATH || abortC "! ${LANG_CUST_ERR_CONF_CREATE}"
set_perm /data/misc/$MISC_PATH root root 0771 "u:object_r:magisk_file:s0" || abortC "! ${LANG_CUST_ERR_PERM}"
echo "[[ -f /data/adb/edxp/keep_data ]] || rm -rf /data/misc/$MISC_PATH" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
echo "rm -rf /data/misc/$MISC_PATH" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
echo "[[ -f /data/adb/edxp/new_install ]] || rm -rf /data/adb/edxp" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"

if [[ "${ARCH}" == "x86" || "${ARCH}" == "x64" ]]; then
touch /data/misc/$MISC_PATH/0/conf/disable_sandhook || abortC "! ${LANG_CUST_ERR_CONF_CREATE}"
fi

ui_print "- ${LANG_CUST_INST_COPY_LIB}"

rm -rf "/data/misc/$MISC_PATH/framework"
mv "${MODPATH}/system/framework" "/data/misc/$MISC_PATH/framework"

if [[ "${VARIANT}" == "SandHook" ]]; then
mkdir -p "/data/misc/$MISC_PATH/framework/lib"
mv "${MODPATH}/system/lib/libsandhook.edxp.so" "/data/misc/$MISC_PATH/framework/lib/libsandhook.edxp.so"
if [ "$IS64BIT" = true ]; then
mkdir -p "/data/misc/$MISC_PATH/framework/lib64"
mv "${MODPATH}/system/lib64/libsandhook.edxp.so" "/data/misc/$MISC_PATH/framework/lib64/libsandhook.edxp.so"
fi
mkdir -p "/data/misc/$MISC_PATH/framework/lib"
mv "${MODPATH}/system/lib/libsandhook.edxp.so" "/data/misc/$MISC_PATH/framework/lib/libsandhook.edxp.so"
if [ "$IS64BIT" = true ]; then
mkdir -p "/data/misc/$MISC_PATH/framework/lib64"
mv "${MODPATH}/system/lib64/libsandhook.edxp.so" "/data/misc/$MISC_PATH/framework/lib64/libsandhook.edxp.so"
fi
set_perm_recursive /data/misc/$MISC_PATH/framework root root 0755 0644 "u:object_r:magisk_file:s0" || abortC "! ${LANG_CUST_ERR_PERM}"

Expand Down Expand Up @@ -262,8 +257,6 @@ cp "${MODPATH}/module.prop" "${RIRU_TARGET}/module.prop" || abortC "! ${LANG_CUS

set_perm "$RIRU_TARGET/module.prop" 0 0 0600 $RIRU_SECONTEXT || abortC "! ${LANG_CUST_ERR_PERM}"

rm -f /data/adb/edxp/keep_data

set_perm_recursive "${MODPATH}" 0 0 0755 0644
ui_print "- ${LANG_CUST_INST_DONE} EdXposed ${VERSION}!"

Loading

0 comments on commit 0ffff4b

Please sign in to comment.