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 


Help with Mono and Lua?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Voidage
Newbie cheater
Reputation: 0

Joined: 29 Aug 2018
Posts: 15

PostPosted: Wed Aug 29, 2018 7:18 pm    Post subject: Help with Mono and Lua? Reply with quote

I am trying to simply find a method (achieved) and then invoke it.

Invoking it with the gui is easy but.. I cannot figure out how to with lua script.

_________________
Wassup
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Wed Aug 29, 2018 10:33 pm    Post subject: Reply with quote

mono_invoke_method. (check out monoscipt.lua in ce's autorun folder)

give it a domain (or nil), the method identifier, and the address of an object. And if it takes parameters a lua array table containing entries which are lua tables containing type and value

also check out http://fearlessrevolution.com/viewtopic.php?t=7391

_________________
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
Voidage
Newbie cheater
Reputation: 0

Joined: 29 Aug 2018
Posts: 15

PostPosted: Thu Aug 30, 2018 5:53 am    Post subject: Reply with quote

Thanks for the reply. I am confused on the
Code:

local domain = mono_enumDomains()[1]


It errors on this part.

_________________
Wassup
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Aug 30, 2018 10:58 am    Post subject: Reply with quote

have the mono features been activated yet?
and what is the error?

(and domain can have the value 0)

_________________
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
Voidage
Newbie cheater
Reputation: 0

Joined: 29 Aug 2018
Posts: 15

PostPosted: Thu Aug 30, 2018 1:12 pm    Post subject: Reply with quote

Yes mono is activated. Okay so here is what the mono looks like. And changing the 1 to 0 in the domain fixed the error.

4346e70
-> Assembly-CSharp
-> Health_Manager
-> methods
-> AddHealth(int amount)

here is the script I made

local hm = mono_findClass('', 'Health_Manager')
local addhealth = mono_class_findMethod(hm, 'AddHealth')
local paddress = 0x0F55E5E8
local domain = mono_enumDomains()[0]
mono_invoke_method(domain, addhealth, paddress, {type="int", value=55})

It does not work, but it does not give an error either.

_________________
Wassup
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Aug 30, 2018 1:32 pm    Post subject: Reply with quote

try domain=0 or mono_enumDomains()[1]

have you confirmed that hm and addhealth are not nil ?

and paddress is the correct address ? (just asking since it doesn't happen that often that i see a valid one ending in 8, but it's possible it's valid)

what is the return value of mono_invoke_method?

Also, the args type is not valid, try vtDword

_________________
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
Voidage
Newbie cheater
Reputation: 0

Joined: 29 Aug 2018
Posts: 15

PostPosted: Thu Aug 30, 2018 1:53 pm    Post subject: Reply with quote

Dark Byte wrote:
try domain=0 or mono_enumDomains()[1]

have you confirmed that hm and addhealth are not nil ?

and paddress is the correct address ? (just asking since it doesn't happen that often that i see a valid one ending in 8, but it's possible it's valid)

what is the return value of mono_invoke_method?

Also, the args type is not valid, try vtDword


Okay, I will try that. And yes it is correct, I can use the CE gui to invoke it, and it works fine.

Update:
I made some adjustments to the script:
--
local hm = mono_findClass('', 'Health_Manager')
print("CLASS: ", hm);
local addhealth = mono_class_findMethod(hm, 'AddHealth')
print("METHOD: " , addhealth);
local paddress = 0x12516AF0
local domain = mono_enumDomains()[1]
local inv = mono_invoke_method(domain, addhealth, paddress, {type="vtDword ", value=55})
print("INVOKE RETURN: ", inv)
--
Output:
CLASS: 290064216
METHOD: 290064760
INVOKE RETURN:
--

I tried putting domain to 0 like you said, but that made no difference.

_________________
Wassup
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Aug 30, 2018 2:01 pm    Post subject: Reply with quote

type is an integer. so type=vtDword
_________________
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
Voidage
Newbie cheater
Reputation: 0

Joined: 29 Aug 2018
Posts: 15

PostPosted: Thu Aug 30, 2018 2:02 pm    Post subject: Reply with quote

Okay. Here is the new script.

--
local hm = mono_findClass('', 'Health_Manager')
print("CLASS: ", hm);
local addhealth = mono_class_findMethod(hm, 'AddHealth')
print("METHOD: " , addhealth);
local paddress = 0x12516AF0
local domain = mono_enumDomains()[1]
local inv = mono_invoke_method(domain, addhealth, paddress, {type=vtDword, value=55})
print("INVOKE RETURN: ", inv)
--

The output is the same as above.

_________________
Wassup
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Aug 30, 2018 2:12 pm    Post subject: Reply with quote

try
Code:

local inv = mono_invoke_method(domain, addhealth, paddress, {{type=vtDword, value=55}})

_________________
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
Voidage
Newbie cheater
Reputation: 0

Joined: 29 Aug 2018
Posts: 15

PostPosted: Thu Aug 30, 2018 2:20 pm    Post subject: Reply with quote

Thank you, it worked. Now I need to figure out how to get a static mono address. I guess it works the same as a normal address, just do pointer scan and reopen the game
_________________
Wassup
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Aug 30, 2018 2:38 pm    Post subject: Reply with quote

you can use
Code:

mono_class_findInstancesOfClassListOnly(domain,class)

it will return a list of objects that resemble the object you're interested in

In case of multiple do some checks so see if it's actually what you are looking for (e.g used pointers filled in, proper values everywhere, etc...)

_________________
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
Voidage
Newbie cheater
Reputation: 0

Joined: 29 Aug 2018
Posts: 15

PostPosted: Thu Aug 30, 2018 2:53 pm    Post subject: Reply with quote

Thank you!!

Also, I know that what I am about to ask isn't SUPER related, but kinda? What I've been trying to do with this the whole time is create an unofficial "modding" support for a game. Even the developer of this game is encouraging me to do my best! Here is what I have so far.

Code:

local Classes = {
      Health_Manager = mono_findClass('', 'Health_Manager');
};

local Methods = {
      AddHealth = mono_class_findMethod(Classes.Health_Manager, 'AddHealth')
};

local Addresses = {
      Health_Manager = 0x12C56B98;
};

local domain = mono_enumDomains()[1];

local API = {};
function API:AddHealth(Amount)
    inv = mono_invoke_method(domain, Methods.AddHealth, Addresses.Health_Manager, {{type=vtDword, value=Amount}})
end

API:AddHealth(500);

--local hm = mono_findClass('', 'Health_Manager')
--local addhealth = mono_class_findMethod(hm, 'AddHealth')
--local paddress = 0x12C56B98
--local domain = mono_enumDomains()[1]
--inv = mono_invoke_method(domain, addhealth, paddress, {{type=vtDword, value=55}})


As you can see, very basic so far. So, my question is, is there any way to make it so people can easily add their own scripts, and have CE execute them at run time, or whenever it hooks onto the process? That is my goal, and that would be awesome!

I was thinking have a folder named scripts, and CE goes through and runs each script. I have really no idea if this is possible or not.

_________________
Wassup
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Thu Aug 30, 2018 3:04 pm    Post subject: Reply with quote

You could use "getDirectoryList" and "getFileList" then use Lua's "dofile" (or "require") to execute a lua file in CE.

Form "celua.txt":
Code:

getFileList(Path:string, searchMask:string OPTIONAL, SearchSubDirs: boolean OPTIONAL, DirAttrib: integer OPTIONAL): Returns an indexed table with filenames
getDirectoryList(Path:string, SearchSubDirs: boolean OPTIONAL): Returns an indexed table with directory names

_________________
Back to top
View user's profile Send private message Visit poster's website
Voidage
Newbie cheater
Reputation: 0

Joined: 29 Aug 2018
Posts: 15

PostPosted: Thu Aug 30, 2018 3:08 pm    Post subject: Reply with quote

TheyCallMeTim13 wrote:
You could use "getDirectoryList" and "getFileList" then use Lua's "dofile" (or "require") to execute a lua file in CE.

Form "celua.txt":
Code:

getFileList(Path:string, searchMask:string OPTIONAL, SearchSubDirs: boolean OPTIONAL, DirAttrib: integer OPTIONAL): Returns an indexed table with filenames
getDirectoryList(Path:string, SearchSubDirs: boolean OPTIONAL): Returns an indexed table with directory names


How would I get the directory of the game? Ik the ACTUAL directory on my pc, but it is different for every person.

_________________
Wassup
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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