ghidra.util.exception.NotFoundException Java Examples

The following examples show how to use ghidra.util.exception.NotFoundException. 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: VarnodeContext.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public long getConstant(Varnode vnode, ContextEvaluator evaluator) throws NotFoundException {
	if (!vnode.isConstant()) {
		if (evaluator == null) {
			throw notFoundExc;
		}

		// is there an assumed value that should be returned for any unknown value?
		Instruction instr = getCurrentInstruction(offsetContext.getAddress());
		Long lval = evaluator.unknownValue(this, instr, vnode);
		if (lval != null) {
			return lval.longValue();
		}
		throw notFoundExc;
	}

	return vnode.getOffset();
}
 
Example #2
Source File: Handler.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Determine if the specified url is supported and that any required 
 * protocol extensions are recognized.
 * @param url
 * @return true if support ghidra URL
 */
public static boolean isSupportedURL(URL url) {
	if (!GhidraURL.PROTOCOL.equals(url.getProtocol())) {
		return false;
	}
	if (url.getAuthority() != null) {
		// assume standard ghidra URL (ghidra://...)
		return true;
	}
	try {
		return getProtocolExtensionHandler(url) != null;
	}
	catch (MalformedURLException | NotFoundException e) {
		return false;
	}
}
 
Example #3
Source File: IndexedV1LocalFileSystem.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
protected synchronized void fileIdChanged(PropertyFile pfile, String oldFileId)
		throws IOException {
	indexJournal.open();
	try {
		Folder folder = getFolder(pfile.getParentPath(), GetFolderOption.READ_ONLY);
		Item item = folder.items.get(pfile.getName());
		if (item == null) {
			throw new NotFoundException(pfile.getPath());
		}
		item.setFileID(pfile.getFileID());

		indexJournal.fileIdSet(pfile.getPath(), pfile.getFileID());
	}
	catch (NotFoundException e) {
		throw new FileNotFoundException(e.getMessage());
	}
	finally {
		indexJournal.close();
	}
}
 
Example #4
Source File: FragmentTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Test
public void testEquals() throws DuplicateNameException, NotFoundException {

	ProgramFragment f = listing.getFragment("MyTree", addr(0));
	assertTrue(f1.equals(f));

	// test equals on address set
	ProgramFragment f3 = root.createFragment("Frag3");
	f3.move(addr(0), addr(0xa));
	f3.move(addr(0x14), addr(0x1e));
	f3.move(addr(0x28), addr(0x32));
	f3.move(addr(0x3c), addr(0x46));
	AddressSet set = new AddressSet();
	set.addRange(addr(0), addr(0xa));
	set.addRange(addr(0x14), addr(0x1e));
	set.addRange(addr(0x28), addr(0x32));
	set.addRange(addr(0x3c), addr(0x46));

	assertTrue(f3.hasSameAddresses(set));

	set = set.subtract(new AddressSet(addr(0x28), addr(0x3d)));
	assertTrue(!f3.equals(set));
}
 
Example #5
Source File: Handler.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
protected URLConnection openConnection(URL url) throws IOException {

	if (!GhidraURL.PROTOCOL.equals(url.getProtocol())) {
		throw new IllegalArgumentException("unsupported URL protocol: " + url.getProtocol());
	}

	// Need to check for protocol extension if URL is of form ghidra:<extension-url>
	// Example:  ghidra:http://host/repo/folder/filename
	if (url.getAuthority() == null && !url.getPath().startsWith("/")) {
		// check for protocol handler which provides access to a full repository
		// while specifying a specific folder/file within the repository.  
		// The repository root is inferred from the URL path.
		try {
			GhidraProtocolHandler protocolHandler = getProtocolExtensionHandler(url);
			// strip ghidra protocol specifier from URL
			url = new URL(url.toExternalForm().substring(GhidraURL.PROTOCOL.length() + 1));
			return new GhidraURLConnection(url, protocolHandler);
		}
		catch (NotFoundException e) {
			throw new IOException("unsupported ghidra URL", e);
		}
	}

	return new GhidraURLConnection(url);
}
 
Example #6
Source File: IndexedLocalFileSystem.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Deallocate item storage
 * @param folderPath
 * @param itemName
 */
@Override
protected void deallocateItemStorage(String folderPath, String itemName) throws IOException {
	indexJournal.open();
	try {
		Folder folder = getFolder(folderPath, GetFolderOption.READ_ONLY);
		if (folder == null) {
			return; // parent not found
		}
		Item item = folder.items.get(itemName);
		if (item != null) {
			indexJournal.deleteItem(item);
			folder.items.remove(itemName);
		}
	}
	catch (NotFoundException e) {
		// ignore
	}
	finally {
		indexJournal.close();
	}
}
 
Example #7
Source File: ProgramTreePlugin3Test.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void dragNodes(ProgramNode node, List<ProgramNode> list, int dropAction)
		throws Exception {
	AtomicReference<Exception> ref = new AtomicReference<>();
	runSwing(() -> {
		try {
			tree.processDropRequest(node, list, TreeTransferable.localTreeNodeFlavor,
				dropAction);
		}
		catch (NotFoundException | CircularDependencyException | DuplicateGroupException e) {
			ref.set(e);
		}
	});

	Exception exception = ref.get();
	if (exception != null) {
		throw exception;
	}

	program.flushEvents();
}
 
Example #8
Source File: ReorderManager.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
   * Add the given data to the destination node.
   * @param destNode destination node for the data.
   * @param dropNode data to add
   */
  void add(ProgramNode destNode, ProgramNode[] dropNodes, int dropAction, int relativeMousePos) 
          throws NotFoundException, CircularDependencyException, DuplicateGroupException {

      ProgramModule targetModule = destNode.getModule();
      ProgramFragment targetFrag = destNode.getFragment();
      if (targetModule == null && targetFrag == null) {
          tree.clearDragData();
          return; // ignore the drop
      }

int transactionID = tree.startTransaction("Reorder");
if (transactionID < 0) {
	return;
}

try {
          for ( int i = 0; i < dropNodes.length; i++ ) {
              ProgramNode parentNode = (ProgramNode)destNode.getParent();
              reorderNode( destNode, dropAction, relativeMousePos, parentNode, dropNodes[i] );
          }
} finally {
	tree.endTransaction(transactionID, true);
}			
  }
 
Example #9
Source File: IndexedLocalFileSystem.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
protected String[] getItemNames(String folderPath, boolean includeHiddenFiles)
		throws IOException {
	if (readOnly) {
		refreshReadOnlyIndex();
	}
	try {
		Folder folder = getFolder(folderPath, GetFolderOption.READ_ONLY);
		Set<String> nameSet = folder.items.keySet();
		int count = nameSet.size();
		ArrayList<String> fileList = new ArrayList<>(count);
		for (String name : nameSet) {
			if (includeHiddenFiles || !name.startsWith(HIDDEN_ITEM_PREFIX)) {
				fileList.add(name);
			}
		}
		return fileList.toArray(new String[fileList.size()]);
	}
	catch (NotFoundException e) {
		throw new FileNotFoundException("Folder not found: " + folderPath);
	}
}
 
Example #10
Source File: IndexedLocalFileSystem.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Find an existing storage location
 * @param folderPath
 * @param itemName
 * @return storage location.  A non-null value does not guarantee that the associated 
 * item actually exists.
 * @throws FileNotFoundException 
 */
@Override
protected ItemStorage findItemStorage(String folderPath, String itemName)
		throws FileNotFoundException {
	try {
		Folder folder = getFolder(folderPath, GetFolderOption.READ_ONLY);
		Item item = folder.items.get(itemName);
		if (item != null) {
			return item.itemStorage;
		}
	}
	catch (NotFoundException e) {
		// ignore - handled below
	}
	throw new FileNotFoundException("Item not found: " + folderPath + SEPARATOR + itemName);
}
 
Example #11
Source File: PasteManager.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Paste the fragment at the given module.
 */
private boolean pasteFragment(ProgramNode nodeToPaste, ProgramModule targetModule,
		ProgramFragment fragment) throws NotFoundException, DuplicateGroupException {
	boolean pasteOK = false;

	if (targetModule.contains(fragment)) {
		if (targetModule.equals(nodeToPaste.getParentModule())) {
			removeFromClipboard(nodeToPaste);
		}
	}
	else if (actionMgr.clipboardContains(nodeToPaste)) {
		targetModule.reparent(nodeToPaste.getName(), nodeToPaste.getParentModule());
		removeFromClipboard(nodeToPaste);
		pasteOK = true;
	}
	else {
		targetModule.add(fragment);
		pasteOK = true;
	}
	return pasteOK;
}
 
Example #12
Source File: IndexedLocalFileSystem.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void replayItemMove(String oldPath, String newPath) throws NotFoundException {
	int index = oldPath.lastIndexOf(SEPARATOR);
	String name = oldPath.substring(index + 1);
	String parentPath = index == 0 ? SEPARATOR : oldPath.substring(0, index);
	Folder parent = getFolder(parentPath, GetFolderOption.READ_ONLY);
	Item item = parent.items.get(name);
	if (item == null) {
		throw new NotFoundException("Item not found: " + oldPath);
	}
	index = newPath.lastIndexOf(SEPARATOR);
	String newName = newPath.substring(index + 1);
	String newParentPath = index == 0 ? SEPARATOR : newPath.substring(0, index);
	Folder newParent = getFolder(newParentPath, GetFolderOption.CREATE_ALL);
	if (newParent.items.get(newName) != null) {
		throw new NotFoundException("Item already exists: " + newPath);
	}
	parent.items.remove(name);
	item.set(newParent, newName, item.getFileID());
	newParent.items.put(newName, item);
}
 
Example #13
Source File: IndexedLocalFileSystem.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Add folder to index during rebuild if missing
 * NOTE: indexJournal must already open'ed by caller
 * @param folderPath
 * @return
 * @throws IOException
 * @throws NotFoundException
 */
private Folder addFolderToIndexIfMissing(String folderPath)
		throws IOException, NotFoundException {

	if (SEPARATOR.equals(folderPath)) {
		return rootFolder;
	}

	int index = folderPath.lastIndexOf(SEPARATOR);
	String name = folderPath.substring(index + 1);
	String parentPath = index == 0 ? SEPARATOR : folderPath.substring(0, index);

	Folder parent = getFolder(parentPath, GetFolderOption.CREATE_ALL);
	Folder folder = parent.folders.get(name);
	if (folder != null) {
		return folder;
	}
	folder = new Folder();
	folder.parent = parent;
	folder.name = name;
	parent.folders.put(name, folder);
	indexJournal.addFolder(folderPath);
	return folder;
}
 
Example #14
Source File: ThunkReferenceAddressDialog.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Find unique original external symbol with the given name.  
 * @param name original external symbol name
 * @return unique external symbol or null if multiple matching external symbols were found
 * @throws NotFoundException if no original external symbols were found
 */
private Symbol findOriginalExternalSymbol(String name) throws NotFoundException {

	// must examine each external since secondary/original name
	// is not indexed within symbol table
	Symbol candidateSymbol = null;
	SymbolTable symbolTable = program.getSymbolTable();
	ExternalManager externalManager = program.getExternalManager();
	for (Symbol s : symbolTable.getExternalSymbols()) {
		SymbolType type = s.getSymbolType();
		if (type == SymbolType.FUNCTION || type == SymbolType.LABEL) {
			ExternalLocation externalLocation = externalManager.getExternalLocation(s);
			String originalName = externalLocation.getOriginalImportedName();
			if (name.equals(originalName)) {
				if (candidateSymbol != null) {
					return null;
				}
				candidateSymbol = s;
			}
		}
	}
	if (candidateSymbol == null) {
		throw new NotFoundException();
	}
	return candidateSymbol;
}
 
Example #15
Source File: VarnodeContext.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public Varnode or(Varnode val1, Varnode val2, ContextEvaluator evaluator)
		throws NotFoundException {
	if (val1.equals(val2)) {
		return val1;
	}

	if (val1.isConstant() || val1.isAddress()) {
		Varnode swap = val1;
		val1 = val2;
		val2 = swap;
	}
	long val2Const = getConstant(val2, null);
	if (val2Const == 0) {
		return val1;
	}
	long lresult = getConstant(val1, evaluator) | val2Const;
	return createConstantVarnode(lresult, val1.getSize());
}
 
Example #16
Source File: ElfCompatibilityProvider.java    From Ghidra-Switch-Loader with ISC License 6 votes vote down vote up
public ElfStringTable getStringTable()
{
    if (this.stringTable != null)
        return this.stringTable;
    
    ElfDynamicTable dynamicTable = this.getDynamicTable();
    
    if (dynamicTable == null || !dynamicTable.containsDynamicValue(ElfDynamicType.DT_STRTAB)) 
        return null;
    
    try
    {
        long dynamicStringTableAddr = this.program.getImageBase().getOffset() + dynamicTable.getDynamicValue(ElfDynamicType.DT_STRTAB);
        long dynamicStringTableSize = dynamicTable.getDynamicValue(ElfDynamicType.DT_STRSZ);

        this.stringTable = ElfStringTable.createElfStringTable(this.factoryReader, this.dummyElfHeader,
                null, dynamicStringTableAddr, dynamicStringTableAddr, dynamicStringTableSize);
    }
    catch (IOException | NotFoundException e)
    {
        Msg.error(this, "Failed to create string table", e);
    }
    
    return this.stringTable;
}
 
Example #17
Source File: FunctionReachabilityTableModel.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private CodeBlockIterator getCallGraphBlocks(TaskMonitor monitor) throws CancelledException {
	BlockModelService blockModelService = serviceProvider.getService(BlockModelService.class);

	CodeBlockModel model;
	try {
		model = blockModelService.getNewModelByName(
			BlockModelService.ISOLATED_ENTRY_SUBROUTINE_MODEL_NAME);
	}
	catch (NotFoundException e) {
		Msg.error(this, "Code block model not found: " +
			BlockModelService.ISOLATED_ENTRY_SUBROUTINE_MODEL_NAME);
		model = blockModelService.getActiveSubroutineModel();
	}

	return model.getCodeBlocks(monitor);
}
 
Example #18
Source File: NXProgramBuilder.java    From Ghidra-Switch-Loader with ISC License 6 votes vote down vote up
protected void tryCreateDynBlockWithRange(String name, ElfDynamicType start, ElfDynamicType end)
{
    NXOAdapter adapter = this.nxo.getAdapter();
    
    try
    {
        if (adapter.getDynamicTable(this.program).containsDynamicValue(start) && adapter.getDynamicTable(this.program).containsDynamicValue(end))
        {
            long offset = adapter.getDynamicTable(this.program).getDynamicValue(start);
            long size = adapter.getDynamicTable(this.program).getDynamicValue(end) - offset;
            
            if (size > 0)
            {
                Msg.info(this, String.format("Created dyn block %s at 0x%X of size 0x%X", name, offset, size));
                this.memBlockHelper.addSection(name, offset, offset, size, true, false, false);
            }
        }
    }
    catch (NotFoundException | AddressOutOfBoundsException e)
    {
        Msg.warn(this, String.format("Couldn't create dyn block %s. It may be absent.", name), e);
    }
}
 
Example #19
Source File: KNXAdapter.java    From Ghidra-Switch-Loader with ISC License 6 votes vote down vote up
@Override
public long getGotSize()
{
    ElfDynamicTable dt = this.getDynamicTable(this.program);
    
    if (dt == null || !dt.containsDynamicValue(ElfDynamicType.DT_INIT_ARRAY))
        return 0;
    
    try 
    {
        return this.program.getImageBase().getOffset() + dt.getDynamicValue(ElfDynamicType.DT_INIT_ARRAY) - this.getGotOffset();
    } 
    catch (NotFoundException e) 
    {
        return 0;
    }
}
 
Example #20
Source File: VarnodeContext.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Copy the varnode with as little manipulation as possible.
 * Try to keep whatever partical state there is intact if a real value isn't required.
 * 
 * @param out varnode to put it in
 * @param in varnode to copy from.
 * @param evaluator 
 * @throws NotFoundException 
 */
public void copy(Varnode out, Varnode in, boolean mustClearAll, ContextEvaluator evaluator)
		throws NotFoundException {
	Varnode val1 = null;
	if (!in.isRegister() || !out.isRegister()) {
		// normal case easy get value, put value
		val1 = getValue(in, evaluator);
		putValue(out, val1, mustClearAll);
		return;
	}
	if (mustClearAll) {
		clearVals.add(out);
	}

	val1 = getValue(in, evaluator);
	putValue(out, val1, mustClearAll);
}
 
Example #21
Source File: EmuX86GccDeobfuscateHookExampleScript.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Get the global namespace symbol address which corresponds to the specified name.
 * @param symbolName global symbol name
 * @return symbol address
 * @throws NotFoundException if symbol not found
 */
private Address getSymbolAddress(String symbolName) throws NotFoundException {
	Symbol symbol = SymbolUtilities.getLabelOrFunctionSymbol(currentProgram, symbolName,
		err -> Msg.error(this, err));
	if (symbol != null) {
		return symbol.getAddress();
	}
	throw new NotFoundException("Failed to locate label: " + symbolName);
}
 
Example #22
Source File: ModuleSortPlugin.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void doSort(ProgramModule parent, GroupComparator comparator, TaskMonitor monitor)
		throws NotFoundException, CancelledException {
	List<Group> list = new ArrayList<Group>();
	Group[] kids = parent.getChildren();

	monitor.initialize(kids.length);

	for (Group kid : kids) {
		monitor.checkCanceled();
		list.add(kid);
		if (kid instanceof ProgramModule) {
			doSort((ProgramModule) kid, comparator, monitor);
		}
		monitor.incrementProgress(1);
	}

	Collections.sort(list, comparator);

	monitor.initialize(list.size());
	for (int i = 0; i < list.size(); i++) {
		monitor.checkCanceled();

		Group group = list.get(i);
		monitor.setMessage("processing " + group.getName());
		parent.moveChild(group.getName(), i);
		monitor.incrementProgress(1);

		if (i % 10 == 0) {
			allowSwingThreadToPaintBetweenLongLocking();
		}

	}
}
 
Example #23
Source File: ThunkReferenceAddressDialog.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Find unique symbol from iterator ignoring related thunks.  
 * @param symbolIterator symbol iterator
 * @return unique function or code symbol or null if multiple symbols found
 * @throws NotFoundException if no symbols were found
 */
private Symbol findRefSymbol(Iterator<Symbol> symbolIterator) throws NotFoundException {
	Symbol candidateSymbol = null;
	Symbol candidateThunkSymbol = null;
	Symbol candidateThunkedSymbol = null; // corresponds to candidateThunkSymbol
	while (symbolIterator.hasNext()) {
		Symbol s = symbolIterator.next();
		SymbolType type = s.getSymbolType();
		if (type == SymbolType.FUNCTION || type == SymbolType.LABEL) {
			Symbol thunkedSymbol = getThunkedSymbol(s);
			if (thunkedSymbol != null) {
				// ignore equivalent thunks
				if (candidateThunkSymbol != null &&
					!thunkedSymbol.equals(candidateThunkedSymbol)) {
					return null;
				}
				candidateThunkedSymbol = thunkedSymbol;
				candidateThunkSymbol = s;
			}
			else { // non-thunk symbol
				if (candidateSymbol != null) {
					return null;
				}
				candidateSymbol = s;
			}
		}
	}
	if (candidateSymbol == null) {
		candidateSymbol = candidateThunkSymbol;
	}
	else if (candidateThunkSymbol != null && !candidateSymbol.equals(candidateThunkedSymbol)) {
		return null;
	}
	if (candidateSymbol == null) {
		throw new NotFoundException();
	}
	return candidateSymbol;
}
 
Example #24
Source File: IndexedLocalFileSystem.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized boolean folderExists(String folderPath) {
	try {
		getFolder(folderPath, GetFolderOption.READ_ONLY);
		return true;
	}
	catch (NotFoundException e) {
		return false;
	}
}
 
Example #25
Source File: IndexedLocalFileSystem.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void replayFileIdSet(String path, String fileId) throws NotFoundException {
	int index = path.lastIndexOf(SEPARATOR);
	String name = path.substring(index + 1);
	String parentPath = index == 0 ? SEPARATOR : path.substring(0, index);
	Folder parent = getFolder(parentPath, GetFolderOption.READ_ONLY);
	Item item = parent.items.get(name);
	if (item == null) {
		throw new NotFoundException("Item not found: " + path);
	}
	item.setFileID(fileId);
}
 
Example #26
Source File: VarnodeContext.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public Varnode getRegisterVarnodeValue(Register register) {
	Varnode regVnode = trans.getVarnode(register);
	try {
		Varnode value = this.getValue(regVnode, false, null);
		return value;
	}
	catch (NotFoundException e) {
		// Don't care, turn into a null varnode.
	}
	return null;
}
 
Example #27
Source File: IndexedLocalFileSystem.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void replayItemAdd(String storageName, String itemPath)
		throws NotFoundException, BadStorageNameException, DuplicateFileException {
	int index = itemPath.lastIndexOf(SEPARATOR);
	String name = itemPath.substring(index + 1);
	String parentPath = index == 0 ? SEPARATOR : itemPath.substring(0, index);
	Folder parent = getFolder(parentPath, GetFolderOption.CREATE_ALL);
	if (parent.items.get(name) != null) {
		throw new DuplicateFileException("Item already exists: " + itemPath);
	}
	new Item(parent, name, storageName);
	bumpNextFileIndexID(storageName);
}
 
Example #28
Source File: IndexedLocalFileSystem.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void replayFolderMove(String oldPath, String newPath)
		throws NotFoundException, DuplicateFileException {
	Folder folder = getFolder(oldPath, GetFolderOption.READ_ONLY);
	int index = newPath.lastIndexOf(SEPARATOR);
	String newName = newPath.substring(index + 1);
	String newParentPath = index == 0 ? SEPARATOR : newPath.substring(0, index);
	Folder newParent = getFolder(newParentPath, GetFolderOption.CREATE_ALL);
	if (newParent.folders.get(newName) != null) {
		throw new DuplicateFileException("Folder already exists: " + newPath);
	}
	folder.parent.folders.remove(folder.name);
	folder.name = newName;
	folder.parent = newParent;
	newParent.folders.put(newName, folder);
}
 
Example #29
Source File: ElfHeader.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void parseStringTables() throws IOException {

		// identify dynamic symbol table address
		long dynamicStringTableAddr = -1;
		if (dynamicTable != null) {
			try {
				dynamicStringTableAddr =
					adjustAddressForPrelink(dynamicTable.getDynamicValue(ElfDynamicType.DT_STRTAB));
			}
			catch (NotFoundException e) {
				Msg.warn(this, "ELF does not contain a dynamic string table (DT_STRTAB)");
			}
		}

		ArrayList<ElfStringTable> stringTableList = new ArrayList<>();
		for (ElfSectionHeader stringTableSectionHeader : sectionHeaders) {
			if (stringTableSectionHeader.getType() == ElfSectionHeaderConstants.SHT_STRTAB) {
				ElfStringTable stringTable = ElfStringTable.createElfStringTable(reader, this,
					stringTableSectionHeader, stringTableSectionHeader.getOffset(),
					stringTableSectionHeader.getAddress(), stringTableSectionHeader.getSize());
				stringTableList.add(stringTable);
				if (stringTable.getAddressOffset() == dynamicStringTableAddr) {
					dynamicStringTable = stringTable;
				}
			}
		}

		if (dynamicStringTable == null && dynamicStringTableAddr != -1) {
			dynamicStringTable = parseDynamicStringTable(dynamicStringTableAddr);
			if (dynamicStringTable != null) {
				stringTableList.add(dynamicStringTable);
			}
		}

		stringTables = new ElfStringTable[stringTableList.size()];
		stringTableList.toArray(stringTables);
	}
 
Example #30
Source File: VarnodeContext.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public BigInteger getValue(Register register, boolean signed) {
	Varnode regVnode = trans.getVarnode(register);
	try {
		Varnode value = this.getValue(regVnode, signed, null);
		if (value.isConstant()) {
			return BigInteger.valueOf(value.getOffset());
		}
	}
	catch (NotFoundException e) {
		// Don't care, turn into a null value
	}
	return null;
}