hachoir-wx-0.3/0000755000175000017500000000000011057463347012461 5ustar haypohaypohachoir-wx-0.3/hachoir_wx/0000755000175000017500000000000011057463347014614 5ustar haypohaypohachoir-wx-0.3/hachoir_wx/field_view/0000755000175000017500000000000011057463347016731 5ustar haypohaypohachoir-wx-0.3/hachoir_wx/field_view/__init__.py0000644000175000017500000000027711057463311021037 0ustar haypohaypo# -*- coding: utf-8 -*- from field_view_setup import setup_field_view from field_view import field_view_t from field_menu_setup import setup_field_menu from field_menu import field_menu_t hachoir-wx-0.3/hachoir_wx/field_view/core_type_menu.py0000644000175000017500000000115211057463311022306 0ustar haypohaypo# -*- coding: utf-8 -*- import wx class core_type_menu_t: def __init__(self, menu): self.menu = menu self.id_to_type = {} self.Bind = self.menu.Bind # see note in field_menu.py def add_type(self, type_name): type_id = wx.NewId() self.id_to_type[type_id] = type_name self.menu.Append(type_id, type_name) def get_type_name(self, id): return self.id_to_type[id] def clear(self): items = self.menu.GetMenuItems() for item in items: self.menu.DeleteItem(item) # TODO: what's the difference between Remove and Delete? hachoir-wx-0.3/hachoir_wx/field_view/core_type_menu_fwd.py0000644000175000017500000000053511057463311023152 0ustar haypohaypo# -*- coding: utf-8 -*- import wx class core_type_menu_fwd_t: def __init__(self, imp): self.imp = imp def on_core_type_menu_ready(self, dispatcher, view): assert view is not None view.Bind(wx.EVT_MENU, self.on_type_selected) def on_type_selected(self, event): self.imp.on_type_selected(event.GetId()) hachoir-wx-0.3/hachoir_wx/field_view/core_type_menu_imp.py0000644000175000017500000000147311057463311023161 0ustar haypohaypo# -*- coding: utf-8 -*- from hachoir_core.field import available_types from hachoir_wx.field_view.mutator import convert_field from hachoir_wx.field_view.stubs import can_convert class core_type_menu_imp_t: def __init__(self): self.cur_field = None def on_core_type_menu_ready(self, dispatcher, view): assert view is not None self.view = view def on_type_selected(self, id): convert_field(self.cur_field, self.view.get_type_name(id)) self.dispatcher.trigger('field_modified', self.cur_field) def on_field_selected(self, dispatcher, field): self.cur_field = field self.view.clear() for type in available_types: if can_convert(field, type) and field.__class__ is not type: self.view.add_type(type.__name__) hachoir-wx-0.3/hachoir_wx/field_view/field_menu.py0000644000175000017500000000107511057463311021404 0ustar haypohaypo# -*- coding: utf-8 -*- from hachoir_wx.dialogs import file_save_dialog import wx class field_menu_t: def __init__(self, parent, menu): self.parent = parent self.menu = menu # forward this call because xrc doesn't allow menu # subclassing (as of 2.6.3) self.Bind = self.menu.Bind def show_opts(self): self.parent.PopupMenu(self.menu) def ask_for_dump_file(self, title): dump_dlog = file_save_dialog(title) if wx.ID_OK == dump_dlog.ShowModal(): return dump_dlog.GetPath() hachoir-wx-0.3/hachoir_wx/field_view/field_menu_fwd.py0000644000175000017500000000160311057463311022241 0ustar haypohaypo# -*- coding: utf-8 -*- from wx import EVT_MENU from wx.xrc import XRCID class field_menu_fwd_t: def __init__(self, imp): self.imp = imp def on_field_view_ready(self, dispatcher, view): assert view is not None view.Bind(EVT_MENU, self.imp.on_addr_rel, id=XRCID('field_menu_address_relative')) view.Bind(EVT_MENU, self.imp.on_addr_abs, id=XRCID('field_menu_address_absolute')) view.Bind(EVT_MENU, self.imp.on_addr_hex, id=XRCID('field_menu_address_base_hex')) view.Bind(EVT_MENU, self.imp.on_addr_dec, id=XRCID('field_menu_address_base_dec')) view.Bind(EVT_MENU, self.imp.on_dump_to_disk, id=XRCID('field_menu_dump_to_disk')) view.Bind(EVT_MENU, self.imp.on_parse_substream, id=XRCID('field_menu_parse_substream')) hachoir-wx-0.3/hachoir_wx/field_view/field_menu_imp.py0000644000175000017500000000275411057463311022256 0ustar haypohaypo# -*- coding: utf-8 -*- from hachoir_wx.field_view.stubs import save_substream_to_disk from hachoir_core.i18n import _ class field_menu_imp_t: def on_field_set_ready(self, dispatcher, fields): assert fields is not None self.fields = fields self.selected = None def on_field_menu_ready(self, dispatcher, view): assert view is not None self.view = view def on_field_show_ops(self, dispatcher, field): self.view.show_opts() def on_addr_rel(self, event): self.dispatcher.trigger('address_relative') def on_addr_abs(self, event): self.dispatcher.trigger('address_absolute') def on_addr_hex(self, event): self.dispatcher.trigger('address_hexadecimal') def on_addr_dec(self, event): self.dispatcher.trigger('address_decimal') def on_split_bits(self): self.dispatcher.trigger('field_split_bits') def on_split_bytes(self): self.dispatcher.trigger('field_split_bytes') def on_field_selected(self, dispatcher, field): self.selected = field def on_file_ready(self, dispatcher, file): self.file = file def on_parse_substream(self, dispatcher): self.dispatcher.trigger('field_parse_substream', self.selected) def on_dump_to_disk(self, event): dump_path = self.view.ask_for_dump_file(_('Dump "' + self.selected._getPath() + '" To Disk...')) if dump_path is not None: save_substream_to_disk(self.selected, dump_path) hachoir-wx-0.3/hachoir_wx/field_view/field_menu_setup.py0000644000175000017500000000335111057463311022623 0ustar haypohaypo# -*- coding: utf-8 -*- from field_menu_imp import field_menu_imp_t from field_menu_fwd import field_menu_fwd_t from field_menu import field_menu_t from core_type_menu import core_type_menu_t from core_type_menu_fwd import core_type_menu_fwd_t from core_type_menu_imp import core_type_menu_imp_t from field_split_menu import field_split_menu_t from field_split_menu_fwd import field_split_menu_fwd_t from field_split_menu_imp import field_split_menu_imp_t import wx from hachoir_wx.resource import get_menu_bar, get_menu_from_bar def setup_field_menu(parent, dispatcher): bar = get_menu_bar('context_menu_bar') menu = get_menu_from_bar(bar, 'Field') field_menu = field_menu_t(parent, menu) imp = field_menu_imp_t() dispatcher.add(imp) fwd = field_menu_fwd_t(imp) dispatcher.add_receiver(fwd) setup_core_type_menu(menu, dispatcher) setup_field_split_menu(parent, menu, dispatcher) dispatcher.trigger('field_menu_ready', field_menu) return field_menu def setup_core_type_menu(parent, dispatcher): menu = parent.FindItemById(wx.xrc.XRCID('field_menu_convert_to_core_type')).GetSubMenu() core_type_menu = core_type_menu_t(menu) imp = core_type_menu_imp_t() dispatcher.add(imp) fwd = core_type_menu_fwd_t(imp) dispatcher.add_receiver(fwd) dispatcher.trigger('core_type_menu_ready', core_type_menu) def setup_field_split_menu(parent, parent_menu, dispatcher): menu = parent_menu.FindItemById(wx.xrc.XRCID('field_menu_split')).GetSubMenu() split_menu = field_split_menu_t(parent, menu) imp = field_split_menu_imp_t() dispatcher.add(imp) fwd = field_split_menu_fwd_t(imp) dispatcher.add_receiver(fwd) dispatcher.trigger('field_split_menu_ready', split_menu) hachoir-wx-0.3/hachoir_wx/field_view/field_split_menu.py0000644000175000017500000000102511057463311022612 0ustar haypohaypo# -*- coding: utf-8 -*- from wx import GetNumberFromUser from hachoir_core.i18n import _ class field_split_menu_t: def __init__(self, parent, menu): self.parent = parent self.menu = menu self.Bind = self.menu.Bind # see note in field_menu.py def ask_split(self, caption, min, max): num = GetNumberFromUser(_('Enter split offset:'), '', caption, min, min, max, self.parent) if -1 == num: return None else: return num hachoir-wx-0.3/hachoir_wx/field_view/field_split_menu_fwd.py0000644000175000017500000000106611057463311023457 0ustar haypohaypo# -*- coding: utf-8 -*- import wx class field_split_menu_fwd_t: def __init__(self, imp): self.imp = imp def on_field_split_menu_ready(self, dispatcher, view): assert view is not None view.Bind(wx.EVT_MENU, self.on_split_bytes, id = wx.xrc.XRCID('field_menu_split_bytes')) view.Bind(wx.EVT_MENU, self.on_split_bits, id = wx.xrc.XRCID('field_menu_split_bits')) def on_split_bits(self, event): self.imp.on_split_bits() def on_split_bytes(self, event): self.imp.on_split_bytes() hachoir-wx-0.3/hachoir_wx/field_view/field_split_menu_imp.py0000644000175000017500000000212011057463311023454 0ustar haypohaypo# -*- coding: utf-8 -*- from hachoir_wx.field_view.mutator import split_field from hachoir_core.field import RawBytes, RawBits from hachoir_core.i18n import _ class field_split_menu_imp_t: def on_field_split_menu_ready(self, dispatcher, view): assert view is not None self.view = view def on_field_selected(self, dispatcher, field): self.field = field def on_split_bytes(self): if self.split_field(_('Split Bytes...'), self.field, RawBytes, lambda field: field._getSize() / 8): self.dispatcher.trigger('field_was_split_bytes', self.field) def on_split_bits(self): if self.split_field(_('Split Bits...'), self.field, RawBits, lambda field: field._getSize()): self.dispatcher.trigger('field_was_split_bits', self.field) def split_field(self, caption, field, split_type, size_func): offset = self.view.ask_split(caption, 1, size_func(field) - 1) if offset is not None: new_fields = split_field(field, offset, field._getName(), split_type, size_func) return offset hachoir-wx-0.3/hachoir_wx/field_view/field_view.py0000644000175000017500000000320411057463311021406 0ustar haypohaypo# -*- coding: utf-8 -*- from wx import ListCtrl, PreListCtrl, EVT_WINDOW_CREATE, CallAfter from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixin from sys import maxint from hachoir_core.i18n import _ class field_view_t(ListCtrl, ListCtrlAutoWidthMixin): def __init__(self): self.cols = {} pre = PreListCtrl() self.PostCreate(pre) self.Bind(EVT_WINDOW_CREATE, self.on_create) def post_init(self): ListCtrlAutoWidthMixin.__init__(self) columns = [_('address'), _('name'), _('type'), _('size'), _('data'), _('description')] for name in columns: self.append_column(name) self.Layout() self.Fit() self.dispatcher.trigger('field_view_ready', self) def on_create(self, event): self.Unbind(EVT_WINDOW_CREATE) CallAfter(self.post_init) def append_column(self, name): index = self.GetColumnCount() self.cols[name] = index self.InsertColumn(col = index, heading = name) def append_row(self, col_map): index = self.InsertStringItem(maxint, '') for name, value in col_map.iteritems(): col_index = self.cols[name] self.SetStringItem(index, col_index, value) self.autosize_column(col_index, value) def get_selected(self, name): return self.GetItem(self.GetFocusedItem(), self.cols[_('name')]).GetText() def clear(self): self.DeleteAllItems() def autosize_column(self, col_index, value): item_width = self.GetCharWidth() * (len(value) + 1) self.SetColumnWidth(col_index, max(item_width, self.GetColumnWidth(col_index))) hachoir-wx-0.3/hachoir_wx/field_view/field_view_fwd.py0000644000175000017500000000135111057463311022247 0ustar haypohaypo# -*- coding: utf-8 -*- import wx class field_view_fwd_t: def __init__(self, imp): self.imp = imp def on_field_view_ready(self, dispatcher, field_view): assert field_view is not None field_view.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.on_item_right_clicked) field_view.Bind(wx.EVT_RIGHT_UP, self.on_item_right_clicked) field_view.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_item_activated) field_view.Bind(wx.EVT_LIST_ITEM_SELECTED, self.on_item_selected) def on_item_activated(self, event): self.imp.on_item_activated() def on_item_selected(self, event): self.imp.on_item_selected() def on_item_right_clicked(self, event): self.imp.on_item_show_ops() hachoir-wx-0.3/hachoir_wx/field_view/field_view_imp.py0000644000175000017500000000536311057463311022263 0ustar haypohaypo# -*- coding: utf-8 -*- from hachoir_wx.field_view.format import format_addr_hex, format_addr_dec, format_size, format_data, format_name, format_desc from hachoir_core.i18n import _ class field_view_imp_t: def __init__(self): self.addr_func = lambda field: field._getAbsoluteAddress() self.format_addr = lambda field: format_addr_hex(self.addr_func(field)) def on_field_set_ready(self, dispatcher, field_set): assert field_set is not None self.fields = field_set def on_field_view_ready(self, dispatcher, view): assert view is not None self.view = view self.fill_view() self.dispatcher.trigger('field_activated', self.fields) def on_item_selected(self): name = self.view.get_selected(_('name')) if isinstance(name, unicode): name = str(name) self.dispatcher.trigger('field_selected', self.fields[name]) def on_item_activated(self): field = self.fields[self.view.get_selected(_('name'))] if field.is_field_set: self.fields = field self.refill_view() self.dispatcher.trigger('field_activated', field) def on_field_modified(self, dispatcher, field): self.refill_view() def on_item_show_ops(self): field = self.fields[self.view.get_selected(_('name'))] self.dispatcher.trigger('field_show_ops', field) def on_address_relative(self, dispatcher): self.addr_func = lambda field: field._getAddress() self.refill_view() def on_address_absolute(self, dispatcher): self.addr_func = lambda field: field._getAbsoluteAddress() self.refill_view() def on_address_hexadecimal(self, dispatcher): self.format_addr = lambda field: format_addr_hex(self.addr_func(field)) self.refill_view() def on_address_decimal(self, dispatcher): self.format_addr = lambda field: format_addr_dec(self.addr_func(field)) self.refill_view() def on_field_was_split_bytes(self, dispatcher, field): self.refill_view() def on_field_was_split_bits(self, dispatcher, field): self.refill_view() def fill_view(self): if self.fields._getParent() is not None: self.view.append_row({ _('name') : '../' }) for field in self.fields: map = { _('address') : self.format_addr(field), _('name') : format_name(field), _('type') : field.getFieldType(), _('size') : format_size(field._getSize()), _('data') : format_data(field), _('description'): format_desc(field) } self.view.append_row(map) def refill_view(self): self.view.clear() self.fill_view() hachoir-wx-0.3/hachoir_wx/field_view/field_view_setup.py0000644000175000017500000000114711057463311022632 0ustar haypohaypo# -*- coding: utf-8 -*- from hachoir_wx.resource import get_child_control from field_view_imp import field_view_imp_t from field_view_fwd import field_view_fwd_t from field_menu_setup import setup_field_menu def setup_field_view(parent, dispatcher): print "[+] Setup field view" field_view = get_child_control(parent, 'field_view') dispatcher.add_sender(field_view) field_view_imp = field_view_imp_t() dispatcher.add(field_view_imp) field_view_fwd = field_view_fwd_t(field_view_imp) dispatcher.add(field_view_fwd) setup_field_menu(field_view, dispatcher) return field_view hachoir-wx-0.3/hachoir_wx/field_view/format.py0000644000175000017500000000105611057463311020564 0ustar haypohaypo# -*- coding: utf-8 -*- def format_addr_dec(addr): return "%08d.%01d" % divmod(addr, 8) def format_addr_hex(addr): return "%08x.%01d" % divmod(addr, 8) def format_size(size): return "%08u.%01d" % divmod(size, 8) def format_data(field): data = '' if field.hasValue(): data = field.display return data def format_name(field): name = field._getName() if field.is_field_set: name += '/' return name def format_desc(field): if field.description: return str(field.description) return '' hachoir-wx-0.3/hachoir_wx/field_view/mutator.py0000644000175000017500000000155411057463311020772 0ustar haypohaypo# -*- coding: utf-8 -*- from hachoir_core import field as field_module from hachoir_wx.field_view.stubs import has_static_size, convert_size def split_field(field, split_pos, split_name, split_t, size_func): split_name += '[]' subfields = [ split_t(field._parent, split_name, split_pos), split_t(field._parent, split_name, size_func(field) - split_pos) ] field._parent.replaceField(field._getName(), subfields) def convert_field(field, new_type_name): field_set = field._parent new_type = getattr(field_module, new_type_name) if has_static_size(new_type): new_field = new_type(field_set, field._getName(), field._getDescription()) else: new_field = new_type(field_set, field._getName(), convert_size(field, new_type), field._getDescription()) field_set.replaceField(field._getName(), [new_field]) hachoir-wx-0.3/hachoir_wx/field_view/stubs.py0000644000175000017500000000240011057463311020426 0ustar haypohaypo# -*- coding: utf-8 -*- # # some stubs that could be in hachoir-core. # from hachoir_core.tools import alignValue from hachoir_core.stream.input import FileFromInputStream def field_index(field_set, field): return field_set._fields.index(field._getName()) def field_from_index(field_set, index): return field_set._fields.values[index] def has_static_size(type): return isinstance(type.static_size, (int, long)) def can_convert(from_field, to_type): if has_static_size(from_field) and has_static_size(to_type): return from_field.static_size == to_type.static_size elif has_static_size(to_type): return from_field._getSize() == to_type.static_size else: return False def field_type_name(field): return field.__class__.__name__ def convert_size(from_field, to_type): if not(('Byte' in field_type_name(from_field)) ^ ('Byte' in to_type.__name__)): return from_field._getSize() elif 'Byte' in field_type_name(from_field): return from_field._getSize() * 8 else: return from_field._getSize() / 8 def save_substream_to_disk(field, dest_path): dest_stream = open(dest_path, 'wb') f = FileFromInputStream(field.getSubIStream()) dest_stream.write(f.read()) dest_stream.close() hachoir-wx-0.3/hachoir_wx/frame_view/0000755000175000017500000000000011057463347016740 5ustar haypohaypohachoir-wx-0.3/hachoir_wx/frame_view/__init__.py0000644000175000017500000000022711057463311021041 0ustar haypohaypo# -*- coding: utf-8 -*- from frame_view import frame_view_t from frame_view_setup import setup_frame_view from frame_view_imp import frame_view_imp_t hachoir-wx-0.3/hachoir_wx/frame_view/frame_view.py0000644000175000017500000000036311057463311021427 0ustar haypohaypo# -*- coding: utf-8 -*- from wx import Frame, PreFrame class frame_view_t(Frame): def __init__(self): pre = PreFrame() self.PostCreate(pre) def ready(self): self.dispatcher.trigger('frame_view_ready', self) hachoir-wx-0.3/hachoir_wx/frame_view/frame_view_fwd.py0000644000175000017500000000076011057463311022270 0ustar haypohaypo# -*- coding: utf-8 -*- import wx class frame_view_fwd_t: def __init__(self, imp): self.imp = imp def on_frame_view_ready(self, dispatcher, view): assert view is not None view.Bind(wx.EVT_ACTIVATE, self.on_activated) view.Bind(wx.EVT_SHOW, self.on_shown) def on_activated(self, event): if event.GetActive(): self.imp.on_activated() def on_shown(self, event): if event.GetShow(): self.imp.on_activated() hachoir-wx-0.3/hachoir_wx/frame_view/frame_view_imp.py0000644000175000017500000000127511057463311022277 0ustar haypohaypo# -*- coding: utf-8 -*- class frame_view_imp_t: def on_frame_view_ready(self, dispatcher, frame_view): assert frame_view is not None self.view = frame_view def on_file_ready(self, dispatcher, file): assert file is not None self.filename = file.name def on_filename_update(self, dispatcher, filename): self.filename = filename def format_title(self, field): field_path = field._getPath() return self.filename+'/'+field_path[1:] def on_field_activated(self, dispatcher, field): self.view.SetTitle(self.format_title(field)) def on_activated(self): self.dispatcher.trigger('frame_activated', self.view) hachoir-wx-0.3/hachoir_wx/frame_view/frame_view_setup.py0000644000175000017500000000074611057463311022654 0ustar haypohaypo# -*- coding: utf-8 -*- from frame_view_imp import frame_view_imp_t from frame_view_fwd import frame_view_fwd_t from hachoir_wx.resource import get_frame def setup_frame_view(dispatcher): print '[+] Setup frame view' frame = get_frame('frame_view') dispatcher.add_sender(frame) frame_view_imp = frame_view_imp_t() dispatcher.add(frame_view_imp) frame_view_fwd = frame_view_fwd_t(frame_view_imp) dispatcher.add_receiver(frame_view_fwd) return frame hachoir-wx-0.3/hachoir_wx/hex_view/0000755000175000017500000000000011057463347016432 5ustar haypohaypohachoir-wx-0.3/hachoir_wx/hex_view/__init__.py0000644000175000017500000000052211057463311020531 0ustar haypohaypo# -*- coding: utf-8 -*- # platform workarounds import wx if '__WXGTK__' == wx.Platform: from compat_gtk import get_width_chars, get_height_chars else: from compat_all import get_width_chars, get_height_chars from hex_view import hex_view_t from hex_view_scroll import hex_view_scroll_t from hex_view_setup import setup_hex_view hachoir-wx-0.3/hachoir_wx/hex_view/compat_all.py0000644000175000017500000000045411057463311021111 0ustar haypohaypo# -*- coding: utf-8 -*- MAX_LINE_TEST = 10 * 1024 def get_width_chars(view): if not view.GetLineLength(0): padding = ' ' * MAX_LINE_TEST view.SetValue(padding) return view.GetLineLength(0) // 3 def get_height_chars(view): return view.GetClientSize()[1] // view.GetCharHeight() hachoir-wx-0.3/hachoir_wx/hex_view/compat_gtk.py0000644000175000017500000000041611057463311021124 0ustar haypohaypo# -*- coding: utf-8 -*- # compatibility routines to work around bugs in wxgtk def get_width_chars(view): return (view.GetClientSize()[0] - 4) // view.GetCharWidth() // 3 def get_height_chars(view): return (view.GetClientSize()[1] - 4) // view.GetCharHeight() hachoir-wx-0.3/hachoir_wx/hex_view/hex_view.py0000644000175000017500000000244511057463311020616 0ustar haypohaypo# -*- coding: utf-8 -*- from wx import TextCtrl, TextAttr, PreTextCtrl from stubs import to_hex, calc_char_range, clamp_range from hachoir_wx.hex_view import get_width_chars, get_height_chars class hex_view_t(TextCtrl): default_style = TextAttr() default_style.SetTextColour((0, 0, 0)) highlight_style = TextAttr() highlight_style.SetTextColour((52, 95, 215)) def __init__(self): pre = PreTextCtrl() self.PostCreate(pre) self.get_width_chars = lambda: max(get_width_chars(self), 1) self.get_height_chars = lambda: max(get_height_chars(self), 1) def ready(self): self.dispatcher.trigger('hex_view_ready', self) def unmark(self): self.SetStyle(0, self.get_size(), self.default_style) self.Refresh() def mark_range(self, start, size): mark_start, mark_end = calc_char_range(start, start + size) mark_start = clamp_range(mark_start, 0, self.get_size()) mark_end = clamp_range(mark_end, 0, self.get_size()) self.SetStyle(mark_start, mark_end, self.highlight_style) self.Refresh() def display_data(self, data): self.SetValue(to_hex(data)) def get_size(self): return len(self.GetValue()) def get_page_size(view): return view.get_width_chars() * view.get_height_chars() hachoir-wx-0.3/hachoir_wx/hex_view/hex_view_fwd.py0000644000175000017500000000047611057463311021460 0ustar haypohaypo# -*- coding: utf-8 -*- from wx import EVT_SIZE class hex_view_fwd_t: def __init__(self, imp): self.imp = imp def on_hex_view_ready(self, dispatcher, view): assert view is not None view.Bind(EVT_SIZE, self.on_resized) def on_resized(self, event): self.imp.on_resized() hachoir-wx-0.3/hachoir_wx/hex_view/hex_view_imp.py0000644000175000017500000000271511057463311021463 0ustar haypohaypo# -*- coding: utf-8 -*- from hex_view import get_page_size from stubs import clamp_range, byte_addr, safe_seek, calc_field_mark, get_page_offset MAX_SIZE = 10 * 1024 class hex_view_imp_t: def on_file_ready(self, dispatcher, file): assert file is not None self.input = file self.field = None self.pos = 0 def on_hex_view_ready(self, dispatcher, view): assert view is not None self.view = view self.fill_view(0) def fill_view(self, pos): paged_pos = get_page_offset(pos, self.view.get_width_chars()) if safe_seek(self.input, paged_pos): size = clamp_range(get_page_size(self.view), 1, MAX_SIZE) self.view.display_data(self.input.read(size)) self.pos = paged_pos def on_resized(self): self.fill_view(self.pos) self.update_mark() self.dispatcher.trigger('hex_view_resized', self.view, self.pos) def on_show_offset(self, dispatcher, pos): self.fill_view(pos) self.update_mark() def on_field_selected(self, dispatcher, field): self.fill_view(byte_addr(field._getAbsoluteAddress())) self.update_set_mark(field) def update_set_mark(self, field): self.field = field self.update_mark() def update_mark(self): if self.field: self.view.unmark() mark = calc_field_mark(self.pos, self.field) self.view.mark_range(mark[0], mark[1]) hachoir-wx-0.3/hachoir_wx/hex_view/hex_view_scroll.py0000644000175000017500000000041511057463311022167 0ustar haypohaypo# -*- coding: utf-8 -*- from wx import ScrollBar, PreScrollBar class hex_view_scroll_t(ScrollBar): def __init__(self): pre = PreScrollBar() self.PostCreate(pre) def ready(self): self.dispatcher.trigger('hex_view_scroll_ready', self) hachoir-wx-0.3/hachoir_wx/hex_view/hex_view_scroll_fwd.py0000644000175000017500000000050511057463311023027 0ustar haypohaypo# -*- coding: utf-8 -*- import wx class hex_view_scroll_fwd_t: def __init__(self, imp): self.imp = imp def on_hex_view_scroll_ready(self, dispatcher, view): assert view is not None view.Bind(wx.EVT_SCROLL, self.on_scrolled) def on_scrolled(self, event): self.imp.on_scrolled() hachoir-wx-0.3/hachoir_wx/hex_view/hex_view_scroll_imp.py0000644000175000017500000000305111057463311023033 0ustar haypohaypo# -*- coding: utf-8 -*- from math import ceil from stubs import byte_addr, get_file_size, get_page_num class hex_view_scroll_imp_t: def on_file_ready(self, dispatcher, file): assert file is not None self.file = file self.reset_mappers() def on_hex_view_scroll_ready(self, dispatcher, view): assert view is not None self.view = view self.view.SetScrollbar(-1, -1, -1, -1) def on_hex_view_resized(self, dispatcher, view, pos): page_width = view.get_width_chars() page_height = view.get_height_chars() self.set_mappers(page_width) cur_height = self.offset_to_thumb(pos) total_height = int(ceil(get_file_size(self.file) / float(page_width))) self.view.SetScrollbar(cur_height, page_height, total_height, page_height) def on_field_selected(self, dispatcher, field): offset = byte_addr(field._getAbsoluteAddress()) thumb = self.offset_to_thumb(offset) self.view.SetThumbPosition(thumb) def reset_mappers(self): self.thumb_to_offset = lambda thumb_pos: 0 self.offset_to_thumb = lambda offset: 0 def set_mappers(self, page_width): self.thumb_to_offset = lambda thumb_pos: thumb_pos * page_width self.offset_to_thumb = lambda offset: get_page_num(offset = offset, page_width = page_width) def on_scrolled(self): offset = self.thumb_to_offset(self.view.GetThumbPosition()) self.dispatcher.trigger('show_offset', offset) hachoir-wx-0.3/hachoir_wx/hex_view/hex_view_scroll_setup.py0000644000175000017500000000075411057463311023415 0ustar haypohaypo# -*- coding: utf-8 -*- from hachoir_wx.resource import get_child_control from hex_view_scroll_fwd import hex_view_scroll_fwd_t from hex_view_scroll_imp import hex_view_scroll_imp_t def setup_hex_view_scroll(parent, dispatcher): scroll = get_child_control(parent, 'hex_view_scroll') dispatcher.add_sender(scroll) imp = hex_view_scroll_imp_t() dispatcher.add(imp) fwd = hex_view_scroll_fwd_t(imp) dispatcher.add_receiver(fwd) scroll.ready() return scroll hachoir-wx-0.3/hachoir_wx/hex_view/hex_view_setup.py0000644000175000017500000000105411057463311022031 0ustar haypohaypo# -*- coding: utf-8 -*- from hachoir_wx.resource import get_child_control from hex_view_imp import hex_view_imp_t from hex_view_fwd import hex_view_fwd_t from hex_view_scroll_setup import setup_hex_view_scroll def setup_hex_view(parent, dispatcher): print "[+] Setup hex view" hex_view = get_child_control(parent, 'hex_view') dispatcher.add_sender(hex_view) imp = hex_view_imp_t() dispatcher.add(imp) fwd = hex_view_fwd_t(imp) dispatcher.add_receiver(fwd) setup_hex_view_scroll(parent, dispatcher) return hex_view hachoir-wx-0.3/hachoir_wx/hex_view/stubs.py0000644000175000017500000000262411057463311020137 0ustar haypohaypo# -*- coding: utf-8 -*- from hachoir_core.tools import alignValue from math import floor from hachoir_core.error import warning def byte_addr(bit): return bit / 8 def bit_addr(byte): return byte * 8 def get_file_size(file): pos = file.tell() file.seek(0, 2) size = file.tell() file.seek(pos) return size def to_hex(data): hex_data = '' for byte in data: hex_data += "%02x " % ord(byte) return hex_data.rstrip(' ') def calc_char_range(start, end): aligned_start = byte_addr(start) aligned_end = byte_addr(alignValue(end, 8)) char_start = calc_char_pos(aligned_start) char_end = calc_char_pos(aligned_end) return char_start, char_end def calc_char_pos(byte_pos): return byte_pos * 3 def clamp_range(what, begin, end): what = max(what, begin) what = min(what, end) return what def safe_seek(file, where): try: where = max(0, where) file.seek(where) except IOError, err: warning("Cannot seek to %s: %s" % (where, unicode(err))) return False return True def get_page_num(offset, page_width): return int(floor(offset / float(page_width))) def get_page_offset(offset, page_width): return get_page_num(offset, page_width) * page_width def calc_field_mark(offset, field): start = field._getAbsoluteAddress() - bit_addr(offset) size = field._getSize() return (start, size) hachoir-wx-0.3/hachoir_wx/resource/0000755000175000017500000000000011057463347016443 5ustar haypohaypohachoir-wx-0.3/hachoir_wx/resource/__init__.py0000644000175000017500000000010411057463311020536 0ustar haypohaypo# -*- coding: utf-8 -*- from hachoir_wx.resource.resource import * hachoir-wx-0.3/hachoir_wx/resource/hachoir_wx.xrc0000644000175000017500000001031411057463311021302 0ustar haypohaypo Ctrl-O Ctrl-W 640, 480 horizontal wxHORIZONTAL 11 modern normal 0 Monaco wxEXPAND 1 wxEXPAND 11 modern normal 0 Monaco Right-click for extra fun! 200 80 1 1 1 1 1 1 hachoir-wx-0.3/hachoir_wx/resource/resource.py0000644000175000017500000000122411057463311020632 0ustar haypohaypo# -*- coding: utf-8 -*- import os from wx.xrc import XmlResource, XRCCTRL def get_resource(): filename = os.path.join(os.getcwd(), os.path.dirname(__file__), 'hachoir_wx.xrc') return XmlResource(filename) def get_frame(name): return get_resource().LoadFrame(None, name) def get_child_control(parent, child): return XRCCTRL(parent, child) def get_menu_bar(name): return get_resource().LoadMenuBar(name) def get_menu_from_bar(menu_bar, menu_name): menu_index = menu_bar.FindMenu(menu_name) assert -1 != menu_index, 'cannot find menu ' + menu_name + ' in menu bar ' + menu_bar.GetTitle() return menu_bar.GetMenu(menu_index) hachoir-wx-0.3/hachoir_wx/__init__.py0000644000175000017500000000006611057463311016716 0ustar haypohaypofrom hachoir_wx.version import VERSION as __version__ hachoir-wx-0.3/hachoir_wx/app.py0000644000175000017500000000516611057463311015745 0ustar haypohaypo# -*- coding: utf-8 -*- from wx import App, EVT_MENU, ID_OK from wx.xrc import XRCID from hachoir_parser.guess import createParser, guessParser from hachoir_core.stream.input import FileFromInputStream from hachoir_wx.dispatcher import dispatcher_t from hachoir_wx import frame_view, field_view, hex_view from hachoir_wx.dialogs import file_open_dialog from hachoir_wx.unicode import force_unicode from hachoir_wx import __version__ as VERSION class app_t(App): def __init__(self, filename = None): print "[+] Run hachoir-wx version %s" % VERSION self.filename = filename App.__init__(self, False) def OnInit(self): self.bind_events() if self.filename: load_file(self, self.filename) else: self.on_file_menu_open_file(None) return True def bind_events(self): self.Bind(EVT_MENU, self.on_file_menu_open_file, id=XRCID('file_menu_open_file')) self.Bind(EVT_MENU, self.on_file_menu_close_window, id=XRCID('file_menu_close_window')) def on_file_menu_open_file(self, event): open_dialog = file_open_dialog() if ID_OK != open_dialog.ShowModal(): return filename = open_dialog.GetPath() open_dialog.Destroy() load_file(self, open_dialog.GetPath()) def on_field_parse_substream(self, dispatcher, field): stream = field.getSubIStream() parser = guessParser(stream) if not parser: return subfile = FileFromInputStream(stream) subfile.name = field.path new_window(self, subfile, parser, subfile.name) def on_frame_activated(self, dispatcher, frame): self.SetTopWindow(frame) def on_file_menu_close_window(self, event): top_window = self.GetTopWindow() assert top_window is not None top_window.Close() def load_file(app, filename): parser = createParser(force_unicode(filename), real_filename = filename) if not parser: return new_window(app, open(filename, 'rb'), parser, filename) def new_window(app, file, parser, filename): print '[+] Opening new GUI' dispatcher = dispatcher_t() dispatcher.add_receiver(app) frame = frame_view.setup_frame_view(dispatcher) field_view.setup_field_view(frame, dispatcher) hex_view_widget = hex_view.setup_hex_view(frame, dispatcher) dispatcher.trigger('file_ready', file) dispatcher.trigger('field_set_ready', parser) dispatcher.trigger('filename_update', filename.replace('\\','/')) frame.ready() hex_view_widget.ready() frame.Show() print '[+] GUI ready' hachoir-wx-0.3/hachoir_wx/dialogs.py0000644000175000017500000000102411057463311016574 0ustar haypohaypo# -*- coding: utf-8 -*- import wx, os from hachoir_core.i18n import _ def file_open_dialog(): dialog_style = wx.OPEN | wx.FILE_MUST_EXIST dialog = wx.FileDialog( None, message = _('Open'), defaultDir = os.getcwd(), defaultFile = '', style = dialog_style) return dialog def file_save_dialog(title): dialog_style = wx.SAVE dialog = wx.FileDialog( None, message = title, defaultDir = os.getcwd(), defaultFile = '', style = dialog_style) return dialog hachoir-wx-0.3/hachoir_wx/dispatcher.py0000644000175000017500000000133311057463311017303 0ustar haypohaypo# -*- coding: utf-8 -*- class dispatcher_t: def __init__(self): self.receivers = [] def add(self, who): self.add_sender(who) self.add_receiver(who) def add_sender(self, sender): sender.dispatcher = self def add_receiver(self, receiver): self.receivers.append(receiver) def trigger(self, event_name, *args): handler_name = 'on_' + event_name unhandled_name = 'on_unhandled' for receiver in self.receivers: if hasattr(receiver, handler_name): getattr(receiver, handler_name)(self, *args) elif hasattr(receiver, unhandled_name): getattr(receiver, unhandled_name)(self, event_name, *args) hachoir-wx-0.3/hachoir_wx/unicode.py0000644000175000017500000000070611057463311016606 0ustar haypohaypo# -*- coding: utf-8 -*- import wx import locale import sys def get_charset(): try: charset = locale.getdefaultlocale()[1] except (locale.Error, NameError, AttributeError, IndexError): pass if charset is None: charset = sys.getdefaultencoding() return charset def force_unicode(name): if not isinstance(name, unicode): charset = get_charset() name = unicode(name, charset) return name hachoir-wx-0.3/hachoir_wx/version.py0000644000175000017500000000015611057463311016644 0ustar haypohaypoPACKAGE = "hachoir-wx" VERSION = "0.3" WEBSITE = 'http://hachoir.org/wiki/hachoir-wx' LICENSE = 'GNU GPL v2' hachoir-wx-0.3/hachoir_wx.egg-info/0000755000175000017500000000000011057463347016306 5ustar haypohaypohachoir-wx-0.3/hachoir_wx.egg-info/PKG-INFO0000644000175000017500000000770211057463346017410 0ustar haypohaypoMetadata-Version: 1.0 Name: hachoir-wx Version: 0.3 Summary: hachoir-wx is a wxWidgets GUI that's meant to provide a (more) user-friendly interface to the hachoir binary parsing engine Home-page: http://hachoir.org/wiki/hachoir-wx Author: Cyril Zorin Author-email: UNKNOWN License: GNU GPL v2 Download-URL: http://hachoir.org/wiki/hachoir-wx Description: hachoir-wx is a wxWidgets-based program that's meant to provide a (more) user-friendly interface to the facilities provided by the hachoir binary parser core. For latest updates, to ask for a feature (please do!), and bleeding(-edge) source code see the website: http://hachoir.org/wiki/hachoir-wx Everyone is very welcome to contribute code =) hachoir-wx 0.3 ============== * Use the new getFieldType() method of hachoir-core 1.2 to display better informations about the field type, eg. shows the string charset hachoir-wx 0.2 ============== * hachoir-wx is now able to parse subfield * Display field description hachoir-wx 0.1.2 ================ Fix setup.py: also install hachoir_wx.xrc hachoir-wx 0.1.1 ================ Bugfixes: * Fix setup.py: install submodules! * setup.py uses distutils by default (and not setuptools) * Add some missing imports * Fix few typo errors hachoir-wx 0.1 Initial Release (all platforms) ============================================== Features: * Lazy-loaded hex view, meaning you can view a 20GB file and memory usage will remain constant, and the GUI will remain responsive. * Dynamic type conversion, meaning (for example) you can take a RawBytes field of size 4 and convert it to a UInt32 for a better look at your data. * Field splitting, meaning you can take a RawBytes range and split it into smaller ranges. This feature in conjunction with dynamic type conversion allows you to explore unknown binary formats more easily. * Field view that allows you to browse a binary file just like a directory. * Minor stuff like hex/dec view of addresses, absolute/relative field offsets, auto-resizing field view columns that stretch to the size of your data, etc. * Hex view automatically scrolls to and highlights the hex data of the currently selected field (called "marking".) * Field dumping, meaning you can select any field inside your binary file and save it on your hard disk for further examination/analysis/etc. Bugs: * [All]: Field view "Merge Down" doesn't work. * [Windows only]: Hex view only shows a ~4x5 char display of the data. This is believed to be due to a wxWidgets bugs related to text wrapping. * [Windows only]: Right-click context menu doesn't work. * [Windows only]: Hex view data marking doesn't work. * [Gtk only]: Hex view will occasionally show two scrollbars for the hex view if you resize the very quickly. This is likely a bug in wxGtk that (for some reason) ignores the "no vertical scrollbar" directive for text controls. Platform: UNKNOWN Classifier: Intended Audience :: Developers Classifier: Development Status :: 4 - Beta Classifier: Environment :: X11 Applications Classifier: Environment :: Win32 (MS Windows) Classifier: Environment :: MacOS X Classifier: Topic :: Software Development :: Disassemblers Classifier: Topic :: Utilities Classifier: License :: OSI Approved :: GNU General Public License (GPL) Classifier: Operating System :: OS Independent Classifier: Natural Language :: English Classifier: Programming Language :: Python hachoir-wx-0.3/hachoir_wx.egg-info/SOURCES.txt0000644000175000017500000000342511057463346020175 0ustar haypohaypoAUTHORS COPYING README hachoir-wx setup.py hachoir_wx/__init__.py hachoir_wx/app.py hachoir_wx/dialogs.py hachoir_wx/dispatcher.py hachoir_wx/unicode.py hachoir_wx/version.py hachoir_wx.egg-info/PKG-INFO hachoir_wx.egg-info/SOURCES.txt hachoir_wx.egg-info/dependency_links.txt hachoir_wx.egg-info/requires.txt hachoir_wx.egg-info/top_level.txt hachoir_wx.egg-info/zip-safe hachoir_wx/field_view/__init__.py hachoir_wx/field_view/core_type_menu.py hachoir_wx/field_view/core_type_menu_fwd.py hachoir_wx/field_view/core_type_menu_imp.py hachoir_wx/field_view/field_menu.py hachoir_wx/field_view/field_menu_fwd.py hachoir_wx/field_view/field_menu_imp.py hachoir_wx/field_view/field_menu_setup.py hachoir_wx/field_view/field_split_menu.py hachoir_wx/field_view/field_split_menu_fwd.py hachoir_wx/field_view/field_split_menu_imp.py hachoir_wx/field_view/field_view.py hachoir_wx/field_view/field_view_fwd.py hachoir_wx/field_view/field_view_imp.py hachoir_wx/field_view/field_view_setup.py hachoir_wx/field_view/format.py hachoir_wx/field_view/mutator.py hachoir_wx/field_view/stubs.py hachoir_wx/frame_view/__init__.py hachoir_wx/frame_view/frame_view.py hachoir_wx/frame_view/frame_view_fwd.py hachoir_wx/frame_view/frame_view_imp.py hachoir_wx/frame_view/frame_view_setup.py hachoir_wx/hex_view/__init__.py hachoir_wx/hex_view/compat_all.py hachoir_wx/hex_view/compat_gtk.py hachoir_wx/hex_view/hex_view.py hachoir_wx/hex_view/hex_view_fwd.py hachoir_wx/hex_view/hex_view_imp.py hachoir_wx/hex_view/hex_view_scroll.py hachoir_wx/hex_view/hex_view_scroll_fwd.py hachoir_wx/hex_view/hex_view_scroll_imp.py hachoir_wx/hex_view/hex_view_scroll_setup.py hachoir_wx/hex_view/hex_view_setup.py hachoir_wx/hex_view/stubs.py hachoir_wx/resource/__init__.py hachoir_wx/resource/hachoir_wx.xrc hachoir_wx/resource/resource.py hachoir-wx-0.3/hachoir_wx.egg-info/dependency_links.txt0000644000175000017500000000000111057463346022353 0ustar haypohaypo hachoir-wx-0.3/hachoir_wx.egg-info/requires.txt0000644000175000017500000000006711057463346020710 0ustar haypohaypohachoir-core>=1.2 hachoir-parser>=0.7.0 wxPython>=2.6.3hachoir-wx-0.3/hachoir_wx.egg-info/top_level.txt0000644000175000017500000000001311057463346021031 0ustar haypohaypohachoir_wx hachoir-wx-0.3/hachoir_wx.egg-info/zip-safe0000644000175000017500000000000111057463346017735 0ustar haypohaypo hachoir-wx-0.3/AUTHORS0000644000175000017500000000024411057463311013520 0ustar haypohaypoCyril Zorin Julien Muchembled Victor Stinner aka haypo hachoir-wx-0.3/COPYING0000644000175000017500000004313311057463311013507 0ustar haypohaypo GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. hachoir-wx-0.3/README0000644000175000017500000000503211057463311013330 0ustar haypohaypohachoir-wx is a wxWidgets-based program that's meant to provide a (more) user-friendly interface to the facilities provided by the hachoir binary parser core. For latest updates, to ask for a feature (please do!), and bleeding(-edge) source code see the website: http://hachoir.org/wiki/hachoir-wx Everyone is very welcome to contribute code =) hachoir-wx 0.3 ============== * Use the new getFieldType() method of hachoir-core 1.2 to display better informations about the field type, eg. shows the string charset hachoir-wx 0.2 ============== * hachoir-wx is now able to parse subfield * Display field description hachoir-wx 0.1.2 ================ Fix setup.py: also install hachoir_wx.xrc hachoir-wx 0.1.1 ================ Bugfixes: * Fix setup.py: install submodules! * setup.py uses distutils by default (and not setuptools) * Add some missing imports * Fix few typo errors hachoir-wx 0.1 Initial Release (all platforms) ============================================== Features: * Lazy-loaded hex view, meaning you can view a 20GB file and memory usage will remain constant, and the GUI will remain responsive. * Dynamic type conversion, meaning (for example) you can take a RawBytes field of size 4 and convert it to a UInt32 for a better look at your data. * Field splitting, meaning you can take a RawBytes range and split it into smaller ranges. This feature in conjunction with dynamic type conversion allows you to explore unknown binary formats more easily. * Field view that allows you to browse a binary file just like a directory. * Minor stuff like hex/dec view of addresses, absolute/relative field offsets, auto-resizing field view columns that stretch to the size of your data, etc. * Hex view automatically scrolls to and highlights the hex data of the currently selected field (called "marking".) * Field dumping, meaning you can select any field inside your binary file and save it on your hard disk for further examination/analysis/etc. Bugs: * [All]: Field view "Merge Down" doesn't work. * [Windows only]: Hex view only shows a ~4x5 char display of the data. This is believed to be due to a wxWidgets bugs related to text wrapping. * [Windows only]: Right-click context menu doesn't work. * [Windows only]: Hex view data marking doesn't work. * [Gtk only]: Hex view will occasionally show two scrollbars for the hex view if you resize the very quickly. This is likely a bug in wxGtk that (for some reason) ignores the "no vertical scrollbar" directive for text controls. hachoir-wx-0.3/hachoir-wx0000755000175000017500000000162211057463311014450 0ustar haypohaypo#!/usr/bin/env python # -*- coding: utf-8 -*- from hachoir_wx.app import app_t from hachoir_wx.version import PACKAGE, VERSION, WEBSITE from hachoir_core.cmd_line import (getHachoirOptions, configureHachoir, unicodeFilename) from optparse import OptionParser import sys def parseOptions(): parser = OptionParser(usage="%prog [options] [filename]") hachoir = getHachoirOptions(parser) parser.add_option_group(hachoir) values, arguments = parser.parse_args() if len(arguments) == 1: filename = arguments[0] elif not arguments: filename = None else: parser.print_help() sys.exit(1) return values, filename def main(): print "%s version %s" % (PACKAGE, VERSION) print WEBSITE print values, filename = parseOptions() configureHachoir(values) app = app_t(filename) app.MainLoop() if __name__ == '__main__': main() hachoir-wx-0.3/setup.py0000755000175000017500000000400211057463311014161 0ustar haypohaypo#!/usr/bin/env python from imp import load_source from os import path from sys import argv if "--setuptools" in argv: argv.remove("--setuptools") from setuptools import setup use_setuptools = True else: from distutils.core import setup use_setuptools = False CLASSIFIERS = [ 'Intended Audience :: Developers', 'Development Status :: 4 - Beta', 'Environment :: X11 Applications', 'Environment :: Win32 (MS Windows)', 'Environment :: MacOS X', 'Topic :: Software Development :: Disassemblers', 'Topic :: Utilities', 'License :: OSI Approved :: GNU General Public License (GPL)', 'Operating System :: OS Independent', 'Natural Language :: English', 'Programming Language :: Python'] MODULES = ("field_view", "frame_view", "hex_view", "resource") def main(): hachoir_wx = load_source("version", path.join("hachoir_wx", "version.py")) PACKAGES = {"hachoir_wx": "hachoir_wx"} for name in MODULES: PACKAGES["hachoir_wx." + name] = path.join("hachoir_wx", name) install_options = { "name": hachoir_wx.PACKAGE, "version": hachoir_wx.VERSION, "url": hachoir_wx.WEBSITE, "download_url": hachoir_wx.WEBSITE, "license": hachoir_wx.LICENSE, "author": "Cyril Zorin", "description": "hachoir-wx is a wxWidgets GUI that's meant to provide a (more) user-friendly interface to the hachoir binary parsing engine", "long_description": open('README').read(), "classifiers": CLASSIFIERS, "scripts": ["hachoir-wx"], "packages": PACKAGES.keys(), "package_dir": PACKAGES, "package_data": {"hachoir_wx.resource": ['hachoir_wx.xrc']}, } if use_setuptools: install_options["install_requires"] = ( "hachoir-core>=1.2", "hachoir-parser>=0.7.0", "wxPython>=2.6.3") install_options["zip_safe"] = True install_options["include_package_data"] = True setup(**install_options) if __name__ == "__main__": main() hachoir-wx-0.3/PKG-INFO0000644000175000017500000000770211057463347013564 0ustar haypohaypoMetadata-Version: 1.0 Name: hachoir-wx Version: 0.3 Summary: hachoir-wx is a wxWidgets GUI that's meant to provide a (more) user-friendly interface to the hachoir binary parsing engine Home-page: http://hachoir.org/wiki/hachoir-wx Author: Cyril Zorin Author-email: UNKNOWN License: GNU GPL v2 Download-URL: http://hachoir.org/wiki/hachoir-wx Description: hachoir-wx is a wxWidgets-based program that's meant to provide a (more) user-friendly interface to the facilities provided by the hachoir binary parser core. For latest updates, to ask for a feature (please do!), and bleeding(-edge) source code see the website: http://hachoir.org/wiki/hachoir-wx Everyone is very welcome to contribute code =) hachoir-wx 0.3 ============== * Use the new getFieldType() method of hachoir-core 1.2 to display better informations about the field type, eg. shows the string charset hachoir-wx 0.2 ============== * hachoir-wx is now able to parse subfield * Display field description hachoir-wx 0.1.2 ================ Fix setup.py: also install hachoir_wx.xrc hachoir-wx 0.1.1 ================ Bugfixes: * Fix setup.py: install submodules! * setup.py uses distutils by default (and not setuptools) * Add some missing imports * Fix few typo errors hachoir-wx 0.1 Initial Release (all platforms) ============================================== Features: * Lazy-loaded hex view, meaning you can view a 20GB file and memory usage will remain constant, and the GUI will remain responsive. * Dynamic type conversion, meaning (for example) you can take a RawBytes field of size 4 and convert it to a UInt32 for a better look at your data. * Field splitting, meaning you can take a RawBytes range and split it into smaller ranges. This feature in conjunction with dynamic type conversion allows you to explore unknown binary formats more easily. * Field view that allows you to browse a binary file just like a directory. * Minor stuff like hex/dec view of addresses, absolute/relative field offsets, auto-resizing field view columns that stretch to the size of your data, etc. * Hex view automatically scrolls to and highlights the hex data of the currently selected field (called "marking".) * Field dumping, meaning you can select any field inside your binary file and save it on your hard disk for further examination/analysis/etc. Bugs: * [All]: Field view "Merge Down" doesn't work. * [Windows only]: Hex view only shows a ~4x5 char display of the data. This is believed to be due to a wxWidgets bugs related to text wrapping. * [Windows only]: Right-click context menu doesn't work. * [Windows only]: Hex view data marking doesn't work. * [Gtk only]: Hex view will occasionally show two scrollbars for the hex view if you resize the very quickly. This is likely a bug in wxGtk that (for some reason) ignores the "no vertical scrollbar" directive for text controls. Platform: UNKNOWN Classifier: Intended Audience :: Developers Classifier: Development Status :: 4 - Beta Classifier: Environment :: X11 Applications Classifier: Environment :: Win32 (MS Windows) Classifier: Environment :: MacOS X Classifier: Topic :: Software Development :: Disassemblers Classifier: Topic :: Utilities Classifier: License :: OSI Approved :: GNU General Public License (GPL) Classifier: Operating System :: OS Independent Classifier: Natural Language :: English Classifier: Programming Language :: Python hachoir-wx-0.3/setup.cfg0000644000175000017500000000007311057463347014302 0ustar haypohaypo[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0