<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to Parse Virtual Table?</title>
	<atom:link href="http://weseetips.com/2009/05/07/how-to-parse-virtual-table/feed/" rel="self" type="application/rss+xml" />
	<link>http://weseetips.com/2009/05/07/how-to-parse-virtual-table/</link>
	<description>Gold mine of Visual C++ tricks!</description>
	<lastBuildDate>Thu, 12 Jan 2012 15:10:53 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: rmn</title>
		<link>http://weseetips.com/2009/05/07/how-to-parse-virtual-table/comment-page-1/#comment-323</link>
		<dc:creator>rmn</dc:creator>
		<pubDate>Tue, 13 Oct 2009 16:40:01 +0000</pubDate>
		<guid isPermaLink="false">http://weseetips.com/?p=1146#comment-323</guid>
		<description>Sorry for the late reply,
Thanks for the kind words :) I enjoy reading your posts as well.

Roman.</description>
		<content:encoded><![CDATA[<p>Sorry for the late reply,<br />
Thanks for the kind words <img src='http://weseetips.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I enjoy reading your posts as well.</p>
<p>Roman.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jijo.Raj</title>
		<link>http://weseetips.com/2009/05/07/how-to-parse-virtual-table/comment-page-1/#comment-322</link>
		<dc:creator>Jijo.Raj</dc:creator>
		<pubDate>Tue, 06 Oct 2009 04:06:09 +0000</pubDate>
		<guid isPermaLink="false">http://weseetips.com/?p=1146#comment-322</guid>
		<description>Hi Xpertz,

Thanks for the sharing the link.
And thanks a lot for adding my blog to your links section, buddy.

Are you the author of cpptalk? Its pretty nice blog!

Best Regards,
Jijo.</description>
		<content:encoded><![CDATA[<p>Hi Xpertz,</p>
<p>Thanks for the sharing the link.<br />
And thanks a lot for adding my blog to your links section, buddy.</p>
<p>Are you the author of cpptalk? Its pretty nice blog!</p>
<p>Best Regards,<br />
Jijo.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jijo.Raj</title>
		<link>http://weseetips.com/2009/05/07/how-to-parse-virtual-table/comment-page-1/#comment-321</link>
		<dc:creator>Jijo.Raj</dc:creator>
		<pubDate>Wed, 16 Sep 2009 14:21:26 +0000</pubDate>
		<guid isPermaLink="false">http://weseetips.com/?p=1146#comment-321</guid>
		<description>Hi Janson,

You have to initialize the DebugHelp library by calling SymInitialize().
And make sure that you have enabled debug symbols for your project.

Hope it helps!

Best Regards,
Jijo.</description>
		<content:encoded><![CDATA[<p>Hi Janson,</p>
<p>You have to initialize the DebugHelp library by calling SymInitialize().<br />
And make sure that you have enabled debug symbols for your project.</p>
<p>Hope it helps!</p>
<p>Best Regards,<br />
Jijo.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Janson lee</title>
		<link>http://weseetips.com/2009/05/07/how-to-parse-virtual-table/comment-page-1/#comment-320</link>
		<dc:creator>Janson lee</dc:creator>
		<pubDate>Sat, 12 Sep 2009 20:53:07 +0000</pubDate>
		<guid isPermaLink="false">http://weseetips.com/?p=1146#comment-320</guid>
		<description>Hi JiJo

This is not directly related to parsing the virtual table but it is related to the dbghelp.dll

I noticed on the msdn site

http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/488135b1-2f92-4d3a-aafb-f9eb56b1736f

that  you suggested to use the SymFromName routine to obtain
the SYMBOL_Info.address and cast it to a function pointer to call the function directly.

This does not seem to work for me, Is there some step that has to be applied to SYMBOL_Info.Address before it can be used as a function pointer.</description>
		<content:encoded><![CDATA[<p>Hi JiJo</p>
<p>This is not directly related to parsing the virtual table but it is related to the dbghelp.dll</p>
<p>I noticed on the msdn site</p>
<p><a href="http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/488135b1-2f92-4d3a-aafb-f9eb56b1736f" rel="nofollow">http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/488135b1-2f92-4d3a-aafb-f9eb56b1736f</a></p>
<p>that  you suggested to use the SymFromName routine to obtain<br />
the SYMBOL_Info.address and cast it to a function pointer to call the function directly.</p>
<p>This does not seem to work for me, Is there some step that has to be applied to SYMBOL_Info.Address before it can be used as a function pointer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xpertz</title>
		<link>http://weseetips.com/2009/05/07/how-to-parse-virtual-table/comment-page-1/#comment-319</link>
		<dc:creator>xpertz</dc:creator>
		<pubDate>Sat, 15 Aug 2009 21:37:05 +0000</pubDate>
		<guid isPermaLink="false">http://weseetips.com/?p=1146#comment-319</guid>
		<description>this is relevant as well:
http://cpptalk.wordpress.com/2009/08/14/changing-the-vtable-pointer/

i&#039;ve added your blog to my links section, nice work.</description>
		<content:encoded><![CDATA[<p>this is relevant as well:<br />
<a href="http://cpptalk.wordpress.com/2009/08/14/changing-the-vtable-pointer/" rel="nofollow">http://cpptalk.wordpress.com/2009/08/14/changing-the-vtable-pointer/</a></p>
<p>i&#8217;ve added your blog to my links section, nice work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marko</title>
		<link>http://weseetips.com/2009/05/07/how-to-parse-virtual-table/comment-page-1/#comment-318</link>
		<dc:creator>Marko</dc:creator>
		<pubDate>Mon, 10 Aug 2009 07:03:50 +0000</pubDate>
		<guid isPermaLink="false">http://weseetips.com/?p=1146#comment-318</guid>
		<description>Hey Jijo great thanks to you. But one ore thing if you disable RTTI option. Your program less useful. Thanks again.</description>
		<content:encoded><![CDATA[<p>Hey Jijo great thanks to you. But one ore thing if you disable RTTI option. Your program less useful. Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marko</title>
		<link>http://weseetips.com/2009/05/07/how-to-parse-virtual-table/comment-page-1/#comment-317</link>
		<dc:creator>Marko</dc:creator>
		<pubDate>Wed, 05 Aug 2009 23:46:31 +0000</pubDate>
		<guid isPermaLink="false">http://weseetips.com/?p=1146#comment-317</guid>
		<description>Hey Jijo Great thanks to you. But some problems stay with me.

Here corrected code: http://tinyurl.com/lt8c6y
I reuploaded to code share sites. Also you can view here: http://www.copypastecode.com/8327/

Here problems. When i build with debug mode and debug code then everyting works without problems but in release mode i cannot see what i saw in debug mod. I Dont know.  I will also upload pics. Thanks.</description>
		<content:encoded><![CDATA[<p>Hey Jijo Great thanks to you. But some problems stay with me.</p>
<p>Here corrected code: <a href="http://tinyurl.com/lt8c6y" rel="nofollow">http://tinyurl.com/lt8c6y</a><br />
I reuploaded to code share sites. Also you can view here: <a href="http://www.copypastecode.com/8327/" rel="nofollow">http://www.copypastecode.com/8327/</a></p>
<p>Here problems. When i build with debug mode and debug code then everyting works without problems but in release mode i cannot see what i saw in debug mod. I Dont know.  I will also upload pics. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jijo.Raj</title>
		<link>http://weseetips.com/2009/05/07/how-to-parse-virtual-table/comment-page-1/#comment-316</link>
		<dc:creator>Jijo.Raj</dc:creator>
		<pubDate>Fri, 31 Jul 2009 01:36:24 +0000</pubDate>
		<guid isPermaLink="false">http://weseetips.com/?p=1146#comment-316</guid>
		<description>Hi Marco,

The line &quot;DWORD* pBase = (DWORD*)( obj );&quot; is already present in ParseVtable() function. So it can be removed. If you put it outside, pBase become global variable and it needs obj to compile. Thats why compiler is popping error.

If the compilation gives more error feel free to post. I&#039;ll try to help you.

Regards,
Jijo.</description>
		<content:encoded><![CDATA[<p>Hi Marco,</p>
<p>The line &#8220;DWORD* pBase = (DWORD*)( obj );&#8221; is already present in ParseVtable() function. So it can be removed. If you put it outside, pBase become global variable and it needs obj to compile. Thats why compiler is popping error.</p>
<p>If the compilation gives more error feel free to post. I&#8217;ll try to help you.</p>
<p>Regards,<br />
Jijo.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marko</title>
		<link>http://weseetips.com/2009/05/07/how-to-parse-virtual-table/comment-page-1/#comment-315</link>
		<dc:creator>Marko</dc:creator>
		<pubDate>Thu, 30 Jul 2009 20:51:28 +0000</pubDate>
		<guid isPermaLink="false">http://weseetips.com/?p=1146#comment-315</guid>
		<description>Hey Jijo. I tried your code. But always failed. Compilation finished well but runtime object occurse acces violation. Im writing code here.

#define WINVER 0x0601

#define WIN32_LEAN_AND_MEAN
#include
//#include
#include
#include
#include

#pragma comment( lib, &quot;dbghelp.lib&quot; )

using namespace std;


void ParseVtable( void* obj );
void InitializeSymbols();
void GetSymbolNameFromAddr( DWORD SymbolAddress, string&amp; csSymbolName );

std::queue m_List;


// Get list of virtual functions.
void ParseVtable( void* obj )
{
    // Initialize symbols.
    InitializeSymbols();

    // We are going to parse vtable of CWinApp object.
DWORD* pBase = (DWORD*)( obj ); // This line gives error
    DWORD* pVptr = (DWORD*)*pBase;

    // Iterate through VirtualTable.
    DWORD Index = 0;
    DWORD FnAddr = pVptr[Index];
    while( FnAddr )
    {
        // Translate FunctionAddress to FunctionName.
        string FunctionName;
        GetSymbolNameFromAddr( FnAddr, FunctionName );

        // Format and add to list.
		CHAR Final[ 4096 ]; //CString Final;
		sprintf_s( Final, _countof(Final), &quot;%0x - %s&quot;, FnAddr, FunctionName.c_str() );//Final.Format( _T(&quot;%0x - %s&quot;), FnAddr, FunctionName.c_str() );
		m_List.push( Final );//m_List.AddString( Final );

        // Next function pointer.
        FnAddr = pVptr[++Index];
    }
}

// Initialize Symbol engine.
void InitializeSymbols()
{
    DWORD Options = SymGetOptions();
    Options &#124;= SYMOPT_DEBUG;
    Options &#124;= SYMOPT_UNDNAME;

    ::SymSetOptions( Options );

    // Initialize symbols.
    ::SymInitialize ( GetCurrentProcess(),
                      NULL,
                      TRUE );
}

// Get symbol name from address.
void GetSymbolNameFromAddr( DWORD SymbolAddress, string&amp; csSymbolName )
{
    DWORD64 Displacement = 0;
    SYMBOL_INFO_PACKAGE SymbolInfo = {0};
    SymbolInfo.si.SizeOfStruct  = sizeof( SYMBOL_INFO );
    SymbolInfo.si.MaxNameLen = sizeof(SymbolInfo.name);

    // Get symbol from address.
    ::SymFromAddr( GetCurrentProcess(),
                   SymbolAddress,
                   &amp;Displacement,
                   &amp;SymbolInfo.si );

    csSymbolName = SymbolInfo.si.Name;
}




int wmain()
{
	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF &#124; _CRTDBG_CHECK_ALWAYS_DF &#124; _CRTDBG_LEAK_CHECK_DF );
	_wsetlocale( LC_ALL, L&quot;trk&quot; );
	SetConsoleTitleW( L&quot;Howto Parse VTable&quot; );

	std::wstring wString = L&quot;Sallama&quot;;

	ParseVtable( (void*)&amp;wString );



	_CrtDumpMemoryLeaks();
	return wcin.get();
}


DWORD* pBase = (DWORD*)( obj ); // This line gives error

I dont know why but i assume you can answer well. Thansk.</description>
		<content:encoded><![CDATA[<p>Hey Jijo. I tried your code. But always failed. Compilation finished well but runtime object occurse acces violation. Im writing code here.</p>
<p>#define WINVER 0&#215;0601</p>
<p>#define WIN32_LEAN_AND_MEAN<br />
#include<br />
//#include<br />
#include<br />
#include<br />
#include</p>
<p>#pragma comment( lib, &#8220;dbghelp.lib&#8221; )</p>
<p>using namespace std;</p>
<p>void ParseVtable( void* obj );<br />
void InitializeSymbols();<br />
void GetSymbolNameFromAddr( DWORD SymbolAddress, string&amp; csSymbolName );</p>
<p>std::queue m_List;</p>
<p>// Get list of virtual functions.<br />
void ParseVtable( void* obj )<br />
{<br />
    // Initialize symbols.<br />
    InitializeSymbols();</p>
<p>    // We are going to parse vtable of CWinApp object.<br />
DWORD* pBase = (DWORD*)( obj ); // This line gives error<br />
    DWORD* pVptr = (DWORD*)*pBase;</p>
<p>    // Iterate through VirtualTable.<br />
    DWORD Index = 0;<br />
    DWORD FnAddr = pVptr[Index];<br />
    while( FnAddr )<br />
    {<br />
        // Translate FunctionAddress to FunctionName.<br />
        string FunctionName;<br />
        GetSymbolNameFromAddr( FnAddr, FunctionName );</p>
<p>        // Format and add to list.<br />
		CHAR Final[ 4096 ]; //CString Final;<br />
		sprintf_s( Final, _countof(Final), &#8220;%0x &#8211; %s&#8221;, FnAddr, FunctionName.c_str() );//Final.Format( _T(&#8220;%0x &#8211; %s&#8221;), FnAddr, FunctionName.c_str() );<br />
		m_List.push( Final );//m_List.AddString( Final );</p>
<p>        // Next function pointer.<br />
        FnAddr = pVptr[++Index];<br />
    }<br />
}</p>
<p>// Initialize Symbol engine.<br />
void InitializeSymbols()<br />
{<br />
    DWORD Options = SymGetOptions();<br />
    Options |= SYMOPT_DEBUG;<br />
    Options |= SYMOPT_UNDNAME;</p>
<p>    ::SymSetOptions( Options );</p>
<p>    // Initialize symbols.<br />
    ::SymInitialize ( GetCurrentProcess(),<br />
                      NULL,<br />
                      TRUE );<br />
}</p>
<p>// Get symbol name from address.<br />
void GetSymbolNameFromAddr( DWORD SymbolAddress, string&amp; csSymbolName )<br />
{<br />
    DWORD64 Displacement = 0;<br />
    SYMBOL_INFO_PACKAGE SymbolInfo = {0};<br />
    SymbolInfo.si.SizeOfStruct  = sizeof( SYMBOL_INFO );<br />
    SymbolInfo.si.MaxNameLen = sizeof(SymbolInfo.name);</p>
<p>    // Get symbol from address.<br />
    ::SymFromAddr( GetCurrentProcess(),<br />
                   SymbolAddress,<br />
                   &amp;Displacement,<br />
                   &amp;SymbolInfo.si );</p>
<p>    csSymbolName = SymbolInfo.si.Name;<br />
}</p>
<p>int wmain()<br />
{<br />
	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF );<br />
	_wsetlocale( LC_ALL, L&#8221;trk&#8221; );<br />
	SetConsoleTitleW( L&#8221;Howto Parse VTable&#8221; );</p>
<p>	std::wstring wString = L&#8221;Sallama&#8221;;</p>
<p>	ParseVtable( (void*)&amp;wString );</p>
<p>	_CrtDumpMemoryLeaks();<br />
	return wcin.get();<br />
}</p>
<p>DWORD* pBase = (DWORD*)( obj ); // This line gives error</p>
<p>I dont know why but i assume you can answer well. Thansk.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

