Author: jmorlan
Date: Sat Jul 26 19:41:45 2008
New Revision: 34817
URL:
http://svn.reactos.org/svn/reactos?rev=34817&view=rev
Log:
Move console alias functions from csrss to win32csr, and make aliases per-console.
Added:
trunk/reactos/subsystems/win32/csrss/win32csr/alias.c
- copied, changed from r34805, trunk/reactos/subsystems/win32/csrss/api/alias.c
Removed:
trunk/reactos/subsystems/win32/csrss/api/alias.c
Modified:
trunk/reactos/dll/win32/kernel32/misc/console.c
trunk/reactos/subsystems/win32/csrss/csrss.rbuild
trunk/reactos/subsystems/win32/csrss/include/api.h
trunk/reactos/subsystems/win32/csrss/include/conio.h
trunk/reactos/subsystems/win32/csrss/init.c
trunk/reactos/subsystems/win32/csrss/win32csr/conio.c
trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c
trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.rbuild
Modified: trunk/reactos/dll/win32/kernel32/misc/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/co…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] Sat Jul 26 19:41:45 2008
@@ -217,7 +217,7 @@
Request->Data.AddConsoleAlias.TargetLength = TargetLength;
- CsrRequest = MAKE_CSR_API(ADD_CONSOLE_ALIAS, CSR_NATIVE);
+ CsrRequest = MAKE_CSR_API(ADD_CONSOLE_ALIAS, CSR_CONSOLE);
Status = CsrClientCallServer(Request,
NULL,
CsrRequest,
@@ -342,7 +342,7 @@
DPRINT("GetConsoleAliasW entered lpSource %S lpExeName %S\n", lpSource,
lpExeName);
- CsrRequest = MAKE_CSR_API(GET_CONSOLE_ALIAS, CSR_NATIVE);
+ CsrRequest = MAKE_CSR_API(GET_CONSOLE_ALIAS, CSR_CONSOLE);
ExeLength = wcslen(lpExeName) + 1;
SourceLength = wcslen(lpSource) + 1;
@@ -458,7 +458,7 @@
return 0;
}
- CsrRequest = MAKE_CSR_API(GET_CONSOLE_ALIASES_EXES, CSR_NATIVE);
+ CsrRequest = MAKE_CSR_API(GET_CONSOLE_ALIASES_EXES, CSR_CONSOLE);
CsrAllocateMessagePointer(CaptureBuffer,
ExeNameBufferLength,
(PVOID*)&Request.Data.GetConsoleAliasesExes.ExeNames);
@@ -519,7 +519,7 @@
DPRINT("GetConsoleAliasExesLengthW entered\n");
- CsrRequest = MAKE_CSR_API(GET_CONSOLE_ALIASES_EXES_LENGTH, CSR_NATIVE);
+ CsrRequest = MAKE_CSR_API(GET_CONSOLE_ALIASES_EXES_LENGTH, CSR_CONSOLE);
Request.Data.GetConsoleAliasesExesLength.Length = 0;
@@ -575,7 +575,7 @@
if (!dwLength || dwLength > AliasBufferLength)
return 0;
- CsrRequest = MAKE_CSR_API(GET_ALL_CONSOLE_ALIASES, CSR_NATIVE);
+ CsrRequest = MAKE_CSR_API(GET_ALL_CONSOLE_ALIASES, CSR_CONSOLE);
Request.Data.GetAllConsoleAlias.AliasBuffer = AliasBuffer;
Request.Data.GetAllConsoleAlias.AliasBufferLength = AliasBufferLength;
Request.Data.GetAllConsoleAlias.lpExeName = ExeName;
@@ -639,7 +639,7 @@
DPRINT("GetConsoleAliasesLengthW entered\n");
- CsrRequest = MAKE_CSR_API(GET_ALL_CONSOLE_ALIASES_LENGTH, CSR_NATIVE);
+ CsrRequest = MAKE_CSR_API(GET_ALL_CONSOLE_ALIASES_LENGTH, CSR_CONSOLE);
Request.Data.GetAllConsoleAliasesLength.lpExeName = lpExeName;
Request.Data.GetAllConsoleAliasesLength.Length = 0;
Removed: trunk/reactos/subsystems/win32/csrss/api/alias.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/api…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/api/alias.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/api/alias.c (removed)
@@ -1,552 +1,0 @@
-/* $Id: init.c 31400 2007-12-22 17:18:32Z fireball $
- * PROJECT: ReactOS CSRSS
- * LICENSE: GPL - See COPYING in the top level directory
- * FILE: subsystems/win32/csrss/api/alias.c
- * PURPOSE: CSRSS alias support functions
- * COPYRIGHT: Christoph Wittich
- * Johannes Anderwald
- *
- */
-
-
-/* INCLUDES ******************************************************************/
-
-#include <csrss.h>
-
-#define NDEBUG
-#include <debug.h>
-
-typedef struct tagALIAS_ENTRY
-{
- LPCWSTR lpSource;
- LPCWSTR lpTarget;
- struct tagALIAS_ENTRY * Next;
-}ALIAS_ENTRY, *PALIAS_ENTRY;
-
-
-typedef struct tagALIAS_HEADER
-{
- LPCWSTR lpExeName;
- PALIAS_ENTRY Data;
- struct tagALIAS_HEADER * Next;
-
-}ALIAS_HEADER, *PALIAS_HEADER;
-
-static PALIAS_HEADER RootHeader = NULL;
-
-/* Ensure that a buffer is contained within the process's shared memory section. */
-static BOOL
-ValidateBuffer(PCSRSS_PROCESS_DATA ProcessData, PVOID Buffer, ULONG Size)
-{
- ULONG Offset = (BYTE *)Buffer - (BYTE *)ProcessData->CsrSectionViewBase;
- if (Offset >= ProcessData->CsrSectionViewSize
- || Size > (ProcessData->CsrSectionViewSize - Offset))
- {
- DPRINT1("Invalid buffer %p %d; not within %p %d\n",
- Buffer, Size, ProcessData->CsrSectionViewBase,
ProcessData->CsrSectionViewSize);
- return FALSE;
- }
- return TRUE;
-}
-
-static
-PALIAS_HEADER
-IntFindAliasHeader(PALIAS_HEADER RootHeader, LPCWSTR lpExeName)
-{
- while(RootHeader)
- {
- INT diff = _wcsicmp(RootHeader->lpExeName, lpExeName);
- if (!diff)
- return RootHeader;
-
- if (diff > 0)
- break;
-
- RootHeader = RootHeader->Next;
- }
- return NULL;
-}
-
-PALIAS_HEADER
-IntCreateAliasHeader(LPCWSTR lpExeName)
-{
- PALIAS_HEADER Entry;
- UINT dwLength = wcslen(lpExeName) + 1;
-
- Entry = RtlAllocateHeap(CsrssApiHeap, 0, sizeof(ALIAS_HEADER) + sizeof(WCHAR) *
dwLength);
- if (!Entry)
- return Entry;
-
- Entry->lpExeName = (LPCWSTR)(Entry + 1);
- wcscpy((WCHAR*)Entry->lpExeName, lpExeName);
- Entry->Data = NULL;
- Entry->Next = NULL;
- return Entry;
-}
-
-VOID
-IntInsertAliasHeader(PALIAS_HEADER * RootHeader, PALIAS_HEADER NewHeader)
-{
- PALIAS_HEADER CurrentHeader;
- PALIAS_HEADER LastHeader = NULL;
-
- if (*RootHeader == 0)
- {
- *RootHeader = NewHeader;
- return;
- }
-
- CurrentHeader = *RootHeader;
-
- while(CurrentHeader)
- {
- INT Diff = _wcsicmp(NewHeader->lpExeName, CurrentHeader->lpExeName);
- if (Diff < 0)
- {
- if (!LastHeader)
- *RootHeader = NewHeader;
- else
- LastHeader->Next = NewHeader;
-
- NewHeader->Next = CurrentHeader;
- return;
- }
- LastHeader = CurrentHeader;
- CurrentHeader = CurrentHeader->Next;
- }
-
- LastHeader->Next = NewHeader;
- NewHeader->Next = NULL;
-}
-
-PALIAS_ENTRY
-IntGetAliasEntry(PALIAS_HEADER Header, LPCWSTR lpSrcName)
-{
- if (Header == NULL)
- return NULL;
-
- PALIAS_ENTRY RootHeader = Header->Data;
- while(RootHeader)
- {
- DPRINT("IntGetAliasEntry>lpSource %S\n", RootHeader->lpSource);
- INT diff = _wcsicmp(RootHeader->lpSource, lpSrcName);
- if (!diff)
- return RootHeader;
-
- if (diff > 0)
- break;
-
- RootHeader = RootHeader->Next;
- }
- return NULL;
-}
-
-
-VOID
-IntInsertAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY NewEntry)
-{
- PALIAS_ENTRY CurrentEntry;
- PALIAS_ENTRY LastEntry = NULL;
-
- CurrentEntry = Header->Data;
-
- if (!CurrentEntry)
- {
- Header->Data = NewEntry;
- NewEntry->Next = NULL;
- return;
- }
-
- while(CurrentEntry)
- {
- INT Diff = _wcsicmp(NewEntry->lpSource, CurrentEntry->lpSource);
- if (Diff < 0)
- {
- if (!LastEntry)
- Header->Data = NewEntry;
- else
- LastEntry->Next = NewEntry;
- NewEntry->Next = CurrentEntry;
- return;
- }
- LastEntry = CurrentEntry;
- CurrentEntry = CurrentEntry->Next;
- }
-
- LastEntry->Next = NewEntry;
- NewEntry->Next = NULL;
-}
-
-PALIAS_ENTRY
-IntCreateAliasEntry(LPCWSTR lpSource, LPCWSTR lpTarget)
-{
- UINT dwSource;
- UINT dwTarget;
- PALIAS_ENTRY Entry;
-
- dwSource = wcslen(lpSource) + 1;
- dwTarget = wcslen(lpTarget) + 1;
-
- Entry = RtlAllocateHeap(CsrssApiHeap, 0, sizeof(ALIAS_ENTRY) + sizeof(WCHAR) *
(dwSource + dwTarget));
- if (!Entry)
- return Entry;
-
- Entry->lpSource = (LPCWSTR)(Entry + 1);
- wcscpy((LPWSTR)Entry->lpSource, lpSource);
- Entry->lpTarget = Entry->lpSource + dwSource;
- wcscpy((LPWSTR)Entry->lpTarget, lpTarget);
- Entry->Next = NULL;
-
- return Entry;
-}
-
-UINT
-IntGetConsoleAliasesExesLength(PALIAS_HEADER RootHeader)
-{
- UINT length = 0;
-
- while(RootHeader)
- {
- length += (wcslen(RootHeader->lpExeName) + 1) * sizeof(WCHAR);
- RootHeader = RootHeader->Next;
- }
- if (length)
- length += sizeof(WCHAR); // last entry entry is terminated with 2 zero bytes
-
- return length;
-}
-
-UINT
-IntGetConsoleAliasesExes(PALIAS_HEADER RootHeader, LPWSTR TargetBuffer, UINT
TargetBufferSize)
-{
- UINT Offset = 0;
- UINT Length;
-
- TargetBufferSize /= sizeof(WCHAR);
- while(RootHeader)
- {
- Length = wcslen(RootHeader->lpExeName) + 1;
- if (TargetBufferSize > Offset + Length)
- {
- wcscpy(&TargetBuffer[Offset], RootHeader->lpExeName);
- Offset += Length;
- }
- else
- {
- break;
- }
- RootHeader = RootHeader->Next;
- }
- Length = min(Offset+1, TargetBufferSize);
- TargetBuffer[Length] = L'\0';
- return Length * sizeof(WCHAR);
-}
-
-UINT
-IntGetAllConsoleAliasesLength(PALIAS_HEADER Header)
-{
- UINT Length = 0;
- PALIAS_ENTRY CurEntry = Header->Data;
-
- while(CurEntry)
- {
- Length += wcslen(CurEntry->lpSource);
- Length += wcslen(CurEntry->lpTarget);
- Length += 2; // zero byte and '='
- CurEntry = CurEntry->Next;
- }
-
- if (Length)
- {
- return (Length+1) * sizeof(WCHAR);
- }
- return 0;
-}
-UINT
-IntGetAllConsoleAliases(PALIAS_HEADER Header, LPWSTR TargetBuffer, UINT
TargetBufferLength)
-{
- PALIAS_ENTRY CurEntry = Header->Data;
- UINT Offset = 0;
- UINT SrcLength, TargetLength;
-
- TargetBufferLength /= sizeof(WCHAR);
- while(CurEntry)
- {
- SrcLength = wcslen(CurEntry->lpSource) + 1;
- TargetLength = wcslen(CurEntry->lpTarget) + 1;
- if (Offset + TargetLength + SrcLength >= TargetBufferLength)
- break;
-
- wcscpy(&TargetBuffer[Offset], CurEntry->lpSource);
- Offset += SrcLength;
- TargetBuffer[Offset] = L'=';
- wcscpy(&TargetBuffer[Offset], CurEntry->lpTarget);
- Offset += TargetLength;
-
- CurEntry = CurEntry->Next;
- }
- TargetBuffer[Offset] = L'\0';
- return Offset * sizeof(WCHAR);
-}
-VOID
-IntDeleteAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY Entry)
-{
- PALIAS_ENTRY LastEntry;
- PALIAS_ENTRY CurEntry;
-
- if (Header->Data == Entry)
- {
- Header->Data = Entry->Next;
- RtlFreeHeap(CsrssApiHeap, 0, Entry);
- return;
- }
- LastEntry = Header->Data;
- CurEntry = LastEntry->Next;
-
- while(CurEntry)
- {
- if (CurEntry == Entry)
- {
- LastEntry->Next = Entry->Next;
- RtlFreeHeap(CsrssApiHeap, 0, Entry);
- return;
- }
- LastEntry = CurEntry;
- CurEntry = CurEntry->Next;
- }
-}
-
-CSR_API(CsrAddConsoleAlias)
-{
- PALIAS_HEADER Header;
- PALIAS_ENTRY Entry;
- WCHAR * lpExeName;
- WCHAR * lpSource;
- WCHAR * lpTarget;
- ULONG TotalLength;
- WCHAR * Ptr;
-
- TotalLength = Request->Data.AddConsoleAlias.SourceLength +
Request->Data.AddConsoleAlias.ExeLength +
Request->Data.AddConsoleAlias.TargetLength;
- Ptr = (WCHAR*)((ULONG_PTR)Request + sizeof(CSR_API_MESSAGE));
-
- lpSource = (WCHAR*)((ULONG_PTR)Request + sizeof(CSR_API_MESSAGE));
- lpExeName = (WCHAR*)((ULONG_PTR)Request + sizeof(CSR_API_MESSAGE) +
Request->Data.AddConsoleAlias.SourceLength * sizeof(WCHAR));
- lpTarget = (Request->Data.AddConsoleAlias.TargetLength != 0 ? lpExeName +
Request->Data.AddConsoleAlias.ExeLength : NULL);
-
- DPRINT("CsrAddConsoleAlias entered Request %p lpSource %p lpExeName %p lpTarget
%p\n", Request, lpSource, lpExeName, lpTarget);
-
- if (lpExeName == NULL || lpSource == NULL)
- {
- Request->Status = STATUS_INVALID_PARAMETER;
- return Request->Status;
- }
-
- Header = IntFindAliasHeader(RootHeader, lpExeName);
- if (!Header && lpTarget != NULL)
- {
- Header = IntCreateAliasHeader(lpExeName);
- if (!Header)
- {
- Request->Status = STATUS_INSUFFICIENT_RESOURCES;
- return Request->Status;
- }
- IntInsertAliasHeader(&RootHeader, Header);
- }
-
- if (lpTarget == NULL) // delete the entry
- {
- Entry = IntGetAliasEntry(Header, lpSource);
- if (Entry)
- {
- IntDeleteAliasEntry(Header, Entry);
- Request->Status = STATUS_SUCCESS;
- }
- else
- {
- Request->Status = STATUS_INVALID_PARAMETER;
- }
- return Request->Status;
- }
-
- Entry = IntCreateAliasEntry(lpSource, lpTarget);
-
- if (!Entry)
- {
- Request->Status = STATUS_INSUFFICIENT_RESOURCES;
- return Request->Status;
- }
-
- IntInsertAliasEntry(Header, Entry);
- Request->Status = STATUS_SUCCESS;
- return Request->Status;
-}
-
-CSR_API(CsrGetConsoleAlias)
-{
- PALIAS_HEADER Header;
- PALIAS_ENTRY Entry;
- UINT Length;
- WCHAR * lpExeName;
- WCHAR * lpSource;
- WCHAR * lpTarget;
-
- lpSource = (LPWSTR)((ULONG_PTR)Request + sizeof(CSR_API_MESSAGE));
- lpExeName = lpSource + Request->Data.GetConsoleAlias.SourceLength;
- lpTarget = Request->Data.GetConsoleAlias.TargetBuffer;
-
-
- DPRINT("CsrGetConsoleAlias entered lpExeName %p lpSource %p TargetBuffer %p
TargetBufferLength %u\n",
- lpExeName, lpSource, lpTarget,
Request->Data.GetConsoleAlias.TargetBufferLength);
-
- if (Request->Data.GetConsoleAlias.ExeLength == 0 || lpTarget == NULL ||
- Request->Data.GetConsoleAlias.TargetBufferLength == 0 ||
Request->Data.GetConsoleAlias.SourceLength == 0)
- {
- Request->Status = STATUS_INVALID_PARAMETER;
- return Request->Status;
- }
-
- Header = IntFindAliasHeader(RootHeader, lpExeName);
- if (!Header)
- {
- Request->Status = STATUS_INVALID_PARAMETER;
- return Request->Status;
- }
-
- Entry = IntGetAliasEntry(Header, lpSource);
- if (!Entry)
- {
- Request->Status = STATUS_INVALID_PARAMETER;
- return Request->Status;
- }
-
- Length = (wcslen(Entry->lpTarget)+1) * sizeof(WCHAR);
- if (Length > Request->Data.GetConsoleAlias.TargetBufferLength)
- {
- Request->Status = STATUS_BUFFER_TOO_SMALL;
- return Request->Status;
- }
-
- if (!ValidateBuffer(ProcessData, lpTarget,
Request->Data.GetConsoleAlias.TargetBufferLength))
- {
- Request->Status = STATUS_ACCESS_VIOLATION;
- return Request->Status;
- }
-
- wcscpy(lpTarget, Entry->lpTarget);
- Request->Data.GetConsoleAlias.BytesWritten = Length;
- Request->Status = STATUS_SUCCESS;
- return Request->Status;
-}
-
-CSR_API(CsrGetAllConsoleAliases)
-{
- ULONG BytesWritten;
- PALIAS_HEADER Header;
-
- if (Request->Data.GetAllConsoleAlias.lpExeName == NULL)
- {
- Request->Status = STATUS_INVALID_PARAMETER;
- return Request->Status;
- }
-
- Header = IntFindAliasHeader(RootHeader,
Request->Data.GetAllConsoleAlias.lpExeName);
- if (!Header)
- {
- Request->Status = STATUS_INVALID_PARAMETER;
- return Request->Status;
- }
-
- if (IntGetAllConsoleAliasesLength(Header) >
Request->Data.GetAllConsoleAlias.AliasBufferLength)
- {
- Request->Status = STATUS_BUFFER_OVERFLOW;
- return Request->Status;
- }
-
- if (!ValidateBuffer(ProcessData,
- Request->Data.GetAllConsoleAlias.AliasBuffer,
- Request->Data.GetAllConsoleAlias.AliasBufferLength))
- {
- Request->Status = STATUS_ACCESS_VIOLATION;
- return Request->Status;
- }
-
- BytesWritten = IntGetAllConsoleAliases(Header,
-
Request->Data.GetAllConsoleAlias.AliasBuffer,
-
Request->Data.GetAllConsoleAlias.AliasBufferLength);
-
- Request->Data.GetAllConsoleAlias.BytesWritten = BytesWritten;
- Request->Status = STATUS_SUCCESS;
- return Request->Status;
-}
-
-CSR_API(CsrGetAllConsoleAliasesLength)
-{
- PALIAS_HEADER Header;
- UINT Length;
-
- if (Request->Data.GetAllConsoleAliasesLength.lpExeName == NULL)
- {
- Request->Status = STATUS_INVALID_PARAMETER;
- return Request->Status;
- }
-
- Header = IntFindAliasHeader(RootHeader,
Request->Data.GetAllConsoleAliasesLength.lpExeName);
- if (!Header)
- {
- Request->Status = STATUS_INVALID_PARAMETER;
- return Request->Status;
- }
-
- Length = IntGetAllConsoleAliasesLength(Header);
- Request->Data.GetAllConsoleAliasesLength.Length = Length;
- Request->Status = STATUS_SUCCESS;
- return Request->Status;
-
-}
-
-CSR_API(CsrGetConsoleAliasesExes)
-{
- UINT BytesWritten;
- UINT ExesLength;
-
- DPRINT("CsrGetConsoleAliasesExes entered\n");
-
- ExesLength = IntGetConsoleAliasesExesLength(RootHeader);
-
- if (ExesLength > Request->Data.GetConsoleAliasesExes.Length)
- {
- Request->Status = STATUS_BUFFER_OVERFLOW;
- return Request->Status;
- }
-
- if (Request->Data.GetConsoleAliasesExes.ExeNames == NULL)
- {
- Request->Status = STATUS_INVALID_PARAMETER;
- return Request->Status;
- }
-
- if (!ValidateBuffer(ProcessData,
- Request->Data.GetConsoleAliasesExes.ExeNames,
- Request->Data.GetConsoleAliasesExes.Length))
- {
- Request->Status = STATUS_ACCESS_VIOLATION;
- return Request->Status;
- }
-
- BytesWritten = IntGetConsoleAliasesExes(RootHeader,
-
Request->Data.GetConsoleAliasesExes.ExeNames,
-
Request->Data.GetConsoleAliasesExes.Length);
-
- Request->Data.GetConsoleAliasesExes.BytesWritten = BytesWritten;
- Request->Status = STATUS_SUCCESS;
- return Request->Status;
-}
-
-CSR_API(CsrGetConsoleAliasesExesLength)
-{
- DPRINT("CsrGetConsoleAliasesExesLength entered\n");
-
- Request->Status = STATUS_SUCCESS;
- Request->Data.GetConsoleAliasesExesLength.Length =
IntGetConsoleAliasesExesLength(RootHeader);
- return Request->Status;
-}
Modified: trunk/reactos/subsystems/win32/csrss/csrss.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrss.rbuild [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrss.rbuild [iso-8859-1] Sat Jul 26 19:41:45
2008
@@ -17,7 +17,6 @@
<file>process.c</file>
<file>user.c</file>
<file>wapi.c</file>
- <file>alias.c</file>
</directory>
<pch>csrss.h</pch>
<file>csrss.c</file>
Modified: trunk/reactos/subsystems/win32/csrss/include/api.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] Sat Jul 26 19:41:45
2008
@@ -156,13 +156,6 @@
CSR_API(CsrSetLogonNotifyWindow);
CSR_API(CsrRegisterLogonProcess);
-CSR_API(CsrAddConsoleAlias);
-CSR_API(CsrGetConsoleAlias);
-CSR_API(CsrGetAllConsoleAliases);
-CSR_API(CsrGetAllConsoleAliasesLength);
-CSR_API(CsrGetConsoleAliasesExes);
-CSR_API(CsrGetConsoleAliasesExesLength);
-
#endif /* ndef API_H_INCLUDED */
Modified: trunk/reactos/subsystems/win32/csrss/include/conio.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/include/conio.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/include/conio.h [iso-8859-1] Sat Jul 26 19:41:45
2008
@@ -83,8 +83,10 @@
UINT OutputCodePage;
PCSRSS_CONSOLE_VTBL Vtbl;
LIST_ENTRY ProcessList;
+ struct tagALIAS_HEADER *Aliases;
} CSRSS_CONSOLE;
+NTSTATUS FASTCALL ConioConsoleFromProcessData(PCSRSS_PROCESS_DATA ProcessData,
PCSRSS_CONSOLE *Console);
VOID STDCALL ConioDeleteConsole(Object_t *Object);
VOID STDCALL ConioDeleteScreenBuffer(Object_t *Buffer);
void STDCALL ConioProcessKey(MSG *msg, PCSRSS_CONSOLE Console, BOOL TextMode);
@@ -162,6 +164,16 @@
Win32CsrUnlockObject((Object_t *) Buff)
#define ConioChangeIcon(Console, hWindowIcon) (Console)->Vtbl->ChangeIcon(Console,
hWindowIcon)
+/* alias.c */
+VOID IntDeleteAllAliases(struct tagALIAS_HEADER *RootHeader);
+CSR_API(CsrAddConsoleAlias);
+CSR_API(CsrGetConsoleAlias);
+CSR_API(CsrGetAllConsoleAliases);
+CSR_API(CsrGetAllConsoleAliasesLength);
+CSR_API(CsrGetConsoleAliasesExes);
+CSR_API(CsrGetConsoleAliasesExesLength);
+
+
#endif /* CONIO_H_INCLUDED */
/* EOF */
Modified: trunk/reactos/subsystems/win32/csrss/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/ini…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/init.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/init.c [iso-8859-1] Sat Jul 26 19:41:45 2008
@@ -294,12 +294,6 @@
CSRSS_DEFINE_API(VERIFY_HANDLE, CsrVerifyHandle),
CSRSS_DEFINE_API(DUPLICATE_HANDLE, CsrDuplicateHandle),
CSRSS_DEFINE_API(GET_INPUT_WAIT_HANDLE, CsrGetInputWaitHandle),
- CSRSS_DEFINE_API(ADD_CONSOLE_ALIAS, CsrAddConsoleAlias),
- CSRSS_DEFINE_API(GET_CONSOLE_ALIAS, CsrGetConsoleAlias),
- CSRSS_DEFINE_API(GET_ALL_CONSOLE_ALIASES, CsrGetAllConsoleAliases),
- CSRSS_DEFINE_API(GET_ALL_CONSOLE_ALIASES_LENGTH, CsrGetAllConsoleAliasesLength),
- CSRSS_DEFINE_API(GET_CONSOLE_ALIASES_EXES, CsrGetConsoleAliasesExes),
- CSRSS_DEFINE_API(GET_CONSOLE_ALIASES_EXES_LENGTH, CsrGetConsoleAliasesExesLength),
{ 0, 0, NULL }
};
Copied: trunk/reactos/subsystems/win32/csrss/win32csr/alias.c (from r34805,
trunk/reactos/subsystems/win32/csrss/api/alias.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/api/alias.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/alias.c [iso-8859-1] Sat Jul 26 19:41:45
2008
@@ -11,7 +11,7 @@
/* INCLUDES ******************************************************************/
-#include <csrss.h>
+#include "w32csr.h"
#define NDEBUG
#include <debug.h>
@@ -32,8 +32,6 @@
}ALIAS_HEADER, *PALIAS_HEADER;
-static PALIAS_HEADER RootHeader = NULL;
-
/* Ensure that a buffer is contained within the process's shared memory section. */
static BOOL
ValidateBuffer(PCSRSS_PROCESS_DATA ProcessData, PVOID Buffer, ULONG Size)
@@ -73,7 +71,7 @@
PALIAS_HEADER Entry;
UINT dwLength = wcslen(lpExeName) + 1;
- Entry = RtlAllocateHeap(CsrssApiHeap, 0, sizeof(ALIAS_HEADER) + sizeof(WCHAR) *
dwLength);
+ Entry = RtlAllocateHeap(Win32CsrApiHeap, 0, sizeof(ALIAS_HEADER) + sizeof(WCHAR) *
dwLength);
if (!Entry)
return Entry;
@@ -187,7 +185,7 @@
dwSource = wcslen(lpSource) + 1;
dwTarget = wcslen(lpTarget) + 1;
- Entry = RtlAllocateHeap(CsrssApiHeap, 0, sizeof(ALIAS_ENTRY) + sizeof(WCHAR) *
(dwSource + dwTarget));
+ Entry = RtlAllocateHeap(Win32CsrApiHeap, 0, sizeof(ALIAS_ENTRY) + sizeof(WCHAR) *
(dwSource + dwTarget));
if (!Entry)
return Entry;
@@ -297,7 +295,7 @@
if (Header->Data == Entry)
{
Header->Data = Entry->Next;
- RtlFreeHeap(CsrssApiHeap, 0, Entry);
+ RtlFreeHeap(Win32CsrApiHeap, 0, Entry);
return;
}
LastEntry = Header->Data;
@@ -308,16 +306,33 @@
if (CurEntry == Entry)
{
LastEntry->Next = Entry->Next;
- RtlFreeHeap(CsrssApiHeap, 0, Entry);
+ RtlFreeHeap(Win32CsrApiHeap, 0, Entry);
return;
}
LastEntry = CurEntry;
CurEntry = CurEntry->Next;
}
}
+VOID
+IntDeleteAllAliases(PALIAS_HEADER RootHeader)
+{
+ PALIAS_HEADER Header, NextHeader;
+ PALIAS_ENTRY Entry, NextEntry;
+ for (Header = RootHeader; Header; Header = NextHeader)
+ {
+ NextHeader = Header->Next;
+ for (Entry = Header->Data; Entry; Entry = NextEntry)
+ {
+ NextEntry = Entry->Next;
+ RtlFreeHeap(Win32CsrApiHeap, 0, Entry);
+ }
+ RtlFreeHeap(Win32CsrApiHeap, 0, Header);
+ }
+}
CSR_API(CsrAddConsoleAlias)
{
+ PCSRSS_CONSOLE Console;
PALIAS_HEADER Header;
PALIAS_ENTRY Entry;
WCHAR * lpExeName;
@@ -341,16 +356,23 @@
return Request->Status;
}
- Header = IntFindAliasHeader(RootHeader, lpExeName);
+ Request->Status = ConioConsoleFromProcessData(ProcessData, &Console);
+ if (!NT_SUCCESS(Request->Status))
+ {
+ return Request->Status;
+ }
+
+ Header = IntFindAliasHeader(Console->Aliases, lpExeName);
if (!Header && lpTarget != NULL)
{
Header = IntCreateAliasHeader(lpExeName);
if (!Header)
{
Request->Status = STATUS_INSUFFICIENT_RESOURCES;
+ ConioUnlockConsole(Console);
return Request->Status;
}
- IntInsertAliasHeader(&RootHeader, Header);
+ IntInsertAliasHeader(&Console->Aliases, Header);
}
if (lpTarget == NULL) // delete the entry
@@ -365,6 +387,7 @@
{
Request->Status = STATUS_INVALID_PARAMETER;
}
+ ConioUnlockConsole(Console);
return Request->Status;
}
@@ -373,16 +396,19 @@
if (!Entry)
{
Request->Status = STATUS_INSUFFICIENT_RESOURCES;
+ ConioUnlockConsole(Console);
return Request->Status;
}
IntInsertAliasEntry(Header, Entry);
Request->Status = STATUS_SUCCESS;
+ ConioUnlockConsole(Console);
return Request->Status;
}
CSR_API(CsrGetConsoleAlias)
{
+ PCSRSS_CONSOLE Console;
PALIAS_HEADER Header;
PALIAS_ENTRY Entry;
UINT Length;
@@ -405,10 +431,17 @@
return Request->Status;
}
- Header = IntFindAliasHeader(RootHeader, lpExeName);
+ Request->Status = ConioConsoleFromProcessData(ProcessData, &Console);
+ if (!NT_SUCCESS(Request->Status))
+ {
+ return Request->Status;
+ }
+
+ Header = IntFindAliasHeader(Console->Aliases, lpExeName);
if (!Header)
{
Request->Status = STATUS_INVALID_PARAMETER;
+ ConioUnlockConsole(Console);
return Request->Status;
}
@@ -416,6 +449,7 @@
if (!Entry)
{
Request->Status = STATUS_INVALID_PARAMETER;
+ ConioUnlockConsole(Console);
return Request->Status;
}
@@ -423,23 +457,27 @@
if (Length > Request->Data.GetConsoleAlias.TargetBufferLength)
{
Request->Status = STATUS_BUFFER_TOO_SMALL;
+ ConioUnlockConsole(Console);
return Request->Status;
}
if (!ValidateBuffer(ProcessData, lpTarget,
Request->Data.GetConsoleAlias.TargetBufferLength))
{
Request->Status = STATUS_ACCESS_VIOLATION;
+ ConioUnlockConsole(Console);
return Request->Status;
}
wcscpy(lpTarget, Entry->lpTarget);
Request->Data.GetConsoleAlias.BytesWritten = Length;
Request->Status = STATUS_SUCCESS;
+ ConioUnlockConsole(Console);
return Request->Status;
}
CSR_API(CsrGetAllConsoleAliases)
{
+ PCSRSS_CONSOLE Console;
ULONG BytesWritten;
PALIAS_HEADER Header;
@@ -449,16 +487,24 @@
return Request->Status;
}
- Header = IntFindAliasHeader(RootHeader,
Request->Data.GetAllConsoleAlias.lpExeName);
+ Request->Status = ConioConsoleFromProcessData(ProcessData, &Console);
+ if (!NT_SUCCESS(Request->Status))
+ {
+ return Request->Status;
+ }
+
+ Header = IntFindAliasHeader(Console->Aliases,
Request->Data.GetAllConsoleAlias.lpExeName);
if (!Header)
{
Request->Status = STATUS_INVALID_PARAMETER;
+ ConioUnlockConsole(Console);
return Request->Status;
}
if (IntGetAllConsoleAliasesLength(Header) >
Request->Data.GetAllConsoleAlias.AliasBufferLength)
{
Request->Status = STATUS_BUFFER_OVERFLOW;
+ ConioUnlockConsole(Console);
return Request->Status;
}
@@ -467,6 +513,7 @@
Request->Data.GetAllConsoleAlias.AliasBufferLength))
{
Request->Status = STATUS_ACCESS_VIOLATION;
+ ConioUnlockConsole(Console);
return Request->Status;
}
@@ -476,11 +523,13 @@
Request->Data.GetAllConsoleAlias.BytesWritten = BytesWritten;
Request->Status = STATUS_SUCCESS;
+ ConioUnlockConsole(Console);
return Request->Status;
}
CSR_API(CsrGetAllConsoleAliasesLength)
{
+ PCSRSS_CONSOLE Console;
PALIAS_HEADER Header;
UINT Length;
@@ -490,38 +539,55 @@
return Request->Status;
}
- Header = IntFindAliasHeader(RootHeader,
Request->Data.GetAllConsoleAliasesLength.lpExeName);
+ Request->Status = ConioConsoleFromProcessData(ProcessData, &Console);
+ if (!NT_SUCCESS(Request->Status))
+ {
+ return Request->Status;
+ }
+
+ Header = IntFindAliasHeader(Console->Aliases,
Request->Data.GetAllConsoleAliasesLength.lpExeName);
if (!Header)
{
Request->Status = STATUS_INVALID_PARAMETER;
+ ConioUnlockConsole(Console);
return Request->Status;
}
Length = IntGetAllConsoleAliasesLength(Header);
Request->Data.GetAllConsoleAliasesLength.Length = Length;
Request->Status = STATUS_SUCCESS;
+ ConioUnlockConsole(Console);
return Request->Status;
}
CSR_API(CsrGetConsoleAliasesExes)
{
+ PCSRSS_CONSOLE Console;
UINT BytesWritten;
UINT ExesLength;
DPRINT("CsrGetConsoleAliasesExes entered\n");
- ExesLength = IntGetConsoleAliasesExesLength(RootHeader);
+ Request->Status = ConioConsoleFromProcessData(ProcessData, &Console);
+ if (!NT_SUCCESS(Request->Status))
+ {
+ return Request->Status;
+ }
+
+ ExesLength = IntGetConsoleAliasesExesLength(Console->Aliases);
if (ExesLength > Request->Data.GetConsoleAliasesExes.Length)
{
Request->Status = STATUS_BUFFER_OVERFLOW;
+ ConioUnlockConsole(Console);
return Request->Status;
}
if (Request->Data.GetConsoleAliasesExes.ExeNames == NULL)
{
Request->Status = STATUS_INVALID_PARAMETER;
+ ConioUnlockConsole(Console);
return Request->Status;
}
@@ -530,23 +596,30 @@
Request->Data.GetConsoleAliasesExes.Length))
{
Request->Status = STATUS_ACCESS_VIOLATION;
- return Request->Status;
- }
-
- BytesWritten = IntGetConsoleAliasesExes(RootHeader,
+ ConioUnlockConsole(Console);
+ return Request->Status;
+ }
+
+ BytesWritten = IntGetConsoleAliasesExes(Console->Aliases,
Request->Data.GetConsoleAliasesExes.ExeNames,
Request->Data.GetConsoleAliasesExes.Length);
Request->Data.GetConsoleAliasesExes.BytesWritten = BytesWritten;
Request->Status = STATUS_SUCCESS;
+ ConioUnlockConsole(Console);
return Request->Status;
}
CSR_API(CsrGetConsoleAliasesExesLength)
{
+ PCSRSS_CONSOLE Console;
DPRINT("CsrGetConsoleAliasesExesLength entered\n");
- Request->Status = STATUS_SUCCESS;
- Request->Data.GetConsoleAliasesExesLength.Length =
IntGetConsoleAliasesExesLength(RootHeader);
+ Request->Status = ConioConsoleFromProcessData(ProcessData, &Console);
+ if (NT_SUCCESS(Request->Status))
+ {
+ Request->Data.GetConsoleAliasesExesLength.Length =
IntGetConsoleAliasesExesLength(Console->Aliases);
+ ConioUnlockConsole(Console);
+ }
return Request->Status;
}
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] Sat Jul 26 19:41:45
2008
@@ -36,7 +36,7 @@
/* FUNCTIONS *****************************************************************/
-static NTSTATUS FASTCALL
+NTSTATUS FASTCALL
ConioConsoleFromProcessData(PCSRSS_PROCESS_DATA ProcessData, PCSRSS_CONSOLE *Console)
{
PCSRSS_CONSOLE ProcessConsole = ProcessData->Console;
@@ -961,6 +961,7 @@
CloseHandle(Console->ActiveEvent);
DeleteCriticalSection(&Console->Header.Lock);
RtlFreeUnicodeString(&Console->Title);
+ IntDeleteAllAliases(Console->Aliases);
HeapFree(Win32CsrApiHeap, 0, Console);
}
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c [iso-8859-1] Sat Jul 26
19:41:45 2008
@@ -68,6 +68,12 @@
CSRSS_DEFINE_API(GET_CONSOLE_OUTPUT_CP, CsrGetConsoleOutputCodePage),
CSRSS_DEFINE_API(SET_CONSOLE_OUTPUT_CP, CsrSetConsoleOutputCodePage),
CSRSS_DEFINE_API(GET_PROCESS_LIST, CsrGetProcessList),
+ CSRSS_DEFINE_API(ADD_CONSOLE_ALIAS, CsrAddConsoleAlias),
+ CSRSS_DEFINE_API(GET_CONSOLE_ALIAS, CsrGetConsoleAlias),
+ CSRSS_DEFINE_API(GET_ALL_CONSOLE_ALIASES, CsrGetAllConsoleAliases),
+ CSRSS_DEFINE_API(GET_ALL_CONSOLE_ALIASES_LENGTH, CsrGetAllConsoleAliasesLength),
+ CSRSS_DEFINE_API(GET_CONSOLE_ALIASES_EXES, CsrGetConsoleAliasesExes),
+ CSRSS_DEFINE_API(GET_CONSOLE_ALIASES_EXES_LENGTH, CsrGetConsoleAliasesExesLength),
{ 0, 0, NULL }
};
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.rbuild [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.rbuild [iso-8859-1] Sat Jul 26
19:41:45 2008
@@ -17,6 +17,7 @@
<library>psapi</library>
<library>msvcrt</library>
<pch>w32csr.h</pch>
+ <file>alias.c</file>
<file>conio.c</file>
<file>desktopbg.c</file>
<file>dllmain.c</file>