Skip to content


An Evil Blog??

Dr EvilFor a long time now, I've wanted to do this; build up a fairly simple (yet powerful) Blog/Wiki/CVS/Bugs/Shopping-list/whatever manager. I was going to try to use Serendipity as the base for this system, but when I sat down to do so, I discovered that s9y has gotten a bit too large for my purposes.

So, here we have a totally new system, hand coded by yours-truly and running from an sqlite database. So far it's a Blog/Wiki, but support for other more useful tools will be forthcoming.

Err, but why is it an Evil Blog?

I was fishing around for a new domain name, in anticipation of a change in employment sometime this year, and I found this one and thought it sounded cool. So, in the spirit of thinking up a cool name and then trying to justify it, my gimmick is this:

I'm motivated by power, so I'm always seeking to make things better, more functional, or even just getting them so that they work. If I had as much uninterrupted time as I needed to finish everything, I could take over the 'Net/world.

Sadly, I don't have that time, so my attempts are on a par with a certain Dr. Evil--both in terms of execution and effect. Yes, it's a pretty lame link, but I like it.

New domain, new blog

I'm gradually moving things over to my new domain and new blog. This one will still hang around to keep links working; eventually I'll move the content over and set up redirects so that I don't need to keep two separate things up and running.

The new blog is something I put together myself without really reading any blogging specs, so it might have a few teething troubles, althought it's not doing anything too complex.

Linux on Windows

[Update: You can now find the source code for this on bitbucket]

Call me crazy, but I've wanted to run a linux binary natively under windows for a while now; kinda like wine, but in reverse.

Well, the other day I was browsing through the MSDN docs (as you do) and discovered that it is possible to install a "vectored" exception handler. A quick bit of test code later, and I discovered that I can trap "int 0x80" instructions using this technique--those are used by linux binaries to initiate syscalls.

A couple of days hacking later, and I have a very small linux kernel emulation environment; it's split into two parts--low.dll (the kernel code) and low.exe (the bootstrap). The usage is quite simple; from your command prompt, run the linux binary of choice by prefixing the command line with "low.exe":

low.exe linuxsmallapp one two three four

The code from the named linux binary is loaded (low.dll includes an ELF loader) and bootstraps the process by faking an execve() syscall. When the syscall returns, the code resumes execution inside the loaded module. The code is running natively on your processor; and syscalls happen in userspace (just like the binary) although they run under a separate stack inside the win32 exception handler code. So, this is almost like kernel space.

What I have now is good enough to run my simple hello world application. It doesn't yet handle dynamic elf executables--they need to be statically linked. Thanks to Tal Peer, I have a collection of statically compiled coreutils from gentoo; they start up fine, but die somewhere in the stdio part of libc. I'm trying to track down the problem.

If anyone has any insight into why this might be (maybe windows is doing stuff for software interrupt number 128? before it calls my exception handler?), I'd like to hear it :-)

[Update] If you're interested in playing with it, please don't expect to acheive much at this stage. You can download it here.

I'm Looking for employment

Yeah, yeah, isn't everyone?

I'm looking for a full-time position doing some kind of systems architecture/development (preferably not grunt work writing PHP scripts all day, thanks!).

I'm prepared to relocate from the UK: west coast USA is appealing as I have family there (I'm married to a US citizen, so getting a green-card isn't going to be a problem), but will certainly consider employment elsewhere.

I've been programming for years and have very broad experience (and depth of knowledge) of a wide range of areas of development: unix, win32, servers, GUI, C/C++, Delphi and so on. I'm extremely flexible and a very fast learner.

Why am I looking for a job when I have my own company? Two reasons: one is that we want to move closer to family in the USA, and that requires working for someone else there so we can establish our credit history, and the second is that I'm tired of trying to scrounge up projects, especially here in the UK. Give me the work, pay me, and I'll do it :-)

If you have a job that might be suitable, please contact me to obtain my resume. I'm also available for project work.

ffi is here

I found the time to fix up my ffi extension so that it largely usable; the main features that are missing are support for arrays and closures (aka callbacks), but it should otherwise be good enough for some hacking.

ffi is multiplatform, and should work on a wide variety of unices as well as the known-good platforms: Linux/x86, Win32 and OSX.

If you want to try it on win32, you can download the PECL binary for windows; this is updated each time the PHP 5 snapshot is rebuilt--every 3 hours or so.

If you want to try it on other platforms, use pear install ffi to install and build the code from source; you need to have previously installed PHP 5 to use ffi.

FFI package page README


Well, I'm finally back from my conference run. Despite some shortcomings with hotel 'net connections, nothing went badly.

One thing I'm particularly pleased with is that I got to write some code (feels like a long time since I had the luxury to write pleasure code). I'm about 50% of the way through a libffi extension for PHP 5 (the ffi page is out of date, but still relevant).

FFI is an acronym for Foreign Function Interface and it provides a portable way to make calls from PHP into C code (and vice versa) at run-time, without having to write glue specifically for the function being called at compile-time.

PHP already has a w32api interface (unmaintained and broken) that does the same thing but for windows; my ffi extension replaces it and will also work on other platforms (Linux, Darwin, SunOS, Irix, Alpha, m68k, PowerPC and Arm).

Not only can you map functions from shared libraries (and DLLs), but you can also define structured types and access them using a natural syntax (taking advantage of the new OO internals in ZE2).

Even better is that you will also be able to pass PHP functions directly to mapped C functions that take callbacks as parameters (like the C library function qsort).

This all sounds really cool, but there is a price - allowing a PHP script to do this stuff is extremely dangerous (hence the title of this entry), so you won't find it on shared hosters.

Starting to talk

The biggest drawback to going to conferences is that I'm missing my wonderful wife Juliette and our son Xander. Xander is 11 months old and has been chatting away saying na-na for a few months now.

Since I've been away on this trip, he's started to say da-da and today he said ma-ma. Thanks to the wonders of technology, Juliette was able to make a quick mpeg so that I don't feel that I'm totally missing out. This brings tears to my eyes because Xander isn't feeling very well right now (he's having trouble keeping his food down), so he doesn't look quite so bright as he does usually.


PHP{Con West

PHP{Con West went very well for me - I got to meet most of the other PHP guys that I haven't seen before, as well as some of the familiar faces from LinuxTag this year, and got to meet some Sams authors, and Shelly too (at last!), as well as a bunch of PHP users.

The Extending PHP tutorial seemed to go well - there were more people at the end than there were at the start, and people were asking the most relevant questions, so it seems that I didn't bore the socks off everyone.

I will be putting the slides from the session online in the next couple of days because I've only just gotten some sane connectivity, which leads me to the down side of the conference...

For a hotel based in Silicon Valley, you might expect the Biltmore to have good internet access... well, it did have WiFi and it did have an elaborate code system to ensure that you are paying for access. The problem was that they didn't have anywhere near enough bandwidth for a computer/networking based conference. The number of attendees completely overwhelmed their line.