Wez Furlong

Browse archives
Conference Presentations
Subscribe. (circulation 746)
Comments. (circulation 2)

Search powered by Google

I am Wez Furlong, Director of Engineering at Message Systems. My team is responsible for the fastest MTA on Earth.

I'm also a PHP Core developer and OpenSource contributor, residing in Maryland with Juliette, Xander and Lily. (read more)

19th January 2004 @ 07:44 EDT
updated 23rd July 2004 @ 17:42 EDT

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.

by Wez Furlong in .
Post a comment
20th January 2004 @ 07:24 EDT

Pretty cool thing! Really! Would like to test some stuff with that, if you got something to view!

Btw, the RSS feed of your blog seems broken. It contains broken archive links:

http://zlog.thebrainroom.netarchives/22_Linux_on_windows.html

That should be only a problem in S9Y configuration, IMHO. Check your Website-Variable!

Regards, Toby

by Toby in .
20th January 2004 @ 07:47 EDT

Yeah, it's kinda neat, although annoying that any real binary I try segfaults. When I get a bit of time over the next couple of days, I'll put up a little download of this for people to test.

RSS should be fixed now; thanks.

by Wez in .
21st January 2004 @ 09:25 EDT

Wez Furlong [1] started reading through some documents at MSDN and finally ended up with a small Linux kernel emulator for Windows. Amazing story ;-) [1] http://zlog.thebrainroom.net/archives/22_Linux_on_windows.html

by circle.ch weblog in .
23rd January 2004 @ 04:00 EDT

looks like an interesting project.. i'll take a look at it as as soon as there is time: linux on windows (via circle.ch)...

by numlock.ch :: a changelog by Daniel Mettler in .
26th January 2004 @ 04:45 EDT

Just came across http://www.colinux.org/.

by Sebastian Bergmann in .
26th January 2004 @ 07:21 EDT

looks like an interesting project.. i'll take a look at it as as soon as there is time: linux on windows (via circle.ch) [update 20030126: there seem to exist other, similar projects: colinux (german introduction by symlink), umlwin32 ]...

by numlock.ch :: a changelog by Daniel Mettler in .
23rd February 2004 @ 00:33 EDT

try checking out colinux http://www.colinux.org/

by Ryan in .
4th March 2004 @ 23:23 EDT

Try Bosch. Emulates a PC. Even boots! Ussually used to try another OS on top of an already running OS. E.g. You can install and run linux on on Bosch running in a Windows environment.

by John in .
7th March 2004 @ 19:07 EDT

ERRATA Should be bochs not bosch. Sorry. Aside from bochs and colinux ( above) there's, WinLinux, Cygwin( ? correct spelling?), Lnx4Win.

John

by John in .
14th March 2004 @ 00:17 EDT

I know this might be controversial to post here, but I run various Operating systems in Virtual PC 2004 - and I'm just so happy with it. I almost forget the host operating system is Windows ;)

by joseph in .
15th March 2004 @ 15:44 EDT

You might want to have a look at Line :

http://line.sourceforge.net/

LINE Is Not an Emulator

LINE executes unmodified Linux applications on Windows by intercepting Linux system calls. The Linux applications themselves are not emulated. They run directly on the CPU just like all other Windows applications.

by Ben in .
15th March 2004 @ 18:10 EDT

Yeah, I found line a couple of weeks ago; the architecture is similar, but has a critical flaw (IMO)-line runs on top of cygwin, which I find a little too slow, and was one of the reasons I started dabbling in this area.

by Wez in .
18th March 2004 @ 06:16 EDT

it must be hard to provide all the APIs that exist on Linux (for Windows). Won't this just turn into one of those giant projects that will get to 30%, but then be impossible to finish (in commercial quality)?

by simon in .
25th March 2004 @ 17:11 EDT

linux on windows .. this i gotta see. what will the think of next :)

by kaz in .
1st April 2004 @ 18:00 EDT

Leggo due post di Wez Furlong, stasera. Il primo, che racconta del progetto controcorrente di Wez "Linux on windows", è del 19 marzo. Il secondo, di 5 giorni prima, re

by PaoloSantori.it in .
11th April 2004 @ 02:10 EDT

I am just wondering, because, I thought this was how cygwin did its stuff...

by Differences from Cygwin and grabbing thost 0x80 inttrupts in .
23rd May 2004 @ 11:12 EDT

the problem is with the drivers. Cygwin only provides some library functions

by dathing in .
14th July 2004 @ 01:23 EDT

First off, really cool idea. Second, check out http://www.packetstormsecurity.org/groups/teso/reducebind.c which converts a dynamic binary to a static one.

by in .
Post a comment