@futpib/parser 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/copilot-instructions.md +149 -0
- package/.github/workflows/copilot-setup-steps.yml +18 -0
- package/.github/workflows/main.yml +29 -8
- package/.yarn/releases/yarn-4.9.4.cjs +942 -0
- package/.yarnrc.yml +1 -1
- package/build/allSettledStream.js +1 -1
- package/build/allSettledStream.test.js +2 -2
- package/build/androidPackageParser.d.ts +1 -1
- package/build/androidPackageParser.js +5 -3
- package/build/androidPackageParser.test.js +7 -7
- package/build/androidPackageUnparser.d.ts +2 -2
- package/build/androidPackageUnparser.js +18 -14
- package/build/androidPackageUnparser.test.js +7 -7
- package/build/arbitrarilySlicedAsyncInterator.js +2 -1
- package/build/arbitraryDalvikBytecode.d.ts +4 -0
- package/build/arbitraryDalvikBytecode.js +640 -0
- package/build/arbitraryDalvikExecutable.d.ts +3 -0
- package/build/arbitraryDalvikExecutable.js +282 -0
- package/build/arbitraryDosDateTime.js +1 -0
- package/build/arbitraryZipStream.js +1 -1
- package/build/arrayParser.js +2 -2
- package/build/arrayUnparser.d.ts +1 -1
- package/build/backsmali.d.ts +3 -1
- package/build/backsmali.js +31 -3
- package/build/bash.d.ts +84 -0
- package/build/bash.js +1 -0
- package/build/bashParser.d.ts +6 -0
- package/build/bashParser.js +294 -0
- package/build/bashParser.test.d.ts +1 -0
- package/build/bashParser.test.js +181 -0
- package/build/customInvariant.d.ts +2 -1
- package/build/customInvariant.js +4 -6
- package/build/dalvikBytecodeParser/formatParsers.d.ts +76 -2
- package/build/dalvikBytecodeParser/formatParsers.js +146 -11
- package/build/dalvikBytecodeParser/formatSizes.d.ts +34 -0
- package/build/dalvikBytecodeParser/formatSizes.js +34 -0
- package/build/dalvikBytecodeParser/operationFormats.d.ts +225 -0
- package/build/dalvikBytecodeParser/operationFormats.js +225 -0
- package/build/dalvikBytecodeParser.d.ts +1105 -5
- package/build/dalvikBytecodeParser.js +658 -205
- package/build/dalvikBytecodeUnparser/formatUnparsers.d.ts +152 -0
- package/build/dalvikBytecodeUnparser/formatUnparsers.js +225 -0
- package/build/dalvikBytecodeUnparser.d.ts +3 -0
- package/build/dalvikBytecodeUnparser.js +642 -0
- package/build/dalvikBytecodeUnparser.test.d.ts +1 -0
- package/build/dalvikBytecodeUnparser.test.js +25 -0
- package/build/dalvikExecutable.d.ts +65 -8
- package/build/dalvikExecutable.js +36 -0
- package/build/dalvikExecutableParser/stringSyntaxParser.d.ts +1 -1
- package/build/dalvikExecutableParser/stringSyntaxParser.js +17 -17
- package/build/dalvikExecutableParser/typeParsers.d.ts +2 -1
- package/build/dalvikExecutableParser/typeParsers.js +16 -11
- package/build/dalvikExecutableParser/typedNumbers.d.ts +85 -69
- package/build/dalvikExecutableParser/typedNumbers.js +0 -1
- package/build/dalvikExecutableParser.d.ts +2 -2
- package/build/dalvikExecutableParser.js +655 -337
- package/build/dalvikExecutableParser.test.js +24 -22
- package/build/dalvikExecutableParserAgainstSmaliParser.test.js +223 -246
- package/build/dalvikExecutableUnparser/annotationUnparsers.d.ts +14 -0
- package/build/dalvikExecutableUnparser/annotationUnparsers.js +97 -0
- package/build/dalvikExecutableUnparser/poolBuilders.d.ts +49 -0
- package/build/dalvikExecutableUnparser/poolBuilders.js +140 -0
- package/build/dalvikExecutableUnparser/poolScanners.d.ts +4 -0
- package/build/dalvikExecutableUnparser/poolScanners.js +220 -0
- package/build/dalvikExecutableUnparser/sectionUnparsers.d.ts +25 -0
- package/build/dalvikExecutableUnparser/sectionUnparsers.js +581 -0
- package/build/dalvikExecutableUnparser/utils.d.ts +10 -0
- package/build/dalvikExecutableUnparser/utils.js +108 -0
- package/build/dalvikExecutableUnparser.d.ts +4 -0
- package/build/dalvikExecutableUnparser.js +406 -0
- package/build/dalvikExecutableUnparser.test.d.ts +1 -0
- package/build/dalvikExecutableUnparser.test.js +31 -0
- package/build/debugLogInputParser.js +1 -1
- package/build/disjunctionParser.d.ts +2 -2
- package/build/disjunctionParser.js +2 -2
- package/build/elementTerminatedArrayParser.d.ts +2 -2
- package/build/elementTerminatedArrayParser.js +1 -1
- package/build/elementTerminatedArrayParser.test.js +5 -5
- package/build/elementTerminatedSequenceArrayParser.d.ts +2 -2
- package/build/elementTerminatedSequenceArrayParser.js +1 -1
- package/build/elementTerminatedSequenceArrayParser.test.js +2 -2
- package/build/elementTerminatedSequenceParser.d.ts +2 -2
- package/build/elementTerminatedSequenceParser.js +1 -1
- package/build/elementTerminatedSequenceParser.test.js +2 -2
- package/build/endOfInputParser.d.ts +1 -1
- package/build/exactElementSwitchParser.d.ts +3 -0
- package/build/exactElementSwitchParser.js +22 -0
- package/build/fetchCid.js +2 -6
- package/build/fetchCid.test.d.ts +1 -0
- package/build/fetchCid.test.js +16 -0
- package/build/fixedLengthSequenceParser.test.js +2 -2
- package/build/hasExecutable.js +2 -2
- package/build/highResolutionTimer.js +1 -1
- package/build/index.d.ts +24 -2
- package/build/index.js +22 -1
- package/build/inputReader.d.ts +1 -1
- package/build/inputReader.test.js +33 -45
- package/build/javaKeyStoreParser.test.js +6 -6
- package/build/jsonParser.js +8 -8
- package/build/lazyMessageError.d.ts +48 -0
- package/build/lazyMessageError.js +53 -0
- package/build/lazyMessageError.test.d.ts +1 -0
- package/build/lazyMessageError.test.js +15 -0
- package/build/leb128Parser.d.ts +1 -1
- package/build/leb128Parser.js +10 -10
- package/build/leb128Parser.test.js +7 -7
- package/build/negativeLookaheadParser.js +2 -2
- package/build/negativeLookaheadParser.test.js +4 -4
- package/build/noStackCaptureOverheadError.d.ts +4 -0
- package/build/noStackCaptureOverheadError.js +9 -0
- package/build/noStackCaptureOverheadError.test.d.ts +1 -0
- package/build/noStackCaptureOverheadError.test.js +15 -0
- package/build/nonEmptyArrayParser.js +2 -2
- package/build/nonEmptyArrayParser.test.js +2 -1
- package/build/optionalParser.js +2 -2
- package/build/parser.d.ts +2 -1
- package/build/parser.js +23 -8
- package/build/parser.test.js +78 -29
- package/build/parserConsumedSequenceParser.d.ts +1 -1
- package/build/parserConsumedSequenceParser.js +2 -2
- package/build/parserContext.d.ts +8 -6
- package/build/parserContext.js +60 -33
- package/build/parserContext.test.js +7 -3
- package/build/parserError.d.ts +603 -44
- package/build/parserError.js +98 -53
- package/build/parserImplementationInvariant.d.ts +1 -1
- package/build/parserImplementationInvariant.js +2 -2
- package/build/parserInputCompanion.js +2 -2
- package/build/promiseCompose.js +1 -2
- package/build/regexpParser.d.ts +2 -0
- package/build/regexpParser.js +71 -0
- package/build/regexpParser.test.d.ts +1 -0
- package/build/regexpParser.test.js +83 -0
- package/build/regularExpression.d.ts +63 -0
- package/build/regularExpression.js +1 -0
- package/build/regularExpressionParser.d.ts +3 -0
- package/build/regularExpressionParser.js +580 -0
- package/build/regularExpressionParser.test.d.ts +1 -0
- package/build/regularExpressionParser.test.js +89 -0
- package/build/separatedArrayParser.js +2 -2
- package/build/separatedNonEmptyArrayParser.d.ts +2 -0
- package/build/separatedNonEmptyArrayParser.js +40 -0
- package/build/separatedNonEmptyArrayParser.test.d.ts +1 -0
- package/build/separatedNonEmptyArrayParser.test.js +66 -0
- package/build/sequenceBuffer.js +1 -1
- package/build/sequenceTerminatedSequenceParser.d.ts +2 -2
- package/build/sequenceTerminatedSequenceParser.js +3 -3
- package/build/sequenceTerminatedSequenceParser.test.js +1 -1
- package/build/sequenceUnparser.d.ts +1 -1
- package/build/skipToParser.d.ts +1 -1
- package/build/skipToParser.js +2 -2
- package/build/sliceBoundedParser.test.js +4 -9
- package/build/smali.d.ts +1 -1
- package/build/smali.js +6 -2
- package/build/smaliParser.d.ts +62 -6
- package/build/smaliParser.js +1721 -296
- package/build/smaliParser.test.js +338 -43
- package/build/stringFromAsyncIterable.d.ts +1 -0
- package/build/stringFromAsyncIterable.js +7 -0
- package/build/terminatedArrayParser.js +4 -4
- package/build/terminatedArrayParser.test.js +7 -7
- package/build/toAsyncIterator.js +4 -4
- package/build/unionParser.d.ts +1 -1
- package/build/unionParser.js +2 -2
- package/build/unionParser.test.js +3 -3
- package/build/unparser.d.ts +3 -3
- package/build/unparser.js +6 -4
- package/build/unparser.test.js +7 -19
- package/build/unparserContext.d.ts +2 -2
- package/build/unparserContext.js +2 -3
- package/build/unparserError.d.ts +2 -1
- package/build/unparserError.js +2 -1
- package/build/unparserImplementationInvariant.d.ts +1 -1
- package/build/unparserOutputCompanion.d.ts +1 -1
- package/build/unparserOutputCompanion.js +1 -1
- package/build/zipParser.js +1 -1
- package/build/zipUnparser.d.ts +3 -3
- package/build/zipUnparser.js +9 -19
- package/build/zipUnparser.test.js +1 -1
- package/package.json +20 -26
- package/src/allSettledStream.test.ts +2 -2
- package/src/allSettledStream.ts +3 -3
- package/src/androidPackageParser.test.ts +17 -19
- package/src/androidPackageParser.ts +129 -171
- package/src/androidPackageUnparser.test.ts +19 -21
- package/src/androidPackageUnparser.ts +23 -17
- package/src/arbitrarilySlicedAsyncInterable.ts +1 -1
- package/src/arbitrarilySlicedAsyncInterator.ts +4 -4
- package/src/arbitraryDalvikBytecode.ts +992 -0
- package/src/arbitraryDalvikExecutable.ts +434 -0
- package/src/arbitraryDosDateTime.ts +1 -0
- package/src/arbitraryZipStream.ts +1 -1
- package/src/arrayParser.ts +2 -2
- package/src/arrayUnparser.ts +2 -2
- package/src/backsmali.ts +48 -4
- package/src/bash.ts +120 -0
- package/src/bashParser.test.ts +332 -0
- package/src/bashParser.ts +461 -0
- package/src/bsonParser.test.ts +12 -14
- package/src/customInvariant.ts +8 -12
- package/src/dalvikBytecodeParser/formatParsers.ts +376 -17
- package/src/dalvikBytecodeParser/formatSizes.ts +35 -0
- package/src/dalvikBytecodeParser/operationFormats.ts +226 -0
- package/src/dalvikBytecodeParser.ts +1042 -243
- package/src/dalvikBytecodeUnparser/formatUnparsers.ts +442 -0
- package/src/dalvikBytecodeUnparser.test.ts +44 -0
- package/src/dalvikBytecodeUnparser.ts +758 -0
- package/src/dalvikExecutable.ts +110 -48
- package/src/dalvikExecutableParser/stringSyntaxParser.ts +33 -33
- package/src/dalvikExecutableParser/typeParsers.ts +23 -14
- package/src/dalvikExecutableParser/typedNumbers.ts +19 -19
- package/src/dalvikExecutableParser.test.ts +60 -60
- package/src/dalvikExecutableParser.test.ts.md +6 -6
- package/src/dalvikExecutableParser.test.ts.snap +0 -0
- package/src/dalvikExecutableParser.ts +911 -434
- package/src/dalvikExecutableParserAgainstSmaliParser.test.ts +256 -239
- package/src/dalvikExecutableUnparser/annotationUnparsers.ts +135 -0
- package/src/dalvikExecutableUnparser/poolBuilders.ts +189 -0
- package/src/dalvikExecutableUnparser/poolScanners.ts +297 -0
- package/src/dalvikExecutableUnparser/sectionUnparsers.ts +683 -0
- package/src/dalvikExecutableUnparser/utils.ts +149 -0
- package/src/dalvikExecutableUnparser.test.ts +57 -0
- package/src/dalvikExecutableUnparser.ts +581 -0
- package/src/debugLogInputParser.ts +1 -1
- package/src/disjunctionParser.ts +5 -5
- package/src/elementTerminatedArrayParser.test.ts +8 -8
- package/src/elementTerminatedArrayParser.ts +2 -2
- package/src/elementTerminatedSequenceArrayParser.test.ts +4 -6
- package/src/elementTerminatedSequenceArrayParser.ts +2 -2
- package/src/elementTerminatedSequenceParser.test.ts +4 -6
- package/src/elementTerminatedSequenceParser.ts +2 -2
- package/src/endOfInputParser.ts +1 -1
- package/src/exactElementSwitchParser.ts +41 -0
- package/src/fetchCid.test.ts +20 -0
- package/src/fetchCid.ts +3 -7
- package/src/fixedLengthSequenceParser.test.ts +10 -12
- package/src/hasExecutable.ts +2 -2
- package/src/highResolutionTimer.ts +1 -1
- package/src/index.ts +113 -2
- package/src/inputReader.test.ts +39 -52
- package/src/inputReader.ts +2 -4
- package/src/inputReaderState.ts +1 -1
- package/src/inspect.ts +1 -1
- package/src/javaKeyStoreParser.test.ts +12 -14
- package/src/javaKeyStoreParser.ts +2 -6
- package/src/jsonParser.test.ts +2 -4
- package/src/jsonParser.ts +34 -38
- package/src/lazyMessageError.test.ts +21 -0
- package/src/lazyMessageError.ts +88 -0
- package/src/leb128Parser.test.ts +25 -23
- package/src/leb128Parser.ts +19 -19
- package/src/negativeLookaheadParser.test.ts +7 -11
- package/src/negativeLookaheadParser.ts +2 -2
- package/src/noStackCaptureOverheadError.test.ts +17 -0
- package/src/noStackCaptureOverheadError.ts +12 -0
- package/src/nonEmptyArrayParser.test.ts +3 -2
- package/src/nonEmptyArrayParser.ts +2 -2
- package/src/optionalParser.ts +2 -2
- package/src/parser.test.ts +96 -43
- package/src/parser.test.ts.md +13 -6
- package/src/parser.test.ts.snap +0 -0
- package/src/parser.ts +35 -12
- package/src/parserAccessorParser.ts +1 -1
- package/src/parserConsumedSequenceParser.ts +3 -3
- package/src/parserContext.test.ts +7 -3
- package/src/parserContext.ts +82 -48
- package/src/parserError.ts +143 -63
- package/src/parserImplementationInvariant.ts +3 -3
- package/src/parserInputCompanion.ts +2 -2
- package/src/promiseCompose.ts +2 -2
- package/src/regexpParser.test.ts +186 -0
- package/src/regexpParser.ts +94 -0
- package/src/regularExpression.ts +24 -0
- package/src/regularExpressionParser.test.ts +102 -0
- package/src/regularExpressionParser.ts +921 -0
- package/src/separatedArrayParser.ts +3 -3
- package/src/separatedNonEmptyArrayParser.test.ts +117 -0
- package/src/separatedNonEmptyArrayParser.ts +61 -0
- package/src/sequenceBuffer.test.ts +9 -9
- package/src/sequenceBuffer.ts +4 -4
- package/src/sequenceTerminatedSequenceParser.test.ts +3 -5
- package/src/sequenceTerminatedSequenceParser.ts +4 -4
- package/src/sequenceUnparser.ts +2 -2
- package/src/skipToParser.ts +2 -2
- package/src/sliceBoundedParser.test.ts +4 -12
- package/src/sliceBoundedParser.ts +2 -2
- package/src/smali.ts +8 -3
- package/src/smaliParser.test.ts +377 -66
- package/src/smaliParser.test.ts.md +1635 -48
- package/src/smaliParser.test.ts.snap +0 -0
- package/src/smaliParser.ts +2751 -569
- package/src/stringFromAsyncIterable.ts +9 -0
- package/src/terminatedArrayParser.test.ts +11 -11
- package/src/terminatedArrayParser.ts +5 -7
- package/src/toAsyncIterator.ts +8 -8
- package/src/uint8Array.ts +2 -3
- package/src/unionParser.test.ts +22 -23
- package/src/unionParser.ts +6 -8
- package/src/unparser.test.ts +18 -34
- package/src/unparser.ts +13 -9
- package/src/unparserContext.ts +9 -13
- package/src/unparserError.ts +2 -1
- package/src/unparserImplementationInvariant.ts +1 -1
- package/src/unparserOutputCompanion.ts +1 -1
- package/src/zip.ts +2 -6
- package/src/zipParser.ts +10 -18
- package/src/zipUnparser.test.ts +1 -1
- package/src/zipUnparser.ts +52 -64
- package/tsconfig.json +7 -1
- package/xo.config.ts +15 -0
- package/.yarn/releases/yarn-4.5.3.cjs +0 -934
|
@@ -3,13 +3,9 @@ import { runParser } from './parser.js';
|
|
|
3
3
|
import { uint8ArrayParserInputCompanion } from './parserInputCompanion.js';
|
|
4
4
|
import { dalvikExecutableParser, dalvikExecutableWithRawInstructionsParser } from './dalvikExecutableParser.js';
|
|
5
5
|
import { fetchCid } from './fetchCid.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
['bafybeibbupm7uzhuq4pa674rb2amxsenbdaoijigmaf4onaodaql4mh7yy', false],
|
|
10
|
-
['bafybeicb3qajmwy6li7hche2nkucvytaxcyxhwhphmi73tgydjzmyoqoda', false],
|
|
11
|
-
]) {
|
|
12
|
-
test.serial('dex (with instructions as bytes) ' + dexCid, async (t) => {
|
|
6
|
+
const dexWithRawInstructionsMacro = test.macro({
|
|
7
|
+
title: (providedTitle, dexCid) => providedTitle ?? `dex (with instructions as bytes) ${dexCid}`,
|
|
8
|
+
async exec(t, dexCid, shouldSnapshot) {
|
|
13
9
|
const dexStream = await fetchCid(dexCid);
|
|
14
10
|
const actual = await runParser(dalvikExecutableWithRawInstructionsParser, dexStream, uint8ArrayParserInputCompanion, {
|
|
15
11
|
errorJoinMode: 'all',
|
|
@@ -18,11 +14,15 @@ for (const [dexCid, shouldSnapshot] of [
|
|
|
18
14
|
t.snapshot(actual);
|
|
19
15
|
}
|
|
20
16
|
else {
|
|
21
|
-
//
|
|
17
|
+
// Console.dir(actual, { depth: null });
|
|
22
18
|
t.pass();
|
|
23
19
|
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
test.serial(dexWithRawInstructionsMacro, 'bafkreibb4gsprc3fvmnyqx6obswvm7e7wngnfj64gz65ey72r7xgyzymt4', true);
|
|
23
|
+
test.serial(dexWithRawInstructionsMacro, 'bafybeiebe27ylo53trgitu6fqfbmba43c4ivxj3nt4kumsilkucpbdxtqq', false);
|
|
24
|
+
test.serial(dexWithRawInstructionsMacro, 'bafybeibbupm7uzhuq4pa674rb2amxsenbdaoijigmaf4onaodaql4mh7yy', false);
|
|
25
|
+
test.serial(dexWithRawInstructionsMacro, 'bafybeicb3qajmwy6li7hche2nkucvytaxcyxhwhphmi73tgydjzmyoqoda', false);
|
|
26
26
|
function objectWalk(object, f, initialPath = []) {
|
|
27
27
|
f(initialPath, object);
|
|
28
28
|
if (!object
|
|
@@ -40,31 +40,33 @@ function objectWalk(object, f, initialPath = []) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// [ 'bafybeibbupm7uzhuq4pa674rb2amxsenbdaoijigmaf4onaodaql4mh7yy', false ],
|
|
47
|
-
// [ 'bafybeicb3qajmwy6li7hche2nkucvytaxcyxhwhphmi73tgydjzmyoqoda', false ],
|
|
48
|
-
]) {
|
|
49
|
-
test.serial('dex (with parsed instructions) ' + dexCid, async (t) => {
|
|
43
|
+
const dexWithParsedInstructionsMacro = test.macro({
|
|
44
|
+
title: (providedTitle, dexCid) => providedTitle ?? `dex (with parsed instructions) ${dexCid}`,
|
|
45
|
+
async exec(t, dexCid, shouldSnapshot) {
|
|
50
46
|
const dexStream = await fetchCid(dexCid);
|
|
47
|
+
debugger;
|
|
51
48
|
const actual = await runParser(dalvikExecutableParser, dexStream, uint8ArrayParserInputCompanion, {
|
|
52
49
|
errorJoinMode: 'all',
|
|
53
50
|
});
|
|
54
|
-
|
|
51
|
+
debugger;
|
|
52
|
+
objectWalk(actual, path => {
|
|
55
53
|
const key = path.at(-1);
|
|
56
54
|
if (typeof key !== 'string') {
|
|
57
55
|
return;
|
|
58
56
|
}
|
|
59
|
-
t.false(key.endsWith('Offset'), 'All offsets should be resolved: ' + path.join('.'));
|
|
57
|
+
t.false(key.endsWith('Offset') && key !== 'branchOffset', 'All offsets should be resolved: ' + path.join('.'));
|
|
60
58
|
t.false(key.endsWith('Index'), 'All indexes should be resolved: ' + path.join('.'));
|
|
61
59
|
});
|
|
62
60
|
if (shouldSnapshot) {
|
|
63
61
|
t.snapshot(actual);
|
|
64
62
|
}
|
|
65
63
|
else {
|
|
66
|
-
//
|
|
64
|
+
// Console.dir(actual, { depth: null });
|
|
67
65
|
t.pass();
|
|
68
66
|
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
test.serial.only(dexWithParsedInstructionsMacro, 'bafkreibb4gsprc3fvmnyqx6obswvm7e7wngnfj64gz65ey72r7xgyzymt4', true);
|
|
70
|
+
test.serial.skip(dexWithParsedInstructionsMacro, 'bafybeiebe27ylo53trgitu6fqfbmba43c4ivxj3nt4kumsilkucpbdxtqq', false);
|
|
71
|
+
test.serial.skip(dexWithParsedInstructionsMacro, 'bafybeibbupm7uzhuq4pa674rb2amxsenbdaoijigmaf4onaodaql4mh7yy', false);
|
|
72
|
+
test.serial.skip(dexWithParsedInstructionsMacro, 'bafybeicb3qajmwy6li7hche2nkucvytaxcyxhwhphmi73tgydjzmyoqoda', false);
|
|
@@ -4,7 +4,7 @@ import { stringParserInputCompanion, uint8ArrayParserInputCompanion } from './pa
|
|
|
4
4
|
import { dalvikExecutableParser } from './dalvikExecutableParser.js';
|
|
5
5
|
import { fetchCid } from './fetchCid.js';
|
|
6
6
|
import { hasExecutable } from './hasExecutable.js';
|
|
7
|
-
import { baksmaliClass } from './backsmali.js';
|
|
7
|
+
import { backsmaliSmaliIsolateClass, baksmaliClass, baksmaliListClasses } from './backsmali.js';
|
|
8
8
|
import { smaliParser } from './smaliParser.js';
|
|
9
9
|
import { smaliClass } from './smali.js';
|
|
10
10
|
const hasBaksmaliPromise = hasExecutable('baksmali');
|
|
@@ -26,253 +26,235 @@ function objectWalk(object, f, initialPath = []) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
29
|
+
function normalizeSmaliFilePath(smaliFilePath) {
|
|
30
|
+
if (typeof smaliFilePath === 'string') {
|
|
31
|
+
return {
|
|
32
|
+
smaliFilePath,
|
|
33
|
+
isolate: false,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
smaliFilePath: smaliFilePath.smaliFilePath,
|
|
38
|
+
isolate: smaliFilePath.isolate ?? false,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function normalizeClassDefinition(classDefinition) {
|
|
42
|
+
objectWalk(classDefinition, (_path, value) => {
|
|
43
|
+
if (value
|
|
44
|
+
&& typeof value === 'object'
|
|
45
|
+
&& 'debugInfo' in value) {
|
|
46
|
+
value.debugInfo = undefined;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const parseDexAgainstSmaliMacro = test.macro({
|
|
51
|
+
title(providedTitle, dexCid, smaliFilePathInput) {
|
|
52
|
+
const { smaliFilePath, isolate } = normalizeSmaliFilePath(smaliFilePathInput);
|
|
53
|
+
return providedTitle ?? `parse(dex) against parse(smali(dex)) ${dexCid} ${smaliFilePath}${isolate ? ' isolated' : ''}`;
|
|
54
|
+
},
|
|
55
|
+
async exec(t, dexCid, smaliFilePathInput) {
|
|
56
|
+
const { smaliFilePath, isolate } = normalizeSmaliFilePath(smaliFilePathInput);
|
|
57
|
+
const hasBaksmali = await hasBaksmaliPromise;
|
|
58
|
+
if (!hasBaksmali) {
|
|
59
|
+
t.pass('skipping test because baksmali is not available');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const dexStream = await fetchCid(dexCid);
|
|
63
|
+
const smali_ = await baksmaliClass(dexStream, smaliFilePath);
|
|
64
|
+
const smali = (smali_
|
|
65
|
+
.replaceAll(/^\s+# getter for:.*$/gm, '')
|
|
66
|
+
.replaceAll(/^\s+# setter for:.*$/gm, '')
|
|
67
|
+
.replaceAll(/^\s+# invokes:.*$/gm, '')
|
|
68
|
+
.replaceAll(/\n{3,}/g, '\n\n'));
|
|
69
|
+
// Console.log(smali);
|
|
70
|
+
const classDefinitionFromSmali = await runParser(smaliParser, smali, stringParserInputCompanion, {
|
|
71
|
+
errorJoinMode: 'all',
|
|
72
|
+
});
|
|
73
|
+
let dexStream2 = await fetchCid(dexCid);
|
|
74
|
+
if (isolate) {
|
|
75
|
+
dexStream2 = await backsmaliSmaliIsolateClass(dexStream2, smaliFilePath);
|
|
76
|
+
}
|
|
77
|
+
const executableFromDex = await runParser(dalvikExecutableParser, dexStream2, uint8ArrayParserInputCompanion, {
|
|
78
|
+
errorJoinMode: 'all',
|
|
79
|
+
});
|
|
80
|
+
const classDefinitionFromDex = executableFromDex.classDefinitions.find(classDefinition => classDefinition.class === classDefinitionFromSmali.class);
|
|
81
|
+
// Normalize both DEX and Smali by removing debug info
|
|
82
|
+
normalizeClassDefinition(classDefinitionFromDex);
|
|
83
|
+
normalizeClassDefinition(classDefinitionFromSmali);
|
|
84
|
+
// Console.dir({
|
|
85
|
+
// classDefinitionFromSmali,
|
|
86
|
+
// classDefinitionFromDex,
|
|
87
|
+
// }, {
|
|
88
|
+
// depth: null,
|
|
89
|
+
// });
|
|
90
|
+
t.deepEqual(classDefinitionFromDex, classDefinitionFromSmali);
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
const parseAllClassesInDexAgainstSmaliMacro = test.macro({
|
|
94
|
+
title(providedTitle, dexCid, options) {
|
|
95
|
+
return providedTitle ?? `parse all classes from dex ${dexCid} against smali${options?.skipUntilClassPath ? ` (skip until ${options.skipUntilClassPath})` : ''}`;
|
|
96
|
+
},
|
|
97
|
+
async exec(t, dexCid, options) {
|
|
98
|
+
const hasBaksmali = await hasBaksmaliPromise;
|
|
99
|
+
if (!hasBaksmali) {
|
|
100
|
+
t.pass('skipping test because baksmali is not available');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const dexStream = await fetchCid(dexCid);
|
|
104
|
+
const classes = ((await baksmaliListClasses(dexStream))
|
|
105
|
+
.map(smaliFilePath => ({ smaliFilePath, sort: Math.random() }))
|
|
106
|
+
.sort((a, b) => a.sort - b.sort)
|
|
107
|
+
.map(({ smaliFilePath }) => smaliFilePath));
|
|
108
|
+
const failures = [];
|
|
109
|
+
let shouldProcess = options?.skipUntilClassPath === undefined;
|
|
110
|
+
let processedCount = 0;
|
|
111
|
+
for (const smaliFilePath of classes) {
|
|
112
|
+
if (options?.skipUntilClassPath && smaliFilePath === options.skipUntilClassPath) {
|
|
113
|
+
shouldProcess = true;
|
|
57
114
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
errorJoinMode: 'all',
|
|
115
|
+
if (!shouldProcess) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
processedCount++;
|
|
119
|
+
const result = await t.try(parseDexAgainstSmaliMacro, dexCid, {
|
|
120
|
+
smaliFilePath,
|
|
121
|
+
isolate: true,
|
|
66
122
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
123
|
+
if (result.passed) {
|
|
124
|
+
result.commit();
|
|
125
|
+
console.log(`ok ${processedCount}/${classes.length}`, smaliFilePath);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
function consoleLogFailure(failure) {
|
|
129
|
+
const [error] = failure.errors;
|
|
130
|
+
console.log(error.formattedDetails.at(0).formatted ?? error);
|
|
131
|
+
}
|
|
132
|
+
console.log(smaliFilePath);
|
|
133
|
+
consoleLogFailure(result);
|
|
134
|
+
failures.push(result);
|
|
135
|
+
if (failures.length >= (options?.maxFailures ?? 1)) {
|
|
136
|
+
for (const failure of failures) {
|
|
137
|
+
consoleLogFailure(failure);
|
|
80
138
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
139
|
+
for (const failure of failures) {
|
|
140
|
+
failure.commit();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
for (const failure of failures) {
|
|
145
|
+
failure.commit();
|
|
146
|
+
}
|
|
147
|
+
t.pass('completed all classes');
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
const testCasesByCid = {
|
|
151
|
+
bafybeicb3qajmwy6li7hche2nkucvytaxcyxhwhphmi73tgydjzmyoqoda: [
|
|
152
|
+
{ smaliFilePath: 'androidx/activity/ComponentActivity$1', isolate: true },
|
|
153
|
+
{ smaliFilePath: 'androidx/activity/R$id', isolate: true },
|
|
154
|
+
{ smaliFilePath: 'androidx/activity/ComponentActivity$NonConfigurationInstances', isolate: true },
|
|
155
|
+
{ smaliFilePath: 'androidx/appcompat/R$styleable', isolate: true },
|
|
156
|
+
{ smaliFilePath: 'androidx/core/content/FileProvider', isolate: true },
|
|
157
|
+
{ smaliFilePath: 'androidx/core/view/KeyEventDispatcher', isolate: true },
|
|
158
|
+
{ smaliFilePath: 'com/google/android/exoplayer2/audio/Sonic', isolate: true },
|
|
159
|
+
{ smaliFilePath: 'com/google/android/exoplayer2/ext/opus/OpusDecoder', isolate: true },
|
|
160
|
+
{ smaliFilePath: 'com/google/android/exoplayer2/extractor/ts/H262Reader', isolate: true },
|
|
161
|
+
{ smaliFilePath: 'com/google/android/gms/internal/common/zzg', isolate: true },
|
|
162
|
+
{ smaliFilePath: 'com/google/android/gms/internal/mlkit_vision_label/zzcm', isolate: true },
|
|
163
|
+
{ smaliFilePath: 'com/google/android/play/core/integrity/model/StandardIntegrityErrorCode', isolate: true },
|
|
164
|
+
{ smaliFilePath: 'com/google/common/math/IntMath', isolate: true },
|
|
165
|
+
{ smaliFilePath: 'com/google/gson/internal/bind/CollectionTypeAdapterFactory', isolate: true },
|
|
166
|
+
],
|
|
167
|
+
bafkreibb4gsprc3fvmnyqx6obswvm7e7wngnfj64gz65ey72r7xgyzymt4: [
|
|
168
|
+
'pl/czak/minimal/MainActivity',
|
|
169
|
+
'pl/czak/minimal/R',
|
|
170
|
+
],
|
|
171
|
+
bafybeibbupm7uzhuq4pa674rb2amxsenbdaoijigmaf4onaodaql4mh7yy: [
|
|
172
|
+
{ smaliFilePath: 'com/journeyapps/barcodescanner/CaptureActivity', isolate: true },
|
|
173
|
+
{ smaliFilePath: '_COROUTINE/ArtificialStackFrames', isolate: true },
|
|
174
|
+
{ smaliFilePath: 'androidx/appcompat/widget/AppCompatTextHelper', isolate: true },
|
|
175
|
+
{ smaliFilePath: '_COROUTINE/CoroutineDebuggingKt', isolate: true },
|
|
176
|
+
{ smaliFilePath: 'androidx/compose/ui/text/android/style/LineHeightSpan', isolate: true },
|
|
177
|
+
{ smaliFilePath: 'androidx/compose/ui/layout/LayoutIdElement', isolate: true },
|
|
178
|
+
{ smaliFilePath: 'androidx/compose/ui/text/EmojiSupportMatch', isolate: true },
|
|
179
|
+
{ smaliFilePath: 'androidx/compose/ui/focus/FocusTransactionsKt', isolate: true },
|
|
180
|
+
{ smaliFilePath: 'androidx/compose/animation/core/SpringSimulationKt', isolate: true },
|
|
181
|
+
{ smaliFilePath: 'androidx/constraintlayout/core/widgets/ConstraintWidget', isolate: true },
|
|
182
|
+
{ smaliFilePath: 'ch/qos/logback/core/CoreConstants', isolate: true },
|
|
183
|
+
{ smaliFilePath: 'ch/qos/logback/classic/spi/ClassPackagingData', isolate: true },
|
|
184
|
+
{ smaliFilePath: 'kotlin/coroutines/jvm/internal/DebugMetadata', isolate: true },
|
|
185
|
+
],
|
|
186
|
+
bafybeiebe27ylo53trgitu6fqfbmba43c4ivxj3nt4kumsilkucpbdxtqq: [
|
|
187
|
+
{ smaliFilePath: 'androidx/viewpager2/adapter/FragmentStateAdapter$5', isolate: true },
|
|
188
|
+
{ smaliFilePath: 'androidx/lifecycle/b0', isolate: true },
|
|
189
|
+
{ smaliFilePath: 'androidx/activity/b', isolate: true },
|
|
190
|
+
{ smaliFilePath: 'androidx/activity/result/a$a', isolate: true },
|
|
191
|
+
{ smaliFilePath: 'androidx/annotation/Keep', isolate: true },
|
|
192
|
+
{ smaliFilePath: 'androidx/activity/result/e', isolate: true },
|
|
193
|
+
{ smaliFilePath: 'androidx/appcompat/widget/ActionBarContextView$a', isolate: true },
|
|
194
|
+
{ smaliFilePath: 'androidx/appcompat/widget/b0', isolate: true },
|
|
195
|
+
{ smaliFilePath: 'androidx/appcompat/widget/b1', isolate: true },
|
|
196
|
+
{ smaliFilePath: 'androidx/appcompat/widget/e', isolate: true },
|
|
197
|
+
{ smaliFilePath: 'androidx/appcompat/widget/m0', isolate: true },
|
|
198
|
+
{ smaliFilePath: 'androidx/appcompat/widget/r1', isolate: true },
|
|
199
|
+
{ smaliFilePath: 'androidx/recyclerview/widget/RecyclerView$a0', isolate: true },
|
|
200
|
+
{ smaliFilePath: 'androidx/constraintlayout/widget/ConstraintLayout$a', isolate: true },
|
|
201
|
+
{ smaliFilePath: 'l4/a', isolate: true },
|
|
202
|
+
{ smaliFilePath: 'n4/o', isolate: true },
|
|
203
|
+
{ smaliFilePath: 'o6/f', isolate: true },
|
|
204
|
+
{ smaliFilePath: 'a', isolate: true },
|
|
205
|
+
{ smaliFilePath: 'a/b', isolate: true },
|
|
206
|
+
{ smaliFilePath: 'f/b', isolate: true },
|
|
207
|
+
{ smaliFilePath: 'h1/j', isolate: true },
|
|
208
|
+
{ smaliFilePath: 'android/app/AppComponentFactory', isolate: true },
|
|
209
|
+
{ smaliFilePath: 'android/app/job/JobInfo$TriggerContentUri', isolate: true },
|
|
210
|
+
{ smaliFilePath: 'android/graphics/BlendModeColorFilter', isolate: true },
|
|
211
|
+
{ smaliFilePath: 'android/graphics/fonts/Font$Builder', isolate: true },
|
|
212
|
+
{ smaliFilePath: 'android/os/LocaleList', isolate: true },
|
|
213
|
+
{ smaliFilePath: 'a0/i', isolate: true },
|
|
214
|
+
{ smaliFilePath: 'a0/l', isolate: true },
|
|
215
|
+
{ smaliFilePath: 'a0/n', isolate: true },
|
|
216
|
+
{ smaliFilePath: 'a0/p', isolate: true },
|
|
217
|
+
{ smaliFilePath: 'a0/v', isolate: true },
|
|
218
|
+
{ smaliFilePath: 'a0/v$a', isolate: true },
|
|
219
|
+
{ smaliFilePath: 'a3/a', isolate: true },
|
|
220
|
+
{ smaliFilePath: 'a3/b', isolate: true },
|
|
221
|
+
{ smaliFilePath: 'a3/d', isolate: true },
|
|
222
|
+
{ smaliFilePath: 'a4/b', isolate: true },
|
|
223
|
+
{ smaliFilePath: 'b4/v', isolate: true },
|
|
224
|
+
{ smaliFilePath: 'd6/a', isolate: true },
|
|
225
|
+
{ smaliFilePath: 'q2/d$a', isolate: true },
|
|
226
|
+
{ smaliFilePath: 'y4/t1', isolate: true },
|
|
227
|
+
{ smaliFilePath: 'com/google/android/material/textfield/b', isolate: true },
|
|
228
|
+
{ smaliFilePath: 'm/g', isolate: true },
|
|
229
|
+
],
|
|
230
|
+
};
|
|
231
|
+
for (const [dexCid, smaliFilePaths] of Object.entries(testCasesByCid)) {
|
|
232
|
+
for (const smaliFilePath of smaliFilePaths) {
|
|
233
|
+
test.serial(parseDexAgainstSmaliMacro, dexCid, smaliFilePath);
|
|
84
234
|
}
|
|
85
235
|
}
|
|
236
|
+
for (const dexCid of Object.keys(testCasesByCid)) {
|
|
237
|
+
test.serial.skip(parseAllClassesInDexAgainstSmaliMacro, dexCid);
|
|
238
|
+
}
|
|
86
239
|
const smali = `
|
|
87
|
-
.class public
|
|
88
|
-
.super
|
|
89
|
-
.source "
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
# instance fields
|
|
93
|
-
.field private barcodeScannerView:Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;
|
|
94
|
-
|
|
95
|
-
.field private capture:Lcom/journeyapps/barcodescanner/CaptureManager;
|
|
96
|
-
|
|
240
|
+
.class public final La0/l;
|
|
241
|
+
.super Ljava/lang/Object;
|
|
242
|
+
.source "SourceFile"
|
|
97
243
|
|
|
98
244
|
# direct methods
|
|
99
|
-
.method public
|
|
100
|
-
.registers
|
|
101
|
-
|
|
102
|
-
.line 13
|
|
103
|
-
invoke-direct {p0}, Landroid/app/Activity;-><init>()V
|
|
245
|
+
.method public static final a(Lh1/p;ZJ)F
|
|
246
|
+
.registers 6
|
|
104
247
|
|
|
105
|
-
return
|
|
106
|
-
.end method
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
# virtual methods
|
|
110
|
-
.method protected initializeContent()Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;
|
|
111
|
-
.registers 2
|
|
112
|
-
|
|
113
|
-
sget v0, Lcom/google/zxing/client/android/R$layout;->zxing_capture:I
|
|
114
|
-
|
|
115
|
-
.line 34
|
|
116
|
-
invoke-virtual {p0, v0}, Landroid/app/Activity;->setContentView(I)V
|
|
117
|
-
|
|
118
|
-
sget v0, Lcom/google/zxing/client/android/R$id;->zxing_barcode_scanner:I
|
|
119
|
-
|
|
120
|
-
.line 35
|
|
121
|
-
invoke-virtual {p0, v0}, Landroid/app/Activity;->findViewById(I)Landroid/view/View;
|
|
122
|
-
|
|
123
|
-
move-result-object v0
|
|
124
|
-
|
|
125
|
-
check-cast v0, Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;
|
|
126
|
-
|
|
127
|
-
return-object v0
|
|
128
|
-
.end method
|
|
129
|
-
|
|
130
|
-
.method protected onCreate(Landroid/os/Bundle;)V
|
|
131
|
-
.registers 4
|
|
132
|
-
|
|
133
|
-
.line 19
|
|
134
|
-
invoke-super {p0, p1}, Landroid/app/Activity;->onCreate(Landroid/os/Bundle;)V
|
|
135
|
-
|
|
136
|
-
.line 21
|
|
137
|
-
invoke-virtual {p0}, Lcom/journeyapps/barcodescanner/CaptureActivity;->initializeContent()Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;
|
|
138
|
-
|
|
139
|
-
move-result-object v0
|
|
140
|
-
|
|
141
|
-
iput-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->barcodeScannerView:Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;
|
|
142
|
-
|
|
143
|
-
.line 23
|
|
144
|
-
new-instance v0, Lcom/journeyapps/barcodescanner/CaptureManager;
|
|
145
|
-
|
|
146
|
-
iget-object v1, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->barcodeScannerView:Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;
|
|
147
|
-
|
|
148
|
-
invoke-direct {v0, p0, v1}, Lcom/journeyapps/barcodescanner/CaptureManager;-><init>(Landroid/app/Activity;Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;)V
|
|
149
|
-
|
|
150
|
-
iput-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->capture:Lcom/journeyapps/barcodescanner/CaptureManager;
|
|
151
|
-
|
|
152
|
-
.line 24
|
|
153
|
-
invoke-virtual {p0}, Landroid/app/Activity;->getIntent()Landroid/content/Intent;
|
|
154
|
-
|
|
155
|
-
move-result-object v1
|
|
156
|
-
|
|
157
|
-
invoke-virtual {v0, v1, p1}, Lcom/journeyapps/barcodescanner/CaptureManager;->initializeFromIntent(Landroid/content/Intent;Landroid/os/Bundle;)V
|
|
158
|
-
|
|
159
|
-
iget-object p1, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->capture:Lcom/journeyapps/barcodescanner/CaptureManager;
|
|
160
|
-
|
|
161
|
-
.line 25
|
|
162
|
-
invoke-virtual {p1}, Lcom/journeyapps/barcodescanner/CaptureManager;->decode()V
|
|
163
|
-
|
|
164
|
-
return-void
|
|
165
|
-
.end method
|
|
166
|
-
|
|
167
|
-
.method protected onDestroy()V
|
|
168
|
-
.registers 2
|
|
169
|
-
|
|
170
|
-
.line 52
|
|
171
|
-
invoke-super {p0}, Landroid/app/Activity;->onDestroy()V
|
|
172
|
-
|
|
173
|
-
iget-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->capture:Lcom/journeyapps/barcodescanner/CaptureManager;
|
|
174
|
-
|
|
175
|
-
.line 53
|
|
176
|
-
invoke-virtual {v0}, Lcom/journeyapps/barcodescanner/CaptureManager;->onDestroy()V
|
|
177
|
-
|
|
178
|
-
return-void
|
|
179
|
-
.end method
|
|
180
|
-
|
|
181
|
-
.method public onKeyDown(ILandroid/view/KeyEvent;)Z
|
|
182
|
-
.registers 4
|
|
183
|
-
|
|
184
|
-
iget-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->barcodeScannerView:Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;
|
|
185
|
-
|
|
186
|
-
.line 69
|
|
187
|
-
invoke-virtual {v0, p1, p2}, Lcom/journeyapps/barcodescanner/DecoratedBarcodeView;->onKeyDown(ILandroid/view/KeyEvent;)Z
|
|
188
|
-
|
|
189
|
-
move-result v0
|
|
190
|
-
|
|
191
|
-
if-nez v0, :cond_11
|
|
192
|
-
|
|
193
|
-
invoke-super {p0, p1, p2}, Landroid/app/Activity;->onKeyDown(ILandroid/view/KeyEvent;)Z
|
|
194
|
-
|
|
195
|
-
move-result p1
|
|
196
|
-
|
|
197
|
-
if-eqz p1, :cond_f
|
|
198
|
-
|
|
199
|
-
goto :goto_11
|
|
200
|
-
|
|
201
|
-
:cond_f
|
|
202
|
-
const/4 p1, 0x0
|
|
203
|
-
|
|
204
|
-
goto :goto_12
|
|
205
|
-
|
|
206
|
-
:cond_11
|
|
207
|
-
:goto_11
|
|
208
|
-
const/4 p1, 0x1
|
|
209
|
-
|
|
210
|
-
:goto_12
|
|
211
|
-
return p1
|
|
212
|
-
.end method
|
|
213
|
-
|
|
214
|
-
.method protected onPause()V
|
|
215
|
-
.registers 2
|
|
216
|
-
|
|
217
|
-
.line 46
|
|
218
|
-
invoke-super {p0}, Landroid/app/Activity;->onPause()V
|
|
219
|
-
|
|
220
|
-
iget-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->capture:Lcom/journeyapps/barcodescanner/CaptureManager;
|
|
221
|
-
|
|
222
|
-
.line 47
|
|
223
|
-
invoke-virtual {v0}, Lcom/journeyapps/barcodescanner/CaptureManager;->onPause()V
|
|
224
|
-
|
|
225
|
-
return-void
|
|
226
|
-
.end method
|
|
227
|
-
|
|
228
|
-
.method public onRequestPermissionsResult(I[Ljava/lang/String;[I)V
|
|
229
|
-
.registers 5
|
|
230
|
-
|
|
231
|
-
iget-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->capture:Lcom/journeyapps/barcodescanner/CaptureManager;
|
|
232
|
-
|
|
233
|
-
.line 64
|
|
234
|
-
invoke-virtual {v0, p1, p2, p3}, Lcom/journeyapps/barcodescanner/CaptureManager;->onRequestPermissionsResult(I[Ljava/lang/String;[I)V
|
|
235
|
-
|
|
236
|
-
return-void
|
|
237
|
-
.end method
|
|
238
|
-
|
|
239
|
-
.method protected onResume()V
|
|
240
|
-
.registers 2
|
|
241
|
-
|
|
242
|
-
.line 40
|
|
243
|
-
invoke-super {p0}, Landroid/app/Activity;->onResume()V
|
|
244
|
-
|
|
245
|
-
iget-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->capture:Lcom/journeyapps/barcodescanner/CaptureManager;
|
|
246
|
-
|
|
247
|
-
.line 41
|
|
248
|
-
invoke-virtual {v0}, Lcom/journeyapps/barcodescanner/CaptureManager;->onResume()V
|
|
249
|
-
|
|
250
|
-
return-void
|
|
251
|
-
.end method
|
|
252
|
-
|
|
253
|
-
.method protected onSaveInstanceState(Landroid/os/Bundle;)V
|
|
254
|
-
.registers 3
|
|
255
|
-
|
|
256
|
-
.line 58
|
|
257
|
-
invoke-super {p0, p1}, Landroid/app/Activity;->onSaveInstanceState(Landroid/os/Bundle;)V
|
|
258
|
-
|
|
259
|
-
iget-object v0, p0, Lcom/journeyapps/barcodescanner/CaptureActivity;->capture:Lcom/journeyapps/barcodescanner/CaptureManager;
|
|
260
|
-
|
|
261
|
-
.line 59
|
|
262
|
-
invoke-virtual {v0, p1}, Lcom/journeyapps/barcodescanner/CaptureManager;->onSaveInstanceState(Landroid/os/Bundle;)V
|
|
263
|
-
|
|
264
|
-
return-void
|
|
248
|
+
return v0
|
|
265
249
|
.end method
|
|
266
250
|
`;
|
|
267
|
-
test.serial
|
|
251
|
+
test.serial('parse(dex(smali)) againts parse(smali)', async (t) => {
|
|
268
252
|
const hasSmali = await hasSmaliPromise;
|
|
269
253
|
if (!hasSmali) {
|
|
270
254
|
t.pass('skipping test because smali is not available');
|
|
271
255
|
return;
|
|
272
256
|
}
|
|
273
|
-
const dexBuffer = await smaliClass(
|
|
274
|
-
yield smali;
|
|
275
|
-
}());
|
|
257
|
+
const dexBuffer = await smaliClass(smali);
|
|
276
258
|
const classDefinitionFromSmali = await runParser(smaliParser, smali, stringParserInputCompanion, {
|
|
277
259
|
errorJoinMode: 'all',
|
|
278
260
|
});
|
|
@@ -280,19 +262,14 @@ test.serial.skip('parse(dex(smali)) againts parse(smali)', async (t) => {
|
|
|
280
262
|
errorJoinMode: 'all',
|
|
281
263
|
});
|
|
282
264
|
const classDefinitionFromDex = executableFromDex.classDefinitions.find(classDefinition => classDefinition.class === classDefinitionFromSmali.class);
|
|
283
|
-
//
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
&& typeof value === 'object'
|
|
293
|
-
&& 'debugInfo' in value) {
|
|
294
|
-
value.debugInfo = undefined;
|
|
295
|
-
}
|
|
296
|
-
});
|
|
265
|
+
// Normalize both DEX and Smali by removing debug info
|
|
266
|
+
normalizeClassDefinition(classDefinitionFromDex);
|
|
267
|
+
normalizeClassDefinition(classDefinitionFromSmali);
|
|
268
|
+
// Console.dir({
|
|
269
|
+
// classDefinitionFromDex,
|
|
270
|
+
// classDefinitionFromSmali,
|
|
271
|
+
// }, {
|
|
272
|
+
// depth: null,
|
|
273
|
+
// });
|
|
297
274
|
t.deepEqual(classDefinitionFromDex, classDefinitionFromSmali);
|
|
298
275
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Unparser } from '../unparser.js';
|
|
2
|
+
import { type DalvikExecutableAnnotation, type DalvikExecutableClassAnnotations, type DalvikExecutableEncodedValue, type DalvikExecutableField, type DalvikExecutableMethod } from '../dalvikExecutable.js';
|
|
3
|
+
import { WriteLater } from '../unparserContext.js';
|
|
4
|
+
export declare function createAnnotationUnparsers(getStringIndex: (str: string | undefined) => number, getTypeIndex: (typeDescriptor: string | undefined) => number, getFieldIndex: (field: DalvikExecutableField) => number, getMethodIndex: (method: DalvikExecutableMethod) => number, encodedValueUnparser: Unparser<DalvikExecutableEncodedValue, Uint8Array>): {
|
|
5
|
+
annotationItemUnparser: Unparser<DalvikExecutableAnnotation, Uint8Array<ArrayBufferLike>>;
|
|
6
|
+
annotationSetItemUnparser: (annotationItemOffsetWriteLaters: Array<WriteLater<Uint8Array, number>>) => Unparser<DalvikExecutableAnnotation[], Uint8Array>;
|
|
7
|
+
annotationSetRefListUnparser: (annotationSetOffsetWriteLaters: Array<WriteLater<Uint8Array, number> | null>) => Unparser<DalvikExecutableAnnotation[][], Uint8Array>;
|
|
8
|
+
annotationsDirectoryItemUnparser: (annotationOffsetWriteLaters: {
|
|
9
|
+
classAnnotationsOffsetWriteLater?: WriteLater<Uint8Array, number>;
|
|
10
|
+
fieldAnnotationsOffsetWriteLaters?: Array<WriteLater<Uint8Array, number> | null>;
|
|
11
|
+
methodAnnotationsOffsetWriteLaters?: Array<WriteLater<Uint8Array, number>>;
|
|
12
|
+
parameterAnnotationsOffsetWriteLaters?: Array<WriteLater<Uint8Array, number>>;
|
|
13
|
+
}) => Unparser<DalvikExecutableClassAnnotations, Uint8Array>;
|
|
14
|
+
};
|