mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-21 19:42:14 +00:00
GT-2703: changed "force" option to "drop extra bytes" in intel hex
options
This commit is contained in:
parent
3cbd8de918
commit
6fad64426a
@ -308,7 +308,7 @@
|
||||
address space.</LI>
|
||||
<LI><B>Record Size</B> - Specifies the size (in bytes) of each record in the
|
||||
output file. The default 16.</LI>
|
||||
<LI><B>Force</B> - If checked, this will ensure that <b>only</b> records matching
|
||||
<LI><B>Drop Extra Bytes</B> - If checked, this will ensure that <b>only</b> records matching
|
||||
the record size will be output. eg: if you set the record size to 16 but there are
|
||||
18 bytes selected, you will see only one line of 16 bytes in the output; the remaining
|
||||
2 bytes will be dropped.</LI>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 8.6 KiB |
@ -39,8 +39,8 @@ import ghidra.util.task.TaskMonitor;
|
||||
* <p>
|
||||
* The output defaults to lines of 16-bytes but this is configurable using the
|
||||
* {@link #recordSizeOption} attribute. This allows users to select any record size
|
||||
* up to the max of 0xFF. Users may also choose to <code>force</code> a record size for every line
|
||||
* of output, which will only print out lines that match the max record size; any other
|
||||
* up to the max of 0xFF. Users may also choose to <code>Drop Extra Bytes</code>, which will
|
||||
* cause only lines that match the max record size to be printed; any other
|
||||
* bytes will be dropped. If this option is not set, every byte will be represented in the output.
|
||||
*/
|
||||
public class IntelHexExporter extends Exporter {
|
||||
@ -100,8 +100,8 @@ public class IntelHexExporter extends Exporter {
|
||||
|
||||
/**
|
||||
* Option for exporting Intel Hex records that allows users to specify a record size for the
|
||||
* output. Users may also optionally specify a <code>force</code> option that will only output
|
||||
* lines that match this maximum size.
|
||||
* output. Users may also optionally select the <code>Drop Extra Bytes</code> option that
|
||||
* will cause only those records that match the maximum size to be output to the file.
|
||||
*
|
||||
* @see RecordSizeComponent
|
||||
*/
|
||||
@ -140,8 +140,8 @@ public class IntelHexExporter extends Exporter {
|
||||
return Integer.class;
|
||||
}
|
||||
|
||||
public boolean getForce() {
|
||||
return comp.getForce();
|
||||
public boolean dropExtraBytes() {
|
||||
return comp.dropExtraBytes();
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,28 +151,28 @@ public class IntelHexExporter extends Exporter {
|
||||
* <ul>
|
||||
* <li><code>input</code>: a {@link HintTextField} for entering numeric digits; these
|
||||
* represent the record size for each line of output</li>
|
||||
* <li>forceCb: a {@link JCheckBox} for specifying the <code>force</code> setting; this
|
||||
* enforces that every line in the output matches the specified record size</li>
|
||||
* <li>dropCb: a {@link JCheckBox} for specifying a setting that enforces that every line in
|
||||
* the output matches the specified record size</li>
|
||||
* </ul>
|
||||
*
|
||||
* Note: If the <code>force</code> option is set, any bytes that are left over after outputting
|
||||
* all lines that match the record size will be dropped on the floor.
|
||||
* Note: If the <code>Drop Extra Bytes</code> option is set, any bytes that are left over
|
||||
* after outputting all lines that match the record size will be omitted from the output.
|
||||
*/
|
||||
private class RecordSizeComponent extends JPanel {
|
||||
|
||||
private HintTextField input;
|
||||
private JCheckBox forceCb;
|
||||
private JCheckBox dropCb;
|
||||
|
||||
public RecordSizeComponent(int recordSize) {
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
input = new HintTextField(String.valueOf(recordSize), false, new BoundedIntegerVerifier());
|
||||
forceCb = new JCheckBox("force");
|
||||
dropCb = new JCheckBox("Drop Extra Bytes");
|
||||
|
||||
input.setText(String.valueOf(recordSize));
|
||||
|
||||
add(input, BorderLayout.CENTER);
|
||||
add(forceCb, BorderLayout.EAST);
|
||||
add(dropCb, BorderLayout.EAST);
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
@ -184,8 +184,8 @@ public class IntelHexExporter extends Exporter {
|
||||
return Integer.valueOf(val);
|
||||
}
|
||||
|
||||
public boolean getForce() {
|
||||
return forceCb.isSelected();
|
||||
public boolean dropExtraBytes() {
|
||||
return dropCb.isSelected();
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,9 +276,9 @@ public class IntelHexExporter extends Exporter {
|
||||
AddressSetView addrSetView, TaskMonitor monitor) throws MemoryAccessException {
|
||||
|
||||
int size = (int) recordSizeOption.getValue();
|
||||
boolean forceSize = recordSizeOption.getForce();
|
||||
boolean dropBytes = recordSizeOption.dropExtraBytes();
|
||||
|
||||
IntelHexRecordWriter writer = new IntelHexRecordWriter(size, forceSize);
|
||||
IntelHexRecordWriter writer = new IntelHexRecordWriter(size, dropBytes);
|
||||
|
||||
AddressSet set = new AddressSet(addrSetView);
|
||||
|
||||
|
@ -22,7 +22,7 @@ import ghidra.program.model.address.*;
|
||||
public class IntelHexRecordWriter {
|
||||
|
||||
private final int maxBytesPerLine;
|
||||
private final boolean forceSize;
|
||||
private final boolean dropExtraBytes;
|
||||
|
||||
private Address startAddress = null;
|
||||
private Long oldSegment = null;
|
||||
@ -36,15 +36,15 @@ public class IntelHexRecordWriter {
|
||||
* Constructor
|
||||
*
|
||||
* @param maxBytesPerLine the maximum number of bytes to write per line in the hex output
|
||||
* @param forceSize if true, only lines matching {@link #maxBytesPerLine} will be output;
|
||||
* @param dropExtraBytes if true, only lines matching {@link #maxBytesPerLine} will be output;
|
||||
* remaining bytes will be left out
|
||||
*/
|
||||
public IntelHexRecordWriter(int maxBytesPerLine, boolean forceSize) {
|
||||
public IntelHexRecordWriter(int maxBytesPerLine, boolean dropExtraBytes) {
|
||||
if (maxBytesPerLine > IntelHexRecord.MAX_RECORD_LENGTH) {
|
||||
throw new IllegalArgumentException("maxBytesPerLine > IntelHexRecord.MAX_RECORD_LENGTH");
|
||||
}
|
||||
this.maxBytesPerLine = maxBytesPerLine;
|
||||
this.forceSize = forceSize;
|
||||
this.dropExtraBytes = dropExtraBytes;
|
||||
}
|
||||
|
||||
public void addByte(Address address, byte b) {
|
||||
@ -129,8 +129,9 @@ public class IntelHexRecordWriter {
|
||||
public List<IntelHexRecord> finish(Address entryPoint) {
|
||||
|
||||
// Before finalizing things, write out any remaining bytes that haven't yet been written, if
|
||||
// the user has specified to do so via the force option (false = write out everything).
|
||||
if (bytes.size() > 0 && !forceSize) {
|
||||
// the user has specified to do so via the drop extra bytes option (false =
|
||||
// write out everything).
|
||||
if (bytes.size() > 0 && !dropExtraBytes) {
|
||||
emitData();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user