我有一个对象的64位引用,其中引用的低32位被0xFFFFFFFF覆盖。我无法弄清楚如何在引用本身的字节上设置数据断点,因为监视窗口无法提供获取引用地址的方法。
我看到两个解决方案(如果我正确理解了这个问题):
class object_t
{
public:
int i;
};
class test_t
{
public:
int64_t dummy {};
object_t& ro;
test_t( object_t& aro ) : ro { aro } {}
};
int main()
{
object_t obj;
test_t c { obj };
// without dummy
int64_t* p = (int64_t*)&c;
*(int32_t*)p = 0xffffffff; // simulates memory corruption
c.ro.i = 0; // exception
// with dummy
int64_t* p = (int64_t*)&c;
*(int32_t*)p = 0xffffffff; // will break
return 0;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句