MCPcopy Index your code
hub / github.com/qilingframework/qiling / __getattribute__

Method __getattribute__

qiling/os/struct.py:94–116  ·  view source on GitHub ↗
(self, name: str)

Source from the content-addressed store, hash-verified

92 """
93
94 def __getattribute__(self, name: str) -> Any:
95 # accessing a structure field?
96 if name in _fields:
97 field = cls.__dict__[name]
98 ftype = _fields[name]
99
100 if issubclass(ftype, BaseStruct):
101 fvalue = ftype.volatile_ref(mem, address + field.offset)
102
103 else:
104 # load field's bytes from memory and tranform them into a value
105 data = mem.read(address + field.offset, field.size)
106 fvalue = ftype.from_buffer(data)
107
108 if hasattr(fvalue, 'value'):
109 fvalue = fvalue.value
110
111 # set the value to the structure in order to maintain consistency with ctypes.Structure
112 super().__setattr__(name, fvalue)
113 return fvalue
114
115 # return attribute value
116 return super().__getattribute__(name)
117
118 def __setattr__(self, name: str, value: Any) -> None:
119 # accessing a structure field?

Callers 5

__getattr__Method · 0.80
__getattr__Method · 0.80
__getattr__Method · 0.80
__getitem__Method · 0.80

Calls 3

volatile_refMethod · 0.80
readMethod · 0.45
__setattr__Method · 0.45

Tested by

no test coverage detected