A+
--
Eric Pouech
diff -u -N -r -x '*~' -x '.#*' -x CVS dlls/kernel37/console.c dlls/kernel/console.c --- dlls/kernel37/console.c 2003-11-09 19:31:14.000000000 +0100 +++ dlls/kernel/console.c 2003-12-07 11:45:15.000000000 +0100 @@ -180,6 +180,123 @@ } +/****************************************************************** + * OpenConsoleW (KERNEL32.@) + * + * Undocumented + * Open a handle to the current process console. + * Returns INVALID_HANDLE_VALUE on failure. + */ +HANDLE WINAPI OpenConsoleW(LPCWSTR name, DWORD access, LPSECURITY_ATTRIBUTES sa, + DWORD creation) +{ + static const WCHAR coninW[] = {'C','O','N','I','N','$',0}; + static const WCHAR conoutW[] = {'C','O','N','O','U','T','$',0}; + BOOL output; + HANDLE ret; + + if (strcmpW(coninW, name) == 0) + output = FALSE; + else if (strcmpW(conoutW, name) == 0) + output = TRUE; + else + { + SetLastError(ERROR_INVALID_NAME); + return INVALID_HANDLE_VALUE; + } + if (creation != OPEN_EXISTING) + { + SetLastError(ERROR_INVALID_PARAMETER); + return INVALID_HANDLE_VALUE; + } + + SERVER_START_REQ( open_console ) + { + req->from = output; + req->access = access; + req->share = FILE_SHARE_READ | FILE_SHARE_WRITE; + req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); + SetLastError(0); + wine_server_call_err( req ); + ret = reply->handle; + } + SERVER_END_REQ; + return ret ? console_handle_map(ret) : INVALID_HANDLE_VALUE; +} + +/****************************************************************** + * VerifyConsoleIoHandle (KERNEL32.@) + * + * Undocumented + */ +BOOL WINAPI VerifyConsoleIoHandle(HANDLE handle) +{ + BOOL ret; + + if (!is_console_handle(handle)) return FALSE; + SERVER_START_REQ(get_console_mode) + { + req->handle = console_handle_unmap(handle); + ret = !wine_server_call_err( req ); + } + SERVER_END_REQ; + return ret; +} + +/****************************************************************** + * DuplicateConsoleHandle (KERNEL32.@) + * + * Undocumented + */ +HANDLE WINAPI DuplicateConsoleHandle(HANDLE handle, DWORD access, BOOL inherit, + DWORD options) +{ + HANDLE ret; + + if (!is_console_handle(handle) || + !DuplicateHandle(GetCurrentProcess(), console_handle_unmap(handle), + GetCurrentProcess(), &ret, access, inherit, options)) + return INVALID_HANDLE_VALUE; + return console_handle_map(ret); +} + +/****************************************************************** + * CloseConsoleHandle (KERNEL32.@) + * + * Undocumented + */ +BOOL WINAPI CloseConsoleHandle(HANDLE handle) +{ + if (!is_console_handle(handle)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + return CloseHandle(console_handle_unmap(handle)); +} + +/****************************************************************** + * GetConsoleInputWaitHandle (KERNEL32.@) + * + * Undocumented + */ +HANDLE WINAPI GetConsoleInputWaitHandle(void) +{ + static HANDLE console_wait_event; + + /* FIXME: this is not thread safe */ + if (!console_wait_event) + { + SERVER_START_REQ(get_console_wait_event) + { + if (!wine_server_call_err( req )) console_wait_event = reply->handle; + } + SERVER_END_REQ; + } + return console_wait_event; +} + + /****************************************************************************** * WriteConsoleInputA [KERNEL32.@] */ diff -u -N -r -x '*~' -x '.#*' -x CVS files37/file.c files/file.c --- files37/file.c 2003-12-07 11:30:34.000000000 +0100 +++ files/file.c 2003-12-07 11:45:51.000000000 +0100 @@ -201,124 +201,6 @@ } -/****************************************************************** - * OpenConsoleW (KERNEL32.@) - * - * Undocumented - * Open a handle to the current process console. - * Returns INVALID_HANDLE_VALUE on failure. - */ -HANDLE WINAPI OpenConsoleW(LPCWSTR name, DWORD access, LPSECURITY_ATTRIBUTES sa, - DWORD creation) -{ - static const WCHAR coninW[] = {'C','O','N','I','N','$',0}; - static const WCHAR conoutW[] = {'C','O','N','O','U','T','$',0}; - BOOL output; - HANDLE ret; - - if (strcmpW(coninW, name) == 0) - output = FALSE; - else if (strcmpW(conoutW, name) == 0) - output = TRUE; - else - { - SetLastError(ERROR_INVALID_NAME); - return INVALID_HANDLE_VALUE; - } - if (creation != OPEN_EXISTING) - { - SetLastError(ERROR_INVALID_PARAMETER); - return INVALID_HANDLE_VALUE; - } - - SERVER_START_REQ( open_console ) - { - req->from = output; - req->access = access; - req->share = FILE_SHARE_READ | FILE_SHARE_WRITE; - req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); - SetLastError(0); - wine_server_call_err( req ); - ret = reply->handle; - } - SERVER_END_REQ; - return ret ? console_handle_map(ret) : INVALID_HANDLE_VALUE; -} - -/****************************************************************** - * VerifyConsoleIoHandle (KERNEL32.@) - * - * Undocumented - */ -BOOL WINAPI VerifyConsoleIoHandle(HANDLE handle) -{ - BOOL ret; - - if (!is_console_handle(handle)) return FALSE; - SERVER_START_REQ(get_console_mode) - { - req->handle = console_handle_unmap(handle); - ret = !wine_server_call_err( req ); - } - SERVER_END_REQ; - return ret; -} - -/****************************************************************** - * DuplicateConsoleHandle (KERNEL32.@) - * - * Undocumented - */ -HANDLE WINAPI DuplicateConsoleHandle(HANDLE handle, DWORD access, BOOL inherit, - DWORD options) -{ - HANDLE ret; - - if (!is_console_handle(handle) || - !DuplicateHandle(GetCurrentProcess(), console_handle_unmap(handle), - GetCurrentProcess(), &ret, access, inherit, options)) - return INVALID_HANDLE_VALUE; - return console_handle_map(ret); -} - -/****************************************************************** - * CloseConsoleHandle (KERNEL32.@) - * - * Undocumented - */ -BOOL WINAPI CloseConsoleHandle(HANDLE handle) -{ - if (!is_console_handle(handle)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - return CloseHandle(console_handle_unmap(handle)); -} - -/****************************************************************** - * GetConsoleInputWaitHandle (KERNEL32.@) - * - * Undocumented - */ -HANDLE WINAPI GetConsoleInputWaitHandle(void) -{ - static HANDLE console_wait_event; - - /* FIXME: this is not thread safe */ - if (!console_wait_event) - { - SERVER_START_REQ(get_console_wait_event) - { - if (!wine_server_call_err( req )) console_wait_event = reply->handle; - } - SERVER_END_REQ; - } - return console_wait_event; -} -/* end of FIXME */ - - /*********************************************************************** * FILE_CreateFile *