def __init__(self, addr, deepness=0): super(StringCache.Ref, self).__init__(addr, deepness) self.entryAddr = idc.Qword(addr + StringCache.Ref.Offset.Entry.value) if self.entryAddr == 0: self.entry = NullObject() else: if deepness >= max_deepness: self.entry = self.entryAddr else: self.entry = StringCache.Entry(self.entryAddr, deepness + 1)
class Ref(MemObject): def __init__(self, addr, deepness=0): super(StringCache.Ref, self).__init__(addr, deepness) self.entryAddr = idc.Qword(addr + StringCache.Ref.Offset.Entry.value) if self.entryAddr == 0: self.entry = NullObject() else: if deepness >= max_deepness: self.entry = self.entryAddr else: self.entry = StringCache.Entry(self.entryAddr, deepness + 1) def __repr__(self): return "<StringCache::Ref at 0x{:X}, Entry: 0x{:X}>".format( self.addr, self.entryAddr) def getCStr(self): return idc.GetString(self.getCStrAddr()) def getCStrAddr(self): if type(self.entry) == StringCache.Entry: return self.entry.getCStrAddr() if self.deepness >= max_deepness: raise DeepnessExceededError() else: return StringCache.Entry(self.entryAddr, self.deepness).getCStrAddr() class Offset(Enum): Entry = 0
def __init__(self, addr, deepness=0): super(BGSInventoryItem, self).__init__(addr, deepness) formAddr = idc.Qword(addr + BGSInventoryItem.Offset.form.value) stackAddr = idc.Qword(addr + BGSInventoryItem.Offset.stack.value) if stackAddr == 0: self.stack = NullObject() else: if deepness >= max_deepness: self.stack = stackAddr else: self.stack = Stack(stackAddr, deepness + 1) if formAddr == 0: self.form = NullObject() else: if deepness >= max_deepness: self.form = formAddr else: self.form = TESForm(formAddr, deepness + 1)
def __init__(self, addr, deepness=0): super(Stack, self).__init__(addr, deepness) nextStackAddr = idc.Qword(addr + Stack.Offset.PtrNextStack.value) if nextStackAddr == 0: self.NextStack = NullObject() else: if deepness >= max_deepness: self.NextStack = nextStackAddr else: self.NextStack = Stack(nextStackAddr, deepness + 1) extraDataListAddr = idc.Qword(addr + Stack.Offset.PtrExtraDataList.value) if extraDataListAddr == 0: self.ExtraDataList = NullObject() else: if deepness >= max_deepness: self.ExtraDataList = extraDataListAddr else: self.ExtraDataList = ExtraDataList(extraDataListAddr, deepness + 1) self.count = idc.Dword(addr + Stack.Offset.Count.value) self.flags = idc.Byte(addr + Stack.Offset.Flags.value)
def getCStrAddr(self): if self.hasCStrValue(): return self.dataAddr % x64RegInfo.MaxValue externDataAddr = idc.Qword( self.addr + StringCache.Entry.Offset.PtrExternDataEntry.value) if externDataAddr == 0: return NullObject() if self.deepness >= max_deepness: raise DeepnessExceededError() return StringCache.Entry(externDataAddr, self.deepness + 1).getCStrAddr()
def __init__(self, addr, deepness=0): super(ExtraDataList, self).__init__(addr, deepness) extraDataAddr = idc.Qword(addr + ExtraDataList.Offset.PtrBSExtraData.value) if extraDataAddr == 0: self.ExtraData = NullObject() else: if deepness >= max_deepness: self.ExtraData = extraDataAddr else: self.ExtraData = BSExtraData(extraDataAddr, deepness + 1) extraDataTypes = {0x99: ExtraTextDisplayData} extraDataType = extraDataTypes.get(self.ExtraData.Type, BSExtraData) if (extraDataType != BSExtraData): self.ExtraData = extraDataType(addr, deepness + 1)
def __init__(self, addr, t_type=None, t_size=None, deepness=0): super(TArray, self).__init__(addr, deepness) self.capacity = idc.Dword(addr + TArray.Offset.Capacity.value) self.count = idc.Dword(addr + TArray.Offset.Count.value) self.maxEntries = 300 self.t_type = t_type self.entriesAddr = idc.Qword(addr + TArray.Offset.Entries.value) if t_type is None: self.Entries = NullObject() else: if deepness >= max_deepness: self.Entries = self.entriesAddr else: if (self.count <= 0) or (t_type is None) or (t_size is None): self.Entries = [] else: self.Entries = [ t_type(i, deepness + 1) for i in range( self.entriesAddr, self.entriesAddr + t_size * (self.count if self.count < self.maxEntries else self.maxEntries), t_size) ]