Skip to content

Latest commit

 

History

History
60 lines (53 loc) · 2.71 KB

README.md

File metadata and controls

60 lines (53 loc) · 2.71 KB

Apk reader

Nuget

Android package file reader assembly. Can read apk files, android xml files (AndroidManifes.xml, *.xml), Dalvik executable format (dex), android resource files (arsc).

Usage:

using(ApkFile apk = new ApkFile(filePath))
{
    if(apk.IsValid)
    {
        If(apk.AndroidManifest!=null)
        {//AndroidManifest.xml
            Console.WriteLine("Package: {0}", apk.AndroidManifest.Package);
            Console.WriteLine("Application name: {0} ({1})", apk.AndroidManifest.Application.Label, apk.AndroidManifest.VersionName);
            //...
        }

        if(apk.Resources!=null)
        {//resources.arsc
            //...
        }

        foreach(String filePath in apk.GetHeaderFiles())
            if(Path.GetExtension(filePath).ToLowerInvariant()==".dex")
                using(DexFile dex=new DexFile(new StreamLoader(apk.GetFileStream(filePath))))
                {//Davlik executables
                    //...
                }
    }
}

Supported structures:

  • ApkFile.cs
    • XmlFile — AndroidManifest.xml
    • Resources — resources.arsc
    • AndroidManifest — Stronly typled android manifest file
  • ArscFile.cs (resources.arsc)
    • Header — Resource file header
    • ResourceMap — Resource table (id,value(s))
  • AxmlFile.cs (https://developer.android.com/guide/topics/manifest/manifest-intro)
    • Strongly typed manifest sections mapped to resources.arsc file where needed
  • DexFile.cs (https://source.android.com/devices/tech/dalvik/dex-format)
    • map_list — This is a list of the entire contents of a file, in order.
    • STRING_ID_ITEM — String identifiers list.
    • STRING_DATA_ITEM — String identifiers list.
    • CODE_ITEM — Source bytecode payload
    • TYPE_ID_ITEM — Type identifiers list.
    • TYPE_LIST — Referenced from Class definitions list and method prototype identifiers list.
    • PROTO_ID_ITEM — Method prototype identifiers list
    • FIELD_ID_ITEM — Field identifiers list
    • METHOD_ID_ITEM — Method identifiers list
    • CLASS_DATA_ITEM — Class structure list
    • encoded_field — Static and instance fields from the class_data_item
    • encoded_method — Class method definition list
    • CLASS_DEF_ITEM — Class definitions list
    • try_item — in the code exceptions are caught and how to handle them
    • encoded_catch_handler_list — Catch handler lists
    • encoded_type_addr_pair — One for each caught type, in the order that the types should be tested