Skip to content

Commit

Permalink
bugfix unidbg wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
jmp0 committed Sep 29, 2022
1 parent 73f1a2a commit db4d32c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
1 change: 0 additions & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ dependencies {
implementation "log4j:log4j:$log4j_version"
api "org.javassist:javassist:$javassist_version"
implementation 'io.github.classgraph:classgraph:4.8.146'
api 'com.github.zhkl0228:unidbg-parent:0.9.7'
api 'com.github.zhkl0228:unidbg-api:0.9.7'
api 'com.github.zhkl0228:unidbg-android:0.9.7'
implementation 'net.lingala.zip4j:zip4j:2.10.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ abstract class UnidbgInterceptor(private val soName:String): IInterceptor {


private fun callUnidbgJniMethod(clazz: DvmClass,methodName:String,signature:String,signatureInfo: ReflectUtilsBase.SignatureInfo,param: Array<out Any?>): IInterceptor.ImplStatus {
val params = UnidbgWrapperUtils.wrapperToUnidbgParams(vm,param)
val params = UnidbgWrapperUtils.wrapperToUnidbgParams(vm,param,signatureInfo)
val res:Any? = when(signatureInfo.returnType!!){
Int::class.java-> clazz.callStaticJniMethodInt(emulator,methodName+signature,*params)
Boolean::class.java-> clazz.callStaticJniMethodBoolean(emulator,methodName+signature,*params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ object UnidbgWrapperUtils {
val longObj = vaList.getLongArg(i)
retArr.add(longObj)
}
"byte"->{
val byteObj = vaList.getIntArg(i).toByte()
retArr.add(byteObj)
}
"char"->{
val charObj = vaList.getIntArg(i).toChar()
retArr.add(charObj)
}
"short"->{
val shortObj = vaList.getIntArg(i).toShort()
retArr.add(shortObj)
}
"boolean"->{
val booleanObj = vaList.getIntArg(i) == 1
retArr.add(booleanObj)
}
else -> {
val dvmObj = vaList.getObjectArg<DvmObject<*>>(i)
dvmObj.repair(androidEnvironment)
Expand Down Expand Up @@ -70,15 +86,18 @@ object UnidbgWrapperUtils {
return ArrayObject(*objectList.toTypedArray())
}
}
val clazzName = className?:obj.javaClass.name.replace(".","/")
val clazzName = className?:obj::class.java.name.replace(".","/")
return DvmObjectWrapper(vm.resolveClass(clazzName),obj)
}

fun wrapperToUnidbgParams(vm: VM,param: Array<out Any?>): Array<out Any> {
val retArr = ArrayList<Any>()
fun wrapperToUnidbgParams(vm: VM,param: Array<out Any?>,signatureInfo: ReflectUtilsBase.SignatureInfo): Array<out Any> {
val retArr = ArrayList<Any?>()
if (param.isEmpty()) return retArr.toArray()
param.forEach {
retArr.add(toUnidbgObject(vm,it))
for (i in param.indices){
when(signatureInfo.paramTypes[i].name){
"byte","short","int","long","char","float","double","boolean"-> retArr.add(param[i])
else -> retArr.add(toUnidbgObject(vm,param[i],signatureInfo.paramTypes[i].name))
}
}
return retArr.toArray()
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/jmp0/util/ZipUtility.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ object ZipUtility {
}
bos.close()
}
@SuppressWarnings("unused")

fun zip(sourceDirPath: String, zipFilePath: String) {
ZipFile(zipFilePath).addFolder(File(sourceDirPath))
// val p: Path = Files.createFile(Paths.get(zipFilePath))
Expand Down

0 comments on commit db4d32c

Please sign in to comment.