Friday, October 26, 2007

My hook doesn't work :-(

A few days ago I rummaged through my old code snippets and sources on my harddisk. I noticed that I coded quite many PE tools, especially with Delphi, but something I have never created - an Api hook!
I read pretty much about it (there are many code snippets in the net about this), but most of them are complicated and badly commented so that it's difficult to undertstand what's going on. So I tried myself and began coding the most simple and clean api hook possible (in c cause it's better to read than asm): a little Messagebox hook which should alter the caption of all messageboxes.
Ok I thought, the most simple approach is to code a loader which starts a target process and loads my selfcoded 'hook dll file' into the address space with the well-known CreateRemoteThread trick. Inside the dll file is all the work: as soon as injected and attached, it travels through the import table of the process, searches for MessageBoxA API from user32.dll and replaces the RVA (called Thunk) with the RVA of my own function I declared in my dll file. Hm... sounds not bad although I know that this works just with exes with a straightforward import table - even loading the MessageBox API with GetProcAddress would bypass my approach. But that's not bad - if it would work.... Damn!
With some targets it works, but in others it corrups the stack!? That's a bit strange to me - either it should work always or never. Of course, I took special care about the arguments and the stack. And debugging with olly is quite boring and not that easy... I think I give up and I put up with the fact that I'm never gonna code a nice Api hook :-(

Moreover, studies suck also -> 'thank god it's friday' and I will relax the whole weekend!

Friday, October 05, 2007

Skyscraper Solver

So folks,
I removed the last bugs and cleaned up the code faster than I thought - so my Skyscraper solver waits to be downloaded from my site :-)
But unfortunately it is pretty timeconsuming to check if a solution is valid so it's quite slower than I thought! For example to go through all possibilities in a 6x6 quest with my backtracking algorithm can take several minutes in the worst case - even on my new laptop! That's bad - but I don't see many places for optimization which would really speed it up.
Of course this makes me thinking about another approach: it is possible and worth the time to solve it with Dancing Links like a Sudoku quest? Well, in fact I don't know and I didn't (and won't) try it. That's not an exercise which could be easily solved in a few hours in my opinion! But if anybody will do it and succeed, mail me please! I would be very interested in it.
So far so good. It's Friday afternoon, I have already done everything I had to do - it's time to relax and waiting for the weekend to begin :-)
Greetz, Sunshine

Monday, October 01, 2007

Again I'm coding...

Hey folks,
well at the moment I have some free time. No exams, the lectures are going to start not until middle of October and there are some problems with my study thesis. I cannot begin cause the HTX-Board (a special board to study the hypertransport bus) is not working properly, so this week seems to be idle too.
But not that bad. I came across a little game similar to sudoku and I decided to code a nice applet to play it. And of course even more: also a solver which gives all solutions to a quest (which is even finished and fully working) and a generator to create new games which has only one valid solution. This in fact is pretty more difficult to code - till now it takes in some cases nearly one minute to generate a quest which is sometimes not even solvable! Ok this tool I hacked in really short time without thinking about a clever algorithm so this is something I have to recode I think. The applet coding comes slowly to an end, here a screenshot from its current state:

As you see, I coded also some kind of lame visualization of the currently game. Well, that's not important for the game. It's more my first try of coding a simple wireframe 3D software rendering engine! Not that easy to code - you find only little information about camera and screen projection, but I succeeded :-) Let's see if I will also implement solid filled polygons...
So keep cool, I'm going to proceed with coding!