The previous FillArrayDataInstruction which converts DEX instructions to Jimpl instructions had two major problems:
The array type detection was only recognizing new-array instructions, not array that are created as a return value of a function
For detecting the array type it used a simple algorithm that inspected the DEX instructions before the fill-array-data instruction, not considering (conditional) branches of the control flow. This caused two problems:
If the array type could not be detected a warning was logged and the fill-array-data instruction completely ignored
If multiple array were defined in a method with non-linear control flow the wrong array-new instruction could be assigned to the fill-array-data instruction causing various problems in the command itself or in a later phase.
The FillArrayDataInstruction implementation provided by this PR splits processing of fill-array-data instructions into two phases:
Command transforming to Jimple instructions, as the array type is not known the elements are stored as UntypedConstant
In the second phase the new DexFillArrayDataTransformer checks AssignStatements that assign an UntypedConstant to an array element. It recovers the array data types and applies it to each value.
Note: The time to execute DexFillArrayDataTransformer.v().transform(jBody); was chosen as it is the latest possible point in time to execute it. The next transformer TypeAssigner.v().transform(jBody); can not handle UntypedConstant and thus throws an exception if it encounters one.
In a test the new implementation was used to process ~350 recent Android apps.
The previous
FillArrayDataInstruction
which converts DEX instructions to Jimpl instructions had two major problems:The
FillArrayDataInstruction
implementation provided by this PR splits processing of fill-array-data instructions into two phases:UntypedConstant
DexFillArrayDataTransformer
checks AssignStatements that assign anUntypedConstant
to an array element. It recovers the array data types and applies it to each value.Note: The time to execute
DexFillArrayDataTransformer.v().transform(jBody);
was chosen as it is the latest possible point in time to execute it. The next transformerTypeAssigner.v().transform(jBody);
can not handleUntypedConstant
and thus throws an exception if it encounters one.In a test the new implementation was used to process ~350 recent Android apps.