https://bugs.winehq.org/show_bug.cgi?id=51378
Bug ID: 51378 Summary: Failures with `DetourCreateProcessWithDllEx` for Microsoft's Detours Library Product: Wine Version: 6.11 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: andrew.jones@vector.com Distribution: ---
Created attachment 70234 --> https://bugs.winehq.org/attachment.cgi?id=70234 stderr from WINEDEBUG
I am trying to work with a third-party tool that use Microsoft's Detours Library:
https://github.com/microsoft/Detours
but it seems that the API call `DetourCreateProcessWithDllEx` inside of Detours does not work correctly when run under Wine.
The implementation for `DetourCreateProcessWithDllEx{A/W}` can be found here:
https://github.com/microsoft/Detours/blob/bc7688373bbbb185277788c04f68ae67b0...
https://github.com/microsoft/Detours/blob/bc7688373bbbb185277788c04f68ae67b0...
Helpfully, Detours includes with a sample application `withdll.exe` that utilises the `DetourCreateProcessWithDllEx` API:
https://github.com/microsoft/Detours/blob/fe7216c037c898b1f65330eda85e6146b6...
I built Detours from git (fe7216c037c898b1f65330eda85e6146b6e3cb85) on Windows 10 (19042.1052) using MSVC 19.29.30038.1; this gave me the resulting binaries `withdll.exe` and `simple64.dll`. Running `withdll.exe` to inject `simple64.dll` on Windows 10 gives:
``` C:\Users\avj\Downloads\Detours-master\bin.X64>withdll.exe /d:simple64.dll withdll.exe withdll.exe: Starting: `withdll.exe' withdll.exe: with `C:\Users\avj\Downloads\Detours-master\bin.X64\simple64.dll' simple64.dll: Starting. simple64.dll: Detoured SleepEx(). Usage: withdll.exe [options] [command line] Options: /d:file.dll : Start the process with file.dll. /v : Verbose, display memory at start. /? : This help screen. simple64.dll: Removed SleepEx() (result=0), slept 0 ticks.
```
However, running this under a fresh Wine 6.11 built (64-bit only; WINEARCH=win64) on openSUSE (gcc 10.3.0) gives me this:
``` withdll.exe: Starting: `withdll.exe' withdll.exe: with `Z:\tmp\wine\simple64.dll' withdll.exe: DetourCreateProcessWithDllEx failed: 2
```
I have attached the stderr from running `WINEDEBUG=+timestamp,+process,+tid,+seh,+module wine64 withdll.exe /d:simple64.dll withdll.exe 2>log.txt` to this case.
I have also uploaded the two binary files (`withdll.exe` and `simple64.dll`) to Google Drive:
https://drive.google.com/file/d/1DmFHYcm4-quslIAsHV1fwbzi6-JxRZse/view?usp=s...
Note: the source code for these files are MIT licensed, so there should be no issues in me sharing my binary builds (i.e., I do not consider these files proprietary).
Is it obvious what's wrong here? Is this a Wine bug or some configuration issue that I can resolve?