[英]Overloaded operator std::ostream& operator<< prints instance memory address
[英]Get memory address of overloaded operator?
MyString类的头文件的摘录。
class MyString
{
...
public:
bool IsEmpty(void) const;
bool operator==(MyString const &)const;
bool operator==(char const *)const;
...
};
现在,我在汇编器中调用MyString的方法,它可以正常工作。
__declspec(naked)
void Injected() {
__asm {
//setup Call Parameters
//...
call MyString::IsEmpty //bool IsEmpty(void) const;
}
}
对于该方法有效的方法不适用于操作员。 是否可以获取重载运算符的地址并在汇编器中调用它?
__declspec(naked)
void Injected() {
__asm {
//setup Call Parameters
//...
call MyString::operator== //bool operator==(char const *)const;
}
}
根据msdn文档, “ __asm块只能调用未重载的全局C ++函数。”
一种解决方案是添加一个可以从asm调用的辅助函数。 就像是:
bool equalCharPtr(char const *str)const { return *this == str; }
当然,这仅适用于Visual C ++。 其他编译器可能会有所不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.