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 


Feature request: Add Copy relative Offset

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

Joined: 11 Mar 2015
Posts: 136

PostPosted: Wed Jan 31, 2018 3:18 am    Post subject: Feature request: Add Copy relative Offset Reply with quote

e.g:
1.Ctrl+Enter Enabling "Show relative addresses"
2.Select any Address
3.rightclicked>>>>Copy Selection Address relative Offset Value to clipboard
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Wed Jan 31, 2018 5:19 am    Post subject: Reply with quote

add this as a .lua file to your autorun folder inside cheat engine
Code:

--this script adds "Copy Selection Address relative Offset Value to clipboard"
local mv=getMemoryViewForm()

if (miCopyRelativeAddress~=nil) then
  miCopyRelativeAddress.destroy()
  miCopyRelativeAddress=nil
  mv.memorypopup.OnPopup=oldmemorypopuponpopup
  oldmemorypopuponpopup=nil
end

miCopyRelativeAddress=createMenuItem(mv.memorypopup)
miCopyRelativeAddress.Name="miCopyRelativeAddress"
miCopyRelativeAddress.Caption="Copy Selection Address relative Offset Value to clipboard"
miCopyRelativeAddress.ShortCut=textToShortCut("Ctrl+Shift+C")
miCopyRelativeAddress.OnClick=function()
  local hv=mv.HexadecimalView
  if hv.UseRelativeBase then
    local s
    if hv.SelectionStart>=hv.RelativeBase then
      s=string.format("+%x", hv.SelectionStart-hv.RelativeBase)
    else
      s=string.format("-%x", hv.RelativeBase-hv.SelectionStart)
    end

    if hv.SelectionStop~=hv.SelectionStart then
      if hv.SelectionStop>=hv.RelativeBase then
        s=string.format("%s to +%x", s, hv.SelectionStop-hv.RelativeBase)
      else
        s=string.format("%s to -%x", s, hv.RelativeBase-hv.SelectionStop)
      end
    end

    --print(s)
    writeToClipboard(s)
  end
end

--mv.memorypopup.Items.Insert(CopyRelativeAddress, mv.Cut1.MenuIndex)
mv.memorypopup.Items.insert(mv.Cut1.MenuIndex-1, miCopyRelativeAddress)

oldmemorypopuponpopup=mv.memorypopup.OnPopup
mv.memorypopup.OnPopup=function(s)
  miCopyRelativeAddress.Visible=mv.HexadecimalView.UseRelativeBase
  return oldmemorypopuponpopup(s)
end

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
xxhehe
Expert Cheater
Reputation: 0

Joined: 11 Mar 2015
Posts: 136

PostPosted: Wed Jan 31, 2018 6:33 am    Post subject: Reply with quote

Dark Byte wrote:
add this as a .lua file to your autorun folder inside cheat engine
Code:

--this script adds "Copy Selection Address relative Offset Value to clipboard"
local mv=getMemoryViewForm()

if (miCopyRelativeAddress~=nil) then
  miCopyRelativeAddress.destroy()
  miCopyRelativeAddress=nil
  mv.memorypopup.OnPopup=oldmemorypopuponpopup
  oldmemorypopuponpopup=nil
end

miCopyRelativeAddress=createMenuItem(mv.memorypopup)
miCopyRelativeAddress.Name="miCopyRelativeAddress"
miCopyRelativeAddress.Caption="Copy Selection Address relative Offset Value to clipboard"
miCopyRelativeAddress.ShortCut=textToShortCut("Ctrl+Shift+C")
miCopyRelativeAddress.OnClick=function()
  local hv=mv.HexadecimalView
  if hv.UseRelativeBase then
    local s
    if hv.SelectionStart>=hv.RelativeBase then
      s=string.format("+%x", hv.SelectionStart-hv.RelativeBase)
    else
      s=string.format("-%x", hv.RelativeBase-hv.SelectionStart)
    end

    if hv.SelectionStop~=hv.SelectionStart then
      if hv.SelectionStop>=hv.RelativeBase then
        s=string.format("%s to +%x", s, hv.SelectionStop-hv.RelativeBase)
      else
        s=string.format("%s to -%x", s, hv.RelativeBase-hv.SelectionStop)
      end
    end

    --print(s)
    writeToClipboard(s)
  end
end

--mv.memorypopup.Items.Insert(CopyRelativeAddress, mv.Cut1.MenuIndex)
mv.memorypopup.Items.insert(mv.Cut1.MenuIndex-1, miCopyRelativeAddress)

oldmemorypopuponpopup=mv.memorypopup.OnPopup
mv.memorypopup.OnPopup=function(s)
  miCopyRelativeAddress.Visible=mv.HexadecimalView.UseRelativeBase
  return oldmemorypopuponpopup(s)
end


Thank DB.
Back to top
View user's profile Send private message
xxhehe
Expert Cheater
Reputation: 0

Joined: 11 Mar 2015
Posts: 136

PostPosted: Sun Feb 11, 2018 6:46 am    Post subject: Reply with quote

Dark Byte wrote:
add this as a .lua file to your autorun folder inside cheat engine
Code:

--this script adds "Copy Selection Address relative Offset Value to clipboard"
local mv=getMemoryViewForm()

if (miCopyRelativeAddress~=nil) then
  miCopyRelativeAddress.destroy()
  miCopyRelativeAddress=nil
  mv.memorypopup.OnPopup=oldmemorypopuponpopup
  oldmemorypopuponpopup=nil
end

miCopyRelativeAddress=createMenuItem(mv.memorypopup)
miCopyRelativeAddress.Name="miCopyRelativeAddress"
miCopyRelativeAddress.Caption="Copy Selection Address relative Offset Value to clipboard"
miCopyRelativeAddress.ShortCut=textToShortCut("Ctrl+Shift+C")
miCopyRelativeAddress.OnClick=function()
  local hv=mv.HexadecimalView
  if hv.UseRelativeBase then
    local s
    if hv.SelectionStart>=hv.RelativeBase then
      s=string.format("+%x", hv.SelectionStart-hv.RelativeBase)
    else
      s=string.format("-%x", hv.RelativeBase-hv.SelectionStart)
    end

    if hv.SelectionStop~=hv.SelectionStart then
      if hv.SelectionStop>=hv.RelativeBase then
        s=string.format("%s to +%x", s, hv.SelectionStop-hv.RelativeBase)
      else
        s=string.format("%s to -%x", s, hv.RelativeBase-hv.SelectionStop)
      end
    end

    --print(s)
    writeToClipboard(s)
  end
end

--mv.memorypopup.Items.Insert(CopyRelativeAddress, mv.Cut1.MenuIndex)
mv.memorypopup.Items.insert(mv.Cut1.MenuIndex-1, miCopyRelativeAddress)

oldmemorypopuponpopup=mv.memorypopup.OnPopup
mv.memorypopup.OnPopup=function(s)
  miCopyRelativeAddress.Visible=mv.HexadecimalView.UseRelativeBase
  return oldmemorypopuponpopup(s)
end


Feature request:
e.g:
Address list
1. valid addresses>>>>rightclicked >>>>PopupMenu >> AddMenu 1>>>The address Set as relative addresses

2. valid addresses>>>> rightclicked >>>>PopupMenu >> AddMenu 2>>>Get this address relative Offset



2018-02-11_203926.png
 Description:
 Filesize:  27.94 KB
 Viewed:  8674 Time(s)

2018-02-11_203926.png


Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Feb 11, 2018 7:17 am    Post subject: Reply with quote

The problem with doing that for the address list is... what is it relative to? Those addresses could be in some threads stack or in numerous modules or dynamically allocated outside of any else....some of them like "game.exe"+1234 are relative to a module (in this case, game.exe) and all you have to do to see that is open the address (or just don't have CE attached to anything) others are things like "400238 + 4" or "-4 * 8 + 400000 + 334", both are relative to something because they aren't absolute addresses but should they be considered so and if so then should the last number be considered the offset or would you want the code to parse each part in some way (is -4 a single part by itself or only -4*8, etc.) and pick the largest? Or would you only want it to look for a module name +- some offset?

If you just want to be able to copy offsets for pointers then I made this after seeing Chris from CheatTheGame copying like 12 offsets on video lol It adds a "print offsets" option which will print to the lua engine window both the compact "[[[[[[[$process+124]+04]+44]+24]+878]+34]+134]+348" and with each part on it's own line for easy editing in a script and you can just copy the part you want or simply leave the window open as a reference that doesn't interfere with you using CE. It doesn't copy it to your clipboard for you though so you do have to copy which part you want rather than have it automatically overwrite whatever you had copied.
Back to top
View user's profile Send private message
xxhehe
Expert Cheater
Reputation: 0

Joined: 11 Mar 2015
Posts: 136

PostPosted: Sun Feb 11, 2018 7:40 am    Post subject: Reply with quote

FreeER wrote:
The problem with doing that for the address list is... what is it relative to? Those addresses could be in some threads stack or in numerous modules or dynamically allocated outside of any else....some of them like "game.exe"+1234 are relative to a module (in this case, game.exe) and all you have to do to see that is open the address (or just don't have CE attached to anything) others are things like "400238 + 4" or "-4 * 8 + 400000 + 334", both are relative to something because they aren't absolute addresses but should they be considered so and if so then should the last number be considered the offset or would you want the code to parse each part in some way (is -4 a single part by itself or only -4*8, etc.) and pick the largest? Or would you only want it to look for a module name +- some offset?

If you just want to be able to copy offsets for pointers then I made this after seeing Chris from CheatTheGame copying like 12 offsets on video lol It adds a "print offsets" option which will print to the lua engine window both the compact "[[[[[[[$process+124]+04]+44]+24]+878]+34]+134]+348" and with each part on it's own line for easy editing in a script and you can just copy the part you want or simply leave the window open as a reference that doesn't interfere with you using CE. It doesn't copy it to your clipboard for you though so you do have to copy which part you want rather than have it automatically overwrite whatever you had copied.


Q:
what is it relative to?

A:
it relative to specifying the Any Emulator/PC GAME Zero address.(e.g:ePSXe 2.05,[ePSXe.exe+53925]+0

-----------------------
My relative address used method:02.png



02.png
 Description:
 Filesize:  27.17 KB
 Viewed:  8659 Time(s)

02.png



2018-02-11_213309.png
 Description:
 Filesize:  6.42 KB
 Viewed:  8664 Time(s)

2018-02-11_213309.png


Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Feb 11, 2018 8:13 am    Post subject: Reply with quote

But processes have multiple modules that addresses can be relative to, some modules can, theoretically anyway, be loaded in different locations each time and using any address that's based on some other module leads to incorrect addresses. And addresses can even exist outside of modules... it's almost like you either didn't read or didn't understand my reply and simply ignored everything I said other than the literal question...

Here's an image showing what I mean, there are two memory viewers open at the same time to two different spots in memory (two different modules in the same process, the CE tutorial). Both have relative addresses of 0, even though the absolute addresses are different.


Actually scrolling through the memory viewer and playing with the relative offsets seems to show that the base address defaults to whatever the previous 1000 address was, eg. if you're at 556EDF then the base address will be 556000 even though the memory region that address is in has an addres of 54F000 (based on the Memory Regions window) which is inside the "Tutorial-i386.exe" module, moving forward to 557EDF which is still within the same memory region (in my test) causes the base to update to 557000 however the relative numbering will only changed when it's toggled.

actually (actually lol), the relative offset doesn't seem to care about the shown base address at all, I just assumed that was relevant. If you use the shortcut (ctrl+enter) it's just whatever byte is at the top of the display window. So if you highlight the first byte (to keep track of the same one) and enable relative offsets the address will be 0, scroll up and toggle relative offsets and it'll change to + something. And if you use the mouse to right click a byte and enable it then it's relative to whatever byte you clicked...

The address list has neither of those to use as a reference. As such it seems kind of like you're just asking for what already exists, right click->change record->address... If it's setup as "process.exe"+someOffset then you'll see that... CE just doesn't seem to do that when you add an address from the memory view so perhaps the real request would be for it to set the address based on the shown relative address (or module if it's in one though whether you'd default to the module or the relative address when it's enabled who knows)...


edit: actually this reminds me of something I've never used (because I don't mess with emulators): http://www.cheatengine.org/forum/viewtopic.php?p=5501704 as I've never used it, it may not actually be useful but... it's definitely emulator + base address related Smile
Back to top
View user's profile Send private message
xxhehe
Expert Cheater
Reputation: 0

Joined: 11 Mar 2015
Posts: 136

PostPosted: Sun Feb 11, 2018 7:55 pm    Post subject: Reply with quote

FreeER wrote:
But processes have multiple modules that addresses can be relative to, some modules can, theoretically anyway, be loaded in different locations each time and using any address that's based on some other module leads to incorrect addresses. And addresses can even exist outside of modules... it's almost like you either didn't read or didn't understand my reply and simply ignored everything I said other than the literal question...

Here's an image showing what I mean, there are two memory viewers open at the same time to two different spots in memory (two different modules in the same process, the CE tutorial). Both have relative addresses of 0, even though the absolute addresses are different.


Actually scrolling through the memory viewer and playing with the relative offsets seems to show that the base address defaults to whatever the previous 1000 address was, eg. if you're at 556EDF then the base address will be 556000 even though the memory region that address is in has an addres of 54F000 (based on the Memory Regions window) which is inside the "Tutorial-i386.exe" module, moving forward to 557EDF which is still within the same memory region (in my test) causes the base to update to 557000 however the relative numbering will only changed when it's toggled.

actually (actually lol), the relative offset doesn't seem to care about the shown base address at all, I just assumed that was relevant. If you use the shortcut (ctrl+enter) it's just whatever byte is at the top of the display window. So if you highlight the first byte (to keep track of the same one) and enable relative offsets the address will be 0, scroll up and toggle relative offsets and it'll change to + something. And if you use the mouse to right click a byte and enable it then it's relative to whatever byte you clicked...

The address list has neither of those to use as a reference. As such it seems kind of like you're just asking for what already exists, right click->change record->address... If it's setup as "process.exe"+someOffset then you'll see that... CE just doesn't seem to do that when you add an address from the memory view so perhaps the real request would be for it to set the address based on the shown relative address (or module if it's in one though whether you'd default to the module or the relative address when it's enabled who knows)...


edit: actually this reminds me of something I've never used (because I don't mess with emulators): http://www.cheatengine.org/forum/viewtopic.php?p=5501704 as I've never used it, it may not actually be useful but... it's definitely emulator + base address related Smile


You this viewpoint is not for emulator.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Mon Feb 12, 2018 2:19 am    Post subject: Reply with quote

Add this to your autorun:
Code:

--this script adds "Browse this memory record relative"
if (miShowAsRelative~=nil)  then
  miShowAsRelative.destroy()
  miShowAsRelative=nil
  AddressList.PopupMenu.OnPopup=oldAddressListPopup
  oldAddressListPopup=nil
end

miShowAsRelative=createMenuItem(AddressList.PopupMenu)
miShowAsRelative.Name="miShowAsRelative"
miShowAsRelative.Caption="Browse this memory record relative"
miShowAsRelative.ShortCut=textToShortCut("Ctrl+R")
miShowAsRelative.OnClick=function()
  if AddressList.SelectedRecord==nil then return end
  local address=AddressList.SelectedRecord.CurrentAddress
  local mv=getMemoryViewForm()
  local mvhv=mv.HexadecimalView

  mvhv.UseRelativeBase=true
  mvhv.RelativeBase=address
  mvhv.Address=address
  mv.show()
end

AddressList.PopupMenu.Items.insert(MainForm.Browsethismemoryregion1.MenuIndex, miShowAsRelative)

oldAddressListPopup=AddressList.PopupMenu.OnPopup
AddressList.PopupMenu.OnPopup=function(s)
  local r=oldAddressListPopup(s)
  miShowAsRelative.Visible=MainForm.Browsethismemoryregion1.Visible
  return r
end

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
xxhehe
Expert Cheater
Reputation: 0

Joined: 11 Mar 2015
Posts: 136

PostPosted: Mon Feb 12, 2018 8:04 am    Post subject: Reply with quote

Dark Byte wrote:
Add this to your autorun:
Code:

--this script adds "Browse this memory record relative"
if (miShowAsRelative~=nil)  then
  miShowAsRelative.destroy()
  miShowAsRelative=nil
  AddressList.PopupMenu.OnPopup=oldAddressListPopup
  oldAddressListPopup=nil
end

miShowAsRelative=createMenuItem(AddressList.PopupMenu)
miShowAsRelative.Name="miShowAsRelative"
miShowAsRelative.Caption="Browse this memory record relative"
miShowAsRelative.ShortCut=textToShortCut("Ctrl+R")
miShowAsRelative.OnClick=function()
  if AddressList.SelectedRecord==nil then return end
  local address=AddressList.SelectedRecord.CurrentAddress
  local mv=getMemoryViewForm()
  local mvhv=mv.HexadecimalView

  mvhv.UseRelativeBase=true
  mvhv.RelativeBase=address
  mvhv.Address=address
  mv.show()
end

AddressList.PopupMenu.Items.insert(MainForm.Browsethismemoryregion1.MenuIndex, miShowAsRelative)

oldAddressListPopup=AddressList.PopupMenu.OnPopup
AddressList.PopupMenu.OnPopup=function(s)
  local r=oldAddressListPopup(s)
  miShowAsRelative.Visible=MainForm.Browsethismemoryregion1.Visible
  return r
end


感谢D.K.实现了将选中的基地址设置为起始地址的功能.

第二个请求添加的功能:在启用"显示相对偏移"或者设置了起始地址(+00000000)之后,能够鼠标移动到查找到的动态地址上就可以获取相对偏移的功能,可能很难实现吧...

Thank D.K.you are (my) god.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Feb 12, 2018 8:13 am    Post subject: Reply with quote

ah, so that's all you wanted. makes sense now Smile
Back to top
View user's profile Send private message
movss
Cheater
Reputation: 0

Joined: 10 Feb 2018
Posts: 38

PostPosted: Tue Feb 13, 2018 12:46 pm    Post subject: Reply with quote

ce比od强大
_________________
A wild programmer
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 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