Page 1 of 1
Invoke mono function using assembly
Posted: Sat Jun 08, 2024 7:14 am
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)
Re: Invoke mono function using assembly
Posted: Sun Jun 09, 2024 4:27 pm
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)
Re: Invoke mono function using assembly
Posted: Sun Jun 09, 2024 9:57 pm
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
Re: Invoke mono function using assembly
Posted: Mon Jun 10, 2024 1:11 am
by JohnFK
Thanks, much appreciated