From 8e8502cc51b1762fd8328a1f4902234a57a72910 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 15 Jul 2001 13:46:16 +0000 Subject: [PATCH] Create symbolic links for dos devices. svn path=/trunk/; revision=2061 --- reactos/subsys/smss/init.c | 100 ++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/reactos/subsys/smss/init.c b/reactos/subsys/smss/init.c index f8d1506fce6..e9cac3e219a 100644 --- a/reactos/subsys/smss/init.c +++ b/reactos/subsys/smss/init.c @@ -1,4 +1,4 @@ -/* $Id: init.c,v 1.25 2001/06/12 17:50:28 chorns Exp $ +/* $Id: init.c,v 1.26 2001/07/15 13:46:16 ekohl Exp $ * * init.c - Session Manager initialization * @@ -35,6 +35,18 @@ #define NDEBUG +/* TYPES ********************************************************************/ + +/* + * NOTE: This is only used until the dos device links are + * read from the registry!! + */ +typedef struct +{ + PWSTR DeviceName; + PWSTR LinkName; +} LINKDATA, *PLINKDATA; + /* GLOBAL VARIABLES *********************************************************/ HANDLE SmApiPort = INVALID_HANDLE_VALUE; @@ -135,6 +147,89 @@ SmCreatePagingFiles (VOID) #endif +static VOID +SmInitDosDevices(VOID) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING DeviceName; + UNICODE_STRING LinkName; + HANDLE LinkHandle; +#if 0 + HANDLE DeviceHandle; + IO_STATUS_BLOCK StatusBlock; +#endif + NTSTATUS Status; + WCHAR LinkBuffer[80]; + + PLINKDATA LinkPtr; + LINKDATA LinkData[] = + {{L"\\Device\\NamedPipe", L"PIPE"}, + {L"\\Device\\Null", L"NUL"}, + {L"\\Device\\Mup", L"UNC"}, + {L"\\Device\\MailSlot", L"MAILSLOT"}, + {L"\\DosDevices\\COM1", L"AUX"}, + {L"\\DosDevices\\LPT1", L"PRN"}, + {NULL, NULL}}; + + /* FIXME: Read the list of symbolic links from the registry!! */ + + LinkPtr = &LinkData[0]; + while (LinkPtr->DeviceName != NULL) + { + swprintf(LinkBuffer, L"\\??\\%s", + LinkPtr->LinkName); + RtlInitUnicodeString(&LinkName, + LinkBuffer); + RtlInitUnicodeString(&DeviceName, + LinkPtr->DeviceName); + + PrintString("SM: Linking %wZ --> %wZ\n", + &LinkName, + &DeviceName); +#if 0 + /* check if target device exists (can be opened) */ + InitializeObjectAttributes(&ObjectAttributes, + &DeviceName, + 0, + NULL, + NULL); + + Status = NtOpenFile(&DeviceHandle, + 0x10001, + &ObjectAttributes, + &StatusBlock, + 1, + FILE_SYNCHRONOUS_IO_NONALERT); + if (NT_SUCCESS(Status)) + { + NtClose(DeviceHandle); +#endif + /* create symbolic link */ + InitializeObjectAttributes(&ObjectAttributes, + &LinkName, + OBJ_PERMANENT, + NULL, + NULL); + + Status = NtCreateSymbolicLinkObject(&LinkHandle, + SYMBOLIC_LINK_ALL_ACCESS, + &ObjectAttributes, + &DeviceName); + if (!NT_SUCCESS(Status)) + { + PrintString("SM: NtCreateSymbolicLink( %wZ --> %wZ ) failed!\n", + &LinkName, + &DeviceName); + } + NtClose(LinkHandle); +#if 0 + } +#endif + LinkPtr++; + } +} + + static VOID SmSetEnvironmentVariables (VOID) { @@ -332,7 +427,8 @@ BOOL InitSessionManager (HANDLE Children[]) DisplayString (L"SM: System Environment created\n"); #endif - /* FIXME: Define symbolic links to kernel devices (MS-DOS names) */ + /* Define symbolic links to kernel devices (MS-DOS names) */ + SmInitDosDevices(); /* FIXME: Run all programs in the boot execution list */ -- 2.17.1