Where and how is the C++ member function located?
First of all, my personal guess is that
Even if you create multiple class objects, the class's member variables are likely to set multiple areas and have a location appropriate to the way they are declared (bss if all the member variables are 0, data if they are declared static, etc.).
Even if you create multiple class objects, the member functions will not generate multiple to the location. Perhaps the member function Func takes over the address of a class object that we don't see as a Func (class object address, variable A, variable B...) and the same member function of multiple objects is implemented only one function.
The location of that member function is... ...maybe it's a STATIC object, or any object, so it's going to be waiting in the data area.
I'm guessing this much, but how far is it right? Or I would appreciate it if you could give me a link to get information about this implementation.
c++ member function member-function
If you study reverse engineering, you can learn what you want.
In any case, the function is just a memory address, and you put the parameter in the stack and call it.
push ebp
mov ebp, esp
We're building a stack frame with and we can see this and predict that it's the beginning of the function.
For c++, there is a virtual declaration, so you can also obtain the function address by referring to vtable.
The code of the actual functions based on the Windows pe file is stored in the text section.
Global variables, constants (string lights), etc. are stored in the data section, and resources such as images are stored in the resources section.
© 2024 OneMinuteCode. All rights reserved.