skylot / jadx

Dex to Java decompiler
Apache License 2.0
40.86k stars 4.8k forks source link

Incompleted search results #426

Closed ghost closed 5 years ago

ghost commented 5 years ago

Search for 'SDK_INT' but not result found from SELinuxHelper.initForProcess XposedBridge.zip

jpstotz commented 5 years ago

This seems to be bug of Jadx caused by the else-if structure it is used in.

Currently for whatever reason the TextSearchIndex class ignores lines that start with a }: https://github.com/skylot/jadx/blob/c0b2230b0bfc8495028ae1404dc92db4991e2f03/jadx-gui/src/main/java/jadx/gui/utils/search/TextSearchIndex.java#L72

If I disable this check the number of search results for "SDK_INT" increases from 24 to 29. Also the find spot inside the SELinuxHelper class is now found, however the search index is pointing to the wrong line. Instead of pointing to line 73 in the source code it points to line 71:

    static void initForProcess(String packageName) {
        if (!sIsSELinuxEnabled) {
            sServiceAppDataFile = new DirectAccessService();
        } else if (packageName == null) { // search index points to this line
            sServiceAppDataFile = new ZygoteService();
        } else if (!packageName.equals("android") || VERSION.SDK_INT >= 26) {
            sServiceAppDataFile = new DirectAccessService();
        } else {
            sServiceAppDataFile = BinderService.getService(0);
        }
    }
skylot commented 5 years ago

Hm, looks like I was trying to skip lines not needed in the index: like "}" or "} else {". Code line can be replaced with

if (line.length() != 0 && (line.length() != 1 || line.charAt(0) != '}')) {

to skip at least single closing brackets. Also sadly, but StringRef does not support equals with string, so I can't do

if (line.length() != 0 && !line.equals("}")) {