mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[KERNEL32]
Fix support for CONIN$ and CONOUT$, and add support for CON special file (now, writing to C:\CON or C:\somepath\CONIN$ or C:\anotherpath\CONOUT$ works). svn path=/branches/ros-csrss/; revision=58182
This commit is contained in:
parent
91e34202c7
commit
573e7edb6f
4 changed files with 79 additions and 23 deletions
|
@ -24,6 +24,11 @@ extern BOOL WINAPI IsDebuggerPresent(VOID);
|
|||
|
||||
/* GLOBALS ********************************************************************/
|
||||
|
||||
/* Console reserved "file" names */
|
||||
static LPCWSTR BaseConFileName = CONSOLE_FILE_NAME;
|
||||
static LPCWSTR BaseConInputFileName = CONSOLE_INPUT_FILE_NAME;
|
||||
static LPCWSTR BaseConOutputFileName = CONSOLE_OUTPUT_FILE_NAME;
|
||||
|
||||
PHANDLER_ROUTINE InitialHandler[1];
|
||||
PHANDLER_ROUTINE* CtrlHandlers;
|
||||
ULONG NrCtrlHandlers;
|
||||
|
@ -189,6 +194,51 @@ InitConsoleCtrlHandling(VOID)
|
|||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
LPCWSTR
|
||||
IntCheckForConsoleFileName(IN LPCWSTR pszName,
|
||||
IN DWORD dwDesiredAccess)
|
||||
{
|
||||
LPCWSTR ConsoleName = pszName;
|
||||
ULONG DeviceNameInfo;
|
||||
|
||||
/*
|
||||
* Check whether we deal with a DOS device, and if so,
|
||||
* strip the path till the file name.
|
||||
* Therefore, things like \\.\CON or C:\some_path\CONIN$
|
||||
* are transformed into CON or CONIN$, for example.
|
||||
*/
|
||||
DeviceNameInfo = RtlIsDosDeviceName_U(pszName);
|
||||
if (DeviceNameInfo != 0)
|
||||
{
|
||||
ConsoleName = (LPCWSTR)((ULONG_PTR)ConsoleName + (ULONG_PTR)((DeviceNameInfo >> 16) & 0xFFFF));
|
||||
}
|
||||
|
||||
/* Return a standard console "file" name according to what we passed in parameters */
|
||||
if (_wcsicmp(ConsoleName, BaseConInputFileName) == 0)
|
||||
{
|
||||
return BaseConInputFileName;
|
||||
}
|
||||
else if (_wcsicmp(ConsoleName, BaseConOutputFileName) == 0)
|
||||
{
|
||||
return BaseConOutputFileName;
|
||||
}
|
||||
else if (_wcsicmp(ConsoleName, BaseConFileName) == 0)
|
||||
{
|
||||
if ((dwDesiredAccess & (GENERIC_READ | GENERIC_WRITE)) == GENERIC_READ)
|
||||
{
|
||||
return BaseConInputFileName;
|
||||
}
|
||||
else if ((dwDesiredAccess & (GENERIC_READ | GENERIC_WRITE)) == GENERIC_WRITE)
|
||||
{
|
||||
return BaseConOutputFileName;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we are there, that means that either the file name or the desired access are wrong */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented (Undocumented)
|
||||
*/
|
||||
|
@ -411,11 +461,11 @@ OpenConsoleW(LPCWSTR wsName,
|
|||
PCONSOLE_OPENCONSOLE OpenConsoleRequest = &ApiMessage.Data.OpenConsoleRequest;
|
||||
CONSOLE_HANDLE_TYPE HandleType;
|
||||
|
||||
if (wsName && 0 == _wcsicmp(wsName, L"CONIN$"))
|
||||
if (wsName && 0 == _wcsicmp(wsName, BaseConInputFileName))
|
||||
{
|
||||
HandleType = HANDLE_INPUT;
|
||||
}
|
||||
else if (wsName && 0 == _wcsicmp(wsName, L"CONOUT$"))
|
||||
else if (wsName && 0 == _wcsicmp(wsName, BaseConOutputFileName))
|
||||
{
|
||||
HandleType = HANDLE_OUTPUT;
|
||||
}
|
||||
|
@ -425,13 +475,8 @@ OpenConsoleW(LPCWSTR wsName,
|
|||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
if (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE))
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
if (dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE))
|
||||
if ( (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)) ||
|
||||
(dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)) )
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
|
|
|
@ -99,6 +99,7 @@ HANDLE WINAPI CreateFileW (LPCWSTR lpFileName,
|
|||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
UNICODE_STRING NtPathU;
|
||||
LPCWSTR pszConsoleFileName;
|
||||
HANDLE FileHandle;
|
||||
NTSTATUS Status;
|
||||
ULONG FileAttributes, Flags = 0;
|
||||
|
@ -142,10 +143,10 @@ HANDLE WINAPI CreateFileW (LPCWSTR lpFileName,
|
|||
}
|
||||
|
||||
/* check for console input/output */
|
||||
if (0 == _wcsicmp(L"CONOUT$", lpFileName)
|
||||
|| 0 == _wcsicmp(L"CONIN$", lpFileName))
|
||||
pszConsoleFileName = IntCheckForConsoleFileName(lpFileName, dwDesiredAccess);
|
||||
if (pszConsoleFileName)
|
||||
{
|
||||
return OpenConsoleW(lpFileName,
|
||||
return OpenConsoleW(pszConsoleFileName,
|
||||
dwDesiredAccess,
|
||||
lpSecurityAttributes ? lpSecurityAttributes->bInheritHandle : FALSE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE);
|
||||
|
|
|
@ -106,19 +106,20 @@ typedef enum _VDM_ENTRY_CODE
|
|||
|
||||
typedef struct _CODEPAGE_ENTRY
|
||||
{
|
||||
LIST_ENTRY Entry;
|
||||
UINT CodePage;
|
||||
HANDLE SectionHandle;
|
||||
PBYTE SectionMapping;
|
||||
CPTABLEINFO CodePageTable;
|
||||
LIST_ENTRY Entry;
|
||||
UINT CodePage;
|
||||
HANDLE SectionHandle;
|
||||
PBYTE SectionMapping;
|
||||
CPTABLEINFO CodePageTable;
|
||||
} CODEPAGE_ENTRY, *PCODEPAGE_ENTRY;
|
||||
|
||||
typedef struct tagLOADPARMS32 {
|
||||
LPSTR lpEnvAddress;
|
||||
LPSTR lpCmdLine;
|
||||
WORD wMagicValue;
|
||||
WORD wCmdShow;
|
||||
DWORD dwReserved;
|
||||
typedef struct tagLOADPARMS32
|
||||
{
|
||||
LPSTR lpEnvAddress;
|
||||
LPSTR lpCmdLine;
|
||||
WORD wMagicValue;
|
||||
WORD wCmdShow;
|
||||
DWORD dwReserved;
|
||||
} LOADPARMS32;
|
||||
|
||||
typedef enum _BASE_SEARCH_PATH_TYPE
|
||||
|
@ -195,6 +196,10 @@ BOOL WINAPI CloseConsoleHandle(HANDLE Handle);
|
|||
HANDLE WINAPI
|
||||
GetConsoleInputWaitHandle(VOID);
|
||||
|
||||
LPCWSTR
|
||||
IntCheckForConsoleFileName(IN LPCWSTR pszName,
|
||||
IN DWORD dwDesiredAccess);
|
||||
|
||||
HANDLE WINAPI OpenConsoleW(LPCWSTR wsName,
|
||||
DWORD dwDesiredAccess,
|
||||
BOOL bInheritHandle,
|
||||
|
|
|
@ -14,6 +14,11 @@
|
|||
#define IsConsoleHandle(h) \
|
||||
(((ULONG_PTR)(h) & 0x10000003) == 0x3)
|
||||
|
||||
/* Console reserved "file" names */
|
||||
#define CONSOLE_FILE_NAME L"CON"
|
||||
#define CONSOLE_INPUT_FILE_NAME L"CONIN$"
|
||||
#define CONSOLE_OUTPUT_FILE_NAME L"CONOUT$"
|
||||
|
||||
#endif // _CONSOLE_H
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Reference in a new issue