Reputation: 308
I have a 64 bit reference to an object where the low order 32 bits of the reference are getting overwritten with 0xFFFFFFFF. I can't figure out how to set a data breakpoint on the bytes for the reference itself because the watch window gives me no way to acquire the address of the reference.
Upvotes: 2
Views: 318
Reputation: 4808
I see two solutions (if I correctly understood the problem):
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;
}
Upvotes: 1
Reputation: 29952
I don't know any direct way to do this. But, here's a possible solution:
esp
/rsp
on x86). If the reference is in an object which is not on stack, then use the this
pointer.Upvotes: 0