Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Double value to memory in 32-bit games

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
sandsmaster
Newbie cheater
Reputation: 1

Joined: 21 Jan 2021
Posts: 24

PostPosted: Mon May 31, 2021 4:17 pm    Post subject: Double value to memory in 32-bit games Reply with quote

Hi everyone!


I want to know, how can I save a double value from a pointer to some allocated memory. I want to register symbol. The game I'm trying to hack today is "Cat Goes Fishing" and it's a very complex game to write scripts in.

The most interesting thing about it is, that it's a 32-bit game, but uses only double somehow.
What's more, all the values in the game go through 2-3 instructions and even when I break and trace them with start condition, I still don't get to anything useful. ( Best result of noping a call was to freeze the game ). The last branch leads to a ton of
Code:
repe movsd


But it's not a really big game and probably won't recieve much updates soon, so I decided to use pointers. Luckily pointers work like a charm for a table, but I want to make them into a script.

So I searched about how to use pointers in Assembler and wrote this code:
Code:

[ENABLE]
alloc(newmem,$100)
label(cash)
registersymbol(cash)

newmem:

push eax
mov eax,["Cat Goes Fishing.exe"+0043F104]
mov eax,[eax+39C]
mov eax,[eax+3C]
mov eax,[eax+28]
//mov eax,[eax+210]
add eax,210
mov [cash],eax
pop eax

cash:
 dq 0

[DISABLE]

unregistersymbol(cash)
dealloc(newmem)


So essentially, I'm trying to write to the symbol a double, with the 32-bit register. I tried direct
Code:
mov
, but it didn't work either, so I'm pretty much clueless, overall.

If you can help out again, I'd really appreciate it.



image_2021-06-01_011000.png
 Description:
 Filesize:  21.88 KB
 Viewed:  1474 Time(s)

image_2021-06-01_011000.png



_________________
I don't post too much. yet.
Back to top
View user's profile Send private message Send e-mail
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Mon May 31, 2021 5:04 pm    Post subject: Reply with quote

To move a qword (8 bytes) in 32 bit you have a few options.

The easiest would be to just do it in chunks.
Code:
push eax
mov  eax,[addr]
mov [symbol],eax
mov  eax,[addr+4]
mov [symbol+4],eax
pop eax


But you could also use the FPU registry.
Code:

fld qword ptr [addr]
fstp qword ptr [symbol]


Or you can use the XMM registries. But you might have to save and restore the registry if it gets used latter.
Code:

movq xmm0,[addr]
movq [symbol],xmm0

_________________
Back to top
View user's profile Send private message Visit poster's website
sandsmaster
Newbie cheater
Reputation: 1

Joined: 21 Jan 2021
Posts: 24

PostPosted: Tue Jun 01, 2021 5:01 am    Post subject: Reply with quote

Thanks a lot man.

I went for using the FPU registry and it works great.

Weird thing is, when I debug the cheat, I don't see the value in the FPU stack,
but it works. I'd be happy to know, if you know how to set it precisely.

Btw here is the new code:

Code:
[ENABLE]
aobscanmodule(INJECTCash,Cat Goes Fishing.exe,83 C4 10 8B C8 89 4D E4) // should be unique
alloc(newmem,$100)

label(cash)
label(return)
label(code)
label(cash_flag)
registersymbol(cash)
registersymbol(cash_flag)

newmem:

code:
  add esp,10
  mov ecx,eax
  cmp [cash_flag],#1
  jne return
  push eax
  mov eax,["Cat Goes Fishing.exe"+0043F104]
  mov eax,[eax+39C]
  mov eax,[eax+3C]
  mov eax,[eax+28]
  fld qword ptr [eax+210]
  fadd qword ptr [cash]
  fstp qword ptr [eax+210]
  mov [cash_flag],#0
  pop eax
  jmp return

cash:
 dq (double)100000

cash_flag:
 dd 0

INJECTCash:
  jmp newmem
return:
registersymbol(INJECTCash)

[DISABLE]

INJECTCash:
  db 83 C4 10 8B C8 89

unregistersymbol(cash)
unregistersymbol(cash_flag)
unregistersymbol(INJECTCash)
dealloc(newmem)

_________________
I don't post too much. yet.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites