From 8e9322ed8b5826dd62bc931d83e0828d42f7969f Mon Sep 17 00:00:00 2001 From: Andrew Lamoureux Date: Mon, 18 Mar 2019 17:31:29 -0400 Subject: kaitai: gif, jpg, png support and return proper priority --- python/examples/kaitai/view.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'python/examples/kaitai/view.py') diff --git a/python/examples/kaitai/view.py b/python/examples/kaitai/view.py index 888049ac..f861b275 100644 --- a/python/examples/kaitai/view.py +++ b/python/examples/kaitai/view.py @@ -207,12 +207,28 @@ class KaitaiViewType(ViewType): # data.file: FileMetadata # data.raw: BinaryView - if binaryView == binaryView.file.raw: - #print 'returning priority=100 for FileView' - return 100 - else: - #print 'returning priority 0, not given a raw view' - return 0 + priority = 0 + isExec = binaryView.executable + weRecognize = kshelpers.id_data(binaryView.read(0,16)) != None + + # NOTE: ui/shared/hexeditor.cpp has the hex editor at priority 20 when + # executable, and 10 otherwise + + if isExec and weRecognize: + #print 'priority=25 to slightly beat out the hex editor case=(executable, recognize)' + priority = 25 + if isExec and not weRecognize: + #print 'priority=15 to lose to the hex editor case=(executable, !recognize)' + priority = 15 + if not isExec and weRecognize: + #print 'priority=100 to beat out everything case=(!executable, recognize)' + priority = 100 + if not isExec and not weRecognize: + #print 'priority=5 to lose to hex editor case=(!executable, !recognize)' + priority = 5 + + #print 'returning priority=%d for KaitaiViewType' % priority + return priority def create(self, binaryView, view_frame): return KaitaiView(view_frame, binaryView) -- cgit v1.3.1