From 604e1a02f15712e4b738c04e55d5351d12780146 Mon Sep 17 00:00:00 2001 From: Vladimir Kononovich Date: Sun, 23 Jan 2022 23:09:08 +0300 Subject: [PATCH] Updated to 10.1.1 --- .classpath | 484 +++++++++--------- .project | 2 +- .../java/amigahunk/AmigaHunkAnalyzer.java | 2 +- .../amigahunk/AmigaHunkLibFileSystem.java | 41 +- 4 files changed, 270 insertions(+), 259 deletions(-) diff --git a/.classpath b/.classpath index 0bfdb4e..68cd5af 100644 --- a/.classpath +++ b/.classpath @@ -4,595 +4,605 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + diff --git a/.project b/.project index 8c5d1ca..8533a24 100644 --- a/.project +++ b/.project @@ -18,7 +18,7 @@ Ghidra 2 - D:/ghidra_10.0_PUBLIC + D:/Ghidra/ghidra_10.1.1_PUBLIC diff --git a/src/main/java/amigahunk/AmigaHunkAnalyzer.java b/src/main/java/amigahunk/AmigaHunkAnalyzer.java index 28140e1..579c6c9 100644 --- a/src/main/java/amigahunk/AmigaHunkAnalyzer.java +++ b/src/main/java/amigahunk/AmigaHunkAnalyzer.java @@ -55,7 +55,7 @@ public class AmigaHunkAnalyzer extends AbstractAnalyzer { - private static final int imageBaseOffset = 0x10000; + //private static final int imageBaseOffset = 0x10000; private final List filter = new ArrayList(); private FdFunctionsInLibs funcsList; diff --git a/src/main/java/amigahunk/AmigaHunkLibFileSystem.java b/src/main/java/amigahunk/AmigaHunkLibFileSystem.java index 9e0dbdc..eb8e429 100644 --- a/src/main/java/amigahunk/AmigaHunkLibFileSystem.java +++ b/src/main/java/amigahunk/AmigaHunkLibFileSystem.java @@ -1,8 +1,6 @@ package amigahunk; -import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -11,18 +9,19 @@ import generic.stl.Pair; import ghidra.app.util.bin.BinaryReader; import ghidra.app.util.bin.ByteProvider; -import ghidra.app.util.bin.ByteProviderInputStream; +import ghidra.app.util.bin.ByteProviderWrapper; import ghidra.formats.gfilesystem.FSRL; import ghidra.formats.gfilesystem.FSRLRoot; -import ghidra.formats.gfilesystem.FSUtilities; import ghidra.formats.gfilesystem.FileSystemIndexHelper; import ghidra.formats.gfilesystem.FileSystemRefManager; import ghidra.formats.gfilesystem.FileSystemService; import ghidra.formats.gfilesystem.GFile; import ghidra.formats.gfilesystem.GFileSystem; import ghidra.formats.gfilesystem.annotations.FileSystemInfo; -import ghidra.formats.gfilesystem.factory.GFileSystemFactoryFull; -import ghidra.formats.gfilesystem.factory.GFileSystemProbeFull; +import ghidra.formats.gfilesystem.factory.GFileSystemFactoryByteProvider; +import ghidra.formats.gfilesystem.factory.GFileSystemProbeByteProvider; +import ghidra.formats.gfilesystem.fileinfo.FileAttributeType; +import ghidra.formats.gfilesystem.fileinfo.FileAttributes; import ghidra.util.exception.CancelledException; import ghidra.util.task.TaskMonitor; import hunk.HunkBlock; @@ -239,14 +238,12 @@ public GFile lookup(String path) throws IOException { } @Override - public InputStream getInputStream(GFile file, TaskMonitor monitor) + public ByteProvider getByteProvider(GFile file, TaskMonitor monitor) throws IOException, CancelledException { - // TODO: Get an input stream for a file. The following is an example of how the metadata - // might be used to get an input stream from a stored provider offset. LibHunkItem metadata = fsih.getMetadata(file); return (metadata != null) - ? new ByteProviderInputStream(provider, metadata.offset, metadata.size) + ? new ByteProviderWrapper(provider, metadata.offset, metadata.size) : null; } @@ -256,9 +253,15 @@ public List getListing(GFile directory) throws IOException { } @Override - public String getInfo(GFile file, TaskMonitor monitor) { + public FileAttributes getFileAttributes(GFile file, TaskMonitor monitor) { LibHunkItem metadata = fsih.getMetadata(file); - return (metadata == null) ? null : FSUtilities.infoMapToString(getInfoMap(metadata)); + FileAttributes result = new FileAttributes(); + if (metadata != null) { + result.add(FileAttributeType.NAME_ATTR, metadata.name); + result.add(FileAttributeType.UNKNOWN_ATTRIBUTE, "Offset", metadata.offset); + result.add(FileAttributeType.SIZE_ATTR, metadata.size); + } + return result; } public Map getInfoMap(LibHunkItem metadata) { @@ -269,14 +272,13 @@ public Map getInfoMap(LibHunkItem metadata) { return info; } - // TODO: Customize for the real file system. public static class AmigaHunkLibFileSystemFactory - implements GFileSystemFactoryFull, GFileSystemProbeFull { + implements GFileSystemFactoryByteProvider, GFileSystemProbeByteProvider { @Override - public AmigaHunkLibFileSystem create(FSRL containerFSRL, FSRLRoot targetFSRL, - ByteProvider byteProvider, File containerFile, FileSystemService fsService, - TaskMonitor monitor) throws IOException, CancelledException { + public AmigaHunkLibFileSystem create(FSRLRoot targetFSRL, + ByteProvider byteProvider, FileSystemService fsService, TaskMonitor monitor) + throws IOException, CancelledException { AmigaHunkLibFileSystem fs = new AmigaHunkLibFileSystem(targetFSRL, byteProvider); fs.mount(monitor); @@ -284,9 +286,8 @@ public AmigaHunkLibFileSystem create(FSRL containerFSRL, FSRLRoot targetFSRL, } @Override - public boolean probe(FSRL containerFSRL, ByteProvider byteProvider, File containerFile, - FileSystemService fsService, TaskMonitor monitor) - throws IOException, CancelledException { + public boolean probe(ByteProvider byteProvider, FileSystemService fsService, + TaskMonitor monitor) throws IOException, CancelledException { if (!HunkBlockFile.isHunkBlockFile(new BinaryReader(byteProvider, false))) { return false;