| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		rezlind How do I cheat?
  Reputation: 0
  Joined: 17 May 2024 Posts: 4
 
  | 
		
			
				 Posted: Fri May 17, 2024 1:45 pm    Post subject: Failure determining what ... means | 
				       | 
			 
			
				
  | 
			 
			
				I am trying to execute auto assembler script and getting the error:
 
"Failure determining what registerValue means "
 
CheatEngine version is 7.5
 
 
Auto Assember code:
 
 	  | Code: | 	 		  
 
 
[ENABLE]
 
 
// Allocate memory for storing the register value
 
alloc(registerValue, 8)
 
 
// Save the RAX register value to the allocated memory
 
mov [registerValue], rax
 
 
// Execute Lua script to print the value
 
{$lua}
 
  local registerValueAddress = getAddress('registerValue')
 
  local value = readQword(registerValueAddress)
 
  print(string.format("The value of the RAX register is: 0x%X", value))
 
{$asm}
 
 
// Continue with assembly code
 
label(afterLua)
 
afterLua:
 
 
[DISABLE]
 
 
// Deallocate the memory when the script is disabled
 
dealloc(registerValue)
 
 | 	  
 | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		ParkourPenguin I post too much
  Reputation: 152
  Joined: 06 Jul 2014 Posts: 4706
 
  | 
		
			
				 Posted: Fri May 17, 2024 3:06 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				That's not how AA scripts work.
 
 
AA scrips assemble code to a specified address.
 
 	  | Code: | 	 		  game.exe+1234:
 
  mov eax,[rbx] | 	  This assembles the instruction `mov eax,[rbx]` to machine code (bytes) and writes those bytes into memory at the address `game.exe+1234`.
 
 
AA scripts usually just assemble code and write it to a certain address. They aren't responsible for running the code they assemble- it's assumed the game will run it when it's suppose to.
 
 
As such, a freestanding instruction that's not being written to a certain address has no meaning.
 
 
Try the CE tutorial for help understanding the basics of code injection. There are plenty of video tutorials if you're stuck.
 
 
Also, {$lua} blocks are run before the script is executed. If you want the game to invoke some Lua code in CE, use {$luacode}:
 
https://forum.cheatengine.org/viewtopic.php?t=618134
 _________________
 I don't know where I'm going, but I'll figure it out when I get there.  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		rezlind How do I cheat?
  Reputation: 0
  Joined: 17 May 2024 Posts: 4
 
  | 
		
			
				 Posted: Fri May 17, 2024 5:38 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				| That was a slightly simplified example. I am trying to inject code using AOB Injection template. I want the game (after injection is made) to execute lua script that will print the contents of a register, I am pushing all the registers to the stack before {$luacode} section and restoring them after it and before it jumps to the orignal game code. I wonder if that is possible?
 | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		ParkourPenguin I post too much
  Reputation: 152
  Joined: 06 Jul 2014 Posts: 4706
 
  | 
		
			
				 Posted: Fri May 17, 2024 6:36 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				"Slightly" is an understatement.
 
 
When something isn't working and you don't know what's wrong, please post the full script. You don't know if what you omitted/changed is part of the problem. Ideally it should be an SSCCE.
 
The only thing you should edit is the name of the game. e.g. replace "OnlineMultiplayerGame.exe" with "game.exe"
 
 
Pushing/popping registers yourself isn't necessary to use {$luacode}. Just do the same thing as the example in the post I linked to.
 _________________
 I don't know where I'm going, but I'll figure it out when I get there.  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		rezlind How do I cheat?
  Reputation: 0
  Joined: 17 May 2024 Posts: 4
 
  | 
		
			
				 Posted: Sat May 18, 2024 1:06 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				I tried assigning to current cheat table this AOB injection:
 
 	  | Code: | 	 		  
 
 
[ENABLE]
 
 
aobscanmodule(INJECT,game.exe,48 8B 47 18 48 8B BC 24 A0 00 00 00) // should be unique
 
alloc(newmem,$1000,INJECT)
 
 
label(code)
 
label(return)
 
label(afterlua)
 
newmem:
 
 
code:
 
{$luacode itemId=eax}
 
  printf("itemId=%d",itemId)
 
{$asm}
 
afterlua:
 
  mov rax,[rdi+18]
 
  mov rdi,[rsp+000000A0]
 
  jmp return
 
 
INJECT:
 
  jmp newmem
 
  nop 7
 
return:
 
registersymbol(INJECT)
 
 
[DISABLE]
 
 
INJECT:
 
  db 48 8B 47 18 48 8B BC 24 A0 00 00 00
 
 
unregistersymbol(INJECT)
 
dealloc(newmem)
 
 | 	  
 
 
I  got an error: Error in line 0 (call CELUA_ExecuteFunctionByReference) :This instruction can't be compiled
 | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		ParkourPenguin I post too much
  Reputation: 152
  Joined: 06 Jul 2014 Posts: 4706
 
  | 
		
			
				 Posted: Sat May 18, 2024 2:10 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				 	  | Dark Byte wrote: | 	 		  As for the lua error, that's just the syntax check. The syntaxcheck does not inject dll's into the target process, so call CELUA_ExecuteFunctionByReference will fail as the dll can't be found yet. But doing an actual run should be fine
 
 | 	  https://forum.cheatengine.org/viewtopic.php?p=5773449#5773449
 
 
When CE asks you if you want to edit it to this anyway select "Yes"
 
 
If you haven't assigned it to the cheat table yet, comment out everything between {$luacode} and {$asm} inclusive, assign it to the cheat table, edit the script in the address list, and uncomment it
 _________________
 I don't know where I'm going, but I'll figure it out when I get there.  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		rezlind How do I cheat?
  Reputation: 0
  Joined: 17 May 2024 Posts: 4
 
  | 
		
			
				 Posted: Sat May 18, 2024 2:31 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				| Thank you! That worked.
 | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		 |