Module hiew
[frames] | no frames]

Module hiew

Classes
  Control
Hiew control class
  Menu
Menu control
  Window
Window control
  Data
Class representing HIEWGATE_GETDATA
  Names
Name management class
Functions
 
FileOpenForWrite()
Reopens file for writing
 
FileRead(offset, bytes)
Reads from the file
 
FileWrite(offset, buf)
Writes buffer to file
 
GetData()
Returns a Data class instance see HIEWGATE_GETDATA structure
 
GetLastResult()
 
Message(title, msg)
Displays single-line message to user
 
MarkBlock(offset1, offset2)
Marks a block
 
UnmarkBlock()
Unmarks selection
 
Find(flags, offset, data, mask=None)
Returns: None - not found Offset - offset of the match
 
FindNext()
Returns the find next offset or None
 
GetString(title, max_input, init_val='')
Gets one line of user input
 
GetStringDual(title, max_input, init_val='', on_hex_line=False)
Gets ascii/hex line from user
 
GetFilename(title, filename='')
Gets line with filename.
 
HiewGate_IsKeyBreak()
Checks if the wait dialog is cancelled
 
MessageWaitOpen(msg='')
Open single-line message to user.
 
MessageWaitClose()
 
SetErrorMsg(error_msg)
 
MessageBox(message, title='Info')
 
dbg(msg)
Output debug string
 
ReturnOffset(offset)
Changes the offset upon the script termination
 
ReturnMode(mode)
Changes the view mode upon script termination
 
ReturnCode(rc)
Changes the return code upon script termination
 
ReturnReload()
Reloads the file upon script termination
 
AskYesNo(msg, title='Please confirm', width=70, yesno_keys={1: 'Yes', 2: 'No'})
Creates a window and prompts the user to answer Yes or No
 
PyHiew_ExecuteScript(script, g, strip_path=False)
Executes a script file and captures the error
 
PyHiew_ExecuteCallable(func_name, g, *args, **kwargs)
Executes a callable and captures the error
 
PyHiew_GetScriptFileName(script)
Given a script name it returns its full path relative to PYHIEW_PATH
 
SetStartupScript(st_script, st_dict, st_func)
 
PyHiew_Main()
Main entry point of PyHiew
Variables
  VERSION = {'major': 8, 'majorsdk': 0, 'minor': 10, 'minorsdk':...
  PYHIEW_PATH = 'C:\\projects\\framework\\PyHiew\\src'
  PYHIEW_VERSION = {'major': 8, 'majorsdk': 0, 'minor': 10, 'min...
  PYHIEW_RELOAD_STARTUP_SCRIPT = True
  PYHIEW_SHOW_EXEC_ERRORS = False
  HEM_MAX_DUALSTR_LEN = 20
  HEM_MAX_FINDSTR_LEN = 20
  PYHIEW_STARTUP_SCRIPT = None
  PYHIEW_STARTUP_DICT = None
  PYHIEW_STARTUP_FUNCTION = None
  PYHIEW_STARTUP_SCRIPT_EXECUTED = False
  PYHIEW_EXCLUDED_SCRIPTS = set(['_hiew', 'hiew', 'init'])
  HIEW_KEY_LABEL_LEN = 6
  HIEW_EMPTY_KEY_LABEL = ' '
  HEM_FNKEY_DELIMITER = '|'
  HEM_FNKEY_F1 = 65339
  HEM_FNKEY_F2 = 65340
  HEM_FNKEY_F3 = 65341
  HEM_FNKEY_F4 = 65342
  HEM_FNKEY_F5 = 65343
  HEM_FNKEY_F6 = 65344
  HEM_FNKEY_F7 = 65345
  HEM_FNKEY_F8 = 65346
  HEM_FNKEY_F9 = 65347
  HEM_FNKEY_F10 = 65348
  HEM_FNKEY_F11 = 65413
  HEM_FNKEY_F12 = 65414
  HEM_FNKEY_ALTF1 = 65384
  HEM_FNKEY_ALTF2 = 65385
  HEM_FNKEY_ALTF3 = 65386
  HEM_FNKEY_ALTF4 = 65387
  HEM_FNKEY_ALTF5 = 65388
  HEM_FNKEY_ALTF6 = 65389
  HEM_FNKEY_ALTF7 = 65390
  HEM_FNKEY_ALTF8 = 65391
  HEM_FNKEY_ALTF9 = 65392
  HEM_FNKEY_ALTF10 = 65393
  HEM_FNKEY_ALTF11 = 65419
  HEM_FNKEY_ALTF12 = 65420
  HEM_FNKEY_CTRLF1 = 65374
  HEM_FNKEY_CTRLF2 = 65375
  HEM_FNKEY_CTRLF3 = 65376
  HEM_FNKEY_CTRLF4 = 65377
  HEM_FNKEY_CTRLF5 = 65378
  HEM_FNKEY_CTRLF6 = 65379
  HEM_FNKEY_CTRLF7 = 65380
  HEM_FNKEY_CTRLF8 = 65381
  HEM_FNKEY_CTRLF9 = 65382
  HEM_FNKEY_CTRLF10 = 65383
  HEM_FNKEY_CTRLF11 = 65417
  HEM_FNKEY_CTRLF12 = 65418
  HEM_FNKEY_SHIFTF1 = 65364
  HEM_FNKEY_SHIFTF2 = 65365
  HEM_FNKEY_SHIFTF3 = 65366
  HEM_FNKEY_SHIFTF4 = 65367
  HEM_FNKEY_SHIFTF5 = 65368
  HEM_FNKEY_SHIFTF6 = 65369
  HEM_FNKEY_SHIFTF7 = 65370
  HEM_FNKEY_SHIFTF8 = 65371
  HEM_FNKEY_SHIFTF9 = 65372
  HEM_FNKEY_SHIFTF10 = 65373
  HEM_FNKEY_SHIFTF11 = 65415
  HEM_FNKEY_SHIFTF12 = 65416
  HEM_SDK_VERSION_MAJOR = 0
  HEM_SDK_VERSION_MINOR = 46
  HEM_FILENAME_MAXLEN = 260
  HEM_SHORTNAME_SIZE = 16
  HEM_NAME_SIZE = 60
  HEM_ABOUT_SIZE = 48
  HEM_FLAG_MARKEDBLOCK = 2147483648
  HEM_FLAG_FILEMASK = 16344
  HEM_FLAG_ELF64 = 8192
  HEM_FLAG_PE64 = 4096
  HEM_FLAG_ELF = 2048
  HEM_FLAG_NLM = 1024
  HEM_FLAG_PE = 512
  HEM_FLAG_LX = 256
  HEM_FLAG_LE = 128
  HEM_FLAG_NE = 64
  HEM_FLAG_FILE = 16
  HEM_FLAG_DISK = 8
  HEM_FLAG_MODEMASK = 7
  HEM_FLAG_CODE = 4
  HEM_FLAG_HEX = 2
  HEM_FLAG_TEXT = 1
  HEM_RETURN_SETOFFSET = 1
  HEM_RETURN_FILERELOAD = 2
  HEM_RETURN_SETMODE = 4
  HEM_RETURN_MODE_TEXT = 1
  HEM_RETURN_MODE_HEX = 2
  HEM_RETURN_MODE_CODE = 3
  HEM_FIND_NEXT = 1
  HEM_FIND_BACKWARD = 2
  HEM_FIND_CASESENSITIVE = 4
  HEM_FIND_INMARK = 8
  HEM_FIND_USEMASK = 16
  HEM_ERR_INTERNAL = -21
  HEM_ERR_INVALID_ARGUMENT = -20
  HEM_ERR_HIEW_VERSION_INVALID = -19
  HEM_ERR_FNKEYS_INVALID = -18
  HEM_ERR_READONLYFILE = -17
  HEM_ERR_POINTER_IS_NULL = -16
  HEM_ERR_HIEWDATA_SIZE_MISMATCH = -15
  HEM_ERR_HEMINFO_SIZE_MISMATCH = -14
  HEM_ERR_HEMINFO_IS_NULL = -13
  HEM_ERR_HEM2HEMGATE_IS_NULL = -12
  HEM_ERR_HEM_NOTFOUND = -11
  HEM_ERR_HIEWGATE_PARM_INVALID = -10
  HEM_ERR_HIEWGATE_ID_INVALID = -9
  HEM_ERR_HANDLE_INVALID = -8
  HEM_ERR_NOADDRESS_HIEWGATE = -7
  HEM_ERR_NOENTRYPOINT = -6
  HEM_ERR_UNLOADED = -5
  HEM_ERR_SDKVER_INCOMPATIBLE = -4
  HEM_ERR_NOADDRESS_LOAD = -3
  HEM_ERR_LOADDLL = -2
  HEM_ERROR = -1
  HEM_OK = 0
  HEM_INPUT_ESC = 0
  HEM_INPUT_CR = 1
  HEM_KEYBREAK = 2
  HEM_OFFSET_NOT_FOUND = -1
  __package__ = None
Function Details

FileRead(offset, bytes)

 

Reads from the file

Parameters:
  • offset - file offset
  • bytes - amount of bytes to read
Returns:
  • (rc != HEM_OK, None)
  • (rc == HEM_OK, buffer)

FileWrite(offset, buf)

 

Writes buffer to file

Parameters:
  • offset - file offset
  • buf - buffer to write
Returns:
HEM_ERR_xxx

MarkBlock(offset1, offset2)

 

Marks a block

Parameters:
  • offset1 - start pos
  • offset2 - end pos
Returns:
HEM_ERR_xxx

UnmarkBlock()

 

Unmarks selection

Returns:
HEM_ERR_xxx

Find(flags, offset, data, mask=None)

 
Parameters:
  • flags - one of HEM_FIND_XXXX flags
  • offset - starting offset
  • data - data buffer to find ; len is max HEM_MAX_FINDSTR_LEN
  • mask - currently unused
Returns:
None - not found Offset - offset of the match

GetString(title, max_input, init_val='')

 

Gets one line of user input

Parameters:
  • title - prompt title
  • max_input - max input
  • init_val - initial input value
Returns:
string or None (if user pressed ESC)

GetStringDual(title, max_input, init_val='', on_hex_line=False)

 

Gets ascii/hex line from user

Parameters:
  • title - prompt title
  • max_input - max input; HEM_MAX_DUALSTR_LEN
  • init_val - initial input value (contains binary data)
  • on_hex_line - focus on hex line
Returns:
None (if user pressed ESC) tuple(1, string) if user pressed enter on the hex line tuple(0, string) if user pressed enter on the string line

GetFilename(title, filename='')

 

Gets line with filename. Hiew offers the F9 key to browse for a filename

Parameters:
  • title - prompt title
  • filename - initial filename value
Returns:
string or None

HiewGate_IsKeyBreak()

 

Checks if the wait dialog is cancelled

Returns:
Boolean

MessageWaitOpen(msg='')

 

Open single-line message to user.

Parameters:
  • msg - the wait message. If empty then message will "Processing..."

ReturnOffset(offset)

 

Changes the offset upon the script termination

Parameters:
  • offset - new offset

ReturnMode(mode)

 

Changes the view mode upon script termination

Parameters:
  • mode - one of HEM_RETURN_MODE_XXXX

ReturnCode(rc)

 

Changes the return code upon script termination

Parameters:
  • rc - one of HEM_ERR_XXX

AskYesNo(msg, title='Please confirm', width=70, yesno_keys={1: 'Yes', 2: 'No'})

 

Creates a window and prompts the user to answer Yes or No

Returns:
Boolean. False = No, True = Yes

PyHiew_ExecuteScript(script, g, strip_path=False)

 

Executes a script file and captures the error

Parameters:
  • script - script file name
  • g - the global scope
Returns:
  • None: execute successful
  • String: the exception and traceback

PyHiew_ExecuteCallable(func_name, g, *args, **kwargs)

 

Executes a callable and captures the error

Parameters:
  • func_name - script file name
  • g - the global scope
Returns:
  • None: execute successful
  • String: the exception and traceback

Variables Details

VERSION

Value:
{'major': 8, 'majorsdk': 0, 'minor': 10, 'minorsdk': 46}

PYHIEW_VERSION

Value:
{'major': 8, 'majorsdk': 0, 'minor': 10, 'minorsdk': 46}