v2.9.17
This commit is contained in:
parent
e1e79d0869
commit
b3e60ce5bf
BIN
libs/commons-compress-1.18.jar
Normal file
BIN
libs/commons-compress-1.18.jar
Normal file
Binary file not shown.
|
@ -1,3 +0,0 @@
|
||||||
Manifest-Version: 1.0
|
|
||||||
Main-Class: the.bytecode.club.bytecodeviewer.BytecodeViewer
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ import the.bytecode.club.bytecodeviewer.util.*;
|
||||||
public class BytecodeViewer
|
public class BytecodeViewer
|
||||||
{
|
{
|
||||||
/*per version*/
|
/*per version*/
|
||||||
public static final String VERSION = "2.9.16";
|
public static final String VERSION = "2.9.17";
|
||||||
public static String krakatauVersion = "12";
|
public static String krakatauVersion = "12";
|
||||||
public static String enjarifyVersion = "4";
|
public static String enjarifyVersion = "4";
|
||||||
public static final boolean BLOCK_TAB_MENU = true;
|
public static final boolean BLOCK_TAB_MENU = true;
|
||||||
|
@ -847,6 +847,13 @@ public class BytecodeViewer
|
||||||
if (fn.endsWith(".jar") || fn.endsWith(".zip")) {
|
if (fn.endsWith(".jar") || fn.endsWith(".zip")) {
|
||||||
try {
|
try {
|
||||||
JarUtils.put(f);
|
JarUtils.put(f);
|
||||||
|
} catch (final java.util.zip.ZipException z) {
|
||||||
|
try {
|
||||||
|
JarUtils.put2(f);
|
||||||
|
} catch (final Exception e) {
|
||||||
|
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||||
|
update = false;
|
||||||
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||||
update = false;
|
update = false;
|
||||||
|
|
|
@ -583,6 +583,10 @@ public class FileNavigationPane extends VisibleComponent implements
|
||||||
if (cn != null) {
|
if (cn != null) {
|
||||||
openClassFileToWorkSpace(container, nameBuffer.toString(), cn);
|
openClassFileToWorkSpace(container, nameBuffer.toString(), cn);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
openFileToWorkSpace(container, nameBuffer.toString(), BytecodeViewer.getFileContents(nameBuffer.toString()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
openFileToWorkSpace(container, nameBuffer.toString(), BytecodeViewer.getFileContents(nameBuffer.toString()));
|
openFileToWorkSpace(container, nameBuffer.toString(), BytecodeViewer.getFileContents(nameBuffer.toString()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2387,7 +2387,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier
|
||||||
});
|
});
|
||||||
|
|
||||||
visualSettings.add(synchronizedViewing);
|
visualSettings.add(synchronizedViewing);
|
||||||
showClassMethods.setSelected(true);
|
showClassMethods.setSelected(false);
|
||||||
visualSettings.add(showClassMethods);
|
visualSettings.add(showClassMethods);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,24 @@
|
||||||
package the.bytecode.club.bytecodeviewer.util;
|
package the.bytecode.club.bytecodeviewer.util;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.*;
|
||||||
import java.io.File;
|
import java.nio.file.Files;
|
||||||
import java.io.FileInputStream;
|
import java.nio.file.Path;
|
||||||
import java.io.FileOutputStream;
|
import java.nio.file.Paths;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.jar.JarOutputStream;
|
import java.util.jar.JarOutputStream;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipException;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
import me.konloch.kontainer.io.DiskWriter;
|
import me.konloch.kontainer.io.DiskWriter;
|
||||||
|
|
||||||
|
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
||||||
|
import org.apache.commons.compress.archivers.zip.ZipFile;
|
||||||
|
import org.apache.commons.compress.utils.IOUtils;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.objectweb.asm.ClassReader;
|
import org.objectweb.asm.ClassReader;
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
@ -76,10 +80,14 @@ public class JarUtils {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println(jarFile + ">" + name + ": Header does not start with CAFEBABE, ignoring.");
|
if (!entry.isDirectory())
|
||||||
|
files.put(name, bytes);
|
||||||
|
//System.out.println(jarFile + ">" + name + ": Header does not start with CAFEBABE, ignoring.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (ZipException e) {
|
||||||
|
//ignore cause apache unzip
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -89,7 +97,57 @@ public class JarUtils {
|
||||||
jis.close();
|
jis.close();
|
||||||
container.files = files;
|
container.files = files;
|
||||||
BytecodeViewer.files.add(container);
|
BytecodeViewer.files.add(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void put2(final File jarFile) throws IOException {
|
||||||
|
//TODO try zip libraries till one works, worst case import Sun's jarsigner code from JDK 7 re-sign the jar to rebuilt the CRC, should also rebuild the archive byte offsets
|
||||||
|
|
||||||
|
FileContainer container = new FileContainer(jarFile);
|
||||||
|
HashMap<String, byte[]> files = new HashMap<String, byte[]>();
|
||||||
|
|
||||||
|
|
||||||
|
Path path = jarFile.toPath();
|
||||||
|
|
||||||
|
String fileBaseName = FilenameUtils.getBaseName(path.getFileName().toString());
|
||||||
|
Path destFolderPath = Paths.get(path.getParent().toString(), fileBaseName);
|
||||||
|
|
||||||
|
try (ZipFile zipFile = new ZipFile(jarFile))
|
||||||
|
{
|
||||||
|
Enumeration<? extends ZipArchiveEntry> entries = zipFile.getEntries();
|
||||||
|
while (entries.hasMoreElements()) {
|
||||||
|
ZipArchiveEntry entry = entries.nextElement();
|
||||||
|
Path entryPath = destFolderPath.resolve(entry.getName());
|
||||||
|
String name = entry.getName();
|
||||||
|
if (entry.isDirectory()) {
|
||||||
|
//directory
|
||||||
|
} else {
|
||||||
|
try (InputStream in = zipFile.getInputStream(entry))
|
||||||
|
{
|
||||||
|
|
||||||
|
final byte[] bytes = getBytes(in);
|
||||||
|
if (!name.endsWith(".class")) {
|
||||||
|
files.put(name, bytes);
|
||||||
|
} else {
|
||||||
|
String cafebabe = String.format("%02X", bytes[0]) + String.format("%02X", bytes[1]) + String.format("%02X", bytes[2]) + String.format("%02X", bytes[3]);
|
||||||
|
if (cafebabe.toLowerCase().equals("cafebabe")) {
|
||||||
|
try {
|
||||||
|
final ClassNode cn = getNode(bytes);
|
||||||
|
container.classes.add(cn);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
files.put(name, bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
container.files = files;
|
||||||
|
BytecodeViewer.files.add(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user