Java Code Examples for ghidra.program.model.data.DataType#getLength()

The following examples show how to use ghidra.program.model.data.DataType#getLength() . 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: PositiveStackEditorEnablementTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Test
public void testFirstComponentSelectedEnablement() throws Exception {
	init(SIMPLE_STACK);

	// Check enablement on first component selected.
	model.setSelection(new int[] { 0 });
	int numBytes = getModel().getMaxReplaceLength(0);
	for (int i = 0; i < actions.length; i++) {
		if (actions[i] instanceof FavoritesAction) {
			FavoritesAction fav = (FavoritesAction) actions[i];
			DataType favDt = fav.getDataType();
			int len = favDt.getLength();
			boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
			checkEnablement(actions[i], enabled);
		}
		else if ((actions[i] instanceof CycleGroupAction) ||
			(actions[i] instanceof HexNumbersAction) ||
			(actions[i] instanceof ShowComponentPathAction) ||
			(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
			(actions[i] instanceof DeleteAction) || (actions[i] instanceof ArrayAction) ||
			(actions[i] instanceof PointerAction)) {
			checkEnablement(actions[i], true);
		}
		else {
			checkEnablement(actions[i], false);
		}
	}
}
 
Example 2
Source File: LinearFunctionAddressCorrelation.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected void computeParamCorrelation() {
	int sourceCount = sourceFunction.getParameterCount();
	int destinationCount = destinationFunction.getParameterCount();
	Parameter[] sourceParameters = sourceFunction.getParameters();
	Parameter[] destinationParameters = destinationFunction.getParameters();
	boolean allMatch = false;
	Map<Address, AddressRange> map = new HashMap<Address, AddressRange>();
	if (sourceCount == destinationCount) {
		allMatch = true;
		for (int i = 0; i < sourceParameters.length; i++) {
			Parameter sourceParameter = sourceParameters[i];
			Parameter destinationParameter = destinationParameters[i];
			DataType sourceDataType = sourceParameter.getDataType();
			DataType destinationDataType = destinationParameter.getDataType();
			int sourceLength = sourceDataType.getLength();
			int destinationLength = destinationDataType.getLength();
			Address dest = destinationParameter.getMinAddress();
			map.put(sourceParameter.getMinAddress(), new AddressRangeImpl(dest, dest));
			if (sourceLength != destinationLength) {
				allMatch = false;
				break;
			}
		}
	}
	if (allMatch) {
		cachedForwardAddressMap.putAll(map);
	}
}
 
Example 3
Source File: StraightLineCorrelation.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Add address correlations for the parameters.
 */
protected void computeParamCorrelation() {
	int sourceCount = sourceFunction.getParameterCount();
	int destinationCount = destinationFunction.getParameterCount();
	Parameter[] sourceParameters = sourceFunction.getParameters();
	Parameter[] destinationParameters = destinationFunction.getParameters();
	boolean allMatch = false;
	Map<Address, AddressRange> map = new HashMap<Address, AddressRange>();
	if (sourceCount == destinationCount) {
		allMatch = true;
		for (int i = 0; i < sourceParameters.length; i++) {
			Parameter sourceParameter = sourceParameters[i];
			Parameter destinationParameter = destinationParameters[i];
			DataType sourceDataType = sourceParameter.getDataType();
			DataType destinationDataType = destinationParameter.getDataType();
			int sourceLength = sourceDataType.getLength();
			int destinationLength = destinationDataType.getLength();
			Address dest = destinationParameter.getMinAddress();
			map.put(sourceParameter.getMinAddress(), new AddressRangeImpl(dest, dest));
			if (sourceLength != destinationLength) {
				allMatch = false;
				break;
			}
		}
	}
	if (allMatch) {
		cachedForwardAddressMap.putAll(map);
	}
}
 
Example 4
Source File: StructureEditorUnlockedCellEdit1Test.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Test
public void testEditDynamicDataTypeAtLastComponent() throws Exception {
	init(simpleStructure, pgmBbCat);
	int column = model.getDataTypeColumn();
	String str = "string";
	int numComponents = simpleStructure.getNumComponents();
	int editRow = numComponents - 1;
	DataType dt = getDataType(editRow);
	int originalLastDtSize = dt.getLength();
	int originalStructSize = 29;
	int newStringComponentSize = 15;

	assertEquals(originalStructSize, model.getLength());
	assertEquals(1, originalLastDtSize);
	editCell(getTable(), editRow, column);
	assertIsEditingField(editRow, column);

	deleteAllInCellEditor();
	type(str);
	enter();

	NumberInputDialog dialog = waitForDialogComponent(NumberInputDialog.class);
	assertNotNull(dialog);
	okInput(dialog, newStringComponentSize);
	dialog = null;
	waitUntilDialogProviderGone(NumberInputDialog.class, 2000);

	assertNotEditingField();
	assertEquals(1, model.getNumSelectedRows());
	assertEquals(editRow, model.getMinIndexSelected());
	assertCellString(str, editRow, column);
	assertEquals(originalStructSize - originalLastDtSize + newStringComponentSize,
		model.getLength());
	assertEquals(-1, getDataType(editRow).getLength());
	assertEquals(newStringComponentSize, model.getComponent(editRow).getLength());
	assertEquals(numComponents, model.getNumComponents());
}
 
Example 5
Source File: StackEditorEnablementTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Test
public void testLastComponentSelectedEnablement() throws Exception {
	init(SIMPLE_STACK);

	// Check enablement on last component selected.
	runSwing(() -> model.setSelection(new int[] { model.getNumComponents() - 1 }));
	int numBytes = getModel().getMaxReplaceLength(model.getNumComponents() - 1);
	for (int i = 0; i < actions.length; i++) {
		if (actions[i] instanceof FavoritesAction) {
			FavoritesAction fav = (FavoritesAction) actions[i];
			DataType favDt = fav.getDataType();
			int len = favDt.getLength();
			boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
			checkEnablement(actions[i], enabled);
		}
		else if ((actions[i] instanceof CycleGroupAction) ||
			(actions[i] instanceof HexNumbersAction) ||
			(actions[i] instanceof ShowComponentPathAction) ||
			(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
			(actions[i] instanceof DeleteAction) || (actions[i] instanceof ArrayAction) ||
			(actions[i] instanceof PointerAction)) {
			checkEnablement(actions[i], true);
		}
		else {
			checkEnablement(actions[i], false);
		}
	}
}
 
Example 6
Source File: StackEditorEnablementTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Test
public void testCentralComponentSelectedEnablement() throws Exception {
	init(SIMPLE_STACK);

	// Check enablement on central component selected.

	runSwing(() -> model.setSelection(new int[] { 1 }));
	int numBytes = getModel().getMaxReplaceLength(1);
	for (int i = 0; i < actions.length; i++) {
		if (actions[i] instanceof FavoritesAction) {
			FavoritesAction fav = (FavoritesAction) actions[i];
			DataType favDt = fav.getDataType();
			int len = favDt.getLength();
			boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
			checkEnablement(actions[i], enabled);
		}
		else if ((actions[i] instanceof CycleGroupAction) ||
			(actions[i] instanceof HexNumbersAction) ||
			(actions[i] instanceof ShowComponentPathAction) ||
			(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
			(actions[i] instanceof ArrayAction) || (actions[i] instanceof PointerAction)) {
			checkEnablement(actions[i], true);
		}
		else {
			checkEnablement(actions[i], false);
		}
	}
}
 
Example 7
Source File: StackEditorEnablementTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Test
public void testFirstComponentSelectedEnablement() throws Exception {
	init(SIMPLE_STACK);

	// Check enablement on first component selected.
	runSwing(() -> model.setSelection(new int[] { 0 }));
	int numBytes = getModel().getMaxReplaceLength(0);
	for (int i = 0; i < actions.length; i++) {
		if (actions[i] instanceof FavoritesAction) {
			FavoritesAction fav = (FavoritesAction) actions[i];
			DataType favDt = fav.getDataType();
			int len = favDt.getLength();
			boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
			checkEnablement(actions[i], enabled);
		}
		else if ((actions[i] instanceof CycleGroupAction) ||
			(actions[i] instanceof HexNumbersAction) ||
			(actions[i] instanceof ShowComponentPathAction) ||
			(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
			(actions[i] instanceof DeleteAction) || (actions[i] instanceof ArrayAction) ||
			(actions[i] instanceof PointerAction)) {
			checkEnablement(actions[i], true);
		}
		else {
			checkEnablement(actions[i], false);
		}
	}
}
 
Example 8
Source File: PositiveStackEditorEnablementTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Test
public void testLastComponentSelectedEnablement() throws Exception {
	init(SIMPLE_STACK);

	// Check enablement on last component selected.
	model.setSelection(new int[] { model.getNumComponents() - 1 });
	int numBytes = getModel().getMaxReplaceLength(model.getNumComponents() - 1);
	for (int i = 0; i < actions.length; i++) {
		if (actions[i] instanceof FavoritesAction) {
			FavoritesAction fav = (FavoritesAction) actions[i];
			DataType favDt = fav.getDataType();
			int len = favDt.getLength();
			boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
			checkEnablement(actions[i], enabled);
		}
		else if ((actions[i] instanceof CycleGroupAction) ||
			(actions[i] instanceof HexNumbersAction) ||
			(actions[i] instanceof ShowComponentPathAction) ||
			(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
			(actions[i] instanceof DeleteAction) || (actions[i] instanceof ArrayAction) ||
			(actions[i] instanceof PointerAction)) {
			checkEnablement(actions[i], true);
		}
		else {
			checkEnablement(actions[i], false);
		}
	}
}
 
Example 9
Source File: PositiveStackEditorEnablementTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Test
public void testCentralComponentSelectedEnablement() throws Exception {
	init(SIMPLE_STACK);

	// Check enablement on central component selected.
	model.setSelection(new int[] { 1 });
	int numBytes = getModel().getMaxReplaceLength(1);
	for (int i = 0; i < actions.length; i++) {
		if (actions[i] instanceof FavoritesAction) {
			FavoritesAction fav = (FavoritesAction) actions[i];
			DataType favDt = fav.getDataType();
			int len = favDt.getLength();
			boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
			checkEnablement(actions[i], enabled);
		}
		else if ((actions[i] instanceof CycleGroupAction) ||
			(actions[i] instanceof HexNumbersAction) ||
			(actions[i] instanceof ShowComponentPathAction) ||
			(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
			(actions[i] instanceof ArrayAction) || (actions[i] instanceof PointerAction)) {
			checkEnablement(actions[i], true);
		}
		else {
			checkEnablement(actions[i], false);
		}
	}
}
 
Example 10
Source File: VariableDB.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isValid() {
	VariableStorage variableStorage = getVariableStorage();
	DataType dt = getDataType();
	return variableStorage.isValid() &&
		((dt instanceof AbstractFloatDataType) || variableStorage.size() == dt.getLength());
}
 
Example 11
Source File: DefaultDataTypeHTMLRepresentation.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private TextLine buildFooter(DataType dataType) {
	int length = dataType.getLength();
	if (length >= 0) {
		return new TextLine(Integer.toString(length));
	}
	return new TextLine(" <i>Unsized</i>");
}
 
Example 12
Source File: FindDataTypesBySizeAction.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean acceptsNode(GTreeNode node) {
	if (!(node instanceof DataTypeNode)) {
		return false;
	}
	DataTypeNode dataTypeNode = (DataTypeNode) node;
	DataType dataType = dataTypeNode.getDataType();
	int length = dataType.getLength();
	return length == size;
}
 
Example 13
Source File: BitFieldGroupCompositeMember.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
boolean addMember(DefaultCompositeMember member) {

	DataType dt = member.getDataType();
	if (dt == null || dt.getLength() <= 0) {
		return false;
	}

	// trigger structure/union transformation
	DefaultCompositeMember bf0 = list.remove(0);

	return bf0.addMember(member);
}
 
Example 14
Source File: GlobalSymbolMap.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Create a HighSymbol based on the id of the underlying Ghidra Symbol. The Symbol
 * is looked up in the SymbolTable and then a HighSymbol is created with the name and
 * dataType associated with the Symbol. If a Symbol cannot be found, null is returned.
 * @param id is the database id of the CodeSymbol
 * @param dataType is the recovered data-type of the symbol
 * @param sz is the size in bytes of the desired symbol
 * @return the CodeSymbol wrapped as a HighSymbol or null
 */
public HighSymbol populateSymbol(long id, DataType dataType, int sz) {
	if ((id >> 56) == (HighSymbol.ID_BASE >> 56)) {
		return null;		// This is an internal id, not a database key
	}
	Symbol symbol = symbolTable.getSymbol(id);
	if (symbol == null) {
		return null;
	}
	HighSymbol highSym = null;
	if (symbol instanceof CodeSymbol) {
		if (dataType == null) {
			Object dataObj = symbol.getObject();
			if (dataObj instanceof Data) {
				dataType = ((Data) dataObj).getDataType();
				sz = dataType.getLength();
			}
			else {
				dataType = DataType.DEFAULT;
				sz = 1;
			}
		}
		highSym = new HighCodeSymbol((CodeSymbol) symbol, dataType, sz, func);
	}
	else if (symbol instanceof FunctionSymbol) {
		highSym = new HighFunctionShellSymbol(id, symbol.getName(), symbol.getAddress(),
			func.getDataTypeManager());
	}
	else {
		return null;
	}
	insertSymbol(highSym, symbol.getAddress());
	return highSym;
}
 
Example 15
Source File: OldFunctionManager.java    From ghidra with Apache License 2.0 5 votes vote down vote up
DataType getDataType(long dataTypeId) {
	DataType dataType = dataManager.getDataType(dataTypeId);
	if (dataType == null || dataType.isDeleted()) {
		return DataType.DEFAULT;
	}
	if (dataType.getLength() > 0) {
		// Return variable - although it could be too big
		return dataType;
	}
	if (dataType instanceof Pointer) {
		return program.getDataTypeManager().getPointer(((Pointer) dataType).getDataType());
	}
	return program.getDataTypeManager().getPointer(dataType);
}
 
Example 16
Source File: OldFunctionDataDB.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private Parameter getRegisterParameter(Record record, int ordinal) {
	String name = record.getString(OldRegisterVariableDBAdapter.REG_VAR_NAME_COL);
	long dataTypeId =
		record.getLongValue(OldRegisterVariableDBAdapter.REG_VAR_DATA_TYPE_ID_COL);
	String regName = record.getString(OldRegisterVariableDBAdapter.REG_VAR_REGNAME_COL);

	DataType dataType = functionManager.getDataType(dataTypeId);

	try {
		VariableStorage storage = VariableStorage.BAD_STORAGE;
		Register register =
			functionManager.getProgram().getProgramContext().getRegister(regName);
		if (register == null) {
			Msg.error(this, "Invalid parameter, register not found: " + regName);
		}
		else {
			storage = new VariableStorage(program, register.getAddress(), dataType.getLength());
		}
		return new OldFunctionParameter(name, ordinal, dataType, storage, program,
			SourceType.USER_DEFINED);
	}
	catch (InvalidInputException e) {
		Msg.error(this,
			"Invalid parameter '" + name + "' in function at " + entryPoint.toString());
		try {
			return new OldFunctionParameter(name, ordinal, dataType,
				VariableStorage.BAD_STORAGE, program, SourceType.USER_DEFINED);
		}
		catch (InvalidInputException e1) {
			// should not occur
			throw new RuntimeException(e1);
		}
	}
}
 
Example 17
Source File: PositiveStackEditorEnablementTest.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Test
	public void testNoVarPosStackEditorState() throws Exception {
		init(NO_VAR_STACK);

		assertEquals(4, stackModel.getNumComponents());// no components
		assertEquals(4, stackModel.getRowCount());// blank row
		assertEquals(4, stackModel.getLength());// size is 0
		assertEquals(0, stackModel.getEditorStack().getNegativeLength());
		assertEquals(4, stackModel.getEditorStack().getPositiveLength());
		assertTrue(!stackModel.hasChanges());// no Changes yet
		assertTrue(stackModel.isValidName());// name should be valid
		assertEquals(0, stackModel.getNumSelectedComponentRows());
		assertEquals(0, stackModel.getNumSelectedRows());
		checkSelection(new int[] {});
//		assertTrue(!stackModel.isLocked());
//		assertTrue(!stackModel.isLockable());
		assertEquals("entry", stackModel.getCompositeName());
		assertEquals(stackModel.getTypeName(), "Stack");

		// Check enablement.
		for (int i = 0; i < actions.length; i++) {
			if ((actions[i] instanceof CycleGroupAction) ||
				(actions[i] instanceof HexNumbersAction)) {
				checkEnablement(actions[i], true);
			}
			else {
				checkEnablement(actions[i], false);
			}
		}

		setSelection(new int[] { 0 });

		// Check enablement.
		int numBytes = getModel().getMaxReplaceLength(0);
		for (int i = 0; i < actions.length; i++) {
			if (actions[i] instanceof FavoritesAction) {
				FavoritesAction fav = (FavoritesAction) actions[i];
				DataType favDt = fav.getDataType();
				int len = favDt.getLength();
				boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
				int offset = model.getComponent(0).getOffset();
				int paramOffset = getModel().getEditorStack().getParameterOffset();
				if (offset < 0 && offset > paramOffset) {
					enabled = false;
				}
				checkEnablement(actions[i], enabled);
			}
			else if ((actions[i] instanceof CycleGroupAction) ||
				(actions[i] instanceof ShowComponentPathAction) ||
				(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
				(actions[i] instanceof DeleteAction) || (actions[i] instanceof PointerAction) ||
				(actions[i] instanceof HexNumbersAction)) {
				checkEnablement(actions[i], true);
			}
			else {
				checkEnablement(actions[i], false);
			}
		}
	}
 
Example 18
Source File: MachoBinaryAnalysisCommand.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public boolean analysisWorkerCallback(Program program, Object workerContext,
		TaskMonitor monitor) throws Exception, CancelledException {

	BookmarkManager bookmarkManager = program.getBookmarkManager();

	ByteProvider provider = new MemoryByteProvider(program.getMemory(),
		program.getAddressFactory().getDefaultAddressSpace());

	try {
		MachHeader header = MachHeader.createMachHeader(RethrowContinuesFactory.INSTANCE,
			provider, getAddress(program).getOffset(), isRelativeToAddress);
		header.parse();

		Address machAddress = getAddress(program);
		DataType headerDT = header.toDataType();
		createData(machAddress, headerDT);
		setHeaderComment(header, machAddress);

		int commandStartIndex = headerDT.getLength();
		Address commandAddress = machAddress.add(commandStartIndex);

		createFragment(module, headerDT.getDisplayName(), machAddress, commandStartIndex);

		List<LoadCommand> commands = header.getLoadCommands();
		for (LoadCommand command : commands) {
			command.markup(header, this, getAddress(program), true, module, monitor, messages);
			commandAddress = commandAddress.add(command.getCommandSize());
			if (command instanceof UnsupportedLoadCommand) {
				bookmarkManager.setBookmark(machAddress.add(command.getStartIndex()),
					BookmarkType.WARNING, "Load commands", command.getCommandName());
			}
		}

		return true;
	}
	catch (MachException e) {
		messages.appendMsg("Not a binary Mach-O program: Mach header not found.");
		return false;
	}
}
 
Example 19
Source File: StackEditorEnablementTest.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Test
	public void testNoVarNegStackEditorState() throws Exception {
		init(NO_VAR_STACK);

		assertEquals(4, stackModel.getNumComponents());// 4 undefined components
		assertEquals(4, stackModel.getRowCount());// undefined row
		assertEquals(4, stackModel.getLength());// size is 4
		assertEquals(4, stackModel.getEditorStack().getNegativeLength());
		assertEquals(0, stackModel.getEditorStack().getPositiveLength());
		assertTrue(!stackModel.hasChanges());// no Changes yet
		assertTrue(stackModel.isValidName());// name should be valid
		assertEquals(0, stackModel.getNumSelectedComponentRows());
		assertEquals(0, stackModel.getNumSelectedRows());
		checkSelection(new int[] {});
//		assertTrue(!stackModel.isLocked());
//		assertTrue(!stackModel.isLockable());
		assertEquals(function.getName(), stackModel.getCompositeName());
		assertEquals(stackModel.getTypeName(), "Stack");

		// Check enablement.
		for (int i = 0; i < actions.length; i++) {
			if ((actions[i] instanceof CycleGroupAction) ||
				(actions[i] instanceof HexNumbersAction)) {
				checkEnablement(actions[i], true);
			}
			else {
				checkEnablement(actions[i], false);
			}
		}

		setSelection(new int[] { 0 });

		// Check enablement.
		int numBytes = getModel().getMaxReplaceLength(0);
		for (int i = 0; i < actions.length; i++) {
			if (actions[i] instanceof FavoritesAction) {
				FavoritesAction fav = (FavoritesAction) actions[i];
				DataType favDt = fav.getDataType();
				int len = favDt.getLength();
				boolean enabled = ((len <= numBytes) && ((favDt instanceof Pointer) || (len > 0)));
				checkEnablement(actions[i], enabled);
			}
			else if ((actions[i] instanceof CycleGroupAction) ||
				(actions[i] instanceof ShowComponentPathAction) ||
				(actions[i] instanceof EditFieldAction) || (actions[i] instanceof ClearAction) ||
				(actions[i] instanceof DeleteAction) || (actions[i] instanceof PointerAction) ||
				(actions[i] instanceof HexNumbersAction)) {
				checkEnablement(actions[i], true);
			}
			else {
				checkEnablement(actions[i], false);
			}
		}
	}
 
Example 20
Source File: ListingStructureVariableAction.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isEnabledForContext(ActionContext context) {
	DataType dt = null;
	boolean isThisParam = false;

	if (!(context instanceof ListingActionContext)) {
		return false;
	}

	ListingActionContext listingContext = (ListingActionContext) context;
	// get the data type at the location and see if it is OK
	// make sure what we are over can be mapped to decompiler
	// param, local, etc...

	ProgramLocation location = listingContext.getLocation();
	Program currentProgram = listingContext.getProgram();

	if (location instanceof VariableLocation) {
		VariableLocation varLoc = (VariableLocation) location;
		Variable variable = varLoc.getVariable();
		if (variable instanceof Parameter) {
			if (((Parameter) variable).getAutoParameterType() == AutoParameterType.THIS) {
				isThisParam = true;
			}
		}
		dt = variable.getDataType();
	}
	else if (location instanceof FunctionParameterFieldLocation) {
		FunctionParameterFieldLocation funcPFL = (FunctionParameterFieldLocation) location;
		Parameter parameter = funcPFL.getParameter();
		if (parameter.getAutoParameterType() == AutoParameterType.THIS) {
			isThisParam = true;
		}
		dt = parameter.getDataType();
	}
	else if (location instanceof FunctionReturnTypeFieldLocation) {
		FunctionReturnTypeFieldLocation funcRTFL = (FunctionReturnTypeFieldLocation) location;
		Function func =
			currentProgram.getFunctionManager().getFunctionAt(funcRTFL.getFunctionAddress());
		dt = func.getReturnType();
	}

	int maxPointerSize = currentProgram.getDefaultPointerSize();
	if (dt == null || dt.getLength() > maxPointerSize) {
		return false;
	}

	adjustCreateStructureMenuText(dt, isThisParam);
	return true;
}