2015-11-11 04:16:45 +00:00
|
|
|
package the.bytecode.club.bytecodeviewer.api;
|
|
|
|
|
2018-01-31 15:03:53 +00:00
|
|
|
import java.util.ArrayList;
|
2021-08-27 08:49:31 +00:00
|
|
|
import java.util.List;
|
2015-11-11 04:16:45 +00:00
|
|
|
import org.objectweb.asm.tree.ClassNode;
|
2018-01-31 15:03:53 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
2021-07-13 11:46:21 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
2015-11-19 03:30:59 +00:00
|
|
|
|
2015-11-11 04:16:45 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
|
|
|
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A simple plugin class, it will run the plugin in a background thread.
|
2018-01-31 15:41:24 +00:00
|
|
|
*
|
2015-11-11 04:16:45 +00:00
|
|
|
* @author Konloch
|
|
|
|
*/
|
|
|
|
|
2021-07-06 22:38:37 +00:00
|
|
|
public abstract class Plugin extends Thread
|
|
|
|
{
|
2021-07-13 11:46:21 +00:00
|
|
|
//as long as your code is being called from the execute function
|
|
|
|
// this will be the current container
|
|
|
|
public ResourceContainer activeContainer = null;
|
|
|
|
|
2018-01-31 15:41:24 +00:00
|
|
|
@Override
|
2021-07-06 22:38:37 +00:00
|
|
|
public void run()
|
|
|
|
{
|
2021-07-06 22:57:42 +00:00
|
|
|
BytecodeViewer.updateBusyStatus(true);
|
2021-07-06 22:38:37 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2021-07-16 20:55:03 +00:00
|
|
|
if (BytecodeViewer.promptIfNoLoadedResources())
|
2018-01-31 15:41:24 +00:00
|
|
|
return;
|
2021-07-13 11:46:21 +00:00
|
|
|
|
|
|
|
executeContainer();
|
2018-01-31 15:41:24 +00:00
|
|
|
} catch (Exception e) {
|
2021-07-07 02:51:10 +00:00
|
|
|
BytecodeViewer.handleException(e);
|
2018-01-31 15:41:24 +00:00
|
|
|
} finally {
|
|
|
|
finished = true;
|
2021-07-06 22:57:42 +00:00
|
|
|
BytecodeViewer.updateBusyStatus(false);
|
2018-01-31 15:41:24 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-11 04:16:45 +00:00
|
|
|
|
2018-01-31 15:41:24 +00:00
|
|
|
private boolean finished = false;
|
2015-11-11 04:16:45 +00:00
|
|
|
|
2018-01-31 15:41:24 +00:00
|
|
|
/**
|
|
|
|
* When the plugin is finally finished, this will return true
|
|
|
|
*
|
|
|
|
* @return true if the plugin is finished executing
|
|
|
|
*/
|
|
|
|
public boolean isFinished() {
|
|
|
|
return finished;
|
|
|
|
}
|
2015-11-11 04:16:45 +00:00
|
|
|
|
2018-01-31 15:41:24 +00:00
|
|
|
/**
|
|
|
|
* If for some reason your plugin needs to keep the thread alive, yet will
|
|
|
|
* still be considered finished (EZ-Injection), you can call this function
|
|
|
|
* and it will set the finished boolean to true.
|
|
|
|
*/
|
|
|
|
public void setFinished() {
|
|
|
|
finished = true;
|
|
|
|
}
|
2021-07-13 11:46:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* On plugin start each resource container is iterated through
|
|
|
|
*/
|
|
|
|
public void executeContainer()
|
|
|
|
{
|
|
|
|
BytecodeViewer.getResourceContainers().forEach(container -> {
|
|
|
|
//set the active container
|
|
|
|
activeContainer = container;
|
|
|
|
|
|
|
|
//call on the plugin code
|
|
|
|
execute(new ArrayList<>(container.resourceClasses.values()));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-01-31 15:41:24 +00:00
|
|
|
/**
|
2021-07-13 11:46:21 +00:00
|
|
|
* On plugin start each resource container is iterated through,
|
|
|
|
* then this is called with the resource container classes
|
2018-01-31 15:41:24 +00:00
|
|
|
*
|
2022-01-07 19:16:17 +00:00
|
|
|
* @param classNodeList all the loaded classes for easy access.
|
2018-01-31 15:41:24 +00:00
|
|
|
*/
|
2021-08-27 08:49:31 +00:00
|
|
|
public abstract void execute(List<ClassNode> classNodeList);
|
2015-11-11 04:16:45 +00:00
|
|
|
}
|