Nonchalant Guidance

About Me·RSS·My Projects·LinkedIn


Added on: Saturday, 21 May, 2022 | Updated on: Monday, 21 October, 2024

On Wine

Some interesting facts and tips for a better experience

Introduction

While I get by pretty well (if not better) without any Windows-specific software, sometimes I do need to run such software (eg. games).

Wine is an extremely useful piece of software on Linux. It attempts to black-box reverse -engineer all of the Windows system calls and re-implement them using Linux ones as best it can in order to run Windows software on Linux. This method helps it be efficient in doing so and there is very little performance penalty for most software.

Some background

What’s black box reverse-engineering? Well, “black box” in this context means to use ONLY public resources and information about Windows and it’s APIs, including how it handles edge cases and errors, to reproduce the same behaviour on Linux. The Wine project NEVER and I repeat NEVER uses any proprietary Microsoft-copyrighted code in it’s releases and has a strict process wherein contributors have to legally acknowledge that they have never seen any such proprietary Windows code at any point in their lives for any reason whatsoever.

Overwhelmed? Well, its really because reverse engineering has been a gray area for a while, but according to most popular wisdom, by not using anything but public resources, if something has been reverse engineered, it’s legally in the clear.

The whole “never contribute if you’ve seen Windows code” is because if there is even a hint of someone using their time at Microsoft or elsewhere (where it can be easily shown that they had seen Windows code), the project WILL get sued and it may well lose, ruining the painstaking work of nearly 30 years.

If that doesn’t apply to you (and it probably doesn’t), feel free to contribute! It’s certainly an amazing project, and it could do with more bug reports or confirmation reports on WineDB, or on ProtonDB if you’re using Proton on Steam.

The problem(s)

As amazing as Wine is, it’s not without it’s drawbacks. Each version may simultaneously be an improvement and regression in terms of compatibility.

Consider, for instance, a function that Wine has implemented to see if a number is even or not. This is (hypothetically) a function that is supposed to be the analogue to a Windows syscall.

int iseven(int n) {
    
    if (n % 2) {
        return 0;
    } else {
        return 1;
    }

}

This just returns 0 if a number is odd or 1 if a number is even.

Now, let’s say a Wine developer reads official Microsoft public documentation on this API and realizes that this isn’t completely perfect, and that Windows actually returns -1 if a number is negative. They end up modifying the code to be like the one below:

int iseven(int n) {

    if (n < 0) {
        return -1;
    }   

    if (n % 2) {
        return 0;
    } else {
        return 1;
    }

}

But, in reality, let’s say Windows does things a bit differently:

int iseven(int n) {

    int result;

    if (n < 0) {
        result = -1;
    }   

    if (n % 2) {
        result = 0;
    } else {
        result = 1;
    }

    return result;

}

This looks to be the same, but actually negative numbers modulo 2 will in fact trigger the second condition, setting result = 0 and therefore returning a different value than what is “the correct behaviour”.

Now, the official, public Windows docs will just say “-1 when it’s a negative number, 0 if odd, 1 if even”. However, in reality, there is a bug here, and Windows developers will know of this bug and take it into consideration. Why can’t Microsoft just fix the bug? Because Windows has a hard requirement to be backwards compatible (that’s why business software usually just runs on Windows; 20-30 year old APIs can still somehow run just fine on a modern, up-to-date Windows install from today), so they’ll trudge along as much as they can.

Now, this is a fairly simple example, but there are so many, complex APIs that all depend on each other one way or another and do so much more than this, that you can imagine why Wine has been around since the 90s and still can have problems running software.

Each release will tweak certain APIs a bit to make test cases run better, but there will likely always be some piece of software out there that will break.

It’s not all bad news though. Most of the older APIs are pretty much implemented perfectly, so sometimes Wine can run really old (think ~90s software) software better than even Windows’ own backward compatibility modes, making it a good candidate for retro Windows gaming or just getting a really old piece of software running for nostalgia’s sake.

The Tips

  1. ALWAYS use a new WINEPREFIX for new software! This helps keep stuff clean and organized, and if something doesn’t run, you don’t have to create a new WINEPREFIX anyway for debugging (this is actually the first thing the Wine devs ask you to do when submitting a bug report).

  2. Wine doesn’t ship with a lot of stuff that Windows does by default, sometimes because they can’t distribute proprietary Microsoft code, such as any C++ redistributables or .NET. These are required by certain pieces of software, though, so if something doesn’t work, check to see if the software depends on these pieces of code.

    If so, install them.

    For games, you can install DirectX from this link. If that doesn’t work, you can get the binary directly from the Internet Archive here

    Installation path is KEY here! For the Arkham games, it’s usually something like “Program Files (x86)\arkham-asylum”. This can vary by game, so make sure to do a little bit of investigation. I found this tip thanks to this YouTube video, which actually wasn’t even for Wine, so that’s kind of funny I guess! Thanks a lot, Sektor LK-9T9!

  3. If these don’t really work, check the Internet for specific advice on running that specific software on Wine. WineDB, as mentioned above, is a good starting point, but it may be outdated, so it’s better to just search the Internet.

Conclusion

I am pretty interested in reverse-engineering, and since Wine was a piece of software I use a lot, it was nice to learn more and share that info.

That’s all for today. Bye now!


This website was made using Markdown, Pandoc, and a custom program to automatically add headers and footers (including this one) to any document that’s published here.

Copyright © 2024 Saksham Mittal. All rights reserved. Unless otherwise stated, all content on this website is licensed under the CC BY-SA 4.0 International License