Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support typedefd types #74

Open
alexrp opened this issue May 31, 2023 · 3 comments
Open

Support typedefd types #74

alexrp opened this issue May 31, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@alexrp
Copy link

alexrp commented May 31, 2023

Description

If I have e.g. typedef void* HANDLE; in Binary Ninja and I retype a function parameter as HANDLE, BinSync saves it as just void*.

I wonder if there's a way to preserve the typedef in such cases?

Steps to reproduce the bug

  1. Create a type: typedef void* HANDLE;.
  2. Change a parameter type to HANDLE.
  3. Sync the changes.

Environment

Binary Ninja 3.5.4311-dev Personal (ff27871c)

Additional context

No response

@alexrp alexrp added the bug Something isn't working label May 31, 2023
@mahaloz mahaloz added enhancement New feature or request and removed bug Something isn't working labels May 31, 2023
@mahaloz mahaloz changed the title typedef'd types are not preserved (Binary Ninja) Support typedefd types in BinSync May 31, 2023
@mahaloz
Copy link
Member

mahaloz commented May 31, 2023

So this one is actually rather hard and shows how little I use typedefd types. At a fundamental level, typedefed types are different artifact types in BinSync. Currently, we support Struct, which can be a user-defined type, but we have no way to save (or catch) types that are just aliases for primitive types.

To support this we need to support typedef types like we do with things like structs here:
https://github.com/binsync/binsync/blob/main/binsync/data/struct.py

In a bsproj, this can be seen like this:
https://github.com/binsync/example.bsproj/blob/binsync/mahaloz/structs/mahaloz_struct.toml

Proposed changes

  1. Create the new artifact type: typedef, add it to list of supported artifacts
  2. Add the dumper and loader to state
  3. Add a callback to Binja to create it on change

@alexrp
Copy link
Author

alexrp commented Jun 1, 2023

If I have e.g. typedef void* HANDLE; in Binary Ninja and I retype a function parameter as HANDLE, BinSync saves it as just void*.

Just correcting myself: I don't know where I got this notion from, but BinSync does actually record the parameter as the typedef type name. It's just that the typedef itself isn't synced.

@mahaloz
Copy link
Member

mahaloz commented Jun 1, 2023

@alexrp this is good to know and what should happen in the current setup.

@mahaloz mahaloz transferred this issue from binsync/binsync May 29, 2024
@mahaloz mahaloz changed the title Support typedefd types in BinSync Support typedefd types May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants