Module BCHByteUtilities

Utility functions to read and write binary data

get_aligned_address dw returns the smallest multiple of 16 greater than or equal to the value of dw, represented as a doubleword

get_1kaligned_address dw returns the smallest multiple of 1024 greater than or equal to the value of dw, represented as a doubleword

val rawdata_to_string : ?markwritten:BCHLibTypes.doubleword_int list -> string -> BCHLibTypes.doubleword_int -> string
val write_xml_raw_data : CHXmlDocument.xml_element_int -> string -> BCHLibTypes.doubleword_int -> unit

write_xml_raw_data elt s dw writes byte string s to the xml element elt in the form of sub elements with tag aline and attributes ytes and print that contain 4 space-separated groups of 4 bytes in hexadecimal and a print represenation of those 16 bytes, respectively.

This format is used in saving binary content of the sections to xml.

val write_doubleword_to_bytestring : BCHLibTypes.doubleword_int -> string

write_doubleword_to_bytestring dw writes the constituting four bytes to a bytestring, least significant byte first.

val write_hex_bytes_to_bytestring : string -> string

write_hex_bytes_to_bytestring s converts the hexadecimal byte representation in s to a string of bytes.

val read_xml_raw_data : CHXmlDocument.xml_element_int -> string

read_xml_raw_data elt reads data written by write_xml_raw_data and returns the original byte string.

val byte_string_to_spaced_string : string -> string

byte_string_to_spaced_string s writes the byte string s to hexadecimal bytes separated by spaces.

val byte_string_to_printed_string : string -> string

byte_string_to_printed_string s writes the byte string s to hexadecimal bytes as a continuous string.

val littleendian_hexstring_todwstring : string -> string
val littleendian_hexstring_towstring : string -> string
val decode_string : string -> BCHLibTypes.doubleword_int -> (string * BCHLibTypes.doubleword_int * BCHLibTypes.doubleword_int * BCHLibTypes.doubleword_int * int) list -> string
val read_hex_stream_file : string -> string