Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
virjar committed Sep 2, 2021
1 parent 6e4a939 commit 24f6c9d
Show file tree
Hide file tree
Showing 50 changed files with 1,772 additions and 189 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
```

## 单步调试
将命令行参数放到``container-builder-repkg/src/main/java/ratelentry/Main.java``,然后单步调试main函数的执行流程即可
将命令行参数放到``container-builder-repkg/src/main/java/com/virjar/ratel/builder/ratelentry/Main.java``,然后单步调试main函数的执行流程即可

Binary file modified base-lib-allcommon-lib/base-lib-allcommon-sources.jar
Binary file not shown.
Binary file modified base-lib-allcommon-lib/base-lib-allcommon.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.virjar.ratel.allcommon;

/**
* 多个模块部件相互关联,通过多个部件无法在同一个classloader直接引用和检查所有的class<br>
* 所以className在这里管理,如果未来ratel存在对抗,需要修改className,那么需要同步修改这张表
*/
public enum ClassNames {
BUILDER_HELPER_MAIN("com.virjar.ratel.builder.helper.Main"),
BUILDER_MAIN("com.virjar.ratel.builder.ratelentry.Main"),
INJECT_REBUILD_BOOTSTRAP("com.virjar.ratel.inject.template.rebuild.BootStrap"),
INJECT_REBUILD_BOOTSTRAP_CINT("com.virjar.ratel.inject.template.rebuild.BootStrapWithStaticInit"),


INJECT_TOOL_SMALI_LOG("com.virjar.ratel.inject.template.RatelSmaliLog"),
INJECT_TOOL_EVENT_NOTIFIER("com.virjar.ratel.inject.template.EventNotifier"),


;

ClassNames(String className) {
this.className = className;
}

private final String className;

public void check(Class<?> clazz) {
if (!clazz.getName().equals(className)) {
throw new IllegalStateException("class name define error-> expected: " + className + " actually: " + clazz.getName());
}
}

public String getClassName() {
return className;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,62 @@
* 新版本的常量定义,之前的太乱了
*/
public interface NewConstants {

/**
* builder的资源文件名称定义
*/
interface BUILDER_RESOURCE_LAYOUT {
String LAYOUT_BASE = "build-asset";
String BUILDER_HELPER_NAME = LAYOUT_BASE + "/builder-helper.jar";
enum BUILDER_RESOURCE_LAYOUT {
LAYOUT_BASE("build-asset", true, true),
BUILDER_HELPER_NAME(LAYOUT_BASE.NAME + "/builder-helper.jar.bin", true),
// BUILDER_HELPER_NAME2(LAYOUT_BASE.NAME + "/builder-helper.jar.bin", true),

String RUNTIME_APK_FILE = LAYOUT_BASE + "/runtime.apk";
String RUNTIME_JAR_FILE = LAYOUT_BASE + "/runtime.jar";
RUNTIME_APK_FILE(LAYOUT_BASE.NAME + "/runtime.apk", true),
RUNTIME_JAR_FILE(LAYOUT_BASE.NAME + "/runtime.jar", false),

String XPOSED_BRIDGE_APK_FILE = LAYOUT_BASE + "/xpBridge.apk";
String XPOSED_BRIDGE_JAR_FILE = LAYOUT_BASE + "/xpBridge.jar";
XPOSED_BRIDGE_APK_FILE(LAYOUT_BASE.NAME + "/xpBridge.apk", true),
XPOSED_BRIDGE_JAR_FILE(LAYOUT_BASE.NAME + "/xpBridge.jar", false),

/**
* 入口代码定义,包括一些smali模版
*/
String TEMPLATE_APK_FILE = LAYOUT_BASE + "/template.apk";
TEMPLATE_APK_FILE(LAYOUT_BASE.NAME + "/template.apk", true),

/**
* appendDex模式下,直接使用dex文件
*/
String TEMPLATE_DEX_FILE = LAYOUT_BASE + "/template.dex";
TEMPLATE_DEX_FILE(LAYOUT_BASE.NAME + "/template.dex", false),

/**
* template需要解成smali
*/
String TEMPLATE_SMALI_ZIP_FILE = LAYOUT_BASE + "/template-smali.zip.bin";
TEMPLATE_SMALI_ZIP_FILE(LAYOUT_BASE.NAME + "/template-smali.zip.bin", false),
;

private final String NAME;
private final boolean raw;
private final boolean dir;

BUILDER_RESOURCE_LAYOUT(String NAME, boolean raw, boolean dir) {
this.NAME = NAME;
this.raw = raw;
this.dir = dir;
}

BUILDER_RESOURCE_LAYOUT(String NAME, boolean raw) {
this(NAME, raw, false);
}

public String getNAME() {
return NAME;
}

public boolean isRaw() {
return raw;
}

public boolean isDir() {
return dir;
}
}


Expand Down
5 changes: 4 additions & 1 deletion container-builder-helper/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.virjar.ratel.allcommon.ClassNames

buildscript {
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
Expand Down Expand Up @@ -26,6 +28,7 @@ dependencies {
api 'org.smali:util:2.2.7'
api 'org.smali:baksmali:2.2.7'
api 'org.smali:smali:2.2.7'
api(name: 'base-lib-allcommon', ext: 'jar')

}

Expand All @@ -39,7 +42,7 @@ shadowJar {
classifier = null
version = 1.0
manifest {
attributes 'Main-Class': 'com.virjar.ratel.builder.helper.Main'
attributes 'Main-Class': ClassNames.BUILDER_HELPER_MAIN.className
}
}
assemble.dependsOn(shadowJar)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.virjar.ratel.builder.helper;

import com.virjar.ratel.allcommon.ClassNames;
import com.virjar.ratel.builder.helper.apk2jar.APK2Jar;
import com.virjar.ratel.builder.helper.bro.OptimizeBuilderResource;

Expand All @@ -14,6 +15,7 @@ public class Main {
* 本模块干的都是脏活儿累活儿,他不需要考虑资源大小问题,因为他最终不会出现在发布版本的构建工具中
*/
public static void main(String[] args) throws Exception {
ClassNames.BUILDER_HELPER_MAIN.check(Main.class);
if (args.length == 0) {
showHelpMessage();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public static void transformApkToAndroidJar(File apkFile, File outJarFile, Packa
//清除无意义的class,因为我们使用了Android的打包工具链,存在一些android本身的class,这些class对于我们来说没有意义
zipOutputStream.write(cleanClasses(zipFile.getInputStream(zipEntry), packageTrie));
}
} else if (zipEntry.getName().startsWith("lib/")
// || zipEntry.getName().startsWith("assets/")
) {
zipOutputStream.putNextEntry(new ZipEntry(zipEntry.getName()));
// lib资源需要迁移过去,因为我们构建的时候需要lib资源
zipOutputStream.write(IOUtils.toByteArray(zipFile.getInputStream(zipEntry)));
}
}
}
Expand Down
Loading

0 comments on commit 24f6c9d

Please sign in to comment.