<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bob on Medical Device Software &#187; Vista</title>
	<atom:link href="http://rdn-consulting.com/blog/category/vista/feed/" rel="self" type="application/rss+xml" />
	<link>http://rdn-consulting.com/blog</link>
	<description>Software Development and Biomedical Engineering</description>
	<lastBuildDate>Wed, 02 May 2012 16:01:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<cloud domain='rdn-consulting.com' port='80' path='/blog/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>More on using a Named Mutex in Vista</title>
		<link>http://rdn-consulting.com/blog/2007/09/14/more-on-using-a-named-mutex-in-vista/</link>
		<comments>http://rdn-consulting.com/blog/2007/09/14/more-on-using-a-named-mutex-in-vista/#comments</comments>
		<pubDate>Sat, 15 Sep 2007 05:15:55 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Vista]]></category>

		<guid isPermaLink="false">http://rdn-consulting.com/blog/2007/09/14/more-on-using-a-named-mutex-in-vista/</guid>
		<description><![CDATA[This is a follow-up to the Kernel Object Namespace and Vista post. Those previous findings were made using an administrative user in Vista. When I tried creating a &#8216;Session\AppName&#8217; Mutex as a non-administrative user though, the application hung! Just to be clear, here is how (simplified) I&#8217;m creating the Mutex: string MutexName = @&#34;Session\AppName&#34;; bool [...]]]></description>
			<content:encoded><![CDATA[<p>This is a follow-up to the <a href="http://rdn-consulting.com/blog/2007/08/20/kernel-object-namespace-and-vista/" target="_blank">Kernel Object Namespace and Vista</a> post. Those previous findings were made using an administrative user in Vista. When I tried creating a &#8216;Session\AppName&#8217; Mutex as a <strong>non-administrative</strong> user though, the application hung!</p>
<p>Just to be clear, here is how (simplified) I&#8217;m creating the Mutex:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">string</span> MutexName <span style="color: #008000;">=</span> <span style="color: #666666;">@&quot;Session\AppName&quot;</span><span style="color: #008000;">;</span>
<span style="color: #6666cc; font-weight: bold;">bool</span> mutexWasCreated<span style="color: #008000;">;</span>
MutexSecurity mSec <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MutexSecurity<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
MutexAccessRule rule <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MutexAccessRule<span style="color: #008000;">&#40;</span>
      <span style="color: #008000;">new</span> SecurityIdentifier<span style="color: #008000;">&#40;</span>WellKnownSidType<span style="color: #008000;">.</span><span style="color: #0000FF;">WorldSid</span>, <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>,
      MutexRights<span style="color: #008000;">.</span><span style="color: #0000FF;">FullControl</span>,AccessControlType<span style="color: #008000;">.</span><span style="color: #0000FF;">Allow</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
mSec<span style="color: #008000;">.</span><span style="color: #0000FF;">AddAccessRule</span><span style="color: #008000;">&#40;</span>rule<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
Mutex m <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Mutex<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">false</span>, mutexName, <span style="color: #0600FF; font-weight: bold;">out</span> mutexWasCreated, mSec<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>The hang occurs when the <a href="http://msdn2.microsoft.com/en-us/library/9zf2f5bz(vs.80).aspx" target="_blank">Mutex is created</a>. By hang I mean that the process just spins its wheels sucking 50-60% of the CPU and will continue until it&#8217;s killed. Based on <a href="http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx" target="_blank">WinDbg</a> analysis it&#8217;s either stuck in the underlaying Win32 <code>CreateMutex()</code> call or <code>CreateMutex()</code> is being called repeatedly. It&#8217;s probably the later.</p>
<p>When &#8216;Local\&#8217; or &#8216;Global\&#8217; are used, the Mutex is created fine! As noted before, &#8216;Local\&#8217; doesn&#8217;t work for other reasons so I&#8217;m stuck using the &#8216;Global\&#8217; namespace. Go figure?</p>
]]></content:encoded>
			<wfw:commentRss>http://rdn-consulting.com/blog/2007/09/14/more-on-using-a-named-mutex-in-vista/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Kernel Object Namespace and Vista</title>
		<link>http://rdn-consulting.com/blog/2007/08/20/kernel-object-namespace-and-vista/</link>
		<comments>http://rdn-consulting.com/blog/2007/08/20/kernel-object-namespace-and-vista/#comments</comments>
		<pubDate>Tue, 21 Aug 2007 00:17:57 +0000</pubDate>
		<dc:creator>Bob</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[Vista]]></category>

		<guid isPermaLink="false">http://rdn-consulting.com/blog/2007/08/20/kernel-object-namespace-and-vista/</guid>
		<description><![CDATA[Just a quick development note: According to Kernel Object Namespaces objects can have one of three predefined prefixes &#8212; &#8216;Local\&#8217;, &#8216;Global\&#8217;, or &#8216;Session\&#8217;. For Win2K/XP I&#8217;ve always used the &#8216;Local\&#8217; prefix, which works fine. My primary use is with a Mutex to determine that a single instance of an application is running (like here). I [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick development note:</p>
<p>According to <a href="http://msdn2.microsoft.com/en-us/library/Aa382954.aspx" target="_blank">Kernel Object Namespaces</a> objects can have one of three predefined prefixes &#8212; &#8216;Local\&#8217;, &#8216;Global\&#8217;, or &#8216;Session\&#8217;.  For Win2K/XP I&#8217;ve always used the &#8216;Local\&#8217; prefix, which works fine.  My primary use is with a Mutex to determine that a single instance of an application is running (like <a href="http://www.codeproject.com/csharp/singleinstanceapplication.asp" target="_blank">here</a>).  I also use the Mutex from a system service to discover if a GUI application is available for messaging. When trying to run the some code on Vista I found that the &#8216;Local\&#8217; namespace does not work when Mutex.OpenExisting() is called from a the system service which is owned by a different user (from the same user, it works fine).  So it appears that the &#8216;Local\&#8217; prefix in Vista has a different behavior for the client session namespace than it does in Win2K/XP.</p>
<p>I searched around for a solution, but was unable to find a definitive answer. I did find a post about the <a href="http://blogs.msdn.com/junfeng/archive/2006/04/23/581161.aspx" target="_blank">Private Object Namespace</a> which alludes to Vista kernel changes, but that&#8217;s all. Here&#8217;s what I determined empirically:</p>
<p></p>
<table class="wptable rowstyle-alt" id="wptable-2"  cellspacing="1">
	<thead>
	<tr>
		<th class="sortable" style="width:75px" align="center">Win2K</th>
		<th class="sortable" style="width:75px" align="center">XP</th>
		<th class="sortable" style="width:75px" align="center">Vista</th>
		<th class="sortable" style="width:300px" align="left">Namespace</th>
	</tr>
	</thead>
	<tr>
		<td style="width:75px" align="center">ok</td>
		<td style="width:75px" align="center">ok</td>
		<td style="width:75px" align="center">NO</td>
		<td style="width:300px" align="left">Local\AppName</td>
	</tr>
	<tr>
		<td style="width:75px" align="center">NO</td>
		<td style="width:75px" align="center">ok</td>
		<td style="width:75px" align="center">ok</td>
		<td style="width:300px" align="left">Session\AppName</td>
	</tr>
	<tr>
		<td style="width:75px" align="center">ok</td>
		<td style="width:75px" align="center">ok</td>
		<td style="width:75px" align="center">ok</td>
		<td style="width:300px" align="left">Global\AppName</td>
	</tr>
	<tr>
		<td style="width:75px" align="center">NO</td>
		<td style="width:75px" align="center">ok</td>
		<td style="width:75px" align="center">ok</td>
		<td style="width:300px" align="left">AppName (same as Session)</td>
	</tr>
</table><p>
</p>
<p>The NO entries in the table mean that the namespace did <strong>not</strong> work. So, it appears that in order to support all three Windows versions I&#8217;d have to use the &#8216;Global\&#8217; namespace.  This is not a good solution. Unless I find another way, I&#8217;ll have to determine the OS version and select the appropriate namespace at runtime (&#8216;Session\&#8217; for Vista, &#8216;Local\&#8217; for Win2K/XP).</p>
]]></content:encoded>
			<wfw:commentRss>http://rdn-consulting.com/blog/2007/08/20/kernel-object-namespace-and-vista/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

