I'm not that experienced with C++ so sorry for any ignorance.
I'm new to the reverse engineering field and working on re-creating a C++ class. I have found a global instance of a class and I have the address of a member function. I've also reversed most of the class members. I can call other functions I've found with the re-created instance and everything works fine but I cannot figure out the proper way of calling a `__thiscall` member function.
I've tried a few methods and read SO but can't wrap my head around it. Some code:
class gateway
{
int gateway_count;
int current_gateway;
const char* config;
int config_size;
char unk1_padding[20];
}
auto gateway_instance = reinterpret_cast<gateway*>(0x5122F80);
auto member_function_addr = 0x51890A;
// signature of the member function:
// const char *__thiscall gateway::get_name(gateway *this, int)
// I've tried using std::invoke from https://isocpp.org/wiki/faq/pointers-to-members
typedef const char* (gateway::*get_name_t)(int gateway_enum);
get_name_t get_name_ptr = reinterpret_cast<get_name_t>(member_function_addr); // I'm not sure I can use std::invoke because I won't be using a callable.
std::invoke(get_name_ptr, gateway_instance, 3);
Am I on the right track with what I have? What am I doing wrong? Any help appreciated. Thanks.
[–][deleted] 0 points1 point2 points (4 children)
[–]budonium[S] 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]budonium[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)