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

Edit Function dialogue chooses incorrect type when confronted with a typedef using the same name (see Microsoft VC headers). #6430

Closed
Wall-AF opened this issue Apr 16, 2024 · 4 comments
Assignees

Comments

@Wall-AF
Copy link

Wall-AF commented Apr 16, 2024

Describe the bug
Given a function definition of
void _PVFV()
and a typedef of
typedef _PVFV _PVFV *
(used often in MS source files) trying to use the typedef'd version in the Edit Function dialogue doesn't work, it uses a pointer to the function instead.

To Reproduce
Steps to reproduce the behavior:

  1. Setup a function and the typedef above
  2. Setup some data as the typedef'd verison (in your data area)
  3. Find a function (such as _initterm) and edit it to try to define it as void _initterm (_PVFV * pfbegin, _PVFV * pfend)
  4. Look at call and see casts (thy should not be there)

In step 3 you are asked which _PVFV type you mean, but Ghidra always reverts to the function definition!

Expected behavior
For the editor to use the correct type.

Screenshots
N/A

Attachments
N/A

Environment (please complete the following information):

  • OS: Windows 11
  • Java Version: 17.0.3.1
  • Ghidra Version: 11.1-DEV
  • Ghidra Origin: locally

Additional context
If you rename the typedef and use that, everything works. You can even then rename it back and, providing you don't edit it again, all's well!

@ryanmkurtz ryanmkurtz added the Status: Triage Information is being gathered label May 15, 2024
@ghidra1
Copy link
Collaborator

ghidra1 commented May 15, 2024

I assume these are contained with different Categories. Otherwise, Ghidra would have named one of them with a .conflict suffix.

@Wall-AF
Copy link
Author

Wall-AF commented May 15, 2024

I assume these are contained with different Categories. Otherwise, Ghidra would have named one of them with a .conflict suffix.

Correct. FYI here's a snapshot:
image

@ghidra1
Copy link
Collaborator

ghidra1 commented May 17, 2024

If your situation is simialr to my test, you start with three types:

  1. Function Definition (internal.h/functions/_PVFV)
  2. A pointer to the Function Definition (internal.h/functions/_PVFV *), and
  3. A typedef to the pointer to FunctionDefinition (internal.h/_PVFV)

Note that No.2 type above can be seen in tree if you enable Pointer toggle button (PointerFinger). It is also important to note that the use of the datatype chooser does not facilitate subsequent modification within the table edit box (e.g., adding a * to force a pointer). This will cause it to search again. Since their is only one "_PVFV *" defined it will use that one (No.2 type above). You will need to first establish a pointer to your _PVFV typedef in the datatype tree before you can select it from the datatype chooser.

@Wall-AF
Copy link
Author

Wall-AF commented May 18, 2024

Mmm, seems to work now.

@Wall-AF Wall-AF closed this as completed May 18, 2024
@ryanmkurtz ryanmkurtz removed the Status: Triage Information is being gathered label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants