<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Special Command: Using ??, @@c++() and poi() with C/C++ Expressions</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2008/03/04/special-commands-using-c-and-poi-with-c-c-expressions.aspx</link><description>I really like using C/C++ expressions from WinDbg. It’s a natural way to extract information from C and C++ applications if you know these programming languages; therefore, I think it’s useful to share how to do this. First, let’s talk about poi(). poi()</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>MSDN Blog Postings  &amp;raquo; Special Commands: Using ??, @@c++() and poi() with C/C++ Expressions</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2008/03/04/special-commands-using-c-and-poi-with-c-c-expressions.aspx#8024236</link><pubDate>Tue, 04 Mar 2008 13:41:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8024236</guid><dc:creator>MSDN Blog Postings  » Special Commands: Using ??, @@c++() and poi() with C/C++ Expressions</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://msdnrss.thecoderblogs.com/2008/03/04/special-commands-using-c-and-poi-with-cc-expressions/"&gt;http://msdnrss.thecoderblogs.com/2008/03/04/special-commands-using-c-and-poi-with-cc-expressions/&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Special Commands: Using ??, @@c++() and poi() with C/C++ Expressions | Secure Software Engineering Blog</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2008/03/04/special-commands-using-c-and-poi-with-c-c-expressions.aspx#8024934</link><pubDate>Tue, 04 Mar 2008 14:34:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8024934</guid><dc:creator>Special Commands: Using ??, @@c++() and poi() with C/C++ Expressions | Secure Software Engineering Blog</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.secure-software-engineering.com/2008/03/04/special-commands-using-c-and-poi-with-cc-expressions/"&gt;http://www.secure-software-engineering.com/2008/03/04/special-commands-using-c-and-poi-with-cc-expressions/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>Interesting Finds: March 4, 2008</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2008/03/04/special-commands-using-c-and-poi-with-c-c-expressions.aspx#8024945</link><pubDate>Tue, 04 Mar 2008 14:35:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8024945</guid><dc:creator>Jason Haley</dc:creator><description /></item><item><title>re: Special Command: Using ??, @@c++() and poi() with C/C++ Expressions</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2008/03/04/special-commands-using-c-and-poi-with-c-c-expressions.aspx#8959232</link><pubDate>Fri, 19 Sep 2008 21:23:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8959232</guid><dc:creator>rembo</dc:creator><description>&lt;p&gt;Hi, I'm trying to learn how to use C/C++ expressions in WinDbg. Thanks for your article! I am having trouble with the following:&lt;/p&gt;
&lt;p&gt;0:000&amp;gt; ?? * (long*) ((@esp)+12) == -13&lt;/p&gt;
&lt;p&gt;bool true&lt;/p&gt;
&lt;p&gt;0:000&amp;gt; .if &amp;nbsp;(-13 == -13) {.echo do whatever}&lt;/p&gt;
&lt;p&gt;do whatever&lt;/p&gt;
&lt;p&gt;so far, so good.&lt;/p&gt;
&lt;p&gt;But how do I use this in a conditional? ---&lt;/p&gt;
&lt;p&gt;0:000&amp;gt; .if &amp;nbsp;(?? * (long*) ((@esp)+12) == -13) {.echo do whatever}&lt;/p&gt;
&lt;p&gt;Syntax error at '?? * (long*) ((@esp)+12) == -13) {.echo do whatever}'&lt;/p&gt;
&lt;p&gt;0:000&amp;gt; .if &amp;nbsp;(? * (long*) ((@esp)+12) == -13) {.echo do whatever}&lt;/p&gt;
&lt;p&gt;Syntax error at '? * (long*) ((@esp)+12) == -13) {.echo do whatever}&lt;/p&gt;</description></item><item><title>re: Special Command: Using ??, @@c++() and poi() with C/C++ Expressions</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2008/03/04/special-commands-using-c-and-poi-with-c-c-expressions.aspx#8960279</link><pubDate>Sun, 21 Sep 2008 02:49:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8960279</guid><dc:creator>Roberto Farah</dc:creator><description>&lt;p&gt;I'm not sure if I understand your question, but I'll try to answer it anyway :) &lt;/p&gt;
&lt;p&gt;If you are comparing registers you don't need to use a cast, for example:&lt;/p&gt;
&lt;p&gt;0:000&amp;gt; r @ecx&lt;/p&gt;
&lt;p&gt;ecx=00000030 &amp;nbsp; &amp;lt;-- By default this is hexadecimal.&lt;/p&gt;
&lt;p&gt;0:000&amp;gt; .if(@ecx == 0x30){.echo True}&lt;/p&gt;
&lt;p&gt;True&lt;/p&gt;
&lt;p&gt;0:000&amp;gt; .formats @ecx&lt;/p&gt;
&lt;p&gt;Evaluate expression:&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Hex: &amp;nbsp; &amp;nbsp; 00000030&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Decimal: 48 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;-- 0x30 == 0n48&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Octal: &amp;nbsp; 00000000060&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Binary: &amp;nbsp;00000000 00000000 00000000 00110000&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Chars: &amp;nbsp; ...0 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;-- 0x30 = ASCII char 0&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Time: &amp;nbsp; &amp;nbsp;Wed Dec 31 16:00:48 1969&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Float: &amp;nbsp; low 6.72623e-044 high 0&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Double: &amp;nbsp;2.37152e-322&lt;/p&gt;
&lt;p&gt;0:000&amp;gt; .if(@ecx == 0n48){.echo True}&lt;/p&gt;
&lt;p&gt;True&lt;/p&gt;
&lt;p&gt;0:000&amp;gt; .if(@ecx == '0'){.echo True}&lt;/p&gt;
&lt;p&gt;True&lt;/p&gt;
&lt;p&gt;The expressions above are equivalent. The content in memory can be interpreted as char, hexadecimal, decimal, octal, binary... you choose.&lt;/p&gt;
&lt;p&gt;Now, if you want to compare C/C++ variables, you can use this approach:&lt;/p&gt;
&lt;p&gt;class CSize Size = class CSize&lt;/p&gt;
&lt;p&gt;0:000&amp;gt; dt Size&lt;/p&gt;
&lt;p&gt;Local var @ 0x12f890 Type CSize&lt;/p&gt;
&lt;p&gt; &amp;nbsp; +0x000 cx &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : 30&lt;/p&gt;
&lt;p&gt; &amp;nbsp; +0x004 cy &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : 39&lt;/p&gt;
&lt;p&gt;Now I use the C++ expression evaluator:&lt;/p&gt;
&lt;p&gt;0:000&amp;gt; .if(@@c++(Size.cx == 30)){.echo True}.else{.echo False}&lt;/p&gt;
&lt;p&gt;True&lt;/p&gt;
&lt;p&gt;0:000&amp;gt; .if(@@c++(Size.cx == 20)){.echo True}.else{.echo False}&lt;/p&gt;
&lt;p&gt;False&lt;/p&gt;
&lt;p&gt;Did it answer your question?&lt;/p&gt;</description></item><item><title>re: Special Command: Using ??, @@c++() and poi() with C/C++ Expressions</title><link>http://blogs.msdn.com/debuggingtoolbox/archive/2008/03/04/special-commands-using-c-and-poi-with-c-c-expressions.aspx#8961558</link><pubDate>Mon, 22 Sep 2008 23:37:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8961558</guid><dc:creator>rembo</dc:creator><description>&lt;p&gt;Yes, thank you for your detailed explanation, that was very helpful! I guess I was confused when to use ?, when @@c++ and when ?? , but you cleared it up. Apologies if my question was unclear; I understand how to use registers, but I was trying to use a parameter on the stack, and it seemed I had to cast it the way I did.&lt;/p&gt;</description></item></channel></rss>