|
|
@ -64,24 +64,26 @@ void DexDump::dumpDex(JNIEnv *env, jlong cookie, jstring dir) { |
|
|
|
auto dirC = env->GetStringUTFChars(dir, 0); |
|
|
|
auto dirC = env->GetStringUTFChars(dir, 0); |
|
|
|
|
|
|
|
|
|
|
|
auto dexSizeOffset = ((unsigned long ) begin) + 0x20; |
|
|
|
auto dexSizeOffset = ((unsigned long ) begin) + 0x20; |
|
|
|
size_t size = *(size_t *) dexSizeOffset; |
|
|
|
int size = *(size_t *) dexSizeOffset; |
|
|
|
|
|
|
|
|
|
|
|
auto buffer = malloc(size); |
|
|
|
auto buffer = malloc(size); |
|
|
|
memcpy(buffer, reinterpret_cast<const void *>(begin), size); |
|
|
|
if (buffer) { |
|
|
|
// fix magic
|
|
|
|
memcpy(buffer, reinterpret_cast<const void *>(begin), size); |
|
|
|
memcpy(buffer, magic, sizeof(magic)); |
|
|
|
// fix magic
|
|
|
|
|
|
|
|
memcpy(buffer, magic, sizeof(magic)); |
|
|
|
|
|
|
|
|
|
|
|
char path[1024]; |
|
|
|
char path[1024]; |
|
|
|
sprintf(path, "%s/dex_%d.dex", dirC, size); |
|
|
|
sprintf(path, "%s/dex_%d.dex", dirC, size); |
|
|
|
auto fd = open(path, O_CREAT | O_WRONLY, 0600); |
|
|
|
auto fd = open(path, O_CREAT | O_WRONLY, 0600); |
|
|
|
ssize_t w = write(fd, buffer, size); |
|
|
|
ssize_t w = write(fd, buffer, size); |
|
|
|
fsync(fd); |
|
|
|
fsync(fd); |
|
|
|
if (w > 0) { |
|
|
|
if (w > 0) { |
|
|
|
ALOGD("dump dex ======> %s", path); |
|
|
|
ALOGD("dump dex ======> %s", path); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
remove(path); |
|
|
|
remove(path); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
close(fd); |
|
|
|
|
|
|
|
free(buffer); |
|
|
|
|
|
|
|
env->ReleaseStringUTFChars(dir, dirC); |
|
|
|
} |
|
|
|
} |
|
|
|
close(fd); |
|
|
|
|
|
|
|
free(buffer); |
|
|
|
|
|
|
|
env->ReleaseStringUTFChars(dir, dirC); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|