public final class ASMHelper
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ASMHelper.InvalidNeedleException |
static class |
ASMHelper.MethodNotFoundException |
| Modifier and Type | Field and Description |
|---|---|
static boolean |
isASMEnabled |
static boolean |
isSrg |
| Constructor and Description |
|---|
ASMHelper() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
canIgnoreInstruction(org.objectweb.asm.tree.AbstractInsnNode insn)
Checks if an instruction can be ignored.
|
static byte[] |
createByteArrayFromClass(org.objectweb.asm.tree.ClassNode classNode,
int flags)
Converts a ClassNode into a byte array which can then be returned by your transformer.
|
static org.objectweb.asm.tree.ClassNode |
createClassFromByteArray(byte[] classBytes)
Converts a byte array into a ClassNode which can then easily be worked with and
manipulated.
|
static org.objectweb.asm.tree.AbstractInsnNode |
findFirstNodeFromNeedle(org.objectweb.asm.tree.InsnList haystack,
org.objectweb.asm.tree.InsnList needle)
Finds the first instruction node after the the provided instruction list, within a
larger list of instructions.
|
static org.objectweb.asm.tree.AbstractInsnNode |
findLastNodeFromNeedle(org.objectweb.asm.tree.InsnList haystack,
org.objectweb.asm.tree.InsnList needle)
Finds the last instruction node after the provided instruction list, within a larger
list of instructions.
|
static java.lang.String |
getAppropriateMapping(java.lang.String mcp,
java.lang.String srg)
Provides an easy way to retrieve an appropriate mapping, based on if the environement is
using mcp mappings or srg mappings.
|
static org.objectweb.asm.tree.MethodNode |
getMethodFromClass(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String methodName,
java.lang.String descriptor)
Retrieves a MethodNode from a ClassNode, if one can not be found, an exception will be
thrown, and the game will stop.
|
static boolean |
hasClassMethodName(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String methodName)
Checks if a ClassNode has an instance of the target method.
|
static void |
removeNeedleFromHaystack(org.objectweb.asm.tree.InsnList haystack,
org.objectweb.asm.tree.InsnList needle)
Removes a specific set of instructions (the needle) from a much larger set of
instructions (the hay stack).
|
public static java.lang.String getAppropriateMapping(java.lang.String mcp,
java.lang.String srg)
mcp: - The string you want if this environment is using mcp mappings.srg: - The string you want if this environment is using srg mappings.public static byte[] createByteArrayFromClass(org.objectweb.asm.tree.ClassNode classNode,
int flags)
classNode: - An instance of the ClassNode you wish to convert into a byte array.flags: - The flags to use when converting the ClassNode. These are generally
COMPUTE_FRAMES and COMPUTE_MAXS.public static org.objectweb.asm.tree.ClassNode createClassFromByteArray(byte[] classBytes)
classBytes: - The byte array representation of the class.public static boolean hasClassMethodName(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String methodName)
classNode: - The instance of ClassNode to look through.methodName: - The name of the method you are looking for.public static org.objectweb.asm.tree.MethodNode getMethodFromClass(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String methodName,
java.lang.String descriptor)
classNode: - An instance of the ClassNode to go looking through.methodName: - The name of the desired method.descriptor: - The descriptor for the method, used to find a specific version of the
desired method.public static org.objectweb.asm.tree.AbstractInsnNode findFirstNodeFromNeedle(org.objectweb.asm.tree.InsnList haystack,
org.objectweb.asm.tree.InsnList needle)
haystack: - A complete list of instructions which is being searched through.needle: - A small list of instructions which represents a very specific part of the
larger instruction list.public static org.objectweb.asm.tree.AbstractInsnNode findLastNodeFromNeedle(org.objectweb.asm.tree.InsnList haystack,
org.objectweb.asm.tree.InsnList needle)
haystack: - A large list of instructions which is being searched through.needle: - A small list of instructions which represents a very specific part of the
larger instruction list.public static void removeNeedleFromHaystack(org.objectweb.asm.tree.InsnList haystack,
org.objectweb.asm.tree.InsnList needle)
haystack: - A large list of instructions which is being searched through.needle: - A specific list of instructions which are to be removed from the larger
instruction list.public static boolean canIgnoreInstruction(org.objectweb.asm.tree.AbstractInsnNode insn)
insn: - The AbstractInsnNode to check against.