diff --git a/src/main/java/wasm/GWasm.java b/src/main/java/wasm/GWasm.java index 12fc7bc..cd2f878 100644 --- a/src/main/java/wasm/GWasm.java +++ b/src/main/java/wasm/GWasm.java @@ -10,5 +10,18 @@ public class GWasm { public static void main(String[] args) throws IOException, InvalidOpCodeException { + long start = System.currentTimeMillis(); + Module module = new Module("C:\\Users\\jonas\\Desktop\\Projects\\Jznnp\\S\\habbo2020\\rawfiles\\0.23.0_(534)\\habbo2020-global-prod.wasm.gz", true, new ArrayList<>()); + long end = System.currentTimeMillis(); + + System.out.println("Disassemble time: " + (end - start)); + + start = System.currentTimeMillis(); + module.assembleToFile("C:\\Users\\jonas\\Desktop\\Projects\\Jznnp\\S\\habbo2020\\rawfiles\\0.23.0_(534)\\out\\habbo2020-global-prod.wasm.gz", true); + end = System.currentTimeMillis(); + + System.out.println("Assemble time: " + (end - start)); + + System.out.println("hi"); } } diff --git a/src/main/java/wasm/disassembly/modules/Module.java b/src/main/java/wasm/disassembly/modules/Module.java index 6a794ad..4161f08 100644 --- a/src/main/java/wasm/disassembly/modules/Module.java +++ b/src/main/java/wasm/disassembly/modules/Module.java @@ -21,6 +21,8 @@ import wasm.misc.StreamReplacement; import java.io.*; import java.util.ArrayList; import java.util.List; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; public class Module extends WASMOpCode { @@ -80,8 +82,12 @@ public class Module extends WASMOpCode { in.close(); } - public Module(String fileName, List streamReplacements) throws IOException, InvalidOpCodeException { - this(new BufferedInputStream(new FileInputStream(new File(fileName))), streamReplacements); + public Module(String fileName, boolean gzip, List streamReplacements) throws IOException, InvalidOpCodeException { + this(new BufferedInputStream(gzip ? + new GZIPInputStream(new FileInputStream(new File(fileName))) : + new FileInputStream(new File(fileName))) + , streamReplacements + ); } private void disassembleCustomSections(BufferedInputStream in) throws IOException, InvalidOpCodeException { @@ -129,8 +135,8 @@ public class Module extends WASMOpCode { } } - public void assembleToFile(String fileName) throws IOException, InvalidOpCodeException { - assemble(new FileOutputStream(fileName)); + public void assembleToFile(String fileName, boolean gzip) throws IOException, InvalidOpCodeException { + assemble(gzip ? new GZIPOutputStream(new FileOutputStream(fileName)) : new FileOutputStream(fileName)); } public Magic getMagic() {