So first I use the source of this texture dumper: https://www.rune-server.ee/runescape...en-source.html
But when I try to dump the texture, I get this error in eclipse:
Code:
Exception in thread "Thread-3" java.lang.RuntimeException: Missing filesystem file.
at mgi.tools.jagcached.cache.FileSystem.load(FileSystem.java:33)
at mgi.tools.jagcached.cache.Cache.getFilesSystem(Cache.java:157)
at nl.mf12.texture_dumper.ui.Frame$2$1.run(Frame.java:84)
When I click on the error i get redirected to:
Code:
/* FileSystem - Decompiled by JODE
* Visit http://jode.sourceforge.net/
*/
package mgi.tools.jagcached.cache;
import mgi.tools.jagcached.Helper;
import mgi.utilities.ByteBuffer;
import mgi.utilities.Whirlpool;
public class FileSystem {
private Cache cache;
private int id;
private boolean useAutomaticVersionIncremetor = true;
private Folder[] folders;
private boolean useWhirlpool;
private boolean useNames;
private int version;
private int crc;
private byte[] digest;
private ByteBuffer packed;
private boolean changed;
public FileSystem(int id, Cache cache) {
this.id = id;
this.cache = cache;
}
public void load() {
if (isLoaded())
throw new RuntimeException("Already loaded!");
ByteBuffer buffer = cache.getInformationStore().get(id);
if (buffer == null)
throw new RuntimeException("Missing filesystem file.");
ByteBuffer unpacked = Helper.decodeFITContainer(buffer);
unpacked.setPosition(0);
int protocol = unpacked.readUnsignedByte();
System.out.println("index: " + id + ", " + "protocol: " + protocol);
if (protocol >= 6)
version = unpacked.readInt();
else
version = 0;
System.out.println("index: " + id + ", " + "revision: " + version);
int properties = unpacked.readUnsignedByte();
useNames = (properties & 0x1) != 0;
useWhirlpool = (properties & 0x2) != 0;
folders = new Folder[(protocol >= 7 ? unpacked.readSmart32() : unpacked
.readUnsignedShort())];
int[] folderIDS = new int[folders.length];
int[] folderNames = new int[folders.length];
int[] folderCRCS = new int[folders.length];
byte[][] folderDigests = new byte[folders.length][64];
int[] folderVersions = new int[folders.length];
int[][] folderFilesIDS = new int[folders.length][];
int[][] folderFilesNames = new int[folders.length][];
int offset = 0;
for (int i = 0; i < folders.length; i++)
folderIDS[i] = offset = offset
+ (protocol >= 7 ? unpacked.readSmart32() : unpacked
.readUnsignedShort());
for (int i = 0; i < folders.length; i++)
folderNames[i] = useNames ? unpacked.readInt() : -1;
for (int i = 0; i < folders.length; i++)
folderCRCS[i] = unpacked.readInt();
if (useWhirlpool) {
for (int i = 0; i < folders.length; i++)
unpacked.readBytes(folderDigests[i], 0, 64);
}
for (int i = 0; i < folders.length; i++)
folderVersions[i] = unpacked.readInt();
for (int i = 0; i < folders.length; i++) {
int filesCount = (protocol >= 7 ? unpacked.readSmart32() : unpacked
.readUnsignedShort());
folderFilesIDS[i] = new int[filesCount];
folderFilesNames[i] = new int[filesCount];
}
for (int i = 0; i < folders.length; i++) {
int offset_0_ = 0;
for (int a = 0; a < folderFilesIDS[i].length; a++)
folderFilesIDS[i][a] = offset_0_ = offset_0_
+ (protocol >= 7 ? unpacked.readSmart32() : unpacked
.readUnsignedShort());
}
for (int i = 0; i < folders.length; i++) {
for (int a = 0; a < folderFilesIDS[i].length; a++)
folderFilesNames[i][a] = useNames ? unpacked.readInt() : -1;
}
for (int i = 0; i < folders.length; i++)
folders[i] = new Folder(folderIDS[i], folderNames[i],
folderVersions[i], folderCRCS[i], folderDigests[i],
folderFilesIDS[i], folderFilesNames[i]);
updateHashes(buffer);
packed = buffer;
}
public void reset() {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
changed = true;
folders = new Folder[0];
version = 0;
}
public void finish() {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
if (needsRepack()) {
for (int i = 0; i < folders.length; i++) {
if (folders[i].isFileSystemInfoChanged()) {
if (useAutomaticVersionIncremetor)
folders[i].setVersion(folders[i].getVersion() + 1);
ByteBuffer buffer = folders[i].finish();
if (!cache.getFilesStore(id).put(folders[i].getID(),
buffer, buffer.getBuffer().length))
throw new RuntimeException(new StringBuilder()
.append("Couldn't update folder:")
.append(folders[i]).toString());
}
}
if (useAutomaticVersionIncremetor)
version++;
packed = pack();
updateHashes(packed);
if (!cache.getInformationStore().put(id, packed,
packed.getBuffer().length))
throw new RuntimeException("Couldn't update packed filesystem.");
changed = false;
for (int i = 0; i < folders.length; i++)
folders[i].markFileSystemInfoAsNotChanged();
}
}
private ByteBuffer pack() {
int protocol = decideProtocol();
ByteBuffer pack = new ByteBuffer(calculatePackedAllocSize(protocol));
pack.writeByte(protocol);
if (protocol >= 6)
pack.writeInt(version);
pack.writeByte((useNames ? 1 : 0) | (useWhirlpool ? 2 : 0));
if (protocol >= 7)
pack.writeSmart32(folders.length);
else
pack.writeShort(folders.length);
int delta = 0;
for (int i = 0; i < folders.length; i++) {
if (protocol >= 7)
pack.writeSmart32(folders[i].getID() - delta);
else
pack.writeShort(folders[i].getID() - delta);
delta = folders[i].getID();
}
if (useNames) {
for (int i = 0; i < folders.length; i++)
pack.writeInt(folders[i].getName());
}
for (int i = 0; i < folders.length; i++)
pack.writeInt(folders[i].getCRC32());
if (useWhirlpool) {
for (int i = 0; i < folders.length; i++)
pack.writeBytes(folders[i].getDigest(), 0, 64);
}
for (int i = 0; i < folders.length; i++)
pack.writeInt(folders[i].getVersion());
for (int i = 0; i < folders.length; i++) {
if (protocol >= 7)
pack.writeSmart32(folders[i].filesCount());
else
pack.writeShort(folders[i].filesCount());
}
for (int i = 0; i < folders.length; i++) {
int delta_1_ = 0;
for (int a = 0; a < folders[i].filesCount(); a++) {
if (protocol >= 7)
pack.writeSmart32(folders[i].getFiles()[a].getID()
- delta_1_);
else
pack.writeShort(folders[i].getFiles()[a].getID() - delta_1_);
delta_1_ = folders[i].getFiles()[a].getID();
}
}
if (useNames) {
for (int i = 0; i < folders.length; i++) {
for (int a = 0; a < folders[i].filesCount(); a++)
pack.writeInt(folders[i].getFiles()[a].getName());
}
}
return Helper.encodeFITContainer(pack, version);
}
private int calculatePackedAllocSize(int protocol) {
int size = 2;
if (protocol >= 6)
size += 4;
size = size + (protocol >= 7 ? folders.length > 32767 ? 4 : 2 : 2);
int delta = 0;
for (int i = 0; i < folders.length; i++) {
if (protocol >= 7 && folders[i].getID() - delta > 32767)
size += 4;
else
size += 2;
delta = folders[i].getID();
}
if (useNames)
size += folders.length * 4;
size += folders.length * 4;
if (useWhirlpool)
size += folders.length * 64;
size += folders.length * 4;
for (int i = 0; i < folders.length; i++)
size = size
+ (protocol >= 7 ? folders[i].filesCount() > 32767 ? 4 : 2
: 2);
for (int i = 0; i < folders.length; i++) {
int delta_2_ = 0;
for (int a = 0; a < folders[i].filesCount(); a++) {
if (protocol >= 7
&& folders[i].getFiles()[a].getID() - delta_2_ > 32767)
size += 4;
else
size += 2;
delta_2_ = folders[i].getFiles()[a].getID();
}
}
for (int i = 0; i < folders.length; i++) {
for (int a = 0; a < folders[i].filesCount(); a++)
size += 4;
}
return size;
}
private int decideProtocol() {
if (folders.length > 65535)
return 7;
int delta = 0;
for (int i = 0; i < folders.length; i++) {
if (folders[i].getID() - delta > 65535)
return 7;
delta = folders[i].getID();
}
for (int i = 0; i < folders.length; i++) {
if (folders[i].filesCount() > 65535)
return 7;
int delta_3_ = 0;
for (int a = 0; a < folders[i].filesCount(); a++) {
if (folders[i].getFiles()[a].getID() - delta_3_ > 65535)
return 7;
delta_3_ = folders[i].getFiles()[a].getID();
}
}
return version != 0 ? 6 : 5;
}
public Folder findFolderByID(int id) {
return findFolderByID(id, null);
}
public Folder findFolderByID(int id, int[] xtea) {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
for (int i = 0; i < folders.length; i++) {
if (folders[i].getID() == id) {
Folder folder = folders[i];
if (folder.isLoaded())
return folder;
ByteBuffer data = cache.getFilesStore(this.id).get(id);
if (data == null)
throw new RuntimeException(new StringBuilder()
.append("Missing folder:").append(id).toString());
folder.load(data, xtea);
return folder;
}
}
return null;
}
public Folder findFolderByName(String name) {
return findFolderByName(name, null);
}
public Folder findFolderByName(int name) {
return findFolderByName(name, null);
}
public Folder findFolderByName(String name, int[] xtea) {
return findFolderByName(Helper.strToI(name), xtea);
}
public Folder findFolderByName(int name, int[] xtea) {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
if (name == -1)
return null;
for (int i = 0; i < folders.length; i++) {
if (folders[i].getName() == name) {
Folder folder = folders[i];
if (folder.isLoaded())
return folder;
ByteBuffer data = cache.getFilesStore(id).get(folder.getID());
if (data == null)
throw new RuntimeException(new StringBuilder()
.append("Missing folder:").append(folder.getID())
.toString());
folder.load(data, xtea);
return folder;
}
}
return null;
}
public void addFolder(Folder folder) {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
if (!folder.isLoaded())
throw new RuntimeException("folder is not loaded.");
if (findFolderIndex(folder) == -1) {
if (folder.getID() == -1)
folder.setID(getFreeFolderID());
int index = -1;
for (int i = 0; i < folders.length; i++) {
if (folders[i].getID() == folder.getID()) {
index = i;
break;
}
}
if (index == -1) {
Folder[] newFolders = new Folder[folders.length + 1];
System.arraycopy(folders, 0, newFolders, 0, folders.length);
index = folders.length;
folders = newFolders;
}
folders[index] = folder;
folder.markFileSystemInfoAsChanged();
changed = true;
}
}
public void deleteFolder(Folder folder) {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
int index = findFolderIndex(folder);
if (index != -1) {
Folder[] newFolders = new Folder[folders.length - 1];
int write = 0;
for (int i = 0; i < folders.length; i++) {
if (folders[i] != folder)
newFolders[write++] = folders[i];
}
folders = newFolders;
changed = true;
}
}
public void deleteAllFolders() {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
folders = new Folder[0];
changed = true;
}
public void load(Folder folder) {
load(folder, null);
}
public void load(Folder folder, int[] xtea) {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
int index = findFolderIndex(folder);
if (index != -1 && !folder.isLoaded()) {
ByteBuffer data = cache.getFilesStore(id).get(folder.getID());
if (data == null)
throw new RuntimeException(new StringBuilder()
.append("Missing folder:").append(folder.getID())
.toString());
folder.load(data, xtea);
}
}
public void unloadCachedFiles() {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
finish();
for (int i = 0; i < folders.length; i++) {
if (folders[i].isLoaded())
folders[i].unload();
}
}
private int getFreeFolderID() {
if (folders.length == 0)
return 0;
int highest = -1;
for (int i = 0; i < folders.length; i++) {
if (folders[i].getID() > highest)
highest = folders[i].getID();
}
return highest + 1;
}
private int findFolderIndex(Folder folder) {
for (int i = 0; i < folders.length; i++) {
if (folders[i] == folder)
return i;
}
return -1;
}
private void updateHashes(ByteBuffer packed) {
crc = Helper.crc32(packed, 0, packed.getBuffer().length);
digest = Whirlpool.whirlpool(packed.getBuffer(), 0,
packed.getBuffer().length);
}
public boolean isLoaded() {
return packed != null;
}
private boolean needsRepack() {
if (changed)
return true;
for (int i = 0; i < folders.length; i++) {
if (folders[i].isFileSystemInfoChanged())
return true;
}
return false;
}
public int getID() {
return id;
}
public boolean usesNames() {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
return useNames;
}
public boolean usesWhirlpool() {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
return useWhirlpool;
}
public void setUsesNames(boolean uses) {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
if (useNames != uses) {
changed = true;
useNames = uses;
}
}
public void setUsesWhirlpool(boolean uses) {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
if (useWhirlpool != uses) {
changed = true;
useWhirlpool = uses;
}
}
public int getVersion() {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
return version;
}
public void setVersion(int version) {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
if (this.version != version) {
changed = true;
this.version = version;
}
}
public int getCRC32() {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
return crc;
}
public byte[] getDigest() {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
return digest;
}
public boolean usingAutomaticVersionsIncremetor() {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
return useAutomaticVersionIncremetor;
}
public void setUseAutomaticVersionsIncremetor(boolean use) {
if (!isLoaded())
throw new RuntimeException("Using nonloaded filesystem.");
useAutomaticVersionIncremetor = use;
}
public Folder[] getFolders() {
return folders;
}
}
and
Code:
package mgi.tools.jagcached.cache;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.math.BigInteger;
import mgi.tools.jagcached.Helper;
import mgi.utilities.ByteBuffer;
import mgi.utilities.Whirlpool;
public class Cache {
private FileStore[] stores;
private FileStore store_255;
private FileSystem[] fileSystems;
private Cache(String path) {
openFiles(path);
}
private final void openFiles(String path) {
try {
String seperator = System.getProperty("file.separator", "/");
RandomAccessFile dataFile = new RandomAccessFile(path + seperator
+ "main_file_cache.dat2", "rw");
RandomAccessFile referenceFile = new RandomAccessFile(path
+ seperator + "main_file_cache.idx" + "255", "rw");
this.store_255 = new FileStore(255, dataFile.getChannel(),
referenceFile.getChannel(), 500000);
int numIndices = this.store_255.getFileCount();
this.stores = new FileStore[numIndices];
this.fileSystems = new FileSystem[numIndices];
for (int i = 0; i < numIndices; i++) {
RandomAccessFile indexFile = new RandomAccessFile(path
+ seperator + "main_file_cache.idx" + i, "rw");
this.stores[i] = new FileStore(i, dataFile.getChannel(),
indexFile.getChannel(), 1000000);
this.fileSystems[i] = new FileSystem(i, this);
}
} catch (IOException ioex) {
ioex.printStackTrace();
}
}
public void flush() {
if (this.fileSystems == null) {
throw new RuntimeException("Cache is closed.");
}
for (int i = 0; i < this.fileSystems.length; i++)
if (this.fileSystems[i].isLoaded())
this.fileSystems[i].finish();
}
public void close() {
if (this.stores == null) {
return;
}
flush();
for (int i = 0; i < this.stores.length; i++) {
this.stores[i].close();
}
this.store_255.close();
this.fileSystems = null;
this.stores = null;
this.store_255 = null;
}
public static Cache openCache(String path) {
return new Cache(path);
}
public static Cache createNewCache(String path, int indicesCount) {
if ((indicesCount < 0) || (indicesCount > 254)) {
return null;
}
File file = new File(path);
if (file.isFile()) {
return null;
}
if (!file.exists()) {
file.mkdirs();
}
if (!file.isDirectory()) {
return null;
}
try {
String seperator = System.getProperty("file.separator", "/");
File data = new File(path + seperator + "main_file_cache.dat2");
if ((data.exists()) || (!data.createNewFile())
|| (!data.canWrite()) || (!data.canRead())) {
return null;
}
for (int i = 0; i < indicesCount; i++) {
File index = new File(path + seperator + "main_file_cache.idx"
+ i);
if ((index.exists()) || (!index.createNewFile())
|| (!index.canWrite()) || (!data.canRead())) {
return null;
}
}
File index255 = new File(path + seperator + "main_file_cache.idx"
+ "255");
if ((index255.exists()) || (!index255.createNewFile())
|| (!index255.canWrite()) || (!index255.canRead())) {
return null;
}
RandomAccessFile dataFile = new RandomAccessFile(path + seperator
+ "main_file_cache.dat2", "rw");
RandomAccessFile referenceFile = new RandomAccessFile(path
+ seperator + "main_file_cache.idx" + "255", "rw");
FileStore store_255 = new FileStore(255, dataFile.getChannel(),
referenceFile.getChannel(), 500000);
for (int i = 0; i < indicesCount; i++) {
byte[] pdata = Helper.encodeFITContainer(new byte[] { 5, 0, 0,
0 }, 0);
store_255.put(i, new ByteBuffer(pdata), pdata.length);
}
dataFile.getChannel().close();
referenceFile.getChannel().close();
return new Cache(path);
} catch (IOException ex) {
ex.printStackTrace();
}
return null;
}
public FileStore getFilesStore(int id) {
if (this.stores == null) {
throw new RuntimeException("Cache is closed.");
}
if ((id < 0) || (id > this.stores.length)) {
return null;
}
return this.stores[id];
}
public FileSystem getFilesSystem(int id) {
if (this.fileSystems == null) {
throw new RuntimeException("Cache is closed.");
}
if ((id < 0) || (id > this.fileSystems.length)) {
return null;
}
FileSystem system = this.fileSystems[id];
if (!system.isLoaded()) {
system.load();
}
return system;
}
public FileStore getInformationStore() {
if (this.store_255 == null) {
throw new RuntimeException("Cache is closed.");
}
return this.store_255;
}
public int getIndicesCount() {
if (this.stores == null) {
throw new RuntimeException("Cache is closed.");
}
return this.stores.length;
}
public ByteBuffer generateInformationStoreDescriptor(BigInteger exponent,
BigInteger modulus) {
if (this.fileSystems == null) {
throw new RuntimeException("Cache is closed.");
}
for (int i = 0; i < this.fileSystems.length; i++) {
if (!this.fileSystems[i].isLoaded()) {
this.fileSystems[i].load();
}
}
flush();
int indicesCount = getIndicesCount();
ByteBuffer alloc = new ByteBuffer((1 + indicesCount * 72 + 1 + 64) * 10);
alloc.writeByte(indicesCount);
for (int i = 0; i < indicesCount; i++) {
alloc.writeInt(this.fileSystems[i].getCRC32());
alloc.writeInt(this.fileSystems[i].getVersion());
alloc.writeBytes(this.fileSystems[i].getDigest(), 0, 64);
}
byte[] selfDigest = Whirlpool.whirlpool(alloc.getBuffer(), 0,
alloc.getPosition());
ByteBuffer rsa = new ByteBuffer(65);
rsa.writeByte(10);
rsa.writeBytes(selfDigest, 0, 64);
BigInteger data = new BigInteger(rsa.getBuffer());
byte[] encrypted = data.modPow(exponent, modulus).toByteArray();
alloc.writeBytes(encrypted, 0, encrypted.length);
return Helper.encodeFITContainer(
new ByteBuffer(alloc.toArray(0, alloc.getPosition())), 0, 0);
}
public ByteBuffer generateInformationStoreDescriptor() {
if (this.fileSystems == null) {
throw new RuntimeException("Cache is closed.");
}
for (int i = 0; i < this.fileSystems.length; i++) {
if (!this.fileSystems[i].isLoaded()) {
this.fileSystems[i].load();
}
}
flush();
int indicesCount = getIndicesCount();
ByteBuffer alloc = new ByteBuffer((1 + indicesCount * 72 + 1 + 64) * 10);
alloc.writeByte(indicesCount);
for (int i = 0; i < indicesCount; i++) {
alloc.writeInt(this.fileSystems[i].getCRC32());
alloc.writeInt(this.fileSystems[i].getVersion());
alloc.writeBytes(this.fileSystems[i].getDigest(), 0, 64);
}
byte[] selfDigest = Whirlpool.whirlpool(alloc.getBuffer(), 0,
alloc.getPosition());
ByteBuffer rsa = new ByteBuffer(65);
rsa.writeByte(10);
rsa.writeBytes(selfDigest, 0, 64);
BigInteger data = new BigInteger(rsa.getBuffer());
byte[] encrypted = data.toByteArray();
alloc.writeBytes(encrypted, 0, encrypted.length);
return Helper.encodeFITContainer(
new ByteBuffer(alloc.toArray(0, alloc.getPosition())), 0, 0);
}
public void finalize() {
if (this.stores != null) {
System.err.println("mgi.tools.jagcached.cache:Cache not closed.");
close();
}
}
I know this might be spoonfeeding, but from what I understand, it cant read the cache file proprely? Also if that can help, Index 43 is for texture. Thanks