Beispiel #1
0
 def __init__(self, parent):
     self.__pe = parent.Parent.peInstance
     self.__fp = parent.Parent.get_loaded_file()
     self.__exp_data = dict()
     self.currentItem = None
     
     self.parentDirectory = parent
     export_data = pedata.getDirectoryEntryExport(self.__pe)
     
     self._init_ctrls(parent)
     
     self.loadExportData(export_data)
     self.loadExportSymbols(export_data)
Beispiel #2
0
    def OnSaveButton(self, event):
        
        cs = pedata.getDirectoryEntryExport(self.__pe).struct
        
        new_dll_name = self._name_string.GetValue()
        
        end = self.__pe.get_data(cs.Name).find("\x00") + 1
        old_dll_name = self.__pe.get_data(cs.Name, end)
        
        if len(old_dll_name) == len(new_dll_name):    
            result = self.__pe.set_bytes_at_rva(cs.Name, new_dll_name)
            if not result:
                wx.MessageBox("Error saving the dll name", "Error", wx.ICON_ERROR)
        else:
            wx.MessageBox("The len of the dll name must be equal to the one in the file: %d" % len(old_dll_name), "Error in length", wx.ICON_ERROR)
            return False
        
        offset_to_et = toInt(self._offset_to_export_table.GetValue())
        
        self.__pe.OPTIONAL_HEADER.DATA_DIRECTORY[0].VirtualAddress = offset_to_et
        
        cs.Characteristics       = toInt(self._characteristics.GetValue())
        cs.Base                  = toInt(self._base.GetValue())
        cs.Name                  = toInt(self._name.GetValue())
        cs.AddressOfFunctions    = toInt(self._address_of_functions.GetValue())
        cs.AddressOfNames        = toInt(self._address_of_names.GetValue())
        cs.NumberOfFunctions     = toInt(self._number_of_functions.GetValue())
        cs.NumberOfNames         = toInt(self._number_of_names.GetValue())
        cs.AddressOfNameOrdinals = toInt(self._address_of_name_ordinals.GetValue())
        cs.TimeDateStamp         = toInt(self._time_date_stamp.GetValue())
        cs.MinorVersion          = self._minor_version.GetValue()
        cs.MajorVersion          = self._major_version.GetValue()

        try:
            self.__pe.write(self.__fp)
        except IOError, e:
            raise str(e)