<?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"
	>

<channel>
	<title>siwu's blog &#187; Research</title>
	<atom:link href="http://siwu.info/category/development/research/feed" rel="self" type="application/rss+xml" />
	<link>http://siwu.info</link>
	<description>sir, i'm certified cpr !</description>
	<pubDate>Fri, 12 Sep 2008 16:51:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<item>
		<title>GTA2 Classics Stuck at 640&#215;480 (and fix!)</title>
		<link>http://siwu.info/80/gta2-classics-stuck-at-640x480-and-fix.html</link>
		<comments>http://siwu.info/80/gta2-classics-stuck-at-640x480-and-fix.html#comments</comments>
		<pubDate>Fri, 23 May 2008 00:35:40 +0000</pubDate>
		<dc:creator>siwu</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://siwu.info/80/gta2-classics-stuck-at-640x480-and-fix.html</guid>
		<description><![CDATA[Lately with friends we've been having some multiplayer fun at GTA 2 Classics Edition (the free one that you can download at Rockstar Classics). I'm amazed to see how cool this game still is in multiplayer. BUT, there was a but. As of now it was impossible to make it run at more than 640x480, [...]]]></description>
			<content:encoded><![CDATA[<p>Lately with friends we've been having some multiplayer fun at GTA 2 Classics Edition (the free one that you can download at <a href="http://www.rockstargames.com/classics/" >Rockstar Classics</a>). I'm amazed to see how cool this game still is in multiplayer. BUT, there was a but. As of now it was impossible to make it run at more than 640x480, despite setting higher resolutions on the GTA 2 Manager. While it's not a <strong>big</strong> issue, it's still annoying nonetheless.<br />
So I've looked and looked and looked and looked on the net to find some kind of answer. While I did find some people who had the same problem as me (and <strong>all</strong> my friends for that matter), I did not find any answer.<br />
Because I'm not desperate, I've took my tools and started decompiling GTA 2 (;))<br />
Long story short, here is a patch to activate high resolution on GTA 2 Classics Edition (aka 9.6F) <strong>only</strong>:</p>
<p><a href='http://siwu.info/wp-content/gta2patch.exe' title='gta2patch.exe'>gta2patch.exe</a> (7 kb)</p>
<p>Please bear in mind that this patch is VERY ghetto. It doesn't even check if you are patching the right version, so <strong>USE AT YOU OWN RISK</strong>!<br />
For the details, the source code and the alternate methods (if you don't feel like downloading and launching an executable from an unknown source), hit the jump.<br />
<span id="more-80"></span><br />
I won't go into big details but it seems at some point the code to detect whether or not your graphic card is capable of handling high resolution <strike>screws up</strike> decides that it can't and falls back into "safe mode" by setting a flag. For another <strike>weird</strike> reason, the flag is not set when a registry key is.<br />
Try to set the <code>DWORD</code> key <code>skip_frontend</code> to <code>1</code> under <code>HKEY_LOCAL_MACHINE\SOFTWARE\DMA Design Ltd\GTA2\Debug</code> and it should launch the game at high resolution. The problem is, the game fails telling you that it can't open some file. Whatever.<br />
So what did I do, well, I simply patched the fail-safe code, by forcing high-res.</p>
<p>If you want to patch it yourself, take you favorite hex editor and open <code>gta2.exe</code>. Go at offset <code>0x000CB2C9</code>, and replace <code>74 1D</code> by <code>EB 1D</code> (forced <code>jmp</code> ftw).</p>
<p>Finally, if you want to compile the patch yourself (some people do I guess!), here is the code! I told you it was ghetto!</p>
<div class="syntax_hilite">
<div id="c-2">
<div class="c">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #339933;">#include &lt;windows.h&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #339933;">#include &lt;conio.h&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333;">int</span>&nbsp;&nbsp;main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> argc, <span style="color: #993333;">char</span> **argv<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #993333;">char</span> *patchFile = <span style="color: #ff0000;">"gta2.exe"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #993333;">char</span> *backupFile = <span style="color: #ff0000;">"gta2.original.exe"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #993333;">long</span> patchOffset = 0x000CB2C9;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> patchData<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\x</span>EB"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html" ><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"GTA2 Classics Edition High Resolution Patch<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html" ><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"by siwu (siwuzzz@gmail.com)<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html" ><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"This program will patch %s to allow high resolutions<span style="color: #000099; font-weight: bold;">\n</span>"</span>, patchFile<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html" ><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"on systems that don't work.<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html" ><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"It will also create a backup file called %s<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>"</span>, backupFile<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html" ><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Press any key to patch!<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; getch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>CopyFile<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>LPCSTR<span style="color: #66cc66;">&#41;</span>patchFile, <span style="color: #66cc66;">&#40;</span>LPCSTR<span style="color: #66cc66;">&#41;</span>backupFile, <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html" ><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Unable to copy %s to %s! Press a key to quit!<span style="color: #000099; font-weight: bold;">\n</span>"</span>, patchFile, backupFile<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; getch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; FILE *gtaFile = fopen<span style="color: #66cc66;">&#40;</span>patchFile, <span style="color: #ff0000;">"r+"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>gtaFile == <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html" ><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Unable to open %s! Press a key to quit!<span style="color: #000099; font-weight: bold;">\n</span>"</span>, patchFile<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; getch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; fseek<span style="color: #66cc66;">&#40;</span>gtaFile, patchOffset, SEEK_SET<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; fwrite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">const</span> <span style="color: #993333;">void</span> *<span style="color: #66cc66;">&#41;</span>patchData, <span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span>patchData<span style="color: #66cc66;">&#41;</span> - <span style="color: #cc66cc;color:#800000;">1</span>, gtaFile<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; fclose<span style="color: #66cc66;">&#40;</span>gtaFile<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html" ><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Succesfully patched %s! Press a key to quit!<span style="color: #000099; font-weight: bold;">\n</span>"</span>, patchFile<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; getch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://siwu.info/80/gta2-classics-stuck-at-640x480-and-fix.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Hacking into Vista&#8217;s Desktop Window Manager (DWM)</title>
		<link>http://siwu.info/66/hacking-into-vistas-desktop-window-manager-dwm.html</link>
		<comments>http://siwu.info/66/hacking-into-vistas-desktop-window-manager-dwm.html#comments</comments>
		<pubDate>Sat, 08 Dec 2007 17:23:39 +0000</pubDate>
		<dc:creator>siwu</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://siwu.info/66/hacking-into-vistas-desktop-window-manager-dwm.html</guid>
		<description><![CDATA[Window texture is soooo last week, when you can manipulate the windows themselves 
  
Jump for the (quite long I admit) story 

Last year (Oct. 2006) I started playing with the Windows Vista's Destkop Window Manager (DWM) API. Like a lot of people, I was really disappointed by the library. The only thing it [...]]]></description>
			<content:encoded><![CDATA[<p>Window texture is soooo last week, when you can manipulate the windows themselves <img src='http://siwu.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
<a href='http://siwu.info/wp-content/dwm_hack3.jpg' title='dwm_hack3.jpg'><img src='http://siwu.info/wp-content/dwm_hack3.thumbnail.jpg' alt='dwm_hack3.jpg' /></a> <a href='http://siwu.info/wp-content/firefox_zoomed.jpg' title='firefox_zoomed.jpg'><img src='http://siwu.info/wp-content/firefox_zoomed.thumbnail.jpg' alt='firefox_zoomed.jpg' /></a> <a href='http://siwu.info/wp-content/dwm_hack2.jpg' title='dwm_hack2.jpg'><img src='http://siwu.info/wp-content/dwm_hack2.thumbnail.jpg' alt='dwm_hack2.jpg' /></a></p>
<p>Jump for the (quite long I admit) story <img src='http://siwu.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
<span id="more-66"></span><br />
Last year (Oct. 2006) I started playing with the <a href="http://msdn2.microsoft.com/en-us/library/aa969540.aspx" >Windows Vista's Destkop Window Manager (DWM) API</a>. Like a lot of people, I was really disappointed by the library. The only thing it permits you to do is to have your own live thumbnails... Come on Microsoft! The DWM uses freaking Direct3D, why don't you let us mess around with that!<br />
I knew there a way to extract the window texture (since DWM uses Direct3D9Ex and its marvelous shared resources), so I <a href="http://www.aeroxp.org/board/index.php?showtopic=6286" >started a thread</a> on <a href="http://www.aeroxp.org/" >AeroXP.org</a> to expose my progress on this.</p>
<p>I started of by disassembling <code>dwmapi.dll</code>, and it paid off. Here it was, in front of me: <code>DwmpDxGetWindowSharedSurface()</code>! ...and its 32 bytes signature! Damn, that's <strong>8</strong> parameters maximum to reverse! Arg.<br />
But after spending almost 2 months reverse engineering, it eventually paid off. I had a (almost) complete function signature, and <a href="http://www.aeroxp.org/board/index.php?s=&#038;showtopic=6286&#038;view=findpost&#038;p=85115" >even a way to use it</a>.</p>
<pre>
int __stdcall DwmpDxGetWindowSharedSurface(HWND hWnd,
                                           LUID adapterLuid,
                                           LUID someLuid,
                                           DWORD *pD3DFormat,
                                           HANDLE *pSharedHandle,
                                           unsigned __int64 *arg7);
</pre>
<p>But there is a "but", the function would return me a correct texture handle but to a black texture! After weeks of trying to tweak the code, I was facing a dead end.<br />
So, taking my courage, I mailed the WPF Architect, <a href="http://blogs.msdn.com/greg_schechter/" >Greg Schechter</a> to ask him for help, without much hope about a response. But he did reply (and that was very kind of him to do so), thanking me for my interest into the DWM, but that he couldn't comment on such things (and it's understandable).</p>
<p>And here I was, lonely, facing a dead end. Eventually the project was forgotten on my hard drive (as many others).</p>
<p>But after some months, <a href="http://jmorrill.hjtcentral.com/Default.aspx" >Jeremiah Morrill</a> followed by work, and <a href="http://jmorrill.hjtcentral.com/Home/tabid/428/EntryID/111/Default.aspx" >scratched some more dust</a>, finding that the texture wasn't black when the window used a Direct3D device, like WPF. And after all, it makes perfect sense. Direct3D applications render to a shared texture given by the DWM, as stated in <a href="http://blogs.msdn.com/greg_schechter/archive/2006/05/02/588934.aspx" >Greg Schechter's blog</a>:</p>
<blockquote><p>
DirectX window redirection is handled by having the DirectX system, when it's determining what surface to provide the app with to render to, make calls to the DWM in order to share a surface between the DirectX client application process, and the DWM process.  This "shared surface" support is unique to DirectX atop the WDDM, and is another key reason why WDDM is an absolute requirement for running the DWM.
</p></blockquote>
<p>But there we were facing the same problem: how the f*ck do we extract the window texture, for all windows?</p>
<p>A few months later, I started talking to <a href="http://avedesk.aqua-soft.org/" >Andreas Verhoeven</a> about this (he was doing some reverse on other parts of DWM on his own), and eventually, I revived the project. After a few nights of work, there it was:<br />
<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/hRTgFTMnT_U&#038;rel=0&#038;color1=0xd6d6d6&#038;color2=0xf0f0f0&#038;border=0"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/hRTgFTMnT_U&#038;rel=0&#038;color1=0xd6d6d6&#038;color2=0xf0f0f0&#038;border=0" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
<p>The texture relies on hooking IDirect3D9::CreateTexture() to watch out for newly created textures by the DWM, and mark them as shared (GDI texture are <strong>not</strong created as shared), and then transmit this handle to my D3D application, to create the proper texture.</p>
<p>However, the technique is flawed. The main problem is that the render loop is done asynchronously of windows creation (synchronous with v-sync), there was no direct way to establish a <code>HWND <-> TextureHandle</code> relationship. More importantly, the rendering is done though MIL (<code>milcore.dll</code>), and MIL doesn't have any clue of windows objects, that are handled by <code>uDWM.dll</code>. Pseudo dead end again.</p>
<p>But I didn't stop here, and thank to Andreas, I dug deeper into the DWM. And the results, you saw them at the top of the post <img src='http://siwu.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
I won't expose exactly what's involved (yet), but it's a combination of internal calls, and API hooking <img src='http://siwu.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>And for those of you who wonder, yes, I'm working on a library to do all this!</p>
]]></content:encoded>
			<wfw:commentRss>http://siwu.info/66/hacking-into-vistas-desktop-window-manager-dwm.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>DWM Hacking, Extracting the Window Texture</title>
		<link>http://siwu.info/64/dwm-hacking-extracting-the-window-texture.html</link>
		<comments>http://siwu.info/64/dwm-hacking-extracting-the-window-texture.html#comments</comments>
		<pubDate>Sun, 25 Nov 2007 18:36:21 +0000</pubDate>
		<dc:creator>siwu</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://siwu.info/64/dwm-hacking-extracting-the-window-texture.html</guid>
		<description><![CDATA[Lately I've been working with Ave on this, and here are the first results:

]]></description>
			<content:encoded><![CDATA[<p>Lately I've been working with Ave on this, and here are the first results:<br />
<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/hRTgFTMnT_U&#038;rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/hRTgFTMnT_U&#038;rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://siwu.info/64/dwm-hacking-extracting-the-window-texture.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Download MP4 videos directly from DailyMotion</title>
		<link>http://siwu.info/59/download-mp4-videos-directly-from-dailymotion.html</link>
		<comments>http://siwu.info/59/download-mp4-videos-directly-from-dailymotion.html#comments</comments>
		<pubDate>Thu, 01 Nov 2007 04:06:20 +0000</pubDate>
		<dc:creator>siwu</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[Projects]]></category>

		<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://siwu.info/59/download-mp4-videos-directly-from-dailymotion.html</guid>
		<description><![CDATA[So I have this shiny iPhone, and I must say, although I was skeptical when it came out, I love it. Thanks to it I can watch YouTube videos on it, and the other competitor (at least here in France), DailyMotion, has an iPhone "webapp" for it. Sweet!
After a while, I wanted to grab some [...]]]></description>
			<content:encoded><![CDATA[<p>So I have this shiny iPhone, and I must say, although I was skeptical when it came out, I love it. Thanks to it I can watch YouTube videos on it, and the other competitor (at least here in France), DailyMotion, has an iPhone "webapp" for it. Sweet!</p>
<p>After a while, I wanted to grab some videos and put them on my phone, so I started to search for an application that would allow me to convert flvs to mp4s, and eventually I found some. But the process is kinda slow, and when you think the iPhone plays the videos directly in mp4 from DailyMotion (and YouTube), you would find this utterly inefficient!</p>
<p>But thankfully for you guys, there is a way to download videos directly in mp4 from DailyMotion, and by directly, I don't mean using some transcoding service. I mean <strong>directly</strong>.<br />
So how do we do that? Well, I've created a simple tool for you to convert DailyMotion urls, to direct download MP4 urls <img src='http://siwu.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<span id="more-59"></span><br />
Thanks to this simple utility, just put the original URL, click "Find!", and it will give you the direct download URL to the MP4 file! It's that simple.</p>
<p>You can download <a href="http://siwu.info/wp-content/dailymotionmp4.rar" >the tool here</a>, and <a href="http://siwu.info/wp-content/dailymotionmp4_src.rar" >download the sources (VS 2008) here</a>.</p>
<p><img src="http://siwu.info/wp-content/screenshot.jpg" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://siwu.info/59/download-mp4-videos-directly-from-dailymotion.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Reverse Engineering the Windows XP Window Manager, Part 4: The real thing</title>
		<link>http://siwu.info/7/reverse-engineering-the-windows-xp-window-manager-part-4-the-real-thing.html</link>
		<comments>http://siwu.info/7/reverse-engineering-the-windows-xp-window-manager-part-4-the-real-thing.html#comments</comments>
		<pubDate>Mon, 26 Mar 2007 12:21:06 +0000</pubDate>
		<dc:creator>siwu</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://siwuzzz.free.fr/?p=7</guid>
		<description><![CDATA[Sooo, here we are. We finally reached the real PrintWindow() implementation. And before we start to comment, let's take a look at the code:






.text:BF8A3C84


.text:BF8A3C84 ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


.text:BF8A3C84


.text:BF8A3C84 ; Attributes: bp-based frame


.text:BF8A3C84


.text:BF8A3C84 ; __stdcall xxxPrintWindow(x, x, x)


.text:BF8A3C84 _xxxPrintWindow@12 proc near&#160; &#160; &#160; &#160; &#160; &#160; ; [...]]]></description>
			<content:encoded><![CDATA[<p>Sooo, here we are. We finally reached the real <code>PrintWindow()</code> implementation. And before we start to comment, let's take a look at the code:<br />
<span id="more-7"></span></p>
<div class="syntax_hilite">
<div id="asm-9">
<div class="asm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84 <span style="color: #adadad; font-style: italic;">; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84 <span style="color: #adadad; font-style: italic;">; Attributes: bp-based frame</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84 <span style="color: #adadad; font-style: italic;">; __stdcall xxxPrintWindow(x, x, x)</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84 _xxxPrintWindow@<span style="color: #ff0000;color:#800000;">12</span> <span style="color: #0000ff;">proc</span> <span style="color: #0000ff;">near</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; CODE XREF: NtUserPrintWindow(x,x,x)+62p</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84 var_C&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span style="color: #0000ff;">dword</span> <span style="color: #0000ff;">ptr</span> -<span style="color: #ff0000;">0Ch</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84 var_8&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span style="color: #0000ff;">dword</span> <span style="color: #0000ff;">ptr</span> -<span style="color: #ff0000;color:#800000;">8</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84 var_4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span style="color: #0000ff;">dword</span> <span style="color: #0000ff;">ptr</span> -<span style="color: #ff0000;color:#800000;">4</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84 arg_0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span style="color: #0000ff;">dword</span> <span style="color: #0000ff;">ptr</span>&nbsp; <span style="color: #ff0000;color:#800000;">8</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84 arg_4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span style="color: #0000ff;">dword</span> <span style="color: #0000ff;">ptr</span>&nbsp; <span style="color: #ff0000;">0Ch</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84 arg_8&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span style="color: #0000ff;">byte</span> <span style="color: #0000ff;">ptr</span>&nbsp; 10h</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84 <span style="color: #adadad; font-style: italic;">; FUNCTION CHUNK AT .text:BF8A3BB8 SIZE 0000002D BYTES</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C84&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">edi</span>, <span style="color: #46aa03; font-weight:bold;">edi</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C86&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">ebp</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C87&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ebp</span>, <span style="color: #46aa03; font-weight:bold;">esp</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C89&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">sub</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">esp</span>, <span style="color: #ff0000;">0Ch</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C8C&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">xor</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">eax</span>, <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C8E&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">ebx</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C8F&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">inc</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C90&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">test</span>&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_8<span style="color: #66cc66;">&#93;</span>, <span style="color: #46aa03; font-weight:bold;">al</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C93&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">esi</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C94&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">esi</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_0<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C97&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">edi</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C98&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+var_4<span style="color: #66cc66;">&#93;</span>, <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C9B&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">jnz</span>&nbsp; &nbsp; &nbsp;loc_BF8A3BB8</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CA1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">edi</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">esi</span>+48h<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CA4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ebx</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">esi</span>+4Ch<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CA7&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">and</span>&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+var_C<span style="color: #66cc66;">&#93;</span>, <span style="color: #ff0000;color:#800000;">0</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CAB&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">and</span>&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+var_8<span style="color: #66cc66;">&#93;</span>, <span style="color: #ff0000;color:#800000;">0</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CAF&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">sub</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">edi</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">esi</span>+40h<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CB2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">sub</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ebx</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">esi</span>+44h<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CB5</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CB5 loc_BF8A3CB5:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; CODE XREF: xxxPrintWindow(x,x,x)-ACj</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CB5&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">esi</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CB6&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _GetRedirectionFlags@<span style="color: #ff0000;color:#800000;">4</span> <span style="color: #adadad; font-style: italic;">; GetRedirectionFlags(x)</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CBB&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">neg</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CBD&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">sbb</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">eax</span>, <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CBF&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #ff0000;color:#800000;">8</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CC1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">inc</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CC2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">esi</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CC3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_0<span style="color: #66cc66;">&#93;</span>, <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CC6&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _SetRedirectedWindow@<span style="color: #ff0000;color:#800000;">8</span> <span style="color: #adadad; font-style: italic;">; SetRedirectedWindow(x,x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CCB&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">test</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">eax</span>, <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CCD&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">jz</span>&nbsp; &nbsp; &nbsp; loc_BF8A3BDD</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CD3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">cmp</span>&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_0<span style="color: #66cc66;">&#93;</span>, <span style="color: #ff0000;color:#800000;">0</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CD7&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">jz</span>&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">short</span> loc_BF8A3CDF</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CD9&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">esi</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CDA&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _xxxUpdateWindow@<span style="color: #ff0000;color:#800000;">4</span> <span style="color: #adadad; font-style: italic;">; xxxUpdateWindow(x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CDF</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CDF loc_BF8A3CDF:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; CODE XREF: xxxPrintWindow(x,x,x)+53j</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CDF&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #ff0000;color:#800000;">3</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CE1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #ff0000;color:#800000;">0</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CE3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">esi</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CE4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; __GetDCEx@<span style="color: #ff0000;color:#800000;">12</span>&nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; _GetDCEx(x,x,x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CE9&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_0<span style="color: #66cc66;">&#93;</span>, <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CEC&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">xor</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">eax</span>, <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CEE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CEF&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CF0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #ff0000;color:#800000;">8</span><span style="color: #ff0000;">0CC0020h</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CF5&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+var_8<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CF8&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+var_C<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CFB&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_0<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CFE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">ebx</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CFF&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">edi</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D00&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D01&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D02&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_4<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D05&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _NtGdiBitBlt@<span style="color: #ff0000;color:#800000;">44</span> <span style="color: #adadad; font-style: italic;">; NtGdiBitBlt(x,x,x,x,x,x,x,x,x,x,x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D0A&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_0<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D0D&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; __ReleaseDC@<span style="color: #ff0000;color:#800000;">4</span>&nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; _ReleaseDC(x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D12&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #ff0000;color:#800000;">8</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D14&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">esi</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D15&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _UnsetRedirectedWindow@<span style="color: #ff0000;color:#800000;">8</span> <span style="color: #adadad; font-style: italic;">; UnsetRedirectedWindow(x,x)</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D1A</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D1A loc_BF8A3D1A:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; CODE XREF: xxxPrintWindow(x,x,x)-A4j</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D1A&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">eax</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+var_4<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D1D&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">pop</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">edi</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D1E&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">pop</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">esi</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D1F&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">pop</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ebx</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D20&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">leave</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D21&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">retn</span>&nbsp; &nbsp; <span style="color: #ff0000;">0Ch</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D21 _xxxPrintWindow@<span style="color: #ff0000;color:#800000;">12</span> <span style="color: #0000ff;">endp</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D21</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D21 <span style="color: #adadad; font-style: italic;">; --------------------------------------------------------------------------- </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="asm-10">
<div class="asm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BB8 <span style="color: #adadad; font-style: italic;">; START OF FUNCTION CHUNK FOR _xxxPrintWindow@12</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BB8</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BB8 loc_BF8A3BB8:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; CODE XREF: xxxPrintWindow(x,x,x)+17j</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BB8&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ecx</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">esi</span>+50h<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BBB&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">eax</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">esi</span>+40h<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BBE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">edx</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">esi</span>+54h<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BC1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">edi</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">esi</span>+58h<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BC4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ebx</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">esi</span>+5Ch<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BC7&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">sub</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">eax</span>, <span style="color: #46aa03; font-weight:bold;">ecx</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BC9&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+var_C<span style="color: #66cc66;">&#93;</span>, <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BCC&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">eax</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">esi</span>+44h<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BCF&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">sub</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">eax</span>, <span style="color: #46aa03; font-weight:bold;">edx</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BD1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">sub</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">edi</span>, <span style="color: #46aa03; font-weight:bold;">ecx</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BD3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+var_8<span style="color: #66cc66;">&#93;</span>, <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BD6&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">sub</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ebx</span>, <span style="color: #46aa03; font-weight:bold;">edx</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BD8&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">jmp</span>&nbsp; &nbsp; &nbsp;loc_BF8A3CB5</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BDD <span style="color: #adadad; font-style: italic;">; ---------------------------------------------------------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BDD</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BDD loc_BF8A3BDD:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; CODE XREF: xxxPrintWindow(x,x,x)+49j</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BDD&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">and</span>&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+var_4<span style="color: #66cc66;">&#93;</span>, <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BE0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">jmp</span>&nbsp; &nbsp; &nbsp;loc_BF8A3D1A</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3BE0 <span style="color: #adadad; font-style: italic;">; END OF FUNCTION CHUNK FOR _xxxPrintWindow@12 </span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Let's analyze this.<br />
<br />
First, we notice that the function moves the first argument in <code>esi</code> and then references some data (like in a structure) from <code>esi</code>.</p>
<div class="syntax_hilite">
<div id="asm-11">
<div class="asm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C94&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">esi</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_0<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CA1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">edi</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">esi</span>+48h<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CA4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ebx</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">esi</span>+4Ch<span style="color: #66cc66;">&#93;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
However, <code>HWND</code>s are not pointer, which tends to demonstrate that the first argument is NOT an <code>HWND</code>, but likely the internal structure kept by the kernel for each window.<br />
If we go back to the call to <code>xxxPrintWindow()</code> in <code>NtUserPrintWindow()</code>, we notice this:</p>
<div class="syntax_hilite">
<div id="asm-12">
<div class="asm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C60&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_8<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C63&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_4<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C66&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C67&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _xxxPrintWindow@<span style="color: #ff0000;color:#800000;">12</span> <span style="color: #adadad; font-style: italic;">; xxxPrintWindow(x,x,x) </span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
The last 2 arguments are forwarded from the original <code>PrintWindow()</code> call, and the first isn't, instead it is <code>eax</code>. So, when does <code>eax</code> get set? Well:</p>
<div class="syntax_hilite">
<div id="asm-13">
<div class="asm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C16&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; @ValidateHwnd@<span style="color: #ff0000;color:#800000;">4</span> <span style="color: #adadad; font-style: italic;">; ValidateHwnd(x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C<span style="color: #ff0000;">1B</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">test</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">eax</span>, <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3C1D&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">jz</span>&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">short</span> loc_BF8A3BB1 </div>
</li>
</ol>
</div>
</div>
</div>
<p>
So here we are, <code>ValidateHwnd()</code> (which is <code>__fastcall</code>), must converts a window handle (<code>HWND</code>) to a window structure pointer. For clarity, let's name this type <code>PWND</code>.<br />
We can then extract the following prototypes:</p>
<pre>
PWND __fastcall ValidateHwnd(HWND hwnd);
BOOL __stdcall xxxPrintWindow(PWND pwnd, HDC hdcBlt, UINT nFlags);
</pre>
<p>
And then we look at the rough function flow:</p>
<div class="syntax_hilite">
<div id="asm-14">
<div class="asm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CB6&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _GetRedirectionFlags@<span style="color: #ff0000;color:#800000;">4</span> <span style="color: #adadad; font-style: italic;">; GetRedirectionFlags(x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CC6&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _SetRedirectedWindow@<span style="color: #ff0000;color:#800000;">8</span> <span style="color: #adadad; font-style: italic;">; SetRedirectedWindow(x,x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CDA&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _xxxUpdateWindow@<span style="color: #ff0000;color:#800000;">4</span> <span style="color: #adadad; font-style: italic;">; xxxUpdateWindow(x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3CE4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; __GetDCEx@<span style="color: #ff0000;color:#800000;">12</span>&nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; _GetDCEx(x,x,x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D05&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _NtGdiBitBlt@<span style="color: #ff0000;color:#800000;">44</span> <span style="color: #adadad; font-style: italic;">; NtGdiBitBlt(x,x,x,x,x,x,x,x,x,x,x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D0D&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; __ReleaseDC@<span style="color: #ff0000;color:#800000;">4</span>&nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; _ReleaseDC(x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8A3D15&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _UnsetRedirectedWindow@<span style="color: #ff0000;color:#800000;">8</span> <span style="color: #adadad; font-style: italic;">; UnsetRedirectedWindow(x,x) </span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Oh, there is one interesting thing: according to this function, we notice that the Win32 GUI does implement the concept of <strong>window drawing redirection</strong>; this basically means that the GUI is able to redirect all the drawing call into a off screen bitmap, instead of the real window, on the screen. This is actually "documented" on <a href="http://msdn2.microsoft.com/en-us/library/ms997507.aspx#layerwin_topic2a" >MSDN</a>:<br />
<em>"The second way to use layered windows is to continue using the Win32 painting paradigm, but allowing the system to redirect all the drawing for the layered window and its children into an off-screen bitmap."</em></p>
<p>In what way is this interesting for <code>PrintWindow()</code> ? Well, thanks to this, the API can screenshot partially or completely hidden windows. This is, to be fair, the core advantage of this API.<br />
So, according to all this, how does it work? Well, it does the following:</p>
<ul>
<li>Sets the window to layered using <code>SetRedirectedWindow()</code></li>
<li>Redraws completely the window using <code>UpdateWindow()</code> in the newly created empty off screen bitmap</li>
<li>Gets the DC of the new of the window with <code>GetDCEx()</code></li>
<li>Copies the bitmap to the provided DC using <code>NtGdiBitBlt()</code></li>
<li>Releases the new DC</li>
<li>Unsets the layered attribute</li>
</ul>
<p>
So we now know why <code>PrintWindow()</code> permits to take screenshots of partially or completely hidden windows! This is because of the existence of layered windows!<br />
So, even though the API appeared in Windows XP, the very existence of layered windows goes back to Windows 2000. Which means reimplementing it on Windows 2000 is totally possible, using a kernel mode driver which would call the kernel mode functions.<br />
<br />
But what is interesting here is the concept of off screen bitmaps. So basically, there <em>is</em> a pointer with DIB data of the windows! This could be very well suited to make a replica and even optimize the <code>PrintWindow()</code> implementation! Why would it be a good thing? Well, here is what we need to do to take a screenshot to a texture:</p>
<ul>
<li>Get the first surface of the texture</li>
<li>Get a DC to this surface</li>
<li><code>PrintWindow()</code> into this DC</li>
<li>Release the DC</li>
<li>Release the surface</li>
</ul>
<p>While this could be not quite cumbersome to some of you, there is one problem: what if the window has a mask? Like MSN windows? Well, here are the steps involved:</p>
<ul>
<li>Create a temporary DC</li>
<li><code>PrintWindow()</code> into this DC</li>
<li>Get the first surface of the texture</li>
<li>Get a DC to this surface</li>
<li>BitBlt from the temporary DC to the surface DC, using the mask</li>
<li>Release the 2 DCs</li>
<li>Release the surface</li>
</ul>
<p>All of this copying, allocations, and GDI stuff is quite slow. What if we had a direct access to the window DIB? We would only have to copy the DIB data to the locked texture. But even more powerful, using a standard 2D API like SDL where image DIB are stored into the system memory, we could even <em>point</em> the pointer to the DIB maintained by the OS, not having to worry about the updating, without even polling!<br />
<br />
And here is the new quest, finding this damn pointer, so we can make something like this: <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/Ysaocz2tMHE"></param><embed src="http://www.youtube.com/v/Ysaocz2tMHE" type="application/x-shockwave-flash" width="425" height="350"></embed></object><br />
Pretty fun eh? <img src='http://siwu.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://siwu.info/7/reverse-engineering-the-windows-xp-window-manager-part-4-the-real-thing.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Reverse Engineering the Windows XP Window Manager, Part 3</title>
		<link>http://siwu.info/6/reverse-engineering-the-windows-xp-window-manager-part-3.html</link>
		<comments>http://siwu.info/6/reverse-engineering-the-windows-xp-window-manager-part-3.html#comments</comments>
		<pubDate>Thu, 01 Feb 2007 12:18:16 +0000</pubDate>
		<dc:creator>siwu</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://siwuzzz.free.fr/?p=6</guid>
		<description><![CDATA[In the previous part we managed to hunt down the real implementation of the PrintWindow API. Le'ts take a look at it. The functions is divided in 3 chunks:






.text:BF8978A3 ; __stdcall NtUserPrintWindow(x, x, x)


.text:BF8978A3 _NtUserPrintWindow@12 proc near&#160; &#160; &#160; &#160; &#160;; DATA XREF: .data:BF998A74o


.text:BF8978A3


.text:BF8978A3 var_C&#160; &#160; &#160; &#160; &#160; &#160;= dword ptr -0Ch


.text:BF8978A3 var_8&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>In the previous part we managed to hunt down the real implementation of the <code>PrintWindow</code> API. Le'ts take a look at it. The functions is divided in 3 chunks:<br />
<span id="more-6"></span></p>
<div class="syntax_hilite">
<div id="asm-19">
<div class="asm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A3 <span style="color: #adadad; font-style: italic;">; __stdcall NtUserPrintWindow(x, x, x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A3 _NtUserPrintWindow@<span style="color: #ff0000;color:#800000;">12</span> <span style="color: #0000ff;">proc</span> <span style="color: #0000ff;">near</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; DATA XREF: .data:BF998A74o</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A3</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A3 var_C&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span style="color: #0000ff;">dword</span> <span style="color: #0000ff;">ptr</span> -<span style="color: #ff0000;">0Ch</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A3 var_8&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span style="color: #0000ff;">dword</span> <span style="color: #0000ff;">ptr</span> -<span style="color: #ff0000;color:#800000;">8</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A3 arg_0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span style="color: #0000ff;">dword</span> <span style="color: #0000ff;">ptr</span>&nbsp; <span style="color: #ff0000;color:#800000;">8</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A3 arg_4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span style="color: #0000ff;">dword</span> <span style="color: #0000ff;">ptr</span>&nbsp; <span style="color: #ff0000;">0Ch</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A3 arg_8&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= <span style="color: #0000ff;">dword</span> <span style="color: #0000ff;">ptr</span>&nbsp; 10h</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A3</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A3 <span style="color: #adadad; font-style: italic;">; FUNCTION CHUNK AT .text:BF89784F SIZE 00000007 BYTES</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A3 <span style="color: #adadad; font-style: italic;">; FUNCTION CHUNK AT .text:BF897893 SIZE 0000000B BYTES</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A3</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">edi</span>, <span style="color: #46aa03; font-weight:bold;">edi</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A5&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">ebp</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A6&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ebp</span>, <span style="color: #46aa03; font-weight:bold;">esp</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978A8&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">sub</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">esp</span>, <span style="color: #ff0000;">0Ch</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978AB&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">esi</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978AC&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _EnterCrit@<span style="color: #ff0000;color:#800000;">0</span>&nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; EnterCrit()</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978B1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ecx</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_0<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978B4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; @ValidateHwnd@<span style="color: #ff0000;color:#800000;">4</span> <span style="color: #adadad; font-style: italic;">; ValidateHwnd(x)</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978B9&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">test</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">eax</span>, <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978BB&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">jz</span>&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">short</span> loc_BF89784F</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978BD&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">movzx</span>&nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ecx</span>, <span style="color: #0000ff;">word</span> <span style="color: #0000ff;">ptr</span> <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">eax</span>+2Ah<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978C1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">and</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ecx</span>, <span style="color: #ff0000;">0FFFF3FFFh</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978C7&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">cmp</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ecx</span>, 29Dh</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978CD&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">jz</span>&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">short</span> loc_BF89784F</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978CF&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">cmp</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ecx</span>, 29Fh</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978D5&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">jz</span>&nbsp; &nbsp; &nbsp; loc_BF89784F</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978DB&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ecx</span>, _gptiCurrent</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978E1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">edx</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ecx</span>+28h<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978E4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+var_C<span style="color: #66cc66;">&#93;</span>, <span style="color: #46aa03; font-weight:bold;">edx</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978E7&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">lea</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">edx</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+var_C<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978EA&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ecx</span>+28h<span style="color: #66cc66;">&#93;</span>, <span style="color: #46aa03; font-weight:bold;">edx</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978ED&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ecx</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_8<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978F0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+var_8<span style="color: #66cc66;">&#93;</span>, <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978F3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">inc</span>&nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">dword</span> <span style="color: #0000ff;">ptr</span> <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">eax</span>+<span style="color: #ff0000;color:#800000;">4</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978F6&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">and</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ecx</span>, <span style="color: #ff0000;color:#800000;">1</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978F9&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">cmp</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">ecx</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_8<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978FC&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">jnz</span>&nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">short</span> loc_BF897893</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978FE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_8<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897901&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #46aa03; font-weight:bold;">ebp</span>+arg_4<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897904&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897905&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _xxxPrintWindow@<span style="color: #ff0000;color:#800000;">12</span> <span style="color: #adadad; font-style: italic;">; xxxPrintWindow(x,x,x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89790A&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">esi</span>, <span style="color: #46aa03; font-weight:bold;">eax</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89790C</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89790C loc_BF89790C:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; CODE XREF: NtUserPrintWindow(x,x,x)-7j</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89790C&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _ThreadUnlock1@<span style="color: #ff0000;color:#800000;">0</span> <span style="color: #adadad; font-style: italic;">; ThreadUnlock1()</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897911</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897911 loc_BF897911:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; CODE XREF: NtUserPrintWindow(x,x,x)-52j</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897911&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _LeaveCrit@<span style="color: #ff0000;color:#800000;">0</span>&nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; LeaveCrit()</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897916&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">mov</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">eax</span>, <span style="color: #46aa03; font-weight:bold;">esi</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897918&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">pop</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">esi</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897919&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">leave</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89791A&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">retn</span>&nbsp; &nbsp; <span style="color: #ff0000;">0Ch</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89791A _NtUserPrintWindow@<span style="color: #ff0000;color:#800000;">12</span> <span style="color: #0000ff;">endp</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="asm-20">
<div class="asm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897893 <span style="color: #adadad; font-style: italic;">; ---------------------------------------------------------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897893 <span style="color: #adadad; font-style: italic;">; START OF FUNCTION CHUNK FOR _NtUserPrintWindow@12</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897893</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897893 loc_BF897893:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; CODE XREF: NtUserPrintWindow(x,x,x)+59j</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897893&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">push</span>&nbsp; &nbsp; 57h</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897895&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">xor</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">esi</span>, <span style="color: #46aa03; font-weight:bold;">esi</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897897&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _UserSetLastError@<span style="color: #ff0000;color:#800000;">4</span> <span style="color: #adadad; font-style: italic;">; UserSetLastError(x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89789C&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">jmp</span>&nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">short</span> loc_BF89790C</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89789C <span style="color: #adadad; font-style: italic;">; END OF FUNCTION CHUNK FOR _NtUserPrintWindow@12</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89789C <span style="color: #adadad; font-style: italic;">; --------------------------------------------------------------------------- </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="asm-21">
<div class="asm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89784F <span style="color: #adadad; font-style: italic;">; ---------------------------------------------------------------------------</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89784F <span style="color: #adadad; font-style: italic;">; START OF FUNCTION CHUNK FOR _NtUserPrintWindow@12</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89784F</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89784F loc_BF89784F:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; CODE XREF: NtUserPrintWindow(x,x,x)+18j</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89784F&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; NtUserPrintWindow(x,x,x)+2Aj ...</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89784F&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">xor</span>&nbsp; &nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">esi</span>, <span style="color: #46aa03; font-weight:bold;">esi</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897851&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">jmp</span>&nbsp; &nbsp; &nbsp;loc_BF897911</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897851 <span style="color: #adadad; font-style: italic;">; END OF FUNCTION CHUNK FOR _NtUserPrintWindow@12</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897856 <span style="color: #adadad; font-style: italic;">; --------------------------------------------------------------------------- </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>So here I am bombing you with assembly... How rude...<br />
In order to know what happens, we could try our analysis by looking at the calls the function does:</p>
<div class="syntax_hilite">
<div id="asm-22">
<div class="asm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978AC&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _EnterCrit@<span style="color: #ff0000;color:#800000;">0</span>&nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; EnterCrit()</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF8978B4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; @ValidateHwnd@<span style="color: #ff0000;color:#800000;">4</span> <span style="color: #adadad; font-style: italic;">; ValidateHwnd(x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897905&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _xxxPrintWindow@<span style="color: #ff0000;color:#800000;">12</span> <span style="color: #adadad; font-style: italic;">; xxxPrintWindow(x,x,x)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF89790C&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _ThreadUnlock1@<span style="color: #ff0000;color:#800000;">0</span> <span style="color: #adadad; font-style: italic;">; ThreadUnlock1()</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897911&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _LeaveCrit@<span style="color: #ff0000;color:#800000;">0</span>&nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; LeaveCrit()</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:BF897897&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">call</span>&nbsp; &nbsp; _UserSetLastError@<span style="color: #ff0000;color:#800000;">4</span> <span style="color: #adadad; font-style: italic;">; UserSetLastError(x) </span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
And what do we see:<br />
- <code>EnterCrit</code>/<code>LeaveCrit</code>: this functions are used for thread synchronization. It must be here to prevent the function from being executed more than once at the same time. See <code>EnterCriticalSection</code> and <code>LeaveCriticalSection</code>.<br />
- <code>ValidateHwnd</code>: we don't know at the moment what it does, but we know it's <code>__fastcall</code> (thanks to the mangling), so it must be called very very often.<br />
- <code>xxxPrintWindow</code>: interesting, must be the underlying <code>PrintWindow</code> implementation.<br />
- <code>ThreadUnlock</code>: used to unlock the thread<br />
- <code>UserSetLastError</code>: used to set the last error in case something went wrong.</p>
<p>With all this it's pretty fair to assume the real <code>PrintWindow</code> code is actually done in <code>xxxPrintWindow</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://siwu.info/6/reverse-engineering-the-windows-xp-window-manager-part-3.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Reverse Engineering the Windows XP Window Manager, Part 2: IDA is my ally</title>
		<link>http://siwu.info/5/reverse-engineering-the-windows-xp-window-manager-part-2-ida-is-my-ally.html</link>
		<comments>http://siwu.info/5/reverse-engineering-the-windows-xp-window-manager-part-2-ida-is-my-ally.html#comments</comments>
		<pubDate>Sat, 21 Oct 2006 03:13:21 +0000</pubDate>
		<dc:creator>siwu</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[Research]]></category>

		<guid isPermaLink="false">http://siwuzzz.free.fr/?p=5</guid>
		<description><![CDATA[First thing I did was fire up IDA and take a look at the disassembly of the PrintWindow. The function is exported in User32.dll.
And here is what I came accross:





.text:77D5D2A0 ; Exported entry 517. PrintWindow


.text:77D5D2A0


.text:77D5D2A0 ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦


.text:77D5D2A0


.text:77D5D2A0


.text:77D5D2A0 ; __stdcall NtUserPrintWindow(x, x, x)


.text:77D5D2A0&#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>First thing I did was fire up <a href="http://www.datarescue.com/idabase/" >IDA</a> and take a look at the disassembly of the <code>PrintWindow</code>. The function is exported in <code>User32.dll</code>.</p>
<p>And here is what I came accross:</p>
<div class="syntax_hilite">
<div id="asm-28">
<div class="asm">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:77D5D2A0 <span style="color: #adadad; font-style: italic;">; Exported entry 517. PrintWindow</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:77D5D2A0</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:77D5D2A0 <span style="color: #adadad; font-style: italic;">; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:77D5D2A0</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:77D5D2A0</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">.text:77D5D2A0 <span style="color: #adadad; font-style: itali