anestisb / vdexExtractor

Tool to decompile & extract Android Dex bytecode from Vdex files
Apache License 2.0
1k stars 215 forks source link

Compact Dex on Windows #38

Open breakersvd opened 5 years ago

breakersvd commented 5 years ago

@anestisb Hi Dev,

As you now compiling AOSP in windows is not available so we can not compile the compact dex converter for android Pie for windows.

could you add support to compiling it on windows or create a project on Github like vdexExtractor so we can compile it on Cygwin too as i do with vdexExtractor ?

anestisb commented 5 years ago

The Cdex converter tool is utilizing the upstream AOSP libdexlayout to create the Dex IR and export back to a standard Dex file. Since AOSP doesn't support Windows builds, and libdexlayout cannot be build as a standalone lib it requires a heavy rewrite, which is not something trivial for an IR library. Unfortunately, no other OSS Dex IR libs exist to use instead.

I'll keep this one open as a potential future enhancement, although it's something that takes time, which I don't have available at the moment.

anestisb commented 5 years ago

Also check https://github.com/anestisb/vdexExtractor/issues/25#issuecomment-417369119 to understand why the de-odexing anchor is not a priority for me.

breakersvd commented 5 years ago

Ok thanks for answer.

I will clone the AOSP sources and try to cross compiling in linux to windows. I will tell you if that goes successfully.

linusyang commented 5 years ago

@anestisb @breakersvd Hi buddies, I have managed to run unmodified 32-bit Linux version of cdex converter on Windows. The key is to use the awesome flinux. Essentially, flinux is a dynamic Linux syscall converter like WSL, but it is a purely userland app and supports Windows 7. The limitation of flinux is that it only supports 32-bit ELF binaries.

I can confirm that flinux 0.21 can run a statically linked 32-bit compact_dex_converter flawlessly on 32-bit Windows 7 SP1. If flinux complains "executable not found", try to put everything in the same directory, cd to that directory and run again.

By the way, I think a 32-bit binary could also help solving @superr's problem in #29. I followed @Furniel's suggestions to remove some x86 flags.

I included flinux 0.21 and several prebuilt compact_dex_converter in my project: https://github.com/linusyang92/mipay-extract/tree/master/tools/cdex

The 32-bit Linux version compact_dex_converter_linux is built from AOSP android-9.0.0_r8 branch. Patches are from @anestisb's gist. I slightly changed the compact_dex_converters entry in Android.bp to generate the 32-bit binary only:

compile_multilib: "32",
multilib: {
    lib32: {
        suffix: "32",
    },
    lib64: {
        suffix: "64",
    },
},

This is just a workaround at the moment, not a proper solution. It would be better if someone could cross-compile the ART library in Cygwin/MinGW.

breakersvd commented 5 years ago

@linusyang Tested with android 9 for Pixel XL "services.cdex" and worked successfully, thanks a lot

mengyanshou commented 5 years ago

ruqo 6vee9sl2njcjb pa9 I have no idea about this,it doesn't contained any issues,I am chinese

linusyang commented 5 years ago

@Nightmare-MYS You need to put everything in the same directory. flinux has problems with path conversions. You may instead run the command like:

flinux compact_dex_converter_linux_32 AppIndexProvider_classes.cdex
mengyanshou commented 5 years ago

@linusyang This is a big headache, and I want to write it in batch

Later, I also found out his problem after this,