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 


Find out what writes and replace with NOP

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

Joined: 27 Aug 2021
Posts: 41

PostPosted: Fri Aug 27, 2021 5:09 am    Post subject: Find out what writes and replace with NOP Reply with quote

I have:
-A pointer to a specific address
I want to:
-Find out what writes to this address but using Lua
-Replace that line with NOP (code that does nothing)

I am not very familiar with how Lua execution works in CE, but It'd be best for it to run when a specific value has changed, is that possible? Otherwise, is it possible for it to run when the user clicks a button (or something similar?)
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Fri Aug 27, 2021 5:49 am    Post subject: Reply with quote

Code:

-- Required to read the values as hex
function toHex(s)
  local s = string.format("%X", s)
  return s
end

local address = toHex(getAddressSafe('[[[[address]+offset1]+offset2]+offset3') --etc... for however many offsets there are.

writeBytes(address, 0x90,0x90,0x90,0x90,0x90)
-- 0x90 = nop, here it writes 5 nop instructions. Just make sure to delimit each byte instruction with a comma for however many you require to write. Although, should it be a large amount of bytes, I recommend you pass a table that holds the byte data instead.


You can provide a table of bytes to write and pass the table instead of the individual bytes
Back to top
View user's profile Send private message
SleepiDreamer
Cheater
Reputation: 0

Joined: 27 Aug 2021
Posts: 41

PostPosted: Fri Aug 27, 2021 5:58 am    Post subject: Reply with quote

thank you so much!

How exactly do I know how many NOPs I need?
is it per address, 1 for each write to a single address, the total amount of writes from all addresses combined or simply the number of addresses?

_________________
Hope you're having a great day!
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Fri Aug 27, 2021 6:07 am    Post subject: Reply with quote

When you find out what writes to this address, a window will popup and instructions will enter the left side of that window. The instruction responsible for dealing with the value you want to manipulate should be selected.
Then click the "Show Disassembler" button. From there, the disassembler window will popup on the line of instructions you want to modify. Count how many bytes on that line in the bytes column, or you can press
Ctrl + Alt + C with the line selected to copy the bytes then paste them to manually count.

Sidenote, I made a small Lua extension to count the bytes so manually counting them isn't required, which is available here:
https://fearlessrevolution.com/viewtopic.php?f=23&t=16793
Back to top
View user's profile Send private message
SleepiDreamer
Cheater
Reputation: 0

Joined: 27 Aug 2021
Posts: 41

PostPosted: Fri Aug 27, 2021 6:14 am    Post subject: Reply with quote

I've counted the bytes, it seems to be 8 of them, but it still doesn't work.
Any idea on why that could be?

_________________
Hope you're having a great day!
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Fri Aug 27, 2021 6:16 am    Post subject: Reply with quote

What exactly doesn't work? What is your script? I could guess what it could be but it would be better for me to see what you have so I can see what the problem is rather than guess.
Back to top
View user's profile Send private message
SleepiDreamer
Cheater
Reputation: 0

Joined: 27 Aug 2021
Posts: 41

PostPosted: Fri Aug 27, 2021 6:18 am    Post subject: Reply with quote

Code:
-- Required to read the values as hex
function toHex(s)
  local s = string.format("%X", s)
  return s
end

local address = toHex(getAddressSafe('[Minecraft.Windows.exe+4030538]+03CA5218')) --etc... for however many offsets there are.

writeBytes(address, 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90)
-- 0x90 = nop, here it writes 5 nop instructions. Just make sure to delimit each byte instruction with a comma for however many you require to write. Although, should it be a large amount of bytes, I recommend you pass a table that holds the byte data instead.



it doesn't actually replace with not I think, because changing the value still just reverts it back to its original the next frame.

EDIT: I've found the problem: I was inputting the setting itself, not what writes to it. Do you know how to do that instead?

_________________
Hope you're having a great day!
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Fri Aug 27, 2021 7:57 am    Post subject: Reply with quote

SleepiDreamer wrote:

Code:

...
local address = toHex(getAddressSafe('[Minecraft.Windows.exe+4030538]+03CA5218')) --etc... for however many offsets there are.

writeBytes(address, 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90)


it doesn't actually replace with not I think, because changing the value still just reverts it back to its original the next frame.

EDIT: I've found the problem: I was inputting the setting itself, not what writes to it. Do you know how to do that instead?


A rather abnormal offset. Are you absolutely certain you have the right address of the instruction you want to manipulate? When writing bytes, you are overwriting opcodes, i.e. changing the game's low-level code in ASM form.
Back to top
View user's profile Send private message
SleepiDreamer
Cheater
Reputation: 0

Joined: 27 Aug 2021
Posts: 41

PostPosted: Fri Aug 27, 2021 8:16 am    Post subject: Reply with quote

Maybe there's a better pointer to this setting, but yes, that is a working pointer.
But because there is something writing to this setting, executing the script only works for a single frame, because I need to change the opcode of what is writing to the setting, and not the setting itself.
PS: what's the password for your extension?

_________________
Hope you're having a great day!
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1055
Location: 0x90

PostPosted: Fri Aug 27, 2021 9:03 am    Post subject: Reply with quote

I can't really advise any further without more information. I don't have the game to even test what you're trying to achieve.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4289

PostPosted: Fri Aug 27, 2021 11:35 am    Post subject: Reply with quote

Use the Lua functions aobscan to find code and getInstructionSize to figure out how many bytes to nop. See celua.txt for documentation.
_________________
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
SleepiDreamer
Cheater
Reputation: 0

Joined: 27 Aug 2021
Posts: 41

PostPosted: Fri Aug 27, 2021 11:56 am    Post subject: Reply with quote

Thanks!
here's some extra information in case it would be necessary:
The pointers I use have one offset, I found them with 'find out what writes to this address'.
The values are (mostly) all floats
I've found about 175 addresses, each corresponding to a different setting in RTX.
My goal is to make a cheat table that can be opened by anyone and just work (with work I mean you can just change a value and it won't be reset the next frame, aka no extra manual work in CE).
Most settings are 1 float apart (4 bytes)

_________________
Hope you're having a great day!
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