2001-11-30 19:46:42 +01:00
|
|
|
/*
|
2004-09-08 03:25:05 +02:00
|
|
|
* Win32 console functions
|
2001-11-30 19:46:42 +01:00
|
|
|
*
|
|
|
|
* Copyright 1995 Martin von Loewis and Cameron Heide
|
|
|
|
* Copyright 1997 Karl Garrison
|
|
|
|
* Copyright 1998 John Richardson
|
|
|
|
* Copyright 1998 Marcus Meissner
|
2011-01-18 22:02:37 +01:00
|
|
|
* Copyright 2001,2002,2004,2005,2010 Eric Pouech
|
2001-11-30 19:46:42 +01:00
|
|
|
* Copyright 2001 Alexandre Julliard
|
2002-03-10 00:29:33 +01: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 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-11-30 19:46:42 +01:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2001-11-30 19:46:42 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2014-04-16 10:09:02 +02:00
|
|
|
#include <limits.h>
|
2001-11-30 19:46:42 +01:00
|
|
|
|
2011-08-03 18:07:09 +02:00
|
|
|
#define NONAMELESSUNION
|
2010-09-10 21:50:19 +02:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2001-11-30 19:46:42 +01:00
|
|
|
#include "winbase.h"
|
2021-02-16 11:43:40 +01:00
|
|
|
#include "winternl.h"
|
2001-11-30 19:46:42 +01:00
|
|
|
#include "winnls.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "wincon.h"
|
2020-07-06 19:28:57 +02:00
|
|
|
#include "wine/condrv.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2003-06-21 04:07:10 +02:00
|
|
|
#include "kernel_private.h"
|
2001-11-30 19:46:42 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(console);
|
2001-11-30 19:46:42 +01:00
|
|
|
|
2003-12-12 05:10:52 +01:00
|
|
|
/******************************************************************
|
|
|
|
* OpenConsoleW (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Undocumented
|
|
|
|
* Open a handle to the current process console.
|
|
|
|
* Returns INVALID_HANDLE_VALUE on failure.
|
|
|
|
*/
|
2004-03-11 23:46:27 +01:00
|
|
|
HANDLE WINAPI OpenConsoleW(LPCWSTR name, DWORD access, BOOL inherit, DWORD creation)
|
2003-12-12 05:10:52 +01:00
|
|
|
{
|
2020-06-25 22:27:51 +02:00
|
|
|
SECURITY_ATTRIBUTES sa;
|
2003-12-12 05:10:52 +01:00
|
|
|
|
2022-02-11 08:41:23 +01:00
|
|
|
TRACE("(%s, 0x%08lx, %d, %lu)\n", debugstr_w(name), access, inherit, creation);
|
2010-04-01 02:53:59 +02:00
|
|
|
|
2020-11-17 00:55:16 +01:00
|
|
|
if (!name || (wcsicmp( L"CONIN$", name ) && wcsicmp( L"CONOUT$", name )) || creation != OPEN_EXISTING)
|
2003-12-12 05:10:52 +01:00
|
|
|
{
|
2020-06-25 22:27:51 +02:00
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
2003-12-12 05:10:52 +01:00
|
|
|
return INVALID_HANDLE_VALUE;
|
2010-04-01 02:53:59 +02:00
|
|
|
}
|
2003-12-12 05:10:52 +01:00
|
|
|
|
2020-06-25 22:27:51 +02:00
|
|
|
sa.nLength = sizeof(sa);
|
|
|
|
sa.lpSecurityDescriptor = NULL;
|
|
|
|
sa.bInheritHandle = inherit;
|
2010-08-30 22:19:39 +02:00
|
|
|
|
2020-06-25 22:27:51 +02:00
|
|
|
return CreateFileW( name, access, FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, creation, 0, NULL );
|
2003-12-12 05:10:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* VerifyConsoleIoHandle (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Undocumented
|
|
|
|
*/
|
|
|
|
BOOL WINAPI VerifyConsoleIoHandle(HANDLE handle)
|
|
|
|
{
|
2020-07-13 13:26:53 +02: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 05:10:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* DuplicateConsoleHandle (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Undocumented
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI DuplicateConsoleHandle(HANDLE handle, DWORD access, BOOL inherit,
|
|
|
|
DWORD options)
|
|
|
|
{
|
2020-11-11 20:06:39 +01:00
|
|
|
HANDLE ret;
|
|
|
|
return DuplicateHandle(GetCurrentProcess(), handle, GetCurrentProcess(), &ret,
|
|
|
|
access, inherit, options) ? ret : INVALID_HANDLE_VALUE;
|
2003-12-12 05:10:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* CloseConsoleHandle (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Undocumented
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CloseConsoleHandle(HANDLE handle)
|
|
|
|
{
|
2020-11-11 20:06:48 +01:00
|
|
|
return CloseHandle(handle);
|
2003-12-12 05:10:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetConsoleInputWaitHandle (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Undocumented
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI GetConsoleInputWaitHandle(void)
|
|
|
|
{
|
2020-07-01 16:27:22 +02:00
|
|
|
return GetStdHandle( STD_INPUT_HANDLE );
|
2003-12-12 05:10:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-11 19:28:00 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* GetConsoleKeyboardLayoutNameA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetConsoleKeyboardLayoutNameA(LPSTR layoutName)
|
|
|
|
{
|
|
|
|
FIXME( "stub %p\n", layoutName);
|
2019-09-09 22:17:58 +02:00
|
|
|
return TRUE;
|
2001-11-30 19:46:42 +01:00
|
|
|
}
|
|
|
|
|
2019-09-09 22:17:58 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetConsoleKeyboardLayoutNameW (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetConsoleKeyboardLayoutNameW(LPWSTR layoutName)
|
2016-01-05 08:59:32 +01:00
|
|
|
{
|
2019-09-09 22:17:58 +02:00
|
|
|
static int once;
|
|
|
|
if (!once++)
|
|
|
|
FIXME( "stub %p\n", layoutName);
|
|
|
|
return TRUE;
|
2016-01-05 08:59:32 +01:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
|
2012-06-05 09:59:49 +02:00
|
|
|
BOOL WINAPI SetConsoleIcon(HICON icon)
|
|
|
|
{
|
|
|
|
FIXME(": (%p) stub!\n", icon);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-08-20 06:20:16 +02:00
|
|
|
|
2015-10-29 13:17:20 +01:00
|
|
|
DWORD WINAPI GetNumberOfConsoleFonts(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-01-05 08:59:33 +01:00
|
|
|
BOOL WINAPI SetConsoleFont(HANDLE hConsole, DWORD index)
|
|
|
|
{
|
2022-02-11 08:41:23 +01:00
|
|
|
FIXME("(%p, %lu): stub!\n", hConsole, index);
|
2019-11-14 00:29:58 +01:00
|
|
|
SetLastError(LOWORD(E_NOTIMPL) /* win10 1709+ */);
|
2016-01-05 08:59:33 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2015-11-02 18:29:47 +01:00
|
|
|
|
|
|
|
BOOL WINAPI SetConsoleKeyShortcuts(BOOL set, BYTE keys, VOID *a, DWORD b)
|
|
|
|
{
|
2022-02-11 08:41:23 +01:00
|
|
|
FIXME(": (%u %u %p %lu) stub!\n", set, keys, a, b);
|
2015-11-02 18:29:47 +01:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-19 03:20:50 +02:00
|
|
|
BOOL WINAPI GetConsoleFontInfo(HANDLE hConsole, BOOL maximize, DWORD numfonts, CONSOLE_FONT_INFO *info)
|
|
|
|
{
|
2022-02-11 08:41:23 +01:00
|
|
|
FIXME("(%p %d %lu %p): stub!\n", hConsole, maximize, numfonts, info);
|
2019-11-06 16:46:09 +01:00
|
|
|
SetLastError(LOWORD(E_NOTIMPL) /* win10 1709+ */);
|
2016-04-19 03:20:50 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|