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 


Request: Mono Compiler

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
jgoemat
Master Cheater
Reputation: 23

Joined: 25 Sep 2011
Posts: 264

PostPosted: Tue Jan 21, 2025 10:29 pm    Post subject: Request: Mono Compiler Reply with quote

I just found the method `mono_loadAssemblyFromFile` which is awesome. I was able to create a Visual Studio project, reference the game files, and write some code interacting with the game code and call it from a table. I created the wiki page showing usage:

https://wiki.cheatengine.org/index.php?title=Mono:Lua:mono_loadAssemblyFromFile

Something that would be next level awesome would be a method like `mono_compileCSharp(assemblyName, cSharpCode)` that would let you build an assembly from a table and load it into the game without external tools. Not sure how hard that would be, roslyn is open source, though most of what I find searching is for syntax stuff and not actually building an assembly. Something that would do that automatically along with referencing the loaded assemblies from the process automatically would be so cool...
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4690

PostPosted: Wed Jan 22, 2025 1:02 am    Post subject: This post has 1 review(s) Reply with quote

celua.txt:
Quote:
compileCS(text, {references}, coreAssembly OPTIONAL) - Compiles c# code and returns the autogenerated filename. references is a list of c# assemblies this code may reference. This file will be deleted when CE closes (or next time another CE closes and it's not in use anymore). Note: This requires .NET 4 to be installed, even if the target is mono. Tip: Handy with injectDotNetDLL

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Wed Jan 22, 2025 5:16 am    Post subject: Reply with quote

dotnetpatch_getAllReferences() returns a table with all references, and a assembly it thinks might be the one.
_________________
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
jgoemat
Master Cheater
Reputation: 23

Joined: 25 Sep 2011
Posts: 264

PostPosted: Wed Jan 22, 2025 9:57 pm    Post subject: Reply with quote

When the hell was that added and why didn't I know about it? Laughing I figured something like that would be in monoscript.lua Embarassed

Just tried it out and it works like a charm! Many thanks! Here's a snippet from an AA script:



Code:
{$lua}
if syntaxcheck then return end

local references, core = dotnetpatch_getAllReferences()

local code = [[namespace MyGuild
{
    public static class CraftingWindowExtensions
    {
        public static void CheckCraftable(this CraftingWindowUI ui)
        {
            ui.CraftButton.interactable = true;
            ui.CraftPrompt.UpdateUI();
        }
    }
}
]]

local assemblyPath = compileCS(code, references, core)
mono_loadAssemblyFromFile(assemblyPath)
{$asm}
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Thu Jan 23, 2025 5:42 am    Post subject: Reply with quote

tip, in .netinfo rightclick on the method of a class and choose "generate patch template for method"


it's not perfect and more of a proof of concept, but you may like it

_________________
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
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3320

PostPosted: Thu Jan 23, 2025 6:04 am    Post subject: Reply with quote

Wut? News to me, too.
Good news.
When I said good, I meant awesome.
Is this in the wiki somewhere with possibly samples how to correctly replace/extend existing code?

Does it work with IL2CPP?
I'd assume not.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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