[Bug 46809] PS4 Remote Play 2.x (.NET 4.x app) crashes on startup, loader fails to resolve dll dependency from private path ( LoadLibraryEx LOAD_WITH_ALTERED_SEARCH_PATH is mutually exclusive to LOAD_LIBRARY_SEARCH* flags )

wine-bugs at winehq.org wine-bugs at winehq.org
Sun Mar 10 10:03:42 CDT 2019


https://bugs.winehq.org/show_bug.cgi?id=46809

Anastasius Focht <focht at gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|-unknown                    |ntdll
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                URL|https://remoteplay.dl.plays |https://web.archive.org/web
                   |tation.net/remoteplay/lang/ |/20190310123055/https://rem
                   |en/index.html               |oteplay.dl.playstation.net/
                   |                            |remoteplay/module/win/Remot
                   |                            |ePlayInstaller.exe
           Keywords|                            |dotnet, download
                 CC|                            |focht at gmx.net
            Summary|PS4 Remote Play doesn't     |PS4 Remote Play 2.x (.NET
                   |open                        |4.x app) crashes on
                   |                            |startup, loader fails to
                   |                            |resolve dll dependency from
                   |                            |private path (LoadLibraryEx
                   |                            |LOAD_WITH_ALTERED_SEARCH_PA
                   |                            |TH is mutually exclusive to
                   |                            |LOAD_LIBRARY_SEARCH* flags)

--- Comment #2 from Anastasius Focht <focht at gmx.net> ---
Hello folks,

please always state the installation environment/prerequisites as exact as
possible.

1) Wine-Staging 4.3 was used (app doesn't install with plain Wine 4.3 -> bug
46812) -> visible in logs but not mentioned!

2) The installer refuses to install with default Windows version setting
('Windows 7'), needs at least 'Windows 8.1' or higher -> not mentioned!

3) The app requires .NET Framework to work. You obviously installed some .NET
Framework 4.x in the prefix (output doesn't look like Wine-Mono) -> not
mentioned!

4) Always start the app from the installation directory (= becomes working
directory)! Many Windows applications rely on this (dll load/search paths).

The app suffers from multiple bugs.

First one:

--- snip ---
$ WINEDEBUG=+seh,+relay,+loaddll,+module wine ./RemotePlay.exe >>log2.txt 2>&1
...
003e:Call KERNEL32.SetDllDirectoryA(0033f378 "") ret=003f73a6
003e:Ret  KERNEL32.SetDllDirectoryA() retval=00000001 ret=003f73a6
...
003e:Call KERNEL32.SetDefaultDllDirectories(00000800) ret=003f74a9
003e:Ret  KERNEL32.SetDefaultDllDirectories() retval=00000001 ret=003f74a9
...
003e:Call KERNEL32.LoadLibraryExW(016f8f14 L"C:\\Program Files (x86)\\Sony\\PS4
Remote Play\\RpCtrlWrapper.dll",00000000,00000008) ret=003f76ea
003e:trace:module:load_dll looking for L"C:\\Program Files (x86)\\Sony\\PS4
Remote Play\\RpCtrlWrapper.dll" in L"C:\\windows\\system32"
003e:trace:module:map_image mapped PE file at 0x6020000-0x62ea000
003e:trace:module:map_image mapping section .text at 0x6021000 off 400 size
225400 virt 22524a flags 60000020
003e:trace:module:map_image clearing 0x6246400 - 0x6247000
003e:trace:module:map_image mapping section .rdata at 0x6247000 off 225800 size
64200 virt 64116 flags 40000040
003e:trace:module:map_image clearing 0x62ab200 - 0x62ac000
003e:trace:module:map_image mapping section .data at 0x62ac000 off 289a00 size
9000 virt 1d56c flags c0000040
003e:trace:module:map_image mapping section .tls at 0x62ca000 off 292a00 size
200 virt 9 flags c0000040
003e:trace:module:map_image clearing 0x62ca200 - 0x62cb000
003e:trace:module:map_image mapping section .rsrc at 0x62cb000 off 292c00 size
3800 virt 3778 flags 40000040
003e:trace:module:map_image clearing 0x62ce800 - 0x62cf000
003e:trace:module:map_image mapping section .reloc at 0x62cf000 off 296400 size
1ae00 virt 1ad6c flags 42000040
003e:trace:module:map_image clearing 0x62e9e00 - 0x62ea000
003e:trace:module:get_load_order looking for L"C:\\Program Files
(x86)\\Sony\\PS4 Remote Play\\RpCtrlWrapper.dll"
003e:trace:module:get_load_order got hardcoded default for L"C:\\Program Files
(x86)\\Sony\\PS4 Remote Play\\RpCtrlWrapper.dll"
003e:trace:module:load_builtin_dll Trying built-in L"RpCtrlWrapper.dll"
003e:warn:module:load_builtin_dll cannot open .so lib for builtin
L"RpCtrlWrapper.dll":
/home/focht/projects/wine/mainline-install-x86_64/bin/../lib/wine/rpctrlwrapper.dll.so:
cannot open shared object file: No such file or directory
003e:trace:module:load_native_dll Trying native dll L"\\??\\C:\\Program Files
(x86)\\Sony\\PS4 Remote Play\\RpCtrlWrapper.dll"
003e:trace:module:perform_relocations relocating from 0x10000000-0x102ca000 to
0x6020000-0x62ea000
003e:trace:module:set_security_cookie initializing security cookie 0x62ac478
003e:trace:module:alloc_tls_slot module 0x6020000 data 0x62ca000-0x62ca008
zerofill 0 index 0x62c952c callback 0x62478b8 flags 300000 -> slot 1
003e:trace:module:alloc_tls_slot thread 0040 slot 1: 8/0 bytes at 0x1c05d0
003e:trace:module:alloc_tls_slot thread 003f slot 1: 8/0 bytes at 0x1c05e8
003e:trace:module:alloc_tls_slot thread 003e slot 1: 8/0 bytes at 0x1c0818 
...
003e:trace:module:load_dll looking for L"scenp.dll" in L"C:\\windows\\system32"
003e:trace:module:get_load_order looking for
L"C:\\windows\\system32\\scenp.dll"
003e:trace:module:get_load_order got hardcoded default for L"scenp.dll"
003e:trace:module:load_builtin_dll Trying built-in L"scenp.dll"
003e:warn:module:load_builtin_dll cannot open .so lib for builtin L"scenp.dll":
/home/focht/projects/wine/mainline-install-x86_64/bin/../lib/wine/scenp.dll.so:
cannot open shared object file: No such file or directory
003e:warn:module:load_dll Failed to load module L"scenp.dll"; status=c0000135
003e:err:module:import_dll Library scenp.dll (which is needed by L"C:\\Program
Files (x86)\\Sony\\PS4 Remote Play\\RpCtrlWrapper.dll") not found 
...
003e:warn:module:load_dll Failed to load module L"C:\\Program Files
(x86)\\Sony\\PS4 Remote Play\\RpCtrlWrapper.dll"; status=c0000135
003e:Ret  KERNEL32.LoadLibraryExW() retval=00000000 ret=003f76ea
...
System.NullReferenceException: Object reference not set to an instance of an
object.
   at RemoteplayUI.CheckUpdate..ctor()
   at ?.Main()
...
003e:trace:seh:call_stack_handlers handler at 0xc9adc9 returned 1
003e:trace:seh:call_stack_handlers calling handler at 0x10057ee8 code=c0000005
flags=0
003e:Call KERNEL32.GetLastError() ret=100031d1
003e:Ret  KERNEL32.GetLastError() retval=00000000 ret=100031d1
003e:trace:seh:call_stack_handlers handler at 0x10057ee8 returned 1
003e:trace:seh:call_stack_handlers calling handler at 0x7b495dc6 code=c0000005
flags=0
wine: Unhandled page fault on read access to 0x0000000c at address 0x3f9a44
(thread 003e), starting debugger...
--- snip ---

'kernel32.LoadLibraryExA' with 'LOAD_WITH_ALTERED_SEARCH_PATH'

https://docs.microsoft.com/en-us/windows/desktop/api/libloaderapi/nf-libloaderapi-loadlibraryexa

Specifically this:

https://docs.microsoft.com/en-us/windows/desktop/Dlls/dynamic-link-library-search-order

--- quote ---
Alternate Search Order for Desktop Applications

The standard search order used by the system can be changed by calling the
LoadLibraryEx function with LOAD_WITH_ALTERED_SEARCH_PATH. The standard search
order can also be changed by calling the SetDllDirectory function.

Windows XP: Changing the standard search order by calling SetDllDirectory is
not supported until Windows XP with Service Pack 1 (SP1).

If you specify an alternate search strategy, its behavior continues until all
associated executable modules have been located. After the system starts
processing DLL initialization routines, the system reverts to the standard
search strategy.

The LoadLibraryEx function supports an alternate search order if the call
specifies LOAD_WITH_ALTERED_SEARCH_PATH and the lpFileName parameter specifies
an absolute path.

Note that the standard search strategy and the alternate search strategy
specified by LoadLibraryEx with LOAD_WITH_ALTERED_SEARCH_PATH differ in just
one way: The standard search begins in the calling application's directory, and
the alternate search begins in the directory of the executable module that
LoadLibraryEx is loading.
--- quote ---

Emphasis on the last paragraph. Wine should locate the dependent dll also from
the directory of the executable module that LoadLibraryEx is loading.

I've included some calls prior to LoadLibraryEx, made by the .NET CLR, that can
potentially influence dll search paths:

--- snip ---
003e:Call KERNEL32.SetDllDirectoryA(0033f378 "") ret=003f73a6
003e:Ret  KERNEL32.SetDllDirectoryA() retval=00000001 ret=003f73a6
--- snip ---

https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-setdlldirectorya

--- quote ---
If this parameter is an empty string (""), the call removes the current
directory from the default DLL search order. 
--- quote ---

This would have no effect on the final search semantics of
LOAD_WITH_ALTERED_SEARCH_PATH.

--- quote ---
003e:Call KERNEL32.SetDefaultDllDirectories(00000800) ret=003f74a9
003e:Ret  KERNEL32.SetDefaultDllDirectories() retval=00000001 ret=003f74a9
--- quote ---

https://docs.microsoft.com/en-us/windows/desktop/api/libloaderapi/nf-libloaderapi-setdefaultdlldirectories

--- quote ---
It is not possible to revert to the standard DLL search path or remove any
directory specified with SetDefaultDllDirectories from the search path.
However, the process DLL search path can be overridden by calling LoadLibraryEx
with one or more LOAD_LIBRARY_SEARCH flags, and directories added with
AddDllDirectory can be removed by calling RemoveDllDirectory.
--- quote ---

This doesn't exclude the directory of the executable module from loader search
path.

Wine source:

https://source.winehq.org/git/wine.git/blob/099303c4590d0f76274f9e9cdbc707fee6e3209b:/dlls/kernel32/module.c#l925

--- snip ---
 925 /******************************************************************
 926  *              load_library
 927  *
 928  * Helper for LoadLibraryExA/W.
 929  */
 930 static HMODULE load_library( const UNICODE_STRING *libname, DWORD flags )
 931 {
 932     NTSTATUS nts;
 933     HMODULE hModule;
 934     WCHAR *load_path;
 935     const DWORD load_library_search_flags =
(LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR |
 936                                             
LOAD_LIBRARY_SEARCH_APPLICATION_DIR |
 937                                              LOAD_LIBRARY_SEARCH_USER_DIRS
|
 938                                              LOAD_LIBRARY_SEARCH_SYSTEM32
|
 939                                             
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
 940     const DWORD unsupported_flags = (LOAD_IGNORE_CODE_AUTHZ_LEVEL |
 941                                      LOAD_LIBRARY_REQUIRE_SIGNED_TARGET);
 942 
 943     if (!(flags & load_library_search_flags)) flags |=
default_search_flags;
 944 
 945     if( flags & unsupported_flags)
 946         FIXME("unsupported flag(s) used (flags: 0x%08x)\n", flags);
 947 
 948     if (flags & load_library_search_flags)
 949         load_path = get_dll_load_path_search_flags( libname->Buffer, flags
);
 950     else
 951         load_path = MODULE_get_dll_load_path( flags &
LOAD_WITH_ALTERED_SEARCH_PATH ? libname->Buffer : NULL, -1 );
 952     if (!load_path) return 0;
...
--- snip ---

'LOAD_WITH_ALTERED_SEARCH_PATH' is mutually exclusive to any
'LOAD_LIBRARY_SEARCH*' flags but the first check doesn't respect this.

You can also work around without modifying Wine source by putting 'scenp.dll'
in syswow64 (32-bit for shared WoW64) directory. But that's just an ugly hack.

$ sha1sum RemotePlayInstaller.exe 
d7e56a826e82689383687dfc63fe2a035b987604  RemotePlayInstaller.exe

$ du -sh RemotePlayInstaller.exe 
19M    RemotePlayInstaller.exe

$ wine --version
wine-4.3-229-g6d82b2f1ad

Regards

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list