http://bugs.winehq.org/show_bug.cgi?id=18551
Summary: Xenocode: NtMapViewOfSection() callers must take non-negative NTSTATUS into account (STATUS_IMAGE_NOT_AT_BASE) Product: Wine Version: 1.1.21 Platform: Other URL: http://rvgsoftware.fileburst.com/holdemmanager.zip OS/Version: other Status: UNCONFIRMED Severity: normal Priority: P2 Component: ntdll AssignedTo: wine-bugs@winehq.org ReportedBy: focht@gmx.net
Hello,
this is an continuation with Xenocode Virtual Appliance "Hold'em Manager" from bug 18274
Although wrapped with Xenocode it seems not to bundle .NET 2.0 Framework (Xenocode can optionally do this). Required prerequisites:
1. clean WINEPREFIX 2. sh winetricks -q dotnet20
The next part is buried within managed app domain hence debug trace doesn't give much useful information (some relay thunks prevent proper execution due to nature of Xenocode).
--- snip --- ... fixme:ntdll:NtQueryObject Unsupported information class 1 ... fixme:module:LdrAddRefDll 0x79000000 flags 1 not implemented ... fixme:shell:URL_ParseUrl failed to parse L"System.Drawing" ... fixme:shell:URL_ParseUrl failed to parse L"DevComponents.DotNetBar2" ... fixme:shell:URL_ParseUrl failed to parse L"System.Windows.Forms" ... fixme:shell:URL_ParseUrl failed to parse L"System" ... fixme:shell:URL_ParseUrl failed to parse L"HMClass" fixme:ntdll:RtlNtStatusToDosErrorNoTeb no mapping for 40000003 ... --- snip ---
That "LdrAddRefDll" message is harmless, Xenocode directly calls loader API (LdrLoadDll, LdrAddRefDll, ..).
Assembly bind info from enabled fusion log:
--- snip --- MDA notification: Name:BindingFailure, Flags:0 Description: The assembly with display name 'HMClass' failed to load in the 'Load' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileLoadException: Could not load file or assembly 'HMClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Exception from HRESULT: 0x8007013D File name: 'HMClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' --- snip ---
This message is the culprit: "fixme:ntdll:RtlNtStatusToDosErrorNoTeb no mapping for 40000003" Winedbg reveals the following callstack at the problem:
--- snip --- 0 0x7bc3b436 RtlNtStatusToDosErrorNoTeb+0xa6(status=1073741827) [/opt/wine/wine-git/dlls/ntdll/error.c:73] in ntdll (0x00339ca4) 1 0x7bc3b571 RtlNtStatusToDosError+0x2d(status=1073741827) [/opt/wine/wine-git/dlls/ntdll/error.c:103] in ntdll (0x00339cb4) 2 0x7b8aa916 MapViewOfFileEx+0xbf(handle=0x9950d8, access=0, offset_high=0, offset_low=0, count=1941504, addr=0x46f0000) [/opt/wine/wine-git/dlls/kernel32/virtual.c:550] in kernel32 (0x00339d04) 3 0x79ea4f44 in mscorwks (+0x34f44) (0x00339d68) ... --- snip ---
The problematic source location:
--- snip dlls/kernel32/virtual.c --- LPVOID WINAPI MapViewOfFileEx( HANDLE handle, DWORD access, DWORD offset_high, DWORD offset_low, SIZE_T count, LPVOID addr ) { ... if ((status = NtMapViewOfSection( handle, GetCurrentProcess(), &addr, 0, 0, &offset, &count, ViewShare, 0, protect ))) { SetLastError( RtlNtStatusToDosError(status) ); addr = NULL; } return addr; } --- snip dlls/kernel32/virtual.c ---
Due to Xenocode native API hooks, NTSTATUS = 0x40000003 (STATUS_IMAGE_NOT_AT_BASE) gets returned which is sane in this situation.
Wine unfortunately validates "success" by either using "if (status)" or if (status != STATUS_SUCCESS)" in several locations.
MSDN: http://msdn.microsoft.com/en-us/library/cc704588(PROT.10).aspx
--- quote --- 0x40000003 STATUS_IMAGE_NOT_AT_BASE
{Image Relocated} An image file could not be mapped at the address that is specified in the image file. Local fixes must be performed on this image. --- quote ---
From my view this doesn't qualify as an error at all (positive value).
Wine should allow this to succeed.
I found at two occurrences of NtMapViewOfSection() which cause Xenocode to fail due to NTSTATUS "STATUS_IMAGE_NOT_AT_BASE":
dlls/kernel32/virtual.c:MapViewOfFileEx dlls/ntdll/loader.c:load_native_dll
Although there are more occurrences of this idiom in Wine source tree, only these two seem relevant to Xenocode (due to hooks).
Either honour STATUS_IMAGE_NOT_AT_BASE when NtMapViewOfSection() is called in these two locations or make a generic check >= 0 because non-negative numbers usually indicate success from my understanding of NTSTATUS.
Regards