<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>CX_BLOG</title>
	<atom:link href="http://codexlive.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://codexlive.wordpress.com</link>
	<description>Retarded gamehacking/programming by Codex.</description>
	<lastBuildDate>Wed, 06 Feb 2008 04:59:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='codexlive.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>CX_BLOG</title>
		<link>http://codexlive.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://codexlive.wordpress.com/osd.xml" title="CX_BLOG" />
	<atom:link rel='hub' href='http://codexlive.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Scanning for values/addresses</title>
		<link>http://codexlive.wordpress.com/2008/02/01/scanning-for-valuesaddresses/</link>
		<comments>http://codexlive.wordpress.com/2008/02/01/scanning-for-valuesaddresses/#comments</comments>
		<pubDate>Sat, 02 Feb 2008 02:19:36 +0000</pubDate>
		<dc:creator>Codex</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://codexlive.wordpress.com/?p=14</guid>
		<description><![CDATA[Little article about scanning for values (&#8220;searching&#8221;) or finding addresses based on their values. This is intended for everyone, but I present it at the basic level to accomplish this. Sorry if you see information that is redundant and stupid to you; it may be new and useful to someone else. First things first, though, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codexlive.wordpress.com&amp;blog=2665489&amp;post=14&amp;subd=codexlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Little article about scanning for values (&#8220;searching&#8221;) or finding addresses based on their values.<br />
This is intended for everyone, but I present it at the basic level to accomplish this.  Sorry if you see information that is redundant and stupid to you; it may be new and useful to someone else.</p>
<p>First things first, though, in case you don&#8217;t understand how addresses &amp; their &#8220;values&#8221; work.<br />
Let&#8217;s look at a random address from a random program.<br />
<code>0x004012AF</code> is the address.  The opcode at this address is <code>MOV DWORD PTR SS:[ESP+4],EAX</code>.  The hexadecimal representation of this opcode is <code>0x89 0x44 0x24 0x04</code>.  This is also the same thing as what many people know as the &#8220;array of bytes&#8221;.  In little endian, this is <code>0x04244489</code>.  In decimal, this is <code>69485705</code>.  This is also the same thing as what many people know as the &#8220;value&#8221; of the address.<br />
So, the opcode, array of bytes, and value (whether in decimal or hexadecimal) are ALL the SAME THING.  They&#8217;re just different representations/notations.  So if you edit the value of an address, you edit the array of bytes and the opcode as well.  Same thing applies for visa-versa.</p>
<p>So anyways, now that you know that (or if you already did know that), there are many ways to search.  You can search for the byte signature (&#8220;array of bytes&#8221;) or the value of the address.  I prefer the byte signature because it&#8217;s a little cooler and allows for some variation.</p>
<p>Here is the address with all values, again, for reference.  (<a href="http://rafb.net/p/X8px3f64.nln.html">Link to reference paste.</a>)<br />
<code>ADDRESS: 0x004012AF  |  MOV DWORD PTR SS:[ESP+4],EAX  |  0x89 0x44 0x24 0x04  |  0x04244489  |  69485705</code><br />
So, the address 0x004012AF has a FOUR BYTE value.  A WORD is two bytes, and a DWORD (double word) is FOUR BYTES.  So our address has a DWORD value.<br />
Each incrementing address contains one of the bytes.  Ex:<br />
<code>0x004012AF:    0x89<br />
0x004012B0:    0x44<br />
0x004012B1:    0x24<br />
0x004012B2:    0x04</code></p>
<p>So, if we want to search for each byte in a pattern (like searching for arrays of bytes), we have to search each address independently, then increment the address and our slot in the array.</p>
<p>If we want to search for values, it&#8217;s more simple.</p>
<p><b>Take note that these code examples search for values WITHIN THE CURRENT PROCESS.<br />
If you want to use them externally, modify them to use the ReadProcessMemory API!</b></p>
<p><b>Also note that the whole code has to be run in an independent thread so that it doesn&#8217;t kill the program by messing up the flow!</b><br />
If you&#8217;re using CE, you can do this by going to the address of the new thread and going to the tools menu -&gt; create thread (or press CTRL+ALT+T).</p>
<p>Otherwise, use the CreateThread API.</p>
<p>ASM:<br />
<code>push 0<br />
push 0<br />
push 0<br />
push NewThread<br />
push 0<br />
push 0<br />
call CreateThread<br />
// EAX (return value) contains handle to the new thread.</code></p>
<p>C:<br />
<code>CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)NewThread, NULL, 0, 0);<br />
// Returns the handle to the new thread.</code></p>
<p>Also note that this is not very efficient coding.  Just get the general idea from it.</p>
<p>On to the code!</p>
<p><b>ASM:<br />
</b><span class="postbody">// Declare FoundAddy as a DWORD.<br />
// Declare BytePattern as however many bytes you use (a DWORD in this case).</p>
<p>FoundAddy:   // Will contain the found addy or 0 if no addy is found.<br />
db 00 00 00 00</p>
<p>BytePattern:   // Defines your byte pattern.<br />
db 89<br />
db 44<br />
db 24<br />
db 04</p>
<p>FindAddressThread:<br />
mov eax, 00400000   // Address to start at.<br />
mov ecx, 00300000   // Range of address (how many bytes to search).</p>
<p>SearchLoop:      // Compares byte pattern to the current search address.<br />
mov ebx,[BytePattern]<br />
cmp byte ptr [eax], ebx<br />
jne NotFound</p>
<p>mov ebx,[BytePattern+1]<br />
cmp byte ptr [eax+1], ebx<br />
jne NotFound</p>
<p>mov ebx,[BytePattern+2]<br />
cmp byte ptr [eax+2], ebx<br />
jne NotFound</p>
<p>mov ebx,[BytePattern+3]<br />
cmp byte ptr [eax+3], ebx<br />
je Found</p>
<p>NotFound:      // Accessed if byte pattern didn&#8217;t match current addy.<br />
inc eax         // Increments the current addy by one.<br />
loop SearchLoop      // Decrements CX by one, then jumps to SearchLoop if CX is not equal to 0.<br />
mov [FoundAddy],0   // This is accessed if the loop is not taken, meaning no addresses were found.<br />
push 0<br />
call ExitThread      // Exits thread (duh).</p>
<p>Found:         // Accessed if byte pattern matched current addy.<br />
mov [FoundAddy],eax   // Record the found address.<br />
push 0<br />
call ExitThread      // Exits thread (duh).</span><br />
<b> This is meant to be its own thread without anything else.  You can modify it to return a value so that the proc is called.</b></p>
<p><b>C(++):<br />
</b><span class="postbody">DWORD SearchBytes(DWORD Value, DWORD StartAddress, DWORD EndAddress)<br />
{<br />
for (DWORD CurrentAddress = StartAddress; CurrentAddress &lt;= EndAddress; CurrentAddress++)<br />
{<br />
if (*(DWORD*)CurrentAddress == Value)<br />
return CurrentAddress;<br />
}<br />
return 0;<br />
}</span><br />
<b> This is a proc that you call, but it should be called from within a separate thread.  Feel free to modify it.  This code just searches a value.</b></p>
<p>Done.  Questions/comments?  Contact me on MSN (codexlive@hotmail.com) or comment here.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codexlive.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codexlive.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codexlive.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codexlive.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codexlive.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codexlive.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codexlive.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codexlive.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codexlive.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codexlive.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codexlive.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codexlive.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codexlive.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codexlive.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codexlive.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codexlive.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codexlive.wordpress.com&amp;blog=2665489&amp;post=14&amp;subd=codexlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codexlive.wordpress.com/2008/02/01/scanning-for-valuesaddresses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cebd1324dbbd3a273140efc28897ae70?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Codex</media:title>
		</media:content>
	</item>
		<item>
		<title>Upcoming posts</title>
		<link>http://codexlive.wordpress.com/2008/01/31/upcoming-posts/</link>
		<comments>http://codexlive.wordpress.com/2008/01/31/upcoming-posts/#comments</comments>
		<pubDate>Fri, 01 Feb 2008 06:57:46 +0000</pubDate>
		<dc:creator>Codex</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codexlive.wordpress.com/?p=13</guid>
		<description><![CDATA[Soon (friday/weekend) I&#8217;ll write some shit. It will probably be about searching for values (&#38; thus finding dynamic addresses) in ASM and C++.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codexlive.wordpress.com&amp;blog=2665489&amp;post=13&amp;subd=codexlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Soon (friday/weekend) I&#8217;ll write some shit.</p>
<p>It will probably be about searching for values (&amp; thus finding dynamic addresses) in ASM and C++.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codexlive.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codexlive.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codexlive.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codexlive.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codexlive.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codexlive.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codexlive.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codexlive.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codexlive.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codexlive.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codexlive.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codexlive.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codexlive.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codexlive.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codexlive.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codexlive.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codexlive.wordpress.com&amp;blog=2665489&amp;post=13&amp;subd=codexlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codexlive.wordpress.com/2008/01/31/upcoming-posts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cebd1324dbbd3a273140efc28897ae70?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Codex</media:title>
		</media:content>
	</item>
		<item>
		<title>First post</title>
		<link>http://codexlive.wordpress.com/2008/01/29/first-post/</link>
		<comments>http://codexlive.wordpress.com/2008/01/29/first-post/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 06:52:57 +0000</pubDate>
		<dc:creator>Codex</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://codexlive.wordpress.com/2008/01/29/first-post/</guid>
		<description><![CDATA[Made a shitty blog for no reason. Sick.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codexlive.wordpress.com&amp;blog=2665489&amp;post=12&amp;subd=codexlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Made a shitty blog for no reason.</p>
<p>Sick.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/codexlive.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/codexlive.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codexlive.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codexlive.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codexlive.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codexlive.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/codexlive.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/codexlive.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/codexlive.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/codexlive.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codexlive.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codexlive.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codexlive.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codexlive.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codexlive.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codexlive.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codexlive.wordpress.com&amp;blog=2665489&amp;post=12&amp;subd=codexlive&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://codexlive.wordpress.com/2008/01/29/first-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/cebd1324dbbd3a273140efc28897ae70?s=96&#38;d=identicon" medium="image">
			<media:title type="html">Codex</media:title>
		</media:content>
	</item>
	</channel>
</rss>
