 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Ali0100 Newbie cheater
Reputation: 0
Joined: 21 Feb 2020 Posts: 10
|
Posted: Sat Feb 22, 2020 9:54 pm Post subject: How to NOP in LUA |
|
|
Hello,
I was wondering how I can NOP stuff(replace with code that does nothing) in LUA script in the cheat table.
As a bit of context, in my script I write a value to an address for a specific amount of time in a timer running at 1ms interval; like cheat engines built in freeze. However the game is also writing to this value super fast, so there is almost like a conflict. I was wondering if I could NOP the memory that writes to that address for a short amount of time while I’m writing to it. So the code would become something like NOP start -> start timer and write -> NOP stop, this would also allow me to not run timer at 1ms but slower as no conflict so more efficient.
Thanks!
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4715
|
Posted: Sat Feb 22, 2020 11:15 pm Post subject: |
|
|
| Code: | -- simple:
writeBytes(address, 0x90, 0x90, 0x90)
-- more generic:
local numBytes = getInstructionSize(address)
local oldBytes = readBytes(address, numBytes, true)
local t = {}
for i = 1, numBytes, 1 do
t[i] = 0x90
end
writeBytes(address, t)
-- restore original bytes:
writeBytes(address, oldBytes) |
Why not just replace it with NOPs permanently?
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
Ali0100 Newbie cheater
Reputation: 0
Joined: 21 Feb 2020 Posts: 10
|
Posted: Sun Feb 23, 2020 10:45 am Post subject: |
|
|
| ParkourPenguin wrote: | | Code: | -- simple:
writeBytes(address, 0x90, 0x90, 0x90)
-- more generic:
local numBytes = getInstructionSize(address)
local oldBytes = readBytes(address, numBytes, true)
local t = {}
for i = 1, numBytes, 1 do
t[i] = 0x90
end
writeBytes(address, t)
-- restore original bytes:
writeBytes(address, oldBytes) |
Why not just replace it with NOPs permanently? |
Thanks for the help. The game uses this address to target enemies, NOP permanently would mean the player would be unable to target enemies, I only NOP this address when writing a target myself.
i have a question about the code, where you write address, which address goes in there? in memory i have , game.exe+123456 bytes: F3 A5 opcode: repe movsd comment: , in the memory viewer in the line i want to NOP. this line is quite unual for me so im unsure what to do with it, all i know is that if i replace with code that does nothing, it stops writing the address. for extra information, on the target address that im writing to, if i click on what writes to this address and NOP the instruction that writes to it, the value is still written and i get NOP insturctions in the what writes to the address, but looking in memory, in a line down i found that repe movsd i mentioned before and NOP ing that instead causes the game not to write to the address. however im not sure what repe or movsd means so im unsure how to deal with this line and to somehow get the address from this that can be used in NOP ing this in the lua script in cheat table.
again thanks
*edit, i use aob injection into that line, and removed the repe movsd, saved that script to my address list, now when i active the script the repe movsd line is gone from memory and the value is not written and when i disable the script the game can write the value again. is there a better way of dealing this than the way i found? though with the way i found, im not sure how to active and disable scripts in the address table with lua script in the cheat table, is there way to do that if the way i found is the best way to deal with this situation ? thanks
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4715
|
Posted: Sun Feb 23, 2020 11:07 am Post subject: |
|
|
Instructions are stored in memory as a sequence of bytes. You can see this in the disassembler in the "Bytes" column. Just as repe movsd is stored as the bytes F3 A5, 1-byte nop instructions are stored as the byte 90. When you click "replace with nop" all CE does is get how big the instruction is at that address and write that many bytes back with the value 0x90. (at least it used to; CE might be more efficient and use multi-byte nops now)
You can enable or disable entries in the address list from Lua like so:
| Code: | | AddressList.getMemoryRecordByDescription('Foo').Active = true or false |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
Ali0100 Newbie cheater
Reputation: 0
Joined: 21 Feb 2020 Posts: 10
|
Posted: Sun Feb 23, 2020 11:40 am Post subject: |
|
|
| ParkourPenguin wrote: | Instructions are stored in memory as a sequence of bytes. You can see this in the disassembler in the "Bytes" column. Just as repe movsd is stored as the bytes F3 A5, 1-byte nop instructions are stored as the byte 90. When you click "replace with nop" all CE does is get how big the instruction is at that address and write that many bytes back with the value 0x90. (at least it used to; CE might be more efficient and use multi-byte nops now)
You can enable or disable entries in the address list from Lua like so:
| Code: | | AddressList.getMemoryRecordByDescription('Foo').Active = true or false |
|
Thank you! it works
|
|
| Back to top |
|
 |
|
|
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
|
|