Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2025-03-13 12:12:27 -04:00
commit 825e8b811d
3 changed files with 18 additions and 7 deletions

View file

@ -32,7 +32,8 @@ import ghidra.app.services.DataTypeManagerService;
import ghidra.app.util.datatype.DataTypeSelectionEditor; import ghidra.app.util.datatype.DataTypeSelectionEditor;
import ghidra.app.util.datatype.NavigationDirection; import ghidra.app.util.datatype.NavigationDirection;
import ghidra.program.model.address.Address; import ghidra.program.model.address.Address;
import ghidra.program.model.data.*; import ghidra.program.model.data.AbstractFloatDataType;
import ghidra.program.model.data.DataType;
import ghidra.program.model.lang.Register; import ghidra.program.model.lang.Register;
import ghidra.program.model.listing.*; import ghidra.program.model.listing.*;
import ghidra.util.HelpLocation; import ghidra.util.HelpLocation;
@ -132,12 +133,12 @@ public class StorageAddressEditorDialog extends DialogComponentProvider
private void setDataType(DataType dt) { private void setDataType(DataType dt) {
currentDataType = dt; currentDataType = dt;
size = dt.getLength(); size = dt.getLength();
boolean unconstrained = (dt instanceof AbstractFloatDataType) || Undefined.isUndefined(dt); boolean unconstrained = (dt instanceof AbstractFloatDataType) || (dt == DataType.DEFAULT);
model.setRequiredSize(size, unconstrained); model.setRequiredSize(size, unconstrained);
if (sizeLabel != null) { if (sizeLabel != null) {
sizeLabel.setText(Integer.toString(size)); sizeLabel.setText(Integer.toString(size));
dataChanged();
} }
model.notifyDataChanged();
} }
private void maybeHandleTabNavigation() { private void maybeHandleTabNavigation() {

View file

@ -155,7 +155,6 @@ class StorageAddressModel {
void notifyDataChanged() { void notifyDataChanged() {
validate(); validate();
SwingUtilities.invokeLater(() -> listener.dataChanged()); SwingUtilities.invokeLater(() -> listener.dataChanged());
} }
@ -174,6 +173,7 @@ class StorageAddressModel {
} }
else if (currentSize < requiredSize) { else if (currentSize < requiredSize) {
statusText = "Warning: Not enough storage space allocated"; statusText = "Warning: Not enough storage space allocated";
return false;
} }
else if (currentSize > requiredSize) { else if (currentSize > requiredSize) {
statusText = "Warning: Too much storage space allocated"; statusText = "Warning: Too much storage space allocated";

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -155,7 +155,14 @@ class VarnodeTableModel extends AbstractGTableModel<VarnodeInfo> {
return; return;
} }
if (aValue instanceof Address) { if (aValue instanceof Address) {
storageModel.setVarnode(varnode, (Address) aValue, varnode.getSize()); Integer size = varnode.getSize();
if (size == null) {
size = storageModel.getRequiredSize() - storageModel.getCurrentSize();
if (size <= 0) {
size = 1;
}
}
storageModel.setVarnode(varnode, (Address) aValue, size);
} }
else if (aValue instanceof Register) { else if (aValue instanceof Register) {
storageModel.setVarnode(varnode, (Register) aValue); storageModel.setVarnode(varnode, (Register) aValue);
@ -187,6 +194,9 @@ class VarnodeTableModel extends AbstractGTableModel<VarnodeInfo> {
} }
Address address = varnode.getAddress(); Address address = varnode.getAddress();
int size = (Integer) aValue; int size = (Integer) aValue;
if (size <= 0) {
return;
}
if (address != null) { if (address != null) {
Register reg = varnode.getRegister(); Register reg = varnode.getRegister();
if (reg != null && reg.isBigEndian()) { if (reg != null && reg.isBigEndian()) {