Terminology Update

File Container has been changed to Resource Container
This commit is contained in:
Konloch 2021-07-13 07:33:32 -07:00
parent f055028686
commit eb225eaa79
12 changed files with 26 additions and 23 deletions

View File

@ -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<ResourceContainer> 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)

View File

@ -60,7 +60,7 @@ public abstract class ResourceViewer extends JPanel
*/
public byte[] getResourceBytes()
{
return container.getBytes(name);
return container.getFileContents(name);
}

View File

@ -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";

View File

@ -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

View File

@ -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);

View File

@ -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())

View File

@ -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);

View File

@ -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");

View File

@ -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);
}
}

View File

@ -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)

View File

@ -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);
}
}

View File

@ -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
*/