Vlad-00003 Cheater Reputation: 0
Joined: 21 Jul 2015 Posts: 36
|
Posted: Sat Aug 12, 2017 10:21 am Post subject: Strange behavoiur of the Mono function |
|
|
Hello everybody!
I'm trying to allow user to adjust Light range and intensity of tourch, but there is somwthing strange going on....
The game I'm currently working on is using mono(UnityEngine espesially) and I'm using CE mono feature to make my table.
So, here is how the game looks like:
Code: |
SomeInGameFunc+3d0 - F2 0F10 45 E0 - movsd xmm0,[rbp-20]
SomeInGameFunc+3d5 - F2 0F10 4D D8 - movsd xmm1,[rbp-28]
SomeInGameFunc+3da - F2 0F59 C1 - mulsd xmm0,xmm1
SomeInGameFunc+3de - 48 8B CF - mov rcx,rdi
SomeInGameFunc+3e1 - F2 0F10 C8 - movsd xmm1,xmm0
SomeInGameFunc+3e5 - F2 0F5A C9 - cvtsd2ss xmm1,xmm1
SomeInGameFunc+3e9 - 48 83 EC 20 - sub rsp,20
SomeInGameFunc+3ed - 83 3F 00 - cmp dword ptr [rdi],00
SomeInGameFunc+3f0 - 49 BB C09F3C1C00000000 - mov r11,UnityEngine:Light:set_intensity
SomeInGameFunc+3fa - 41 FF D3 - call r11
SomeInGameFunc+3fd - 48 83 C4 20 - add rsp,20
|
So, what I'm trying to do is simple - create 2 allocs with the range and intensity and call required function:
Code: |
define(BurnDur,SomeInGameFunc)
[ENABLE]
assert(BurnDur+3e9,48 83 EC 20 83 3F 00)
alloc(_Light,2048)
alloc(_LightRange,4)
alloc(_LightIntensity,4)
alloc(_uLight,4)
label(LightIntensRet)
registersymbol(_LightIntensity)
registersymbol(_LightRange)
registersymbol(_uLight)
_uLight:
//dd "UnityEngine:Light:set_intensity" // <- This one doesn't needed - I'm injecting my code right before it being called
dd "UnityEngine:Light:set_range"//jit set range address
_LightIntensity:
dd (float)0.3
_LightRange:
dd (float)35
_Light:
movss xmm1, [_LightRange] //Store range in XMM1
sub rsp,20
cmp dword ptr [rdi],00
mov r11,[_uLight]
call r11 //Caling function
add rsp, 20
movss xmm1, [_LightIntensity] //Store intensity
sub rsp,20
cmp dword ptr [rdi],00
jmp LightIntensRet //Calling function doesn't needed - it would be called after the ret
BurnDur+3e9:
jmp _Light
nop
nop
LightIntensRet:
[DISABLE]
BurnDur+3e9:
db 48 83 EC 20 83 3F 00
unregistersymbol(_LightIntensity)
unregistersymbol(_LightRange)
unregistersymbol(_uLight)
dealloc(_uLight)
dealloc(_LightRange)
dealloc(_LightIntensity)
dealloc(_Light) |
And as I think it should work - I'm calling one function, then changing xmm1 again and calling another.... but it doesn't.
I have actually no idea.
The code above works 50\50 - it only sets the range of the light. Intensity doesn't work at all.
I've checked in disassembler - xmm1 being changed.
But for some reason changing _LightIntensity does nothing. at all.
If I comment this Code: | movss xmm1, [_LightRange] //Store range in XMM1
sub rsp,20
cmp dword ptr [rdi],00
mov r11,[_uLight]
call r11 //Caling function
add rsp, 20 |
Intensity works..... Can anyone help me figure out why?
|
|