<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Case study: Fraps</title>
	<atom:link href="http://www.ring3circus.com/gameprogramming/case-study-fraps/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ring3circus.com/gameprogramming/case-study-fraps/</link>
	<description>Diary of a programmer, journal of a hacker.</description>
	<lastBuildDate>Tue, 23 Feb 2010 06:23:21 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: fromFr</title>
		<link>http://www.ring3circus.com/gameprogramming/case-study-fraps/comment-page-1/#comment-1390</link>
		<dc:creator>fromFr</dc:creator>
		<pubDate>Tue, 04 Aug 2009 15:36:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.ring3circus.com/gameprogramming/case-study-fraps/#comment-1390</guid>
		<description>Hi Greg,

1st, a thanks &quot;from France :)&quot; for this source of knowledge...
2nd, is this trick is still valid ?

Tnx a lot</description>
		<content:encoded><![CDATA[<p>Hi Greg,</p>
<p>1st, a thanks &#8220;from France <img src='http://www.ring3circus.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> &#8221; for this source of knowledge&#8230;<br />
2nd, is this trick is still valid ?</p>
<p>Tnx a lot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ImaNewbie</title>
		<link>http://www.ring3circus.com/gameprogramming/case-study-fraps/comment-page-1/#comment-209</link>
		<dc:creator>ImaNewbie</dc:creator>
		<pubDate>Wed, 28 Jan 2009 05:09:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.ring3circus.com/gameprogramming/case-study-fraps/#comment-209</guid>
		<description>Hello there!

It&#039;s very nice of you to publish sample of D3D9 hook. Thanks.

Although I was searching the web for weeks, reading lots of tutorials and articles, I&#039;m still confused with DirectX and D3D. And I still have questions unsolved.

So the problem is next. I have a DirectX application and I want to get pixel color from certain coords. I&#039;m doing this using C++ GetPixel(HDC, X, Y). It works with DirectX window, but it won&#039;t do when it&#039;s minimized/hidden. And I&#039;m wondering how FRAPS does this? I mean, I can capture a screenshot using FRAPS even if window is minimized and/or hidden. I know it inject fraps.dll in a window&#039;s process, but when I inject the same dll (using RemoteDll http://www.novell.com/coolsolutions/tools/17354.html)nothing happens.

So I want to ask what function(s) do I have to hook in order to be able to take a pixel color from some coords even if the DirectX window is minimized and/or hidden? I.e. I want to make DirectX application to draw itself in HDC or anywhere else (not a .bmp or .jpg or anything like that), even if it&#039;s minimized hidden.

Thanks in advance.

Kindest Regards, AP.</description>
		<content:encoded><![CDATA[<p>Hello there!</p>
<p>It&#8217;s very nice of you to publish sample of D3D9 hook. Thanks.</p>
<p>Although I was searching the web for weeks, reading lots of tutorials and articles, I&#8217;m still confused with DirectX and D3D. And I still have questions unsolved.</p>
<p>So the problem is next. I have a DirectX application and I want to get pixel color from certain coords. I&#8217;m doing this using C++ GetPixel(HDC, X, Y). It works with DirectX window, but it won&#8217;t do when it&#8217;s minimized/hidden. And I&#8217;m wondering how FRAPS does this? I mean, I can capture a screenshot using FRAPS even if window is minimized and/or hidden. I know it inject fraps.dll in a window&#8217;s process, but when I inject the same dll (using RemoteDll <a href="http://www.novell.com/coolsolutions/tools/17354.html)nothing" rel="nofollow" onclick="javascript:urchinTracker('/outbound/comment/http://www.novell.com/coolsolutions/tools/17354.html)nothing');">http://www.novell.com/coolsolutions/tools/17354.html)nothing</a> happens.</p>
<p>So I want to ask what function(s) do I have to hook in order to be able to take a pixel color from some coords even if the DirectX window is minimized and/or hidden? I.e. I want to make DirectX application to draw itself in HDC or anywhere else (not a .bmp or .jpg or anything like that), even if it&#8217;s minimized hidden.</p>
<p>Thanks in advance.</p>
<p>Kindest Regards, AP.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ed</title>
		<link>http://www.ring3circus.com/gameprogramming/case-study-fraps/comment-page-1/#comment-154</link>
		<dc:creator>Ed</dc:creator>
		<pubDate>Sun, 25 May 2008 02:05:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.ring3circus.com/gameprogramming/case-study-fraps/#comment-154</guid>
		<description>Hey Greg, another solution to enumproc is to load a very small dll into every process that does ONE, and only one thng:  Check if the real fraps dll needs loading.</description>
		<content:encoded><![CDATA[<p>Hey Greg, another solution to enumproc is to load a very small dll into every process that does ONE, and only one thng:  Check if the real fraps dll needs loading.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FRAPS vs. Hypercam - Emuforums.com</title>
		<link>http://www.ring3circus.com/gameprogramming/case-study-fraps/comment-page-1/#comment-153</link>
		<dc:creator>FRAPS vs. Hypercam - Emuforums.com</dc:creator>
		<pubDate>Sat, 24 May 2008 08:09:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.ring3circus.com/gameprogramming/case-study-fraps/#comment-153</guid>
		<description>[...] into every running process?&quot;  i think it only targets directX and openGL apps.    Wrong  It targets ANY application, regardless of API. Which is wrong and ineffective.   [...]</description>
		<content:encoded><![CDATA[<p>[...] into every running process?&quot;  i think it only targets directX and openGL apps.    Wrong  It targets ANY application, regardless of API. Which is wrong and ineffective.   [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FRAPS vs. Hypercam - Emuforums.com</title>
		<link>http://www.ring3circus.com/gameprogramming/case-study-fraps/comment-page-1/#comment-152</link>
		<dc:creator>FRAPS vs. Hypercam - Emuforums.com</dc:creator>
		<pubDate>Sat, 24 May 2008 07:52:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.ring3circus.com/gameprogramming/case-study-fraps/#comment-152</guid>
		<description>[...] into every running process?&quot;  i think it only targets directX and openGL apps.    Wrong  It targets ANY application, regardless of API.   [...]</description>
		<content:encoded><![CDATA[<p>[...] into every running process?&quot;  i think it only targets directX and openGL apps.    Wrong  It targets ANY application, regardless of API.   [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg</title>
		<link>http://www.ring3circus.com/gameprogramming/case-study-fraps/comment-page-1/#comment-138</link>
		<dc:creator>Greg</dc:creator>
		<pubDate>Fri, 28 Mar 2008 10:59:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.ring3circus.com/gameprogramming/case-study-fraps/#comment-138</guid>
		<description>Glad it worked out for you.

The RETN 4 is there to clean up the stack before returning. If you look at OutputDebugStringA&#039;s declaration, you&#039;ll see it&#039;s a &lt;tt&gt;stdcall&lt;/tt&gt; taking a single pointer. This calling convention dictates that the callee function must remove the arguments from the stack, and since a single pointer is four bytes long (on x86), RETN 4 is the quickest way to do it.</description>
		<content:encoded><![CDATA[<p>Glad it worked out for you.</p>
<p>The RETN 4 is there to clean up the stack before returning. If you look at OutputDebugStringA&#8217;s declaration, you&#8217;ll see it&#8217;s a <tt>stdcall</tt> taking a single pointer. This calling convention dictates that the callee function must remove the arguments from the stack, and since a single pointer is four bytes long (on x86), RETN 4 is the quickest way to do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel</title>
		<link>http://www.ring3circus.com/gameprogramming/case-study-fraps/comment-page-1/#comment-137</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Fri, 28 Mar 2008 02:14:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.ring3circus.com/gameprogramming/case-study-fraps/#comment-137</guid>
		<description>wow, amazing! what a find... and, the solution worked! I had a couple of illegal and privileged instructions but shift-f9 did solve it. now fraps is up and running, and i can continue my journey. 

btw, a general question - I wondered why the 4 in RETN 4? I know what the 4 does (increment the stack pointer by a further 4 bytes after popping the return address), just wondered why did you use it here

thanks much
J</description>
		<content:encoded><![CDATA[<p>wow, amazing! what a find&#8230; and, the solution worked! I had a couple of illegal and privileged instructions but shift-f9 did solve it. now fraps is up and running, and i can continue my journey. </p>
<p>btw, a general question &#8211; I wondered why the 4 in RETN 4? I know what the 4 does (increment the stack pointer by a further 4 bytes after popping the return address), just wondered why did you use it here</p>
<p>thanks much<br />
J</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg</title>
		<link>http://www.ring3circus.com/gameprogramming/case-study-fraps/comment-page-1/#comment-136</link>
		<dc:creator>Greg</dc:creator>
		<pubDate>Thu, 27 Mar 2008 17:05:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.ring3circus.com/gameprogramming/case-study-fraps/#comment-136</guid>
		<description>Hi again Joel.

I&#039;m pretty sure this is new behaviour. I just downloaded the latest Fraps, gave it a spin and saw Olly crash just like you did. Perhaps the makers of Fraps didn&#039;t take too kindly to my recent analysis, or maybe it&#039;s just a coincidence, but this is an anti-debug measure targetting OllyDbg.

Attaching a JIT debugger to the failed instance of OllyDbg (after Fraps has crashed it) reveals a very suspicious looking string not too far down the stack. It turns out that OllyDbg uses an unsanitised call to &lt;tt&gt;sprintf&lt;/tt&gt; in its console logging. Consequently, if the debuggee causes it to log a string containing formatting tokens, undefined behaviour ensues. In this case, a simple call to &lt;tt&gt;OutputDebugStringA(&quot;%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s...&quot;)&lt;/tt&gt; will cause a Olly to crash with certainty.

Normally I&#039;d patch the offending call out of the executable file, but Fraps seems to be packed, so the quickest way to proceed is to simply short-circuit OutputDebugStringA itself, in the target Fraps process before allowing execution to commence.

So to sidestep this nasty behaviour, load up Fraps, wait for Olly to pause at WinMain, then in the disassembly pane, &#039;Go to&#039; OutputDebugStringA, and assemble (space-bar) &#039;RETN 4&#039; at its first instruction. Now any calls to this function will return immediately, and execution may resume normally.

Unfortunately, this will need to be done each time you restart the target process, which is a bit of a pain, but if you&#039;re feeling ambitious you could either automate the process with an OllyScript or attempt to unpack the executable on disk and patch out the offending OutputDebugStringA calls (PEiD doesn&#039;t positively identify any packer, so I couldn&#039;t say how difficult this process will be).</description>
		<content:encoded><![CDATA[<p>Hi again Joel.</p>
<p>I&#8217;m pretty sure this is new behaviour. I just downloaded the latest Fraps, gave it a spin and saw Olly crash just like you did. Perhaps the makers of Fraps didn&#8217;t take too kindly to my recent analysis, or maybe it&#8217;s just a coincidence, but this is an anti-debug measure targetting OllyDbg.</p>
<p>Attaching a JIT debugger to the failed instance of OllyDbg (after Fraps has crashed it) reveals a very suspicious looking string not too far down the stack. It turns out that OllyDbg uses an unsanitised call to <tt>sprintf</tt> in its console logging. Consequently, if the debuggee causes it to log a string containing formatting tokens, undefined behaviour ensues. In this case, a simple call to <tt>OutputDebugStringA("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s...")</tt> will cause a Olly to crash with certainty.</p>
<p>Normally I&#8217;d patch the offending call out of the executable file, but Fraps seems to be packed, so the quickest way to proceed is to simply short-circuit OutputDebugStringA itself, in the target Fraps process before allowing execution to commence.</p>
<p>So to sidestep this nasty behaviour, load up Fraps, wait for Olly to pause at WinMain, then in the disassembly pane, &#8216;Go to&#8217; OutputDebugStringA, and assemble (space-bar) &#8216;RETN 4&#8242; at its first instruction. Now any calls to this function will return immediately, and execution may resume normally.</p>
<p>Unfortunately, this will need to be done each time you restart the target process, which is a bit of a pain, but if you&#8217;re feeling ambitious you could either automate the process with an OllyScript or attempt to unpack the executable on disk and patch out the offending OutputDebugStringA calls (PEiD doesn&#8217;t positively identify any packer, so I couldn&#8217;t say how difficult this process will be).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel</title>
		<link>http://www.ring3circus.com/gameprogramming/case-study-fraps/comment-page-1/#comment-135</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Thu, 27 Mar 2008 16:44:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.ring3circus.com/gameprogramming/case-study-fraps/#comment-135</guid>
		<description>Hi Greg,

and thanks again for an invalueble source of knowledge. I tried to run fraps in ollydbg, but it got stuck. i tried to search for the call IsDebuggerPresent (or something like that) to set there a breakpoint, but i think the freeze happens before

any tricks? i&#039;m a complete newbie to ollydbg, so if you could pin-point me it would be just great.

again, thanks a lot
Joel</description>
		<content:encoded><![CDATA[<p>Hi Greg,</p>
<p>and thanks again for an invalueble source of knowledge. I tried to run fraps in ollydbg, but it got stuck. i tried to search for the call IsDebuggerPresent (or something like that) to set there a breakpoint, but i think the freeze happens before</p>
<p>any tricks? i&#8217;m a complete newbie to ollydbg, so if you could pin-point me it would be just great.</p>
<p>again, thanks a lot<br />
Joel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Drawing on another Direct3D program&#8217;s viewport &#187; Ring3 Circus &#187; Diary of a programmer, journal of a hacker.</title>
		<link>http://www.ring3circus.com/gameprogramming/case-study-fraps/comment-page-1/#comment-11</link>
		<dc:creator>Drawing on another Direct3D program&#8217;s viewport &#187; Ring3 Circus &#187; Diary of a programmer, journal of a hacker.</dc:creator>
		<pubDate>Tue, 27 Nov 2007 09:32:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.ring3circus.com/gameprogramming/case-study-fraps/#comment-11</guid>
		<description>[...] moment is DLL hooking, and so I thought I&#8217;d present an applied example. I already explained how Fraps works, and since I&#8217;ve recently been roped into writing a similar tool for a stranger, I thought [...]</description>
		<content:encoded><![CDATA[<p>[...] moment is DLL hooking, and so I thought I&#8217;d present an applied example. I already explained how Fraps works, and since I&#8217;ve recently been roped into writing a similar tool for a stranger, I thought [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.609 seconds -->
