2001-11-30 18:46:42 +00:00
|
|
|
/*
|
2004-09-08 01:25:05 +00:00
|
|
|
* Win32 console functions
|
2001-11-30 18:46:42 +00:00
|
|
|
*
|
|
|
|
* Copyright 1995 Martin von Loewis and Cameron Heide
|
|
|
|
* Copyright 1997 Karl Garrison
|
|
|
|
* Copyright 1998 John Richardson
|
|
|
|
* Copyright 1998 Marcus Meissner
|
2011-01-18 21:02:37 +00:00
|
|
|
* Copyright 2001,2002,2004,2005,2010 Eric Pouech
|
2001-11-30 18:46:42 +00:00
|
|
|
* Copyright 2001 Alexandre Julliard
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-11-30 18:46:42 +00:00
|
|
|
*/
|
|
|
|
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
2001-11-30 18:46:42 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2014-04-16 08:09:02 +00:00
|
|
|
#include <limits.h>
|
2001-11-30 18:46:42 +00:00
|
|
|
|
2011-08-03 16:07:09 +00:00
|
|
|
#define NONAMELESSUNION
|
2010-09-10 19:50:19 +00:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "windef.h"
|
2001-11-30 18:46:42 +00:00
|
|
|
#include "winbase.h"
|
2021-02-16 10:43:40 +00:00
|
|
|
#include "winternl.h"
|
2001-11-30 18:46:42 +00:00
|
|
|
#include "winnls.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "wincon.h"
|
2020-07-06 17:28:57 +00:00
|
|
|
#include "wine/condrv.h"
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
2003-06-21 02:07:10 +00:00
|
|
|
#include "kernel_private.h"
|
2001-11-30 18:46:42 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(console);
|
2001-11-30 18:46:42 +00:00
|
|
|
|
2003-12-12 04:10:52 +00:00
|
|
|
/******************************************************************
|
|
|
|
* OpenConsoleW (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Undocumented
|
|
|
|
* Open a handle to the current process console.
|
|
|
|
* Returns INVALID_HANDLE_VALUE on failure.
|
|
|
|
*/
|
2004-03-11 22:46:27 +00:00
|
|
|
HANDLE WINAPI OpenConsoleW(LPCWSTR name, DWORD access, BOOL inherit, DWORD creation)
|
2003-12-12 04:10:52 +00:00
|
|
|
{
|
2020-06-25 20:27:51 +00:00
|
|
|
SECURITY_ATTRIBUTES sa;
|
2003-12-12 04:10:52 +00:00
|
|
|
|
2022-02-11 07:41:23 +00:00
|
|
|
TRACE("(%s, 0x%08lx, %d, %lu)\n", debugstr_w(name), access, inherit, creation);
|
2010-04-01 00:53:59 +00:00
|
|
|
|
2020-11-16 23:55:16 +00:00
|
|
|
if (!name || (wcsicmp( L"CONIN$", name ) && wcsicmp( L"CONOUT$", name )) || creation != OPEN_EXISTING)
|
2003-12-12 04:10:52 +00:00
|
|
|
{
|
2020-06-25 20:27:51 +00:00
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
2003-12-12 04:10:52 +00:00
|
|
|
return INVALID_HANDLE_VALUE;
|
2010-04-01 00:53:59 +00:00
|
|
|
}
|
2003-12-12 04:10:52 +00:00
|
|
|
|
2020-06-25 20:27:51 +00:00
|
|
|
sa.nLength = sizeof(sa);
|
|
|
|
sa.lpSecurityDescriptor = NULL;
|
|
|
|
sa.bInheritHandle = inherit;
|
2010-08-30 20:19:39 +00:00
|
|
|
|
2020-06-25 20:27:51 +00:00
|
|
|
return CreateFileW( name, access, FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, creation, 0, NULL );
|
2003-12-12 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* VerifyConsoleIoHandle (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Undocumented
|
|
|
|
*/
|
|
|
|
BOOL WINAPI VerifyConsoleIoHandle(HANDLE handle)
|
|
|
|
{
|
2020-07-13 11:26:53 +00:00
|
|
|
IO_STATUS_BLOCK io;
|
|
|
|
DWORD mode;
|
|
|
|
return !NtDeviceIoControlFile( handle, NULL, NULL, NULL, &io, IOCTL_CONDRV_GET_MODE,
|
|
|
|
NULL, 0, &mode, sizeof(mode) );
|
2003-12-12 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* DuplicateConsoleHandle (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Undocumented
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI DuplicateConsoleHandle(HANDLE handle, DWORD access, BOOL inherit,
|
|
|
|
DWORD options)
|
|
|
|
{
|
2020-11-11 19:06:39 +00:00
|
|
|
HANDLE ret;
|
|
|
|
return DuplicateHandle(GetCurrentProcess(), handle, GetCurrentProcess(), &ret,
|
|
|
|
access, inherit, options) ? ret : INVALID_HANDLE_VALUE;
|
2003-12-12 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* CloseConsoleHandle (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Undocumented
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CloseConsoleHandle(HANDLE handle)
|
|
|
|
{
|
2020-11-11 19:06:48 +00:00
|
|
|
return CloseHandle(handle);
|
2003-12-12 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetConsoleInputWaitHandle (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Undocumented
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI GetConsoleInputWaitHandle(void)
|
|
|
|
{
|
2020-07-01 14:27:22 +00:00
|
|
|
return GetStdHandle( STD_INPUT_HANDLE );
|
2003-12-12 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-11 18:28:00 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetConsoleKeyboardLayoutNameA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetConsoleKeyboardLayoutNameA(LPSTR layoutName)
|
|
|
|
{
|
|
|
|
FIXME( "stub %p\n", layoutName);
|
2019-09-09 20:17:58 +00:00
|
|
|
return TRUE;
|
2001-11-30 18:46:42 +00:00
|
|
|
}
|
|
|
|
|
2019-09-09 20:17:58 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* GetConsoleKeyboardLayoutNameW (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetConsoleKeyboardLayoutNameW(LPWSTR layoutName)
|
2016-01-05 07:59:32 +00:00
|
|
|
{
|
2019-09-09 20:17:58 +00:00
|
|
|
static int once;
|
|
|
|
if (!once++)
|
|
|
|
FIXME( "stub %p\n", layoutName);
|
|
|
|
return TRUE;
|
2016-01-05 07:59:32 +00:00
|
|
|
}
|
2001-11-30 18:46:42 +00:00
|
|
|
|
2012-06-05 07:59:49 +00:00
|
|
|
BOOL WINAPI SetConsoleIcon(HICON icon)
|
|
|
|
{
|
|
|
|
FIXME(": (%p) stub!\n", icon);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-08-20 04:20:16 +00:00
|
|
|
|
2015-10-29 12:17:20 +00:00
|
|
|
DWORD WINAPI GetNumberOfConsoleFonts(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-01-05 07:59:33 +00:00
|
|
|
BOOL WINAPI SetConsoleFont(HANDLE hConsole, DWORD index)
|
|
|
|
{
|
2022-02-11 07:41:23 +00:00
|
|
|
FIXME("(%p, %lu): stub!\n", hConsole, index);
|
2019-11-13 23:29:58 +00:00
|
|
|
SetLastError(LOWORD(E_NOTIMPL) /* win10 1709+ */);
|
2016-01-05 07:59:33 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2015-11-02 17:29:47 +00:00
|
|
|
|
|
|
|
BOOL WINAPI SetConsoleKeyShortcuts(BOOL set, BYTE keys, VOID *a, DWORD b)
|
|
|
|
{
|
2022-02-11 07:41:23 +00:00
|
|
|
FIXME(": (%u %u %p %lu) stub!\n", set, keys, a, b);
|
2015-11-02 17:29:47 +00:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-19 01:20:50 +00:00
|
|
|
BOOL WINAPI GetConsoleFontInfo(HANDLE hConsole, BOOL maximize, DWORD numfonts, CONSOLE_FONT_INFO *info)
|
|
|
|
{
|
2022-02-11 07:41:23 +00:00
|
|
|
FIXME("(%p %d %lu %p): stub!\n", hConsole, maximize, numfonts, info);
|
2019-11-06 15:46:09 +00:00
|
|
|
SetLastError(LOWORD(E_NOTIMPL) /* win10 1709+ */);
|
2016-04-19 01:20:50 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|