diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java index 54ff141a..c5d022d2 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java @@ -77,7 +77,7 @@ import static the.bytecode.club.bytecodeviewer.util.MiscUtils.guessLanguage; * + All of the plugins that modify code need to include BytecodeViewer.updateAllClassNodeByteArrays(); * + All of the plugins that do any code changes should also include BytecodeViewer.refreshAllTabs(); * + Anything using getLoadedClasses() needs to be replaced with the new API - * + Anything using blindlySearchForClassNode() should instead search through the file container search function + * + Anything using blindlySearchForClassNode() should instead search through the resource container search function * * TODO IN-PROGRESS: * + Resource Exporter/Save/Decompile As Zip needs to be rewrittern @@ -319,7 +319,7 @@ public class BytecodeViewer /** * Returns the ClassNode by the specified name * - * TODO anything relying on this should be rewritten to search using the file container + * TODO anything relying on this should be rewritten to search using the resource container * * @param name the class name * @return the ClassNode instance @@ -338,7 +338,7 @@ public class BytecodeViewer } /** - * Returns the File Container by the specific name + * Returns the resource container by the specific name */ public static ResourceContainer getFileContainer(String name) { @@ -350,7 +350,7 @@ public class BytecodeViewer } /** - * Returns all of the loaded File Containers + * Returns all of the loaded resource containers */ public static List getResourceContainers() { return resourceContainers; @@ -359,9 +359,12 @@ public class BytecodeViewer /** * Grabs the file contents of the loaded resources. * + * TODO anything relying on this should be rewritten to use the resource container's getFileContents + * * @param name the file name * @return the file contents as a byte[] */ + @Deprecated public static byte[] getFileContents(String name) { for (ResourceContainer container : resourceContainers) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ResourceViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ResourceViewer.java index 357dd5bf..8bab3513 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ResourceViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ResourceViewer.java @@ -60,7 +60,7 @@ public abstract class ResourceViewer extends JPanel */ public byte[] getResourceBytes() { - return container.getBytes(name); + return container.getFileContents(name); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/malwarescanner/MalwareCodeScanner.java b/src/main/java/the/bytecode/club/bytecodeviewer/malwarescanner/MalwareCodeScanner.java index 4f066198..52e32a7f 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/malwarescanner/MalwareCodeScanner.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/malwarescanner/MalwareCodeScanner.java @@ -108,7 +108,7 @@ public abstract class MalwareCodeScanner implements CodeScanner { String header = String.format("%30s", (module.getReadableName() + " ->\t")); - //TODO display the file container for this specific ClassNode + //TODO display the resource container for this specific ClassNode if(BytecodeViewer.viewer.showFileInTabTitle.isSelected()) header += "{fileContainerGoesHere}\t"; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/AllatoriStringDecrypter.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/AllatoriStringDecrypter.java index 6365e1b3..c4db38b1 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/AllatoriStringDecrypter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/AllatoriStringDecrypter.java @@ -111,7 +111,7 @@ public class AllatoriStringDecrypter extends Plugin private int getConstantPoolSize(String className) { - byte[] fileContents = BytecodeViewer.getFileContents(className + ".class"); + byte[] fileContents = activeContainer.getFileContents(className + ".class"); return readUnsignedShort(fileContents, 8); } @@ -144,7 +144,7 @@ public class AllatoriStringDecrypter extends Plugin // Decrypter is always a static method of other class's inner class if (decrypterClassName.contains("$")) { - byte[] decrypterFileContents = BytecodeViewer.getFileContents(decrypterClassName + ".class"); + byte[] decrypterFileContents = activeContainer.getFileContents(decrypterClassName + ".class"); // We have to create new node for editing // Also, one decrypter method could be used for multiple methods in code, what gives us only part of string decrypted diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ViewAPKAndroidPermissions.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ViewAPKAndroidPermissions.java index e7b1d55d..b4f09b29 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ViewAPKAndroidPermissions.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ViewAPKAndroidPermissions.java @@ -20,14 +20,14 @@ public class ViewAPKAndroidPermissions extends Plugin PluginConsole frame = new PluginConsole(activeContainer.name + " - Android Permissions"); frame.setVisible(true); - byte[] encodedAndroidManifest = BytecodeViewer.getFileContents("AndroidManifest.xml"); + byte[] encodedAndroidManifest = activeContainer.getFileContents("AndroidManifest.xml"); if(encodedAndroidManifest == null) { frame.appendText("This plugin only works on valid Android APKs"); return; } - byte[] decodedAndroidManifest = BytecodeViewer.getFileContents("Decoded Resources/AndroidManifest.xml"); + byte[] decodedAndroidManifest = activeContainer.getFileContents("Decoded Resources/AndroidManifest.xml"); if(decodedAndroidManifest != null) { String manifest = new String(decodedAndroidManifest, StandardCharsets.UTF_8); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ViewManifest.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ViewManifest.java index f1bad95a..44deb880 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ViewManifest.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/preinstalled/ViewManifest.java @@ -21,18 +21,18 @@ public class ViewManifest extends Plugin frame.setVisible(true); //TODO android APKs may have AndroidManifests that can be viewed normally, this should be checked - byte[] encodedAndroidManifest = BytecodeViewer.getFileContents("AndroidManifest.xml"); + byte[] encodedAndroidManifest = activeContainer.getFileContents("AndroidManifest.xml"); if(encodedAndroidManifest != null) { frame.appendText("Android APK Manifest:\r"); - byte[] decodedAndroidManifest = BytecodeViewer.getFileContents("Decoded Resources/AndroidManifest.xml"); + byte[] decodedAndroidManifest = activeContainer.getFileContents("Decoded Resources/AndroidManifest.xml"); if(decodedAndroidManifest != null) frame.appendText(new String(decodedAndroidManifest, StandardCharsets.UTF_8)); else frame.appendText("Enable Settings>Decode APK Resources!"); } - byte[] jarManifest = BytecodeViewer.getFileContents("META-INF/MANIFEST.MF"); + byte[] jarManifest = activeContainer.getFileContents("META-INF/MANIFEST.MF"); if(jarManifest != null) { if(!frame.getTextArea().getText().isEmpty()) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceContainer.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceContainer.java index 03649bd0..e787f71d 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceContainer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceContainer.java @@ -74,7 +74,7 @@ public class ResourceContainer /** * Returns the resource bytes for the specified resource key (full name path) */ - public byte[] getBytes(String resourceName) + public byte[] getFileContents(String resourceName) { if(resourceClassBytes.containsKey(resourceName)) return resourceClassBytes.get(resourceName); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceContainerImporter.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceContainerImporter.java index 87ec49ca..37dd792e 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceContainerImporter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceContainerImporter.java @@ -116,7 +116,7 @@ public class ResourceContainerImporter if( existingNode != null) { //TODO prompt to ask the user if they would like to overwrite the resource conflict - // or solve it automatically by creating a new file container for each conflict (means no editing) + // or solve it automatically by creating a new resource container for each conflict (means no editing) System.err.println("WARNING: Resource Conflict: " + name); System.err.println("Suggested Fix: Contact Konloch to add support for resource conflicts"); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/FileResourceImporter.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/FileResourceImporter.java index d3b35869..02971d6d 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/FileResourceImporter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/FileResourceImporter.java @@ -16,13 +16,13 @@ public class FileResourceImporter implements Importer @Override public void open(File file) throws Exception { - //create the new file container + //create the new resource container ResourceContainer container = new ResourceContainer(file); //create the new file importer ResourceContainerImporter importer = new ResourceContainerImporter(container); - //import the file into the file container + //import the file into the resource container importer.importAsFile(); - //add the file container to BCV's total loaded files + //add the resource container to BCV's total loaded files BytecodeViewer.resourceContainers.add(container); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/XAPKResourceImporter.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/XAPKResourceImporter.java index 61d02f79..8132b155 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/XAPKResourceImporter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/XAPKResourceImporter.java @@ -72,7 +72,7 @@ public class XAPKResourceImporter implements Importer Configuration.silenceExceptionGUI--; //turn exceptions back on BytecodeViewer.viewer.clearBusyStatus(); //clear errant busy signals from failed APK imports container.resourceFiles = allDirectoryFiles; //store the file resource - BytecodeViewer.resourceContainers.add(container); //add the file container to BCV's total loaded files + BytecodeViewer.resourceContainers.add(container); //add the resource container to BCV's total loaded files } public File exportTo(File original, String extension, byte[] bytes) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/ZipResourceImporter.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/ZipResourceImporter.java index acddd4a7..4ee6b094 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/ZipResourceImporter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/importing/impl/ZipResourceImporter.java @@ -16,13 +16,13 @@ public class ZipResourceImporter implements Importer @Override public void open(File file) throws Exception { - //create the new file container + //create the new resource container ResourceContainer container = new ResourceContainer(file); //create the new file importer ResourceContainerImporter importer = new ResourceContainerImporter(container); - //import the file as zip into the file container + //import the file as zip into the resource container importer.importAsZip(); - //add the file container to BCV's total loaded files + //add the resource container to BCV's total loaded files BytecodeViewer.resourceContainers.add(container); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/LazyNameUtil.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/LazyNameUtil.java index 7101d9c5..ddb71ce0 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/LazyNameUtil.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/LazyNameUtil.java @@ -23,7 +23,7 @@ import org.apache.commons.lang3.StringUtils; ***************************************************************************/ /** - * Prevents name path collisions by allowing the same name to be used in multiple file containers. + * Prevents name path collisions by allowing the same name to be used in multiple resource containers. * * @author Konloch */