summaryrefslogtreecommitdiff
path: root/rust/plugin_examples/data_renderer/README.md
blob: 794b93b950f43bd62b0c6335bed1db9e09f9618c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Data Renderer Example

This example implements a simple data renderer for the Mach-O load command LC_UUID.
You can try the renderer by loading the `/bin/cat` binary from macOS.

We're implementing a functionality similar to the one described in the Python data renderer blog post: 
https://binary.ninja/2024/04/08/customizing-data-display.html.

## Building

```sh
# Build from the root directory (binaryninja-api)
cargo build --manifest-path rust/plugin_examples/data_renderer/Cargo.toml
# Link binary on macOS
ln -sf $PWD/target/debug/libexample_data_renderer.dylib ~/Library/Application\ Support/Binary\ Ninja/plugins
```

## Result

The following Mach-O load command be will be transformed from

```c
struct uuid __macho_load_command_[10] = 
{
    enum load_command_type_t cmd = LC_UUID
    uint32_t cmdsize = 0x18
    uint8_t uuid[0x10] = 
    {
        [0x0] =  0x74
        [0x1] =  0xa0
        [0x2] =  0x3a
        [0x3] =  0xbd
        [0x4] =  0x1e
        [0x5] =  0x19
        [0x6] =  0x32
        [0x7] =  0x67
        [0x8] =  0x9a
        [0x9] =  0xdc
        [0xa] =  0x42
        [0xb] =  0x99
        [0xc] =  0x4e
        [0xd] =  0x26
        [0xe] =  0xa2
        [0xf] =  0xb7
    }
}
```

into the following representation

```c
struct uuid __macho_load_command_[10] = 
{
    enum load_command_type_t cmd = LC_UUID
    uint32_t cmdsize = 0x18
    uint8_t uuid[0x10] = UUID("74a03abd-1e19-3267-9adc-42994e26a2b7")
}
```

You can compare the shown UUID with the output of otool:
```sh
otool -arch all -l /bin/cat
```