Visual C ++ Debugger and the BoundsChecker Riddle

Take a look at this screenshot of a Visual C ++ debugger session:


(source: lviv.ua )

The execution point is now inside a virtual function. "mDb" is a reference to an object that is a member of this class. "mDb" is of type CDbBackend & . There is only one thread. The values ​​in the red boxes should be equal, but this is not the case. How can this be possible?

BoundsChecker ( ). . . , BoundsChecker - , BoundsChecker , .

, "b = & mDb", , . thhrough , , ( AVI 500).

007AB7B0  push        4    
007AB7B2  push        80000643h 
007AB7B7  push        4    
007AB7B9  push        0C0002643h 
007AB7BE  lea         eax,[ebp-10h] 
007AB7C1  push        eax  
007AB7C2  call        dword ptr [_numega_finalcheck_C_110456 (8FA8A8h)] 
007AB7C8  mov         eax,dword ptr [eax] 
007AB7CA  add         eax,1CCh 
007AB7CF  push        eax  
007AB7D0  call        dword ptr [_numega_finalcheck_C_110456 (8FA8A8h)] 
007AB7D6  mov         dword ptr [ebp-70h],eax 
007AB7D9  push        dword ptr [ebp-70h] 
007AB7DC  push        4    
007AB7DE  push        50000643h 
007AB7E3  lea         eax,[ebp-20h] 
007AB7E6  push        eax  
007AB7E7  call        dword ptr [_numega_finalcheck_Y_110456 (8FA8ECh)] 
007AB7ED  mov         ecx,dword ptr [ebp-70h] 
007AB7F0  mov         ecx,dword ptr [ecx] 
007AB7F2  mov         dword ptr [eax],ecx 
+3
2
  • , . ( , :)

  • - , ? , . . [ebp - offset]; , b. " " .

  • , , , b = &mDb. , [ebp-10h] [ebp-70h] b, mDb . . ?

  • , , . , - . , . Visual Studio 2008 Intel C/++, .

. , .

+1

mDb CDbBackend? , .

:

class A
{
  // Stuff
};

class B : public A
{
  // More stuff
};

B *b = new B;
A *a = (A *)&b;

b a , "Stuff" "More Stuff". , , - . , . mDb, , CDbBackend, .

0

Source: https://habr.com/ru/post/1722124/


All Articles