def create_cpp_header(self, class_name="Landroid/app/Activity;"): # if self.m_class_name_id.in(class_name): # index into typeIds for this class if self.m_class_name_id.has_key(class_name): class_idx = self.m_class_name_id[class_name] field_list = dex_class( self, class_idx).create_header_file_cplusplus(self)
def __init__(self, file_path): global DEX_MAGIC global DEX_OPT_MAGIC self.m_file_path = file_path self.m_fd = open(file_path, "rb") self.m_content = self.m_fd.read() self.m_fd.close() self.m_dex_optheader = None self.m_class_name_id = {} # dirct class_name : index self.m_string_table = [] # list if self.m_content[0:4] == DEX_OPT_MAGIC: # self.init_optheader() pass elif self.m_content[0:4] == DEX_MAGIC: self.init_header(self.m_content, 0) bOffset = self.m_stringIdsoff if self.m_stringIdsSize > 0: for i in xrange(0, self.m_stringIdsSize): # pdb.set_trace() offset, = struct.unpack_from( "I", self.m_content, bOffset + i * 4) start = offset skip, length = get_uleb128(self.m_content[start:start + 5]) # self.string_table.append(self.m_content[start+skip:offset-1]) self.m_string_table.append( self.m_content[start + skip: start + skip + length]) for x in xrange(0, self.m_classDefSize): str1 = self.get_classname(x) self.m_class_name_id[str1] = x ''' str1 'Lcom/example/inotify/BuildConfig;' 'Lcom/example/inotify/MainActivity$1;' ...... ''' for i in xrange(0, self.m_classDefSize): dex_class(self, i) . printf(self)