`MulDiv` doesn't match the correct Windows behavior for the function, which actually differs in some edge cases for 32-bit and 64-bit.
Test case:
```c MulDiv(1, 0x80000000, 0x80000000);
// WINE - both 32-bit and 64-bit: 0 // Windows (32-bit/kernel32.dll): 2 // Windows (64-bit/kernelbase.dll): -1 ```
On Windows 32-bit, this would return 2. On 64-bit, it'd return -1. However, on WINE, this call would return 0 for both 32-bit and 64-bit. This discrepancy was previously abused by threat actors to detect if the application runs under WINE.
---
On Windows, `MulDiv` has a different implementation for 32-bit (from `kernel32.dll`) and 64-bit (leveraged to `kernelbase.dll` from `kernel32.dll`).
After adjusting the 64-bit code to be an exact replica of the original code from `kernelbase.dll`, it'd still return the incorrect value due to Microsoft's code having undefined behavior with negation. It could be avoided with `-O0` but I opted into rewriting it with the undefined behavior to be, well.. defined.
To clarify, the original code from Microsoft has a bug (logically, at least). But WINE is supposed to have matching behavior so we can run Windows programs as intended.
The 32-bit version of `MulDiv` in Windows has a more complicated bug; I've documented it in the code.
---
This is my first contribution to WINE - I cannot find any `CONTRIBUTING.md` or similar file with guidelines so I did my best to follow the convention of other merge requests.
I've added unit testing for `MulDiv` to ensure there won't be a regression in the future.