Friday, August 14, 2015

Introduction & Setup

What are native mods?

Native mods (also called addons though they're apps that are addons to blocklauncher) are programs written in C++ and Java for Android. The core mod's code must be written in C++.

How does an addon work?

Addons are programs which are interpreted by Block Launcher, a mod loader for mcpe for android. Block Launcher basically launches mcpe inside it's view, and can override mcpe's methods (via replacing addresses in RAM). E.g. if one mcpe's function is called whenever a block is being rendered and an addon overrides the method, BlockLauncher simply "redirects" the original method to the addon function, which calls it's own methods and (optionally) the original one. An addon must contain the mcpe's library in it's /jni folder in order to override mcpe's code.

Why native mods are better than modpe scripts (which are really easier to be made)?

ModPE has only about 60 functions whereas native mods have access to all mcpe's functions (about 12000).

Looks neat and easy? so no it's the right time to show you the low point of native mods

Now, although there are over 12,000 functions that are in MCPE, not all of them can be modded. There are a few factors that prevent some functions from being modded:

  • Some functions have names that are too short: Substrate actually has, for whatever reason, trouble hooking functions that have short names, though not many have this issue. This can sometimes be worked around by direct vtable replacement.

  • Some functions are weak: Now what exactly this means I don't know, but if a function seen has the word WEAK next to its name, it cannot be normally hooked, though there is a way around this.

  • Some functions have stripped symbols: Some functions that the game uses have stripped symbols. This means that the modders can't identify the function, because its name will simple read sub_xxxxxx. These functions can still be hooked, but it takes a bit of work to identify them.

  • Some functions are inlined: This is the worst whammy of all. Mojang compiles the game with certain flags that will cause alot of functions to be inlined, which means that the function will be deleted completely, and all of its code is added in place of each of its calls. This is a limitation that is impossible to reverse and hard to workaround.

Before you start...

It's the right time for a setup:
I'd prefer to use a PC for modding, but if you want, you can use an android device.

For PCs you will need:
- IDA Evaluation Version (link here)
- Apache Ant, Android Studio or Eclipse (I'd prefer to use Android Studio)
- The android SDK and NDK
- An emulator (or a device for testing)
- MCPE's apk
- Patience

For Android devices:
- AIDE (link here)
- A disassembly of libminecraftpe.so prepared on your pc
- MCPE's apk
- Patience

1 comment:

  1. It seems that it is quite difficult to use Android Studio with this. Would be best if you explain that part (since Eclipse ADT is not much supported now).

    ReplyDelete