|
dex++ 0.3.1
C++ and C API reference
|
A loaded Android package. More...
#include <apk/apk.hpp>
Public Member Functions | |
| std::vector< std::string > | entries () const |
| Names of every entry in the archive, in central-directory order. | |
| std::optional< std::vector< uint8_t > > | read (std::string_view name) const |
| Raw (decompressed) bytes of one archive entry, or nullopt if absent. | |
| const Manifest * | manifest () const |
| The decoded AndroidManifest.xml. | |
| const ResourceTable * | resources () const |
| The decoded resources.arsc table. | |
| std::optional< std::string_view > | resolve_string (uint32_t reference_id) const |
| Convenience: resolve a resource reference id (e.g. the value of android:label="@string/app_name") to its string, via resources(). | |
| const SigningInfo & | signing () const |
| Signing schemes and certificates. | |
| std::expected< AnalysisContext, Error > | analysis (const ApkLoadOptions &options={}) const |
| A code-analysis context over every classes*.dex in the APK, in multidex order, loaded from the bytes the Apk already holds. | |
Static Public Member Functions | |
| static std::expected< Apk, Error > | open (const std::string &path) |
| Open an APK (ZIP) from disk. | |
| static std::expected< Apk, Error > | from_buffer (std::vector< uint8_t > bytes, const std::string &label="<apk>") |
| Open an APK (ZIP) whose bytes are already in memory, for example bytes received over the network or uploaded by a user. | |
| static std::expected< Apk, Error > | from_buffer (std::span< const uint8_t > bytes, const std::string &label="<apk>") |
| Open an APK (ZIP) from a view of bytes in memory. | |
A loaded Android package.
Owns the archive bytes; lazily decodes the manifest and lazily builds the code-analysis context on first request. Cheap to copy (shared ownership of the impl).
|
static |
Open an APK (ZIP) whose bytes are already in memory, for example bytes received over the network or uploaded by a user.
The bytes go through the same checks as the bytes open() reads from a file, and every accessor then works the same.
The Apk owns its bytes. This overload takes the vector by value, so a caller that passes it with std::move gives its memory to the Apk and nothing is copied. An lvalue vector is copied.
| bytes | The content of an APK file. |
| label | Names the bytes in error messages, where open() puts the path, for example the name of the file they came from. It is also used for the errors of analysis(). |
|
static |
Open an APK (ZIP) from a view of bytes in memory.
The bytes are copied, so the caller may free them as soon as this returns. Otherwise the same as the overload that takes a vector.
| std::vector< std::string > dex::apk::Apk::entries | ( | ) | const |
Names of every entry in the archive, in central-directory order.
| std::optional< std::vector< uint8_t > > dex::apk::Apk::read | ( | std::string_view | name | ) | const |
Raw (decompressed) bytes of one archive entry, or nullopt if absent.
| const Manifest * dex::apk::Apk::manifest | ( | ) | const |
The decoded AndroidManifest.xml.
Parsed once on first call and cached. nullptr if the APK has no manifest or it fails to decode. Boolean and integer attributes given as resource references are resolved through resources() (see manifest.hpp).
| const ResourceTable * dex::apk::Apk::resources | ( | ) | const |
The decoded resources.arsc table.
Parsed once on first call and cached. nullptr if the APK has no resource table or it fails to decode.
| std::optional< std::string_view > dex::apk::Apk::resolve_string | ( | uint32_t | reference_id | ) | const |
Convenience: resolve a resource reference id (e.g. the value of android:label="@string/app_name") to its string, via resources().
nullopt if there is no resource table or the id is not a string.
| const SigningInfo & dex::apk::Apk::signing | ( | ) | const |
Signing schemes and certificates.
Identification only — digests and signatures are NOT verified. Computed once on first call and cached; an unsigned APK yields a default SigningInfo (is_signed() == false).
| std::expected< AnalysisContext, Error > dex::apk::Apk::analysis | ( | const ApkLoadOptions & | options = {} | ) | const |
A code-analysis context over every classes*.dex in the APK, in multidex order, loaded from the bytes the Apk already holds.
options works as for AnalysisContext::from_apk: pass {.threads = 1} to keep all the work, the call graph included, on the calling thread.
The result is cached per value of options. The first call with a given value builds the context, and every later call with an equal value returns that same context, so its lazy structures (call graph, class hierarchy, cross-references) are built once. A call with different options builds and keeps a second, separate context, which holds its own copy of the DEX files; the two give the same answers. So call it with one setting in a program. A failure is cached the same way.