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 


Why doesn't the script work?

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

Joined: 19 Apr 2023
Posts: 25

PostPosted: Mon Oct 30, 2023 8:29 am    Post subject: Why doesn't the script work? Reply with quote

Is it possible to make the game not slow down when debugging is enabled?

I'm trying to activate a button in the game so that the script will work, but everything is slow.


Code:
debug_setBreakpoint("lua51.dll+1ED0")
function debugger_onBreakpoint()
  if RBP == 429496723 then
       print("YES");
       debug_removeBreakpoint("lua51.dll+1ED0")
       return 1;
  end
  return 1;
end



I need to reads value from register RBP == 429496723
Back to top
View user's profile Send private message
Famine
Cheater
Reputation: 0

Joined: 23 Oct 2023
Posts: 27
Location: A club where people wee on each other.

PostPosted: Mon Oct 30, 2023 9:34 am    Post subject: Re: Why doesn't the script work? Reply with quote

24quant42 wrote:
Is it possible to make the game not slow down when debugging is enabled?

I'm trying to activate a button in the game so that the script will work, but everything is slow.


Code:
debug_setBreakpoint("lua51.dll+1ED0")
function debugger_onBreakpoint()
  if RBP == 429496723 then
       print("YES");
       debug_removeBreakpoint("lua51.dll+1ED0")
       return 1;
  end
  return 1;

The slowdown you're experiencing when debugging a game can be caused by various factors, and it's not necessarily related to the code you've shown. There are several potential reasons for this issue:

Debugging Overhead: Debugging inherently adds overhead to the execution of your code. This is because the debugger needs to constantly monitor your code's execution, which can slow down the game.

Breakpoint Location: The location of your breakpoint can affect performance. If you've set a breakpoint in a frequently executed section of code, it can significantly impact the game's speed.

Debugging Tools: The debugger you are using may not be optimized for real-time game debugging. Some debuggers are more efficient than others.

Hardware Limitations: The performance of your game may be constrained by your computer's hardware. If your computer isn't powerful enough to run the game and the debugger simultaneously, it can cause slowdowns.

Game Engine: The game engine you're using might have limitations when debugging. Some game engines are more robust for debugging than others.

Code Optimizations: Sometimes, debuggers slow down code execution when they can't optimize it effectively. In some cases, recompiling with debugging information might help.

Inefficient Code: The code you are trying to debug might have performance issues itself. Debugging can make these issues more apparent.

To address this issue, you can try the following:

Set breakpoints strategically. Try to set breakpoints only where necessary to minimize the impact on performance.

Use conditional breakpoints. Instead of constantly checking a condition in your debugger_onBreakpoint function, you can set a conditional breakpoint directly in your debugger based on the RBP value.

Optimize your code for debugging. Simplify your code, break it into smaller functions, and minimize any unnecessary operations that can be a bottleneck during debugging.

Use a profiler: Profilers can help you identify performance bottlenecks in your code more effectively than a debugger.

Check your debugger settings. Make sure you're not running your debugger with excessive logging or other features that may slow down the debugging process.

If you're experiencing significant slowdowns even after trying these suggestions, you might want to consider reaching out to the game engine's community or support for specific advice related to that engine and debugging setup.p-==oi97
end


I need to reads value from register RBP == 429496723

_________________
LeFiXER wrote:
You probably should read the replies to make sure someone else hasn't already mentioned what you are about to say. It gives the impression that you are ignorant of other members in this community.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4307

PostPosted: Mon Oct 30, 2023 9:46 am    Post subject: Reply with quote

Make a code injection and check the condition in the game's process

i.e. "Full Injection" template at "lua51.dll+1ED0" and do this:

Code:
...
newmem:
  cmp rbp,429496723
  jne code
  nop  // set breakpoint here
code:
  // original code here

  jmp return
...

_________________
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
24quant42
Cheater
Reputation: 0

Joined: 19 Apr 2023
Posts: 25

PostPosted: Mon Oct 30, 2023 2:11 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Make a code injection and check the condition in the game's process

i.e. "Full Injection" template at "lua51.dll+1ED0" and do this:

Code:
...
newmem:
  cmp rbp,429496723
  jne code
  nop  // set breakpoint here
code:
  // original code here

  jmp return
...



Thanks, I learned how to use AOB, but I'm having some problems. I have attached a screenshot.
As you can see, I use Find out access and get about 1500 addresses.
To the right of address 0A54F0F8 is a timer for charging skills.
0A54EFF4 is a Boolean, if the number at the end is 4, then the skills can be used, if 3, then it is charging.

Notice on the left I can find timer 0A54F0F8, but I can't find 0A54EFF4, instead I find 0A54EFF0.
1) I would like to know why this happens?

2) And the second question, if in AOB I write cmp rcx, #4294967294, then Cheat Engine complains that this code may not compile. But this is strange, because RCX is 64 bits, that is, 8 bytes, and this number must be supported.

Sorry for asking 2 questions at once, but I'm stumped right now, so any answers would be helpful, thanks



1111.png
 Description:
 Filesize:  89.16 KB
 Viewed:  2201 Time(s)

1111.png


Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4307

PostPosted: Mon Oct 30, 2023 3:29 pm    Post subject: Reply with quote

1) The instruction probably accesses 8 bytes at a time. e.g. `mov rcx,[rsi]`.
2) `cmp` can't take a 64-bit immediate value. It can take a 32-bit immediate value and sign-extend it to a 64-bit value, but the 8-byte value 429496723 can't be represented that way.
In this case, if you want to treat it as a 4-byte value, then do so. There's no need to sign-extend anything and it won't be a problem.

You probably want the higher 32 bits anyway.
Code:
push rcx
shr rcx,#32
cmp ecx,4294967294
pop rcx
...


This seems like some memcpy routine. Is there anywhere else you can inject code at?

_________________
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
24quant42
Cheater
Reputation: 0

Joined: 19 Apr 2023
Posts: 25

PostPosted: Mon Oct 30, 2023 4:35 pm    Post subject: Reply with quote

ParkourPenguin wrote:
1)
This seems like some memcpy routine. Is there anywhere else you can inject code at?



1) Yes, you are right, this is exactly the instruction that is used in memory, so how can I make Find out give me the desired address? Maybe you need to change something in the Cheat Engine settings?

2) By the way, this value 4294967294 is equal to FFFFFFFE.
Displayed in memory as
00000000FFFFFFFE
AND
00000000FFFFFFFD
State on and off
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4307

PostPosted: Mon Oct 30, 2023 6:39 pm    Post subject: Reply with quote

1) Regarding the instruction `mov rcx,[rsi]`, if rsi is 0x0A54EFF0, this instruction access all of the bytes at all of the addresses between 0x0A54EFF0 and 0x0A54EFF7 inclusive. This includes the 4-byte value at 0x0A54EFF4. Nothing is wrong, 0x0A54EFF0 is the correct and desired address, there is no setting in CE to change it from being correct.

Maybe an example would help?
Code:
// stores a float and an int
data:
  dd (float)15  // bytes 00 00 70 41
  dd #10000     // bytes 10 27 00 00

code:
  // moves the 8 bytes at `data` into rcx
  // this instruction accesses both the float and the int
  mov rcx,[data]
  // rcx is now 0x0000271041700000
  shr rcx,#32
  // rcx is now 0x0000000000002710
  cmp ecx,#10000  // compares the int value
  ...

_________________
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 Lua Scripting 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