mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Thu Jun 26, 2014 4:13 pm Post subject: registerAssembler and registerGlobalDisassembleOverride |
|
|
based on this post:
http://forum.cheatengine.org/viewtopic.php?p=5539479#5539479
and this:
http://forum.cheatengine.org/viewtopic.php?p=5539482#5539482
I made script which will add those instructions to the assembler and disassembler:
- NOP 2, NOP 3, NOP 4, NOP 5, NOP 6, NOP 7, NOP 8, NOP 9, NOP 10, NOP 11. Those are multibyte NOPs.
- PADDING 4, PADDING 8, PADDING 16 - with those you can guarantee that next instruction will be placed at aligned address. (pad16 will guarantee address which ends with 0)
I mainly made below scripts to achieve PADDING thing, for example when you use movaps instructions, you want a memory operand aligned on a 16-byte boundary. It will pad out with NOP instructions and next available address will be aligned. http://www.winasm.net/forum/index.php?showtopic=2075
Just try to assemble "padding 16" (do it in single-line assembler) at address which ends with "1". It will generate two multibyte nops. Try also other addresses not 16-byte aligned (not ending with zero). The same way it will work for AA scripts.
Add this script to lua file in autorun folder:
Code: | -- initialize table
local NOP = {}
NOP[1] = {0x90}
NOP[2] = {0x66, 0x90}
NOP[3] = { 0x0F, 0x1F, 0x00}
NOP[4] = { 0x0F, 0x1F, 0x40, 0x00}
NOP[5] = { 0x0F, 0x1F, 0x44, 0x00, 0x00}
NOP[6] = {0x66, 0x0F, 0x1F, 0x44, 0x00, 0x00}
NOP[7] = { 0x0F, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00}
NOP[8] = { 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}
NOP[9] = {0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}
NOP[10] = {0x66, 0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}
NOP[11] = {0x66, 0x66, 0x66, 0x0F, 0x1F, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}
for k,v in ipairs(NOP) do NOP[tostring(k)]=v end
for i=2,11 do NOP['concat'..i]=table.concat(NOP[i],'-') end
local function joinTables(t1,t2)
local newT = {}
for _,v in ipairs(t1) do newT[#newT+1] = v end
for _,v in ipairs(t2) do newT[#newT+1] = v end
return newT
end
function add_MULTINOP_and_PADDING(address, instruction)
instruction = instruction:gsub("[^%w]",'')
if instruction:sub(1,3):upper()=="NOP" then
return NOP[instruction:sub(4,5)]
end
if instruction:upper()=="PADDING4" then
return NOP[ 4-(address%4) ]
end
if instruction:upper()=="PADDING8" then
return NOP[ 8-(address%8) ]
end
if instruction:upper()=="PADDING16" then
local neededbytes = 16-(address%16)
if neededbytes<12 then return NOP[ neededbytes ]
else return joinTables(NOP[11],NOP[neededbytes-11])
end
end
return nil
end
function disassembleMultiNOP(sender, address, ldd)
local bytes=readBytes(address, 11, true)
if bytes==nil then return bytes end
for i=11,2,-1 do
if table.concat(bytes,'-',1,i)==NOP['concat'..i] then
ldd.address=address
ldd.opcode="nop"
ldd.parameters=tostring(i)
ldd.description="it is smartass multibyte nop, size (decimal) of this nop:"..i
ldd.bytes=NOP[i]
return ldd.opcode, ldd.description
end
end
return nil,nil
end
registerAssembler(add_MULTINOP_and_PADDING)
registerGlobalDisassembleOverride(disassembleMultiNOP) |
_________________
|
|