kernelbase: Move CONTROL_C_EXIT handler to kernelbase.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0451e44d95
commit
43ce429234
|
@ -648,37 +648,6 @@ BOOL WINAPI GetNumberOfConsoleMouseButtons(LPDWORD nrofbuttons)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* CONSOLE_HandleCtrlC
|
||||
*
|
||||
* Check whether the shall manipulate CtrlC events
|
||||
*/
|
||||
LONG CALLBACK CONSOLE_HandleCtrlC( EXCEPTION_POINTERS *eptr )
|
||||
{
|
||||
extern DWORD WINAPI CtrlRoutine( void *arg );
|
||||
HANDLE thread;
|
||||
|
||||
if (eptr->ExceptionRecord->ExceptionCode != CONTROL_C_EXIT) return EXCEPTION_CONTINUE_SEARCH;
|
||||
if (!RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle) return EXCEPTION_CONTINUE_SEARCH;
|
||||
|
||||
/* check if we have to ignore ctrl-C events */
|
||||
if (!(NtCurrentTeb()->Peb->ProcessParameters->ConsoleFlags & 1))
|
||||
{
|
||||
/* Create a separate thread to signal all the events.
|
||||
* This is needed because:
|
||||
* - this function can be called in an Unix signal handler (hence on an
|
||||
* different stack than the thread that's running). This breaks the
|
||||
* Win32 exception mechanisms (where the thread's stack is checked).
|
||||
* - since the current thread, while processing the signal, can hold the
|
||||
* console critical section, we need another execution environment where
|
||||
* we can wait on this critical section
|
||||
*/
|
||||
thread = CreateThread(NULL, 0, CtrlRoutine, (void*)CTRL_C_EVENT, 0, NULL);
|
||||
if (thread) CloseHandle(thread);
|
||||
}
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* CONSOLE_WriteChars
|
||||
*
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#define __WINE_CONSOLE_PRIVATE_H
|
||||
|
||||
/* console.c */
|
||||
extern LONG CALLBACK CONSOLE_HandleCtrlC( EXCEPTION_POINTERS *eptr ) DECLSPEC_HIDDEN;
|
||||
extern int CONSOLE_GetHistory(int idx, WCHAR* buf, int buf_len) DECLSPEC_HIDDEN;
|
||||
extern BOOL CONSOLE_AppendHistory(const WCHAR *p) DECLSPEC_HIDDEN;
|
||||
extern unsigned CONSOLE_GetNumHistoryEntries(void) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -147,9 +147,6 @@ static BOOL process_attach( HMODULE module )
|
|||
LoadLibraryA( "krnl386.exe16" );
|
||||
}
|
||||
|
||||
/* finish the process initialisation for console bits, if needed */
|
||||
RtlAddVectoredExceptionHandler( FALSE, CONSOLE_HandleCtrlC );
|
||||
|
||||
if (params->ConsoleHandle == KERNEL32_CONSOLE_ALLOC)
|
||||
{
|
||||
HMODULE mod = GetModuleHandleA(0);
|
||||
|
|
|
@ -421,6 +421,20 @@ DWORD WINAPI CtrlRoutine( void *arg )
|
|||
}
|
||||
|
||||
|
||||
static LONG WINAPI handle_ctrl_c( EXCEPTION_POINTERS *eptr )
|
||||
{
|
||||
if (eptr->ExceptionRecord->ExceptionCode != CONTROL_C_EXIT) return EXCEPTION_CONTINUE_SEARCH;
|
||||
if (!RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle) return EXCEPTION_CONTINUE_SEARCH;
|
||||
|
||||
if (!(NtCurrentTeb()->Peb->ProcessParameters->ConsoleFlags & 1))
|
||||
{
|
||||
HANDLE thread = CreateThread( NULL, 0, CtrlRoutine, (void*)CTRL_C_EVENT, 0, NULL );
|
||||
if (thread) CloseHandle( thread );
|
||||
}
|
||||
return EXCEPTION_CONTINUE_EXECUTION;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* FillConsoleOutputAttribute (kernelbase.@)
|
||||
*/
|
||||
|
@ -1626,3 +1640,8 @@ HRESULT WINAPI ResizePseudoConsole( HPCON handle, COORD size )
|
|||
FIXME( "%p (%u,%u)\n", handle, size.X, size.Y );
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
void init_console( void )
|
||||
{
|
||||
RtlAddVectoredExceptionHandler( FALSE, handle_ctrl_c );
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ extern WCHAR *file_name_AtoW( LPCSTR name, BOOL alloc ) DECLSPEC_HIDDEN;
|
|||
extern DWORD file_name_WtoA( LPCWSTR src, INT srclen, LPSTR dest, INT destlen ) DECLSPEC_HIDDEN;
|
||||
extern void init_startup_info( RTL_USER_PROCESS_PARAMETERS *params ) DECLSPEC_HIDDEN;
|
||||
extern void init_locale(void) DECLSPEC_HIDDEN;
|
||||
extern void init_console(void) DECLSPEC_HIDDEN;
|
||||
extern HANDLE get_console_wait_handle( HANDLE handle ) DECLSPEC_HIDDEN;
|
||||
|
||||
extern const WCHAR windows_dir[] DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -47,6 +47,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
|
|||
IsWow64Process( GetCurrentProcess(), &is_wow64 );
|
||||
init_locale();
|
||||
init_startup_info( NtCurrentTeb()->Peb->ProcessParameters );
|
||||
init_console();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue