|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
saiqw How do I cheat? Reputation: 0
Joined: 12 Sep 2019 Posts: 1
|
Posted: Thu Sep 12, 2019 11:24 am Post subject: Putting a value in xmm register |
|
|
I'm trying to make a code injection so that I replace the value of the xmm1 register with a const value (or maybe later another memory value)
Here is what the original code looks like :
Code: |
...
movss xmm1,[eax+000001A0]
cvtdq2ps xmm0, xmm0
...
|
Here is what my auto assemble code looks like :
Code: |
[ENABLE]
alloc(newmem,2048)
define(var,(float)10.0)
label(returnhere)
label(originalcode)
label(exit)
newmem:
push eax
mov eax, var
originalcode:
movss xmm1,eax
pop eax
exit:
jmp returnhere
...
|
But it doesn't compile and I get this error : "Error in line 13 (movss xmm1, eax): This instruction can't be compiled"
I think I know it doesn't compile because you can't just put the value of eax into a float register, but I don't know how to do it otherwise.
Sorry if the question is dumb, I did my best to research and find an answer myself but without any success
|
|
Back to top |
|
|
Csimbi I post too much Reputation: 94
Joined: 14 Jul 2007 Posts: 3110
|
Posted: Thu Sep 12, 2019 2:03 pm Post subject: |
|
|
movss moves a single from eax to xmm or vice versa.
movd moves a dword and movq moves a quad.
So, you should use movd xmm1, eax
You really ought to read the ASM reference...
But, if you have a hardcoded value, I'd go for:
Code: | push (float)10.0
movss xmm1,[esp]
add esp,4 |
|
|
Back to top |
|
|
saiqw How do I cheat? Reputation: 0
Joined: 12 Sep 2019 Posts: 1
|
Posted: Thu Sep 12, 2019 6:10 pm Post subject: |
|
|
Thanks for the answer, now i'm trying to convert an integer memory value to a float and store it to xmm1 but it's not quite working
When I do :
Code: | push (float)100
movss xmm1,[esp] |
This is what xmm1 looks like Code: | xmm1:100.00 _ 0.00 _ 0.00 _ 0.00 |
But when I try this :
Code: | cvtsi2sd xmm1, [[game.exe+some_address]+some_offset] |
I get this : Code: | xmm1:0.00 _ 1.88 _ 0.00 _ 0.00 |
What I want to do is take the integer part of that memory value and convert it to a float and store it to xmm1[/code]
|
|
Back to top |
|
|
Csimbi I post too much Reputation: 94
Joined: 14 Jul 2007 Posts: 3110
|
Posted: Fri Sep 13, 2019 12:39 am Post subject: |
|
|
saiqw wrote: |
When I do :
Code: | push (float)100
movss xmm1,[esp] |
This is what xmm1 looks like Code: | xmm1:100.00 _ 0.00 _ 0.00 _ 0.00 |
|
That is correct because the XMM registers are 128bit wide.
When you load a float, that's what it looks like, just ignore those zeroes.
cvtsi2sd converts to double.
Again, you need to read the instruction reference.
Why do you insist on using XMM registers though?
If you want to convert dword to float and back, the easiest I found was using the integer load/store instructions through the FPU.
For example:
Code: | push eax // assume we have 100 in it
fild dword ptr [esp] // we load an int to FPU
push (float)0.1 // Store some dummy
fmul dword ptr [esp] // we multiply with a float
add esp,4 // Throw away dummy
fistp dword ptr [esp] // we store the result as int
pop eax // Replace eax with the result: eax will now be 10 |
|
|
Back to top |
|
|
|
|
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
|
|