1911 Commits

Author SHA1 Message Date
Ben Gruver
c52c16b8e4 Bump the version to v2.5.1 2021-03-02 16:55:45 -08:00
Ben Gruver
5da8a04863 Update the gradle wrapper itself to 6.8.2 2021-03-02 16:55:02 -08:00
Connor Tumbleson
e4746fbd75 fix: Cast java.nio.ByteBuffer to support java6-8
- affected methods
 -- position
 -- limit
 -- flip
 -- clear
2021-03-02 16:42:36 -08:00
Ben Gruver
0e53c0fd0f Bump the version to 2.5.0 2021-03-01 17:13:38 -08:00
Ben Gruver
fb77140154 Allow duplicate paths in the smali sourcesJar task
This fixes a gradle deprecation warning
2021-03-01 17:13:38 -08:00
Ben Gruver
1d72698081 Update proguard version to 6.2.2, to support building with java 11 2021-03-01 17:13:38 -08:00
Ben Gruver
93e7043ac7 Set target/source java version to 1.8 2021-03-01 17:13:38 -08:00
Ben Gruver
fd25f51eec Replace some deprecated property usages in the gradle file 2021-03-01 17:13:38 -08:00
Ben Gruver
c03e4bf7f8 Switch from the maven plugin to the maven-publish plugin 2021-03-01 17:13:38 -08:00
Ben Gruver
53b52f023d Switch from "compile" to "implementation" in gradle dependencies
compile/testCompile has been deprecated for a long time, and will be
removed in the next major version of gradle.
2021-03-01 15:36:10 -08:00
Ben Gruver
ecd68918ac Update everything in baksmali to use the new BaksmaliWriter functionality 2021-03-01 13:09:57 -08:00
Ben Gruver
9ce00aae9c Switch out IndentingWriter for BaksmaliWriter throughout baksmali
This refactors everything using an IndentingWriter to use a BaksmaliWriter
instead, but the usages of ReferenceUtil and EncodedValue aren't refactored
yet.
2021-03-01 13:04:55 -08:00
Ben Gruver
6efebc1543 Add the numeric writing methods from IndentingWriter to BaksmaliWriter
Those were never really a good fit for IndentingWriter anyway, they had
nothing to do with that class's functionality.

They'll be removed from IndentingWriter once all the usages are switched.
2021-03-01 12:58:38 -08:00
Ben Gruver
b6a1ae3481 Add new BaksmaliWriter/BaksmaliFormatter classes
These are intended to be the centralized place for most individual items
to be formatted and converted to/written as text
2021-03-01 12:55:51 -08:00
Ben Gruver
c2ac11c693 Use DexFormatter everywhere in dexlib2
This replaces all uses of ReferenceUtil/EncodedValueUtils.writeEncodedValue.
2021-02-26 17:19:59 -08:00
Ben Gruver
e894435e9d Add new DexFormatter/DexFormattedWriter class
This will be a more unified way to get/write out human-readable strings for
individual "things" from a dex file. The goal is to replace things like
ReferenceUtil, EncodedValueUtils, etc.
2021-02-26 17:19:59 -08:00
Ben Gruver
812bf35149 Add support for the new test-api hidden api restriction in Android 11 2021-02-17 16:17:38 -08:00
Ben Gruver
66802eb926 Update gradle to 6.8.2 2021-02-16 16:52:15 -08:00
Ben Gruver
1e655c2e54 Handle unicode filename collisions on mac
Some unicode characters are considered equivalent for filename purposes on mac.
This adds logic to treat these collisions the same way as case sensitivy
collisions are currently handled -- by adding a numeric suffix to the
file/directory anytime there is a collision.

See pull request #789 for more information.
2021-02-16 16:52:15 -08:00
Régis Décamps
c1534fc96d Cast long yychar to int.
Starting from JFlex 1.8.0, `yychar` is a long.

However, it is used to build an antlr `CommonToken` which takes an int.
Hence, explicit casting is needed.

I propose to cast the `yychar` with `java.lang.Math.toIntExact()` which throw an ArithmeticException in case of overflow.
This is acceptable because the previous code would have returned an overflowed (negative) position.

See https://github.com/jflex-de/jflex/pull/605 for details.
2020-03-30 11:24:38 -07:00
Ben Gruver
b761c5f089 Remove smalidea from the smali repository
It has been split out into a separate smalidea repository
2020-02-23 16:44:37 -08:00
Ben Gruver
5339a81f0f Bump the version to 2.4.0 2020-02-05 12:09:45 -08:00
Ben Gruver
71a79c8ac1 Add the new hidden api restriction tokens to the lexer token test 2020-02-04 21:40:56 -08:00
Ben Gruver
15a98cbb4b Add the new HIDDENAPI_RESTRICTION as a possible SIMPLE_NAME 2020-02-04 21:40:56 -08:00
Ben Gruver
c1f2da0e0b Improve the performance of the TypeRewriter.rewrite method 2020-02-03 00:09:21 -08:00
Ben Gruver
409cf27ba9 Make the new TypeRewriter.rewriteUnwrappedType protected
This method shouldn't be called from outside the class.
2020-02-02 20:52:57 -08:00
Ben Gruver
12b95235e3 Add a dex file rewriter to the rewriters module
Previously, if you needed to provide a custom dex file rewriter, you
would have to override the DexRewriter class. This provides a more
consistent interface, allowing the dex file rewriter to be specified in
the module.
2020-02-02 20:47:17 -08:00
Ben Gruver
cb37770c1c Make RewrittenArrayEncodedValue delegate rewriting sub-values to the module 2020-02-02 20:37:00 -08:00
Ben Gruver
78e92b0524 Add support for automatically rewriting array types in the rewriter
This adds a new rewriteUnwrappedType to the TypeRewriter class, which
gets called with the unwrapped type for array types, with the potentially
modified return value automatically being re-array-ified.
2020-02-02 20:34:29 -08:00
Ben Gruver
5a900e22e0 Use reference type from wrapped instruction in BaseRewrittenReferenceInstruction
Otherwise, the reference won't be rewritten correctly if the overriding
class overrides getReferenceType to return a different type.
2020-02-02 20:06:55 -08:00
Ben Gruver
49f7e26507 Set the hiddenApiRestrictionOffset in the new DexBackedDexFile constructor
This fixes the build. That's what I get for rebasing changes and not
testing.
2020-02-02 19:45:08 -08:00
Ben Gruver
8eb2595f87 Set the oat version based on the api level in AnalysisArguments
This ensures the oat version is set to NOT_ART for api 19 and lower, and
fixes deodexing for those api levels.
2020-02-02 19:26:14 -08:00
Ben Gruver
210e36dc19 Update VersionMap for Android 10 2020-02-02 18:38:24 -08:00
Ben Gruver
c3bbc771f5 Add support for hidden api restrictions to smali and baksmali
The hidden api restrictions are exposed in the smali language as
additional access flags for fields and methods
2020-02-02 16:32:35 -08:00
Ben Gruver
721fffc60e Add support to dexlib2 for writing hidden api restrictions 2020-02-02 16:32:35 -08:00
Ben Gruver
36c94ad653 Add support for reading the new hidden api restrictions in dexlib2 2020-02-02 16:32:35 -08:00
Ben Gruver
1590b4a05e Use HeaderItem.ITEM_SIZE in the new DexBackedDexFile constructor 2020-01-22 16:50:28 -08:00
Huaxin Li
b7a1052c66 Add support for constructing a DexBackedDexFile from a DexBuffer 2020-01-22 16:50:20 -08:00
Ben Gruver
bf65e575a0 Bump the version to 2.3.4 2019-10-02 16:37:23 -07:00
Ben Gruver
b3b8778ef8 Add support for Oat versions up to 173
The only relevant differences are some added/removed fields in the
OatHeader that affect the offsets of some fields we use.
2019-10-02 16:36:26 -07:00
Ben Gruver
539353a85c Use the correct path separator character when looking for classpath entries 2019-10-02 16:34:04 -07:00
Ben Gruver
7f5e1cc633 Bump the version to 2.3.3 2019-09-19 15:13:35 -07:00
Ben Gruver
ae2efe146b Fix lexing regression in certain types of method parameter lists
It was mis-lexing the case when a class descriptor is immediately
followed by a primitive type. The primitive type was being lexed as
PARAM_LIST_OR_ID_PRIMITIVE_TYPE instead of PRIMITIVE_TYPE.

The root cause was due to an incorrect state change. Since the
CLASS_DESCRIPTOR state can be started from within the PARAM_LIST state,
but when the CLASS_DESCRIPTOR state ends it just went back to YYINITIAL,
instead of going back to PARAM_LIST.

This adds a state stack to track these state changes
2019-09-19 15:11:55 -07:00
Ben Gruver
2598dff4b1 Bump the version to v2.3.2 2019-09-17 13:42:15 -07:00
Ben Gruver
b0ebe0b662 Add a lexer test for api 29
This tests that spaces are not supported in simple names and class
descriptors prior to api 30
2019-09-17 13:31:39 -07:00
Ben Gruver
0e5421cacb Fix how quoted simple names are handled in class descriptors
This unifies the handling of simple names between class descriptors and
member names, and ensures that spaces are only allowed for the appropriate
api levels in both cases
2019-09-17 13:31:27 -07:00
Ben Gruver
d762deacc9 Add a hidden command for printing out the lexical tokens of a smali file
This is useful for creating/updating the .tokens file for the lexer tests.
2019-09-17 13:31:22 -07:00
Ulya Trafimovich
209ba3b0a6 Disallow spaces in Simple name prior to the future API level 30. 2019-09-17 13:31:12 -07:00
Ulya Trafimovich
586ec594e2 Allow space characters in SimpleName.
DEX format allows Unicode space characters in SimpleName since version 040.
Allowed space characters include everything in Unicode category 'Zs':

  0x20, 0xa0, 0x1680, 0x2000..0x200a, 0x202f, 0x205f, 0x3000

Smali now supports symtax `method with spaces` (spaces are allowed in
backtick-quoted names).
2019-09-17 13:31:03 -07:00
Ben Gruver
751fe1ce61 Fix Preconditions.checkArrayPayloadElements
The previous implementation did not correctly handle negative numbers.
2019-09-12 11:30:27 -07:00