<?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>Radius of Rainbow : Tech Gyaan</title><link>http://blogs.msdn.com/ashutosh_galande/archive/tags/Tech+Gyaan/default.aspx</link><description>Tags: Tech Gyaan</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>VS debugger can do the trick with $user</title><link>http://blogs.msdn.com/ashutosh_galande/archive/2006/06/26/647846.aspx</link><pubDate>Tue, 27 Jun 2006 00:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:647846</guid><dc:creator>Ashutosh Galande</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/ashutosh_galande/comments/647846.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ashutosh_galande/commentrss.aspx?PostID=647846</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ashutosh_galande/rsscomments.aspx?PostID=647846</wfw:comment><description>&lt;P&gt;It's a general perception that windbg and cdb are tools for a power debugger. Quite true! With the extensions and powerful commands, they provide the toolset you need to literally rip apart any process. Looks like VS debugger is getting there too. &lt;/P&gt;
&lt;P&gt;Just last week I realized that Visual Studio 2005&amp;nbsp;has something called pseudovariables. These curiously named variables can yield you some power that you are so used to in the windbg land. In fact MSDN has &lt;A href="http://msdn2.microsoft.com/en-us/library/ms164891.aspx"&gt;documented &lt;/A&gt;these for long time.&lt;/P&gt;
&lt;P&gt;Managed code can only use the $user and $exception variable of these.&amp;nbsp;Try it out. Particularly $user. It gives a lot of helpful information on process and thread tokens. Pretty helpful if you are debugging impersonation problems in the managed world. Just type it in the watch window and debug away!!!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=647846" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ashutosh_galande/archive/tags/Tech+Gyaan/default.aspx">Tech Gyaan</category></item><item><title>Administrators? Whats that?</title><link>http://blogs.msdn.com/ashutosh_galande/archive/2005/12/25/507349.aspx</link><pubDate>Mon, 26 Dec 2005 04:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:507349</guid><dc:creator>Ashutosh Galande</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/ashutosh_galande/comments/507349.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ashutosh_galande/commentrss.aspx?PostID=507349</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ashutosh_galande/rsscomments.aspx?PostID=507349</wfw:comment><description>&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&lt;FONT face=Arial&gt;It might not be as glorious as the "root" but Administrators command similar rights and privileges. But not every locale uses that string to identify the all powerful group of users. That might introduce interesting bugs.&amp;nbsp;Even in some &lt;/FONT&gt;&lt;A href="http://support.microsoft.com/?kbid=258163"&gt;&lt;FONT face=Arial&gt;microsoft&amp;nbsp;tools&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial&gt;. &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&lt;FONT face=Arial&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&lt;FONT face=Arial&gt;Use of &lt;/FONT&gt;&lt;A href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q243330 "&gt;&lt;FONT face=Arial&gt;well known SID&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial&gt; is how these sort of bugs can be avoided. .Net has &lt;SPAN style="COLOR: black; FONT-FAMILY: Arial"&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/system.security.principal.wellknownsidtype.aspx"&gt;WellKnownSidType enumeration&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Arial"&gt;that makes it quite easy but in the unmanaged world, it’s a 2 step process. You have to create the SID yourself. The constants are defined in sddl.h to get admin SID you can do something like this: &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&lt;FONT face="Courier New"&gt;PSID GetAdminSID()&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&lt;FONT face="Courier New"&gt;{&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; mso-outline-level: 2"&gt;&lt;FONT face="Courier New"&gt;SID_IDENTIFIER_AUTHORITY SIDAuth = SECURITY_NT_AUTHORITY;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; mso-outline-level: 2"&gt;&lt;FONT face="Courier New"&gt;PSID pSID = NULL;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; mso-outline-level: 2"&gt;&lt;FONT face="Courier New"&gt;if(! AllocateAndInitializeSid( &amp;amp;SIDAuth, 2,&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; mso-outline-level: 3"&gt;&lt;FONT face="Courier New"&gt;SECURITY_BUILTIN_DOMAIN_RID,&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; mso-outline-level: 3"&gt;&lt;FONT face="Courier New"&gt;DOMAIN_ALIAS_RID_ADMINS,&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; mso-outline-level: 3"&gt;&lt;FONT face="Courier New"&gt;0, 0, 0, 0, 0, 0,&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; mso-outline-level: 3"&gt;&lt;FONT face="Courier New"&gt;&amp;amp;pSID) ) &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; mso-outline-level: 3"&gt;&lt;FONT face="Courier New"&gt;{&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1.5in; FONT-FAMILY: Verdana; mso-outline-level: 4"&gt;&lt;FONT face="Courier New"&gt;ThrowExceptionUsingHr(HRESULT_FROM_WIN32(GetLastError()));&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; mso-outline-level: 3"&gt;&lt;FONT face="Courier New"&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 1in; FONT-FAMILY: Verdana; mso-outline-level: 3"&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in 0in 0in 0.5in; FONT-FAMILY: Verdana; mso-outline-level: 2"&gt;&lt;FONT face="Courier New"&gt;return pSID;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&lt;FONT face="Courier New"&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&lt;FONT face=Arial&gt;Make sure that you free the SID created above using FreeSid()&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&lt;FONT face=Arial&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="FONT-SIZE: 10pt; MARGIN: 0in; FONT-FAMILY: Verdana; mso-outline-level: 1"&gt;&lt;FONT face=Arial&gt;Edit: &lt;A href="http://blogs.msdn.com/michkap/"&gt;Michael Kaplan&lt;/A&gt; has &lt;A href="http://blogs.msdn.com/michkap/archive/2005/12/27/507404.aspx"&gt;more details&lt;/A&gt; about the bug in Microsoft tools that I&amp;nbsp;was referring to above.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=507349" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ashutosh_galande/archive/tags/Tech+Gyaan/default.aspx">Tech Gyaan</category></item></channel></rss>