Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


reducing CheatEngine standalone trainer size.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Source
View previous topic :: View next topic  
Author Message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Nov 03, 2013 7:31 pm    Post subject: reducing CheatEngine standalone trainer size. Reply with quote

I have few problems when uploading "big" files (over few MB). Because I have WiFi 5GHz and about 14km to Access Point, plus bad weather (rain, snow).

What I and DB already made:
- http://forum.cheatengine.org/viewtopic.php?t=560886
- https://code.google.com/p/cheat-engine/source/browse/trunk/Cheat+Engine/custombase85.pas

That was first step... Files added to CheatTable are stored more efficiently.
(extra files are 37% smaller inside CT, and 10% smaller inside CETRAINER and EXE)




Now I want to create something similar to standalone from Cheat Engine v.5 (generated trainer uses stripped version of CheatEngine.exe).
That is, I want cheatengine-i386.exe (v6.x) with absolute minimum, but still with Lua, D3DHook, etc.

Currently, cheatengine-i386.exe rev.2198 compiled with lazarus-1.0.10-fpc-2.6.2-win32.exe has 6.60 MB

Generated empty trainer has:
Code:

compression preset |    EXE     |  7zipped EXE
-------------------|-----------------------------
       none        |  8.33MB    |    2.08MB
-------------------|-----------------------------
     fastest       |  3.86MB    |    3.65MB
-------------------|-----------------------------
     default       |  3.54MB    |    3.33MB
-------------------|-----------------------------
     maximum       |  3.53MB    |    3.32MB

As we see, the best option for now is to choose compression preset "none" and then compress final EXE with 7zip
Second option is: compression preset "default" or "maximum" and then compress final EXE with 7zip
Third option is: compression preset "default" or "maximum" and just upload EXE file

1.   2.080 MB  (none    +7z)
2.   3.325 MB  (default +7z)
3.   3.535 MB  (default)



I cut those units:
SynEdit, SynEditSearch, SynGutterBase, SynEditMarks, SynHighlighterCpp,
SynHighlighterAA, LuaSyntax, frmAAEditPrefsUnit, frmLuaEngineUnit

Details here (diff/patch file): http://pastebin.com/B1rv5NX2


Now cheatengine-i386.exe has 5.99MB (0.61MB less)

Generated empty trainer has:
Code:

compression preset |    EXE     |  7zipped EXE
-------------------|-----------------------------
       none        |  7.72MB    |    1.95MB
-------------------|-----------------------------
     fastest       |  3.60MB    |    3.39MB
-------------------|-----------------------------
     default       |  3.31MB    |    3.10MB
-------------------|-----------------------------
     maximum       |  3.30MB    |    3.08MB

The best option is: compression preset "none" and then compress final EXE with 7zip.
Second option is: compression preset "maximum" and then compress final EXE with 7zip
Third option is: compression preset "default" and then compress final EXE with 7zip

1.   1.950 MB   (none    +7z)   (0.130MB less)
2.   3.080 MB   (max     +7z)   (0.245MB less)
3.   3.100 MB   (default +7z)   (0.225MB less)

Initial 0.61MB transforms to 0.13MB Sad


Conclusion
1.   1.950 MB   (cut  +none    +7z)
2.   2.080 MB   (orig +none    +7z)
3.   3.080 MB   (cut  +max     +7z)
4.   3.100 MB   (cut  +default +7z)
5.   3.325 MB   (orig +default +7z)
6.   3.535 MB   (orig +default)


But, I don't like "preset none" because we have big "trainer EXE" (and some people think it is suspicious)
and I don't like "preset maximum" because we have to wait few seconds after double click.

Again:
1.   3.100 MB   (cut  +default+7z)  (which is 0.225MB less)
2.   3.325 MB   (orig +default+7z)
3.   3.535 MB   (orig +default)

Initial 0.61MB transforms to 0.225MB, slightly better.


Request:
Anyone found other "not useful"* units and etc. ? Ideas ?

* - of course for final standalone trainer.



32 bit trainer (CE) uses "win32\dbghelp.dll". Can we, somehow, strip dbghelp.dll size ?




PS: I know about UPX and other packers. It would be better if we reduce size the normal way (by removing "not needed" parts).

_________________
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Mon Nov 04, 2013 5:10 am    Post subject: Reply with quote

TLG may get removed, but you'll be missing the best gaming experience ever

Pointerscan and it's helper units can go as well
Ultimap isn't needed
The whole memorybrowser can go (requires a lot of code changes and only breaks a very tiny amount of lua scripts)
FrmTracer and it's children can go
Stackview
The save code from Tmemoryrecord and opensave.pas can be removed
The form designer can be removed

Honestly though, i myself will keep the focus on tiny trainers. Perhaps adding an option to open the browser to the cheat engine download page if the ce runtime isn't installed

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Nov 04, 2013 6:10 am    Post subject: Reply with quote

TLG ? Now I will try to remove units with regexp.

EDIT:

So, I removed those units (SynEdit):
SynEdit, SynEditSearch, SynGutterBase, SynEditMarks, SynHighlighterCpp,
SynHighlighterAA, LuaSyntax, frmAAEditPrefsUnit, frmLuaEngineUnit,

(regexpr and old regexpr)
frmDisassemblyscanunit, frmStringMapUnit, frmStringPointerScanUnit

(trace, stackview, BreakPoints, pointer)
*trace*, *stack*, *ultimap*, *pointerscan*, *pointerrescan*, rescanhelper

diff

Result:
cheatengine-i386.exe is now 5.65MB (0.95MB smaller), original is 6.60MB.


Previous "cut +default+7z" is 3.10MB (0.225MB smaller)
Now "cut +default+7z" is 2.97MB (0.355MB smaller)

Initial 0.95MB transforms to 0.355MB Confused


Too many Lazarus widgets? I give up for now.

_________________
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Sun Nov 10, 2013 2:22 am    Post subject: Reply with quote

TLG = The Lame Game (Easter Egg in the CE about form.)
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Nov 11, 2013 2:37 pm    Post subject: Reply with quote

@Wiccaan, any toughs about reducing cheatengine binary size?


Anyone know something about this:
http://wiki.freepascal.org/Whole_Program_Optimization
(I used -OWsymbolliveness instead of -OWall, because of Windows)

I tried this on CheatEngine project, but I'm still getting errors, WPO files aren't created.

_________________
Back to top
View user's profile Send private message MSN Messenger
justa_dude
Grandmaster Cheater
Reputation: 23

Joined: 29 Jun 2010
Posts: 891

PostPosted: Mon Nov 11, 2013 3:50 pm    Post subject: Reply with quote

Why even bother? I mean, obviously CE is amazing, but if you insist on distributing trainers instead of tables then why not just write up some proper framework? Coded in ASM, a trainer can be absolutely tiny - tens of KB or less. I have also had fantastic results with C++ and Petr Kobalíček's unbelievably amazing ASMJIT library as well - ASMJIT basically replicates the auto-assembler functionality of CE, including labels and relative addresses, etc. The other value-adds that CE provides for trainers, like LUA scripting, DLL injection, and thread creation, become much less important when your framework is in a robust language like C++ with full API support to begin with.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Nov 11, 2013 3:53 pm    Post subject: Re: reducing CheatEngine standalone trainer size. Reply with quote

Main reason:
mgr.inz.Player wrote:
still with Lua, D3DHook, etc.

_________________
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Mon Nov 11, 2013 4:04 pm    Post subject: Reply with quote

The binary of the entire application or just the trainers themselves?

If you are referring to just the trainers themselves I would probably suggest some stuff like:
  • Add checks for needed externals like Lua, music files, etc. and only import needed things.
  • Strip any and all CE code that is not needed inside the trainers themselves. (Which you have started already.)
  • Embedded files can be compressed better with 7zip as you have stated above. (LZMA/LZMA2)


The below examples are using this trainer as reference:
http://forum.cheatengine.org/viewtopic.php?t=543996

ARCHIVE resource can be compressed.
The default ARCHIVE resource is in its "semi-raw" format.

The ARCHIVE is: 8.07 MB (8,466,432 bytes)
When it is 7zip'd it is down to: 2.55 MB (2,674,688 bytes)

DECOMPRESSOR resource can be compressed and packed.
The decompressor resource is just an executable. While the size of it isn't that large, it can be shrunk still.

The default size is: 184 KB (188,416 bytes)
Using UPX on the highest compression it is: 72.0 KB (73,728 bytes)
Using 7zip on the UPX compressed file it is: 60.0 KB (61,440 bytes)

CETRAINER is storing data in a raw format.
The data stored inside the CETARINER itself isn't compressed at all either. Instead the file is just xor'd and then stored in the format of:
- File Name (Size before)
- File Folder (Size before)
- File Data (Size before)

Perhaps 7zip each file being added to the archive instead of just packing their raw format into the file.

xmplayer.exe can be packed and compressed with UPX/7zip as well.

lua5.1-32.dll can be compressed, although packing it may cause issues. But tests can be done to find out if it is an issue.

The biggest issue though is the size of the CE executable packed into the trainer. 6MB is a bit excessive. Perhaps creating a "lite" version of CE with everything not needed stripped out, including all the forms, non-needed objects, non-needed classes/containers and so on to literally create a lite version of CE that just reads the trainer files and exposes the needed part only.

The file is fairly large due to a bunch of things that can be stripped from a lite version to still run the needed trainer files.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Nov 11, 2013 4:15 pm    Post subject: Reply with quote

Not quite. Additional files added to table are always zlib'ed (zstream), then converted to Base85. Even "forms" are compressed and converted to Base85. (zstream, clMax)

CETRAINER is additionally compressed (clMax) and XOR'ed.


I UPX'ed (preset --best) those some time ago (when DB implemented my Base85):
- cheatengine-i386.exe
- lua5.1-32.dll
- standalonephase2.dat
- dbghelp.dll

And then I chose compression level none while creating EXE trainer. Final EXE was about 2.02MB and 7zipped 2.03MB. But, as I wrote earlier, I don't like EXE packers.



I think the problem is Lazarus itself, and used units and packages.

_________________
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Tue Nov 12, 2013 4:24 pm    Post subject: Reply with quote

you might be able to cut it down a little bit more by going to the project inspector and remove the dependencies on IDEIntf (form designer) and SynEdit

Perhaps also codetools, but I think ce needs those for lua

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8517
Location: 127.0.0.1

PostPosted: Tue Nov 12, 2013 6:14 pm    Post subject: Reply with quote

mgr.inz.Player wrote:
Not quite. Additional files added to table are always zlib'ed (zstream), then converted to Base85. Even "forms" are compressed and converted to Base85. (zstream, clMax)

CETRAINER is additionally compressed (clMax) and XOR'ed.


I UPX'ed (preset --best) those some time ago (when DB implemented my Base85):
- cheatengine-i386.exe
- lua5.1-32.dll
- standalonephase2.dat
- dbghelp.dll

And then I chose compression level none while creating EXE trainer. Final EXE was about 2.02MB and 7zipped 2.03MB. But, as I wrote earlier, I don't like EXE packers.



I think the problem is Lazarus itself, and used units and packages.


zlib doesn't compress down as well as 7z can.

As for exe packers, UPX is made specifically to help with size, not protection. I don't see it being a big deal using it especially when its the most well known packer in the world.

The main issue(s) lie in the Cheat Engine.exe itself though. I don't code in or use Delphi/Lazarus at all so I can't help with any suggestions on that outside what I mentioned above.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Source All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites