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 


Redo ver. 1.05 (ALT+Backspace known from OllyDbg)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Oct 25, 2015 11:01 am    Post subject: Redo ver. 1.05 (ALT+Backspace known from OllyDbg) Reply with quote

Lua script version 1.05
history: public release (1.02), increased number of "next lines" (1.03), deal with unreadable addresses (1.04), do not use "disassemblerview_onSelectionChange" (1.05)



CE will remember the original instruction, altered line will be moved to the right.
You can restore the old one with ALT+R.

After AA injection:



Manually altered line:


New menu entry:



Code:
function restoreOrigBytes(sender)
  selectedAddress_redo = disassemblerview_getSelectedAddress(redo_dv)
  if origBytesTable[selectedAddress_redo]==nil then return end

  local bytes={}
  local start=origBytesTable[selectedAddress_redo].startaddress
  local size=origBytesTable[selectedAddress_redo].size

  --prepare subset
  for i=1,size do bytes[#bytes+1]=origBytesTable[start+i-1].byte end

  local script=string.format('%X',start)..':\r\n'..'db '..'#'..(table.concat(bytes,' #'))

  skip_myAssemblerWithRedo=true
  if not autoAssemble(script) then return nil end
  skip_myAssemblerWithRedo=false
end

skip_myAssemblerWithRedo=false
function myAssemblerWithRedo(addr,inst)

  if skip_myAssemblerWithRedo               -- forced skip?
     or
     origBytesTable[addr]~=nil   -- we already have collected orig bytes
  then return nil end

  local origsize=getInstructionSize(addr)
  local sizes={}
  local tmpVar=0

  -- get sizes of those next lines
  for i=1,20 do
    sizes[i]=getInstructionSize(addr+tmpVar)
    tmpVar=tmpVar+sizes[i]
  end

  --get bytes of those next lines
  local originalbytes=readBytes(addr,tmpVar,true)
  if originalbytes==nil then return nil end

  -- save original bytes if not already saved
  tmpVar=1
  for i=1,20 do
    for j=1,sizes[i] do
      local tmp={startaddress=addr, byte=originalbytes[tmpVar], size=sizes[i]}
      if not origBytesTable[addr+j-1] then origBytesTable[addr+j-1]=tmp end
      tmpVar=tmpVar+1
    end
    addr=addr+sizes[i]
  end

  return nil
end

getVisibleDisassembler().OnDisassembleOverride =
function (vd, a, ldd)
  if origBytesTable[a]==nil then return nil,nil end -- 100% not changed

  disAsm_redo.syntaxhighlighting=vd.syntaxhighlighting
  disAsm_redo.disassemble(a)

  local modified=false
  local startbyte=origBytesTable[a].startaddress
  local endbyte=startbyte+origBytesTable[a].size-1

  -- search for differences
  for i=startbyte,endbyte do
    if disAsm_redo.LastDisassembleData.bytes[i-origBytesTable[a].startaddress+1]~=
       origBytesTable[i].byte
    then modified=true break end
  end

  if not modified then return nil,nil end -- bytes the same, not modified

  for k,v in pairs(disAsm_redo.LastDisassembleData) do ldd[k]=v end

  ldd.opcode='  '..ldd.opcode -- add few spaces at the beginning
  return ldd.opcode,ldd.description
end

function addRedoMenuItem()
  redo_dv=getMemoryViewForm().DisassemblerView

  if redoMenuItem==nil then
   local pmenu=redo_dv.PopupMenu
   redoMenuItem=createMenuItem(pmenu)
   pmenu.Items.add(redoMenuItem)
  end
  redoMenuItem.Caption='Restore Original Bytes'
  redoMenuItem.Shortcut='Alt+R'
  redoMenuItem.OnClick=restoreOrigBytes
end

if myAssemblerWithRedo_ID==nil then myAssemblerWithRedo_ID=registerAssembler(myAssemblerWithRedo) end
if disAsm_redo==nil then disAsm_redo=createDisassembler() end
if origBytesTable==nil then origBytesTable={} end

addRedoMenuItem()

_________________


Last edited by mgr.inz.Player on Sun Jan 31, 2016 8:22 pm; edited 8 times in total
Back to top
View user's profile Send private message MSN Messenger
lolAnonymous
Expert Cheater
Reputation: 1

Joined: 19 Jul 2015
Posts: 154

PostPosted: Sun Oct 25, 2015 2:19 pm    Post subject: Reply with quote

Hello Sir I Think The Thing U Have Posted Is Very Very Useful For Me So Can U Pls Explain It Little More I Can't Understand What Will It Do Smile

Can I Inbox U ?
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Oct 25, 2015 3:31 pm    Post subject: Reply with quote

It is more like CE plug-in, written in Lua.
It is an autorun Lua script.
Copy and paste above script into any/new lua file inside autorun folder.

_________________
Back to top
View user's profile Send private message MSN Messenger
lolAnonymous
Expert Cheater
Reputation: 1

Joined: 19 Jul 2015
Posts: 154

PostPosted: Sun Oct 25, 2015 8:14 pm    Post subject: Reply with quote

Wow nice sir I know how to use it but I was confused in what it does... But now everything is OK Wink

Thanks Smile
Back to top
View user's profile Send private message
theboy181
Advanced Cheater
Reputation: 0

Joined: 26 Jan 2018
Posts: 90

PostPosted: Sun Jul 11, 2021 11:01 am    Post subject: Reply with quote

Should this script work when you manually change a bunch of bytes in the bottom half of the viewer? I would like to change a float in hex and then be able to undo it.
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