mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-01 14:20:15 +00:00
ntdll: Move the call to MODULE_DllThreadAttach from the kernel32
thread creation function to the NTDLL one.
This commit is contained in:
parent
2d15c8fb75
commit
ea6f3a4cc0
4 changed files with 39 additions and 7 deletions
|
@ -54,7 +54,6 @@ struct new_thread_info
|
||||||
void *arg;
|
void *arg;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern NTSTATUS MODULE_DllThreadAttach( LPVOID lpReserved ); /* FIXME */
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* THREAD_Start
|
* THREAD_Start
|
||||||
|
@ -74,7 +73,6 @@ static void CALLBACK THREAD_Start( void *ptr )
|
||||||
|
|
||||||
__TRY
|
__TRY
|
||||||
{
|
{
|
||||||
MODULE_DllThreadAttach( NULL );
|
|
||||||
ExitThread( func( arg ) );
|
ExitThread( func( arg ) );
|
||||||
}
|
}
|
||||||
__EXCEPT(UnhandledExceptionFilter)
|
__EXCEPT(UnhandledExceptionFilter)
|
||||||
|
|
|
@ -1390,8 +1390,3 @@
|
||||||
@ cdecl wine_nt_to_unix_file_name(ptr ptr long long)
|
@ cdecl wine_nt_to_unix_file_name(ptr ptr long long)
|
||||||
@ cdecl wine_unix_to_nt_file_name(ptr ptr)
|
@ cdecl wine_unix_to_nt_file_name(ptr ptr)
|
||||||
@ cdecl __wine_init_windows_dir(wstr wstr)
|
@ 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 );
|
extern void DECLSPEC_NORETURN server_abort_thread( int status );
|
||||||
|
|
||||||
/* module handling */
|
/* module handling */
|
||||||
|
extern NTSTATUS MODULE_DllThreadAttach( LPVOID lpReserved );
|
||||||
extern FARPROC RELAY_GetProcAddress( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
|
extern FARPROC RELAY_GetProcAddress( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
|
||||||
DWORD exp_size, FARPROC proc, DWORD ordinal, const WCHAR *user );
|
DWORD exp_size, FARPROC proc, DWORD ordinal, const WCHAR *user );
|
||||||
extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, const IMAGE_EXPORT_DIRECTORY *exports, DWORD exp_size,
|
extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, const IMAGE_EXPORT_DIRECTORY *exports, DWORD exp_size,
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "wine/pthread.h"
|
#include "wine/pthread.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
#include "ntdll_misc.h"
|
#include "ntdll_misc.h"
|
||||||
|
#include "wine/exception.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(thread);
|
WINE_DEFAULT_DEBUG_CHANNEL(thread);
|
||||||
|
|
||||||
|
@ -273,6 +274,26 @@ HANDLE thread_init(void)
|
||||||
return exe_file;
|
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
|
* start_thread
|
||||||
|
@ -316,6 +337,23 @@ static void start_thread( struct wine_pthread_thread_info *info )
|
||||||
InsertHeadList( &tls_links, &teb->TlsLinks );
|
InsertHeadList( &tls_links, &teb->TlsLinks );
|
||||||
RtlReleasePebLock();
|
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 );
|
func( arg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue