Listing 2: Stack walking code

DWORD parentEBP ;
  __asm MOV parentEBP, EBP
do
  {
  BYTE* caller = 
    *((BYTE**)parentEBP + 1) ;
  parentEBP = 
    *(DWORD*)parentEBP ;
  MEMORY_BASIC_INFORMATION mbi ;
  VirtualQuery( caller, &mbi, sizeof( mbi ) ) ;
  HINSTANCE hInstance = mbi.AllocationBase ;
  if( hInstance )
    DumpDebugInfo( caller, hInstance ) ;
  else
    break ; // End of the call chain
  }
while( TRUE ) ;
//End of File