Mpjy dZdZddlZddlZejj ejj ejjeZ ejj ejje dZ e ejvrejjde ddl Z ejddk\reZdZndZdZd Zd jed Dcgc].}eee|d kxr|d k\xre|xsd0c}ZddZddZddZdZedk(reyycc}w)a ezhexviewer.py A simple hexadecimal viewer based on easygui. It should work on any platform with Python 2.x or 3.x. Usage: ezhexviewer.py [file] Usage in a python application: import ezhexviewer ezhexviewer.hexview_file(filename) ezhexviewer.hexview_data(data) ezhexviewer project website: http://www.decalage.info/python/ezhexviewer ezhexviewer is copyright (c) 2012-2019, Philippe Lagadec (http://www.decalage.info) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. z0.54Nz..TFc<t|tr|St|S)a{ workaround for ord() to work on characters from a bytes string with Python 2 and 3. If s is a bytes string, s[i] is a bytes string of length 1 on Python 2, but it is an integer on Python 3... xord(c) returns ord(c) if c is a bytes string, or c if it is already an integer. :param char: int or bytes of length 1 :return: ord(c) if bytes, c if int ) isinstanceintord)chars b/mnt/ssd/data/Dropbox/adrian/scripts/msg_venv/lib/python3.12/site-packages/oletools/ezhexviewer.pyxordr Ws$ 4yc<tr t|gSt|S)a! workaround for chr() to return a bytes string of length 1 with Python 2 and 3. On Python 3, chr returns a unicode string, but on Python 2 it is a bytes string. bchr() always returns a bytes string on Python 2+3. :param x: int :return: chr(x) as a bytes string )PYTHON3byteschrxs r bchrrfsaSz1v r r  .c bg}tdt||D]}||||z}dj|Dcgc]}dt|zc}}|j t }t r|jd}|jd||z|dz||fzdj|Scc}w)z Returns a hexadecimal dump of a binary string. length: number of bytes per row. startindex: index of 1st byte. r z%02Xlatin1z%08X %-*s %s r) xrangelenjoinr translateFILTERr decodeappend) srclength startindexresultisrhexa printables r hexdump3r*s F As3x (X !F(Oxx15a$q')56KK' !((2I *a lF1HdI-VVWX 776? 6sB, cPt|||}tj|||y)N)r#r$)msgtitletext)r*easyguicodebox)datar,r-r#r$hexs r hexview_datar3s 4: >C OO5s3r cXt|dj}t|||||y)Nrb)r,r-r#r$)openreadr3)filenamer,r-r#r$r1s r hexview_filer9s' $  $ $ &D3eFzRr c tjd}|r t |d|zyy#tj}Y-xYw#tj ddYyxYw)NzFile: %s)r,zError: ezhexviewer)r,r-)sysargvr/ fileopenboxr9 exceptionbox)r8s r mainrAs_)88A; D zH'< =)&&( D  X] Cs*AAA __main__)r)rr<r)__doc__ __version__r=ospathnormpathabspathdirname__file___thismodule_dirr _parent_dirinsertr/ version_inforangerr r rrreprrr*r3r9rA__name__rs0r rTs:'f ''""277??277??83L#MNggrww||OTBC chhHHOOA{#A!FGG 0 TYZ]T^_qCT!W &)5agB47JdJ_ `,4 S D zFa`s13E