Ranged Nop
Posted: Sat Jan 01, 2022 12:17 pm
This is a function that allows to make ranged nop,let's say you need to clean up game code,for example from 0x493A27 to 0x493A4B but the size is 36 and you will be lazy to type db 36 times(cleaning game code can be used when you inject your code/bytes/asm into game & you don't wanna to mess with memory when injecting code),
So here's function:
To use the function type:
Function execution will be looking like this:
So here's function:
Code: Select all
function MakeRangedNop(addr,addrTo)
local size
if addr == nil then
return
end
addr = getAddress(addr)
if addrTo == nil then
size = getInstructionSize(addr)
else
addrTo = getAddress(addrTo)
size = -(addr - addrTo) - 1
end
for i = 0,size do
writeBytes(addr+i,0x90)
end
end
Code: Select all
MakeRangedNop(0x493A04,0x493A0B) --Those two addresses are examples,you can replace them and nop will execute from 0x493A04 to 0x493A0A
Before wrote: 0x493A04: A0 C8E6A900 mov al,[00A9E6C8]
0x493A09: 84 C0 test al,al
Another variant of function(two functions):After wrote: 0x493A04: 90 nop
0x493A05: 90 nop
0x493A06: 90 nop
0x493A07: 90 nop
0x493A08: 90 nop
0x493A09: 90 nop
0x493A0A: 90 nop
Code: Select all
function MakeRangedNop(addr,addrTo)
local size
if addr == nil then
return
end
addr = getAddress(addr)
addrTo = getAddress(addrTo)
if addrTo == nil then
size = getInstructionSize(addr)
else
size = -(addr - addrTo)
end
MakeNop(addr,size)
end
function MakeNop(addr,size)
if addr == nil then
return
end
if size == 0 then
return
end
addr = getAddress(addr)
if size == nil then
size = getInstructionSize(addr)
end
size = size - 1
for i = 0,size do
writeBytes(addr+i,0x90)
end
end