Java Code Examples for ghidra.program.model.symbol.SourceType#IMPORTED

The following examples show how to use ghidra.program.model.symbol.SourceType#IMPORTED . 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: RefListFlagsV0.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public RefListFlagsV0(boolean isPrimary, boolean isOffsetRef, boolean hasSymbolID,
		boolean isShiftRef, SourceType source) {
	flags = 0;
	if (source == SourceType.USER_DEFINED || source == SourceType.IMPORTED) {
		flags |= SOURCE_LOBIT;
	}
	if (source == SourceType.ANALYSIS || source == SourceType.IMPORTED) {
		flags |= SOURCE_HIBIT;
	}
	if (isPrimary)
		flags |= IS_PRIMARY;
	if (isOffsetRef)
		flags |= IS_OFFSET;
	if (hasSymbolID)
		flags |= HAS_SYMBOL_ID;
	if (isShiftRef)
		flags |= IS_SHIFT;
}
 
Example 2
Source File: FindUndefinedFunctionsScript.java    From ghidra with Apache License 2.0 6 votes vote down vote up
boolean isMatch(Address undefinedAddress) throws MemoryAccessException {
			byte[] actualBytes = new byte[expectedBytes.length];
			currentProgram.getMemory().getBytes(undefinedAddress, actualBytes);

			if (equals(expectedBytes, actualBytes)) {
				if (requiresEntyPoint) {
//					return currentProgram.getSymbolTable().isExternalEntryPoint(undefinedAddress);
					Symbol primarySymbol =
						currentProgram.getSymbolTable().getPrimarySymbol(undefinedAddress);
					return (primarySymbol != null) &&
						(primarySymbol.getSource() == SourceType.IMPORTED);
				}
				return true;
			}
			return false;
		}
 
Example 3
Source File: NXProgramBuilder.java    From Ghidra-Switch-Loader with ISC License 5 votes vote down vote up
public boolean hasImportedSymbol(Address addr)
{
    for (Symbol sym : program.getSymbolTable().getSymbols(addr))
    {
        if (sym.getSource() == SourceType.IMPORTED)
            return true;
    }
    
    return false;
}
 
Example 4
Source File: IPCAnalyzer.java    From Ghidra-Switch-Loader with ISC License 5 votes vote down vote up
public boolean hasImportedSymbol(Program program, Address addr)
{
    for (Symbol sym : program.getSymbolTable().getSymbols(addr))
    {
        if (sym.getSource() == SourceType.IMPORTED)
            return true;
    }
    
    return false;
}
 
Example 5
Source File: RefListFlagsV0.java    From ghidra with Apache License 2.0 5 votes vote down vote up
SourceType getSource() {
	boolean isLoBit = (flags & SOURCE_LOBIT) != 0;
	boolean isHiBit = (flags & SOURCE_HIBIT) != 0;
	if (isHiBit) {
		return isLoBit ? SourceType.IMPORTED : SourceType.ANALYSIS;
	}
	return isLoBit ? SourceType.USER_DEFINED : SourceType.DEFAULT;
}
 
Example 6
Source File: ApplyDataArchiveAnalyzer.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public boolean added(Program program, AddressSetView set, TaskMonitor monitor, MessageLog log) {
	AutoAnalysisManager mgr = AutoAnalysisManager.getAnalysisManager(program);
	DataTypeManagerService service = mgr.getDataTypeManagerService();

	// pick the archives to apply
	List<String> archiveList = DataTypeArchiveUtility.getArchiveList(program);
	List<DataTypeManager> managerList = new ArrayList<>();
	monitor.initialize(archiveList.size());

	// apply the archive restricted to the address set
	for (String archiveName : archiveList) {
		if (monitor.isCancelled()) {
			break;
		}
		DataTypeManager dtm = null;
		try {
			dtm = service.openDataTypeArchive(archiveName);
			if (dtm == null) {
				Msg.showError(this, null, "Failed to Apply Data Types",
					"Failed to locate data type archive: " + archiveName);
			}
			else {
				managerList.add(dtm);
			}
		}
		catch (Exception e) {
			if (mgr.debugOn) {
				Msg.error(this, "Unexpected Exception: " + e.getMessage(), e);
			}
		}
	}
	monitor.setMessage("Applying Function Signatures...");
	// TODO: SourceType of imported is not exactly right here.
	//       This isn't imported.  Need to add some other sourceType, like SecondaryInfo
	ApplyFunctionDataTypesCmd cmd = new ApplyFunctionDataTypesCmd(managerList, set,
		SourceType.IMPORTED, false, createBookmarksEnabled);
	cmd.applyTo(program, monitor);
	return true;
}
 
Example 7
Source File: DecompilerCallConventionAnalyzer.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private boolean hasImportedSignatureWithinNamespace(Function function) {
	return function.getSignatureSource() == SourceType.IMPORTED &&
		function.getParentNamespace().getID() != Namespace.GLOBAL_NAMESPACE_ID;
}