question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Union of pointers is not shown correctly in Decompiler

See original GitHub issue

Describe the bug When creating structure with union of pointers to another structure on disasembly it appears to be shown incorectly in disassembler.

Screenshots Main Structure 2 Union with pointers to structures 3 Dissassembly 1

Expected behavior When we have union in struture what is union of pointers to different structures i expect it to:

  • be able to pick member of union
  • show code in dissasembly view with actual union field and then eventually offset it. In this case we should get something like this if (pUnit->eUnitType == UNITTYPE_Object) { *(D2ShrinesTxt **)(pUnit->pUnitData->pDataObject[8]) = pShrinesTxt; return; } instead of code shown above on screenshot.
  • after rightclicking we should be able to select what union member we want to use.

Environment (please complete the following information):

  • OS: Windows 10
  • Java Version: jdk-11.0.2
  • Ghidra Version: 9.0 (first public version)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:18
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
sagian2005commented, Jul 20, 2021

Having the ability to define unions at all seems kind of useless without this.

2reactions
dzik87commented, Dec 19, 2020

It’s been almost 2 years and this issue is still not resolved. Maybe we can have some more attention on this topic? Or at least official statement it will/will not be implemented. We are in this void for quite some time…

Read more comments on GitHub >

github_iconTop Results From Across the Web

c++ - Union of object vs Union of pointers - Stack Overflow
Adding a constructor and a destructor made your code compileable, but it did not make it correct. The problem inherent in the original...
Read more >
Igor's tip of the week #75: Working with unions - Hex Rays
In C, union is a type similar to a struct but in which all members (possibly of different types) occupy the same memory,...
Read more >
Union in C - GeeksforGeeks
Like Structures, union is a user defined data type. In union, all members share the same memory location. For example in the following...
Read more >
Type punning isn't funny: Using pointers to recast in C is bad.
I show you a technique to perform reinterpret casts safely in your own code. ... The compiler will treat both "puns" as unrelated...
Read more >
Unionize Your Variables – An Introduction To Advanced Data ...
However, unlike a struct , the fields inside a union are not ... the compiler will pack them, so your code might not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found