diff options
| -rw-r--r-- | example/jitter/memstruct.py | 2 | ||||
| -rw-r--r-- | miasm2/analysis/mem.py | 13 |
2 files changed, 9 insertions, 6 deletions
diff --git a/example/jitter/memstruct.py b/example/jitter/memstruct.py index f2e9f8dc..775b3643 100644 --- a/example/jitter/memstruct.py +++ b/example/jitter/memstruct.py @@ -184,7 +184,7 @@ assert link.size == 2 # Make the Array Ptr point to the data's array field data.arrayptr = data.get_addr("array") # Now the pointer dereference is equal to the array field's value -assert data.deref_arrayptr == data.array +assert data.deref_arrayptr.value == data.array # Let's say that it is a DataStr: datastr = data.cast(DataStr) diff --git a/miasm2/analysis/mem.py b/miasm2/analysis/mem.py index 2e52ec1a..86db0fc5 100644 --- a/miasm2/analysis/mem.py +++ b/miasm2/analysis/mem.py @@ -875,11 +875,7 @@ class MemStruct(object): return '%r:\n' % self.__class__ + indent('\n'.join(out), 2) def __eq__(self, other): - # Do not test class equality, because of dynamically generated fields - # self.__class__ == other.__class__ and - # Could test attrs? - # TODO: self._attrs == other._attrs and - return str(self) == str(other) + return self.__class__ == other.__class__ and str(self) == str(other) def __ne__(self, other): return not self == other @@ -1216,6 +1212,13 @@ class MemSizedArray(MemArray): items = ', '.join(item_reprs) return "[%s] [%r; %s]" % (items, self._field_type, self._array_len) + def __eq__(self, other): + # Special implementation to handle dynamic subclasses + return isinstance(other, MemSizedArray) and \ + self._field_type == other._field_type and \ + self._array_len == other._array_len and \ + str(self) == str(other) + def mem_array_type(field_type): """Generate a MemArray subclass that has a fixed @field_type. It allows to |