Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix baksmali without API version and various optimizations #2604

Merged
merged 8 commits into from
Jul 3, 2021
Merged

Fix baksmali without API version and various optimizations #2604

merged 8 commits into from
Jul 3, 2021

Conversation

IgorEisberg
Copy link
Contributor

@IgorEisberg IgorEisberg commented Jul 3, 2021

  1. Organized a few "import" statements and renamed some of the variables/arguments for consistency across the code.
  2. setAnalysisMode was redesigned properly while ensuring the ResTable always has the up-to-date value of mAnalysisMode.
  3. Removed setTargetSdkVersion, as it was used before manifest was decoded, thus was doing basically nothing because targetSdkVersion was never available at that point. Even then, using targetSdkVersion for baksmali is incorrect, since dex version used when an APK/JAR was originally built is determined by minSdkVersion, else compatibility with defined minSdkVersion would not be possible in the first place.
  4. getResTable creates a new table if it doesn't already exist, thus should only be called if necessary (lazy initialization): either by ApkDecoder when decoding manifest and/or resources (and only when those are available), or explicitly by Test code. Otherwise, resource table is unnecessary. In the case of writeMetaFile and its putX methods: putX methods which depend on a ResTable are only called if mResTable is defined, thus the use of getResTable is redundant here.
  5. Unless the user forces an API level for decoding, let baksmali handle the proper opcodes to use automatically. When DexBackedDexFile gets opcodes==null, it calls getDefaultOpcodes(dexVersion) which returns the appropriate opcodes for the given dex version. No hints are required for baksmali, but of course still needed for smali.

@iBotPeaches iBotPeaches merged commit d1e4478 into iBotPeaches:master Jul 3, 2021
@iBotPeaches
Copy link
Owner

thanks!

iBotPeaches added a commit that referenced this pull request Jul 3, 2021
@iBotPeaches iBotPeaches added this to the v2.6.0 milestone Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants