Skip to content

Commit d902a6c

Browse files
committed
Merge remote-tracking branch 'origin/dev' into test_homegrown_powerpc_vle
2 parents 8dce3f9 + 1367521 commit d902a6c

File tree

15 files changed

+415
-67
lines changed

15 files changed

+415
-67
lines changed

binaryninjaapi.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17022,8 +17022,9 @@ namespace BinaryNinja {
1702217022
"readOnly" bool None Yes Only enforced by UI elements
1702317023
"optional" bool None Yes Indicates setting can be null
1702417024
"hidden" bool "type" is "string" Yes Indicates the UI should conceal the content. The "ignore" property is required to specify the applicable storage scopes
17025-
"requiresRestart bool None Yes Enable restart notification in the UI upon change
17025+
"requiresRestart" bool None Yes Enable restart notification in the UI upon change
1702617026
"uiSelectionAction" string "type" is "string" Yes {"file", "directory", <Registered UIAction Name>} Informs the UI to add a button to open a selection dialog or run a registered UIAction
17027+
"quickSettingsGroup" string None Yes Informs the submenu name in the UI when added to quick settings context menu
1702717028
================== ====================================== ================== ======== =======================================================================
1702817029

1702917030
\note In order to facilitate deterministic analysis results, settings from the <em><tt>default</tt></em> schema that impact analysis are serialized
@@ -17124,9 +17125,10 @@ namespace BinaryNinja {
1712417125

1712517126
/*! Determine if the active settings schema is empty
1712617127

17128+
\param scope the settings scope to check, defaults to SettingsAutoScope
1712717129
\return True if the active settings schema is empty, False otherwise
1712817130
*/
17129-
bool IsEmpty();
17131+
bool IsEmpty(BNSettingsScope scope = SettingsAutoScope);
1713017132

1713117133
/*! Retrieve the list of setting identifiers in the active settings schema
1713217134

@@ -17153,6 +17155,7 @@ namespace BinaryNinja {
1715317155
const std::string& contents, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
1715417156
std::string SerializeSettings(Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
1715517157

17158+
bool IsEmpty(Ref<BinaryView> view, BNSettingsScope scope = SettingsAutoScope);
1715617159
bool Reset(const std::string& key, Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope);
1715717160
bool ResetAll(
1715817161
Ref<BinaryView> view = nullptr, BNSettingsScope scope = SettingsAutoScope, bool schemaOnly = true);
@@ -17209,6 +17212,7 @@ namespace BinaryNinja {
1720917212
bool DeserializeSettings(const std::string& contents, Ref<Function> func, BNSettingsScope scope = SettingsAutoScope);
1721017213
std::string SerializeSettings(Ref<Function> func, BNSettingsScope scope = SettingsAutoScope);
1721117214

17215+
bool IsEmpty(Ref<Function> func, BNSettingsScope scope = SettingsAutoScope);
1721217216
bool Reset(const std::string& key, Ref<Function> func, BNSettingsScope scope = SettingsAutoScope);
1721317217
bool ResetAll(Ref<Function> func, BNSettingsScope scope = SettingsAutoScope, bool schemaOnly = true);
1721417218

binaryninjacore.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@
3737
// Current ABI version for linking to the core. This is incremented any time
3838
// there are changes to the API that affect linking, including new functions,
3939
// new types, or modifications to existing functions or types.
40-
#define BN_CURRENT_CORE_ABI_VERSION 112
40+
#define BN_CURRENT_CORE_ABI_VERSION 113
4141

4242
// Minimum ABI version that is supported for loading of plugins. Plugins that
4343
// are linked to an ABI version less than this will not be able to load and
4444
// will require rebuilding. The minimum version is increased when there are
4545
// incompatible changes that break binary compatibility, such as changes to
4646
// existing types or functions.
47-
#define BN_MINIMUM_CORE_ABI_VERSION 100
47+
#define BN_MINIMUM_CORE_ABI_VERSION 113
4848

4949
#ifdef __GNUC__
5050
#ifdef BINARYNINJACORE_LIBRARY
@@ -7429,7 +7429,7 @@ extern "C"
74297429
BINARYNINJACOREAPI bool BNSettingsRegisterGroup(BNSettings* settings, const char* group, const char* title);
74307430
BINARYNINJACOREAPI bool BNSettingsRegisterSetting(BNSettings* settings, const char* key, const char* properties);
74317431
BINARYNINJACOREAPI bool BNSettingsContains(BNSettings* settings, const char* key);
7432-
BINARYNINJACOREAPI bool BNSettingsIsEmpty(BNSettings* settings);
7432+
BINARYNINJACOREAPI bool BNSettingsIsEmpty(BNSettings* settings, BNBinaryView* view, BNFunction* func, BNSettingsScope scope);
74337433
BINARYNINJACOREAPI const char** BNSettingsKeysList(BNSettings* settings, size_t* inoutSize);
74347434
BINARYNINJACOREAPI char* BNSettingsQueryPropertyString(BNSettings* settings, const char* key, const char* property);
74357435
BINARYNINJACOREAPI const char** BNSettingsQueryPropertyStringList(BNSettings* settings, const char* key, const char* property, size_t* inoutSize);

docs/guide/settings.md

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,94 @@
11
# Settings
22

3-
## UI
3+
## Settings UI
44

55
![settings](../img/settings.png "Settings"){ width="800" }
66

7-
Binary Ninja provides various settings which are available via the `[CMD/CTRL] ,` hotkey for *User* settings and the `[CMD/CTRL] .` hotkey for *Resource* settings which apply to the current BinaryView. These settings allow a wide variety of customization of the user interface and functional aspects of the analysis environment.
7+
Binary Ninja's settings are accessible via `[CMD/CTRL] ,` or `[CMD/CTRL] .` (which auto-selects the current BinaryView's scope). These settings provide extensive customization options for both the user interface and analysis functionality.
88

9-
Several search keywords are available in the settings UI. Those include:
10-
11-
- `@default` - Shows settings that are in the default scope
12-
- `@user` - Shows only settings that the user has changed
13-
- `@project` - Shows settings scoped to the current project
14-
- `@resource` - Shows settings scoped to the current resource (for example if you used open-with-options and changed settings)
15-
- `@modified` - Shows settings that are changed from their default values
9+
## Settings Scopes
1610

1711
There are several scopes available for settings:
1812

1913
* **User Settings** - Settings that apply globally and override the defaults. These settings are stored in `settings.json` within the [User Folder](./index.md#user-folder).
2014
* **Project Settings** - Settings which only apply if a project is opened. These settings are stored in `.binaryninja/settings.json` within a Project Folder. Project Folders can exist anywhere except within the User Folder. These settings apply to all files contained in the Project Folder and override the default and user settings. In order to activate this feature, select the Project Settings tab and a clickable "Open Project" link will appear at the top right of the view. Clicking this will create `.binaryninja/settings.json` in the folder of the currently selected binary view. If it already exists, this link will be replaced with the path of the project folder.
21-
* **Resource Settings** - Settings which only apply to a specific BinaryView object within a file. These settings persist in a Binary Ninja Database (.bndb) database or ephemerally in a BinaryView object if a database does not yet exist for a file.
15+
* **Resource Settings** - Settings which only apply to a specific resource (BinaryView or Function) within a file. These settings persist in a Binary Ninja Database (.bndb) database or ephemerally in a BinaryView/Function object if a database does not yet exist for a file.
2216

2317
???+ Info "Tip"
24-
Both the _Project_ and _Resource_ tabs have a drop down indicator (▾) that can be clicked to select the project or resource whose settings you want to adjust.
18+
Both the _Project_ and _Resource_ tabs have a drop down indicator (▾) for selecting which project or resource settings to modify.
19+
20+
### Filter Keywords
21+
22+
The settings UI supports several filter tags to help find specific settings:
23+
24+
- `@default` - Shows settings that are in the default scope
25+
- `@user` - Shows settings changed by the user
26+
- `@project` - Shows project-scoped settings
27+
- `@resource` - Shows resource-scoped settings (BinaryView or Function-specific)
28+
- `@modified` - Shows settings changed from their default values
2529

2630
All settings are uniquely identified with an identifier string. Identifiers are available in the settings UI via the context menu and are useful for finding settings using the search box and for [programmatically](https://api.binary.ninja/binaryninja.settings-module.html) interacting with settings.
2731

28-
**Note**: In order to facilitate reproducible analysis results, when opening a file for the first time, all of the analysis settings are automatically serialized into the _Resource Setting_ scope. This prevents subsequent _User_ and _Project_ setting modifications from unintentionally changing existing analysis results.
32+
## Resource Settings (BinaryView)
33+
34+
To facilitate reproducible analysis results, when opening a file for the first time, all analysis settings are automatically serialized into the BinaryView's Resource Setting scope. This prevents subsequent User and Project setting modifications from unintentionally changing existing settings which may influence analysis results.
35+
36+
### Accessing BinaryView Resource Settings
37+
38+
BinaryView Resource settings can be accessed through:
39+
40+
* **Settings UI**: Use `[CMD/CTRL] .` to open Resource Settings (automatically selects the current BinaryView)
41+
* **Programmatically**: Use the [Settings API](https://api.binary.ninja/binaryninja.settings-module.html) with a BinaryView object as the resource parameter
42+
43+
## Resource Settings (Function)
44+
45+
Binary Ninja supports function-level settings for fine-grained control over analysis parameters. Unlike BinaryView Resource settings which store a complete copy of all analysis settings, Function Resource settings use an inheritance-based storage model. Each function inherits settings from its BinaryView by default, and only stores settings in its own cache when customization is needed for that specific function.
46+
47+
### Accessing Function Resource Settings
48+
49+
Function Resource settings can be accessed through:
50+
51+
* **Context Menu**: Right-click in any analysis view and select "Function Settings" to access a customizable submenu of boolean settings controlled by the Quick Settings system
52+
* **Programmatically**: Use the [Settings API](https://api.binary.ninja/binaryninja.settings-module.html) with a Function object as the resource parameter
53+
54+
!!! note
55+
Function-specific Resource settings are not currently accessible in the Settings UI Resource dropdown tab.
56+
57+
## Quick Settings
58+
59+
Quick Settings provide streamlined access to frequently used boolean analysis settings directly from the context menu within analysis views. This mechanism is designed for efficient per-function customization without requiring the full Settings UI.
60+
61+
By default, no settings are included in the context menus. Individual settings must be explicitly marked for inclusion.
62+
63+
### Using Quick Settings in Context Menus
64+
65+
1. Right-click within any analysis view (Graph, Linear, etc.).
66+
2. Two submenus may appear:
67+
- **Function Analysis** – Contains settings auto-generated by the Workflow system, used to control activity eligibility.
68+
- **Function Settings** – Contains manually added analysis settings for quick toggling in the Function Resource scope.
69+
3. Toggle settings as needed. These changes apply only to the current function’s settings scope.
70+
4. Select "Reset Settings" to clear the function settings and revert to inherited settings from the BinaryView.
71+
72+
### Adding Quick Settings
73+
74+
1. Open the Settings UI
75+
2. Right-click any boolean setting
76+
3. Select “Add to Quick Settings” to add it to the quick access menu
77+
78+
The setting will appear under the `Function Analysis` or the `Function Settings` submenu in applicable context menus.
79+
80+
### Removing Quick Settings
81+
82+
1. Open the Settings UI
83+
2. Right-click on any boolean setting
84+
3. Uncheck “Add to Quick Settings” to remove it from the quick access menu
85+
86+
### Reset Quick Settings
87+
88+
* Right-click within the Settings dialog.
89+
* Select “Reset All Quick Settings”
2990

30-
## All Settings
91+
## Settings Reference
3192

3293
|Category|Setting|Description|Type|Default|Scope|Key|
3394
|---|---|---|---|---|---|---|

lang/c/objctypes.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include "objctypes.h"
2+
#include "binaryninjaapi.h"
3+
4+
using namespace BinaryNinja;
5+
6+
namespace {
7+
8+
bool IsPointerToObjCObject(const Ref<Type>& type)
9+
{
10+
if (!type || type->GetClass() != PointerTypeClass)
11+
return false;
12+
13+
auto childType = type->GetChildType();
14+
if (!childType || childType->GetClass() != NamedTypeReferenceClass)
15+
return false;
16+
17+
auto namedType = childType->GetNamedTypeReference();
18+
return namedType && namedType->GetName().GetString() == "objc_object";
19+
}
20+
21+
} // unnamed namespace
22+
23+
PseudoObjCTypePrinter::PseudoObjCTypePrinter() : TypePrinter("Objective-C") {}
24+
25+
std::vector<InstructionTextToken> PseudoObjCTypePrinter::GetTypeTokensBeforeName(
26+
Ref<Type> type, Ref<Platform> platform, uint8_t baseConfidence, Ref<Type> parentType, BNTokenEscapingType escaping)
27+
{
28+
// It is idiomatic in Objective-C to use `id` rather than `objc_object*`.
29+
if (IsPointerToObjCObject(type))
30+
return {InstructionTextToken {baseConfidence, TypeNameToken, "id"}};
31+
32+
return TypePrinter::GetDefault()->GetTypeTokensBeforeName(type, platform, baseConfidence, parentType, escaping);
33+
}
34+
35+
std::vector<InstructionTextToken> PseudoObjCTypePrinter::GetTypeTokensAfterName(
36+
Ref<Type> type, Ref<Platform> platform, uint8_t baseConfidence, Ref<Type> parentType, BNTokenEscapingType escaping)
37+
{
38+
return TypePrinter::GetDefault()->GetTypeTokensAfterName(type, platform, baseConfidence, parentType, escaping);
39+
}
40+
41+
std::vector<TypeDefinitionLine> PseudoObjCTypePrinter::GetTypeLines(Ref<Type> type, const TypeContainer& types,
42+
const QualifiedName& name, int paddingCols, bool collapsed, BNTokenEscapingType escaping)
43+
{
44+
return TypePrinter::GetDefault()->GetTypeLines(type, types, name, paddingCols, collapsed, escaping);
45+
}

lang/c/objctypes.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
3+
#include "binaryninjaapi.h"
4+
5+
class PseudoObjCTypePrinter : public BinaryNinja::TypePrinter
6+
{
7+
public:
8+
PseudoObjCTypePrinter();
9+
10+
std::vector<BinaryNinja::InstructionTextToken> GetTypeTokensBeforeName(BinaryNinja::Ref<BinaryNinja::Type> type,
11+
BinaryNinja::Ref<BinaryNinja::Platform> platform,
12+
uint8_t baseConfidence = BN_FULL_CONFIDENCE, BinaryNinja::Ref<BinaryNinja::Type> parentType = nullptr,
13+
BNTokenEscapingType escaping = NoTokenEscapingType) override;
14+
15+
std::vector<BinaryNinja::InstructionTextToken> GetTypeTokensAfterName(BinaryNinja::Ref<BinaryNinja::Type> type,
16+
BinaryNinja::Ref<BinaryNinja::Platform> platform,
17+
uint8_t baseConfidence = BN_FULL_CONFIDENCE, BinaryNinja::Ref<BinaryNinja::Type> parentType = nullptr,
18+
BNTokenEscapingType escaping = NoTokenEscapingType) override;
19+
20+
std::vector<BinaryNinja::TypeDefinitionLine> GetTypeLines(BinaryNinja::Ref<BinaryNinja::Type> type,
21+
const BinaryNinja::TypeContainer& types,
22+
const BinaryNinja::QualifiedName& name, int paddingCols = 64, bool collapsed = false,
23+
BNTokenEscapingType escaping = NoTokenEscapingType) override;
24+
};

lang/c/pseudoc.cpp

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ using namespace BinaryNinja;
88

99
PseudoCFunction::PseudoCFunction(LanguageRepresentationFunctionType* type, Architecture* arch, Function* owner,
1010
HighLevelILFunction* highLevelILFunction) :
11-
LanguageRepresentationFunction(type, arch, owner, highLevelILFunction), m_highLevelIL(highLevelILFunction)
11+
LanguageRepresentationFunction(type, arch, owner, highLevelILFunction), m_highLevelIL(highLevelILFunction),
12+
m_typePrinter(type->GetTypePrinter())
1213
{
14+
if (!m_typePrinter) {
15+
m_typePrinter = TypePrinter::GetDefault();
16+
}
1317
}
1418

1519

@@ -177,11 +181,7 @@ BNSymbolDisplayResult PseudoCFunction::AppendPointerTextToken(const HighLevelILI
177181

178182
string PseudoCFunction::GetSizeToken(size_t size, bool isSigned)
179183
{
180-
return TypePrinter::GetDefault()->GetTypeString(
181-
Type::IntegerType(size, isSigned),
182-
nullptr,
183-
QualifiedName()
184-
);
184+
return GetTypePrinter()->GetTypeString(Type::IntegerType(size, isSigned), nullptr, QualifiedName());
185185
}
186186

187187

@@ -546,11 +546,8 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
546546
{
547547
tokens.AppendOpenParen();
548548
tokens.AppendOpenParen();
549-
auto typeTokens = TypePrinter::GetDefault()->GetTypeTokens(
550-
instr.GetType(),
551-
GetArchitecture()->GetStandalonePlatform(),
552-
QualifiedName()
553-
);
549+
auto typeTokens = GetTypePrinter()->GetTypeTokens(
550+
instr.GetType(), GetArchitecture()->GetStandalonePlatform(), QualifiedName());
554551
for (auto& token: typeTokens)
555552
{
556553
tokens.Append(token);
@@ -618,8 +615,11 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
618615
needSeparator = hasBlocks;
619616

620617
// Emit the lines for the statement itself
621-
GetExprTextInternal(*i, tokens, settings, TopLevelOperatorPrecedence, true);
622-
tokens.NewLine();
618+
if (!ShouldSkipStatement(*i))
619+
{
620+
GetExprTextInternal(*i, tokens, settings, TopLevelOperatorPrecedence, true);
621+
tokens.NewLine();
622+
}
623623
}
624624
}();
625625
break;
@@ -1004,14 +1004,12 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
10041004

10051005
const auto variableType = GetHighLevelILFunction()->GetFunction()->GetVariableType(destExpr);
10061006
const auto platform = GetHighLevelILFunction()->GetFunction()->GetPlatform();
1007-
const auto prevTypeTokens =
1008-
variableType ?
1009-
TypePrinter::GetDefault()->GetTypeTokensBeforeName(variableType, platform, variableType.GetConfidence()) :
1010-
vector<InstructionTextToken>{};
1011-
const auto postTypeTokens =
1012-
variableType ?
1013-
TypePrinter::GetDefault()->GetTypeTokensAfterName(variableType, platform, variableType.GetConfidence()) :
1014-
vector<InstructionTextToken>{};
1007+
const auto prevTypeTokens = variableType ?
1008+
GetTypePrinter()->GetTypeTokensBeforeName(variableType, platform, variableType.GetConfidence()) :
1009+
vector<InstructionTextToken> {};
1010+
const auto postTypeTokens = variableType ?
1011+
GetTypePrinter()->GetTypeTokensAfterName(variableType, platform, variableType.GetConfidence()) :
1012+
vector<InstructionTextToken> {};
10151013

10161014
// Check to see if the variable appears live
10171015
bool appearsDead = false;
@@ -1070,14 +1068,12 @@ void PseudoCFunction::GetExprTextInternal(const HighLevelILInstruction& instr, H
10701068

10711069
const auto variableType = GetHighLevelILFunction()->GetFunction()->GetVariableType(variable);
10721070
const auto platform = GetHighLevelILFunction()->GetFunction()->GetPlatform();
1073-
const auto prevTypeTokens =
1074-
variableType ?
1075-
TypePrinter::GetDefault()->GetTypeTokensBeforeName(variableType, platform, variableType.GetConfidence()) :
1076-
vector<InstructionTextToken>{};
1077-
const auto postTypeTokens =
1078-
variableType ?
1079-
TypePrinter::GetDefault()->GetTypeTokensAfterName(variableType, platform, variableType.GetConfidence()) :
1080-
vector<InstructionTextToken>{};
1071+
const auto prevTypeTokens = variableType ?
1072+
GetTypePrinter()->GetTypeTokensBeforeName(variableType, platform, variableType.GetConfidence()) :
1073+
vector<InstructionTextToken> {};
1074+
const auto postTypeTokens = variableType ?
1075+
GetTypePrinter()->GetTypeTokensAfterName(variableType, platform, variableType.GetConfidence()) :
1076+
vector<InstructionTextToken> {};
10811077

10821078
if (variableType)
10831079
{
@@ -2848,6 +2844,15 @@ string PseudoCFunction::GetAnnotationEndString() const
28482844
return " */";
28492845
}
28502846

2847+
TypePrinter* PseudoCFunction::GetTypePrinter() const
2848+
{
2849+
return m_typePrinter;
2850+
}
2851+
2852+
bool PseudoCFunction::ShouldSkipStatement(const BinaryNinja::HighLevelILInstruction& instr)
2853+
{
2854+
return false;
2855+
}
28512856

28522857
PseudoCFunctionType::PseudoCFunctionType(): LanguageRepresentationFunctionType("Pseudo C")
28532858
{

0 commit comments

Comments
 (0)