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 


getSymbolFromAddress()

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Thu Sep 26, 2024 2:25 pm    Post subject: getSymbolFromAddress() Reply with quote

How to use getSymbolFromAddress()

I tried this and it did not print anything:

Code:
  local address = getMemoryViewForm().DisassemblerView.SelectedAddress
  print(getMainSymbolList().getSymbolFromAddress(address))


I want to get the symbol name of the function/address so I can extract the offset
Back to top
View user's profile Send private message Visit poster's website
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Thu Sep 26, 2024 2:55 pm    Post subject: Reply with quote

you're best of using getNameFromAddress and parse the +xxx part

but if you really want to, it's something like this:

Code:

local address = getMemoryViewForm().DisassemblerView.SelectedAddress
local symbolinfo=getMainSymbolList().getSymbolFromAddress(address)

if symbolinfo then
  printf("symbol address of %s=%x, so offset is %x", symbolinfo.searchkey, symbolinfo.address, address-symbolinfo.address )
else
  printf("not a symbol. Checking modules")
  local ml=enumModules()
  for i=1,#ml do
    if address>=ml[i].Address then
      local ms=getModuleSize(ml[i].Name)  --7.6 will have .Size part of the modulelist
      if address<ml[i].Address+ms then
        printf("module address=%x, so offset is %x", ml[i].Address, address-ml[i].Address)
      end
      break --the modulelist is sorted by address, so if this isn't it, it's not in the list
    end
  end
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
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Thu Sep 26, 2024 3:46 pm    Post subject: Reply with quote

Thank you )
Back to top
View user's profile Send private message Visit poster's website
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