Skip to content

Commit 591c9e4

Browse files
committed
Rewrite Obj-C workflow in Rust
This is functionally equivalent to the previous workflow_objc, with the following changes: 1. It mutates the `core.function.metaAnalysis` workflow rather than registering a new named workflow. The activities now all check for the presence of the Objective-C metadata added by `ObjCProcessor` to determine whether they should do work, rather than relying on `MachoView` to override the function workflow when Objective-C metadata is present. This fixes #6779. 2. The auto-inlining of `objc_msgSend` selector stub functions is performed in a separate activity from the processing of `objc_msgSend` call sites. The selector stub inlining activity is configured so that it does not run in `DSCView` as the shared cache needs different behavior for stub functions more generally that `SharedCacheWorkflow` already provides. 3. The way that types like `id` and `SEL` are referenced is fixed so that they show up as `id` rather than `objc_struct*`. This also replaces the Objective-C portion of the shared cache's workflow, and incorporates several bug fixes that had been applied to it but not the standalone Objective-C workflow.
1 parent 6ec4685 commit 591c9e4

40 files changed

+943
-1096
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ members = [
1616
"plugins/idb_import",
1717
"plugins/pdb-ng",
1818
"plugins/pdb-ng/demo",
19-
"plugins/warp",
2019
"plugins/svd",
21-
"plugins/svd/demo"
20+
"plugins/svd/demo",
21+
"plugins/warp",
22+
"plugins/workflow_objc",
2223
]
2324

2425
[workspace.dependencies]

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,18 @@ This repository contains all of our Binary View Type plugins available here:
124124

125125
## Other Plugins
126126

127-
* [SVD Loader](https://github.com/Vector35/binaryninja-api/tree/dev/plugins/svd/)
127+
* [Objective-C](https://github.com/Vector35/binaryninja-api/tree/dev/plugins/workflow_objc/)
128128
* [RTTI Analysis](https://github.com/Vector35/binaryninja-api/tree/dev/plugins/rtti/)
129-
* [WARP Integration](https://github.com/Vector35/binaryninja-api/tree/dev/plugins/warp/)
130129
* [Stack Render Layer](https://github.com/Vector35/binaryninja-api/tree/dev/plugins/stack_render_layer/)
130+
* [SVD Loader](https://github.com/Vector35/binaryninja-api/tree/dev/plugins/svd/)
131131
* [Triage View](https://github.com/Vector35/binaryninja-api/tree/dev/examples/triage/)
132+
* [WARP Integration](https://github.com/Vector35/binaryninja-api/tree/dev/plugins/warp/)
132133

133134
## Related Repositories
134135

135-
In addition to this main API repository being open source Vector35 also has open sourced the Debugger and the Objective-C plugins open source as well:
136+
In addition to this main API repository being open source Vector35 also has open sourced the Debugger plugin as well:
136137

137138
* [Debugger](https://github.com/Vector35/debugger)
138-
* [workflow_objc](https://github.com/Vector35/workflow_objc)
139139

140140
## Licensing
141141

docs/guide/objectivec.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
11
# Objective-C
22

3-
Binary Ninja ships with [an additional plugin](https://github.com/Vector35/workflow_objc) for assisting with Objective-C analysis.
3+
Binary Ninja ships with built-in functionality for assisting with Objective-C analysis.
44
A brief summary of the features offered is as follows:
55

6-
- **Function Call Cleanup.** When using the Objective-C workflow, calls to
7-
`objc_msgSend` can be replaced with direct calls to the relevant function's
8-
implementation.
9-
106
- **Name and Type Recovery.** Using runtime information embedded in the
11-
binary, Binary Ninja can automatically apply names and type information to
7+
binary, Binary Ninja automatically applies names and type information to
128
Objective-C functions.
139

1410
- **Structure Markup.** Data variables are automatically created for Objective-C
1511
structures such as classes and method lists to enable easy navigation.
1612

17-
- **Data Renderers.** Formatting of Objective-C types such as tagged and/or
18-
(image-)relative pointers is improved via custom data renderers.
13+
- **String Literal Handling.** Data variables are automatically created for all
14+
`CFString` or `NSString` instances present in the binary.
1915

20-
- **CFString Handling.** Data variables are automatically created for all
21-
`CFString` instances present in the binary.
16+
- **Automatic Call Type Adjustments.** Binary Ninja automatically infers the number of arguments and their names
17+
for individual calls to `objc_msgSend` and `objc_msgSendSuper2`. Argument names are derived from the selector
18+
components, and argument types are inferred in limited cases.
2219

23-
## Usage
20+
- **Pseudo Objective-C Language.** Decompiled code can be displayed using a _Pseudo Objective-C_
21+
language syntax. This renders `objc_msgSend` and other Objective-C runtime calls using the
22+
`[receiver message:argument other:argument2]` syntax found in Objective-C source code.
23+
Additionally, literals such as `CFString` or `NSString` are displayed inline as `@"string"`.
2424

25-
If you have an Objective-C binary opening in Binary Ninja should automatically process
26-
the information. This is handled by the view, e.g. MACH-O & Shared Cache.
25+
- **Direct Call Rewriting.** Calls to `objc_msgSend` can be rewritten to be direct calls to
26+
the first known method implementation for that selector.
27+
28+
This is disabled by default as it will give potentially confusing results for any selector
29+
that has more than one implementation or for common selector names. That said, some users may
30+
still find it to be useful. It can be enabled via `analysis.objectiveC.resolveDynamicDispatch`
31+
setting.
32+
33+
## Usage
2734

28-
### Workflow
35+
Objective-C metadata will be automatically processed when you open a Mach-O or DYLD shared cache binary in Binary Ninja.
2936

30-
To utilize function call cleanup, the Objective-C workflow must be chosen when loading a binary for analysis.
37+
The Pseudo Objective-C Language representation is available via the language pop-up menu at the top of Linear and Graph views:
3138

32-
![](../img/objc-workflow-selected.png)
39+
![](../img/pseudo-objc-menu-item.png)
3340

34-
This will automatically apply structure analysis as the binary is analyzed and
35-
also translate `objc_msgSend` calls to direct method calls, where possible.
-69.5 KB
Binary file not shown.

docs/img/pseudo-objc-menu-item.png

253 KB
Loading

plugins/warp/src/plugin.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use binaryninja::background_task::BackgroundTask;
1212
use binaryninja::command::{
1313
register_command, register_command_for_function, register_command_for_project,
1414
};
15+
use binaryninja::is_ui_enabled;
1516
use binaryninja::logger::Logger;
1617
use binaryninja::settings::Settings;
17-
use binaryninja::{add_optional_plugin_dependency, is_ui_enabled};
1818
use log::LevelFilter;
1919
use reqwest::StatusCode;
2020

@@ -200,9 +200,3 @@ pub extern "C" fn CorePluginInit() -> bool {
200200

201201
true
202202
}
203-
204-
#[unsafe(no_mangle)]
205-
pub extern "C" fn CorePluginDependencies() {
206-
// TODO: Remove this once the objectivec workflow is registered on the meta workflow.
207-
add_optional_plugin_dependency("workflow_objc");
208-
}

plugins/workflow_objc/.clang-format

Lines changed: 0 additions & 4 deletions
This file was deleted.

plugins/workflow_objc/.gitignore

Lines changed: 0 additions & 7 deletions
This file was deleted.

plugins/workflow_objc/BinaryNinja.h

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)