The Discordant Opposition Journal Issue 10 - File 16
How to Integrate X and Win32
foreword:
i'm sure most of you know that it's possible to run most Win32 applications on an x server using wine (http://www.winehq.com). if you don't, visit the website in the parentheses to the left.. but what if you want to do the opposite? say you want to run x windows applications on Win32?
well the tools that you need to do this are older than wine. yep. they been around forever. in fact, government institutions used a package called X Vision along with pc-tcp/ip on windows 3.1 back when i was just an ikkle kid helping my dad with his computer maintenance contract.
the packages that i am talking about are called Windows X Servers. they create an x graphics server on your windows machine, using standard windows api calls to create the windows. then you run a program on a unix machine, and it mysteriously appears on your windows desktop. how's this work? let's find out!
(please note this is my grossly under-educated understanding)
rough theory behind x servers:
you may or may not know what happens behind the scenes when you type startx and the mysterious yet strangely appealing xfree86 gui system pops up on your screen. well basically, (and the entire philosophy which makes the entire unix architecture stronger than windows) instead of having one large windows program and a bunch of libraries which plug into it to do various things - x windows uses many smaller programs, and they all talk to each other.
for example, when you type startx, you don't just start x windows. no, you start an x server (often XF86-SVGA or a similar x server, sometimes an accelerated one). this x server only knows:
- how to talk to an x windows client application
- everything it needs to know about making pictures on your graphics hardware
once the x server is started, x calls upon a "window manager". i'm sure you know what these are, but these things simply contact the x server, and tell it what pictures to make.
when you a program, such as X term. it contacts the x server.... and tells the x server how it wants to be drawn.
how do the x client applications contact the x server? why, through tcp/ip! there are several application-level protocols used for this, and i won't bother explaining it. but suffice to say it uses port 6000/tcp. for a normal local x windows session, it would connect using the ip 127.0.0.1 (localhost), but the x server binds to all devices/ip addresses, on port 6000.
for this reason, it's >crucial< that you firewall port 6000 if you're connecting a gui box to the internet. we wouldn't want other people connecting malicious applications (such as a nasty trojan horse which would trick you into entering your password, or i even theorize that a keylogger could be written in this fashion) now would we?
onto the windows x servers:
basically, a windows x server takes the place of XF86-SVGA or whichever other x server you were using, only it runs on your windows machine instead of on a unix machine.
the x server for windows i like to use is XWin32, it's available on tucows (look under windows95 software, under servers; x servers). you can get the crack from www.fwaggle.net/tno_xw50.exe (version 5.0). it has the neat ability to create multiple windows for each window which pops up, and these windows use explorer as their windows manager, so it looks as though the program is actually running on your windows box.
so install xwin32 (you can choose a different one, but xwin32 is nice and stable) and run it so that a little blue x is in your system tray.
you can use xwin32 to run programs remotely using rsh, rexec, and XDMCP. now, i don't really understand XDMCP, so i can't comment on it. but in my experience, setting up the trust required for rsh and rexec isn't a terribly good idea security wise. so, i simply don't bother setting up the point 'n' click sessions for xwin32, and click cancel at the wizard. it's terribly easy anyway.
running programs:
i'd recommend creating a completely new (non-authoritive) user to run the programs accross your lan. for example, the xwin32 server is running on my wife's windows box, so i use her username to run the programs. now, you can append the --display tag to all the programs you wish to run, OR there's an easier way. let's look at the first way first...
this varies from program to program, and some programs don't even support it. most notably, Eterm, does support it. so does netscape. simply put, you specify the display switch, and the ip address/x server of the windows box running xwin32. like so:
Eterm --display 192.168.1.2:0
Netscape -display 192.168.1.2:0
as you can see, it varies from program to program. some programs even need it like: --display=192.168.1.2:0. this is a bitch of a way to do it. as i said before, there's an easier way.
most (all as far as i know) x client applications check the environment for a variable called "DISPLAY", which contains the current x server that the shell knows about. if you run startx, this is set to the local x server. if you run Eterm, it's set to whatever display Eterm connected to (i guess other terminal emulators do this too).
if your username (such as Sabriena in my case) isn't going to log in locally and will only ever want to run x windows programs on xwin32, then just put something like this in your .bash_profile (assuming you're using bash for your shell):
DISPLAY=192.168.1.2:0.0
remember to change the ip address to whatever ip address your windows machine is. using the environment variable like this, you should be able to run any x windows app from telnet, simply by typing it's name.
the end:
well if everything worked right, you should be able to run x applications on your windows machine. i'm doing it right now as we speak, to write this text. why? because my monitor exploded so i have to put together the entire DoJ using the methods described in this text.
this could be useful if you're in my predicament, or if you like some programs on x but you're not quite willing to let go of your windows just yet. and in my opinion, it's far better than dual booting, because both operating systems are always available. and the monitor is usually the more expensive part of a box, so why not think about setting up an old little pentium?
anyway i hope you got something useful out of this and learnt something. have fun.
fwaggle
root@fwaggle.net