<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Why does the compiler generate a MOV  EDI, EDI instruction at the beginning of functions?</title><link>http://blogs.msdn.com/b/ishai/archive/2004/06/24/165143.aspx</link><description>Why does the compiler generate a MOV EDI, EDI instruction at the beginning of functions? 
 
 I&amp;#8217;ve recently noticed that on the XPSP2 Beta that I am running the function prologs look like this: 
 
 MOV EDI, EDI 
 PUSH EBP 
 MOV EBP, ESP 
</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>  Sense out of Nonsene : Acceptably Unique</title><link>http://blogs.msdn.com/b/ishai/archive/2004/06/24/165143.aspx#9640796</link><pubDate>Mon, 25 May 2009 22:52:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9640796</guid><dc:creator>  Sense out of Nonsene : Acceptably Unique</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://bradykelly.net/?p=25"&gt;http://bradykelly.net/?p=25&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9640796" width="1" height="1"&gt;</description></item><item><title>  You Won&amp;#8217;t Learn This in School: Disabling Kernel Functions in Your Process | Chad Austin</title><link>http://blogs.msdn.com/b/ishai/archive/2004/06/24/165143.aspx#9521912</link><pubDate>Tue, 31 Mar 2009 11:14:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9521912</guid><dc:creator>  You Won&amp;#8217;t Learn This in School: Disabling Kernel Functions in Your Process | Chad Austin</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://aegisknight.org/2009/03/disabling-functions/"&gt;http://aegisknight.org/2009/03/disabling-functions/&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9521912" width="1" height="1"&gt;</description></item><item><title>re: Why does the compiler generate a MOV  EDI, EDI instruction at the beginning of functions?</title><link>http://blogs.msdn.com/b/ishai/archive/2004/06/24/165143.aspx#166003</link><pubDate>Fri, 25 Jun 2004 16:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:166003</guid><dc:creator>Ishai</dc:creator><description>Detours change a binary file offline.  Hot patching is done on a running executable and they want to guarantee that the instruction pointer does not point in the middle of the patched area.&lt;br&gt;&lt;br&gt;Using the Detours method on a live process would require suspending threads and making sure no thread instruction pointer is pointing at the second, third, forth, or fifth byte of a function that is being Detoured and handling the case that it does. &lt;br&gt;&lt;br&gt;A Detour will also put limitation on the code generation (i.e. never jump to instructions in bytes 2-5).&lt;br&gt;&lt;br&gt;Seems to be possible but more complicated than placing a gap between functions and ensuring a 2-byte first instruction.  &lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=166003" width="1" height="1"&gt;</description></item><item><title>re: Why does the compiler generate a MOV  EDI, EDI instruction at the beginning of functions?</title><link>http://blogs.msdn.com/b/ishai/archive/2004/06/24/165143.aspx#165576</link><pubDate>Fri, 25 Jun 2004 08:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:165576</guid><dc:creator>Ziv Caspi</dc:creator><description>It's interesting they've chosen this method for patching. It not only requires 2 extra bytes per entry, but it also requires you put gaps every once in a while between methods for the 5-bytes long jump (in theory, one gap per method, if you need to patch them all).&lt;br&gt;&lt;br&gt;It does have an advantage if you have extremely short functions (less than 5 bytes required for a long jump) or in cases where functions share code, but these could have been taken care of by a simple modification of the compiler in any case.&lt;br&gt;&lt;br&gt;Do you know why they didn't rely on in-place patching like what is done with Detours?&lt;br&gt;&lt;br&gt;(BTW -- Welcome aboard, Ishai!)&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=165576" width="1" height="1"&gt;</description></item></channel></rss>