v2.9.17
This commit is contained in:
		
							parent
							
								
									e1e79d0869
								
							
						
					
					
						commit
						b3e60ce5bf
					
				
					 6 changed files with 78 additions and 12 deletions
				
			
		
							
								
								
									
										
											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
 | 
			
		||||
{
 | 
			
		||||
    /*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 enjarifyVersion = "4";
 | 
			
		||||
    public static final boolean BLOCK_TAB_MENU = true;
 | 
			
		||||
| 
						 | 
				
			
			@ -847,6 +847,13 @@ public class BytecodeViewer
 | 
			
		|||
                                if (fn.endsWith(".jar") || fn.endsWith(".zip")) {
 | 
			
		||||
                                    try {
 | 
			
		||||
                                        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) {
 | 
			
		||||
                                        new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
 | 
			
		||||
                                        update = false;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -583,6 +583,10 @@ public class FileNavigationPane extends VisibleComponent implements
 | 
			
		|||
            if (cn != null) {
 | 
			
		||||
                openClassFileToWorkSpace(container, nameBuffer.toString(), cn);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                openFileToWorkSpace(container, nameBuffer.toString(), BytecodeViewer.getFileContents(nameBuffer.toString()));
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            openFileToWorkSpace(container, nameBuffer.toString(), BytecodeViewer.getFileContents(nameBuffer.toString()));
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2387,7 +2387,7 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier
 | 
			
		|||
        });
 | 
			
		||||
 | 
			
		||||
        visualSettings.add(synchronizedViewing);
 | 
			
		||||
        showClassMethods.setSelected(true);
 | 
			
		||||
        showClassMethods.setSelected(false);
 | 
			
		||||
        visualSettings.add(showClassMethods);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,20 +1,24 @@
 | 
			
		|||
package the.bytecode.club.bytecodeviewer.util;
 | 
			
		||||
 | 
			
		||||
import java.io.ByteArrayOutputStream;
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.io.FileInputStream;
 | 
			
		||||
import java.io.FileOutputStream;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
import java.io.*;
 | 
			
		||||
import java.nio.file.Files;
 | 
			
		||||
import java.nio.file.Path;
 | 
			
		||||
import java.nio.file.Paths;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Enumeration;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
import java.util.jar.JarOutputStream;
 | 
			
		||||
import java.util.zip.ZipEntry;
 | 
			
		||||
import java.util.zip.ZipException;
 | 
			
		||||
import java.util.zip.ZipInputStream;
 | 
			
		||||
 | 
			
		||||
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.ClassWriter;
 | 
			
		||||
import org.objectweb.asm.tree.ClassNode;
 | 
			
		||||
| 
						 | 
				
			
			@ -76,10 +80,14 @@ public class JarUtils {
 | 
			
		|||
                            e.printStackTrace();
 | 
			
		||||
                        }
 | 
			
		||||
                    } 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) {
 | 
			
		||||
                new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
 | 
			
		||||
            } finally {
 | 
			
		||||
| 
						 | 
				
			
			@ -89,7 +97,57 @@ public class JarUtils {
 | 
			
		|||
        jis.close();
 | 
			
		||||
        container.files = files;
 | 
			
		||||
        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…
	
	Add table
		Add a link
		
	
		Reference in a new issue