Skip to content

Commit ebff89f

Browse files
committed
Load -> Apply because this language is a shit show
Windows def'd somethings and now i either have to spam undef everywhere, use a namespace, or do this...
1 parent 0657b09 commit ebff89f

File tree

12 files changed

+33
-37
lines changed

12 files changed

+33
-37
lines changed

view/sharedcache/api/python/sharedcache.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ class SharedCacheController:
109109
def __init__(self, view: BinaryView):
110110
self.handle = sccore.BNGetSharedCacheController(view.handle)
111111

112-
def load_region(self, view: BinaryView, region: CacheRegion) -> bool:
112+
def apply_region(self, view: BinaryView, region: CacheRegion) -> bool:
113113
api_region: sccore.BNSharedCacheRegion = region_to_api(region)
114-
result = sccore.BNSharedCacheControllerLoadRegion(self.handle, view.handle, api_region)
114+
result = sccore.BNSharedCacheControllerApplyRegion(self.handle, view.handle, api_region)
115115
sccore.BNSharedCacheFreeRegion(api_region)
116116
return result
117117

118-
def load_image(self, view: BinaryView, image: CacheImage) -> bool:
118+
def apply_image(self, view: BinaryView, image: CacheImage) -> bool:
119119
api_image: sccore.BNSharedCacheImage = image_to_api(image)
120-
result = sccore.BNSharedCacheControllerLoadImage(self.handle, view.handle, api_image)
120+
result = sccore.BNSharedCacheControllerApplyImage(self.handle, view.handle, api_image)
121121
sccore.BNSharedCacheFreeImage(api_image)
122122
return result
123123

view/sharedcache/api/sharedcache.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,18 @@ DSCRef<SharedCacheController> SharedCacheController::GetController(BinaryView& v
121121
return new SharedCacheController(controller);
122122
}
123123

124-
bool SharedCacheController::LoadRegion(BinaryView &view, const CacheRegion &region)
124+
bool SharedCacheController::ApplyRegion(BinaryView &view, const CacheRegion &region)
125125
{
126126
auto apiRegion = RegionToApi(region);
127-
bool result = BNSharedCacheControllerLoadRegion(m_object, view.GetObject(), &apiRegion);
127+
bool result = BNSharedCacheControllerApplyRegion(m_object, view.GetObject(), &apiRegion);
128128
BNSharedCacheFreeRegion(apiRegion);
129129
return result;
130130
}
131131

132-
bool SharedCacheController::LoadImage(BinaryView &view, const CacheImage &image)
132+
bool SharedCacheController::ApplyImage(BinaryView &view, const CacheImage &image)
133133
{
134134
auto apiImage = ImageToApi(image);
135-
bool result = BNSharedCacheControllerLoadImage(m_object, view.GetObject(), &apiImage);
135+
bool result = BNSharedCacheControllerApplyImage(m_object, view.GetObject(), &apiImage);
136136
BNSharedCacheFreeImage(apiImage);
137137
return result;
138138
}

view/sharedcache/api/sharedcacheapi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,13 @@ namespace SharedCacheAPI {
292292
explicit SharedCacheController(BNSharedCacheController* controller);
293293
static DSCRef<SharedCacheController> GetController(BinaryNinja::BinaryView& view);
294294

295-
bool LoadRegion(BinaryNinja::BinaryView& view, const CacheRegion& region);
295+
bool ApplyRegion(BinaryNinja::BinaryView& view, const CacheRegion& region);
296296

297297
// Attempt to load the given image into the view.
298298
//
299299
// It is the callers responsibility to run linear sweep and update analysis, as you might want to add
300300
// multiple images at a time.
301-
bool LoadImage(BinaryNinja::BinaryView& view, const CacheImage& image);
301+
bool ApplyImage(BinaryNinja::BinaryView& view, const CacheImage& image);
302302

303303
bool IsRegionLoaded(const CacheRegion& region) const;
304304
bool IsImageLoaded(const CacheImage& image) const;

view/sharedcache/api/sharedcachecore.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ extern "C"
113113
SHAREDCACHE_FFI_API BNSharedCacheController* BNNewSharedCacheControllerReference(BNSharedCacheController* controller);
114114
SHAREDCACHE_FFI_API void BNFreeSharedCacheControllerReference(BNSharedCacheController* controller);
115115

116-
SHAREDCACHE_FFI_API bool BNSharedCacheControllerLoadImage(BNSharedCacheController* controller, BNBinaryView* view, BNSharedCacheImage* image);
117-
SHAREDCACHE_FFI_API bool BNSharedCacheControllerLoadRegion(BNSharedCacheController* controller, BNBinaryView* view, BNSharedCacheRegion* region);
116+
SHAREDCACHE_FFI_API bool BNSharedCacheControllerApplyImage(BNSharedCacheController* controller, BNBinaryView* view, BNSharedCacheImage* image);
117+
SHAREDCACHE_FFI_API bool BNSharedCacheControllerApplyRegion(BNSharedCacheController* controller, BNBinaryView* view, BNSharedCacheRegion* region);
118118

119119
SHAREDCACHE_FFI_API bool BNSharedCacheControllerIsImageLoaded(BNSharedCacheController* controller, BNSharedCacheImage* image);
120120
SHAREDCACHE_FFI_API bool BNSharedCacheControllerIsRegionLoaded(BNSharedCacheController* controller, BNSharedCacheRegion* region);

view/sharedcache/core/SharedCacheController.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,15 @@ DSCRef<SharedCacheController> SharedCacheController::FromView(BinaryView& view)
8484
return dscView->second;
8585
}
8686

87-
bool SharedCacheController::LoadRegionAtAddress(BinaryView& view, const uint64_t address)
87+
bool SharedCacheController::ApplyRegionAtAddress(BinaryView& view, const uint64_t address)
8888
{
8989
auto region = m_cache.GetRegionAt(address);
9090
if (!region)
9191
return false;
92-
93-
LogInfo("Loading region at %llx named %s with range %llx - %llx", address, region->name.c_str(), region->start, region->start + region->size);
94-
95-
return LoadRegion(view, *region);
92+
return ApplyRegion(view, *region);
9693
}
9794

98-
bool SharedCacheController::LoadRegion(BinaryView& view, const CacheRegion& region)
95+
bool SharedCacheController::ApplyRegion(BinaryView& view, const CacheRegion& region)
9996
{
10097
// TODO: Check m_loadedRegions? This seems redundant...
10198
// Loads the given region into the BinaryView and marks it as loaded.
@@ -146,14 +143,13 @@ bool SharedCacheController::IsRegionLoaded(const CacheRegion &region) const
146143
});
147144
}
148145

149-
bool SharedCacheController::LoadImage(BinaryView& view, const CacheImage& image)
146+
bool SharedCacheController::ApplyImage(BinaryView& view, const CacheImage& image)
150147
{
151148
// TODO: Check m_loadedImages? This seems redundant...
152-
// TODO: Will this load the header for the image as well?
153149
// Load all regions of an image and mark the image as loaded.
154150
bool loadedRegion = false;
155151
for (const auto& regionStart : image.regionStarts)
156-
if (LoadRegionAtAddress(view, regionStart))
152+
if (ApplyRegionAtAddress(view, regionStart))
157153
loadedRegion = true;
158154

159155
// If there was no loaded regions than we just want to forgo loading the image.

view/sharedcache/core/SharedCacheController.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ namespace BinaryNinja::DSC {
3535

3636
// TODO: LoadResult type? AlreadyLoaded, Loaded, NotLoaded.
3737
// NOTE: `address` should be the start of a region, not containing the address.
38-
bool LoadRegionAtAddress(BinaryView& view, uint64_t address);
39-
bool LoadRegion(BinaryView& view, const CacheRegion& region);
38+
bool ApplyRegionAtAddress(BinaryView& view, uint64_t address);
39+
bool ApplyRegion(BinaryView& view, const CacheRegion& region);
4040
bool IsRegionLoaded(const CacheRegion& region) const;
4141

4242
// Loads the relevant image info into the view. This does not update analysis so if you
4343
// call this make sure at some point you update analysis and likely with linear sweep.
44-
bool LoadImage(BinaryView& view, const CacheImage& image);
44+
bool ApplyImage(BinaryView& view, const CacheImage& image);
4545
bool IsImageLoaded(const CacheImage& image) const;
4646

4747
// Get the metadata for saving the state of the shared cache.

view/sharedcache/core/SharedCacheView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ bool SharedCacheView::Init()
789789
auto autoLoadPattern = std::regex(".*libsystem_c.dylib");
790790
for (const auto& [_, image] : sharedCache.GetImages())
791791
if (std::regex_match(image.GetName(), autoLoadPattern))
792-
cacheController->LoadImage(*this, image);
792+
cacheController->ApplyImage(*this, image);
793793

794794
return true;
795795
}

view/sharedcache/core/ffi.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,20 +161,20 @@ extern "C" {
161161
DSC_API_OBJECT_FREE(controller);
162162
}
163163

164-
bool BNSharedCacheControllerLoadImage(BNSharedCacheController* controller, BNBinaryView* data, BNSharedCacheImage* image)
164+
bool BNSharedCacheControllerApplyImage(BNSharedCacheController* controller, BNBinaryView* data, BNSharedCacheImage* image)
165165
{
166166
Ref<BinaryView> view = new BinaryView(BNNewViewReference(data));
167167
// LoadImage will use the header, lets do everyone a favor and use the existing image!
168168
if (const auto realImage = controller->object->GetCache().GetImageAt(image->headerAddress))
169-
return controller->object->LoadImage(*view, *realImage);
169+
return controller->object->ApplyImage(*view, *realImage);
170170
// They gave us an unknown image, we will not have header information.
171-
return controller->object->LoadImage(*view, ImageFromApi(*image));
171+
return controller->object->ApplyImage(*view, ImageFromApi(*image));
172172
}
173173

174-
bool BNSharedCacheControllerLoadRegion(BNSharedCacheController* controller, BNBinaryView* data, BNSharedCacheRegion* region)
174+
bool BNSharedCacheControllerApplyRegion(BNSharedCacheController* controller, BNBinaryView* data, BNSharedCacheRegion* region)
175175
{
176176
Ref<BinaryView> view = new BinaryView(BNNewViewReference(data));
177-
return controller->object->LoadRegion(*view, RegionFromApi(*region));
177+
return controller->object->ApplyRegion(*view, RegionFromApi(*region));
178178
}
179179

180180
bool BNSharedCacheControllerIsRegionLoaded(BNSharedCacheController* controller, BNSharedCacheRegion* region)

view/sharedcache/ui/SharedCacheUINotifications.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void UINotifications::OnViewChange(UIContext* context, ViewFrame* frame, const Q
4646
if (auto foundRegion = controller->GetRegionContaining(addr))
4747
{
4848
// If we did not load the region, then we don't need to run analysis.
49-
if (!controller->LoadRegion(view, *foundRegion))
49+
if (!controller->ApplyRegion(view, *foundRegion))
5050
return;
5151
view.AddAnalysisOption("linearsweep");
5252
view.UpdateAnalysis();
@@ -60,7 +60,7 @@ void UINotifications::OnViewChange(UIContext* context, ViewFrame* frame, const Q
6060
if (auto foundImage = controller->GetImageContaining(addr))
6161
{
6262
// If we did not load the image, then we don't need to run analysis.
63-
if (!controller->LoadImage(view, *foundImage))
63+
if (!controller->ApplyImage(view, *foundImage))
6464
return;
6565
view.AddAnalysisOption("linearsweep");
6666
view.UpdateAnalysis();

view/sharedcache/ui/dscpicker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void DisplayDSCPicker(UIContext* ctx, Ref<BinaryView> dscView)
4545
{
4646
if (const auto selectedImage = controller->GetImageWithName( selectedImageName))
4747
{
48-
controller->LoadImage(*dscView, *selectedImage);
48+
controller->ApplyImage(*dscView, *selectedImage);
4949
dscView->AddAnalysisOption("linearsweep");
5050
dscView->UpdateAnalysis();
5151
}

0 commit comments

Comments
 (0)