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 


index vtable and call

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Sat Sep 03, 2022 10:16 am    Post subject: index vtable and call Reply with quote

so i want to do like this:
Code:
return player:GetVTable()[2](...) --Note: custom function in player class, passed through GetVTable function but having a little modified version, still calls function

and i have a little code here:
Code:
function GetVTable(obj, size)
  if obj == nil or size == nil then
    return nil
  end
  local vtbl = {}
  for i = 0, size / 4 do
    vtbl[i] = readPointer(readPointer(obj) + i * 0x4)
  end
  return vtbl
end

function returns vtable functions values and i wanted to pass the address through my Call functon
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Sun Sep 04, 2022 12:10 am    Post subject: Reply with quote

instead of
Code:

  for i = 0, size / 4 do
    vtbl[i] = readPointer(readPointer(obj) + i * 0x4)
  end


do something like
Code:

  for i = 0, size / 4 do
    local address=readPointer(readPointer(obj) + i * 0x4)
    vtbl[i] = function(...)
                return executeMethod(0, nil, address, obj,  <parse parameters here>)
              end
  end


you just need to parse the ... parameters and it should behave the way you intended in the first part

_________________
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
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Sun Sep 04, 2022 12:37 am    Post subject: Reply with quote

Its exactly what i wanted. Thank you
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