Skip to content

Commit 464b2db

Browse files
committed
wip
1 parent d7bda0e commit 464b2db

31 files changed

+3090
-6483
lines changed

view/sharedcache/api/python/sharedcache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def load_image_containing_address(self, addr, skipObjC = False):
125125
return sccore.BNDSCViewLoadImageContainingAddress(self.handle, addr, skipObjC)
126126

127127
def process_objc_sections_for_image_with_install_name(self, installName):
128-
return sccore.BNDSCViewProcessObjCSectionsForImageWithInstallName(self.handle, installName, False)
128+
return sccore.BNDSCViewProcessObjCSectionsForImageWithInstallName(self.handle, installName)
129129

130130
def process_all_objc_sections(self):
131131
return sccore.BNDSCViewProcessAllObjCSections(self.handle)

view/sharedcache/api/sharedcache.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@ std::vector<std::string> SharedCache::GetAvailableImages()
5555
return result;
5656
}
5757

58-
void SharedCache::ProcessObjCSectionsForImageWithInstallName(std::string installName)
58+
void SharedCache::ProcessObjCSectionsForImageWithInstallName(const std::string& installName)
5959
{
60-
char* str = BNAllocString(installName.c_str());
61-
BNDSCViewProcessObjCSectionsForImageWithInstallName(m_object, str, true);
60+
BNDSCViewProcessObjCSectionsForImageWithInstallName(m_object, installName.c_str());
6261
}
6362

6463
void SharedCache::ProcessAllObjCSections()

view/sharedcache/api/sharedcacheapi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ namespace SharedCacheAPI {
147147
bool LoadImageContainingAddress(uint64_t addr, bool skipObjC = false);
148148
std::vector<std::string> GetAvailableImages();
149149

150-
void ProcessObjCSectionsForImageWithInstallName(std::string installName);
150+
void ProcessObjCSectionsForImageWithInstallName(const std::string& installName);
151151
void ProcessAllObjCSections();
152152

153153
std::vector<DSCSymbol> LoadAllSymbolsAndWait();

view/sharedcache/api/sharedcachecore.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ extern "C"
127127

128128
SHAREDCACHE_FFI_API char** BNDSCViewGetInstallNames(BNSharedCache* cache, size_t* count);
129129

130-
SHAREDCACHE_FFI_API bool BNDSCViewLoadImageWithInstallName(BNSharedCache* cache, char* name, bool skipObjC);
130+
SHAREDCACHE_FFI_API bool BNDSCViewLoadImageWithInstallName(BNSharedCache* cache, const char* name, bool skipObjC);
131131
SHAREDCACHE_FFI_API bool BNDSCViewLoadSectionAtAddress(BNSharedCache* cache, uint64_t name);
132132
SHAREDCACHE_FFI_API bool BNDSCViewLoadImageContainingAddress(BNSharedCache* cache, uint64_t address, bool skipObjC);
133133

134-
SHAREDCACHE_FFI_API void BNDSCViewProcessObjCSectionsForImageWithInstallName(BNSharedCache* cache, char* name, bool deallocName);
134+
SHAREDCACHE_FFI_API void BNDSCViewProcessObjCSectionsForImageWithInstallName(BNSharedCache* cache, const char* name);
135135
SHAREDCACHE_FFI_API void BNDSCViewProcessAllObjCSections(BNSharedCache* cache);
136136

137137
SHAREDCACHE_FFI_API char* BNDSCViewGetNameForAddress(BNSharedCache* cache, uint64_t address);
@@ -156,7 +156,7 @@ extern "C"
156156
SHAREDCACHE_FFI_API void BNDSCFindSymbolAtAddressAndApplyToAddress(BNSharedCache* cache, uint64_t symbolLocation, uint64_t targetLocation, bool triggerReanalysis);
157157

158158
SHAREDCACHE_FFI_API char* BNDSCViewGetImageHeaderForAddress(BNSharedCache* cache, uint64_t address);
159-
SHAREDCACHE_FFI_API char* BNDSCViewGetImageHeaderForName(BNSharedCache* cache, char* name);
159+
SHAREDCACHE_FFI_API char* BNDSCViewGetImageHeaderForName(BNSharedCache* cache, const char* name);
160160

161161
SHAREDCACHE_FFI_API BNDSCMemoryUsageInfo BNDSCViewGetMemoryUsageInfo();
162162

view/sharedcache/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if((NOT BN_API_PATH) AND (NOT BN_INTERNAL_BUILD))
99
endif()
1010
endif()
1111

12-
file(GLOB SOURCES *.cpp *.h ../../../objectivec/*)
12+
file(GLOB_RECURSE SOURCES *.cpp *.h ../../../objectivec/*)
1313

1414
add_library(sharedcachecore OBJECT ${SOURCES})
1515

view/sharedcache/core/DSCView.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
* */
1414

1515
#include "DSCView.h"
16+
17+
#include "FileAccessorCache.h"
18+
#include "MappedFileAccessor.h"
1619
#include "view/macho/machoview.h"
1720
#include "SharedCache.h"
1821

@@ -196,7 +199,7 @@ bool DSCView::Init()
196199
auto metadataVersion = SharedCacheCore::SharedCacheMetadata::ViewMetadataVersion(GetParentView());
197200
if (metadataVersion.has_value() && metadataVersion.value() != METADATA_VERSION)
198201
{
199-
// TODO: This is fucked up lmaooooo
202+
// TODO: dont worry this will go away with the refactor, eta this week idk.
200203
ShowMessageBox("Invalid Shared Cache Metadata!", "The BNDB shared cache metadata was created with a different version of the Shared Cache view, to continue the metadata has to be recreated. You will need to add your images back again.");
201204
}
202205

@@ -650,8 +653,11 @@ DSCViewType::DSCViewType() : BinaryViewType(VIEW_NAME, VIEW_NAME)
650653

651654
void DSCViewType::Register()
652655
{
653-
MMappedFileAccessor::InitialVMSetup();
654-
std::atexit(VMShutdown);
656+
auto fdLimit = AdjustFileDescriptorLimit();
657+
BinaryNinja::LogDebug("Shared Cache processing initialized with a max file descriptor limit of %lld", fdLimit);
658+
659+
// Adjust the global accessor cache to the fdlimit.
660+
FileAccessorCache::Global().SetCacheSize(fdLimit);
655661

656662
static DSCViewType type;
657663
BinaryViewType::Register(&type);

0 commit comments

Comments
 (0)