bunseokbot / dexparser

DEX file format parser for Pythonist

Home Page:https://dexparser.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FR] Handle with static data

kotori2 opened this issue · comments

With static_values_off in classdef_data.
Here is a working but incomplete snippet, I'm a little bit lazy to fill all of the types.
References could be found here

    def get_static_data(self, offset):
        """

        :param offset:
        :return:
        """
        self.get_strings()
        size, size_off = uleb128_value(self.data, offset)
        offset += size_off
        result = []
        for _ in range(size):
            value_arg = self.data[offset] >> 5
            value_type = self.data[offset] & 0b11111
            offset += 1
            match value_type:
                case 23:  # string
                    string_off = 0
                    for i in range(value_arg + 1):
                        string_off |= (self.data[offset] << 8 * i)
                        offset += 1
                    result.append(self.strings[string_off])
                case 4:  # int
                    val = 0
                    for i in range(value_arg + 1):
                        val |= (self.data[offset] << 8 * i)
                        offset += 1
                    result.append(val)
                case _:
                    result.append(None)
        return result

Feature applied into version 1.2.0. Thank you for your precious suggestion.

Thank you so much!