hiew 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hiew/__init__.py +2 -0
- hiew/__main__.py +83 -0
- hiew/app.py +1828 -0
- hiew/buffer.py +237 -0
- hiew/disasm.py +315 -0
- hiew/extra.py +910 -0
- hiew/formats.py +640 -0
- hiew/keys.py +287 -0
- hiew/mods.py +230 -0
- hiew/spec.py +1807 -0
- hiew/themes.py +132 -0
- hiew/xrefs.py +321 -0
- hiew-1.0.0.dist-info/METADATA +244 -0
- hiew-1.0.0.dist-info/RECORD +18 -0
- hiew-1.0.0.dist-info/WHEEL +5 -0
- hiew-1.0.0.dist-info/entry_points.txt +2 -0
- hiew-1.0.0.dist-info/licenses/LICENSE +21 -0
- hiew-1.0.0.dist-info/top_level.txt +1 -0
hiew/__init__.py
ADDED
hiew/__main__.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import glob
|
|
3
|
+
import locale
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def main(argv=None):
|
|
9
|
+
p = argparse.ArgumentParser(prog='hiew', description="Hiew - cross-platform Hacker's View: hex viewer, editor and disassembler")
|
|
10
|
+
from . import __version__
|
|
11
|
+
p.add_argument('-V', '--version', action='version', version='%(prog)s ' + __version__)
|
|
12
|
+
p.add_argument('files', nargs='*', help='file(s) to open; Ctrl+F11 / Ctrl+F12 switch between them')
|
|
13
|
+
p.add_argument('--keys', action='store_true', help='key test: show how key presses are recognised')
|
|
14
|
+
p.add_argument('-m', '--mode', choices=('text', 'hex', 'decode'), help='start mode')
|
|
15
|
+
p.add_argument('-o', '--offset', help='start position: hex offset, .VA or symbol name')
|
|
16
|
+
p.add_argument('-e', '--entry', action='store_true', help='start at the entry point in decode mode')
|
|
17
|
+
p.add_argument('-a', '--arch', help='disassembler architecture (x86-16/32/64, arm, thumb, arm64, mips32, ...)')
|
|
18
|
+
p.add_argument('-s', '--slice', help='universal (fat) Mach-O: slice to open, by cpu name (x86_64, arm64) or number')
|
|
19
|
+
p.add_argument('--no-mouse', dest='mouse', action='store_false', help='do not capture the mouse')
|
|
20
|
+
p.add_argument('-t', '--theme', choices=('hiew', 'blue', 'dark', 'light'),
|
|
21
|
+
help='colour theme (default: the last one chosen in F4, else hiew); F4 switches it live')
|
|
22
|
+
p.add_argument('--colors', choices=('auto', 'classic', '8'), default='auto',
|
|
23
|
+
help='auto: 256-colour palette; classic: DOS blue; 8: 8-colour variant of the theme')
|
|
24
|
+
p.add_argument('--no-modpoll', dest='modpoll', action='store_false',
|
|
25
|
+
help='do not read Alt/Ctrl/Shift state from the OS (live keybar)')
|
|
26
|
+
p.add_argument('--no-kitty', dest='kitty', action='store_false',
|
|
27
|
+
help='do not enable the kitty keyboard protocol (live Alt/Ctrl keybar over ssh)')
|
|
28
|
+
opts = p.parse_args(argv)
|
|
29
|
+
|
|
30
|
+
files = []
|
|
31
|
+
for f in opts.files:
|
|
32
|
+
files += sorted(glob.glob(f)) if any(c in f for c in '*?[') else [f]
|
|
33
|
+
opts.files = files
|
|
34
|
+
if not opts.keys and not files:
|
|
35
|
+
p.error('a file is required')
|
|
36
|
+
for f in files if not opts.keys else []:
|
|
37
|
+
if not os.path.isfile(f):
|
|
38
|
+
p.error('not a file: %s' % f)
|
|
39
|
+
opts.file = files[0] if files else None
|
|
40
|
+
from .disasm import ARCHS
|
|
41
|
+
if opts.arch and opts.arch not in ARCHS:
|
|
42
|
+
p.error('unknown arch %s, choose from: %s' % (opts.arch, ', '.join(ARCHS)))
|
|
43
|
+
|
|
44
|
+
if not opts.modpoll:
|
|
45
|
+
os.environ['HIEW_NO_MODPOLL'] = '1'
|
|
46
|
+
try: # Backspace sends DEL -> a ^H can only be Ctrl+Backspace
|
|
47
|
+
import termios
|
|
48
|
+
from . import keys as K
|
|
49
|
+
K.CTRL_H_IS_CBS = termios.tcgetattr(sys.stdin.fileno())[6][termios.VERASE] in (b'\x7f', 127)
|
|
50
|
+
except Exception:
|
|
51
|
+
pass
|
|
52
|
+
locale.setlocale(locale.LC_ALL, '')
|
|
53
|
+
os.environ.setdefault('ESCDELAY', '25')
|
|
54
|
+
try:
|
|
55
|
+
import curses
|
|
56
|
+
except ImportError:
|
|
57
|
+
sys.exit('curses is missing. On Windows run: pip install windows-curses')
|
|
58
|
+
from .spec import Hiew
|
|
59
|
+
|
|
60
|
+
def run(scr):
|
|
61
|
+
try:
|
|
62
|
+
curses.set_escdelay(25) # novermin (Python 3.9+, guarded)
|
|
63
|
+
except Exception:
|
|
64
|
+
pass
|
|
65
|
+
try:
|
|
66
|
+
curses.raw()
|
|
67
|
+
curses.nonl() # keep Enter (\r) and Ctrl+Enter / Ctrl+J (\n) apart
|
|
68
|
+
except curses.error:
|
|
69
|
+
pass
|
|
70
|
+
if opts.keys:
|
|
71
|
+
from .mods import keytest
|
|
72
|
+
keytest(scr, opts)
|
|
73
|
+
else:
|
|
74
|
+
Hiew(scr, opts.file, opts).run()
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
curses.wrapper(run)
|
|
78
|
+
except KeyboardInterrupt:
|
|
79
|
+
pass
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
if __name__ == '__main__':
|
|
83
|
+
main()
|