Building CESERVER from source code for android emulator device

This tutorial is for Windows OS (to build from). This is just to give you general information how to build for yourself.

A section for guides, manuals, and walkthroughs on how to use Cheat Engine functions and advanced features.


Post Reply
User avatar
J1327
Donor
Donor
Novice Hacker
Novice Hacker
Posts: 34
Joined: Mon Jul 25, 2022 5:00 pm
Answers: 0
Location: Baltic States
x 43

Building CESERVER from source code for android emulator device

Post by J1327 »

Building CESERVER from source code for android emulator device

Initially my workspace is powered by x64 intel and windows os across multiple machines (not virtual) and this tutorial will be around windows os and targeting x86_64 virtual android 9 (nox).
(…)

Chapters:

CESERVER -- INTRO
CESERVER -- VERSION
CESERVER -- BUILD REQUIREMENTS
CESERVER -- DEVICE
NDK -- INSTALL
NDK -- SETUP AND CONFIGURATION
ADB -- SETUP
ECLIPSE -- INSTALL
ECLIPSE -- SETUP
ECLIPSE -- BUILD
CESERVER -- ADDITIONAL PUSH
CESERVER -- LAUNCH
CESERVER -- SPEEDHACK
CESERVER -- DIAGNOSTIC
CESERVER -- DEBUGGING
ECLIPSE – TROUBLESHOOTERS
OUTTAKES

CESERVER: INTRO.

Building manually might not be required since you can download pre-compiled files from official source.
note: that as for prebuilt 7.5 ceserver, "r23c" NDK is used.
https://www.cheatengine.org/downloads.php under header of "Server (For network scanning)"

CESERVER: VERSION. (! IMPORTANT)

Across each version of cheat engine -- (...as for newest cheat engine (at least for 751 GitHub build), cheat engine version can be found in a "about" menu else you can print version from Lua engine..) -- is required to build-/-have ceserver for that cheat engine specific version. I meant like this:

Cheat Engine 7.5 | Cheat Engine 7.4 ceserver plugin <- and that won't work.

So, this must be like,
Cheat Engine 7.5 | Cheat Engine 7.5 ceserver plugin

or
Cheat Engine GitHub latest source code | Cheat Engine GitHub ceserver latest source code

Else ceserver won't work.

CESERVER: BUILD REQUIREMENTS

If you decided you want to build yourself from source code using this tutorial then requirements are
Intel x64Bits, Windows. As well to have network connection and at least 30GB of space. Also, if you are on your account isn’t administrator you need have administrator privileges in order to install, build and run.

So firstly, you also need to have cheat engine from source code in order to work with ceserver.
(As I did mention in CESERVER: VERSION.)
download cheat-engine source from here:
https://github.com/cheat-engine/cheat-engine
to download source code, click code and drop-down menu should appear:
select Download ZIP

note: that mono and ceserver source code (compliable code) is included there.

after download extract folder anywhere, you wish to work from.
example you can extract into your desktop, or you can extract directly into drive C:/
(Example: C:\cheat-engine-master)

Install cheat engine compiling tools aka. Lazarus:
https://sourceforge.net/projects/lazaru ... s%202.2.2/

first download and install Lazarus-...-win64.exe then Lazarus-...-cross...

I recommend keep installation path as it is C:/lazarus.

... After installation open folder: cheat-engine-master >
Cheat Engine and there is file: cheatengine.lpi
Note: if Lazarus installation was successful no errors should be occurred during project “cheatengine.lpi” opening.

... After opening file select sub menu code > build many modes > mark according your needs and hit OK.
If you don’t know – mark at least 32bit, 64bit, 64bit AVX2.

.. After compiling message will pop up saying x modes were successfully compiled.

.. A New cheat engine file was generated at cheat-engine-master > cheat engine > bin > cheatengine-x86_64.exe

Now you are ready to setup NDK!

CESERVER: ANDROID DEVICE.

To have working ceserver, you need have rooted device or emulator.
ceserver recommendations are to have at least minimum android 7 or up.
Emulators usually have their own root applications/methods.

Recommended root options: https://github.com/topjohnwu/Magisk
Note: Rooting device can brick your device unrecoverably, be careful when rooting your device. You are solely responsible for your device.
Note: If you going to root your device, check out for your device model recovery custom rom as well such as TWRP or CWM. So, to speaking, back up your android device.

NDK: INSTALL.

Required tools for ceserver:

NDK-Build (Latest): https://developer.android.com/ndk/downloads
OR
NDK Outdated: https://github.com/android/ndk/wiki/Uns ... -Downloads

note: if you are going to debug ceserver then you should need go with NDK (23) unsupported version (am on 23 version) -- since gdbserver is departed from recent NDK versions.

(…)

NDK: SETUP & CONFIGURATION.

1#
Get NDK-build (links provided above)

2#
Set path to ndk-build

This is how you can set up ndk path:
A. Extract ndk into your local drive if haven’t done that already.
B. After doing so, Open windows explorer
C. right click on my computer ("This PC") and select properties
C-1. In windows 11 should open ms:settings page "About."
D. Click on "Advanced system settings" in "Related links".
D-1. This should open System Properties
E. In System Properties select environment variables...
E-1. Environment Variables should open.
F. Open up Path at "User variables for account_name" and click on "New" in "Edit environment variable" window.
F-1. enter path of extracted ndk folder example: "C:\android-ndk-r23c" or "C:\Users\...\Desktop\android-ndk-r23c" and click OK,
G. Enter ndk folder path in System variables "Path" column also.
G-1. add new entry below system variables -- click "New" in Environment variables.
G-2. enter in Variable name "ndk-build" case sensitive.
G-3. in variable value enter path to android ndk folder but also add "ndk-build.cmd”, so example "C:\android-ndk-r23c\ndk-build.cmd" and click OK.
G-4. Click apply and close System Properties.
H. Restart your machine.
H-1. Check if ndk-path is correctly working by opening terminal and entering "ndk-build". If you get some output, then you have successful set path to ndk. If you get something "not recognized as an internal or external command" path is set incorrectly.

3#
Edit android.mk files in ceserver directory (if you are building for x86_64)
add space and x86_64 (as example)
APP_ABI:= x86 armeabi-v7a arm64-v8a x86_64

Now you are ready to get into eclipse program...

ADB: SETUP.

As you have done environment setup for ndk you can also setup adb/nox_adb to system environment for faster files transfer. This is required if you want to have automated push to emulator device.
(...)

ECLIPSE: INSTALL.

1#
Download from
https://www.eclipse.org/downloads/packa ... developers
2#
Extract there you need.
(...)

ECLIPSE: SETUP.

Open eclipse.
close welcome page :P if haven’t done that.
chose open projects from file system or archive.

in the next windows select folder "\cheat-engine-master\Cheat Engine\MonoDataCollector"

and also do the same for folder "\cheat-engine-master\Cheat Engine\ceserver"

don't get confused and don't select "\cheat-engine-master\Cheat Engine\MonoDataCollector\MonoDataCollector"

and choose cross GCC.
press finish button.
at left side project explorer window should be now populated.

~ Repeatable ~

right click on recently populated MonoDataCollector and press Preferences
search for "tool" which should bring up Tool Chain Editor. Select that.
(If you are missing this option, try closing eclipse and opening again project.)
In that preferences tab you should see configuration default [Active] in order to change architecture for monodatacollector click on manage configurations...

Select according to your needs. set to active. Example press active button on android-x86_64 and so press OK.
in same tool chain editor for monodatacollector select recently clicked to active configuration, in this example android-x86_64 [Active]

Select Cross GCC over CDT Internal Builder and click apply.

Now go to C/C++ ->
and select Internal builder.

Now go to C/C++ -> Settings:
Cross Settings:
"C:\android-ndk-r23c\toolchains\llvm\prebuilt\windows-x86_64\bin" -- path to subfolder from ndk folder. Select inside prebuilt folder architecture folder to your needs.
Apply
An rebuild index prompt will show up click OK.

Another crucial step: Open c/c++ > Settings
Select Build Steps and edit:
from
cp ${BuildA...
to
cmd.exe /c move ${BuildArtifactFilePrefix}${BuildArtifactFileName} "${WorkspaceDirPath}/${BuildArtifactFilePrefix}${BuildArtifactFileName} "

and press apply and close.

~ end of configuration ~

Repeat these steps for ceserver and for ceserver-extension.

ECLIPSE: BUILD.

press tool icon to build, a new .so mono lib file should appear in your new workspace directory.
now you can move new .so and without extension files into android device
else if you have environments set -- files should be directly pushed there (if emulator is running) ...
(…)

CESERVER: ADDITIONAL PUSH

In order to work you need also have these files on targeted device (example as for x86_64):
you can find these files in NDK folder:
libc++
shared.so,
Push an copy of file into
/data/ceserver
/lib/
/system/lib64/
(...)

CESERVER: LAUNCH.

This depends on there you placed ceserver in emulator and .so libraries...
example if you placed in /data/ceserver

also, you need to do chmod on new written files inside emulator which allows read/write/execute (777)7)

In order to launch ceserver, you need to forward port first in order to launch ceserver (when emulator is running) open CMD/Terminal:

nox_adb forward tcp:52736 tcp:52736

and then

nox_adb shell

su

/data/ceserver/ceserver_x86_64

this command will launch ceserver. While ceserver is running you can try to open emulator app and then try to attach with Cheat engine.
To connect to ceserver from cheat engine, do via process list -> Network -> localhost 52736 -> Android emulator processes should appear in cheat engine’s process list (…)

(...)

CESERVER: SPEEDHACK

Ceserver has component (extension) called "ceserver-extension" which is (essential in order ceserver to work) responsible for speed control also known as speed hack. If extension fails to load -- output would be something like this:
OpenPipe("ceserver_extension123894")trying to connect to ceserver_extension123894
connect returned -1
it means -- speed hack for targeted platform-process won't work …
(...)

CESERVER: DIAGNOSTIC.

In order to have better log output from ceserver (trace) is recommended to use logcat/syslog. It can provide important information why and what fails in more detailed way.

This is what am using:

nox_adb logcat | grep -iE "CESERVER|MonoDataCollector|CESERVER_EXTENSION"

With this command will be only displayed ceserver output only.

(...)

CESERVER: DEBUGGING.

You can also debug, ceserver with gdbserver which requires opening/forwarding addition ports, configurating eclipse (setting gdbserver settings in eclipse to manual TCP connection) and moving some additional files into targeted device (which also exist in android-ndk 23).
Or as alternative to eclipse you can try to launch gdbserver directly from Console/PowerShell.
Example in how to launch (alternatively) gdbserver:
Nox_adb shell
SU
/data/ceserver/gdbserver :2345 /data/ceserver/ceserver_x86_64
(...)

ECLIPSE: TROUBLESHOOTERS.

If builders empty and you installed eclipse C/C++ -- if that happens then there is misconfiguration going on, try restarting eclipse.

if you are missing internal builder option -- delete current monodatacollector and import again from cheat-engine-master zip monodatacollector and try again loading folder (also restart eclipse but not PC)
Note: indication that project successfully loaded is when you go to project properties and select tool chain editor at configuration should appear dropdown list with android-x86, android-x86-64 and so on...

Info: Nothing to build for MonoDataCollector. (Clean project. Note as default eclipse will try clean with command rm which by default on windows doesn't exist -- you have either two options: clean manually yourself or edit cprojects file) (…)

OUTTAKES.

Rundown on Cross GCC:
Cross GCC/android-NDK is all you need, and you don't need to install any components like cygwin64 -- I tried installing cygwin64 but just wasted my time debugging installation problems (incompatibility). As default or at least for that latest cygwin64 build comes with installation incompatibilities. Which makes problems when using cygwin64 libraries such as "make" to compile things...

How can I get *.apk files from google play store?
Install application from google play store and then get *.apk file from 3rd application which can save from application into *.apk file...

another approach is to use online services:
https://apkcombo.com/downloader/
note: this service doesn’t allow direct *.apk downloads from paid apps.

As for paid applications. There is another online service which allows download apks from google play store if you own application (you must connect your google account with their service in order to download). Yet I currently don't recall website URI.

🙃
Ṯ̸͋͠H̷̻́Ē̵̦̇R̴̛̠̞̾E̷̥̗̎̾ ̷̩̽̂Ì̵̱S̵̲͘ ̷̝̝̽͆S̵̯̒T̷̩͈̃͑Î̶̯̟Ļ̴̬̈L̴̘̱̏̒ ̵̨̟̈́͠T̵͓͎͐I̶̥͈̽M̷̡̛͒E̶͙͗


Post Reply