From 5c0b037fa8fb8a5d203ff52f338378e22482bd7c Mon Sep 17 00:00:00 2001 From: Dmitry Isaenko Date: Sun, 19 Apr 2020 04:56:13 +0300 Subject: [PATCH] Drafts for RomFs support Ad-Hoc fix: POC for Lvl 6 header --- .../Controllers/RFS/RFSFolderEntry.java | 3 +- .../Controllers/RFS/RomFsController.java | 9 ++++ .../konogonka/Tools/RomFs/Level6Header.java | 42 +++++++++---------- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/main/java/konogonka/Controllers/RFS/RFSFolderEntry.java b/src/main/java/konogonka/Controllers/RFS/RFSFolderEntry.java index f4bf4b6..bfcea98 100644 --- a/src/main/java/konogonka/Controllers/RFS/RFSFolderEntry.java +++ b/src/main/java/konogonka/Controllers/RFS/RFSFolderEntry.java @@ -33,4 +33,5 @@ public class RFSFolderEntry { public String toString(){ return name; } -} + +} \ No newline at end of file diff --git a/src/main/java/konogonka/Controllers/RFS/RomFsController.java b/src/main/java/konogonka/Controllers/RFS/RomFsController.java index 46f662f..f4bff08 100644 --- a/src/main/java/konogonka/Controllers/RFS/RomFsController.java +++ b/src/main/java/konogonka/Controllers/RFS/RomFsController.java @@ -25,6 +25,7 @@ import javafx.scene.layout.Region; import javafx.scene.layout.VBox; import konogonka.Controllers.ITabController; import konogonka.Tools.ISuperProvider; +import konogonka.Tools.RomFs.RomFsDecryptedProvider; import java.io.File; import java.net.URL; @@ -37,6 +38,8 @@ public class RomFsController implements ITabController { @FXML private VBox folderContentVBox; + private RomFsDecryptedProvider RomFsProvider; + @Override public void initialize(URL url, ResourceBundle resourceBundle) { TreeItem rootTest = getEmptyRoot(); @@ -54,6 +57,12 @@ public class RomFsController implements ITabController { @Override public void analyze(File file, long offset) { + try { + this.RomFsProvider = new RomFsDecryptedProvider(file); + } + catch (Exception e){ // TODO: FIX + e.printStackTrace(); + } TreeItem rootItem = getEmptyRoot(); filesTreeView.setRoot(rootItem); diff --git a/src/main/java/konogonka/Tools/RomFs/Level6Header.java b/src/main/java/konogonka/Tools/RomFs/Level6Header.java index d11c334..c73921a 100644 --- a/src/main/java/konogonka/Tools/RomFs/Level6Header.java +++ b/src/main/java/konogonka/Tools/RomFs/Level6Header.java @@ -33,28 +33,22 @@ public class Level6Header { private long headerFileMetadataTableOffset; private long headerFileMetadataTableLength; private long headerFileDataOffset; - + + private byte[] headerBytes; + private int i; + Level6Header(byte[] headerBytes){ - int i = 0; - headerHeaderLength = LoperConverter.getLEint(headerBytes, i); - i += 0x8; - headerDirectoryHashTableOffset = LoperConverter.getLEint(headerBytes, i); - i += 0x8; - headerDirectoryHashTableLength = LoperConverter.getLEint(headerBytes, i); - i += 0x8; - headerDirectoryMetadataTableOffset = LoperConverter.getLEint(headerBytes, i); - i += 0x8; - headerDirectoryMetadataTableLength = LoperConverter.getLEint(headerBytes, i); - i += 0x8; - headerFileHashTableOffset = LoperConverter.getLEint(headerBytes, i); - i += 0x8; - headerFileHashTableLength = LoperConverter.getLEint(headerBytes, i); - i += 0x8; - headerFileMetadataTableOffset = LoperConverter.getLEint(headerBytes, i); - i += 0x8; - headerFileMetadataTableLength = LoperConverter.getLEint(headerBytes, i); - i += 0x8; - headerFileDataOffset = LoperConverter.getLEint(headerBytes, i); + this.headerBytes = headerBytes; + headerHeaderLength = getNext(); + headerDirectoryHashTableOffset = getNext(); + headerDirectoryHashTableLength = getNext(); + headerDirectoryMetadataTableOffset = getNext(); + headerDirectoryMetadataTableLength = getNext(); + headerFileHashTableOffset = getNext(); + headerFileHashTableLength = getNext(); + headerFileMetadataTableOffset = getNext(); + headerFileMetadataTableLength = getNext(); + headerFileDataOffset = getNext(); System.out.println("== Level 6 Header ==\n" + "Header Length (always 0x50 ?) "+ RainbowDump.formatDecHexString(headerHeaderLength)+" (size of this structure within first 0x200 block of LEVEL 6 part)\n" + @@ -71,6 +65,12 @@ public class Level6Header { ); } + private long getNext(){ + final long result = LoperConverter.getLEint(headerBytes, i); + i += 0x8; + return result; + } + public long getHeaderHeaderLength() { return headerHeaderLength; } public long getHeaderDirectoryHashTableOffset() { return headerDirectoryHashTableOffset; } public long getHeaderDirectoryHashTableLength() { return headerDirectoryHashTableLength; }