From 40bdfac7b71dd1cbe9223b82518053f80268e2a8 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 16 Aug 2022 20:49:02 -0400 Subject: Splitting of variables --- docs/getting-started.md | 34 ++++++++++++++++++++++++++++++++++ docs/img/merge-vars-dialog.png | Bin 0 -> 58976 bytes docs/img/merge-vars.png | Bin 0 -> 63066 bytes docs/img/split-var.png | Bin 0 -> 54707 bytes 4 files changed, 34 insertions(+) create mode 100644 docs/img/merge-vars-dialog.png create mode 100644 docs/img/merge-vars.png create mode 100644 docs/img/split-var.png (limited to 'docs') diff --git a/docs/getting-started.md b/docs/getting-started.md index d6c6adc3..cddea0a4 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -233,6 +233,7 @@ Any action in the [action system](#command-palette) can have a custom hotkey map - `[CMD-SHIFT] -` (macOS) : Graph view zoom out - `[CTRL-SHIFT] +` (Windows/Linux) : Graph view zoom in - `[CTRL-SHIFT] -` (Windows/Linux) : Graph view zoom out + - `=` : Merge variables - Other hotkeys specifically for working with types are in the [type guide](guide/type.md#direct-ui-manipulation) ### Graph View @@ -499,6 +500,39 @@ Performing this action on both variables in the example results in the following ![Dead Store Elimination Results](img/dead-store-after.png "Dead Store Elimination Results") +### Merging and Splitting Variables + +Binary Ninja automatically splits all variables that the analysis determines to be safely splittable. This allows +the user to assign different types to different uses of the same register or memory location. Sometimes, however, +the code is more clear if two or more of these variables are merged together into a single variable. + +![Merge Variables Menu >](img/merge-vars.png "Merge Variables Menu") + +To merge variables, first click on the variable that the others should be merged into. Then, select "Merge Variables..." from the context menu (the default keybind for this action is `=`). This will bring up a dialog where the variables +to be merged in can be selected. All selected variables will be merged into the target variable, inheriting the name +and type of the variable that was first clicked. + +![Merge Variables Dialog](img/merge-vars-dialog.png "Merge Variables Dialog") + +To unmerge a variable, either select "Split Merged Variable" from the context menu, or reenter the "Merge Variables..." +dialog and deselect the variables that should no longer be merged. + +![Split Variable >](img/split-var.png "Split Variable") + +Variables that have multiple definitions can be manually split into multiple variables by clicking on the +variable at a definition site and selecting "Split Variable at Definition" from the context menu. + +!!! Warning "Warning" + Splitting a variable manually can cause IL and decompilation to be incorrect. There are some + patterns where variables can be safely split semantically but analysis cannot determine that + it is safe, and this feature is provided to allow variable splitting to be performed in these + cases. + +Manually split variables will initially provide the selected definition as a separate variable, and all other +definitions will be automatically resolved into one or more other variables. If some of the definitions should +have been included as part of the same variable, use "Merge Variables..." from the context menu after splitting +to select which of the other definitions should be merged. + ### Script (Python) Console ![console >](img/console.png "Console") diff --git a/docs/img/merge-vars-dialog.png b/docs/img/merge-vars-dialog.png new file mode 100644 index 00000000..722503c9 Binary files /dev/null and b/docs/img/merge-vars-dialog.png differ diff --git a/docs/img/merge-vars.png b/docs/img/merge-vars.png new file mode 100644 index 00000000..3038b1db Binary files /dev/null and b/docs/img/merge-vars.png differ diff --git a/docs/img/split-var.png b/docs/img/split-var.png new file mode 100644 index 00000000..72f45e85 Binary files /dev/null and b/docs/img/split-var.png differ -- cgit v1.3.1