Skip to content

Commit

Permalink
Add SandHook-hooklib to source tree
Browse files Browse the repository at this point in the history
  • Loading branch information
kotori2 committed Dec 10, 2020
1 parent 8aa619f commit 35bdae3
Show file tree
Hide file tree
Showing 87 changed files with 6,887 additions and 31 deletions.
6 changes: 1 addition & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ allprojects {
templateLib64Path = templateRootPath + "/system/lib64/"
templateEtcPath = templateRootPath + "/system/etc/"
hiddenApiStubJarFilePath = project(":hiddenapi-stubs").buildDir.absolutePath + "/libs/framework-stub.jar"
zipPathMagiskReleasePath = project(":edxp-core").projectDir.path + "/build/tmp/release/magisk"
}
repositories {
google()
Expand All @@ -34,8 +35,3 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}

ext {
minSdkVersion = 23
targetSdkVersion = 28
}
4 changes: 2 additions & 2 deletions edxp-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ android {
compileSdkVersion androidCompileSdkVersion.toInteger()

defaultConfig {
minSdkVersion 26
targetSdkVersion 28
minSdkVersion minSdkVersion
targetSdkVersion targetSdkVersion
versionCode 1
versionName "1.0"
}
Expand Down
27 changes: 16 additions & 11 deletions edxp-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ ext {
sandhook_authors = "solohsu, MlgmXyysd & ganyao114"

riruModuleId = "edxp"
zipPathMagiskRelease = "$buildDir/tmp/release/magisk"

moduleMinRiruApiVersion = 10
moduleMinRiruVersionName = "v23.0"
Expand Down Expand Up @@ -120,13 +119,16 @@ afterEvaluate {
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")

project.logger.lifecycle("delete file")
delete file(zipPathMagiskReleasePath)

def prepareJarsTask = task("prepareJars${backendCapped}${variantCapped}") {
project.logger.lifecycle("prepareJarsTask")
dependsOn cleanTemplate
dependsOn tasks.getByPath(":dexmaker:copyDex${variantCapped}")
dependsOn tasks.getByPath(":dalvikdx:copyDex${variantCapped}")
Expand All @@ -136,7 +138,6 @@ afterEvaluate {

def prepareMagiskFilesTask = task("prepareMagiskFiles${backendCapped}${variantCapped}", type: Delete) {
dependsOn prepareJarsTask, "assemble${variantCapped}"
delete file(zipPathMagiskRelease)
doFirst {
copy {
from "${projectDir}/tpl/edconfig.tpl"
Expand Down Expand Up @@ -169,12 +170,12 @@ afterEvaluate {
doLast {
copy {
from "${projectDir}/template_override"
into zipPathMagiskRelease
into zipPathMagiskReleasePath
exclude exclude_list
}
copy {
from "${projectDir}/template_override"
into zipPathMagiskRelease
into zipPathMagiskReleasePath
include 'riru.sh'
filter { line ->
line.replaceAll('%%%RIRU_MODULE_ID%%%', riruModuleId)
Expand All @@ -185,23 +186,27 @@ afterEvaluate {
eol: FixCrLfFilter.CrLf.newInstance("lf"))
}
copy {
include "libriru_edxp.so"
from "$libPathRelease/armeabi-v7a"
into "$zipPathMagiskRelease/system/lib"
into "$zipPathMagiskReleasePath/system/lib"
}
copy {
include "libriru_edxp.so"
from "$libPathRelease/arm64-v8a"
into "$zipPathMagiskRelease/system/lib64"
into "$zipPathMagiskReleasePath/system/lib64"
}
copy {
include "libriru_edxp.so"
from "$libPathRelease/x86"
into "$zipPathMagiskRelease/system_x86/lib"
into "$zipPathMagiskReleasePath/system_x86/lib"
}
copy {
include "libriru_edxp.so"
from "$libPathRelease/x86_64"
into "$zipPathMagiskRelease/system_x86/lib64"
into "$zipPathMagiskReleasePath/system_x86/lib64"
}
// generate sha1sum
fileTree(zipPathMagiskRelease).matching {
fileTree(zipPathMagiskReleasePath).matching {
exclude "README.md", "META-INF"
}.visit { f ->
if (f.directory) return
Expand All @@ -214,7 +219,7 @@ afterEvaluate {
dependsOn prepareMagiskFilesTask
archiveName "${module_name}-${backend}-${project.version}-${variantLowered}.zip"
destinationDir file("$projectDir/release")
from "$zipPathMagiskRelease"
from "$zipPathMagiskReleasePath"
}

task("push${backendCapped}${variantCapped}", type: Exec) {
Expand Down
12 changes: 6 additions & 6 deletions edxp-sandhook/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {

defaultConfig {
applicationId "com.elderdrivers.riru.edxp.sandhook"
minSdkVersion 26
targetSdkVersion 28
minSdkVersion minSdkVersion
targetSdkVersion targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled false
Expand All @@ -28,7 +28,7 @@ android {
dependencies {
compileOnly project(':hiddenapi-stubs')
implementation project(':edxp-common')
implementation 'com.swift.sandhook:hooklib:4.2.1'
implementation project(':sandhook-hooklib')
compileOnly files(project(":dexmaker").tasks.getByName("makeJarRelease").outputs)
}

Expand Down Expand Up @@ -62,21 +62,21 @@ afterEvaluate {
task("copyDex${variantNameCapped}", type: Copy) {
dependsOn "assemble${variantNameCapped}"
dependsOn tasks.getByPath(":edxp-common:copyCommonProperties")
dependsOn tasks.getByPath(":sandhook-hooklib:copySandHook${variantNameCapped}LibraryToMagiskTemplate")
def dexOutPath = variant.name.contains("release") ?
"${buildDir}/intermediates/dex/${variantNameLowered}/minify${variantNameCapped}WithR8" :
"${buildDir}/intermediates/dex/${variantNameLowered}/mergeDex${variantNameCapped}"
from (dexOutPath){
rename("classes.dex", "edxp.dex")
}
destinationDir file(templateRootPath + "system/framework/")
destinationDir file(zipPathMagiskReleasePath + "/system/framework/")
outputs.upToDateWhen { false }
doLast {
copy {
from file(myTemplatePath)
into file(templateRootPath)
into file(zipPathMagiskReleasePath)
}
}
}

}
}
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions edxp-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {

defaultConfig {
applicationId "com.elderdrivers.riru.edxp.yahfa"
minSdkVersion 26
targetSdkVersion 28
minSdkVersion minSdkVersion
targetSdkVersion targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled false
Expand Down
4 changes: 2 additions & 2 deletions edxp-yahfa/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {

defaultConfig {
applicationId "com.elderdrivers.riru.edxp.yahfa"
minSdkVersion 26
targetSdkVersion 28
minSdkVersion minSdkVersion
targetSdkVersion targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled false
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
androidCompileSdkVersion=30
androidCompileNdkVersion=22.0.6917172
android.prefabVersion=1.1.2
apiCode=93
apiCode=93
minSdkVersion=26
targetSdkVersion=30
1 change: 1 addition & 0 deletions sandhook-annotation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
8 changes: 8 additions & 0 deletions sandhook-annotation/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apply plugin: 'java-library'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}

sourceCompatibility = "1.7"
targetCompatibility = "1.7"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.swift.sandhook.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface HookClass {
Class<?> value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.swift.sandhook.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface HookMethod {
String value() default "<init>";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.swift.sandhook.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.METHOD,ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface HookMethodBackup {
String value() default "<init>";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.swift.sandhook.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface HookMode {

int AUTO = 0;
int INLINE = 1;
int REPLACE = 2;

int value() default AUTO;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.swift.sandhook.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface HookReflectClass {
String value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.swift.sandhook.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.METHOD,ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface MethodParams {
Class<?>[] value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.swift.sandhook.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.METHOD,ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface MethodReflectParams {

String BOOLEAN = "boolean";
String BYTE = "byte";
String CHAR = "char";
String DOUBLE = "double";
String FLOAT = "float";
String INT = "int";
String LONG = "long";
String SHORT = "short";

String[] value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.swift.sandhook.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface Param {
String value() default "";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.swift.sandhook.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface SkipParamCheck {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.swift.sandhook.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface ThisObject {
}
2 changes: 2 additions & 0 deletions sandhook-hooklib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build
/.cxx
Loading

0 comments on commit 35bdae3

Please sign in to comment.