<?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>Fooling Around &#187; Technology</title>
	<atom:link href="http://alax.info/blog/category/technology/feed" rel="self" type="application/rss+xml" />
	<link>http://alax.info/blog</link>
	<description>// Software Production Line</description>
	<lastBuildDate>Fri, 03 Feb 2012 22:49:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>File Mappings: Virtual Memory and Virtual Address Space</title>
		<link>http://alax.info/blog/1325</link>
		<comments>http://alax.info/blog/1325#comments</comments>
		<pubDate>Thu, 15 Dec 2011 23:36:34 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[WTL]]></category>
		<category><![CDATA[32-bit]]></category>
		<category><![CDATA[CreateFileMapping]]></category>
		<category><![CDATA[file mapping]]></category>
		<category><![CDATA[MapViewOfFile]]></category>
		<category><![CDATA[RAM]]></category>
		<category><![CDATA[virtual memory]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1325</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1325" title="File Mappings: Virtual Memory and Virtual Address Space"></a>More and more applications hit the Windows limit of available address space for 32-bit applications, and the whole concept becomes more important for understanding due to necessity to work things around. A thing, which is more or less easy to &#8230;<p class="read-more"><a href="http://alax.info/blog/1325">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1325" title="File Mappings: Virtual Memory and Virtual Address Space"></a><p>More and more applications hit the Windows limit of available <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366912%28v=VS.85%29.aspx">address space</a> for 32-bit applications, and the whole concept becomes more important for understanding due to necessity to work things around.</p>
<p>A thing, which is more or less easy to understand, is that a user mode 32-bit application can address 2^32 addresses. The addresses are not directly physical RAM and the operating system is responsible for management of the mapping addresses into RAM as a part of virtual memory manager operation. Paged memory organization is <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366914%28v=VS.85%29.aspx">well documented on MSDN</a>, and the questions has been raised numerous times. An interesting question is whether a 32-bit application can effectively manage memory amounts exceeding address space limits.</p>
<p>Back in 80386 times, the systems could address megabytes of RAM in 16-bit code through <a href="http://en.wikipedia.org/wiki/EXtended_Memory_Specification#eXtended_Memory_Specification_.28XMS.29">XMS</a> and <a href="http://en.wikipedia.org/wiki/Expanded_memory">EMS</a> services. The application could access &#8220;high&#8221; memory addresses by requesting mapping portions of RAM into lower megabyte address space. In some way similar technique is also here for 32-bit applications in Windows through use of <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366556%28v=vs.85%29.aspx">file mappings</a>.</p>
<p>A regular memory backed file mapping requests Windows to reserve a memory block which becomes available for mapping into address space of one or more processes. Creating file mapping itself does not imply mapping and this leaves a great option for the owner to allocate more data than it can actually map into address space: if 32-bit process virtual address space is fundamentally constrained, the file mapping allocation space is more loosely limited by amount of physical memory and paging file. The application can allocate 2, 3, 4 and more gigabytes of memory &#8211; it just cannot still map it all together into address space and make it available simultaneously.</p>
<p>The FileMappingVirtualAddress utility does a simple thing:</p>
<ul>
<li>on startup it allocates (<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366537%28v=VS.85%29.aspx">CreateFileMapping</a>) as many 256 MB file mappings as operating system would allow, and shows it in a list</li>
<li>each time a user checks a box, the application maps (<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366761%28v=vs.85%29.aspx">MapViewOfFile</a>) corresponding file mapping into address space; unchecking a box unmaps the view</li>
<li>the caption shows currently used and maximal available virtual address space</li>
</ul>
<p><img class="alignnone size-full wp-image-1326" title="Allocated and Mapped 256 MB File Mappings" src="http://alax.info/blog/wp-content/uploads/2011/12/Image001.png" alt="" width="462" height="426" /></p>
<p>A plain 32-bit version of the application allocated 51 blocks for me (which totals in 13 GB of memory, with 8 GB physical RAM installed in the system). The allocation takes place immediately because the operating system does not actually make all this memory prepared for use &#8211; the actual pages would be allocated and ready to use on demand when the application requires them.</p>
<p><strong>The most important part made so obvious is that the 32-bit application succeeds in allocating well over 4 GB, which is maximal virtual address space it can ever get.</strong></p>
<p>The virtual address space in use is only 1641 MB and another request to map an additional section with <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366761%28v=vs.85%29.aspx">MapViewOfFile</a> would fail (the default address space limit is 2 GB) &#8211; space fragmentation make mapping unavailable earlier than we actually use the whole space, since the API would need to allocate contiguous range of addresses to satisfy the request.</p>
<p><img class="alignnone size-full wp-image-1327" title="Error Hitting Virtual Address Space Limit" src="http://alax.info/blog/wp-content/uploads/2011/12/Image002.png" alt="" width="426" height="171" /></p>
<p>32-bit application built with <a href="http://msdn.microsoft.com/en-us/library/wz223b1z%28v=VS.100%29.aspx">/LARGEADDRESSAWARE</a> parameter might manage to do more allocations: 64-bit versions of Windows provide 4 GB of addresses to 32-bit processes. 32-bit operating systems might also be extending the limit in case of <a href="http://support.microsoft.com/kb/291988">4GB RAM Tuning</a> (which would typically be 3 GB of space for a process).</p>
<p><img class="alignnone size-full wp-image-1328" title="File Mappings with /LARGEADDRESSAWARE" src="http://alax.info/blog/wp-content/uploads/2011/12/Image003.png" alt="" width="462" height="426" /></p>
<p>Finally, 64-bit build of the application is free from virtual address space limit as the limit is <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa384271%28v=VS.85%29.aspx">8 terabytes</a>. The mapping is again instantaneous because actual RAM will be supplied on first request to mapped pages only.</p>
<p><img class="alignnone size-full wp-image-1329" title="File Mappings in 64-bit Code" src="http://alax.info/blog/wp-content/uploads/2011/12/Image004.png" alt="" width="462" height="426" /></p>
<p>A binary [<a href="http://www.alax.info/svn/public/trunk/Utilities/FileMappingVirtualAddress/Win32/Release/FileMappingVirtualAddress.exe">Win32</a>, <a href="http://www.alax.info/svn/public/trunk/Utilities/FileMappingVirtualAddress/Win32/Release%20with%20Large%20Address%20Aware/FileMappingVirtualAddress.exe">Win32 with /LARGEADDRESSAWARE</a>, <a href="http://www.alax.info/svn/public/trunk/Utilities/FileMappingVirtualAddress/x64/Release/FileMappingVirtualAddress.exe">x64</a>] and partial Visual C++ .NET 2010 <a href="http://www.alax.info/trac/public/browser/trunk/Utilities/FileMappingVirtualAddress">partial source code</a> are available from SVN.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1325/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DirectShow SDK at Crime Scene Investigation Service</title>
		<link>http://alax.info/blog/1322</link>
		<comments>http://alax.info/blog/1322#comments</comments>
		<pubDate>Sun, 27 Nov 2011 11:03:46 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[amusing]]></category>
		<category><![CDATA[DirectShow]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1322</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1322" title="DirectShow SDK at Crime Scene Investigation Service"></a>According to CSI: Crime Scene Investigation, Season 06 Episode 13 (17:04), investigators are using snake scope camera with DirectShow AMCAP tool to present the captured image:]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1322" title="DirectShow SDK at Crime Scene Investigation Service"></a><p>According to <em>CSI: Crime Scene Investigation</em>, Season 06 Episode 13 (17:04), investigators are using snake scope camera with <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd373424%28v=vs.85%29.aspx">DirectShow AMCAP</a> tool to present the captured image:</p>
<p><img class="alignnone size-full wp-image-1323" title="AmCap and CSI" src="http://alax.info/blog/wp-content/uploads/2011/11/csi.s06e13.rus_.eng_.dvdrip.novafilm.tv_.avi_snapshot_17.04_2011.11.27_12.57.05-2.jpg" alt="" width="624" height="352" /></p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1322/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hardware assisted memory corruption detection</title>
		<link>http://alax.info/blog/1319</link>
		<comments>http://alax.info/blog/1319#comments</comments>
		<pubDate>Sat, 19 Nov 2011 17:26:25 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Seriously]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[corruption]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[detection]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[protection]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1319</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1319" title="Hardware assisted memory corruption detection"></a>So you got a memory corruption issue with a piece of software. It comes in a unique scenario along the line of having a huge pile of weird code running well most of the time and then, right out of &#8230;<p class="read-more"><a href="http://alax.info/blog/1319">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1319" title="Hardware assisted memory corruption detection"></a><p>So you got a memory corruption issue with a piece of software. It comes in a unique scenario along the line of having a huge pile of weird code running well most of the time and then, right out of the blue, a corruption takes place followed by unexpected code execution and unstable software state in general.</p>
<p>The biggest problem with memory corruption is that a fragment of code is modifying a memory block which it does not own, and it has no idea who actually is the owner of the block, while the real owner has no timely way to detect the modification. You only face the consequences being unable to capture the modification moment in first place.</p>
<p>To get back to the original cause, an engineer has to drop into a time machine, turn back time and step back to where the trouble took originally place. As developers are not actually given state-of-the-art time machines, the time turning step is speculative.</p>
<h4>CVirtualHeapPtr Class: Memory with Exception-on-Write access mode</h4>
<p>At the same time a Windows platform developer is or might be aware of <a href="http://msdn.microsoft.com/en-us/library/ms810627.aspx">virtual memory API</a> which among other things provides user mode application with capabilities to define memory protection modes. Having this on hands opens unique opportunity to apply read-only protection (PAGE_READONLY) onto a memory block and have exception raised at the very moment of unexpected memory modification, having call stack showing up a source of the problem. I refer to this mode of operation as &#8220;hardware assisted&#8221; because the access violation exception/condition would be generated purely in hardware without any need to additionally do any address comparison in code.</p>
<p>Needless to say that this way is completely convenient for the developer as he does not need to patch the monstrous application all around in order to compare access addresses against read-only fragment. Instead, a block defined as read-only will be immediately available as such for the whole process almost without any performance overhead.</p>
<p>As ATL provides a set of memory allocator templates (<a href="http://msdn.microsoft.com/en-us/library/3by29yh0%28v=vs.80%29.aspx">CHeapPtr</a> for heap backed memory blocks, allocated with <em>CCRTAllocator</em>, alternate options include <a href="http://msdn.microsoft.com/en-us/library/80zw33a6%28v=vs.80%29.aspx">CComHeapPtr</a> with <em>CComAllocator</em> wrapping <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms692727%28v=vs.85%29.aspx">CoTaskMemAlloc</a>/<em>CoTaskMemFree</em> API), let us make an alternate allocator option that mimic well-known class interface and would facilitate corruption detection.</p>
<p>Because virtual memory allocation unit is a page, and protection mode is defined for the whole page, this would be the allocation granularity. For a single allocated byte we would need to request <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms724958%28v=vs.85%29.aspx">SYSTEM_INFO::dwPageSize</a> bytes of virtual memory. Unlike normal memory heap manager, we have no way to share pages between allocations as we would be unable to effectively apply protection modes. This would definitely increase application pressure onto virtual memory, but is still acceptable for the sacred task of troubleshooting.</p>
<p>We define a <em>CVirtualAllocator</em> class to be compatible with ATL&#8217;s <em>CCRTAllocator</em>, however based on <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366887%28v=vs.85%29.aspx">VirtualAlloc</a>/<em>VirtualFree</em> API. The smart pointer class over memory pointer would be defined as follows:</p>
<pre style="color: #000000; background: #ffffff;"><span style="color: #800000; font-weight: bold;">template</span> <span style="color: #800080;">&lt;</span><span style="color: #800000; font-weight: bold;">typename</span> T<span style="color: #800080;">&gt;</span>
<span style="color: #800000; font-weight: bold;">class</span> CVirtualHeapPtr <span style="color: #800080;">:</span>
    <span style="color: #800000; font-weight: bold;">public</span> CHeapPtr<span style="color: #800080;">&lt;</span>T<span style="color: #808030;">,</span> CVirtualAllocator<span style="color: #800080;">&gt;</span>
<span style="color: #800080;">{</span>
<span style="color: #800000; font-weight: bold;">public</span><span style="color: #e34adc;">:</span>
<span style="color: #696969;">// CVirtualHeapPtr</span>
    CVirtualHeapPtr<span style="color: #808030;">(</span><span style="color: #808030;">)</span> <span style="color: #800000; font-weight: bold;">throw</span><span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">explicit</span> CVirtualHeapPtr<span style="color: #808030;">(</span>_In_ T<span style="color: #808030;">*</span> pData<span style="color: #808030;">)</span> <span style="color: #800000; font-weight: bold;">throw</span><span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #603000;">VOID</span> SetProtection<span style="color: #808030;">(</span><span style="color: #603000;">DWORD</span> nProtection<span style="color: #808030;">)</span>
    <span style="color: #800080;">{</span>
        <span style="color: #696969;">// </span><span style="color: #ffffff; background: #808000;">TODO: ...</span>
    <span style="color: #800080;">}</span>
<span style="color: #800080;">}</span><span style="color: #800080;">;</span></pre>
<p>The <em>SetProtection</em> method is to define memory protection for the memory block. Full code for the classes <a href="http://www.alax.info/trac/public/browser/trunk/Utilities/VirtualHeapPtr/VirtualHeapPtr.h#L9">is available on Trac here</a> (lines 9-132):</p>
<ul>
<li><em>CGlobalVirtualAllocator</em> class is a singleton querying operating system for virtual memory page size, and provides alignment method</li>
<li><em>CVirtualAllocator</em> class is a <em>CCRTAllocator</em>-compatible allocator class</li>
<li><em>CVirtualHeapPtr</em> class is smart template class wrapping a pointer to allocated memory</li>
</ul>
<p>Use case code will be as follows. &#8220;SetProtection(PAGE_READONLY)&#8221; enables protection on memory block and turns on exception generation at the moment memory block modification attempt. &#8220;SetProtection(PAGE_READWRITE)&#8221; would restore normal mode of memory operation.</p>
<pre style="color: #000000; background: #ffffff;">CVirtualHeapPtr<span style="color: #800080;">&lt;</span><span style="color: #603000;">BYTE</span><span style="color: #800080;">&gt;</span> p<span style="color: #800080;">;</span>
p<span style="color: #808030;">.</span>Allocate<span style="color: #808030;">(</span><span style="color: #008c00;">2</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
p<span style="color: #808030;">[</span><span style="color: #008c00;">1</span><span style="color: #808030;">]</span> <span style="color: #808030;">=</span> <span style="color: #008000;">0x01</span><span style="color: #800080;">;</span>
p<span style="color: #808030;">.</span>SetProtection<span style="color: #808030;">(</span>PAGE_READONLY<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
<span style="color: #696969;">// NOTE: Compile with /EHa on order to catch the exception</span>
_ATLTRY
<span style="color: #800080;">{</span>
    p<span style="color: #808030;">[</span><span style="color: #008c00;">1</span><span style="color: #808030;">]</span> <span style="color: #808030;">=</span> <span style="color: #008000;">0x02</span><span style="color: #800080;">;</span>
    <span style="color: #696969;">// NOTE: We never reach here due to exception</span>
<span style="color: #800080;">}</span>
_ATLCATCHALL<span style="color: #808030;">(</span><span style="color: #808030;">)</span>
<span style="color: #800080;">{</span>
    <span style="color: #696969;">// NOTE: Catching the access violation for now to be able to continue execution</span>
<span style="color: #800080;">}</span>
p<span style="color: #808030;">.</span>SetProtection<span style="color: #808030;">(</span>PAGE_READWRITE<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
p<span style="color: #808030;">[</span><span style="color: #008c00;">1</span><span style="color: #808030;">]</span> <span style="color: #808030;">=</span> <span style="color: #008000;">0x03</span><span style="color: #800080;">;</span></pre>
<p>Given the information what data gets corrupt, the pointer allocator provides an efficient opportunity to detect the violation attempt. The only thing remained is to keep memory read-only, and temporarily revert to write access when the &#8220;legal&#8221; memory modification code is about to be executed.</p>
<p><span id="more-1319"></span></p>
<h5>One-shot Read/Write Protection with Guard Pages</h5>
<p>Another option granted by memory protection modes is brought by PAGE_GUARD flag. MSDN says:</p>
<blockquote><p>A guard page provides a one-shot alarm for memory page access. This can be useful for an application that needs to monitor the growth of large dynamic data structures. For example, there are operating systems that use guard pages to implement automatic stack checking.</p></blockquote>
<p>Setting a guard page mode provides an additional option to trigger an exception with even read access to a protected memory block.</p>
<pre style="color: #000000; background: #ffffff;">p<span style="color: #808030;">.</span>SetProtection<span style="color: #808030;">(</span>PAGE_READWRITE <span style="color: #808030;">|</span> PAGE_GUARD<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
<span style="color: #603000;">BYTE</span> n <span style="color: #808030;">=</span> p<span style="color: #808030;">[</span><span style="color: #008c00;">0</span><span style="color: #808030;">]</span><span style="color: #800080;">;</span></pre>
<h4>CDebugHeapPtr Class: More Options to Catch Memory Corruption Conditions</h4>
<p>While setting memory protection attributes on a memory block of interest provides unique troubleshooting opportunities, it still does not cover important typical problems with memory misuse scenarios. Those are writing immediately before the allocated block, and writing immediately after. Having array of N items, this would be writing to indices -1 and N respectively.</p>
<p>To address this scenarios of misuse we can extend CVirtualHeapPtr class so that it could additionally provide &#8220;sanity pages&#8221; with PAGE_NOACCESS protection at the boundary of allocation. Because virtual memory allocation is granular, we will have to have padding bytes that extend our block to the page boundary, however we have an option to put the padding bytes before or after the payload data block in order to capture after or before memory block writes respectively.</p>
<p>The figure below shows memory layout for the data:</p>
<p><img class="alignnone size-full wp-image-1320" title="CDebugHeapPtr Memory Layout" src="http://alax.info/blog/wp-content/uploads/2011/11/image.png" alt="" width="509" height="541" /></p>
<p>Source code for the <em>CDebugHeapPtr</em> class <a href="http://www.alax.info/trac/public/browser/trunk/Utilities/VirtualHeapPtr/VirtualHeapPtr.h#L155">is available on Trac</a> (lines 155-). The sanity pages create a block of inaccessible addresses which immediately cause access violation exception on either read of write access attempt. Under debugger, those are shows with question marks:</p>
<p><img class="alignnone size-full wp-image-1321" title="PAGE_NOACCESS Data" src="http://alax.info/blog/wp-content/uploads/2011/11/Image0011.png" alt="" width="673" height="288" /></p>
<p>The padding space is pre-initialized with hardcoded value 0&#215;77, and the space is checked for integrity at release of memory block call.</p>
<h4>Catching the Exceptions</h4>
<p>Having the exceptions generated on run-time, they immediately alter application execution code path and are easy to track and catch. There is no need to bring the feature rich debugger, such as Visual Studio to the production site in order to catch the exception and environment, instead a way simpler tool such as <a href="http://alax.info/blog/1248">LogProcessExceptions</a> would be able to create a minidump file and write the state of the application. The minidump can be transferred into debugger-enabled environment for detailed check.</p>
<p>Visual C++ .NET 2010 <a href="http://www.alax.info/trac/public/browser/trunk/Utilities/VirtualHeapPtr">source code</a> is available from SVN.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1319/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GPS Location/Coordinate Converter: Multiple Locations at Once</title>
		<link>http://alax.info/blog/1313</link>
		<comments>http://alax.info/blog/1313#comments</comments>
		<pubDate>Mon, 14 Nov 2011 18:06:26 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[WTL]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[rally]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1313</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1313" title="GPS Location/Coordinate Converter: Multiple Locations at Once"></a>Today&#8217;s update lets you convert multiple locations at once with a single click. Here is the story behind the update and use case scenario. In rally raid sport events (so called baja), a team gets a road book for the &#8230;<p class="read-more"><a href="http://alax.info/blog/1313">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1313" title="GPS Location/Coordinate Converter: Multiple Locations at Once"></a><p>Today&#8217;s update lets you convert multiple locations at once with a single click. Here is the story behind the update and use case scenario.</p>
<p>In <a href="http://en.wikipedia.org/wiki/Rally_raid">rally raid</a> sport events (so called <em>baja</em>), a team gets a road book for the next competition day in a few hours before actual start. The GPS coordinates are printed on one of the pages of the roadbook and are not available in any electronic format.</p>
<p>There were just a few times when the organizer also uploaded a copy of a file with the coordinates and shared a link to download from, but this was rather an exception. Another alternate option was a dedicated person to upload the coordinates (they were earlier full tracks, but at some point tracks were no longer available at all) to pilots&#8217; hardware, but in a state of pre-start рфыеу and variety of GPS hardware, formats, cable etc. this created lines of people. The most one can rely on is a sheet of paper with GPS coordinates. The mistery does not end even here as you don&#8217;t know whether you are to get Degrees only, or Degrees and Minutes, or Degrees, Minutes and Seconds. Everything depends on software the organizer uses.</p>
<p><img class="alignnone size-full wp-image-1314" title="A Page with GPS Locations in Road Book " src="http://alax.info/blog/wp-content/uploads/2011/11/Scan1.jpg" alt="" width="480" height="307" /></p>
<p>As soon as you get a hard copy of this, the idea is to upload it into device as quickly as possible because there are other things to do and the time is normally 11 PM when the race is to start 7 AM next day tens of miles away from you. The time interval will be shared by uploading data, sleeping and transfer to start location.</p>
<p>The utility is here to grant extra sleep time. Since it is capable to accept various separators on the input, a convenient way is to quickly type in the text in Microsoft Excel, check the data against the hardcopy, and copy into clipboard to transfer to the utility.</p>
<p><img class="alignnone size-full wp-image-1315" title="GPS Coordinates in Microsoft Excel" src="http://alax.info/blog/wp-content/uploads/2011/11/Image001.png" alt="" width="558" height="472" /></p>
<p>A hotkey with conversion transfers data into format of interest, and single &#8220;Find and Replace&#8221; operation creates a good OziExplorer waypoint file which is good for upload onto portable navigation device.<img class="alignnone size-large wp-image-1316" title="Visual Studio with OziExplorer Waypoint Data" src="http://alax.info/blog/wp-content/uploads/2011/11/Image002-687x600.png" alt="" width="620" height="541" /></p>
<p>The whole thing take a few minutes to do with minimal routine typing in.</p>
<p>A binary [<a href="http://www.alax.info/svn/public/trunk/Utilities/GpsLocationConverter/_Bin/Release/GpsLocationConverter.exe">Win32</a>] and partial Visual C++ .NET 2010 <a href="http://www.alax.info/trac/public/browser/trunk/Utilities/GpsLocationConverter">partial source code</a> are available from SVN.</p>
<p>Bonus picture, rally raid Suzuki is on the way to score the victory and the rally promotional teaser:</p>
<p><a href="https://picasaweb.google.com/105209331201471192155/BajaPolygon4thRoundOfUkrainianCup2011InRallyRaidsNearNovomoskovskUkraine"><img class="alignnone" src="https://lh6.googleusercontent.com/--53JPr3B2Hw/TsD_WnIrE9I/AAAAAAAAFXo/PjmYMfS_WJI/s640/DSC04127a.jpg" alt="Rally Raid Suzuki Samurai on the Way" width="640" height="426" /></a></p>
<p><object width="640" height="360"><param name="movie" value="http://www.youtube.com/v/k-_-Re2PhQ8&#038;rel=0&#038;hl=en_US&#038;feature=player_embedded&#038;version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.youtube.com/v/k-_-Re2PhQ8&#038;rel=0&#038;hl=en_US&#038;feature=player_embedded&#038;version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="360"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1313/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Common Controls: Versions, Compatibility, WTL</title>
		<link>http://alax.info/blog/1306</link>
		<comments>http://alax.info/blog/1306#comments</comments>
		<pubDate>Sun, 30 Oct 2011 19:55:52 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[WTL]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[compatibility]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1306</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1306" title="Common Controls: Versions, Compatibility, WTL"></a>An application appears to be not working in Windows XP in a weird way: rebar control appeared to fail showing up. Where the application is expected to look much nicer with rebar control as a container for menu (implemented as &#8230;<p class="read-more"><a href="http://alax.info/blog/1306">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1306" title="Common Controls: Versions, Compatibility, WTL"></a><p>An application appears to be not working in Windows XP in a weird way: <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb774373%28v=vs.85%29.aspx">rebar control</a> appeared to fail showing up.</p>
<p><img class="alignnone size-full wp-image-1310" title="Rebar Failed" src="http://alax.info/blog/wp-content/uploads/2011/10/Image003.png" alt="" width="640" height="238" /></p>
<p>Where the application is expected to look much nicer with rebar control as a container for menu (implemented as command bar WTL control) and toolbar with buttons:</p>
<p><img class="alignnone size-full wp-image-1309" title="Rebar Succeeded" src="http://alax.info/blog/wp-content/uploads/2011/10/Image0022.png" alt="" width="640" height="238" /></p>
<p>A WTL sample project generated by a Visual Studio wizard would never give such effect, and the bug was a combination of factors:</p>
<ol>
<li>An application built with a newer version of Windows SDK, which includes support for features (Windows Vista+ Common Controls) that are more recent than production environment (Windows XP); the application targets to Windows Vista+ environment too (<em>_WIN32_WINNT</em> &gt;= <em>0&#215;0600</em>)</li>
<li>Compatibility issues of Common Controls library</li>
<li>WTL version (7.5), which did not yet include a workaround for the problem</li>
</ol>
<p>The problem, which caused the bug directly was the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb774393%28v=vs.85%29.aspx">REBARBANDINFO structure</a> and its use as an argument with Common Controls API. As MSDN shows, the structure was amended twice with additional fields.</p>
<p>One of the way to support multiple versions of the structure definition, and to resolve compatibility issues, is to embed structure size into structure payload. In fact, <em>REBARBANDINFO::cbSize</em> member is there exactly for this reason.</p>
<p>The application is normally filling <em>cbSize</em> with the maximal known structure size and fills the rest of the fields respectively. The API is expected to be checking <em>cbSize</em> member and be detecting API version compatibility scenarios:</p>
<ol>
<li><em>cbSize</em> holds exactly the value the API expects (that is, the maximal value known/defined to the API) &#8211; the simplest scenario where the API and the application are on the same page, both are using the same versions of the &#8220;protocol&#8221;/interface.</li>
<li><em>cbSize</em> is smaller than API can support &#8211; the API sees that it is dealing with a sort of legacy application which cannot utilize all available features, and the API acts respectively supporting the older part of the protocol, and keeping defaults or &#8220;old look&#8221; for the rest of implementation. This addresses backward compatibility: the newer API works with apps designed for older version of the API</li>
<li><em>cbSize</em> is greater then API can support &#8211; the API sees that the application is already aware of newer version API and is possibly requesting some of the missing features. The API might be ignoring the unsupported part in assumption that API evolution tool place keeping some compatibility in mind, and still do the best it can with the existing implementation. Or, the API might just fail to work.</li>
</ol>
<p>The latter item #3 is the scenario here with rebar control. The application is using Windows Vista version of <em>REBARBANDINFO</em> structure and Windows XP implementation choses to completely fail.</p>
<p>While it does not seem to be directly a bug, this attitude is definitely not developer friendly: there is no reason for the control to not work in its best and default way. Having API acting this way, each developer using the API needs to take care of the situation explicitly: whenever Windows Vista enabled application needs to be able to run in Windows XP system, the code around <em>REBARBANDINFO</em> would look like this:</p>
<pre style="color: #000000; background: #ffffff;">REBARBANDINFO BandInformation <span style="color: #808030;">=</span> <span style="color: #800080;">{</span> <span style="color: #800000; font-weight: bold;">sizeof</span> BandInformation<span style="color: #808030;">,</span> RBBIM_LPARAM <span style="color: #800080;">}</span><span style="color: #800080;">;</span>
<span style="color: #004a43;">#</span><span style="color: #004a43;">if</span><span style="color: #004a43;"> _WIN32_WINNT </span><span style="color: #808030;">&gt;</span><span style="color: #808030;">=</span><span style="color: #004a43;"> 0x0600</span>
<span style="color: #800000; font-weight: bold;">if</span><span style="color: #808030;">(</span>GetOsVersion<span style="color: #808030;">(</span><span style="color: #808030;">)</span> <span style="color: #808030;">&lt;</span> <span style="color: #008000;">0x00060000</span> <span style="color: #808030;">|</span><span style="color: #808030;">|</span> GetCommCtrlVersion<span style="color: #808030;">(</span><span style="color: #808030;">)</span> <span style="color: #808030;">&lt;</span> <span style="color: #008000;">0x00060000</span><span style="color: #808030;">)</span> <span style="color: #696969;">// pre-Vista, Common Controls pre-6.0</span>
    BandInformation<span style="color: #808030;">.</span>cbSize <span style="color: #808030;">=</span> REBARBANDINFO_V6_SIZE<span style="color: #800080;">;</span>
<span style="color: #004a43;">#</span><span style="color: #004a43;">endif</span><span style="color: #696969;">// _WIN32_WINNT &gt;= 0x0600</span>
<span style="color: #800000; font-weight: bold;">const</span> <span style="color: #603000;">BOOL</span> bGetBandInfoResult <span style="color: #808030;">=</span> Rebar<span style="color: #808030;">.</span>GetBandInfo<span style="color: #808030;">(</span><span style="color: #008c00;">0</span><span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>BandInformation<span style="color: #808030;">)</span><span style="color: #800080;">;</span></pre>
<p>If the API was nicer to developers, the code would be plain and simple:</p>
<pre style="color: #000000; background: #ffffff;">REBARBANDINFO BandInformation <span style="color: #808030;">=</span> <span style="color: #800080;">{</span> <span style="color: #800000; font-weight: bold;">sizeof</span> BandInformation<span style="color: #808030;">,</span> RBBIM_LPARAM <span style="color: #800080;">}</span><span style="color: #800080;">;</span>
<span style="color: #800000; font-weight: bold;">const</span> <span style="color: #603000;">BOOL</span> bGetBandInfoResult <span style="color: #808030;">=</span> Rebar<span style="color: #808030;">.</span>GetBandInfo<span style="color: #808030;">(</span><span style="color: #008c00;">0</span><span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>BandInformation<span style="color: #808030;">)</span><span style="color: #800080;">;</span></pre>
<p>To address this problem, <a href="http://wtl.sourceforge.net/">WTL</a> 8.0 comes up with <em>RunTimeHelper</em> namespace and its <em>SizeOf_REBARBANDINFO</em> function. It takes care of details for the developer choosing the proper size of the structure on runtime. The code is being taken back to a simpler shape:</p>
<pre style="color: #000000; background: #ffffff;">REBARBANDINFO BandInformation <span style="color: #808030;">=</span> <span style="color: #800080;">{</span> RunTimeHelper<span style="color: #800080;">::</span>SizeOf_REBARBANDINFO<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> RBBIM_LPARAM <span style="color: #800080;">}</span><span style="color: #800080;">;</span>
<span style="color: #800000; font-weight: bold;">const</span> <span style="color: #603000;">BOOL</span> bGetBandInfoResult <span style="color: #808030;">=</span> Rebar<span style="color: #808030;">.</span>GetBandInfo<span style="color: #808030;">(</span><span style="color: #008c00;">0</span><span style="color: #808030;">,</span> <span style="color: #808030;">&amp;</span>BandInformation<span style="color: #808030;">)</span><span style="color: #800080;">;</span></pre>
<p>All in all:</p>
<ul>
<li>be aware of compatibility issues (same scenario exists with other SDK structures: <em>LVGROUP</em>, <em>LVTILEINFO</em>, <em>MCHITTESTINFO</em>, <em>NONCLIENTMETRICS</em> and other).</li>
<li>use latest version of WTL to have things worked around for you where Microsoft developers were not kid enough to provide perfect API</li>
<li>be aware and take advantage of WTL&#8217;s <em>RunTimeHelper</em> class</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1306/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GPS Location/Coordinate Converter: Fractional Seconds, More Shortcuts</title>
		<link>http://alax.info/blog/1302</link>
		<comments>http://alax.info/blog/1302#comments</comments>
		<pubDate>Thu, 20 Oct 2011 17:48:42 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[WTL]]></category>
		<category><![CDATA[coordinate]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1302</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1302" title="GPS Location/Coordinate Converter: Fractional Seconds, More Shortcuts"></a>This adds a small update to the recently published GPS Location/Coordinate Converter utility: Seconds in Degrees, Minutes &#38; Seconds notation are shown and are accepted as floating point numbers More shortcuts to popular online map services (note that only Google &#8230;<p class="read-more"><a href="http://alax.info/blog/1302">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1302" title="GPS Location/Coordinate Converter: Fractional Seconds, More Shortcuts"></a><p>This adds a small update to the recently published <a title="Permalink to Utility Clearance: GPS Location/Coordinate Converter" href="../1297">GPS Location/Coordinate Converter</a> utility:</p>
<ul>
<li>Seconds in <em>Degrees, Minutes &amp; Seconds</em> notation are shown and are accepted as floating point numbers</li>
<li>More shortcuts to popular online map services (note that only Google Maps and Yandex Maps are still accepted as input via clipboard):</li>
<ul>
<li style="text-align: left;">Bing Maps</li>
<li style="text-align: left;">Yahoo Maps</li>
<li style="text-align: left;">Open Street Map</li>
<li style="text-align: left;">WikiMapia</li>
</ul>
</ul>
<p>The latter makes the tool an easy to use converted between the services for a GPS POI.</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/10/Image0011.png"><img class="alignnone size-large wp-image-1303" title="GPS Location Converter" src="http://alax.info/blog/wp-content/uploads/2011/10/Image0011-800x316.png" alt="" width="620" height="244" /></a></p>
<p>A binary [<a href="http://www.alax.info/svn/public/trunk/Utilities/GpsLocationConverter/_Bin/Release/GpsLocationConverter.exe">Win32</a>] and partial Visual C++ .NET 2010 <a href="http://www.alax.info/trac/public/browser/trunk/Utilities/GpsLocationConverter">partial source code</a> are available from SVN.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1302/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utility Clearance: GPS Location/Coordinate Converter</title>
		<link>http://alax.info/blog/1297</link>
		<comments>http://alax.info/blog/1297#comments</comments>
		<pubDate>Wed, 12 Oct 2011 21:20:40 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[WTL]]></category>
		<category><![CDATA[coordinate]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1297</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1297" title="Utility Clearance: GPS Location/Coordinate Converter"></a>This tool came up as a result of mess around GPS coordinate formatting and variety of popular formats and notations. Some use latitude and longitude degrees, some prefer degrees and minutes with fractional part. this does not take into account &#8230;<p class="read-more"><a href="http://alax.info/blog/1297">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1297" title="Utility Clearance: GPS Location/Coordinate Converter"></a><p>This tool came up as a result of mess around GPS coordinate formatting and variety of popular formats and notations. Some use latitude and longitude degrees, some prefer degrees and minutes with fractional part. this does not take into account choices for datum and file formats.</p>
<p>For instance, both <a href="http://maps.google.com">Google Maps</a> and <a href="http://maps.yandex.ru">Yandex Maps</a> accept latitude and longitude as <strong>ll=</strong> URL parameter with the value of latitude and longitude in degrees, however Google uses latitude coming first, while Yandex prefers the opposite.</p>
<p>Recently, a rally road book contained the following formatting of track points:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/10/Image001.png"><img class="alignnone size-large wp-image-1298" title="Rally Raid Service Book" src="http://alax.info/blog/wp-content/uploads/2011/10/Image001-800x418.png" alt="" width="620" height="323" /></a></p>
<p>Having to put a stop to the madness, this utility comes up as a handy assistant to convert and format GPS coordinates into reasonable presentation and separators.</p>
<p>The utility runs on background and monitors clipboard, and once it recognizes one of the following:</p>
<ul>
<li>GPS Point in Degrees</li>
<li>GPS Point in Degrees and Minutes</li>
<li>GPS Point in Degrees, Minutes and Seconds</li>
<li>Google Maps URL</li>
<li>Yandex Maps URL</li>
</ul>
<p>it flashes and updates its UI providing the choices of track point formatting:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/10/Image0021.png"><img class="alignnone size-full wp-image-1299" title="GPS Point Formatting and Options" src="http://alax.info/blog/wp-content/uploads/2011/10/Image0021.png" alt="" width="778" height="248" /></a></p>
<p>The utility is trying hard to accept various separators and formats, just one thing is important to keep in mind: if you are using minutes without seconds, the fractional part of minutes should be separated by decimal point (.).</p>
<p>The utility also responds to hotkeys <em>Ctrl+Shift+F1</em>, <em>Ctrl+Shift+F2</em> etc. and copies the formatted point location back into clipboard so that one could quickly re-format editable text in another application through clipboard updates. Alternatively, it is possible to click the formatted value and place it into clipboard.</p>
<p>The utility also provides clickable hyperlinks to open Google Maps and Yandex Maps into the point of interest.</p>
<p>A binary [<a href="http://www.alax.info/svn/public/trunk/Utilities/GpsLocationConverter/_Bin/Release/GpsLocationConverter.exe">Win32</a>] and partial Visual C++ .NET 2010 <a href="http://www.alax.info/trac/public/browser/trunk/Utilities/GpsLocationConverter">partial source code</a> are available from SVN.</p>
<p>Note: you might need to run the tool &#8220;As Administrator&#8221; elevating UAC privileges in Vista/7 operating systems.</p>
<p>Bonus links on the topic:</p>
<ul>
<li><a href="http://boulter.com/gps/">GPS Coordinate Converter, Maps and Info</a></li>
<li><a href="http://www.benichou-software.com/index.php?option=com_content&amp;view=article&amp;id=4&amp;Itemid=2&amp;lang=en">ITN Converter</a> &#8211; converts for route file formats</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1297/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft DTV-DVD Video Decoder at High Resolutions</title>
		<link>http://alax.info/blog/1283</link>
		<comments>http://alax.info/blog/1283#comments</comments>
		<pubDate>Wed, 21 Sep 2011 20:51:23 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[H.264]]></category>
		<category><![CDATA[microsoft]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1283</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1283" title="Microsoft DTV-DVD Video Decoder at High Resolutions"></a>It is really great news that Windows 7 offers quite some goodies for MPEG-4 support right out of the box, but some things appear to be made not so accurate. The component responsible for video decoding is Microsoft DTV-DVD Video &#8230;<p class="read-more"><a href="http://alax.info/blog/1283">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1283" title="Microsoft DTV-DVD Video Decoder at High Resolutions"></a><p>It is really great news that Windows 7 offers quite some goodies for MPEG-4 support right out of the box, but some things appear to be made not so accurate.</p>
<p>The component responsible for video decoding is <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd390679%28v=vs.85%29.aspx">Microsoft DTV-DVD Video Decoder</a> (also known as Microsoft MPEG-2 Video Decoder), available with DirectShow interface. It offers video decoding capabilities for video resolutions up to 1920&#215;1088 (Full HD), including DXVA version 2 mode. The decoder is a &#8220;preferred decoder&#8221; and is given a first chance to be taken when it comes for <a href="http://msdn.microsoft.com/en-us/library/dd390342%28v=VS.85%29.aspx">Intelligent Connect</a> to render a video stream.</p>
<p>Technology went ahead though, stepped behind 1920&#215;1088 in particular. Microsoft DTV-DVD Video Decoder DirectShow filter still remains the first take in H.264 video decoding, and what however is taking place &#8211; the decoder accepts the format (media type) which is clearly cannot decode, neither according to specification, nor in real life. As soon as pin connection succeeds, DirectShow is not trying to look for another decoder, which can truly decode the feed. Result: failure to decode video.</p>
<p><img class="alignnone size-full wp-image-1284" title="Incorrect Media Type on Microsoft DTV-DVD Decoder Output" src="http://alax.info/blog/wp-content/uploads/2011/09/Image001.png" alt="" width="1034" height="624" /></p>
<p>The problem takes place in a quite surprising way. Given 5 megapixel video (2560&#215;1592, H.264, Baseline profile, from <a href="http://en.wikipedia.org/wiki/RTSP">RTSP</a>-enabled IP camera), the decoder advertises 720&#215;480 NV12 output media type. While consuming input data, the decoder outputs nothing and keeps video window black.</p>
<p>It does not issue any filter graph events, no. The filter is persistent and works hard in assumption that a new piece of knowledge will come from Mars and provide new capabilities to start decoding video, or filter&#8217;s input will give up and provide a new <a href="http://en.wikipedia.org/wiki/Network_Abstraction_Layer#Parameter_Sets">SPS</a> to lower resolution down to something less complex.</p>
<p>Well then, so is this advanced technology yet to be discovered by science? It appears that no. CoreAVC Video Decoder, applied to the same H.264 video decodes it well and nice:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/09/Image002.png"><img class="alignnone size-large wp-image-1287" title="CoreAVC H.264 Video Decoder with 5 MP Video from StarDot SDH500BN IP Camera" src="http://alax.info/blog/wp-content/uploads/2011/09/Image002-505x600.png" alt="" width="505" height="600" /></a></p>
<p><span style="text-decoration: underline;">Update 2011-09-26</span>: According to Microsoft classification, this is <a href="http://connect.microsoft.com/VisualStudio/feedback/details/689926/dtv-dvd-video-decoder-directshow-filter-negotiates-decoding-at-high-resolutions-but-fails-to-actually-decode">a bug on a released product</a>. That is, if anyone is experiencing severe issues as a result of this behavior, one might need to contact Microsoft Support directly in search of a solution.</p>
<p>Actually, as resolutions over Full HD (1920&#215;1080) are not so much common at the moment, the issue side effects are not yet likely. Still moving on with time, I think the issues are likely to come up, without being severe though.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1283/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Utility Clearance: Enumerate Audio &#8216;MMDevice&#8217;s</title>
		<link>http://alax.info/blog/1279</link>
		<comments>http://alax.info/blog/1279#comments</comments>
		<pubDate>Tue, 30 Aug 2011 17:14:24 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[Audio]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[WTL]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Core Audio]]></category>
		<category><![CDATA[device]]></category>
		<category><![CDATA[IMMDevice]]></category>
		<category><![CDATA[MMDevice]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[WASAPI]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1279</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1279" title="Utility Clearance: Enumerate Audio &#039;MMDevice&#039;s"></a>The utility and code does straightforward enumeration of MMDevices (Vista+, check MSDN for MMDevice API availability), which correspond to MMDevice API, WASAPI, Core Audio API. The code itself is straightforward, with a ready to use binary to quickly lookup data &#8230;<p class="read-more"><a href="http://alax.info/blog/1279">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1279" title="Utility Clearance: Enumerate Audio &#039;MMDevice&#039;s"></a><p>The utility and code does straightforward enumeration of MMDevices (Vista+, check MSDN for <a href="http://msdn.microsoft.com/en-us/library/dd371399%28v=vs.85%29.aspx">MMDevice API availability</a>), which correspond to MMDevice API, WASAPI, Core Audio API. The code itself is straightforward, with a ready to use binary to quickly lookup data of interest:</p>
<p><img class="alignnone size-full wp-image-1280" title="Enumerate Audio Devices in Action" src="http://alax.info/blog/wp-content/uploads/2011/08/Image0012.png" alt="" width="541" height="363" /></p>
<p>The data is detailed well and in Excel-friendly format (via Copy/Paste):</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/08/Image002.png"><img class="alignnone size-large wp-image-1281" title="Enumerate Audio Device Output in Microsoft Excel" src="http://alax.info/blog/wp-content/uploads/2011/08/Image002-800x362.png" alt="" width="620" height="280" /></a></p>
<p>The code also automatically looks up for named Windows SDK constants, such as <a href="http://msdn.microsoft.com/en-us/library/dd316594%28v=vs.85%29.aspx">PKEY_Device_FriendlyName</a>:</p>
<pre>    Identifier    {0.0.1.00000000}.{4c1a7642-3f91-43e5-8fcf-b4b1e803d3f9}
    State    DEVICE_STATE_DISABLED    0x02
    Properties:
        {B3F8FA53-0004-438E-9003-51A46E139BFC}, 15    16 bytes of BLOB, DA 07 03 00 02 00 09 00 0E 00 39 00 16 00 C5 02    65
        PKEY_Device_DeviceDesc    Stereo Mix    31
        {B3F8FA53-0004-438E-9003-51A46E139BFC}, 6    Realtek High Definition Audio    31
        {B3F8FA53-0004-438E-9003-51A46E139BFC}, 2    {1}.HDAUDIO\FUNC_01&amp;VEN_10EC&amp;DEV_0888&amp;SUBSYS_80860034&amp;REV_1002\4&amp;37D44F2F&amp;0&amp;0201    31
        {83DA6326-97A6-4088-9453-A1923F573B29}, 3    oem29.inf:AzaliaManufacturerID.NTamd64.6.0:IntcAzAudModel:6.0.1.5964:hdaudio\func_01&amp;ven_10ec&amp;dev_0888    31
        PKEY_Device_BaseContainerId    {00000000-0000-0000-FFFF-FFFFFFFFFFFF}    72
        PKEY_Device_ContainerId    {00000000-0000-0000-FFFF-FFFFFFFFFFFF}    72
        PKEY_Device_EnumeratorName    HDAUDIO    31
        PKEY_AudioEndpoint_FormFactor    10    19
        PKEY_AudioEndpoint_JackSubType    {DFF21FE1-F70F-11D0-B917-00A0C9223196}    31
        PKEY_DeviceClass_IconPath    %windir%\system32\mmres.dll,-3018    31
        {840B8171-B0AD-410F-8581-CCCC0382CFEF}, 0    316 bytes of BLOB, 01 00 00 00 38 01 00 00 ... 00 00 00 00    65
        PKEY_AudioEndpoint_Association    {00000000-0000-0000-0000-000000000000}    31
        PKEY_AudioEndpoint_Supports_EventDriven_Mode    1    19
        {24DBB0FC-9311-4B3D-9CF0-18FF155639D4}, 3    0    11
        {24DBB0FC-9311-4B3D-9CF0-18FF155639D4}, 4    -1    11
        {9A82A7DB-3EBB-41B4-83BA-18B7311718FC}, 1    65536    19
        {233164C8-1B2C-4C7D-BC68-B671687A2567}, 1    {2}.\\?\hdaudio#func_01&amp;ven_10ec&amp;dev_0888&amp;subsys_80860034&amp;rev_1002#4&amp;37d44f2f&amp;0&amp;0201#{6994ad04-93ef-11d0-a3cc-00a0c9223196}\rtstereomixwave    31
        {5A9125B7-F367-4924-ACE2-0803A4A3A471}, 0    1610612916    19
        {B3F8FA53-0004-438E-9003-51A46E139BFC}, 0    3    19
<span style="color: #3366ff;"><strong>        PKEY_Device_FriendlyName    Stereo Mix (Realtek High Definition Audio)    31</strong></span>
        PKEY_DeviceInterface_FriendlyName    Realtek High Definition Audio    31
        PKEY_AudioEndpoint_GUID    {4C1A7642-3F91-43E5-8FCF-B4B1E803D3F9}    31</pre>
<p>A binary [<a href="http://www.alax.info/svn/public/trunk/Utilities/EnumerateAudioDevices/_Bin/Win32/Release/EnumerateAudioDevices.exe">Win32</a>, <a href="http://www.alax.info/svn/public/trunk/Utilities/EnumerateAudioDevices/_Bin/x64/Release/EnumerateAudioDevices.exe">x64</a>] and partial Visual C++ .NET 2010 <a href="http://www.alax.info/trac/public/browser/trunk/Utilities/EnumerateAudioDevices">source code</a> are available from SVN.</p>
<p>See also:</p>
<ul>
<li><a href="http://blogs.msdn.com/b/matthew_van_eerde/archive/2011/06/13/how-to-enumerate-audio-endpoint-immdevice-properties-on-your-system.aspx">A similar tool with source code</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/dd371400%28v=VS.85%29.aspx">IMMDeviceEnumerator::EnumAudioEndpoints</a> on MSDN</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1279/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resource Tools: 64-bit build</title>
		<link>http://alax.info/blog/1278</link>
		<comments>http://alax.info/blog/1278#comments</comments>
		<pubDate>Tue, 30 Aug 2011 16:56:34 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Resource Tools]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[.rc]]></category>
		<category><![CDATA[.res]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[resource]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[x64]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1278</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1278" title="Resource Tools: 64-bit build"></a>I rebuilt the Resource Tools utility in 64-bits to, supposedly, be able to be good with resources on 64-bit binaries (actually 32-bit code might be dealing with those fine also?). Anyway, the build is here and the tool available in &#8230;<p class="read-more"><a href="http://alax.info/blog/1278">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1278" title="Resource Tools: 64-bit build"></a><p>I rebuilt the <a href="http://alax.info/blog/352">Resource Tools</a> utility in 64-bits to, supposedly, be able to be good with resources on 64-bit binaries (actually 32-bit code might be dealing with those fine also?). Anyway, the build is here and the tool available in both 32-bit and 64-bit versions.</p>
<p>In particular, both 32-bit and 64-bit JavaScript scripts hosted by <a href="http://en.wikipedia.org/wiki/Windows_Script_Host">Windows Scripting Host</a> (respectively, 32-bit from C:\Windows\syswow64 or 64-bit from C:\Windows\system32 &#8211; in 64-bit Windows) can leverage the tool in file manipulation.</p>
<p>This utility is specifically helpful in automating steps which involve resource updates, such as to apply OEM branding, or resource-based file operations. The code snippet below archives a copy of DLL and PDB files for published release into a .7z archive named using current file version of the DLL itself (that is, it created a <em>ResourceTools.dll-1.0.6.296.7z</em> archive file out of <em>ResourceTools.dll</em> and corresponding <em>ResourceTools.pdb</em> files):</p>
<pre style="color: #000000; background: #ffffff;">image <span style="color: #808030;">=</span> <span style="color: #800000; font-weight: bold;">new</span> ActiveXObject<span style="color: #808030;">(</span><span style="color: #0000e6;">"AlaxInfo.ResourceTools.Image"</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
image<span style="color: #808030;">.</span>Initialize<span style="color: #808030;">(</span>inputDirectory <span style="color: #808030;">+</span> fileName<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
productVersion <span style="color: #808030;">=</span> image<span style="color: #808030;">.</span>VersionInfo<span style="color: #808030;">.</span>ProductVersionString<span style="color: #800080;">;</span>
fileVersion <span style="color: #808030;">=</span> image<span style="color: #808030;">.</span>VersionInfo<span style="color: #808030;">.</span>FileVersionString<span style="color: #800080;">;</span>
WScript<span style="color: #808030;">.</span>Echo<span style="color: #808030;">(</span><span style="color: #0000e6;">" Product Version: "</span> <span style="color: #808030;">+</span> productVersion<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
WScript<span style="color: #808030;">.</span>Echo<span style="color: #808030;">(</span><span style="color: #0000e6;">" File Version: "</span> <span style="color: #808030;">+</span> fileVersion<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
shell <span style="color: #808030;">=</span> WScript<span style="color: #808030;">.</span>CreateObject<span style="color: #808030;">(</span><span style="color: #0000e6;">"WScript.Shell"</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
currentDirectory <span style="color: #808030;">=</span> shell<span style="color: #808030;">.</span>CurrentDirectory<span style="color: #800080;">;</span>
shell<span style="color: #808030;">.</span>CurrentDirectory <span style="color: #808030;">=</span> currentDirectory <span style="color: #808030;">+</span> <span style="color: #0000e6;">"</span><span style="color: #0f69ff;">\\</span><span style="color: #0000e6;">"</span> <span style="color: #808030;">+</span> inputDirectory<span style="color: #800080;">;</span>
<span style="color: #800000; font-weight: bold;">try</span> <span style="color: #800080;">{</span>
    shellExec <span style="color: #808030;">=</span> shell<span style="color: #808030;">.</span>Exec<span style="color: #808030;">(</span>
        <span style="color: #0000e6;">"</span><span style="color: #0f69ff;">\"</span><span style="color: #0000e6;">"</span> <span style="color: #808030;">+</span> toolDirectory <span style="color: #808030;">+</span> <span style="color: #0000e6;">"7z"</span> <span style="color: #808030;">+</span> <span style="color: #0000e6;">"</span><span style="color: #0f69ff;">\"</span><span style="color: #0000e6;"> "</span> <span style="color: #808030;">+</span>
        <span style="color: #0000e6;">"a -t7z "</span> <span style="color: #808030;">+</span>
        <span style="color: #0000e6;">"</span><span style="color: #0f69ff;">\"</span><span style="color: #0000e6;">"</span> <span style="color: #808030;">+</span> currentDirectory <span style="color: #808030;">+</span> <span style="color: #0000e6;">"</span><span style="color: #0f69ff;">\\</span><span style="color: #0000e6;">"</span> <span style="color: #808030;">+</span> outputDirectory <span style="color: #808030;">+</span> <span style="color: #0000e6;">"ResourceTools.dll-"</span> <span style="color: #808030;">+</span> fileVersion <span style="color: #808030;">+</span> <span style="color: #0000e6;">".7z"</span> <span style="color: #808030;">+</span> <span style="color: #0000e6;">"</span><span style="color: #0f69ff;">\"</span><span style="color: #0000e6;"> "</span> <span style="color: #808030;">+</span>
        <span style="color: #0000e6;">"ResourceTools.dll"</span> <span style="color: #808030;">+</span> <span style="color: #0000e6;">" "</span> <span style="color: #808030;">+</span>
        <span style="color: #0000e6;">"ResourceTools.pdb"</span> <span style="color: #808030;">+</span> <span style="color: #0000e6;">" "</span> <span style="color: #808030;">+</span>
        <span style="color: #0000e6;">""</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">while</span> <span style="color: #808030;">(</span>shellExec<span style="color: #808030;">.</span>Status <span style="color: #808030;">==</span> <span style="color: #008c00;">0</span><span style="color: #808030;">)</span>
        WScript<span style="color: #808030;">.</span>Sleep<span style="color: #808030;">(</span><span style="color: #008c00;">100</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">if</span> <span style="color: #808030;">(</span>shellExec<span style="color: #808030;">.</span>ExitCode <span style="color: #808030;">!=</span> <span style="color: #008c00;">0</span><span style="color: #808030;">)</span>
        <span style="color: #800000; font-weight: bold;">throw</span> <span style="color: #800000; font-weight: bold;">new</span> Error<span style="color: #808030;">(</span><span style="color: #0000e6;">"7-Zip Exec failed, .ExitCode "</span> <span style="color: #808030;">+</span> shellExec<span style="color: #808030;">.</span>ExitCode<span style="color: #808030;">.</span><span style="color: #800000; font-weight: bold;">toString</span><span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    WScript<span style="color: #808030;">.</span>Echo<span style="color: #808030;">(</span><span style="color: #0000e6;">" Output File: "</span> <span style="color: #808030;">+</span> <span style="color: #0000e6;">"ResourceTools-"</span> <span style="color: #808030;">+</span> fileVersion <span style="color: #808030;">+</span> <span style="color: #0000e6;">".7z"</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
<span style="color: #800080;">}</span>
<span style="color: #800000; font-weight: bold;">finally</span> <span style="color: #800080;">{</span>
    shell<span style="color: #808030;">.</span>CurrentDirectory <span style="color: #808030;">=</span> currentDirectory<span style="color: #800080;">;</span>
<span style="color: #800080;">}</span></pre>
<p>Title: Alax.Info Resource Tools<br />
Version: 1.0.6<br />
Download Links: <a href="http://www.alax.info/svn/public/trunk/ResourceTools/ResourceToolsSetup.msi">ResourceToolsSetup.msi</a> (Win32, 32-bit) and <a href="http://www.alax.info/svn/public/trunk/ResourceTools/ResourceToolsSetup-x64.msi">ResourceToolsSetup-x64.msi</a> (x64, 64-bit)</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1278/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

