Asm call to mono-address

M

miraikolus

Cheater
Joined
Jan 4, 2019
Messages
47
Now, I believe the following (simplified) should work, but is there anything better? celua and web didn't show anything but who knows .. some combination ..
Code:
label(jitAddress)
registersymbol(jitAddress)
Jump:To:Address: //thanks to mono features
jitAddress:

newmem:
mov r11,[jitAddress]
call r11
Btw, can any1 explain me the purpose of the following (debugging only?):
Code:
lea rax,[rax+rcx*8+20]
mov rax, [rax]
 
TheyCallMeTim13

TheyCallMeTim13

Enchanter
Staff member
Administrator
Fearless Donors
Talents
Joined
Mar 3, 2017
Messages
1,794
Googled "ce mono lua", which lead to Mono - Lua Functions, and there listed is Mono:Lua:mono invoke method. So not really sure what you're trying to do it that wasn't it.

As for the ASM, it's using LEA (load effective address) to set RAX to the address, then moving the value at that address to RAX.
mov rax,[rax+rcx*8+20] is the same thing and would be faster.
 
M

miraikolus

Cheater
Joined
Jan 4, 2019
Messages
47
What I do want to do is easy, call a function I do know does what i want (on above code - of course i'd do checks & co, set parameters before, thus "simplified"). Now in LUA, there are few methods to resolve, at last i'll prob need registerSymbol while addr. needs to be conv. to int.
But I am act. looking for a more simple instruction in code, i mean both options do get executed before actual asm, but above will require less.

Yeah, I do know what lea does. I just don't get why unity does that ... is there some debug=0 val/cons not set or ....? (yeah this question is something different and requires some ... history with unity compil. & asm.
 
TheyCallMeTim13

TheyCallMeTim13

Enchanter
Staff member
Administrator
Fearless Donors
Talents
Joined
Mar 3, 2017
Messages
1,794
miraikolus said:
What I do want to do is easy, call a function I do know does what i want (on above code - of course i'd do checks & co, set parameters before, thus "simplified"). Now in LUA, there are few methods to resolve, at last i'll prob need registerSymbol while addr. needs to be conv. to int.
But I am act. looking for a more simple instruction in code, i mean both options do get executed before actual asm, but above will require less.
...
I don't know if it's a language barrier or what. But that was painful to try and read, and after three tries I still don't understand what you're trying to say here.

As far as getting the address of a symbol just use getAddress or getAddressSafe.
miraikolus said:
...

Yeah, I do know what lea does. I just don't get why unity does that ...
Probably just something the compiler does.
miraikolus said:
... is there some debug=0 val/cons not set or ....? (yeah this question is something different and requires some ... history with unity compil. & asm.
Maybe but I have no idea, not really knowledgeable with the Unity Engine. But it might be defined and used in a way that the code that uses it is only compiled in a development version, thus it wouldn't even be in the release version; which would make for better optimization of the game at release. But again, not really sure.
 
P

panraven

Cheater
Table Maker
Joined
Mar 3, 2017
Messages
45
You can enclose the symbolic address with double quote to force interpret the content as address,
it should work in general not just mono.
call "Jump:To:Address"
--
the memory addressing like [rax+rcx*8+20] may be a form to access an item in an array type.
For instance, it is the item with size 8 (so *8) base zero index rcx whose 1st element is in address rax+20.
For mono, usually the array length may be locate -8 offset from its 1st element, eg. rax+18 .
But it should be read in context with up and down codes.

Lea may also to do simple constant multiply on registers, usually several Lea run together.
 
M

miraikolus

Cheater
Joined
Jan 4, 2019
Messages
47
But it might be defined and used in a way that the code that uses it is only compiled in a development version, thus it wouldn't even be in the release version; which would make for better optimization of the game at release. But again, not really sure.
That's what i mean, it is a released game. So I do wonder why. May they just forgot to disable those dev flags. But any way, that was just my curiosity.
panraven said:
call "Jump:To:Address"
.... right clear. I never had to use that for unity up to now. But it's clear that this is an option. Thanks, that's what I did need.

As for the other options - thanks for the note. But I do know generally and in that game exactly what each of the registers stand for and instructions do. It was just as written to TheyCallMeTim13, that I don't know why the extra effort. Yeah, sometimes you want to get the addr ... mostly to store in some other memory addr . But storing in a register, next you do store the pointed addr into same register is .....
Any way, those explanations might do help others.
 
Top