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 


Auto Assemble: Keypress

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Dave_Scream
Cheater
Reputation: 0

Joined: 06 Dec 2009
Posts: 36

PostPosted: Sun May 05, 2024 5:05 am    Post subject: Auto Assemble: Keypress Reply with quote

There is some information about injecting hotkeys in process. But it is still too hard for me.

My question is can it be done more simplier by using {ccode} call and injection?


Tutorials: Auto Assemble: Keypress https://www.cheatengine.org/keypresstut.php

How to use getasynckeystate in a 64 bit platform? https://forum.cheatengine.org/viewtopic.php?t=609403

[C Code]What is better? https://www.cheatengine.org/forum/viewtopic.php?p=5774606


Check/Toggle hotkey script https://forum.cheatengine.org/viewtopic.php?t=609811



List of GetAsyncKeyState keys https://www.unknowncheats.me/forum/c-and-c-/376307-list-getasynckeystate-keys.html
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4711

PostPosted: Sun May 05, 2024 1:46 pm    Post subject: Reply with quote

CE tutorial x64 step 2; hold "V" to win:
Code:
define(address,"Tutorial-x86_64.exe"+2B4BC)
define(bytes,29 83 F8 07 00 00)

[ENABLE]

assert(address,bytes)
alloc(newmem,$1000,"Tutorial-x86_64.exe"+2B4BC)

label(code)
label(return)

newmem:
{$ccode damage=rax rbx=rbx}
short GetAsyncKeyState(int);

short res = GetAsyncKeyState('V');
if (res & 0x8000) {
    int *healthp = (int *)(rbx+0x7F8);
    *healthp = 1000;
    damage=0;
}
{$asm}
code:
  sub [rbx+000007F8],eax
  jmp return

address:
  jmp newmem
  nop
return:

[DISABLE]

address:
  db bytes
  // sub [rbx+000007F8],eax

dealloc(newmem)

{
// ORIGINAL CODE - INJECTION POINT: Tutorial-x86_64.exe+2B4BC

Tutorial-x86_64.exe+2B490: 55                       - push rbp
Tutorial-x86_64.exe+2B491: 48 89 E5                 - mov rbp,rsp
Tutorial-x86_64.exe+2B494: 48 8D A4 24 D0 FE FF FF  - lea rsp,[rsp-00000130]
Tutorial-x86_64.exe+2B49C: 48 89 9D F0 FE FF FF     - mov [rbp-00000110],rbx
Tutorial-x86_64.exe+2B4A3: 48 89 CB                 - mov rbx,rcx
Tutorial-x86_64.exe+2B4A6: 48 C7 45 F8 00 00 00 00  - mov qword ptr [rbp-08],00000000
Tutorial-x86_64.exe+2B4AE: 90                       - nop
Tutorial-x86_64.exe+2B4AF: B9 05 00 00 00           - mov ecx,00000005
Tutorial-x86_64.exe+2B4B4: E8 57 47 FE FF           - call Tutorial-x86_64.exe+FC10
Tutorial-x86_64.exe+2B4B9: 83 C0 01                 - add eax,01
// ---------- INJECTING HERE ----------
Tutorial-x86_64.exe+2B4BC: 29 83 F8 07 00 00        - sub [rbx+000007F8],eax
// ---------- DONE INJECTING  ----------
Tutorial-x86_64.exe+2B4C2: 48 8D 4D F8              - lea rcx,[rbp-08]
Tutorial-x86_64.exe+2B4C6: E8 45 DA FD FF           - call Tutorial-x86_64.exe+8F10
Tutorial-x86_64.exe+2B4CB: 8B 8B F8 07 00 00        - mov ecx,[rbx+000007F8]
Tutorial-x86_64.exe+2B4D1: 41 B9 FF 00 00 00        - mov r9d,000000FF
Tutorial-x86_64.exe+2B4D7: 4C 8D 85 F8 FE FF FF     - lea r8,[rbp-00000108]
Tutorial-x86_64.exe+2B4DE: 48 C7 C2 FF FF FF FF     - mov rdx,FFFFFFFFFFFFFFFF
Tutorial-x86_64.exe+2B4E5: 48 63 C9                 - movsxd  rcx,ecx
Tutorial-x86_64.exe+2B4E8: E8 A3 AB FD FF           - call Tutorial-x86_64.exe+6090
Tutorial-x86_64.exe+2B4ED: 45 31 C0                 - xor r8d,r8d
Tutorial-x86_64.exe+2B4F0: 48 8D 95 F8 FE FF FF     - lea rdx,[rbp-00000108]
}

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Dave_Scream
Cheater
Reputation: 0

Joined: 06 Dec 2009
Posts: 36

PostPosted: Sun May 05, 2024 3:13 pm    Post subject: Reply with quote

ParkourPenguin wrote:


Thank you it working! Also I add push and pop registers. Because somewhere here on forum guys said that GetAsyncStateKey function may mess some registers.


Code:
push rax
push rbx
push rcx
push rdx
push rsi
push rdi
push rbp
push r8
push r9
push r10
push r11
push r12
push r13
push r14
push r15
pushfq
{$ccode}
extern float runspeed_mult;
short GetAsyncKeyState(int);
short res = GetAsyncKeyState('K');
if (res & 0x8000) {
  runspeed_mult = 5;
} else {
   runspeed_mult = 1;
}
{$asm}
popfq
pop r15
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rbp
pop rdi
pop rsi
pop rdx
pop rcx
pop rbx
pop rax
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4711

PostPosted: Sun May 05, 2024 3:27 pm    Post subject: Reply with quote

That's unnecessary. {$ccode} does all that for you. Look at the code CE injects.
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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