Tuesday, September 27, 2011

BCBG now has an integrated deobfuscator, kind of!

Thanks to the kindness of the MCP devs CBG now loads and parses the MCP .csv deobf tables at runtime, allowing mod developers to compile with MCP calls! This was really only needed for the @noPatch annotation as MCp is "clever" and won't obfuscate a method call if there's a method with that name declared, so I just do it at runtime instead. Eventually this will become a full deobfuscator.

Reobfing method a(IIF)V to sf.a
func_35356_c, (IIF)V, sf
Replacing method call: GuiMainMenu_Stub.func_35356_c with sf.c

Saturday, September 24, 2011

BCBG is now open source!

Check out the repository on GitHub!

This is not the official first release, but I've been stalling a bit and wanted to show I was doing something ;). The first release will be soon, after the @nopatch annotation feature is added.

An Update on BCBG

I know I said I'd have the mod done in a week, a week ago. I've gotten sort of sidetracked with some side-projects, and it's taken a while.

Also, I've now officially doubled the amount of classes in the launcher. Jeez.

The launcher can now load stubs named with MCP class names (ie, in 1.8 GuiMainMenu_Stub.class will patch sf.class).I've also worked out how I'll handle needing to reference methods/fields in the original class but not wanting to override them: with a @nopatch annotation (not ideal but subclasses dun work).

For example, before:
public void patchMe(){
    nonPatchyThings();
    return 1 + 1;
}
//need nonPatchyThings declared even though you won't use it, so it will be patched even though it shouldn't be!
After:
public void patchMe(){
    nonPatchyThings();
    return 1+1;
}
@nopatch
public void nonPatchyThins(){} //won't get patched but will compile without errors, will use actual version at runtime 
I'm also working on the installer that was promised. The manual patch API might get pushed back to a different release because it's a pain.

Saturday, September 17, 2011

Evolution of the Stub Mechanism

Originally my plan for BCBG was to only provide Patch classes. However, I noticed transitioning a base class to a patch class was often needlessly difficult if the modifications weren't complicated. I started designing an extension to the Patch interface that would allow passing in a byte[] as class data to strip methods from, and realized "Hey, I could do this automatically!". I quickly created a very hacky interface to scan for one method and move it to another class. Then I rewrote that into a nicer interface, and made it scan all methods and fields.

The way the current mechanism works is through a "cache" system. I parse through the stub class and cache all the events ASM emits, then replay them on the target class.

The BCBG event chain - the CachingClassAdapter stores the CallCache/CachingMethodAdapter/CachingFieldAdapters to emit later


The old Patch classes are neatly worked in as pre/post Stub operations. The system is very fast, mainly thanks to ASM's optimization. Two Stubs complete in less than a second, depending on their complexity.

Next blog post I'll talk about the Patch class design and how that works in with Stub classes.

Thursday, September 15, 2011

BaseClassesBeGone Development Blog Launch

I doubt very many people will read this, but I sort of wanted a place to document my development choices for BCBG.

What is BCBG?
BCBG is a mod for the Minecraft launcher that replaces basefile modifications for patching classes. More information at the Reddit thread here.