Thursday, March 22, 2012

Asmjit Installation

While some what known in the game hacking community. I don't think a lot of people know about asmjit. While it's taken me a bit to wrap my head around how it works (boy did that take a while) I must say it's pretty damn cool. So what it is asmjit? Well it let's you basically dynamically create assembly opcodes via C++. Why would you want to do that? Because in-lining asm is a pain when you want to play with the raw bytes. This way we can dynamically create our PIC and hopefully be able to stuff it into a remote process. Infact, the authors of
asmjit apparently already saw this as a good use and already created a remote injector for us!

So asmjit isn't a very straight forward setup. Here's the steps I had to do to get it all working.
1. Download asmjit from svn: svn checkout http://asmjit.googlecode.com/svn/trunk/ asmjit
2. Download cmake from: http://www.cmake.org/cmake/resources/software.html
3. Go to <where you downloaded>\AsmJit\AsmJit-1.0\Util. and run configure-windows-vs2008-x86.bat or which ever arch/Visual Studio version you want. If it doesn't work make sure cmake is in your path (or just modify the bat file to call the full path of cmake.exe
4. Now go to your AsmJit-1.0\Build folder and you should see all the project files. Open up AsmJit.sln or just AsmJit.vcproj and build it.
5. The last step should have produced a Debug directory and the AsmJit.dll and AsmJit.lib files.

Now to use AsmJit in your project do the following:
1. Create a new visual studio project -> win32 -> console -> Console Application and make sure "Precompiled header" is selected, and finish.
2. Right click on the project properties and add the "Include Directories", in my case it was in E:\Research\...

3. Now go down to Linker and add the AsmJit.lib

4. Of course Visual Studio needs to know where to find AsmJit.lib, so in VS 2008 you will need to add it to your library path.

5. Now you should be able to build and play with asmjit. (You'll probably need to copy the AsmJit.dll file to your executable's directory before running.)

I've got some working code already for calling MessageBox via assembly but I'll post that tomorrow. Enjoy for now!