ghidra: Union of pointers is not shown correctly in Decompiler
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
Union with pointers to structures
Dissassembly
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)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 18
- Comments: 18 (3 by maintainers)
Having the ability to define unions at all seems kind of useless without this.
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…
I’m running into this issue as well: without being able to manually annotate union accesses, the type inference engine gets horribly confused: it sees the same memory location being accessed as both a byte and a word and starts generating gibberish code. It really needs human intervention to proceed.
I think this happens for any union, not just a union of pointers.
The feature you are requesting is called “Select union member” in IDA Pro.
Indeed, it is required as union are used everywhere in places like the Windows kernel.
Closed by 31b30adf2dfdd2688cc0e4e7cd01d125fc27c45b