mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-06 10:45:47 +08:00
Release 1.0 available
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# Yuki Hook API (完善中)
|
# Yuki Hook API
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
@@ -49,7 +49,6 @@
|
|||||||
|
|
||||||
# Get Started
|
# Get Started
|
||||||
|
|
||||||
- ❗相关依赖暂未上传 Maven,将在稍后完成。
|
|
||||||
- 你可以点击[快速开始](https://github.com/fankes/YukiHookAPI/wiki#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B),集成 `YukiHookAPI` 并开始使用。
|
- 你可以点击[快速开始](https://github.com/fankes/YukiHookAPI/wiki#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B),集成 `YukiHookAPI` 并开始使用。
|
||||||
- 更多使用教程及 API 文档请[前往 Wiki 主页](https://github.com/fankes/YukiHookAPI/wiki)进行查看。
|
- 更多使用教程及 API 文档请[前往 Wiki 主页](https://github.com/fankes/YukiHookAPI/wiki)进行查看。
|
||||||
|
|
||||||
|
@@ -9,6 +9,13 @@ plugins {
|
|||||||
java {
|
java {
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
withJavadocJar()
|
||||||
|
withSourcesJar()
|
||||||
|
}
|
||||||
|
|
||||||
|
javadoc {
|
||||||
|
options.addStringOption("charset", "UTF-8")
|
||||||
|
if (JavaVersion.current().isJava9Compatible()) options.addBooleanOption('html5', true)
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin { sourceSets.main { kotlin.srcDir("src/api/kotlin") } }
|
kotlin { sourceSets.main { kotlin.srcDir("src/api/kotlin") } }
|
||||||
@@ -61,14 +68,8 @@ publishing {
|
|||||||
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
|
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
|
||||||
}
|
}
|
||||||
credentials {
|
credentials {
|
||||||
BufferedReader buff_USERNAME = new BufferedReader(new FileReader("/Users/fankes/ProjectPath/AndroidStudioProjects/YukiHookAPI/.gradle/OSSRH_USERNAME"))
|
username = getFileContent("OSSRH_USERNAME")
|
||||||
String OSSRH_USERNAME = buff_USERNAME.readLine()
|
password = getFileContent("OSSRH_PASSWORD")
|
||||||
buff_USERNAME.close()
|
|
||||||
BufferedReader buff_PASSWORD = new BufferedReader(new FileReader("/Users/fankes/ProjectPath/AndroidStudioProjects/YukiHookAPI/.gradle/OSSRH_PASSWORD"))
|
|
||||||
String OSSRH_PASSWORD = buff_PASSWORD.readLine()
|
|
||||||
buff_PASSWORD.close()
|
|
||||||
username = OSSRH_USERNAME
|
|
||||||
password = OSSRH_PASSWORD
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,4 +77,13 @@ publishing {
|
|||||||
|
|
||||||
signing {
|
signing {
|
||||||
sign(publishing.publications.mavenJava)
|
sign(publishing.publications.mavenJava)
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getFileContent(String name) {
|
||||||
|
FileReader reader = new FileReader("/Users/fankes/ProjectPath/AndroidStudioProjects/YukiHookAPI/.gradle/" + name)
|
||||||
|
BufferedReader buff = new BufferedReader(reader)
|
||||||
|
String result = buff.readLine()
|
||||||
|
buff.close()
|
||||||
|
reader.close()
|
||||||
|
return result
|
||||||
}
|
}
|
@@ -9,9 +9,15 @@ java {
|
|||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
sourceSets.main { java.srcDir("src/api/kotlin") }
|
sourceSets.main { java.srcDir("src/api/kotlin") }
|
||||||
|
withJavadocJar()
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
javadoc {
|
||||||
|
options.addStringOption("charset", "UTF-8")
|
||||||
|
if (JavaVersion.current().isJava9Compatible()) options.addBooleanOption('html5', true)
|
||||||
|
}
|
||||||
|
|
||||||
kotlin { sourceSets.main { kotlin.srcDir("src/api/kotlin") } }
|
kotlin { sourceSets.main { kotlin.srcDir("src/api/kotlin") } }
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -63,14 +69,8 @@ publishing {
|
|||||||
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
|
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
|
||||||
}
|
}
|
||||||
credentials {
|
credentials {
|
||||||
BufferedReader buff_USERNAME = new BufferedReader(new FileReader("/Users/fankes/ProjectPath/AndroidStudioProjects/YukiHookAPI/.gradle/OSSRH_USERNAME"))
|
username = getFileContent("OSSRH_USERNAME")
|
||||||
String OSSRH_USERNAME = buff_USERNAME.readLine()
|
password = getFileContent("OSSRH_PASSWORD")
|
||||||
buff_USERNAME.close()
|
|
||||||
BufferedReader buff_PASSWORD = new BufferedReader(new FileReader("/Users/fankes/ProjectPath/AndroidStudioProjects/YukiHookAPI/.gradle/OSSRH_PASSWORD"))
|
|
||||||
String OSSRH_PASSWORD = buff_PASSWORD.readLine()
|
|
||||||
buff_PASSWORD.close()
|
|
||||||
username = OSSRH_USERNAME
|
|
||||||
password = OSSRH_PASSWORD
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,4 +78,13 @@ publishing {
|
|||||||
|
|
||||||
signing {
|
signing {
|
||||||
sign(publishing.publications.mavenJava)
|
sign(publishing.publications.mavenJava)
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getFileContent(String name) {
|
||||||
|
FileReader reader = new FileReader("/Users/fankes/ProjectPath/AndroidStudioProjects/YukiHookAPI/.gradle/" + name)
|
||||||
|
BufferedReader buff = new BufferedReader(reader)
|
||||||
|
String result = buff.readLine()
|
||||||
|
buff.close()
|
||||||
|
reader.close()
|
||||||
|
return result
|
||||||
}
|
}
|
@@ -49,10 +49,6 @@ public class ReflectionUtils {
|
|||||||
private static final HashMap<String, Field> fieldCache = new HashMap<>();
|
private static final HashMap<String, Field> fieldCache = new HashMap<>();
|
||||||
private static final HashMap<String, Method> methodCache = new HashMap<>();
|
private static final HashMap<String, Method> methodCache = new HashMap<>();
|
||||||
|
|
||||||
/**
|
|
||||||
* @param clazzes
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
private static String getParametersString(Class<?>... clazzes) {
|
private static String getParametersString(Class<?>... clazzes) {
|
||||||
StringBuilder sb = new StringBuilder("(");
|
StringBuilder sb = new StringBuilder("(");
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
@@ -72,70 +68,13 @@ public class ReflectionUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param clazz
|
* 适用于查找混淆类型的 abcd 变量
|
||||||
* @param fieldType
|
*
|
||||||
* @param fieldName
|
* @param clazz 变量所在类
|
||||||
* @param value
|
* @param typeName 类型名称
|
||||||
* @return Field
|
* @param fieldName 变量名
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static void setStaticObjectField(Class<?> clazz, Class<?> fieldType, String fieldName, Object value)
|
|
||||||
throws NoSuchFieldException, IllegalAccessException {
|
|
||||||
findFieldIfExists(clazz, fieldType, fieldName).set(null, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param fieldType
|
|
||||||
* @param fieldName
|
|
||||||
* @param value
|
|
||||||
* @param obj
|
|
||||||
* @return Field
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static void setObjectField(Object obj, Class<?> fieldType, String fieldName, Object value)
|
|
||||||
throws NoSuchFieldException, IllegalAccessException {
|
|
||||||
if (obj != null) {
|
|
||||||
Field field = findFieldIfExists(obj.getClass(), fieldType, fieldName);
|
|
||||||
if (field != null) {
|
|
||||||
field.set(obj, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Field findFieldIfExists(Class<?> clazz, Class<?> fieldType, String fieldName)
|
|
||||||
throws NoSuchFieldException {
|
|
||||||
return findFieldIfExists(clazz, fieldType.getName(), fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isCallingFrom(String className) {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread()
|
|
||||||
.getStackTrace();
|
|
||||||
for (StackTraceElement element : stackTraceElements) {
|
|
||||||
if (element.getClassName()
|
|
||||||
.contains(className)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isCallingFromEither(String... classname) {
|
|
||||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
|
||||||
for (StackTraceElement element : stackTraceElements) {
|
|
||||||
for (String name : classname) {
|
|
||||||
if (element.toString().contains(name)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param clazz
|
|
||||||
* @param typeName
|
|
||||||
* @param fieldName
|
|
||||||
* @return Field
|
* @return Field
|
||||||
|
* @throws NoSuchFieldException 如果找不到变量
|
||||||
*/
|
*/
|
||||||
public static Field findFieldIfExists(Class<?> clazz, String typeName, String fieldName) throws NoSuchFieldException {
|
public static Field findFieldIfExists(Class<?> clazz, String typeName, String fieldName) throws NoSuchFieldException {
|
||||||
String fullFieldName = "name:[" + fieldName + "] type:[" + typeName + "] in Class [" + clazz.getName() + "] by YukiHookAPI#finder";
|
String fullFieldName = "name:[" + fieldName + "] type:[" + typeName + "] in Class [" + clazz.getName() + "] by YukiHookAPI#finder";
|
||||||
@@ -172,6 +111,7 @@ public class ReflectionUtils {
|
|||||||
* @param returnType 返回类型
|
* @param returnType 返回类型
|
||||||
* @param methodName 方法名
|
* @param methodName 方法名
|
||||||
* @return Method
|
* @return Method
|
||||||
|
* @throws NoSuchMethodError 如果找不到方法
|
||||||
*/
|
*/
|
||||||
public static Method findMethodNoParam(Class<?> clazz, Class<?> returnType, String methodName) {
|
public static Method findMethodNoParam(Class<?> clazz, Class<?> returnType, String methodName) {
|
||||||
String fullMethodName = "name:[" + methodName + "] in Class [" + clazz.getName() + "] by YukiHookAPI#finder";
|
String fullMethodName = "name:[" + methodName + "] in Class [" + clazz.getName() + "] by YukiHookAPI#finder";
|
||||||
@@ -192,6 +132,7 @@ public class ReflectionUtils {
|
|||||||
* @param methodName 方法名
|
* @param methodName 方法名
|
||||||
* @param parameterTypes 方法参数类型数组
|
* @param parameterTypes 方法参数类型数组
|
||||||
* @return Method
|
* @return Method
|
||||||
|
* @throws NoSuchMethodError 如果找不到方法
|
||||||
*/
|
*/
|
||||||
public static Method findMethodBestMatch(Class<?> clazz, Class<?> returnType, String methodName, Class<?>... parameterTypes) {
|
public static Method findMethodBestMatch(Class<?> clazz, Class<?> returnType, String methodName, Class<?>... parameterTypes) {
|
||||||
String fullMethodName = "name:[" + methodName + "] paramType:[" + getParametersString(parameterTypes) + "] in Class [" + clazz.getName() + "] by YukiHookAPI#finder";
|
String fullMethodName = "name:[" + methodName + "] paramType:[" + getParametersString(parameterTypes) + "] in Class [" + clazz.getName() + "] by YukiHookAPI#finder";
|
||||||
@@ -210,6 +151,7 @@ public class ReflectionUtils {
|
|||||||
* @param clazz 构造类所在类
|
* @param clazz 构造类所在类
|
||||||
* @param parameterTypes 构造类方法参数类型数组
|
* @param parameterTypes 构造类方法参数类型数组
|
||||||
* @return Constructor
|
* @return Constructor
|
||||||
|
* @throws NoSuchMethodError 如果找不到构造类
|
||||||
*/
|
*/
|
||||||
public static Constructor<?> findConstructorExact(Class<?> clazz, Class<?>... parameterTypes) {
|
public static Constructor<?> findConstructorExact(Class<?> clazz, Class<?>... parameterTypes) {
|
||||||
String fullConstructorName = "paramType:[" + getParametersString(parameterTypes) + "in Class [" + clazz.getName() + "] by YukiHookAPI#finder";
|
String fullConstructorName = "paramType:[" + getParametersString(parameterTypes) + "in Class [" + clazz.getName() + "] by YukiHookAPI#finder";
|
||||||
|
Reference in New Issue
Block a user