use of codechicken.lib.asm.ObfMapping in project Galacticraft by micdoodle8.
the class InterfaceDependancyTransformer method transform.
@Override
public byte[] transform(String name, String tname, byte[] bytes) {
if (bytes == null) {
return null;
}
ClassNode cnode = ASMHelper.createClassNode(bytes);
boolean hasDependancyInterfaces = false;
if (cnode.visibleAnnotations != null) {
for (AnnotationNode ann : cnode.visibleAnnotations) {
if (ann.desc.equals(Type.getDescriptor(InterfaceDependancies.class))) {
hasDependancyInterfaces = true;
break;
}
}
}
if (!hasDependancyInterfaces) {
return bytes;
}
hasDependancyInterfaces = false;
for (Iterator<String> iterator = cnode.interfaces.iterator(); iterator.hasNext(); ) {
try {
Launch.classLoader.findClass(new ObfMapping(iterator.next()).toRuntime().javaClass());
} catch (ClassNotFoundException cnfe) {
iterator.remove();
hasDependancyInterfaces = true;
}
}
if (!hasDependancyInterfaces) {
return bytes;
}
return ASMHelper.createBytes(cnode, 0);
}
use of codechicken.lib.asm.ObfMapping in project Galacticraft by micdoodle8.
the class MCPDeobfuscationTransformer method injectCallback.
private byte[] injectCallback(byte[] bytes) {
ClassNode cnode = ASMHelper.createClassNode(bytes);
MethodNode mnode = ASMHelper.findMethod(new ObfMapping(cnode.name, "<clinit>", "()V"), cnode);
mnode.instructions.insert(new MethodInsnNode(INVOKESTATIC, "codechicken/core/asm/MCPDeobfuscationTransformer", "loadCallback", "()V"));
return ASMHelper.createBytes(cnode, 0);
}
use of codechicken.lib.asm.ObfMapping in project Galacticraft by micdoodle8.
the class ConstantObfuscator method matchesDesc.
private boolean matchesDesc(AbstractInsnNode insn) {
if (insn.getType() != LDC_INSN) {
return false;
}
insn = insn.getNext();
if (insn == null || insn.getType() != LDC_INSN) {
return false;
}
insn = insn.getNext();
if (insn == null || insn.getType() != LDC_INSN) {
return false;
}
insn = insn.getNext();
if (insn == null || insn.getType() != METHOD_INSN) {
return false;
}
for (ObfMapping m : descCalls) {
if (m.matches((MethodInsnNode) insn)) {
return true;
}
}
return false;
}
use of codechicken.lib.asm.ObfMapping in project Galacticraft by micdoodle8.
the class ConstantObfuscator method obfuscateInsnSeq.
private void obfuscateInsnSeq(AbstractInsnNode insn) {
if (matchesClass(insn)) {
LdcInsnNode node1 = (LdcInsnNode) insn;
node1.cst = obf.map((String) node1.cst);
}
if (matchesDesc(insn)) {
LdcInsnNode node1 = (LdcInsnNode) insn;
LdcInsnNode node2 = (LdcInsnNode) node1.getNext();
LdcInsnNode node3 = (LdcInsnNode) node2.getNext();
ObfMapping mapping = new ObfMapping((String) node1.cst, (String) node2.cst, (String) node3.cst).map(obf);
node1.cst = mapping.s_owner;
node2.cst = mapping.s_name;
node3.cst = mapping.s_desc;
}
}
use of codechicken.lib.asm.ObfMapping in project Galacticraft by micdoodle8.
the class MCPDeobfuscationTransformer method remapAccessTransformer.
@SuppressWarnings("unchecked")
private static void remapAccessTransformer(IClassTransformer t) {
Multimap<String, ?> modifiers = (Multimap<String, ?>) get(f_modifiers, t);
Multimap<String, Object> t_modifiers = HashMultimap.create();
for (Entry<String, ?> entry : modifiers.entries()) {
Object mod = entry.getValue();
String m_owner = entry.getKey().replace('.', '/');
String m_name = (String) get(f_Modifier_name, mod);
String m_desc = ((String) get(f_Modifier_desc, mod)).replace('.', '/');
ObfMapping map;
if (m_name.equals("*")) {
map = new ObfMapping(m_owner);
map.s_name = m_name;
map.s_desc = m_desc;
} else {
try {
map = new ObfMapping(m_owner, m_name, m_desc).toClassloading();
} catch (Exception e) {
new Object();
continue;
}
}
set(f_Modifier_name, mod, map.s_name);
set(f_Modifier_desc, mod, map.s_desc);
t_modifiers.put(map.javaClass(), mod);
}
set(f_modifiers, t, t_modifiers);
}
Aggregations