this is a pain

This commit is contained in:
Jean-Marie Mineau 2025-04-16 17:11:36 +02:00
parent abd30de39c
commit d269206cbb
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
9 changed files with 166 additions and 25 deletions

View file

@ -37,7 +37,7 @@ debug: all
test: all grodd-venv
$(ADB) install build/$(APP).apk
$(ADB) shell am start -n $(PACKAGE)/.$(MAIN_ACTIVITY)
grodd-venv/bin/grodd-runner -d emulator-5554 -r grodd -t 300 -p $(PACKAGE) # -s 1.
grodd-venv/bin/grodd-runner -d emulator-5554 -r grodd -t 900 -p $(PACKAGE) -s 0.5
build/%.v1signed.apk: ./build/%.unsigned.apk ./ToyKey.keystore
$(JARSIGNER) -verbose -keystore ./ToyKey.keystore -storepass $(pass) -keypass $(pass) -signedjar $@ $< SignKey
@ -54,6 +54,11 @@ build/%/classes.dex: build/%/classes
mkdir -p ./build/$*
$(D8) $(D8_ARGS) --classpath $(SDK_TOOLS)/platforms/android-$(VERSION_B)/android.jar $(shell find build/$*/classes -type f -regex ".*\.class" -printf "'%p'\n") --output ./build/$*/
build/a/classes.dex: build/a/classes
mkdir -p ./build/a
$(D8) $(D8_ARGS) --classpath $(SDK_TOOLS)/platforms/android-$(VERSION_B)/android.jar $(shell find build/a/classes -type f -regex ".*\.class" -printf "'%p'\n") --output ./build/a/
#$(D8) $(D8_ARGS) --classpath $(SDK_TOOLS)/platforms/android-$(VERSION_B)/android.jar $(shell find build/a/classes -type f -regex ".*\.class" -not -name "ICommonInterface.class" -printf "'%p'\n") --output ./build/a/
build/%.unsigned.apk: build/classes/classes.dex build/a/classes.dex
mkdir -p ./build/$*_files ./build/$*_files/assets
mv ./build/classes/classes.dex ./build/$*_files/classes.dex

View file

@ -1,6 +1,6 @@
package com.example.theseus.dynandref;
public class AReflectee extends APReflectee implements AIReflectee {
public class AReflectee extends APReflectee implements AIReflectee, ICommonInterface {
public static String getReflecteeId() {
return "A";
}
@ -59,4 +59,23 @@ public class AReflectee extends APReflectee implements AIReflectee {
}
return getReflecteeId() + ":" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
}
public String commonInterTransfer(
boolean bool,
byte by,
short sh,
char ch,
int in,
long lo,
float fl,
double dou,
String str,
String... args
) {
String val = "";
for (String v : args) {
val += " " + v;
}
return getReflecteeId() + ":" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
}
}

View file

@ -1,6 +1,6 @@
package com.example.theseus.dynandref;
public class Collider extends PCollider implements ICollider {
public class Collider extends PCollider implements ICollider, ICommonInterface {
public static String getColliderId() {
return "A";
}
@ -59,4 +59,23 @@ public class Collider extends PCollider implements ICollider {
}
return getColliderId() + ":" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
}
public String commonInterTransfer(
boolean bool,
byte by,
short sh,
char ch,
int in,
long lo,
float fl,
double dou,
String str,
String... args
) {
String val = "";
for (String v : args) {
val += " " + v;
}
return getColliderId() + ":" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
}
}

View file

@ -0,0 +1,16 @@
package com.example.theseus.dynandref;
public interface ICommonInterface {
public String commonInterTransfer(
boolean bool,
byte by,
short sh,
char ch,
int in,
long lo,
float fl,
double dou,
String str,
String... args
);
}

View file

@ -132,33 +132,33 @@ public class ClassLoaderContextActivity extends Activity {
if (classLoaderName.equals("DelegateLastClassLoader") && hasCollision && hasParent) {
cl = CollisionWithParentDelegateLastClassLoaderActivity.class;
} else if (classLoaderName.equals("DelegateLastClassLoader") && hasCollision && !hasParent) {
cl = CollisionWithParentDelegateLastClassLoaderActivity.class;
cl = CollisionWithoutParentDelegateLastClassLoaderActivity.class;
} else if (classLoaderName.equals("DelegateLastClassLoader") && !hasCollision && hasParent) {
cl = NoCollisionWithoutParentDelegateLastClassLoaderActivity.class;
cl = NoCollisionWithParentDelegateLastClassLoaderActivity.class;
} else if (classLoaderName.equals("DelegateLastClassLoader") && !hasCollision && !hasParent) {
cl = NoCollisionWithoutParentDelegateLastClassLoaderActivity.class;
} else if (classLoaderName.equals("DexClassLoader") && hasCollision && hasParent) {
cl = CollisionWithParentDexClassLoaderActivity.class;
} else if (classLoaderName.equals("DexClassLoader") && hasCollision && !hasParent) {
cl = CollisionWithParentDexClassLoaderActivity.class;
cl = CollisionWithoutParentDexClassLoaderActivity.class;
} else if (classLoaderName.equals("DexClassLoader") && !hasCollision && hasParent) {
cl = NoCollisionWithoutParentDexClassLoaderActivity.class;
cl = NoCollisionWithParentDexClassLoaderActivity.class;
} else if (classLoaderName.equals("DexClassLoader") && !hasCollision && !hasParent) {
cl = NoCollisionWithoutParentDexClassLoaderActivity.class;
} else if (classLoaderName.equals("InMemoryDexClassLoader") && hasCollision && hasParent) {
cl = CollisionWithParentInMemoryDexClassLoaderActivity.class;
} else if (classLoaderName.equals("InMemoryDexClassLoader") && hasCollision && !hasParent) {
cl = CollisionWithParentInMemoryDexClassLoaderActivity.class;
cl = CollisionWithoutParentInMemoryDexClassLoaderActivity.class;
} else if (classLoaderName.equals("InMemoryDexClassLoader") && !hasCollision && hasParent) {
cl = NoCollisionWithoutParentInMemoryDexClassLoaderActivity.class;
cl = NoCollisionWithParentInMemoryDexClassLoaderActivity.class;
} else if (classLoaderName.equals("InMemoryDexClassLoader") && !hasCollision && !hasParent) {
cl = NoCollisionWithoutParentInMemoryDexClassLoaderActivity.class;
} else if (classLoaderName.equals("PathClassLoader") && hasCollision && hasParent) {
cl = CollisionWithParentPathClassLoaderActivity.class;
} else if (classLoaderName.equals("PathClassLoader") && hasCollision && !hasParent) {
cl = CollisionWithParentPathClassLoaderActivity.class;
cl = CollisionWithoutParentPathClassLoaderActivity.class;
} else if (classLoaderName.equals("PathClassLoader") && !hasCollision && hasParent) {
cl = NoCollisionWithoutParentPathClassLoaderActivity.class;
cl = NoCollisionWithParentPathClassLoaderActivity.class;
} else if (classLoaderName.equals("PathClassLoader") && !hasCollision && !hasParent) {
cl = NoCollisionWithoutParentPathClassLoaderActivity.class;
} else {

View file

@ -1,6 +1,6 @@
package com.example.theseus.dynandref;
public class Collider extends PCollider implements ICollider {
public class Collider extends PCollider implements ICollider, ICommonInterface {
public static String getColliderId() {
return "MainAPK";
}
@ -59,4 +59,23 @@ public class Collider extends PCollider implements ICollider {
}
return getColliderId() + ":" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
}
public String commonInterTransfer(
boolean bool,
byte by,
short sh,
char ch,
int in,
long lo,
float fl,
double dou,
String str,
String... args
) {
String val = "";
for (String v : args) {
val += " " + v;
}
return getColliderId() + ":" + val + "(" + bool + " " + by + " " + sh + " " + ch + " " + in + " " + lo + " " + fl + " " + dou + " " + str + ")";
}
}

View file

@ -0,0 +1,16 @@
package com.example.theseus.dynandref;
public interface ICommonInterface {
public String commonInterTransfer(
boolean bool,
byte by,
short sh,
char ch,
int in,
long lo,
float fl,
double dou,
String str,
String... args
);
}

View file

@ -72,9 +72,9 @@ public class Main {
if (methodType.equals("Virtual")) {
Method mth = clz.getMethod("virtTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
Object instance = clz.getDeclaredConstructor().newInstance();
invoke(ac,
instance,
true,
clz,
mth,
args,
true,
@ -91,7 +91,8 @@ public class Main {
} else if (methodType.equals("Static")) {
Method mth = clz.getMethod("staticTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
invoke(ac,
null,
false,
clz,
mth,
args,
true,
@ -107,9 +108,9 @@ public class Main {
);
} else if (methodType.equals("Extended")) {
Method mth = clz.getMethod("extendedTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
Object instance = clz.getDeclaredConstructor().newInstance();
invoke(ac,
instance,
true,
clz,
mth,
args,
true,
@ -125,9 +126,9 @@ public class Main {
);
} else if (methodType.equals("Interface")) {
Method mth = clz.getMethod("interTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
Object instance = clz.getDeclaredConstructor().newInstance();
invoke(ac,
instance,
true,
clz,
mth,
args,
true,
@ -147,7 +148,8 @@ public class Main {
clz = cl.loadClass("com.example.theseus.dynandref.ICollider");
Method mth = clz.getMethod("staticInterfaceTransfer", boolean.class, byte.class, short.class, char.class, int.class, long.class, float.class, double.class, String.class, String[].class);
invoke(ac,
null,
false,
clz,
mth,
args,
true,
@ -161,8 +163,19 @@ public class Main {
"",
new String[] {"some", "strings"}
);
} else if (methodType.equals("Factory isDirectPattern")) {
return;
} else if (methodType.equals("Factory Pattern")) {
factory(
ac, clz,
true,
(byte)42,
(short)666,
'*',
0xDEAD_BEEF,
0xD1AB011C_5EAF00DL,
0.99f,
3.1415926535897932384626433d,
new String[] {"some", "strings"}
);
} else {
return;
};
@ -171,8 +184,36 @@ public class Main {
}
}
public static void factory(
Activity ac, Class clz,
boolean bool,
byte by,
short sh,
char ch,
int in,
long lo,
float fl,
double dou,
String... args
) throws Exception {
ICommonInterface instance = (ICommonInterface)clz.getDeclaredConstructor().newInstance();
String res = instance.commonInterTransfer(
bool,
by,
sh,
ch,
in,
lo,
fl,
dou,
Utils.source(),
args
);
Utils.sink(ac, res);
}
public static void invoke(
Activity ac, Object instance, Method mth, Object[] args,
Activity ac, boolean instanciate, Class clz, Method mth, Object[] args,
// Additionnal args to check the register reservation
boolean bool,
byte by,
@ -185,8 +226,11 @@ public class Main {
String str,
String... strArgs
) throws Exception {
Object instance = null;
if (instanciate) {
instance = clz.getDeclaredConstructor().newInstance();
}
args[8] = Utils.source();
Log.e("THESEUS", "instance: " + instance + " mth: " + mth);
String res = (String)mth.invoke(instance, args);
Utils.sink(ac, res);
if (!(

View file

@ -98,7 +98,10 @@ public class MethodActivity extends Activity {
Button b6 = new Button(this);
b6.generateViewId();
linLayout.addView(b6);
if (!classLoaderName.equals("DelegateLastClassLoader") && hasParent) {
// if no parent or use DelegateLastClassLoader, the type of the Interface is incompatible
linLayout.addView(b6);
}
scrollView.addView(linLayout);
relLayout.addView(scrollView);