19 สิงหาคม
Building Rotor (SSCLI) on Windows Vista
I like to dig into the inner working of .NET and Microsoft have released a the complete source for a working CLI framework, its called Rotor or SSCLI (Shared Source Common Language Infrastructue).
Some recent discussions on the MSDN forums made me want to dig deeper into how a CLI implementation actually works and as I already knew about Rotor I though I get the sources and build it on my computer. The download page mentions it is only tested for Windows XP SP2. I thought I would try it anyway as I use Windows Vista.
I downloaded and installed ActiveState Perl, version 5.8.8 in my case, as it is required and then tried to build the SSCLI source as described in readfirst.html.
First problem I encountered was "Permissions denied" and I thought this would be because I tried to compile it as a limited user and opened a new command window as administrator.
This got me pass the permissions denied issue and the building proceded. During the build I ran into trouble, it failed at one step. While building sscli20\fx\src\sys\sources I got a fatal error: Internal buffer overflow.
I thought could not be the first with this I immediatly started to seaching the net for a solution. Disappointed I realized I was not able to find any help how to solve this, I was on my own.
I started to try to dig out a bit more details about this error in the log files. The first file I was lead to by the error message was sscli20\fx\src\buildc.log. The last line revealed that it was a Internal buffer overflow in a method called MakeMacroString.
I browsed to the root of where I extracted the SSCLI sources and searched for MakeMacroString. I got 4 files matching my search.
- sscli20\tools\build.h
- sscli20\tools\buildmak.c
- sscli20\tools\buildsrc.c
- sscli20\tools\buildutl.c
Not a very big list so I loaded up the files in a text editor and searched for any occurance of MakeMacroString in them. I found the implementation of it in the buildsrc.c file. I directly saw the expression that caused the error.
if (cb > sizeof(MMSBuffer) - 1) {
BuildError(
"(Fatal Error) Buffer overflow: MakeMacroString(%s)\n",
psrc);
exit(16);
}
This indicated that cb, that is the length of argument psrc, is greater than the size of the buffer MMSBuffer. If I would increase the size of the buffer I should be able to fix this problem and as MMSBuffer is declared just above the MakeMacroString() method in buildsrc.c (line 521) it was a simple modification.
I didn't know how much bigger buffer was needed so I quadrupled it to be
char MMSBuffer[256*1024];
compared to what it was before
char MMSBuffer[64*1024];
This change allowed me to build the SSCLI V2 source code on Windows Vista. I tried to build hello.cs and run it as described. It worked! Now you can have fun with SSCLI (Rotor) on Windows Vista.