From f4a4b17b9e30cf603eb614e153d68226a3b24520 Mon Sep 17 00:00:00 2001 From: kat Date: Wed, 30 Oct 2024 08:39:09 -0400 Subject: [SharedCache] Implement LoadedImage API, Fix serialized image names, more robust system for out-of-date databases --- view/sharedcache/api/python/_sharedcachecore.py | 17 ---------- view/sharedcache/api/python/sharedcache.py | 45 +++++++++++-------------- 2 files changed, 20 insertions(+), 42 deletions(-) (limited to 'view/sharedcache/api/python') diff --git a/view/sharedcache/api/python/_sharedcachecore.py b/view/sharedcache/api/python/_sharedcachecore.py index 93228468..d208048b 100644 --- a/view/sharedcache/api/python/_sharedcachecore.py +++ b/view/sharedcache/api/python/_sharedcachecore.py @@ -577,23 +577,6 @@ def BNDSCViewLoadSectionAtAddress( return _BNDSCViewLoadSectionAtAddress(cache, name) -# ------------------------------------------------------- -# _BNDSCViewLoadedImageCount - -_BNDSCViewLoadedImageCount = core.BNDSCViewLoadedImageCount -_BNDSCViewLoadedImageCount.restype = ctypes.c_ulonglong -_BNDSCViewLoadedImageCount.argtypes = [ - ctypes.POINTER(BNSharedCache), - ] - - -# noinspection PyPep8Naming -def BNDSCViewLoadedImageCount( - cache: ctypes.POINTER(BNSharedCache) - ) -> int: - return _BNDSCViewLoadedImageCount(cache) - - # ------------------------------------------------------- # _BNFreeSharedCacheReference diff --git a/view/sharedcache/api/python/sharedcache.py b/view/sharedcache/api/python/sharedcache.py index ca031e03..54745ed5 100644 --- a/view/sharedcache/api/python/sharedcache.py +++ b/view/sharedcache/api/python/sharedcache.py @@ -12,17 +12,15 @@ from .sharedcache_enums import * @dataclasses.dataclass class DSCMemoryMapping: - filePath: str name: str vmAddress: int - rawViewOffset: int size: int def __str__(self): return repr(self) def __repr__(self): - return f": {self.vmAddress:x}+{self.size:x}>" + return f"" @dataclasses.dataclass @@ -176,31 +174,32 @@ class SharedCache: return result @property - def loaded_images(self): + def loaded_regions(self): + """ + Get all loaded regions in the shared cache + + The internal logic for loading images treats a region as 'loaded' whenever + that region has been mapped into memory, and, if it's located within an image, header information has been applied to that region. + + Individual segments within an image can be loaded independently of the image itself. + + Only once all regions of an image are loaded will the header processor refuse to run on that region. + :return: + """ count = ctypes.c_ulonglong() - value = sccore.BNDSCViewGetLoadedImages(self.handle, count) + value = sccore.BNDSCViewGetLoadedRegions(self.handle, count) if value is None: return [] result = [] for i in range(count.value): - mappings = [] - for j in range(value[i].mappingCount): - mapping = DSCMemoryMapping( - value[i].mappings[j].filePath, - value[i].mappings[j].name, - value[i].mappings[j].vmAddress, - value[i].mappings[j].rawViewOffset, - value[i].mappings[j].size - ) - mappings.append(mapping) - result.append(LoadedRegion( + mapping = DSCMemoryMapping( value[i].name, - value[i].headerAddress, - mappings - )) - - sccore.BNDSCViewFreeLoadedImages(value, count) + value[i].vmAddress, + value[i].size, + ) + result.append(mapping) + sccore.BNDSCViewFreeLoadedRegions(value, count) return result def load_all_symbols_and_wait(self): @@ -234,10 +233,6 @@ class SharedCache: BNFreeStringList(value, count) return result - @property - def image_count(self): - return sccore.BNDSCViewLoadedImageCount(self.handle) - @property def state(self): return DSCViewState(sccore.BNDSCViewGetState(self.handle)) -- cgit v1.3.1