Skip to content

Commit 0b199d1

Browse files
committed
Mark DVP overlay data as qwords for compact display
- Added applyQWordDataType() helper method to format overlay blocks - VU instructions (16 bytes) now display as 2 qwords for better readability - Applied to both overlay table blocks and VU section overlays - Uses proper transaction management and TaskMonitor support
1 parent 6a542d2 commit 0b199d1

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

src/main/java/ghidra/emotionengine/dvp/DvpOverlayTable.java

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import ghidra.program.model.address.Address;
88
import ghidra.program.model.data.*;
99
import ghidra.program.model.listing.Data;
10+
import ghidra.program.model.listing.Listing;
1011
import ghidra.program.model.listing.Program;
1112
import ghidra.program.model.mem.Memory;
1213
import ghidra.program.model.mem.MemoryBlock;
@@ -40,6 +41,38 @@ private Structure getDvpExtOverlay() {
4041
return struct;
4142
}
4243

44+
/**
45+
* Apply QWord data type to the memory block for compact display.
46+
* VU instructions are 16 bytes (2 qwords), so marking as qwords provides better visualization.
47+
*/
48+
private void applyQWordDataType(Program program, MemoryBlock block, TaskMonitor monitor) {
49+
int txId = program.startTransaction("Apply QWord data type to " + block.getName());
50+
try {
51+
Listing listing = program.getListing();
52+
Address addr = block.getStart();
53+
Address end = block.getEnd();
54+
DataType qword = QWordDataType.dataType;
55+
56+
while (addr.compareTo(end) <= 0) {
57+
monitor.checkCancelled();
58+
try {
59+
// Only create data if there isn't already data at this location
60+
if (listing.getDataAt(addr) == null) {
61+
listing.createData(addr, qword);
62+
}
63+
addr = addr.add(8); // QWord is 8 bytes
64+
} catch (Exception e) {
65+
// If we can't create data here (e.g., not enough bytes), skip
66+
break;
67+
}
68+
}
69+
program.endTransaction(txId, true);
70+
} catch (Exception e) {
71+
program.endTransaction(txId, false);
72+
elf.getLog().appendException(e);
73+
}
74+
}
75+
4376
@Override
4477
public void parse(TaskMonitor monitor) throws Exception {
4578
Memory mem = elf.getProgram().getMemory();
@@ -50,11 +83,11 @@ public void parse(TaskMonitor monitor) throws Exception {
5083
// only 1 function
5184
ElfSectionHeader section = elfHeader.getSection(".vutext");
5285
if (section != null) {
53-
parseVuSection(elf, section);
86+
parseVuSection(elf, section, monitor);
5487
}
5588
section = elfHeader.getSection(".vudata");
5689
if (section != null) {
57-
parseVuSection(elf, section);
90+
parseVuSection(elf, section, monitor);
5891
}
5992
return;
6093
}
@@ -128,14 +161,17 @@ public void parse(TaskMonitor monitor) throws Exception {
128161
// }
129162
block.setRead(true);
130163
block.setWrite(section.isWritable());
164+
165+
// Apply QWord data type for compact display
166+
applyQWordDataType(elf.getProgram(), block, monitor);
131167
}
132168
catch (Exception e) {
133169
elf.getLog().appendException(e);
134170
}
135171
}
136172
}
137173

138-
private void parseVuSection(ElfLoadHelper elfLoadHelper, ElfSectionHeader section) {
174+
private void parseVuSection(ElfLoadHelper elfLoadHelper, ElfSectionHeader section, TaskMonitor monitor) {
139175
Program program = elfLoadHelper.getProgram();
140176
Memory mem = program.getMemory();
141177
long base = section.isExecutable() ? VU1_TEXT_ADDRESS : VU1_DATA_ADDRESS;
@@ -161,6 +197,9 @@ private void parseVuSection(ElfLoadHelper elfLoadHelper, ElfSectionHeader sectio
161197
// EmotionEngineLoader.setMicroMode(program, block);
162198
// elfLoadHelper.createOneByteFunction(null, block.getStart(), true);
163199
// }
200+
201+
// Apply QWord data type for compact display
202+
applyQWordDataType(program, block, monitor);
164203
} catch (Exception e) {
165204
elfLoadHelper.getLog().appendException(e);
166205
}

0 commit comments

Comments
 (0)