获取重载运算符的内存地址
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++。其他编译器可能有所不同。
相关文章:
- C++ 指针的内存地址和指向数组的内存地址如何相同?
- 在C++中打印指向不同基元数据类型的指针的内存地址
- 为什么 vector 的随机访问迭代器给出与指针不同的内存地址?
- 使用内存地址访问结构的属性值
- 为什么C++总是显示十六进制内存地址,而不仅仅是整数?
- 将布局映射到内存地址
- 为什么同一个变量的内存地址不同?
- 无法将内存地址转换为值
- 给定特定内存地址的数组的动态内存分配
- 在 Microsoft Access SQL 中调用自定义 DLL 函数时传递的内存地址无效
- 获取 R 数据帧的内存地址
- c++ 编译器是否保护常量内存地址免受任何更改?
- 如何防止矢量的内存地址更改
- cout 打印内存地址而不是值
- 如何运行外部程序,向其传递内存地址以读取/写入?
- 循环中的变量被设置为下一个数组的元素始终具有相同的内存地址?
- 重载 ostream << 运算符,指针作为参数,导致输出上的内存地址
- C++在变量的内存地址上做什么来"deallocate"它?
- 在指向现有内存地址的 hpp 文件中声明成员函数的最佳方法
- 为什么我无法获取 MSVS2019 / C++ 中字符或uint8_t变量的内存地址?