Merge remote-tracking branch 'origin/Ghidra_9.1'

This commit is contained in:
Ryan Kurtz
2019-10-16 08:12:27 -04:00
3 changed files with 43 additions and 8 deletions
@@ -30,7 +30,7 @@ import ghidra.util.exception.AssertException;
import ghidra.util.layout.VerticalLayout; import ghidra.util.layout.VerticalLayout;
import resources.icons.ColorIcon; import resources.icons.ColorIcon;
public class BitFieldPlacementComponent extends JPanel { public class BitFieldPlacementComponent extends JPanel implements Scrollable {
private static final int CELL_HEIGHT = 25; private static final int CELL_HEIGHT = 25;
private static final int ZERO_BIT_WIDTH = 3; private static final int ZERO_BIT_WIDTH = 3;
@@ -145,6 +145,33 @@ public class BitFieldPlacementComponent extends JPanel {
init(null); init(null);
} }
@Override
public Dimension getPreferredScrollableViewportSize() {
return getPreferredSize();
}
@Override
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
// NOTE: consider forcing visibleRect edge alignment to byte boundary based upon direction
return byteWidth;
}
@Override
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
// NOTE: consider forcing visibleRect edge alignment to byte boundary based upon direction
return visibleRect.width;
}
@Override
public boolean getScrollableTracksViewportWidth() {
return false;
}
@Override
public boolean getScrollableTracksViewportHeight() {
return true;
}
private class MyMouseWheelListener implements MouseWheelListener { private class MyMouseWheelListener implements MouseWheelListener {
@Override @Override
@@ -303,7 +303,8 @@ public class RetypeVariableAction extends AbstractDecompilerAction {
return true; return true;
} }
VariableStorage storage = param.getStorage(); VariableStorage storage = param.getStorage();
if (!storage.equals(parameters[i].getVariableStorage())) { // Don't compare using the equals method so that DynamicVariableStorage can match
if (0 != storage.compareTo(parameters[i].getVariableStorage())) {
return true; return true;
} }
} }
@@ -359,12 +359,13 @@ public class HighFunctionDBUtil {
} }
/** /**
* Get database parameter which corresponds to HighParam committing all parameters to * Get database parameter which corresponds to HighParam, where we anticipate that
* database if necessary * the parameter will be modified to match the HighParam. The entire prototype is
* @param param * committed to the database if necessary. An exception is thrown if a modifiable parameter
* @return matching parameter or null if not found * can't be found/created.
* @throws DuplicateNameException * @param param is the HighParam describing the desired function parameter
* @throws InvalidInputException * @return the matching parameter that can be modified
* @throws InvalidInputException if the desired parameter cannot be modified
*/ */
private static Parameter getDatabaseParameter(HighParam param) throws InvalidInputException { private static Parameter getDatabaseParameter(HighParam param) throws InvalidInputException {
@@ -373,6 +374,12 @@ public class HighFunctionDBUtil {
int slot = param.getSlot(); int slot = param.getSlot();
Parameter[] parameters = function.getParameters(); Parameter[] parameters = function.getParameters();
if (slot < parameters.length) {
if (parameters[slot].isAutoParameter()) {
throw new InvalidInputException(
"Cannot modify auto-parameter: " + parameters[slot].getName());
}
}
if (slot >= parameters.length || if (slot >= parameters.length ||
!parameters[slot].getVariableStorage().equals(param.getStorage())) { !parameters[slot].getVariableStorage().equals(param.getStorage())) {
try { try {