diff options
| author | KyleMiles <krm504@nyu.edu> | 2022-10-07 15:55:43 -0400 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2022-10-09 18:08:24 -0400 |
| commit | 1d21f2de35633113c38692a4fcb7e0481c96fd08 (patch) | |
| tree | 0d30c740c9279940fa07d04f380c554a02b0632b | |
| parent | ed4dbf7bad554078139dcde3b437527078dc42ec (diff) | |
Remove default load settings; Move settings `analysis.debugInfoInternal` and `loader.debugInfoExternal` to `analysis.debugInfo.internal` and `analysis.debugInfo.external`
| -rw-r--r-- | binaryninjaapi.h | 43 | ||||
| -rw-r--r-- | binaryninjacore.h | 11 | ||||
| -rw-r--r-- | binaryview.cpp | 20 | ||||
| -rw-r--r-- | docs/getting-started.md | 2 | ||||
| -rw-r--r-- | python/binaryview.py | 24 | ||||
| -rw-r--r-- | python/debuginfo.py | 2 | ||||
| -rwxr-xr-x | python/examples/debug_info.py | 2 | ||||
| -rw-r--r-- | python/examples/mappedview.py | 7 | ||||
| -rw-r--r-- | rust/src/binaryview.rs | 28 | ||||
| -rw-r--r-- | rust/src/debuginfo.rs | 2 | ||||
| -rw-r--r-- | suite/api_test.py | 2 |
11 files changed, 47 insertions, 96 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h index a8f761a0..36b37006 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -1874,9 +1874,9 @@ namespace BinaryNinja { (void)previousName; (void)component; } - + /*! This notification is posted after a Component is added to the tree. - + \param data BinaryView the Component was added to \param component Component which was added. */ @@ -1885,15 +1885,15 @@ namespace BinaryNinja { (void)data; (void)component; } - + /*! This notification is posted after a Component is removed from the tree. - + \param data BinaryView the Component was removed from \param formerParent Former parent of the Component \param component \parblock The removed and now "dead" Component object. - + This "dead" Component can no longer be moved to other components or have components added to it. It should not be used after this point for storing any objects, and will be destroyed once no more references are held to it. @@ -1905,7 +1905,7 @@ namespace BinaryNinja { (void)formerParent; (void)component; } - + /*! This notification is posted whenever a component is moved from one component to another. \param data BinaryView the Component was removed from @@ -1920,9 +1920,9 @@ namespace BinaryNinja { (void)newParent; (void)component; } - + /*! This notification is posted whenever a Function is added to a Component - + \param data BinaryView containing the Component and Function \param component Component the Function was added to \param function The Function which was added @@ -3788,7 +3788,7 @@ namespace BinaryNinja { \return The component at that path */ std::optional<Ref<Component>> GetComponentByPath(std::string path); - + /*! Get the root component for the BinaryView (read-only) This Component cannot be removed, and houses all unparented Components. @@ -3796,7 +3796,7 @@ namespace BinaryNinja { \return The Root Component */ Ref<Component> GetRootComponent(); - + /*! Create a component This component will be added to the root component and initialized with the name "Component" @@ -3804,7 +3804,7 @@ namespace BinaryNinja { \return The created Component */ Ref<Component> CreateComponent(); - + /*! Create a component as a subcomponent of the component with a given Guid This component will be initialized with the name "Component" @@ -3813,16 +3813,16 @@ namespace BinaryNinja { \return The created Component */ Ref<Component> CreateComponent(std::string parentGUID); - + /*! Create a component as a subcomponent of a given Component This component will be initialized with the name "Component" - + \param parent Parent Component \return The created Component */ Ref<Component> CreateComponent(Ref<Component> parent); - + /*! Create a component with a given name and optional parent \param name Name to initialize the component with @@ -3830,7 +3830,7 @@ namespace BinaryNinja { \return The created Component */ Ref<Component> CreateComponentWithName(std::string name, std::string parentGUID = {}); - + /*! Create a component with a given name and parent \param name Name to initialize the component with @@ -3838,14 +3838,14 @@ namespace BinaryNinja { \return The created Component */ Ref<Component> CreateComponentWithName(std::string name, Ref<Component> parent); - + /*! Remove a component from the tree entirely. This will also by nature remove all subcomponents. \param component Component to remove \return Whether removal was successful */ bool RemoveComponent(Ref<Component> component); - + /*! Remove a component from the tree entirely. This will also by nature remove all subcomponents. \param guid Guid of the Component to remove @@ -4299,7 +4299,6 @@ namespace BinaryNinja { std::vector<std::string> GetLoadSettingsTypeNames(); Ref<Settings> GetLoadSettings(const std::string& typeName); void SetLoadSettings(const std::string& typeName, Ref<Settings> settings); - Ref<Settings> GetDefaultLoadSettings(const std::string& typeName, Ref<Settings> settings = nullptr); BNAnalysisParameters GetParametersForAnalysis(); void SetParametersForAnalysis(BNAnalysisParameters params); @@ -12147,14 +12146,14 @@ namespace BinaryNinja { This can differ from the GetOriginalName() value if the parent component also contains other components with the same name. - + Subsequent duplicates will return the original name with " (1)", " (2)" and so on appended. This name can change whenever a different duplicate is removed. \note For looking up Components, utilizing Guid is highly recommended, as it will *always* map to this component, and as Guid lookups are faster by nature. - + \return Component name */ std::string GetDisplayName(); @@ -12162,7 +12161,7 @@ namespace BinaryNinja { /*! The original name for the component This may differ from Component::GetName() whenever the parent contains Components with the same original name. - + This function will always return the value originally set for this Component. \return Component name @@ -12171,7 +12170,7 @@ namespace BinaryNinja { /*! Set the name for the component - \see GetName(), GetOriginalName() + \see GetName(), GetOriginalName() \param name New component name. */ diff --git a/binaryninjacore.h b/binaryninjacore.h index b601a682..2eb698fe 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -3382,11 +3382,11 @@ extern "C" BINARYNINJACOREAPI BNRegisterValueWithConfidence BNGetGlobalPointerValue(BNBinaryView* view); // Raw binary data view - BINARYNINJACOREAPI BNBinaryView* BNCreateBinaryDataView(BNFileMetadata* file, bool setDefaultLoadSettings); - BINARYNINJACOREAPI BNBinaryView* BNCreateBinaryDataViewFromBuffer(BNFileMetadata* file, BNDataBuffer* buf, bool setDefaultLoadSettings); - BINARYNINJACOREAPI BNBinaryView* BNCreateBinaryDataViewFromData(BNFileMetadata* file, const void* data, size_t len, bool setDefaultLoadSettings); - BINARYNINJACOREAPI BNBinaryView* BNCreateBinaryDataViewFromFilename(BNFileMetadata* file, const char* filename, bool setDefaultLoadSettings); - BINARYNINJACOREAPI BNBinaryView* BNCreateBinaryDataViewFromFile(BNFileMetadata* file, BNFileAccessor* accessor, bool setDefaultLoadSettings); + BINARYNINJACOREAPI BNBinaryView* BNCreateBinaryDataView(BNFileMetadata* file); + BINARYNINJACOREAPI BNBinaryView* BNCreateBinaryDataViewFromBuffer(BNFileMetadata* file, BNDataBuffer* buf); + BINARYNINJACOREAPI BNBinaryView* BNCreateBinaryDataViewFromData(BNFileMetadata* file, const void* data, size_t len); + BINARYNINJACOREAPI BNBinaryView* BNCreateBinaryDataViewFromFilename(BNFileMetadata* file, const char* filename); + BINARYNINJACOREAPI BNBinaryView* BNCreateBinaryDataViewFromFile(BNFileMetadata* file, BNFileAccessor* accessor); // Creation of new types of binary views BINARYNINJACOREAPI BNBinaryView* BNCreateCustomBinaryView( @@ -6188,7 +6188,6 @@ extern "C" BINARYNINJACOREAPI char** BNBinaryViewGetLoadSettingsTypeNames(BNBinaryView* view, size_t* count); BINARYNINJACOREAPI BNSettings* BNBinaryViewGetLoadSettings(BNBinaryView* view, const char* typeName); BINARYNINJACOREAPI void BNBinaryViewSetLoadSettings(BNBinaryView* view, const char* typeName, BNSettings* settings); - BINARYNINJACOREAPI BNSettings* BNBinaryViewGetDefaultLoadSettings(BNBinaryView* view, const char* typeName, BNSettings* settings); // Relocation object methods BINARYNINJACOREAPI BNRelocation* BNNewRelocationReference(BNRelocation* reloc); diff --git a/binaryview.cpp b/binaryview.cpp index 713e2c0c..bed725f1 100644 --- a/binaryview.cpp +++ b/binaryview.cpp @@ -4042,16 +4042,6 @@ void BinaryView::SetLoadSettings(const string& typeName, Ref<Settings> settings) } -Ref<Settings> BinaryView::GetDefaultLoadSettings(const string& typeName, Ref<Settings> settings) -{ - BNSettings* defaultSettings = - BNBinaryViewGetDefaultLoadSettings(m_object, typeName.c_str(), settings ? settings->GetObject() : nullptr); - if (!defaultSettings) - return nullptr; - return new Settings(defaultSettings); -} - - BNAnalysisParameters BinaryView::GetParametersForAnalysis() { return BNGetParametersForAnalysis(m_object); @@ -4199,26 +4189,26 @@ Ref<Symbol> Relocation::GetSymbol() const } -BinaryData::BinaryData(FileMetadata* file) : BinaryView(BNCreateBinaryDataView(file->GetObject(), false)) {} +BinaryData::BinaryData(FileMetadata* file) : BinaryView(BNCreateBinaryDataView(file->GetObject())) {} BinaryData::BinaryData(FileMetadata* file, const DataBuffer& data) : - BinaryView(BNCreateBinaryDataViewFromBuffer(file->GetObject(), data.GetBufferObject(), false)) + BinaryView(BNCreateBinaryDataViewFromBuffer(file->GetObject(), data.GetBufferObject())) {} BinaryData::BinaryData(FileMetadata* file, const void* data, size_t len) : - BinaryView(BNCreateBinaryDataViewFromData(file->GetObject(), data, len, false)) + BinaryView(BNCreateBinaryDataViewFromData(file->GetObject(), data, len)) {} BinaryData::BinaryData(FileMetadata* file, const string& path) : - BinaryView(BNCreateBinaryDataViewFromFilename(file->GetObject(), path.c_str(), false)) + BinaryView(BNCreateBinaryDataViewFromFilename(file->GetObject(), path.c_str())) {} BinaryData::BinaryData(FileMetadata* file, FileAccessor* accessor) : - BinaryView(BNCreateBinaryDataViewFromFile(file->GetObject(), accessor->GetCallbacks(), false)) + BinaryView(BNCreateBinaryDataViewFromFile(file->GetObject(), accessor->GetCallbacks())) {} diff --git a/docs/getting-started.md b/docs/getting-started.md index a343e995..f2385981 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -682,6 +682,8 @@ Here's a list of all built-in settings currently available from the UI: |analysis|Purge Snapshots|When saving a database, purge old snapshots keeping only the current snapshot.|`boolean`|`False`|[`SettingsProjectScope`, `SettingsUserScope`]|<a id='analysis.database.purgeSnapshots'>analysis.database.purgeSnapshots</a>| |analysis|Purge Undo History|When saving a database, purge current and existing undo history.|`boolean`|`False`|[`SettingsProjectScope`, `SettingsUserScope`]|<a id='analysis.database.purgeUndoHistory'>analysis.database.purgeUndoHistory</a>| |analysis|Suppress Reanalysis|Disable function reanalysis on database load when the product version or analysis settings change.|`boolean`|`False`|[`SettingsProjectScope`, `SettingsResourceScope`, `SettingsUserScope`]|<a id='analysis.database.suppressReanalysis'>analysis.database.suppressReanalysis</a>| +|analysis|Import Debug Information|Attempt to parse and apply debug information from each file opened.|`boolean`|`True`|[`SettingsProjectScope`, `SettingsResourceScope`, `SettingsUserScope`]|<a id='analysis.debugInfo.internal'>analysis.debugInfo.internal</a>| +|analysis|External Debug Information File|Separate file to attempt to parse and import debug information from.|`string`|`""`|[`SettingsProjectScope`, `SettingsResourceScope`, `SettingsUserScope`]|<a id='analysis.debugInfo.external'>analysis.debugInfo.external</a>| |analysis|Alternate Type Propagation|Enable an alternate approach for function type propagation. This setting is experimental and may be useful for some binaries.|`boolean`|`True`|[`SettingsProjectScope`, `SettingsResourceScope`, `SettingsUserScope`]|<a id='analysis.experimental.alternateTypePropagation'>analysis.experimental.alternateTypePropagation</a>| |analysis|Correlated Memory Value Propagation|Attempt to propagate the value of an expression from a memory definition to a usage. Currently this feature is simplistic and the scope is a single basic block. This setting is experimental and may be useful for some binaries.|`boolean`|`True`|[`SettingsProjectScope`, `SettingsResourceScope`, `SettingsUserScope`]|<a id='analysis.experimental.correlatedMemoryValuePropagation'>analysis.experimental.correlatedMemoryValuePropagation</a>| |analysis|Gratuitous Function Update|Force the function update cycle to always end with an IncrementalAutoFunctionUpdate type.|`boolean`|`False`|[`SettingsProjectScope`, `SettingsResourceScope`, `SettingsUserScope`]|<a id='analysis.experimental.gratuitousFunctionUpdate'>analysis.experimental.gratuitousFunctionUpdate</a>| diff --git a/python/binaryview.py b/python/binaryview.py index 02255b95..02b1cc53 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -1956,7 +1956,7 @@ class BinaryView: binaryninja._init_plugins() if file_metadata is None: file_metadata = filemetadata.FileMetadata() - _handle = core.BNCreateBinaryDataView(file_metadata.handle, True) + _handle = core.BNCreateBinaryDataView(file_metadata.handle) self._file = filemetadata.FileMetadata(handle=core.BNNewFileReference(file_metadata.handle)) else: binaryninja._init_plugins() @@ -2223,11 +2223,11 @@ class BinaryView: if isinstance(src, fileaccessor.FileAccessor): if file_metadata is None: file_metadata = filemetadata.FileMetadata() - view = core.BNCreateBinaryDataViewFromFile(file_metadata.handle, src._cb, True) + view = core.BNCreateBinaryDataViewFromFile(file_metadata.handle, src._cb) else: if file_metadata is None: file_metadata = filemetadata.FileMetadata(str(src)) - view = core.BNCreateBinaryDataViewFromFilename(file_metadata.handle, str(src), True) + view = core.BNCreateBinaryDataViewFromFilename(file_metadata.handle, str(src)) if view is None: return None return BinaryView(file_metadata=file_metadata, handle=view) @@ -2238,12 +2238,12 @@ class BinaryView: if file_metadata is None: file_metadata = filemetadata.FileMetadata() if data is None: - view = core.BNCreateBinaryDataView(file_metadata.handle, True) + view = core.BNCreateBinaryDataView(file_metadata.handle) elif isinstance(data, databuffer.DataBuffer): - view = core.BNCreateBinaryDataViewFromBuffer(file_metadata.handle, data.handle, True) + view = core.BNCreateBinaryDataViewFromBuffer(file_metadata.handle, data.handle) else: buf = databuffer.DataBuffer(data) - view = core.BNCreateBinaryDataViewFromBuffer(file_metadata.handle, buf.handle, True) + view = core.BNCreateBinaryDataViewFromBuffer(file_metadata.handle, buf.handle) if view is None: return None return BinaryView(file_metadata=file_metadata, handle=view) @@ -7808,18 +7808,6 @@ class BinaryView: settings = settings.handle core.BNBinaryViewSetLoadSettings(self.handle, type_name, settings) - def get_default_load_settings(self, type_name: str, settings: settings.Settings) -> None: - """ - ``get_default_load_settings`` retrieve a :py:class:`Settings` object which defines the load settings for the given :py:class:`BinaryViewType` ``type_name`` - - :param str type_name: the :py:class:`BinaryViewType` name - :param Settings settings: the load settings - :rtype: :py:class:`Settings`, or ``None`` - """ - if settings is not None: - settings = settings.handle - core.BNBinaryViewGetDefaultLoadSettings(self.handle, type_name, settings) - def parse_expression(self, expression: str, here: int = 0) -> int: r""" Evaluates a string expression to an integer value. diff --git a/python/debuginfo.py b/python/debuginfo.py index 153e450d..f56b83de 100644 --- a/python/debuginfo.py +++ b/python/debuginfo.py @@ -177,7 +177,7 @@ class DebugInfoParser(object, metaclass=_DebugInfoParserMetaClass): bn.debuginfo.DebugInfoParser.register("debug info parser", is_valid, parse_info) - :py:class:`DebugInfo` will then be automatically applied to binary views that contain debug information (via the load setting `loader.debugInfoInternal`), binary views that provide valid external debug info files (`loader.debugInfoExternal`), or manually fetched/applied as below:: + :py:class:`DebugInfo` will then be automatically applied to binary views that contain debug information (via the setting `analysis.debugInfo.internal`), binary views that provide valid external debug info files (`analysis.debugInfo.external`), or manually fetched/applied as below: valid_parsers = bn.debuginfo.DebugInfoParser.get_parsers_for_view(bv) parser = valid_parsers[0] diff --git a/python/examples/debug_info.py b/python/examples/debug_info.py index 0dd25786..a060e465 100755 --- a/python/examples/debug_info.py +++ b/python/examples/debug_info.py @@ -222,7 +222,7 @@ for p in bn.debuginfo.DebugInfoParser: print(f" {bn.debuginfo.DebugInfoParser[p.name].name}") # Test calling our `is_valid` callback -bv = bn.open_view(filename, options={"loader.debugInfoInternal": False}) +bv = bn.open_view(filename, options={"analysis.debugInfo.internal": False}) if parser.is_valid_for_view(bv): print("Parser is valid") else: diff --git a/python/examples/mappedview.py b/python/examples/mappedview.py index cfefa87a..0b74ce3a 100644 --- a/python/examples/mappedview.py +++ b/python/examples/mappedview.py @@ -53,7 +53,7 @@ class MappedView(BinaryView): def get_load_settings_for_data(cls, data): # This method is optional. If provided this is where the Load Settings for a BinaryViewType are specified. Binary Ninja provides # some default read-only load settings which are: - # ["loader.architecture", "loader.platform", "loader.entryPointOffset", "loader.imageBase", "loader.segments", "loader.sections", "loader.debugInfoInternal", "loader.debugInfoExternal"] + # ["loader.architecture", "loader.platform", "loader.entryPointOffset", "loader.imageBase", "loader.segments", "loader.sections"] # The default load settings are provided for consistency and convenience. # The default load settings are always generated with a read-only indication which is respected by the UI. # The read-only indication is a property that consists of a JSON name/value pair ("readOnly" : true). @@ -75,10 +75,7 @@ class MappedView(BinaryView): load_settings = registered_view.get_default_load_settings_for_data(view) # Specify default load settings that can be overridden (from the UI). - overrides = [ - "loader.architecture", "loader.platform", "loader.entryPointOffset", "loader.imageBase", - "loader.segments", "loader.sections", "loader.debugInfoInternal", "loader.debugInfoExternal" - ] + overrides = ["loader.architecture", "loader.platform", "loader.entryPointOffset", "loader.imageBase", "loader.segments", "loader.sections"] for override in overrides: if load_settings.contains(override): load_settings.update_property(override, json.dumps({'readOnly': False})) diff --git a/rust/src/binaryview.rs b/rust/src/binaryview.rs index bf9aea9b..b0379aae 100644 --- a/rust/src/binaryview.rs +++ b/rust/src/binaryview.rs @@ -690,28 +690,6 @@ pub trait BinaryViewExt: BinaryViewBase { }; } - fn get_default_load_settings<S: BnStrCompatible>( - &self, - view_type_name: S, - settings: &Settings, - ) -> Result<Ref<Settings>> { - let view_type_name = view_type_name.into_bytes_with_nul(); - - let settings_handle = unsafe { - BNBinaryViewGetDefaultLoadSettings( - self.as_ref().handle, - view_type_name.as_ref().as_ptr() as *mut _, - settings.handle, - ) - }; - - if settings_handle.is_null() { - Err(()) - } else { - Ok(unsafe { Settings::from_raw(settings_handle) }) - } - } - /// Creates a new [TagType] and adds it to the view. /// /// # Arguments @@ -934,7 +912,7 @@ impl BinaryView { let file = filename.into_bytes_with_nul(); let handle = unsafe { - BNCreateBinaryDataViewFromFilename(meta.handle, file.as_ref().as_ptr() as *mut _, true) + BNCreateBinaryDataViewFromFilename(meta.handle, file.as_ref().as_ptr() as *mut _) }; if handle.is_null() { @@ -946,7 +924,7 @@ impl BinaryView { pub fn from_accessor(meta: &FileMetadata, file: &mut FileAccessor) -> Result<Ref<Self>> { let handle = unsafe { - BNCreateBinaryDataViewFromFile(meta.handle, &mut file.api_object as *mut _, true) + BNCreateBinaryDataViewFromFile(meta.handle, &mut file.api_object as *mut _) }; if handle.is_null() { @@ -958,7 +936,7 @@ impl BinaryView { pub fn from_data(meta: &FileMetadata, data: &[u8]) -> Result<Ref<Self>> { let handle = unsafe { - BNCreateBinaryDataViewFromData(meta.handle, data.as_ptr() as *mut _, data.len(), true) + BNCreateBinaryDataViewFromData(meta.handle, data.as_ptr() as *mut _, data.len()) }; if handle.is_null() { diff --git a/rust/src/debuginfo.rs b/rust/src/debuginfo.rs index d4c8b357..c3c94261 100644 --- a/rust/src/debuginfo.rs +++ b/rust/src/debuginfo.rs @@ -52,7 +52,7 @@ //! } //! ``` //! -//! `DebugInfo` will then be automatically applied to binary views that contain debug information (via the load setting `loader.debugInfoInternal`), binary views that provide valid external debug info files (`loader.debugInfoExternal`), or manually fetched/applied as below: +//! `DebugInfo` will then be automatically applied to binary views that contain debug information (via the setting `analysis.debugInfo.internal`), binary views that provide valid external debug info files (`analysis.debugInfo.external`), or manually fetched/applied as below: //! ``` //! let valid_parsers = DebugInfoParser::parsers_for_view(bv); //! let parser = valid_parsers[0]; diff --git a/suite/api_test.py b/suite/api_test.py index 2a544f7c..a4131a29 100644 --- a/suite/api_test.py +++ b/suite/api_test.py @@ -318,8 +318,6 @@ class SettingsAPI(unittest.TestCase): assert load_settings.contains("loader.platform"), "test_load_settings failed" assert load_settings.contains("loader.imageBase"), "test_load_settings failed" assert load_settings.contains("loader.entryPointOffset"), "test_load_settings failed" - assert load_settings.contains("loader.debugInfoInternal"), "test_load_settings failed" - assert load_settings.contains("loader.debugInfoExternal"), "test_load_settings failed" load_settings.set_string("loader.architecture", 'x86_64') load_settings.set_integer("loader.imageBase", 0x500000) load_settings.set_integer("loader.entryPointOffset", 0) |
