def _create_vtable_struct(classinfo): """Create the ::vtable struct for a C++ class.""" sid = idau.struct_create(classinfo.classname + '::vtable') if sid is None: _log(0, 'Could not create {}::vtable', classinfo.classname) return False return _populate_vtable_struct(sid, classinfo)
def _set_class_style(style): """Set the global class style.""" global _style_was_set, _create_class_structs, _populate_class_structs assert style in (CLASS_SLICES, CLASS_UNIONS) # Check the current style based on OSObject, a class that should always exist. sid = idau.struct_open('OSObject') want_union = style == CLASS_UNIONS if sid is None: # No global style has been set. idau.struct_create('OSObject', union=want_union) else: # A style already exists. Check that the requested style matches. is_union = bool(idc.IsUnion(sid)) if is_union != want_union: raise ValueError('Incompatible style {}', style) # Set the appropriate functions based on the style. if style == CLASS_SLICES: _create_class_structs = _create_class_structs__slices _populate_class_structs = _populate_class_structs__slices else: _create_class_structs = _create_class_structs__unions _populate_class_structs = _populate_class_structs__unions