diff --git a/DALVIK_MISSING_PARSERS.md b/DALVIK_MISSING_PARSERS.md index 83a16fa..c973432 100644 --- a/DALVIK_MISSING_PARSERS.md +++ b/DALVIK_MISSING_PARSERS.md @@ -7,30 +7,10 @@ Reference: [Android Dalvik Bytecode Specification](https://source.android.com/do ## Implementation Status **Total formats:** 32 -**Implemented:** 23 -**Missing:** 9 +**Implemented:** 24 +**Missing:** 8 -## Missing Format Parsers Checklist - -### High Priority Formats - -- [x] **Format 11n** (const/4) - ✅ IMPLEMENTED - - **Description:** vA, #+B - Immediate constant with 4-bit register and 4-bit signed immediate value - - **Size:** 2 bytes (1 unit) - - **Syntax:** `AA|op BBBB` - - **Use case:** Small constant values (e.g., `const/4`) - -- [x] **Format 51l** (const-wide) - ✅ IMPLEMENTED - - **Description:** vAA, #+BBBBBBBBBBBBBBBB - 64-bit immediate constant - - **Size:** 10 bytes (5 units) - - **Syntax:** `AA|op BBBBlo BBBBhi` - - **Use case:** Wide (64-bit) constant values - -- [ ] **Format 31c** (const-string/jumbo) - - **Description:** vAA, thing@BBBBBBBB - Constant pool index with 8-bit register - - **Size:** 6 bytes (3 units) - - **Syntax:** `AA|op BBBBlo BBBBhi` - - **Use case:** Large constant pool references (> 65535 items) +## Missing Format Parsers ### Method Invocation Formats (Deprecated/Optimized) @@ -88,22 +68,17 @@ Reference: [Android Dalvik Bytecode Specification](https://source.android.com/do - **Syntax:** `AA|op BBBB CCCC HHHH` - **Use case:** Range version of polymorphic invocation -## Implementation Notes - -### Priority Recommendations +## Priority Recommendations -1. **Immediate Priority:** - - Format 31c - Needed for large DEX files with many string/type references - -2. **Medium Priority:** +1. **Medium Priority:** - Format 45cc and 4rcc - Required for Android 8.0+ features (method handles) - Format 20bc - Needed for complete verification error handling -3. **Low Priority (Deprecated):** +2. **Low Priority (Deprecated):** - Formats 35mi, 35ms, 3rmi, 3rms, 22cs - These are deprecated optimization formats - Only implement if parsing legacy/optimized DEX files is required -### Implementation Guidelines +## Implementation Guidelines For each format parser, the following should be implemented: @@ -115,20 +90,7 @@ For each format parser, the following should be implemented: ### Example Implementation Pattern -```typescript -type DalvikBytecodeFormat11n = { - value: number; - registers: number[]; -}; - -export const dalvikBytecodeFormat11nParser: Parser = promiseCompose( - nibblesParser, - ([value, register0]) => ({ - value: value << 28 >> 28, // Sign extend 4-bit value - registers: [register0], - }), -); -``` +See existing parsers in `src/dalvikBytecodeParser/formatParsers.ts` for reference. ## References @@ -136,45 +98,6 @@ export const dalvikBytecodeFormat11nParser: Parser = promiseCompose( + createTupleParser([ + createExactElementParser(0x1b), + createDalvikBytecodeFormat31cParser({ + isoIndex: isoIndexIntoStringIds, + }), + ]), + ([ _opcode, { index, registers } ]) => ({ + operation: 'const-string/jumbo', + stringIndex: index, + registers, + }), +); + +setParserName(dalvikBytecodeOperationConstStringJumboParser, 'dalvikBytecodeOperationConstStringJumboParser'); + type DalvikBytecodeOperationConstMethodHandle = { operation: 'const-method-handle'; methodIndex: IndexIntoMethodIds; @@ -2195,6 +2218,7 @@ const dalvikBytecodeOperationParser: Parser = { + index: Index; + registers: number[]; +}; + +export const createDalvikBytecodeFormat31cParser = ({ + isoIndex, +}: { + isoIndex: Iso; +}): Parser, Uint8Array> => promiseCompose( + createTupleParser([ + ubyteParser, + uintParser, + ]), + ([ + register0, + index, + ]) => ({ + index: isoIndex.wrap(index), + registers: [ + register0, + ], + }), +); + type DalvikBytecodeFormat31t = { branchOffset: number; registers: number[];