Skip to content

Instantly share code, notes, and snippets.

@rofl0r
Last active November 25, 2021 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rofl0r/a4a2f51f0650f8255fd2a078b9b3cfab to your computer and use it in GitHub Desktop.
Save rofl0r/a4a2f51f0650f8255fd2a078b9b3cfab to your computer and use it in GitHub Desktop.

How to install CodeGear RAD Studio 2009 on wine

As mentioned in Wine's application database, installing Codegear RAD Studio 2009 (Delphi + C++ Builder) fails with the dreaded "Cannot open AVI" error, followed by a bunch of Access Violations in the "InstallAware Wizard".

In order to get it installed anyway, the following needs to be done:

  • get freely available install iso from http://altd.embarcadero.com/download/Delphi_C++Builder2009/Delphi_C++Builder2009_ISO_June2009.iso

  • mount iso in linux to a directory that's accesible from wine. e.g.:

    mount Delphi_C++Builder2009_ISO_June2009.iso /tmp/iso

  • search the string '@Install@!UTF-8!' without single quotes in /tmp/iso/Install/Setup.exe with a hexeditor. It's not the first occurence, but the second. this is a magic marker so the exe detects the attached payload.

  • find the 7z header that starts a couple bytes further. hex: 377ABCAF in case of the Setup.exe of the above mentioned iso, the 7z header starts at offset 0x3B03D.

  • use dd utility to dump the data starting at that offset to a separate file:

    mkdir /tmp/setup
    dd if=/tmp/iso/Install/Setup.exe of=/tmp/setup/payload.7z bs=1 skip=$((0x3B03D))
  • cd to /tmp/setup/ and unpack payload.7z with 7z command line utility:
    7z x payload.7z

this extracts a couple files and directories, including yet another Setup.exe. the important bit is "Setup.res", which is just another 7zip archive in disguise. However, it's an uncompressed 7z archive, and it needs to stay that way because the installer we're gonna use later on can only deal with uncompressed 7z's.

  • extract contents of Setup.res to yet another directory:
    mkdir /tmp/setup/res_content
    cd /tmp/setup/res_content
    7z x ../Setup.res
  • the files extracted from Setup.res contain the damned "gray.avi" which is the reason for the installer crashing. or rather, the code trying to load it. i've tried to debug the code in Setup.exe that loads it to no avail, it's really tricky because the code gets called by a windowproc callback. what i ended up doing instead is fixing the place that tries to play the avi: progress.dfm and progressprereq.dfm. someone familiar with delphi might notice that these are compiled forms. both of these forms contain a TAnimate control which tries to play that avi. the only way i found to actually make it work was to completely remove the blocks for the TAnimate control. In case of progress.dfm this is simple as it's the very last block in the file, so we can simply truncate it.

  • progress.dfm: Navigate with the hexeditor to the end of progress.dfm. A couple bytes before the end you see 0854416E696D617465, i.e. hex 08 followed by "TAnimate". the 08 stands for the string length of "TAnimate". in my case this is at offset 0x6E64D. Overwrite the 08 and the next byte with 00 and truncate the file at this offset or simply overwrite all the following bytes with 00. alternatively you can use dd to dump the first 0x6E64D bytes to a different file.

  • progressprereq.dfm: Open progressprereq.dfm in hexeditor. Search for "TAnimate". You'll notice that it's not the last component in the file. in my case, It's at offset 0x6E1EA (we need the offset including the "08" byte, as it belongs to that block). The next component placed on the Delphi form is a "TStaticText". including it's size byte, it starts at offset 0x6E252. the task at hand now is to move the TStaticText block and everything that follows up to where the TAnimate is now, akin to a memmove() operation in C.

    what i did was dd'ing the first part of the file into one file, and the end block to a second file, and then catting the 2 together like this:

    dd if=progressprereq.dfm of=prog.head count=$((0x6E1EA)) bs=1
    dd if=progressprereq.dfm of=prog.snip skip=$((0x6E252)) bs=1
    cat prog.head prog.snip >progressprereq.dfm
  • now that we have patched the 2 forms, we need to inject them back into Setup.res
    7z u -m0=Copy ../Setup.res progress.dfm
    7z u -m0=Copy ../Setup.res progressprereq.dfm

the -m0=Copy is required so 7z doesn't compress the files, but only stores them in the archive.

  • time to start wine and the setup: start winecfg and in "drives" tab map the contents of the iso to a drive letter e.g. F: -> /tmp/iso
    cd /tmp/setup
    wine ./Setup.exe /m="F:\Install\Setup.exe" /k=""

done, the progress bar finally runs through without raising the AVI error.

but... what's that ? Now it fails because MDAC 2.8 SP1 isn't installed.

  • install MDAC 2.8 SP1

    thankfully, the iso provides the required dependency... no, i lied. it doesn't, and microshit removed the download from their webpage. fortunately, i've been able to find it after about an hour of websearches with the help of web archive. http://web.archive.org/web/20170503023439/https://download.microsoft.com/download/4/a/a/4aafff19-9d21-4d35-ae81-02c48dcbbbff/MDAC_TYP.EXE before install, you gotta change the windows type in winecfg to windows 2000. after that, the install finally runs through... nope, i lied again.

    we now need to install .net framework 2.0 and jsharp? or something like that. fortunately these 2 will be installed by clicking next. in my case, the first run failed, but it worked after starting setup again

  • voila, after entering your serial the install finally runs through! unfortunately, the IDE still doesn't work (at least not with Wine 6.22). in my case, i got what i wanted anyway, because the only thing i was after was a newer ilink32.exe/.dll, because the ones shipped with BCB6 crash with wine. the same happens with the ones of RAD studio 2009 too, unfortunately, so my whole hacking adventure was pointless.

    i should have been able to extract the linker directly from the install media, but since we're dealing with proprietary crapware, the install data is split among a few dozen password protected .7zip files.

    update: i got BCB6's linker fixed using these instructions. The same likely works for RAD Studio 2k9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment