Victory is mine

December 31st 2007 04:08 pm

So I bought the game Galactic Civilizations II a long time ago. I was able to play it on my wife’s laptop and I figured it had to be pretty easy to get at least the major parts of the game running in Wine since it doesn’t have the copy protection code which normally breaks games nowadays, and it didn’t look like it was using any fancy DirectX features.

Needless to say my first attempts to make it work in Wine didn’t go so well. I tried off and on over that month and eventually just gave up, playing it on the laptop when I had time. I basically never play it now, as moving over to the laptop is just too much of a hassle.

Last night I decided to try again. It took some 6 hours and probably the most debugging I’ve had to employ over this entire year on a problem, but Victory is Mine! :)

Link to screenshot of GalCiv2 running in Wine

The first problem I had is that after patching the game to the latest version, 1.4x, it required activation (what Stardock uses for copy protection instead of CD copying controls) in order to start. This is normally pretty easy, and you can activate by email even if necessary. But the process always crashed. I first tried copying over the authentication certificate from the laptop but it’s tied to the machine you’re on.

So I then tried bringing down the network interface, running the activation again and trying to get the activation request so I could email it to Stardock. That didn’t work either, as it crashed just before I got to that part.

Getting fed up I decided to use one of the Wine debugging megaweapons, relay tracing. This option causes Wine to mark the entry and exit from practically every single procedure call in Wine, including function name, module, and parameters and return codes. You can filter this all down to just the module you need but I didn’t know where the problem was. 70 megabytes of a relay log later, I had something which I could look at.

It took a bit of deductiveness (i.e. searching for the last place where the serial number is used, which is probably close to the crash location) but it turned out the error was in advapi32, in the cryptographic code. Looking at the Wine source code, it looked like the code was trying and failing to read a required Registry key. But how did Wine install itself without setting up required Registry contents?

I tried running wineprefixcreate (which among other things, sets up default Registry contents) but that didn’t help. Eventually a bit of Google searching for the registry key name (Cryptography\Defaults or something like that) resulted in a hit on the rsaenh.dll in the Wine source, in the DllRegisterServer() function. That looked like it created the required keys. Hmm.

From my past life developing Win32 applications I knew that OLE registration for a DLL was typically handled by running rundll32 and passing the DLL name and entry point (DllRegisterServer in this case). wine has that tool as well so I tried running it and… success at last!

Now GalCiv2 wouldn’t run because it said I didn’t have DirectX 9.0c. I tried following some instructions I found to install DirectX 9.0c DLLs into Wine. It turned out I had to use the rundll32 program again on the wintrust DLL to get the installer to do anything. It would still error out though.

At this time I figured there were probably many DLLs that needed to be registered. So I took the rash action of going to my /usr/lib32/wine directory and registering every single DLL in there.

GalCiv2 still didn’t start up, but that’s because I forgot to undo some of the steps I took in the previously mentioned DirectX 9.0c install guide (namely, using native instead of builtin versions of some DLLs). Once I undid that GalCiv2 started up just fine. I haven’t actually played it yet. It was so late by that point that I immediately went to bed. Now I need to see if the game can actually be played in Wine.

I also wonder what part of Wine is supposed to register DLLs (i.e. installer, on first run, or what?) and figure out why it never happened here.

Posted by mpyne under Computing Troubles & Personal & Screenshots |

7 Responses to “Victory is mine”

  1. Nicholas Schmidt Identicon Icon Nicholas Schmidt responded on 31 Dec 2007 at 18:23 #

    Not looking good my friend:

    http://appdb.winehq.org/objectManager.php?sClass=application&iId=3081

  2. Bligh Identicon Icon Bligh responded on 31 Dec 2007 at 22:52 #

    “since it doesn’t have the copy protection code” and “it required activation (what Stardock uses for copy protection instead of CD copying controls)” and “the authentication certificate …. it’s tied to the machine you’re on.”

    You said “bought … a long time ago”. Imagine that the company was out of business, you would be out of luck.

    It doesn’t matter if the “copy protection” is tied to the CD or not. Tying it to the machine is worse: changing hardware; machine died; or moving to another machine. It’s the same with Windows “copy protection”. Harms consumers and it should be illegal.

    It’s not Linux/Open Source/Free Software that makes it harder to use Linux based operating systems as a “Gaming Platform” but the idiotic narrow minded views of the game companies about “copy protection”.

  3. ethana2 Identicon Icon ethana2 responded on 01 Jan 2008 at 07:14 #

    I agree. Death to copy protection.
    …although it does provide a reason to switch to open source games, once they reach high enough quality.

    I look forward to apricot :)
    I’d like to run Halo in WINE, but with all you went through, I don’t know if I have the will to bother. It segfaults immediately upon starting up, though the installation was fine.

    Yarr, you’ve already given me enough info to proceed. Now I have to get Halo working. *shakes fist*

  4. Jure Repinc Identicon Icon Jure Repinc responded on 01 Jan 2008 at 09:04 #

    “I agree. Death to copy protection.
    …although it does provide a reason to switch to open source games, once they reach high enough quality.”

    Also don’t forget that you can always speed things up so that the FLOSS game reaches high enough quality quicker. Join the open source game project and help them with the game. And no you don’t need to be a programmer at all. You can help with the story, web page, graphics, sound, ideas …..

    For 4X games similar to GalCiv I know two open source projects who could sure use all the help:
    Thousand Parsec
    FreeOrion

    I already try to do my best to help with Thousand Parsec. One of the things I slowly do there is also to develop a client for KDE 4. I hope to get the first test version out shorty after KDE 4.0 release on 11th January.

  5. mpyne Identicon Icon mpyne responded on 01 Jan 2008 at 16:24 #

    Bligh: All of what you mention is true, which is why I dislike copy-protected games in general. The activation thing kind of caught me off guard; it was not required in the 1.0x version you buy off the shelf, instead the serial number was mentioned as being required to download patches and updates.

    Either way the point of the article was more on making Wine work, pity no one else seems to know about registering the Wine DLLs.

  6. mpyne Identicon Icon mpyne responded on 01 Jan 2008 at 16:42 #

    Jure: To be honest what I think we need is some kind of open-source Master of Orion workalike. :) If that’s where FreeOrion is headed then I’d be very happy.

    Thousand Parsec looks a little too general to be a fun game at this point (I’ve always been suspicious of game-building frameworks). FreeOrion was much further behind last time I had checked it out but it looks to be much improved now, so I’ll check it out again I guess.

    Of course the way to go to play Master of Orion is DOSBox which works just fine in fact but it would still be nice to have an open-source client.

  7. Mithro Identicon Icon Mithro responded on 19 Feb 2008 at 00:29 #

    I thought you would like to know that Thousand Parsec, after a year of development, released a new version of it’s Primary Client.

    If you are into old-style 4x games, I suggest you give it a go!

Trackback URI | Comments RSS

Leave a Reply


For spam filtering purposes, please copy the number 3744 to the field below This message appears because you have JavaScript disabled or your browser does not support CSS, a standard web feature.