ProguardCache

Struct ProguardCache 

Source
pub struct ProguardCache<'data> { /* private fields */ }
Expand description

The serialized ProguardCache binary format.

Implementations§

Source§

impl<'data> ProguardCache<'data>

Source

pub fn debug_classes<'r>( &'r self, ) -> impl Iterator<Item = ClassDebug<'r, 'data>>

Returns an iterator over class entries in this cache file that can be debug printed.

Source

pub fn debug_members<'r>( &'r self, ) -> impl Iterator<Item = MemberDebug<'r, 'data>>

Returns an iterator over member entries in this cache file that can be debug printed.

Source

pub fn debug_members_by_params<'r>( &'r self, ) -> impl Iterator<Item = MemberDebug<'r, 'data>>

Returns an iterator over by-params member entries in this cache file that can be debug printed.

Source

pub fn display(&self) -> CacheDebug<'_, '_>

Creates a view of the cache that implements Display.

The Display impl is very similar to the original proguard format.

Source§

impl<'data> ProguardCache<'data>

Source

pub fn parse(buf: &'data [u8]) -> Result<Self, CacheError>

Parses a ProguardCache out of bytes.

Source

pub fn write<W: Write>( mapping: &ProguardMapping<'_>, writer: &mut W, ) -> Result<()>

Writes a ProguardMapping into a writer in the proguard cache format.

Source

pub fn test(&self)

Tests the integrity of this cache.

Specifically it checks the following:

  • All string offsets in class and member entries are either u32::MAX or defined.
  • Member entries are ordered by the class they belong to.
  • All is_synthesized fields on classes and members are either 0 or 1.
Source§

impl<'data> ProguardCache<'data>

Source

pub fn remap_class(&self, class: &str) -> Option<&'data str>

Remaps an obfuscated Class.

This works on the fully-qualified name of the class, with its complete module prefix.

§Examples
use proguard::{ProguardMapping, ProguardCache};
let mapping = ProguardMapping::new(br#"android.arch.core.executor.ArchTaskExecutor -> a.a.a.a.c:"#);
let mut cache = Vec::new();
ProguardCache::write(&mapping, &mut cache).unwrap();
let cache = ProguardCache::parse(&cache).unwrap();

let mapped = cache.remap_class("a.a.a.a.c");
assert_eq!(mapped, Some("android.arch.core.executor.ArchTaskExecutor"));
Source

pub fn remap_method( &self, class: &str, method: &str, ) -> Option<(&'data str, &'data str)>

Remaps an obfuscated Class Method.

The class argument has to be the fully-qualified obfuscated name of the class, with its complete module prefix.

If the method can be resolved unambiguously, it will be returned alongside the remapped class, otherwise None is being returned.

Source

pub fn remap_frame<'r: 'data>( &'r self, frame: &StackFrame<'data>, ) -> RemappedFrameIter<'r, 'data>

Remaps a single Stackframe.

Returns zero or more StackFrames, based on the information in the proguard mapping. This can return more than one frame in the case of inlined functions. In that case, frames are sorted top to bottom.

Source

pub fn remap_frame_with_context<'r>( &'r self, frame: &StackFrame<'data>, exception_descriptor: Option<&str>, apply_rewrite: bool, carried_outline_pos: &mut Option<usize>, ) -> Option<RemappedFrameIter<'r, 'data>>
where 'r: 'data,

Remaps a single stack frame through the complete processing pipeline.

This method combines:

§Arguments
  • frame - The frame to remap
  • exception_descriptor - Optional exception descriptor for rewrite rules (e.g., Ljava/lang/NullPointerException;)
  • apply_rewrite - Whether to apply rewrite rules (typically true only for the first frame after an exception)
  • carried_outline_pos - Mutable reference to track outline position across frames
§Returns
  • None if this is an outline frame (caller should skip, carried_outline_pos is updated internally)
  • Some(iterator) with remapped frames. Use [RemappedFrameIter::had_mappings] after collecting to detect if rewrite rules cleared all frames (skip if had_mappings() && collected.is_empty())
Source

pub fn remap_throwable<'a>( &'a self, throwable: &Throwable<'a>, ) -> Option<Throwable<'a>>

Remaps a throwable which is the first line of a full stacktrace.

§Example
use proguard::{ProguardMapping, ProguardCache, Throwable};

let mapping = ProguardMapping::new(b"com.example.Mapper -> a.b:");
let mut cache = Vec::new();
ProguardCache::write(&mapping, &mut cache).unwrap();
let cache = ProguardCache::parse(&cache).unwrap();

let throwable = Throwable::try_parse(b"a.b: Crash").unwrap();
let mapped = cache.remap_throwable(&throwable);

assert_eq!(
    Some(Throwable::with_message("com.example.Mapper", "Crash")),
    mapped
);
Source

pub fn is_outline_frame(&self, class: &str, method: &str) -> bool

Determines if a frame refers to an outline method via the method-level flag. Outline metadata is consistent across all mapping entries for a method, so we only need to inspect the method metadata instead of individual lines.

Source

pub fn prepare_frame_for_mapping<'a>( &self, frame: &StackFrame<'a>, carried_outline_pos: &mut Option<usize>, ) -> StackFrame<'a>

Applies any carried outline position to the frame line and returns the adjusted frame.

Source

pub fn remap_stacktrace(&self, input: &str) -> Result<String, Error>

Remaps a complete Java StackTrace, similar to Self::remap_stacktrace_typed but instead works on strings as input and output.

Source

pub fn remap_stacktrace_typed<'a>( &'a self, trace: &StackTrace<'a>, ) -> StackTrace<'a>

Remaps a complete Java StackTrace.

Source

pub fn deobfuscate_signature( &self, signature: &str, ) -> Option<DeobfuscatedSignature>

returns a tuple where the first element is the list of the function parameters and the second one is the return type

Trait Implementations§

Source§

impl<'data> Clone for ProguardCache<'data>

Source§

fn clone(&self) -> ProguardCache<'data>

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProguardCache<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'data> PartialEq for ProguardCache<'data>

Source§

fn eq(&self, other: &ProguardCache<'data>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'data> Eq for ProguardCache<'data>

Source§

impl<'data> StructuralPartialEq for ProguardCache<'data>

Auto Trait Implementations§

§

impl<'data> Freeze for ProguardCache<'data>

§

impl<'data> RefUnwindSafe for ProguardCache<'data>

§

impl<'data> Send for ProguardCache<'data>

§

impl<'data> Sync for ProguardCache<'data>

§

impl<'data> Unpin for ProguardCache<'data>

§

impl<'data> UnwindSafe for ProguardCache<'data>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.