Skip to content

Commit a0ab8fa

Browse files
committed
Patch wine to fix addDllDirectory
Fixes errors like this when trying to load DLLs into template haskell code with GHC 9.4 and above: ``` iserv-proxy-interpreter.exe: addLibrarySearchPath: \\?\Z:\nix\store\gjsf5jazfbfv21hvvgf1amd5rdx3ycf3-x86_64-w64-mingw32-ghc-9.4.3\lib\x86_64-windows-ghc-9.4.3\ghc-bignum-1.3 (Win32 error 87): Invalid parameter. ``` These errors arise with GHC 9.4 and above because it uses UNC paths to avoid limits on path length. The `RtlDetermineDosPathNameType_U` function classifies these as a `DEVICE_PATH` and `LdrAddDllDirectory` gives up at that point.
1 parent 60c297c commit a0ab8fa

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
2+
index 85eb2976807..36d92b32d1c 100644
3+
--- a/dlls/ntdll/loader.c
4+
+++ b/dlls/ntdll/loader.c
5+
@@ -4015,7 +4015,7 @@ NTSTATUS WINAPI LdrAddDllDirectory( const UNICODE_STRING *dir, void **cookie )
6+
struct dll_dir_entry *ptr;
7+
DOS_PATHNAME_TYPE type = RtlDetermineDosPathNameType_U( dir->Buffer );
8+
9+
- if (type != ABSOLUTE_PATH && type != ABSOLUTE_DRIVE_PATH)
10+
+ if (type != ABSOLUTE_PATH && type != ABSOLUTE_DRIVE_PATH && type != DEVICE_PATH )
11+
return STATUS_INVALID_PARAMETER;
12+
13+
status = RtlDosPathNameToNtPathName_U_WithStatus( dir->Buffer, &nt_name, NULL, NULL );

overlays/wine.nix

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,10 @@
22
# files from TH code) for GHC built with msvcrt (ghc<9.6).
33
# This will inevitably replace *any* wine version. Thus this might not really be what we ultimately want.
44
# Wine 5.4 does not build on macOS so that is not pinned and TH code will probably break.
5-
final: prev:
6-
prev.lib.optionalAttrs (!prev.stdenv.hostPlatform.isDarwin) {
7-
winePackages = prev.winePackages // {
8-
minimal = prev.winePackages.minimal.overrideAttrs (oldAttrs: {
9-
name = "wine-5.4";
10-
version = "5.4";
11-
src = prev.fetchurl {
12-
url = "https://dl.winehq.org/wine/source/5.x/wine-5.4.tar.xz";
13-
sha256 = "sha256-Sz4rD/pUFfGZVA5gUcKMOXb86R6lv7LPSgmcJXMXBSw=";
14-
};
15-
patches = [];
16-
# Turning off the tests as there is a problem with the `schedsvc` test.
17-
# With recent nixpkgs both the IDL files generate `_c.c` files with
18-
# `handle_t rpc_handle` and that results in a linker error (duplicate symbols).
19-
configureFlags = oldAttrs.configureFlags or [] ++ ["--disable-tests"];
20-
});
21-
};
5+
final: prev: {
6+
winePackages = prev.winePackages // {
7+
minimal = prev.winePackages.minimal.overrideAttrs (oldAttrs: {
8+
patches = oldAttrs.patches or [] ++ [ ./patches/wine-add-dll-directory.patch ];
9+
});
10+
};
2211
}

0 commit comments

Comments
 (0)