Dave Hylands' Mindstorms Patch

This is a patch for the Mindstorms RIS software that allows it to run on a Macintosh under Virtual PC. This is not an official patch from LEGO.

The patch was written by Dave Hylands. Please direct any questions about the patch to him.

Download the Patch

Here is Dave's description of the patch itself:


The files contained in the zip file are:

 2192  SPHack.cpp   - Source code for utility which modifies Spirit.ocx
 3396  SPHack.dsp   - Visual C++ 5.0 Project file
37376  SPHack.exe   - Executable for utility which modifies Spirit.ocx
 3989  SPHack.mak   - NMAKE makefile generated by VC++
 8148  SPKrnl32.cpp - Source code for DLL which spoofs the CTS line
33209  SPKrnl32.def - DEF file used to build SPKrnl32.dll
81920  SpKrnl32.dll - DLL to be placed in the same directory as Spirit.ocx
 3725  SpKrnl32.dsp - Visual C++ 5.0 Project file
  726  SpKrnl32.dsw - Visual C++ 5.0 Workspace which includes the above
 4754  SpKrnl32.mak - NMAKE makefile generated by VC++

To install:
- Make a backup of your Spirit.ocx file (typically found in c:\Program
- Copy SPKrnl32.dll and SPHack.exe into the same directory as Spirt.ocx
- From the command line, cd into the directory containing Spirit.ocx
- From the command line run 'SPHack Spirit.ocx'

How it works:
- Spirit.ocx uses the Comm functions located in Kernel32.dll to perform
serial communications
- SPHack modifies Spirit.ocx to look for SPKRNL32.dll rather than
- The def file for SPKrnl32.dll forwards most of the Kernel32 functions to
Kernel32 itself, and redirects CreateFileA, EscapeCommFunction,
GetCommModemStatus, and CloseHandle to routines in SPKrnl32.dll with the
same name but with an SP_ prefixed to the function name (that way
SP_CreateFileA can call CreateFileA without running into recursion
- SP_CreateFileA looks for attempts to open a COM port, and if the request
is successful, it remembers the file handle that was returned.
- SP_CloseHandle looks for close requests on the file handle that was used
for the serial port.
- SP_EscapeCommFunction looks for requests to Set/Clear the RTS and
remembers what the current state of RTS is.
- SP_GetCommModemStatus overwrites the result of CTS to match the last value
that RTS was set to (effectively emulating the CTS to RTS connection which
occurs inside the IR Tower).
- There are four functions which are redirected to SP_Dummy. These are
routines which are in the NT ServicePack3 version of Kernel32, but aren't
used by Spirit.ocx. If I remove them from the .def file I'm pretty sure that
I can remove SP_Dummy from SPKrnl32.cpp. I used 'dumpbin /exports
KERNEL32.DLL' to get a list of the entry points which are exported (I
actually compiled/tested this under NT 4 SP3, as well as testing under
Windows 95 running under Virtual PC on my Mac laptop).

Because I modified Spirit.ocx and not Kernel32.dll, this modification will
have no effect on any other applications (except those that use Spirit.ocx).
Because I'm modifying Spirit.ocx it should allow anybody else's program
which uses Spirit.ocx to work under Virtual PC (like RCX Control or rcxcc).

I added some hooks to allow information to be logged into a debug file, but
the way I've given the files to you it's conditionally compiled out. With a
few more mods, it would also be possible to intercept the serial stream
going to/from Spirit.ocx and the IR Tower.