Invoke mono function using assembly

Memory scanning, code injection, debugger internals and other gamemodding related discussion
Post Reply
JohnFK
Expert Cheater
Expert Cheater
Posts: 58
Joined: Tue Aug 29, 2017 10:50 am
Reputation: 24

Invoke mono function using assembly

Post by JohnFK »

How can I invoke a static mono function (no parameters) with using only assembly? I've tried the following but it crashes the game (the function is already jitted btw).

Code: Select all

alloc(bla,1024)

bla:
sub rsp,28
mov r11,IngameDebugMenu:Show
call r11
add rsp,28
ret

createthread(bla)

Bloodybone
Table Makers
Table Makers
Posts: 291
Joined: Thu Aug 03, 2017 6:19 am
Reputation: 141

Re: Invoke mono function using assembly

Post by Bloodybone »

Code: Select all

alloc(bla,1024)

bla:
sub rsp,28
call mono_get_root_domain
mov rcx,rax
call mono_thread_attach
mov r11,IngameDebugMenu:Show
call r11
call mono_thread_get
mov rcx,rax
call mono_thread_detach
add rsp,28
ret

createthread(bla)

User avatar
Metanoia
Cheater
Cheater
Posts: 33
Joined: Thu Mar 07, 2024 7:16 pm
Reputation: 29

Re: Invoke mono function using assembly

Post by Metanoia »

Bloodybone wrote:
Sun Jun 09, 2024 4:27 pm

Code: Select all

alloc(bla,1024)

bla:
sub rsp,28
call mono_get_root_domain
mov rcx,rax
call mono_thread_attach
mov r11,IngameDebugMenu:Show
call r11
call mono_thread_get
mov rcx,rax
call mono_thread_detach
add rsp,28
ret

createthread(bla)


Why call mono_thread_Get just do this

Code: Select all

sub rsp,28
call mono_get_root_domain
mov rcx,rax
call mono_thread_attach
mov rsi,rax

...

mov rcx,rsi
call mono_thread_detach
add rsp,28
ret
or

For IL2CPP games use this

Code: Select all

sub rsp,28
call il2cpp_domain_get
mov rcx,rax
call il2cpp_thread_attach
mov rsi,rax

...

mov rcx,rsi
call il2cpp_thread_detach 
add rsp,28
ret

JohnFK
Expert Cheater
Expert Cheater
Posts: 58
Joined: Tue Aug 29, 2017 10:50 am
Reputation: 24

Re: Invoke mono function using assembly

Post by JohnFK »

Thanks, much appreciated

Post Reply

Who is online

Users browsing this forum: No registered users