@@ -139,6 +139,22 @@ def __setitem__(self, index, value):
139139 raise_from (RuntimeError ('Unknown field {} in regs.x86'
140140 .format (index .name .lower ())), e )
141141
142+ def __str__ (self ):
143+ # Heuristic to determine the architecture
144+ if hasattr (self .cffi_regs .x86 , 'rip' ) or hasattr (self .cffi_regs .x86 , 'eip' ):
145+ regs_to_print = self .cffi_regs .x86
146+ elif hasattr (self .cffi_regs .arm , 'pc' ):
147+ regs_to_print = self .cffi_regs .arm
148+ else :
149+ raise RuntimeError ("Unable to determine architecture" )
150+ attributes = []
151+ for attr in dir (regs_to_print ):
152+ if not attr .startswith ('_' ):
153+ value = getattr (regs_to_print , attr )
154+ attributes .append (f"{ attr .lower ()} = { value :#x} " )
155+
156+ return '\n ' .join (attributes )
157+
142158
143159class VMIMode (Enum ):
144160 XEN = lib .VMI_XEN
@@ -150,6 +166,8 @@ class VMIConfig(Enum):
150166 GLOBAL_FILE_ENTRY = lib .VMI_CONFIG_GLOBAL_FILE_ENTRY
151167 STRING = lib .VMI_CONFIG_STRING
152168 DICT = lib .VMI_CONFIG_GHASHTABLE
169+ JSON_PATH = lib .VMI_CONFIG_JSON_PATH
170+ FILE_PATH = lib .VMI_CONFIG_FILE_PATH
153171
154172
155173class VMIStatus (Enum ):
@@ -318,8 +336,8 @@ def __init__(self, domain, init_flags=INIT_DOMAINNAME, init_data=None,
318336 # from str to bytes
319337 if init_flags & INIT_DOMAINNAME or init_flags & INIT_DOMAINID :
320338 domain = domain .encode ()
321- # same for VMI_CONFIG_STRING
322- if config_mode == VMIConfig .STRING :
339+ # same for VMI_CONFIG_STRING | VMI_CONFIG_FILE_PATH | VMI_CONFIG_JSON_PATH
340+ if config_mode in [ VMIConfig .STRING , VMIConfig . FILE_PATH , VMIConfig . JSON_PATH ] :
323341 config = config .encode ()
324342 elif config_mode == VMIConfig .DICT :
325343 # need to convert config to a GHashTable
0 commit comments