Friday, March 26, 2010

Cellphones Party

A cellphone is actually a computer with a microphone and an amplifier.
We used to think that its speakers are quite lousy, and rightfully so, because they've got no sound box which is a crucial part in creating a good natural sound. Nonetheless our judgment is based mostly on phone calls' quality which is pretty bad because of the GSM encoding the voice go through when going over the cellular network.
Current phone technology though, with smart phones such as the iPhone, the N95 and Android based phones got better sound quality than ever before. These phones became quite popular recently, striking me with the idea of putting a bunch of those phones together to play music. The quantity of phones might just prove enough to compensate for the quality.

My idea is to write an application for smart phones, to find all the phones running the application that are located in the same room (or preselected phones). The application will synchronize the phones by locating the distance and direction from each other, and then play some music as best as possible. Finding the direction and distance might be as easy as playing a short tone, and waiting for a reply from the other phones over Bluetooth or similar means. By measuring the reply time of about three or four phones, it's possible to calculate the direction and distance.

Although the phones won't produce the best music quality, it could be fun to play with. For instance:
1. Playing perfect surround sound, which means making sound as if it is coming from different parts of the room, even from places with no phones.
2. Creating Active Noise Control, or an interference sound wave. This can create better sound, cancel out noises or even create a sound that only a certain person or a group of people in the room could hear. As far as I understand, it is a bit out the plausible range of the speakers and the computational power of the CPU, but I would love to hear more of the subject from anyone whose got a better understanding.
3. Creating a sonar, to create a 3d map of the room and the objects it contains. Again, my lack of understanding forbids me from knowing the plausibility of the challenge.

On a different but related subject, I like the idea that everyone in a party would have the ability to vote for the next song on the play list. It is already common to find in restaurants songs menu which you can choose song from by sending SMS, but still putting it as an extra interaction of the parties with the DJ has some added value to the concept. Allowing people to watch the play list of the party, voting for songs, and sending insulting messages to all the people who vote for U2 songs is a must for every successful party.

P.S.
I forgot to thanks Werner for helping me on the last post. Big thanks goes to Omer for this one, check out his new awesome fun web-game @ http://www.knowthesong.com/app/

Thursday, March 18, 2010

Patch like there's no tommorow

On this post I would like to tell the story of three little binary patches I've done recently. I find patching to be the highest form of hacking, it requires decent reverse engineering skills combined with good OS understanding. Every Pirate must have its own eye patch.

1. Gmail Notifier:

Not long ago I bought a USB mail notifier, which is a small LED lamp in the shape of an envelope, that glitters every time I get a new email. About 8 USDs on DealExtreme (http://www.dealextreme.com/details.dx/sku.27062). I didn't quite like the software it came with, so I decided I would add the ability of turning the LED on n' off to some better mail notifier. I've spent some time figuring out how to control it using a C++ tool that I wrote, that did not work whatsoever. After some frustrating long hours of reading on the MSDN, I turned to reverse engineer the C# software that came with the device combing some USB port monitoring. After failing again to turn on this stupid LED, I called Python to the rescue. I found out that there is an HID USB module for Python that makes life so much easier. I must say that the Python module was so good at explaining everything, that after two minutes of playing with it, I instantly got the freaking device on, I understood what was wrong with my C++ code and I gained a better understanding of the entire HID mechanism. And my message for everyone who reads this post is, don't work hard, use Python. Anyhow, now I got a small script that sets the USB device to whatever color I choose. I installed the Gmail notifier that is written by Google, set it up, and almost instinctively loaded it to IDA. Strings like "%d unread mails" or "No new mails" were easy to find, so it became quite clear where the patch should go. Using Ollydbg, I wrote the patch down. Ollydbg has a good assembling option, where one can enter assembly code easily, check the encoding and later copy it into the original EXE file. Easy as one, two, three. If anyone has ideas on ways to improve this process, please do tell.

2. SWF32.dll. I've written before about my Flash games cheating experience. One of the problems I was telling you about was patching an Action Script byte code at real time, because after the Flash VM loads the code it changes it and optimizes it, and makes it hard for me to find the relevant code in the memory. So I wanted to add an option to patch an SWF file just after the browser is done loading it, but a second before it's loaded by the VM. The SWF file format supports ZLib compression, and most of the games out there take advantage of it. So I thought a good place to patch would be after the file is inflated. On this attempt I wanted to write down a patch that is a bit more complicated; a patch that would load a set of binary alterings for the SWF file from some text file, check that the original bytes match the target (To avoid oopsies) and apply. So for this patch I used the Microsoft Detours Library, published for free, examples included, on the MSDN. I found the detour library to be very intuitive and useful.

3. The Matrix. I found the bug on the Matrix that allows Neo to jump over buildings, I fixed it and banned the user... Ok, I had another real patch, but I think I'll save it for another time.