Robert Shearman : ntdll:
Move the call to MODULE_DllThreadAttach from the kernel32
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Mar 14 12:04:30 CST 2006
Module: wine
Branch: refs/heads/master
Commit: ea6f3a4cc0ba4a8e0a30df259052c8bb3e25ba5b
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=ea6f3a4cc0ba4a8e0a30df259052c8bb3e25ba5b
Author: Robert Shearman <rob at codeweavers.com>
Date: Tue Mar 14 14:35:21 2006 +0000
ntdll: Move the call to MODULE_DllThreadAttach from the kernel32
thread creation function to the NTDLL one.
---
dlls/kernel/thread.c | 2 --
dlls/ntdll/ntdll.spec | 5 -----
dlls/ntdll/ntdll_misc.h | 1 +
dlls/ntdll/thread.c | 38 ++++++++++++++++++++++++++++++++++++++
4 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/dlls/kernel/thread.c b/dlls/kernel/thread.c
index 41a8ccf..2d83707 100644
--- a/dlls/kernel/thread.c
+++ b/dlls/kernel/thread.c
@@ -54,7 +54,6 @@ struct new_thread_info
void *arg;
};
-extern NTSTATUS MODULE_DllThreadAttach( LPVOID lpReserved ); /* FIXME */
/***********************************************************************
* THREAD_Start
@@ -74,7 +73,6 @@ static void CALLBACK THREAD_Start( void
__TRY
{
- MODULE_DllThreadAttach( NULL );
ExitThread( func( arg ) );
}
__EXCEPT(UnhandledExceptionFilter)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 7ccbbfd..b2001ae 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -1390,8 +1390,3 @@
@ cdecl wine_nt_to_unix_file_name(ptr ptr long long)
@ cdecl wine_unix_to_nt_file_name(ptr ptr)
@ cdecl __wine_init_windows_dir(wstr wstr)
-
-################################################################
-# Wine dll separation hacks, these will go away, don't use them
-#
-@ cdecl MODULE_DllThreadAttach(ptr)
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index c32a246..35cbd5b 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -60,6 +60,7 @@ extern void DECLSPEC_NORETURN server_exi
extern void DECLSPEC_NORETURN server_abort_thread( int status );
/* module handling */
+extern NTSTATUS MODULE_DllThreadAttach( LPVOID lpReserved );
extern FARPROC RELAY_GetProcAddress( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
DWORD exp_size, FARPROC proc, DWORD ordinal, const WCHAR *user );
extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, const IMAGE_EXPORT_DIRECTORY *exports, DWORD exp_size,
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 5bfdcee..6e3d019 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -39,6 +39,7 @@
#include "wine/pthread.h"
#include "wine/debug.h"
#include "ntdll_misc.h"
+#include "wine/exception.h"
WINE_DEFAULT_DEBUG_CHANNEL(thread);
@@ -273,6 +274,26 @@ HANDLE thread_init(void)
return exe_file;
}
+typedef ULONG (WINAPI *PUNHANDLED_EXCEPTION_FILTER)(PEXCEPTION_POINTERS);
+static PUNHANDLED_EXCEPTION_FILTER get_unhandled_exception_filter(void)
+{
+ static PUNHANDLED_EXCEPTION_FILTER unhandled_exception_filter;
+ static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2','.','d','l','l',0};
+ UNICODE_STRING module_name;
+ ANSI_STRING func_name;
+ HMODULE kernel32_handle;
+
+ if (unhandled_exception_filter) return unhandled_exception_filter;
+
+ RtlInitUnicodeString(&module_name, kernel32W);
+ RtlInitAnsiString( &func_name, "UnhandledExceptionFilter" );
+
+ if (LdrGetDllHandle( 0, 0, &module_name, &kernel32_handle ) == STATUS_SUCCESS)
+ LdrGetProcedureAddress( kernel32_handle, &func_name, 0,
+ (void **)&unhandled_exception_filter );
+
+ return unhandled_exception_filter;
+}
/***********************************************************************
* start_thread
@@ -316,6 +337,23 @@ static void start_thread( struct wine_pt
InsertHeadList( &tls_links, &teb->TlsLinks );
RtlReleasePebLock();
+ /* NOTE: Windows does not have an exception handler around the call to
+ * the thread attach. We do for ease of debugging */
+ if (get_unhandled_exception_filter())
+ {
+ __TRY
+ {
+ MODULE_DllThreadAttach( NULL );
+ }
+ __EXCEPT(get_unhandled_exception_filter())
+ {
+ NtTerminateThread( GetCurrentThread(), GetExceptionCode() );
+ }
+ __ENDTRY
+ }
+ else
+ MODULE_DllThreadAttach( NULL );
+
func( arg );
}
More information about the wine-cvs
mailing list