Java Code Examples for ghidra.program.model.listing.Function#getStackPurgeSize()
The following examples show how to use
ghidra.program.model.listing.Function#getStackPurgeSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FunctionPurgeTableColumn.java From ghidra with Apache License 2.0 | 6 votes |
@Override public String getValue(Function rowObject, Settings settings, Program pgm, ServiceProvider serviceProvider) throws IllegalArgumentException { Function function = rowObject; String stringDepth = "UNK"; int depth = function.getStackPurgeSize(); switch (depth) { case Function.INVALID_STACK_DEPTH_CHANGE: stringDepth = "INV"; break; case Function.UNKNOWN_STACK_DEPTH_CHANGE: stringDepth = "UNK"; break; default: if (depth < 0) { stringDepth = "-" + Integer.toHexString(-depth); } else { stringDepth = Integer.toHexString(depth); } } return stringDepth; }
Example 2
Source File: DecompilerParallelConventionAnalysisCmd.java From ghidra with Apache License 2.0 | 5 votes |
private SourceType updateCallingConvention(Function f, SourceType signatureSource, HighFunction highFunction, String modelName) throws InvalidInputException { // do the number of parameters disagree and decompiler says there is one more Namespace parentNamespace = f.getParentNamespace(); if (f.getParameterCount() + 1 == highFunction.getFunctionPrototype().getNumParams()) { // does it have a namespace if (parentNamespace.getID() != Namespace.GLOBAL_NAMESPACE_ID && // prevent accidental treatment of std namespace as class !parentNamespace.getName().equals(STD_NAMESPACE)) { // does it have a this call convention that is the equivalent of the stdcall PrototypeModel callingConvention = program.getCompilerSpec().getCallingConvention( CompilerSpec.CALLING_CONVENTION_thiscall); if (callingConvention != null) { modelName = CompilerSpec.CALLING_CONVENTION_thiscall; } } } // Then is __thiscall, create an object and new parameter if it doesn't have one yet. if (modelName.equals(CompilerSpec.CALLING_CONVENTION_stdcall) && f.getStackPurgeSize() == 0 && f.getParameterCount() > 0) { // if has parameters, and there is no purge, it can't be a stdcall, change it to cdecl if (program.getLanguageID().getIdAsString().startsWith("x86:LE:32")) { modelName = CompilerSpec.CALLING_CONVENTION_cdecl; // it could be a this call... } } if (parentNamespace.getSymbol().getSymbolType() == SymbolType.NAMESPACE && modelName.equals(CompilerSpec.CALLING_CONVENTION_thiscall)) { NamespaceUtils.convertNamespaceToClass(f.getParentNamespace()); } f.setCallingConvention(modelName); if (signatureSource == SourceType.DEFAULT) { signatureSource = SourceType.ANALYSIS; } return signatureSource; }
Example 3
Source File: EditFunctionPurgeAction.java From ghidra with Apache License 2.0 | 5 votes |
private void showDialog(Function function) { int currentFunctionPurgeSize = function.getStackPurgeSize(); if (currentFunctionPurgeSize == Function.INVALID_STACK_DEPTH_CHANGE || currentFunctionPurgeSize == Function.UNKNOWN_STACK_DEPTH_CHANGE) { currentFunctionPurgeSize = 0; } NumberInputDialog numberInputDialog = new NumberInputDialog("Please Enter Function Purge", "Enter Function Purge", currentFunctionPurgeSize, -1048576, 1048576, false); numberInputDialog.setHelpLocation(new HelpLocation("FunctionPlugin", "Function_Purge")); if (!numberInputDialog.show()) { functionPlugin.getTool().setStatusInfo("User cancelled function purge"); return; } int newFunctionPurgeSize = numberInputDialog.getValue(); if (newFunctionPurgeSize != currentFunctionPurgeSize) { Command command = new SetFunctionPurgeCommand(function, newFunctionPurgeSize); PluginTool tool = functionPlugin.getTool(); Program program = function.getProgram(); if (!tool.execute(command, program)) { tool.setStatusInfo("Unable to set function purge on " + "function: " + function.getName()); } } }
Example 4
Source File: FunctionPurgeFieldFactory.java From ghidra with Apache License 2.0 | 5 votes |
/** * @see ghidra.app.util.viewer.field.FieldFactory#getField(ProxyObj, int) */ @Override public ListingField getField(ProxyObj<?> proxy, int varWidth) { Object obj = proxy.getObject(); if (!enabled || !(obj instanceof Function)) { return null; } Function func = (Function) obj; String stringDepth = "UNK"; int depth = func.getStackPurgeSize(); switch (depth) { case Function.INVALID_STACK_DEPTH_CHANGE: stringDepth = "INV"; break; case Function.UNKNOWN_STACK_DEPTH_CHANGE: stringDepth = "UNK"; break; default: if (depth < 0) { stringDepth = "-" + Integer.toHexString(-depth); } else { stringDepth = Integer.toHexString(depth); } } AttributedString as = new AttributedString(stringDepth, Color.BLUE, getMetrics()); FieldElement text = new TextFieldElement(as, 0, 0); return ListingTextField.createSingleLineTextField(this, proxy, text, startX + varWidth, width, hlProvider); }