//------------------------------------------------ //--- 010 Editor v5.0.2 Binary Template // // File: AndroidManifest.bt // Authors: dongmu // Version: 1.1.3 // Purpose: Define a template for parsing // AndroidManifest.xml binary files. // Category: Operating System // File Mask: AndroidManifest.xml // ID Bytes: 03 00 // History: // 1.1.3 2024-03-06 ckcat: Separated type and headerSize. Added check to STRINGCHUNK. // 1.1.2 2022-12-18 hj: skip some useless bytes at end of STCHUNK. // 1.1.1 2019-09-16 lj94093: add a Read function for STRING_ITEM for better reading // 1.1 2016-02-11 SweetScape Software: Updated header for repository submission. // 1.0 dongmu: Initial release. //------------------------------------------------ // Define the structures used in a // AndroidManifest.xml binary file // Define Header typedef struct { ushort type; ushort headerSize ; uint filesize; } HEADER; // Define the string format typedef struct { ushort sfSize ; if (sfSize > 0) { struct { char c1; char c2; } ONECHAR[ sfSize ]; } ushort sfEnd; } STRING_ITEM; string ReadSTRING_ITEM( STRING_ITEM &string_item ) { local string result=""; local int i; for(i=0;i; uint scSize ; uint scStringCount; uint scStyleCount; uint flags; uint scStringPoolOffset; uint scStylePoolOffset; uint scStringOffsets[ scStringCount ] ; if (scStyleCount > 0) uint scStyleOffset[ scStylePoolOffset ]; // The Strings local int i; local uint addr; local ushort sfsize; local ushort sfend; for (i = 0; i < scStringCount; i++) { addr = 0x8+scStringPoolOffset + scStringOffsets[ i ]; if (addr < (0x8+scSize)) { sfsize = ReadShort(addr); sfend = ReadShort(addr + sfsize*2 +0x2); if (sfend != 0) break; FSeek(addr); STRING_ITEM strItem; } } } STRINGCHUNK; // Define the Resource chunk typedef struct { local int pos = FTell(); ushort type; ushort headerSize ; uint rcSize; uint rcItem[ rcSize/4 - 2 ]; } RESOURCEIDCHUNK; // Define the Start Namespace Chunk typedef struct { ushort type; ushort headerSize ; uint sncSize; uint sncLineNumber; uint sncComment; uint sncPrefix; uint sncUri; } SNCHUNK; // Define the End Namespace Chunk typedef struct { ushort type; ushort headerSize; uint encSize; uint encLineNumber; uint sncComment; uint encPrefix; uint encUri; } ENCHUNK; // Define the Attribute Chunk typedef struct { uint acNamespaceUri; uint acName; uint acValueStr; ushort resValueSize; uchar res0; uchar resDataType ; uint acData; } ATTRIBUTECHUNK; // Define the Start Tag Chunk typedef struct { local int pos = FTell(); ushort type; ushort headerSize; uint stcSize; uint stcLineNumber; uint stcComment; uint stcNamespaceUri; uint stcName; uint stcFlags; uint stcAttributeCount; uint stcClassAttribute; local int i; for (i = 0; i < stcAttributeCount; i++) { if (FTell() == pos + stcSize) { break; } ATTRIBUTECHUNK attributeChunk; } local int endPos = pos + stcSize; pos = FTell(); if (endPos > pos) { FSeek(endPos); } } STCHUNK; // Define the End Tag Chunk typedef struct { ushort type; ushort headerSize; uint etcSize; uint etcLineNumber; uint stcComment; uint etcNamespaceUri; uint etcName; } ETCHUNK; // Define the Text Chunk typedef struct { ushort type; ushort headerSize; uint tcSize; uint tcLineNumber; uint tcUNKNOWN; uint tcName; uint tcUNKNOWN; uint tcUNNNOWN; } TEXTCHUNK; //-------------------------------------- // Define the file local uint tag; LittleEndian(); HEADER header; SetBackColor( cLtGreen ); STRINGCHUNK stringChunk; // Sometimes there are some zeros padding after the string chunk FSeek(0x8+stringChunk.scSize); SetBackColor( cLtBlue ); RESOURCEIDCHUNK resourceChunk; FSeek(resourceChunk.pos+resourceChunk.rcSize); while( !FEof() ) { // Read a tag tag = ReadUInt( FTell() ); // Read data depending upon tag if (tag == 0x00100100) { SetBackColor( cLtPurple ); SNCHUNK startNamespaceChunk; } else if (tag == 0x00100101) { SetBackColor( cLtPurple ); ENCHUNK endNamespaceChunk; } else if (tag == 0x00100102) { SetBackColor( cLtGreen ); STCHUNK startTagChunk; } else if (tag == 0x00100103) { SetBackColor( cLtGreen ); ETCHUNK endTagChunk; } else if (tag == 0x00100104) { SetBackColor( cLtBlue ); TEXTCHUNK TextChunk; } }