Commit ea6f3a4c authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

ntdll: Move the call to MODULE_DllThreadAttach from the kernel32

thread creation function to the NTDLL one.
parent 2d15c8fb
......@@ -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 *ptr )
__TRY
{
MODULE_DllThreadAttach( NULL );
ExitThread( func( arg ) );
}
__EXCEPT(UnhandledExceptionFilter)
......
......@@ -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)
......@@ -60,6 +60,7 @@ extern void DECLSPEC_NORETURN server_exit_thread( int status );
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,
......
......@@ -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_pthread_thread_info *info )
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 );
}
......
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