I've a class named Person. The Person object has only 1 private property 'Age'. I was trying for making a naked assembly function with a parameter of object Person.
That object i want to store in a assemlembly register, and try for taking the property value of age in that stored register.
Storing the object in a register is hopefully well done.
mov edx, dword ptr ds:[ebp + 0x8]
But now i want to take the property value age, of the object that is been stored in EDX register. I tried a few things for picking the value up, but i received always from data. I only want to do this in inline assembly of registers. without using C++ code in the inline assembly.
person class
#include "Person.h"
Person::Person()
{
}
void Person::SetAge(int age)
{
this->_age = age;
}
int Person::GetAge()
{
return this->_age;
}
__declspec(naked) void ObjectCall(Person* p)
{
int age;
_asm
{
mov ebp, esp // prologue
push ecx
mov edx, dword ptr ds:[ebp + 0x8] // Take full object in parameter and put it in edx register
mov ecx, 0x4
mov eax, dword ptr ds:[edx + ecx] // Trying for taking the property value of age in person object.
mov age, eax
}
std::cout << age << std::endl;
_asm
{
// epilogue
pop ecx
ret
}
}
int main()
{
Person p = Person();
p.SetAge(5);
ObjectCall(&p);
}