[docs]classMemoryDataSort:Unspecified=NoneUnknown="unknown"Integer="integer"PointerArray="pointer-array"String="string"UnicodeString="unicode"SegmentBoundary="segment-boundary"CodeReference="code reference"GOTPLTEntry="GOT PLT Entry"ELFHeader="elf-header"FloatingPoint="fp"# the size is determined by the MemoryData itself
[docs]classMemoryData(Serializable):""" MemoryData describes the syntactic content of a single address of memory. `reference_size` reflects the size of `content`. It can be different from `size`, which is the actual size of the memory data item in memory. The intended way to get the actual content in memory is `self.content[:self.size]`. """__slots__=("addr","size","reference_size","sort","max_size","pointer_addr","content",)
[docs]defcopy(self):""" Make a copy of the MemoryData. :return: A copy of the MemoryData instance. :rtype: MemoryData """s=MemoryData(self.address,self.size,self.sort,pointer_addr=self.pointer_addr,max_size=self.max_size)s.content=self.contentreturns
[docs]deffill_content(self,loader):""" Load data to fill self.content. :param loader: The project loader. :return: None """ifself.sort==MemoryDataSort.String:self.content=loader.memory.load(self.addr,self.reference_sizeifself.reference_sizeisnotNoneelseself.size)ifself.content.endswith(b"\x00"):self.content=self.content.strip(b"\x00")elifself.sort==MemoryDataSort.UnicodeString:self.content=loader.memory.load(self.addr,self.reference_sizeifself.reference_sizeisnotNoneelseself.size)ifself.content.endswith(b"\x00\x00"):self.content=self.content[:-2]else:# FIXME: Other types are not supported yetreturn