Commit 649f70ab authored by Alexandre Julliard's avatar Alexandre Julliard

server: Don't generate dll load event for native binaries on Wow64.

parent 1ce08530
......@@ -38,6 +38,7 @@
static int myARGC;
static char** myARGV;
static BOOL is_wow64;
static BOOL (WINAPI *pCheckRemoteDebuggerPresent)(HANDLE,PBOOL);
......@@ -51,6 +52,7 @@ static NTSTATUS (WINAPI *pDbgUiConnectToDbg)(void);
static HANDLE (WINAPI *pDbgUiGetThreadDebugObject)(void);
static void (WINAPI *pDbgUiSetThreadDebugObject)(HANDLE);
static DWORD (WINAPI *pGetMappedFileNameW)(HANDLE,void*,WCHAR*,DWORD);
static BOOL (WINAPI *pIsWow64Process)(HANDLE,PBOOL);
static LONG child_failures;
......@@ -905,11 +907,33 @@ static void doChild(int argc, char **argv)
CloseHandle( map );
UnmapViewOfFile( mod );
if (sizeof(void *) > sizeof(int))
{
GetSystemWow64DirectoryW( path, MAX_PATH );
wcscat( path, L"\\oleacc.dll" );
}
else if (is_wow64)
{
wcscpy( path, L"c:\\windows\\sysnative\\oleacc.dll" );
}
else goto done;
file = CreateFileW( path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
child_ok( file != INVALID_HANDLE_VALUE, "failed to open %s: %u\n", debugstr_w(path), GetLastError());
map = CreateFileMappingW( file, NULL, SEC_IMAGE | PAGE_READONLY, 0, 0, NULL );
child_ok( map != NULL, "failed to create mapping %s: %u\n", debugstr_w(path), GetLastError() );
mod = MapViewOfFile( map, FILE_MAP_READ, 0, 0, 0 );
child_ok( mod != NULL, "failed to map %s: %u\n", debugstr_w(path), GetLastError() );
CloseHandle( file );
CloseHandle( map );
UnmapViewOfFile( mod );
done:
blackbox.failures = child_failures;
save_blackbox(blackbox_file, &blackbox, sizeof(blackbox), NULL);
}
static HMODULE ole32_mod, oleaut32_mod;
static HMODULE ole32_mod, oleaut32_mod, oleacc_mod;
static void check_dll_event( HANDLE process, DEBUG_EVENT *ev )
{
......@@ -925,10 +949,12 @@ static void check_dll_event( HANDLE process, DEBUG_EVENT *ev )
else p = module;
if (!wcsicmp( p, L"ole32.dll" )) ole32_mod = ev->u.LoadDll.lpBaseOfDll;
else if (!wcsicmp( p, L"oleaut32.dll" )) oleaut32_mod = ev->u.LoadDll.lpBaseOfDll;
else if (!wcsicmp( p, L"oleacc.dll" )) oleacc_mod = ev->u.LoadDll.lpBaseOfDll;
break;
case UNLOAD_DLL_DEBUG_EVENT:
if (ev->u.UnloadDll.lpBaseOfDll == ole32_mod) ole32_mod = (HMODULE)1;
if (ev->u.UnloadDll.lpBaseOfDll == oleaut32_mod) oleaut32_mod = (HMODULE)1;
if (ev->u.UnloadDll.lpBaseOfDll == oleacc_mod) oleacc_mod = (HMODULE)1;
break;
}
}
......@@ -996,6 +1022,11 @@ static void test_debug_loop(int argc, char **argv)
ok( ole32_mod == (HMODULE)1, "ole32.dll was not reported\n" );
ok( oleaut32_mod == (HMODULE)1, "oleaut32.dll was not reported\n" );
#ifdef _WIN64
ok( oleacc_mod == (HMODULE)1, "oleacc.dll was not reported\n" );
#else
ok( oleacc_mod == NULL, "oleacc.dll was reported\n" );
#endif
ret = CloseHandle(pi.hThread);
ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
......@@ -2120,6 +2151,7 @@ START_TEST(debugger)
hdll=GetModuleHandleA("kernel32.dll");
pCheckRemoteDebuggerPresent=(void*)GetProcAddress(hdll, "CheckRemoteDebuggerPresent");
pIsWow64Process=(void*)GetProcAddress(hdll, "IsWow64Process");
pGetMappedFileNameW = (void*)GetProcAddress(hdll, "GetMappedFileNameW");
if (!pGetMappedFileNameW) pGetMappedFileNameW = (void*)GetProcAddress(LoadLibraryA("psapi.dll"),
"GetMappedFileNameW");
......@@ -2133,6 +2165,8 @@ START_TEST(debugger)
pDbgUiGetThreadDebugObject = (void*)GetProcAddress(ntdll, "DbgUiGetThreadDebugObject");
pDbgUiSetThreadDebugObject = (void*)GetProcAddress(ntdll, "DbgUiSetThreadDebugObject");
if (pIsWow64Process) pIsWow64Process( GetCurrentProcess(), &is_wow64 );
myARGC=winetest_get_mainargs(&myARGV);
if (myARGC >= 3 && strcmp(myARGV[2], "crash") == 0)
{
......
......@@ -361,6 +361,16 @@ static void set_process_machine( struct process *process, struct memory_view *vi
process->machine = machine;
}
static int generate_dll_event( struct thread *thread, int code, struct memory_view *view )
{
unsigned short process_machine = thread->process->machine;
if (!(view->flags & SEC_IMAGE)) return 0;
if (process_machine != native_machine && process_machine != view->image.machine) return 0;
generate_debug_event( thread, code, view );
return 1;
}
/* add a view to the process list */
static void add_process_view( struct thread *thread, struct memory_view *view )
{
......@@ -370,7 +380,9 @@ static void add_process_view( struct thread *thread, struct memory_view *view )
if (view->flags & SEC_IMAGE)
{
if (is_process_init_done( process ))
generate_debug_event( thread, DbgLoadDllStateChange, view );
{
generate_dll_event( thread, DbgLoadDllStateChange, view );
}
else if (!(view->image.image_charact & IMAGE_FILE_DLL))
{
/* main exe */
......@@ -1016,9 +1028,7 @@ void generate_startup_debug_events( struct process *process )
while (ptr && (ptr = list_next( &process->views, ptr )))
{
view = LIST_ENTRY( ptr, struct memory_view, entry );
if (!(view->flags & SEC_IMAGE)) continue;
generate_debug_event( first_thread, DbgLoadDllStateChange, view );
break;
if (generate_dll_event( first_thread, DbgLoadDllStateChange, view )) break;
}
/* generate creation events */
......@@ -1032,8 +1042,7 @@ void generate_startup_debug_events( struct process *process )
while (ptr && (ptr = list_next( &process->views, ptr )))
{
view = LIST_ENTRY( ptr, struct memory_view, entry );
if (!(view->flags & SEC_IMAGE)) continue;
generate_debug_event( first_thread, DbgLoadDllStateChange, view );
generate_dll_event( first_thread, DbgLoadDllStateChange, view );
}
}
......@@ -1244,7 +1253,7 @@ DECL_HANDLER(unmap_view)
struct memory_view *view = find_mapped_view( current->process, req->base );
if (!view) return;
if (view->flags & SEC_IMAGE) generate_debug_event( current, DbgUnloadDllStateChange, view );
generate_dll_event( current, DbgUnloadDllStateChange, view );
free_memory_view( view );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment