<?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 for Insanely Low-Level</title>
	<atom:link href="http://www.ragestorm.net/blogs/?feed=comments-rss2" rel="self" type="application/rss+xml" />
	<link>http://www.ragestorm.net/blogs</link>
	<description>An Arkon Blog</description>
	<lastBuildDate>Sun, 29 Apr 2012 19:55:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>Comment on isX64 Gem by Brundle Lab &#124; The result could be different as expected</title>
		<link>http://www.ragestorm.net/blogs/?p=376&#038;cpage=1#comment-4366</link>
		<dc:creator>Brundle Lab &#124; The result could be different as expected</dc:creator>
		<pubDate>Sun, 29 Apr 2012 19:55:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.ragestorm.net/blogs/?p=376#comment-4366</guid>
		<description>[...] NOTE: This difference in the opcode translation is leveraged in a very neat trick in order to make your shellcode architecture independent. Read more here. [...]</description>
		<content:encoded><![CDATA[<p>[...] NOTE: This difference in the opcode translation is leveraged in a very neat trick in order to make your shellcode architecture independent. Read more here. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript Sucks by James Hancock</title>
		<link>http://www.ragestorm.net/blogs/?p=63&#038;cpage=1#comment-4365</link>
		<dc:creator>James Hancock</dc:creator>
		<pubDate>Fri, 27 Apr 2012 14:17:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.ragestorm.net/blogs/?p=63#comment-4365</guid>
		<description>All late bound script languages suck.

They are not discoverable, they&#039;re not syntax checkable, you can&#039;t catch errors at compile and design time, they&#039;re virtually untestable because of no structure, and javascript is just worse than most.

First law of programming is &quot;Do no magic&quot;. But almost everything is magic in javascript.

Want an array of classes?

Sure, go ahead and put them in and name the fields whatever you want, and every element of the array can have a different definition.

Wow this is so powerful!

NOT. 

It&#039;s a good way to have typos up your ass, have almost impossible to debug code because you&#039;ll only hit it every once in a blue moon, and you don&#039;t have a class definition that anyone else can work from and understand.

Then there is the magic inline functions and definitions as a result of this stupid array syntax that lets you define a ton of crap all at once.

Sorry, but the only thing about this syntax (see the .ajax function on jquery for examples) is that it&#039;s short. But I type 120 words a minute. I could give a damn about short. I want readable code, that is clear what it&#039;s doing, with no magic and no made up stuff that you have to dig into documentation forever to find.

Oh, and then, because of all of this dynamic late bound CRAP there is no intellisense, so you can&#039;t splunk frameworks at all.

Oh and then there is 0 intelligent error handling in any functions so it normally crashes in minified (or incredibly complex code written by someone else that you can&#039;t possibly understand because of the magic that is going on) code with no way of knowing WHY.

Javascript is a step back to the dark ages. I would say that it was a step back to something that I&#039;ve used in the past 30 years, but you know what? There isn&#039;t anything that I&#039;ve ever written in other than maybe Scheme/LISP on unix in a text editor that is as bad and that was for largely the same reasons, but wasn&#039;t nearly as bad because it still required STRUCTURE instead of made up crap.

And the worst part of this whole thing is that .NET and other real languages are copying this crap and making their languages worse to deal with the mess that is javascript.

End the madness. Give us a strongly typed, fully bound language for web. If script kiddies copying and pasting want to use this crap, let them. For the rest of us, give us a real language.

GRRRR.</description>
		<content:encoded><![CDATA[<p>All late bound script languages suck.</p>
<p>They are not discoverable, they&#8217;re not syntax checkable, you can&#8217;t catch errors at compile and design time, they&#8217;re virtually untestable because of no structure, and javascript is just worse than most.</p>
<p>First law of programming is &#8220;Do no magic&#8221;. But almost everything is magic in javascript.</p>
<p>Want an array of classes?</p>
<p>Sure, go ahead and put them in and name the fields whatever you want, and every element of the array can have a different definition.</p>
<p>Wow this is so powerful!</p>
<p>NOT. </p>
<p>It&#8217;s a good way to have typos up your ass, have almost impossible to debug code because you&#8217;ll only hit it every once in a blue moon, and you don&#8217;t have a class definition that anyone else can work from and understand.</p>
<p>Then there is the magic inline functions and definitions as a result of this stupid array syntax that lets you define a ton of crap all at once.</p>
<p>Sorry, but the only thing about this syntax (see the .ajax function on jquery for examples) is that it&#8217;s short. But I type 120 words a minute. I could give a damn about short. I want readable code, that is clear what it&#8217;s doing, with no magic and no made up stuff that you have to dig into documentation forever to find.</p>
<p>Oh, and then, because of all of this dynamic late bound CRAP there is no intellisense, so you can&#8217;t splunk frameworks at all.</p>
<p>Oh and then there is 0 intelligent error handling in any functions so it normally crashes in minified (or incredibly complex code written by someone else that you can&#8217;t possibly understand because of the magic that is going on) code with no way of knowing WHY.</p>
<p>Javascript is a step back to the dark ages. I would say that it was a step back to something that I&#8217;ve used in the past 30 years, but you know what? There isn&#8217;t anything that I&#8217;ve ever written in other than maybe Scheme/LISP on unix in a text editor that is as bad and that was for largely the same reasons, but wasn&#8217;t nearly as bad because it still required STRUCTURE instead of made up crap.</p>
<p>And the worst part of this whole thing is that .NET and other real languages are copying this crap and making their languages worse to deal with the mess that is javascript.</p>
<p>End the madness. Give us a strongly typed, fully bound language for web. If script kiddies copying and pasting want to use this crap, let them. For the rest of us, give us a real language.</p>
<p>GRRRR.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Opening a file by ID &#8211; FILE_OPEN_BY_FILE_ID by Peter</title>
		<link>http://www.ragestorm.net/blogs/?p=186&#038;cpage=1#comment-4356</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Wed, 04 Apr 2012 11:56:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.ragestorm.net/blogs/?p=186#comment-4356</guid>
		<description>Did you find a solution lev? What i have does is to use OpenFileById since we can use NtCreateFile on Windows XP. On windows 7 ntcreatefile will give you access denied. My solution was to load a unmanaged dll in c# that calls OpenFileById. This works fine on Windows Vista and up (x86 and x64). But i&#039;d love to see a working solution in c# in regards of the file descriptor struct. I&#039;ve spent days trying to make viable solution in c#, but it seems hopeless to get it working.</description>
		<content:encoded><![CDATA[<p>Did you find a solution lev? What i have does is to use OpenFileById since we can use NtCreateFile on Windows XP. On windows 7 ntcreatefile will give you access denied. My solution was to load a unmanaged dll in c# that calls OpenFileById. This works fine on Windows Vista and up (x86 and x64). But i&#8217;d love to see a working solution in c# in regards of the file descriptor struct. I&#8217;ve spent days trying to make viable solution in c#, but it seems hopeless to get it working.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Appfront by Colin</title>
		<link>http://www.ragestorm.net/blogs/?p=391&#038;cpage=1#comment-4343</link>
		<dc:creator>Colin</dc:creator>
		<pubDate>Fri, 02 Mar 2012 11:57:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.ragestorm.net/blogs/?p=391#comment-4343</guid>
		<description>Your blog is amusing and fascinating!</description>
		<content:encoded><![CDATA[<p>Your blog is amusing and fascinating!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Finding Kernel32 Base Address Shellcode by hopcode</title>
		<link>http://www.ragestorm.net/blogs/?p=369&#038;cpage=1#comment-4342</link>
		<dc:creator>hopcode</dc:creator>
		<pubDate>Tue, 28 Feb 2012 10:12:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.ragestorm.net/blogs/?p=369#comment-4342</guid>
		<description>Hi arkon,
site looks very nice.
my 2 explaining papers

PEB 64
http://sites.google.com/site/x64lab/home/notes-on-x64-windows-gui-programming/exploring-peb-process-environment-block

and custom GetProcAdress

https://sites.google.com/site/x64lab/home/notes-on-x64-windows-gui-programming/customizing-the-getprocaddress

Cheers,</description>
		<content:encoded><![CDATA[<p>Hi arkon,<br />
site looks very nice.<br />
my 2 explaining papers</p>
<p>PEB 64<br />
<a href="http://sites.google.com/site/x64lab/home/notes-on-x64-windows-gui-programming/exploring-peb-process-environment-block" rel="nofollow">http://sites.google.com/site/x64lab/home/notes-on-x64-windows-gui-programming/exploring-peb-process-environment-block</a></p>
<p>and custom GetProcAdress</p>
<p><a href="https://sites.google.com/site/x64lab/home/notes-on-x64-windows-gui-programming/customizing-the-getprocaddress" rel="nofollow">https://sites.google.com/site/x64lab/home/notes-on-x64-windows-gui-programming/customizing-the-getprocaddress</a></p>
<p>Cheers,</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on A BSWAP Issue by mov wtf, 0</title>
		<link>http://www.ragestorm.net/blogs/?p=141&#038;cpage=1#comment-4335</link>
		<dc:creator>mov wtf, 0</dc:creator>
		<pubDate>Mon, 13 Feb 2012 18:37:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.ragestorm.net/blogs/?p=141#comment-4335</guid>
		<description>XCHG ah, al    ; 16-bit byte swap.  Not hard at all.</description>
		<content:encoded><![CDATA[<p>XCHG ah, al    ; 16-bit byte swap.  Not hard at all.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript Sucks by Tom</title>
		<link>http://www.ragestorm.net/blogs/?p=63&#038;cpage=1#comment-4334</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Sat, 11 Feb 2012 05:27:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.ragestorm.net/blogs/?p=63#comment-4334</guid>
		<description>@Crank
Just to clarify:

6: Afaik no UI framework is capable of modifying the UI from a non UI thread without issues. However, you can use thread marshalling (SL: Dispatcher.BeginInvoke) to update the UI during a background thread process. Best practice is to do it in more small pieces.

7: You can build up documents from the SL primitives, that will be also an UIElement. Furthermore, SL has PostScript Vector printing API.</description>
		<content:encoded><![CDATA[<p>@Crank<br />
Just to clarify:</p>
<p>6: Afaik no UI framework is capable of modifying the UI from a non UI thread without issues. However, you can use thread marshalling (SL: Dispatcher.BeginInvoke) to update the UI during a background thread process. Best practice is to do it in more small pieces.</p>
<p>7: You can build up documents from the SL primitives, that will be also an UIElement. Furthermore, SL has PostScript Vector printing API.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript Sucks by Scurvy Cur</title>
		<link>http://www.ragestorm.net/blogs/?p=63&#038;cpage=1#comment-4332</link>
		<dc:creator>Scurvy Cur</dc:creator>
		<pubDate>Mon, 30 Jan 2012 03:06:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.ragestorm.net/blogs/?p=63#comment-4332</guid>
		<description>Worst than the JavaScript language itself is the browser environment, where I&#039;ve noticed some operations fail silently on some browsers, or give incorrect results that are undetectable from within JavaScript code.

You can&#039;t unit test for whether a browser quietly places an element 30 pixels to the right of where you told it to place the element, nor can you unit-test for whether an in-memory Image grows and shrinks when you zoom in and out of a page with Ctrl+Scrollbar. Problems like this mean that, contrary to accepted JS wisdom, you have to explicitly check the host browser&#039;s name and not attempt to programmatically check for browser features.</description>
		<content:encoded><![CDATA[<p>Worst than the JavaScript language itself is the browser environment, where I&#8217;ve noticed some operations fail silently on some browsers, or give incorrect results that are undetectable from within JavaScript code.</p>
<p>You can&#8217;t unit test for whether a browser quietly places an element 30 pixels to the right of where you told it to place the element, nor can you unit-test for whether an in-memory Image grows and shrinks when you zoom in and out of a page with Ctrl+Scrollbar. Problems like this mean that, contrary to accepted JS wisdom, you have to explicitly check the host browser&#8217;s name and not attempt to programmatically check for browser features.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Binary Hooking Problems by Sirmabus</title>
		<link>http://www.ragestorm.net/blogs/?p=348&#038;cpage=1#comment-4322</link>
		<dc:creator>Sirmabus</dc:creator>
		<pubDate>Tue, 03 Jan 2012 22:35:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.ragestorm.net/blogs/?p=348#comment-4322</guid>
		<description>I have a related post on my blog here:
&quot;Knowing if and when you can fit a JMP5 binary hook.&quot; http://www.sirmabus.macromonkey.com/?p=124

Like you I use a disassembler/code analyzer for proper hooking.

Some comment  to other comments:
IAT hooking has it&#039;s usefulness. In particular where you want to control hooking at a module level.
At the same time this is also it&#039;s problem.  You have to do it for every loaded module.  Existing then an use an internal hook to catch newly loaded modules. And then this doesn&#039;t cover the cases where the API is accessed via &quot;GetProcAddress()&quot;.
Although you can replace the EAT vector too that will at least cover the 2nd case.

This is what madCodeHook does for problem API cases.
If IMHO you want to see an excellent  API hooking engine in practice is learn how MCH does it.
It&#039;s been around a long time, and is very complete and robust.

I don&#039;t claim to know all the answers but I feel people should look at each technique for it&#039;s usefulness.  Add them to your &quot;toolbox&quot; to use fitting the situations.  The main thing is to have an understanding of what they do, what their side effects are, etc.
As in most things science it&#039;s not always &quot;black and white&quot;.  Grey area&#039;s where there is more then one solution et al. And some things fitting more then other depending on your choice of paradigms, etc.
For instance if your target is a game and it has an anti-cheat then maybe you have (if it will still work for you) to hook the main exit point/block of a function.  Or maybe you can hook the IAT vector because it&#039;s not being checked (when the entry point is).

I prefer the binary hook method as it is the most complete for general purpose use.  And the same paradigm applies to general purpose, other then API hooking, too.

From my blog post you will see I made a little program (that has since been expanded) to walk through a single or many DLLs to get some statistics and metrics of some common hooking considerations.

The problem cases are actually pretty rare. So rare that for general purpose you probably don&#039;t even need to compensate for them.
Out of all the DLL exports in a XP 32bit &quot;system32&quot; folder less then 5% where a problem.
With the size increased to 6 bytes (for absolute jumps, etc.) it&#039;s still only about 10%.
And these percentages are actually less due to various error and special cases.

Just 32bit so far, I haven&#039;t had the need to do actual native 64bit hooks when actually even on a 64bit OS most of my target applications are still 32bit (using the OS WoW64 emulation internally).

Those NOP&#039;s (or the single byte int3/0xCC equivalent) are actually alignment padding bytes.  To get the big performance benefit of having function entry points 16 byte (partial cache line) aligned.
Incidentally, you want to have your bridge/trampoline code stubs aligned too. The difference is big between a few cycles for aligned or some ~100 cycles more not aligned. So use &quot;_aligned_malloc(p, 16)&quot; or similar when you allocate those.

What I found in my tests is that it&#039;s fine to assume if you see at least two of these NOPs in series you can assume them to be alignment bytes and overwrite  them for hooking.
Example, as you analyze a function entry for hooking and step over a &quot;retn&quot; and see these alignment bytes you can just overwrite them to place your JMP (or what ever) hook there.
It might not always be the case, there is some chance for error here (that will probably result in a crash). But again we are talking a small percentage here and you should have exception handling both in your hooks and setup some exception monitoring in your engine.

Furthermore what I added to my engine is to take advantage of these NOP padding to use them as a &quot;code cave&quot; and place a relative short (2 byte) JMP from the entry point to a NOP space where I can fit my JMP5 hook.  It&#039;s an extra level of indirection, although a relativity few extra cycles compared to many alternatives.

Also I have an option to place a single byte int3 instead to form an exception hook for more problem cases (requires your engine to handle exceptions of course).
If there is an actual function, you should be able to put a one byte hook there.
You can also do a HWBP as well (although limited to four per thread).
Although not ideal the as there is some ~100 cycle overhead per exception.  Maybe only an issue if the hook is on some very commonly called function.  An exception hook handling kernel driver could reduce the overhead quite a bit too.

Finally what my engine tries to do in every case where possible and feasible is to just copy the whole function (at least the first visible block from it anyhow. Another technique borrowed from MH).  This works particularly well for those short functions that are usually just a &quot;call xxx&quot; followed by a &quot;retn&quot; et al.
This has a performance advantage where your bridge/trampoline code doesn&#039;t need to branch back to original code space to continue.

These things will get the already low 5% problem area down even smaller to just a few percent.  Plus add to the tool box techniques that can be used as needed.</description>
		<content:encoded><![CDATA[<p>I have a related post on my blog here:<br />
&#8220;Knowing if and when you can fit a JMP5 binary hook.&#8221; <a href="http://www.sirmabus.macromonkey.com/?p=124" rel="nofollow">http://www.sirmabus.macromonkey.com/?p=124</a></p>
<p>Like you I use a disassembler/code analyzer for proper hooking.</p>
<p>Some comment  to other comments:<br />
IAT hooking has it&#8217;s usefulness. In particular where you want to control hooking at a module level.<br />
At the same time this is also it&#8217;s problem.  You have to do it for every loaded module.  Existing then an use an internal hook to catch newly loaded modules. And then this doesn&#8217;t cover the cases where the API is accessed via &#8220;GetProcAddress()&#8221;.<br />
Although you can replace the EAT vector too that will at least cover the 2nd case.</p>
<p>This is what madCodeHook does for problem API cases.<br />
If IMHO you want to see an excellent  API hooking engine in practice is learn how MCH does it.<br />
It&#8217;s been around a long time, and is very complete and robust.</p>
<p>I don&#8217;t claim to know all the answers but I feel people should look at each technique for it&#8217;s usefulness.  Add them to your &#8220;toolbox&#8221; to use fitting the situations.  The main thing is to have an understanding of what they do, what their side effects are, etc.<br />
As in most things science it&#8217;s not always &#8220;black and white&#8221;.  Grey area&#8217;s where there is more then one solution et al. And some things fitting more then other depending on your choice of paradigms, etc.<br />
For instance if your target is a game and it has an anti-cheat then maybe you have (if it will still work for you) to hook the main exit point/block of a function.  Or maybe you can hook the IAT vector because it&#8217;s not being checked (when the entry point is).</p>
<p>I prefer the binary hook method as it is the most complete for general purpose use.  And the same paradigm applies to general purpose, other then API hooking, too.</p>
<p>From my blog post you will see I made a little program (that has since been expanded) to walk through a single or many DLLs to get some statistics and metrics of some common hooking considerations.</p>
<p>The problem cases are actually pretty rare. So rare that for general purpose you probably don&#8217;t even need to compensate for them.<br />
Out of all the DLL exports in a XP 32bit &#8220;system32&#8243; folder less then 5% where a problem.<br />
With the size increased to 6 bytes (for absolute jumps, etc.) it&#8217;s still only about 10%.<br />
And these percentages are actually less due to various error and special cases.</p>
<p>Just 32bit so far, I haven&#8217;t had the need to do actual native 64bit hooks when actually even on a 64bit OS most of my target applications are still 32bit (using the OS WoW64 emulation internally).</p>
<p>Those NOP&#8217;s (or the single byte int3/0xCC equivalent) are actually alignment padding bytes.  To get the big performance benefit of having function entry points 16 byte (partial cache line) aligned.<br />
Incidentally, you want to have your bridge/trampoline code stubs aligned too. The difference is big between a few cycles for aligned or some ~100 cycles more not aligned. So use &#8220;_aligned_malloc(p, 16)&#8221; or similar when you allocate those.</p>
<p>What I found in my tests is that it&#8217;s fine to assume if you see at least two of these NOPs in series you can assume them to be alignment bytes and overwrite  them for hooking.<br />
Example, as you analyze a function entry for hooking and step over a &#8220;retn&#8221; and see these alignment bytes you can just overwrite them to place your JMP (or what ever) hook there.<br />
It might not always be the case, there is some chance for error here (that will probably result in a crash). But again we are talking a small percentage here and you should have exception handling both in your hooks and setup some exception monitoring in your engine.</p>
<p>Furthermore what I added to my engine is to take advantage of these NOP padding to use them as a &#8220;code cave&#8221; and place a relative short (2 byte) JMP from the entry point to a NOP space where I can fit my JMP5 hook.  It&#8217;s an extra level of indirection, although a relativity few extra cycles compared to many alternatives.</p>
<p>Also I have an option to place a single byte int3 instead to form an exception hook for more problem cases (requires your engine to handle exceptions of course).<br />
If there is an actual function, you should be able to put a one byte hook there.<br />
You can also do a HWBP as well (although limited to four per thread).<br />
Although not ideal the as there is some ~100 cycle overhead per exception.  Maybe only an issue if the hook is on some very commonly called function.  An exception hook handling kernel driver could reduce the overhead quite a bit too.</p>
<p>Finally what my engine tries to do in every case where possible and feasible is to just copy the whole function (at least the first visible block from it anyhow. Another technique borrowed from MH).  This works particularly well for those short functions that are usually just a &#8220;call xxx&#8221; followed by a &#8220;retn&#8221; et al.<br />
This has a performance advantage where your bridge/trampoline code doesn&#8217;t need to branch back to original code space to continue.</p>
<p>These things will get the already low 5% problem area down even smaller to just a few percent.  Plus add to the tool box techniques that can be used as needed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript Sucks by Agreed</title>
		<link>http://www.ragestorm.net/blogs/?p=63&#038;cpage=1#comment-4292</link>
		<dc:creator>Agreed</dc:creator>
		<pubDate>Tue, 20 Dec 2011 03:24:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.ragestorm.net/blogs/?p=63#comment-4292</guid>
		<description>I agree JavaScript sucks.

I&#039;m in the middle of reading two great books on the language:

1. Professional JavaScript for Web Developers (Zakas)
2. JavaScript Patterns (Stefanov)

Both of the books are excellent, so nothing against them or the authors at all; but so far I think it&#039;s an ugly, hacked-up and confusing language. The OO techniques are especially so. I need to get above &quot;intermediate&quot; level for professional reasons, but I&#039;m really not having fun. Give me a strictly typed, proper OO language anyday over this bunch of hacks.</description>
		<content:encoded><![CDATA[<p>I agree JavaScript sucks.</p>
<p>I&#8217;m in the middle of reading two great books on the language:</p>
<p>1. Professional JavaScript for Web Developers (Zakas)<br />
2. JavaScript Patterns (Stefanov)</p>
<p>Both of the books are excellent, so nothing against them or the authors at all; but so far I think it&#8217;s an ugly, hacked-up and confusing language. The OO techniques are especially so. I need to get above &#8220;intermediate&#8221; level for professional reasons, but I&#8217;m really not having fun. Give me a strictly typed, proper OO language anyday over this bunch of hacks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

