14. april 2016

[Tutorial] Removing non-official APK version error from Unity 3D Games

 [​IMG]

Have non-official version error? Well, you can remove it from any Unity 3D games except games with protection, such as xigncode.

Requirements:
Be a modder
any .NET Decompiler that supports Reflexil 2.0 add-in (e.g. .NET Reflector, ILSpy, etc.) installed on your computer running Windows OS. I'd recommended .NET Reflector
Basic knowledge of C# and IL
Understanding logcat
CatLog app for Android: Download from Play Store
Terminal app for Android: Download from Play Store
App Backup & Restore app for Android: Download from Play Store
Any APK tool to sign an APK file. I'd recommended APK Easy Tool

Checking errors and finding correct function from Unity in logcat:
You got the version error and you don't know which function is called. Logcat does tell you which function is being called

What is logcat?: The Android logging system provides a mechanism for collecting and viewing system debug output. Logs from various applications and portions of the system are collected in a series of circular buffers, which then can be viewed and filtered by the logcat command. You can use logcat from an ADB shell to view the log messages.


Open the CatLog app, press on menu button (3 dots vertical icon), and tap Record

[​IMG] 

Name the file

[​IMG]

Press the home button to minimize the app and run the game

When the version error appear (see picture on top), tap on GO button to open Play Store.

[​IMG]

This is useful because the logcat collected your actions in your device and you can easly find the errors or warnings in the logcat. Close the game, open CatLog app and stop recording

[​IMG]

The CatLog app will open the saved file for you. Search "Unity" in the search bar. Start from the bottom, scroll up and find something interesting

Aha, this is the link to the Play Store that we opened, scroll up again

[​IMG] 

Now we have found the useful error infomations from Unity. Look at the first line, Error Type is INSTALL_ERROR and the Error pop-up has been called but it might not look useful so let's take a look at the second line. the ReceiveInstallFromWrongLocationError() sounds interesting so we will note it
 [​IMG]

Modding DLL file
Open the app 'App Backup & Restore' on your device, backup the app you want to backup and copy the APK file to your computer. Open an APK file using WinRAR or 7-Zip. Navigate to assets/bin/Data/ and extract/copy the Managed folder to your desktop or somewhere else


Run any .NET Decompile software and open the Assembly-Csharp.dll file. In my example, i will use .NET Reflector

Click on the search button, select Search Member icon and search the function ReceiveInstallFromWrongLocationError

[​IMG]

[​IMG] 

That codes doesn't look interesting.

[​IMG] 

On the right side, right click on the selected function and select Analyze (Ctrl + R)

[​IMG]

Expand "Used By", right click on the InitOnStart() function and select Go To Member

[​IMG]

Look at the code to see if you find something interesting.
Aha, we have found InstalledFromRightLocation. Let's click on it

[​IMG]

This code looks very interesting. You can see it checks the package of the APK and it checks if it is installed from Google Play. As you can see, this function is a boolean which means it can return true or false. Example: If the game was installed from Play Store, it returns true and continue the game. If the game was installed from unknown sources, it returns false and show the version error, so we want to make the game always thinking that the game was installed from Play Store by clearing all codes and return it to true

[​IMG] 

Open Reflexil

[​IMG]

The Reflexil will open. Right click and delete all the instructions.

[​IMG]

Right click and create new OpCode

[​IMG]

input "ret" and select Append

[​IMG]

create new OpCode again, input "ldc.i4.1" and select "Insert before selection"

[​IMG]

That's it, you're done. This is how you return it to true.
False is ldc.i4.0 and true is ldc.i4.1


in C#, the code will look like

return true;

Save the DLL file using Reflexil

 [​IMG]

Open the APK file using WinRAR or 7-Zip, navigate to assets/bin/Data/Managed, and replace the modded Assembly-Csharp.dll file

[​IMG]

Sign the APK using APK tool. Copy the signed APK to your device and install it.

That's all, now you can play modded version of the game

[​IMG]

Credit:

iAndroHacker

0 kommentarer:

Send en kommentar