utilities
¶
This modules provides utility functions for a variety of purposes.
Functions¶
-
align_down
(number, alignment=16)[source]¶ Subtract from number so it is divisible by alignment.
Parameters: Returns: The modified value.
Return type:
-
align_up
(number, alignment=16)[source]¶ Add to number so it is divisible by alignment.
Parameters: Returns: The modified value.
Return type:
-
architecture_is_32bit
(arch)[source]¶ Check if the architecture specified in arch is 32-bit.
Parameters: arch (str) – The value to check. Return type: bool
-
architecture_is_64bit
(arch)[source]¶ Check if the architecture specified in arch is 64-bit.
Parameters: arch (str) – The value to check. Return type: bool
-
eval_number
(number)[source]¶ Evaluate a numerical expressions in different string formats indicating base.
Parameters: number (str) – The string to evaluate. Returns: The converted value. Return type: int
-
print_hexdump
(data, address=0, stream=None)[source]¶ Print data to stdout in a visually pleasant hex format.
Parameters:
-
struct_pack
(structure)[source]¶ Pack a
ctypes.Structure
object and convert it to a packed string.Parameters: structure ( ctypes.Structure
) – The structure instance to convertReturns: The structure instance converted to a string. Return type: str
-
struct_unpack
(structure, raw_data)[source]¶ Convert raw_data to an instance of structure.
Parameters: - structure (
ctypes.Structure
) – The structure that describes raw_data. - raw_data (str) – The binary string which contains the structures data.
Returns: A new instance of structure.
Return type: - structure (