http://bugs.winehq.org/show_bug.cgi?id=18798
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |focht@gmx.net
--- Comment #1 from Anastasius Focht focht@gmx.net 2009-06-05 17:21:26 --- Hello,
looks like Xenocode is very picky about the way how native dlls are being loaded.
--- snip --- ... 0009:trace:module:get_load_order looking for L"C:\Program Files\Neuro-Programmer 2\VmX.dll" 0009:trace:module:get_load_order got hardcoded default for L"C:\Program Files\Neuro-Programmer 2\VmX.dll" ... 0009: create_mapping( access=000f000f, attributes=00000080, protect=00000043, size=00025000, file_handle=0000, objattr={rootdir=0014,sd={control=00000004,owner=<not present>,group=<not present>,sacl={},dacl={{AceType=ACCESS_ALLOWED_ACE_TYPE,Mask=10000000,AceFlags=0,Sid={S-1-1-0}}}},name=L"_xvm_mem_708E180A6A058DCDE2E1F8586DD2BA4A_0xE6BEAA6E"} ) 0009: create_mapping() = 0 { handle=0078 } 0009:trace:virtual:NtMapViewOfSection handle=0x78 process=0xffffffff addr=(nil) off=000000000 size=0 access=4 0009: get_mapping_info( handle=0078, access=00000002 ) 0009: get_mapping_info() = 0 { size=00025000, protect=67, header_size=0, base=00000000, mapping=007c, shared_file=0000 } 0009: get_handle_fd( handle=0078 ) 0009: *fd* 0078 -> 91 0009: get_handle_fd() = 0 { type=1, removable=0, access=000f000f, options=00000020 } 0009:trace:virtual:map_view got mem in reserved area 0xdd0000-0xdf5000 0009:trace:virtual:VIRTUAL_DumpView View: 0xdd0000 - 0xdf4fff (anonymous) 0009:trace:virtual:VIRTUAL_DumpView 0xdd0000 - 0xdf4fff c-rw- 0009:trace:virtual:create_view forcing exec permission on 0xdd0000-0xdf4fff 0009:trace:virtual:NtMapViewOfSection handle=0x78 size=25000 offset=000000000 0009:trace:virtual:NtMapViewOfSection handle=0x24 process=0xffffffff addr=(nil) off=000220000 size=1bf1b access=2 0009: get_mapping_info( handle=0024, access=00000004 ) 0009: get_mapping_info() = 0 { size=01915000, protect=65, header_size=0, base=00000000, mapping=0080, shared_file=0000 } 0009:trace:virtual:map_view got mem in reserved area 0xe00000-0xe1c000 0009:trace:virtual:VIRTUAL_DumpView View: 0xe00000 - 0xe1bfff (anonymous) 0009:trace:virtual:VIRTUAL_DumpView 0xe00000 - 0xe1bfff c-r-- 0009:trace:virtual:create_view forcing exec permission on 0xe00000-0xe1bfff 0009:trace:virtual:NtMapViewOfSection handle=0x24 size=1c000 offset=000220000 0009: close_handle( handle=0080 ) 0009: close_handle() = 0 0009:trace:virtual:NtFreeVirtualMemory 0xffffffff 0xffc10000 003e0000 4000 0009: release_mutex( handle=0028 ) 0009: release_mutex() = 0 { prev_count=00000001 } 0009:trace:module:load_builtin_dll Trying built-in L"C:\Program Files\Neuro-Programmer 2\VmX.dll" 0009:trace:module:load_builtin_dll Trying built-in L"VmX.dll" 0009:warn:module:load_builtin_dll cannot open .so lib for builtin L"VmX.dll": /opt/wine/wine-install/bin/../lib/wine/vmx.dll.so: cannot open shared object file: No such file or directory 0009:trace:module:load_native_dll Trying native dll L"C:\Program Files\Neuro-Programmer 2\VmX.dll" 0009:warn:module:load_dll Failed to load module L"C:\Program Files\Neuro-Programmer 2\VmX.dll"; status=c0000022 0009:trace:module:load_dll looking for L"user32.dll" in L"C:\Program Files\Neuro-Programmer 2;.;C:\windows\system32;C:\windows\system;C:\windows;C:\Program Files\Neuro-Programmer 2\;C:\windows\system32;C:\windows;" 0009:trace:module:load_dll Found L"C:\windows\system32\user32.dll" for L"user32.dll" at 0x60530000, count=9 ... --- snip ---
Several things happen when a native dll is loaded by OS loader. One of the actions is to create a section for the executable image file.
Corresponding code:
--- snip dlls/ntdll/loader.c --- static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file, DWORD flags, WINE_MODREF** pwm ) { ... TRACE("Trying native dll %s\n", debugstr_w(name));
attr.Length = sizeof(attr); attr.RootDirectory = 0; attr.ObjectName = NULL; attr.Attributes = 0; attr.SecurityDescriptor = NULL; attr.SecurityQualityOfService = NULL; size.QuadPart = 0;
status = NtCreateSection( &mapping, STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ, &attr, &size, PAGE_READONLY, SEC_IMAGE, file ); if (status != STATUS_SUCCESS) return status;
module = NULL; status = NtMapViewOfSection( mapping, NtCurrentProcess(), &module, 0, 0, &size, &len, ViewShare, 0, PAGE_READONLY ); ... --- snip dlls/ntdll/loader.c ---
Xenocode hooks NtCreateSection() to actually control/redirect the creation of the section for the executable image file (SEC_IMAGE flags set). Using this hook (and others) it basically injects a PE image from its own resources.
"status=c0000022" indicates the problem, Xenocode didn't like all parameters passed to NtCreateSection() call in this situation, hence it fails.
Xenocode checks certain API parameters in its virtualization layer code for example to convert between real OS and Xenocode virtual handles. It seems the OBJECT_ATTRIBUTES *attr param passed to NtCreateSection() must be NULL at this point for whatever reason. Maybe Xenocode expects exact Windows OS loader behaviour here (remember: they are former M$ engineers, now partnering with M$ and Novell so they might know internals or had access to source code).
Passing NULL attributes makes it happy. Though it might be difficult to prove this incompatibility in internal OS loader behaviour between Wine and Windows using a conformance test. Maybe using a native API hook (like detours) to dump the parameters for that native API between call and return of LoadLibrary() in Windows (or using an strace-NT like tool).
A quick test with NULL attr passed to NtCreateSection() in load_native_dll() shows it successfully proceeds and maps the dll. This is the only parameter required to change, all others seem fine.
--- snip --- ... 0009:trace:module:load_dll looking for L"C:\Program Files\Neuro-Programmer 2\VmX.dll" in L"C:\Program Files\Neuro-Programmer 2;.;C:\windows\system32;C:\windows\system;C:\windows;C:\Program Files\Neuro-Programmer 2\;C:\windows\system32;C:\windows;" ... 0009:trace:module:get_load_order looking for L"C:\Program Files\Neuro-Programmer 2\VmX.dll" 0009:trace:module:get_load_order got hardcoded default for L"C:\Program Files\Neuro-Programmer 2\VmX.dll" ... 0009: create_mapping( access=000f000f, attributes=00000080, protect=00000043, size=00025000, file_handle=0000, objattr={rootdir=0014,sd={control=00000004,owner=<not present>,group=<not present>,sacl={},dacl={{AceType=ACCESS_ALLOWED_ACE_TYPE,Mask=10000000,AceFlags=0,Sid={S-1-1-0}}}},name=L"_xvm_mem_708E180A6A058DCDE2E1F8586DD2BA4A_0xE6BEAA6E"} ) 0009: create_mapping() = 0 { handle=0078 } 0009:trace:virtual:NtMapViewOfSection handle=0x78 process=0xffffffff addr=(nil) off=000000000 size=0 access=4 0009: get_mapping_info( handle=0078, access=00000002 ) 0009: get_mapping_info() = 0 { size=00025000, protect=67, header_size=0, base=00000000, mapping=007c, shared_file=0000 } 0009: get_handle_fd( handle=0078 ) 0009: *fd* 0078 -> 91 0009: get_handle_fd() = 0 { type=1, removable=0, access=000f000f, options=00000020 } 0009:trace:virtual:map_view got mem in reserved area 0xdd0000-0xdf5000 0009:trace:virtual:VIRTUAL_DumpView View: 0xdd0000 - 0xdf4fff (anonymous) 0009:trace:virtual:VIRTUAL_DumpView 0xdd0000 - 0xdf4fff c-rw- 0009:trace:virtual:create_view forcing exec permission on 0xdd0000-0xdf4fff 0009:trace:virtual:NtMapViewOfSection handle=0x78 size=25000 offset=000000000 0009:trace:virtual:NtMapViewOfSection handle=0x24 process=0xffffffff addr=(nil) off=000220000 size=1bf1b access=2 0009: get_mapping_info( handle=0024, access=00000004 ) 0009: get_mapping_info() = 0 { size=01915000, protect=65, header_size=0, base=00000000, mapping=0080, shared_file=0000 } 0009:trace:virtual:map_view got mem in reserved area 0xe00000-0xe1c000 0009:trace:virtual:VIRTUAL_DumpView View: 0xe00000 - 0xe1bfff (anonymous) 0009:trace:virtual:VIRTUAL_DumpView 0xe00000 - 0xe1bfff c-r-- 0009:trace:virtual:create_view forcing exec permission on 0xe00000-0xe1bfff 0009:trace:virtual:NtMapViewOfSection handle=0x24 size=1c000 offset=000220000 0009: close_handle( handle=0080 ) 0009: close_handle() = 0 0009:trace:virtual:NtFreeVirtualMemory 0xffffffff 0xffc10000 003e0000 4000 0009: release_mutex( handle=0028 ) 0009: release_mutex() = 0 { prev_count=00000001 } 0009:trace:module:load_builtin_dll Trying built-in L"C:\Program Files\Neuro-Programmer 2\VmX.dll" 0009:trace:module:load_builtin_dll Trying built-in L"VmX.dll" 0009:warn:module:load_builtin_dll cannot open .so lib for builtin L"VmX.dll": /opt/wine/wine-install/bin/../lib/wine/vmx.dll.so: cannot open shared object file: No such file or directory 0009:trace:module:load_native_dll Trying native dll L"C:\Program Files\Neuro-Programmer 2\VmX.dll" 0009: create_mapping( access=000f0007, attributes=00000000, protect=00000043, size=00026000, file_handle=0000, objattr={rootdir=0000,sd={},name=L""} ) 0009: create_mapping() = 0 { handle=0080 } 0009:trace:virtual:NtMapViewOfSection handle=0x80 process=0xffffffff addr=0x10000000 off=000000000 size=0 access=4 0009: get_mapping_info( handle=0080, access=00000002 ) 0009: get_mapping_info() = 0 { size=00026000, protect=67, header_size=0, base=00000000, mapping=0084, shared_file=0000 } 0009: get_handle_fd( handle=0080 ) 0009: *fd* 0080 -> 92 0009: get_handle_fd() = 0 { type=1, removable=0, access=000f0007, options=00000020 } 0009:trace:virtual:VIRTUAL_DumpView View: 0x10000000 - 0x10025fff (anonymous) 0009:trace:virtual:VIRTUAL_DumpView 0x10000000 - 0x10025fff c-rw- 0009:trace:virtual:create_view forcing exec permission on 0x10000000-0x10025fff 0009:trace:virtual:NtMapViewOfSection handle=0x80 size=26000 offset=000000000 0009:warn:module:alloc_module disabling no-exec because of L"VmX.dll" ... --- snip ---
Regards