[KERNEL32/CONSRV]

- Use capture buffers to pass (variable-length) strings to the console server.
- Merge the CSRSS_ADD_CONSOLE_ALIAS and CSRSS_GET_CONSOLE_ALIAS structures into a unique structure CSRSS_CONSOLE_ALIAS.

TODO: Check what happens to the "/ sizeof(WCHAR);" in GetConsoleAliasesW.

svn path=/branches/ros-csrss/; revision=57712
This commit is contained in:
Hermès Bélusca-Maïto 2012-11-15 21:02:01 +00:00
parent d6b0ad349a
commit 1ccafa6cae
3 changed files with 506 additions and 336 deletions

View file

@ -1,8 +1,8 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: dll/win32/kernel32/client/console/console.c
* PURPOSE: Win32 server console functions
* FILE: dll/win32/kernel32/client/console/alias.c
* PURPOSE: Win32 Console Client Alias support functions
* PROGRAMMERS: David Welch (welch@cwcom.net) (welch@mcmail.com)
* Christoph von Wittich (christoph_vw@reactos.org)
* Johannes Anderwald (janderwald@reactos.org)
@ -15,10 +15,11 @@
#define NDEBUG
#include <debug.h>
/* FUNCTIONS ******************************************************************/
/*
* @unimplemented
* @implemented
*/
BOOL
WINAPI
@ -26,54 +27,77 @@ AddConsoleAliasW(LPCWSTR lpSource,
LPCWSTR lpTarget,
LPCWSTR lpExeName)
{
PCSR_API_MESSAGE Request;
NTSTATUS Status;
ULONG SourceLength;
ULONG TargetLength = 0;
ULONG ExeLength;
ULONG Size;
ULONG RequestLength;
WCHAR * Ptr;
CONSOLE_API_MESSAGE ApiMessage;
PCSRSS_CONSOLE_ALIAS ConsoleAlias = &ApiMessage.Data.ConsoleAlias;
PCSR_CAPTURE_BUFFER CaptureBuffer;
ULONG CapturedStrings;
DPRINT("AddConsoleAliasW enterd with lpSource %S lpTarget %S lpExeName %S\n", lpSource, lpTarget, lpExeName);
ExeLength = wcslen(lpExeName) + 1;
SourceLength = wcslen(lpSource)+ 1;
if (lpTarget)
TargetLength = wcslen(lpTarget) + 1;
/* Determine the needed sizes */
ConsoleAlias->SourceLength = (wcslen(lpSource ) + 1) * sizeof(WCHAR);
ConsoleAlias->ExeLength = (wcslen(lpExeName) + 1) * sizeof(WCHAR);
CapturedStrings = 2;
Size = (ExeLength + SourceLength + TargetLength) * sizeof(WCHAR);
RequestLength = sizeof(CSR_API_MESSAGE) + Size;
Request = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, RequestLength);
Ptr = (WCHAR*)(((ULONG_PTR)Request) + sizeof(CSR_API_MESSAGE));
wcscpy(Ptr, lpSource);
Request->Data.AddConsoleAlias.SourceLength = SourceLength;
Ptr = (WCHAR*)(((ULONG_PTR)Request) + sizeof(CSR_API_MESSAGE) + SourceLength * sizeof(WCHAR));
wcscpy(Ptr, lpExeName);
Request->Data.AddConsoleAlias.ExeLength = ExeLength;
Ptr = (WCHAR*)(((ULONG_PTR)Request) + sizeof(CSR_API_MESSAGE) + (ExeLength + SourceLength)* sizeof(WCHAR));
if (lpTarget) /* target can be optional */
wcscpy(Ptr, lpTarget);
Request->Data.AddConsoleAlias.TargetLength = TargetLength;
Status = CsrClientCallServer(Request,
NULL,
CSR_CREATE_API_NUMBER(CSR_CONSOLE, ADD_CONSOLE_ALIAS),
RequestLength);
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status))
if (lpTarget) /* The target can be optional */
{
BaseSetLastNTError(Status);
RtlFreeHeap(GetProcessHeap(), 0, Request);
ConsoleAlias->TargetLength = (wcslen(lpTarget) + 1) * sizeof(WCHAR);
CapturedStrings++;
}
else
{
ConsoleAlias->TargetLength = 0;
}
/* Allocate a Capture Buffer */
CaptureBuffer = CsrAllocateCaptureBuffer(CapturedStrings,
ConsoleAlias->SourceLength +
ConsoleAlias->ExeLength +
ConsoleAlias->TargetLength);
if (CaptureBuffer == NULL)
{
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
/* Capture the strings */
CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpSource,
ConsoleAlias->SourceLength,
&ConsoleAlias->Source);
CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpExeName,
ConsoleAlias->ExeLength,
&ConsoleAlias->Exe);
if (lpTarget) /* The target can be optional */
{
CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpTarget,
ConsoleAlias->TargetLength,
&ConsoleAlias->Target);
}
else
{
ConsoleAlias->Target = NULL;
}
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
CaptureBuffer,
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepAddAlias),
sizeof(CSRSS_CONSOLE_ALIAS));
CsrFreeCaptureBuffer(CaptureBuffer);
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
{
BaseSetLastNTError(Status);
return FALSE;
}
RtlFreeHeap(GetProcessHeap(), 0, Request);
return TRUE;
}
@ -93,21 +117,21 @@ AddConsoleAliasA(LPCSTR lpSource,
BOOL bRetVal;
if (lpSource)
BasepAnsiStringToHeapUnicodeString(lpSource, (LPWSTR*) &lpSourceW);
BasepAnsiStringToHeapUnicodeString(lpSource, (LPWSTR*)&lpSourceW);
if (lpTarget)
BasepAnsiStringToHeapUnicodeString(lpTarget, (LPWSTR*) &lpTargetW);
BasepAnsiStringToHeapUnicodeString(lpTarget, (LPWSTR*)&lpTargetW);
if (lpExeName)
BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*) &lpExeNameW);
BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*)&lpExeNameW);
bRetVal = AddConsoleAliasW(lpSourceW, lpTargetW, lpExeNameW);
/* Clean up */
if (lpSourceW)
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpSourceW);
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpSourceW);
if (lpTargetW)
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpTargetW);
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpTargetW);
if (lpExeNameW)
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpExeNameW);
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpExeNameW);
return bRetVal;
}
@ -123,16 +147,12 @@ GetConsoleAliasW(LPWSTR lpSource,
DWORD TargetBufferLength,
LPWSTR lpExeName)
{
PCSR_API_MESSAGE Request;
PCSR_CAPTURE_BUFFER CaptureBuffer;
NTSTATUS Status;
ULONG Size;
ULONG ExeLength;
ULONG SourceLength;
ULONG RequestLength;
WCHAR * Ptr;
CONSOLE_API_MESSAGE ApiMessage;
PCSRSS_CONSOLE_ALIAS ConsoleAlias = &ApiMessage.Data.ConsoleAlias;
PCSR_CAPTURE_BUFFER CaptureBuffer;
DPRINT("GetConsoleAliasW entered lpSource %S lpExeName %S\n", lpSource, lpExeName);
DPRINT("GetConsoleAliasW entered with lpSource %S lpExeName %S\n", lpSource, lpExeName);
if (lpTargetBuffer == NULL)
{
@ -140,63 +160,61 @@ GetConsoleAliasW(LPWSTR lpSource,
return 0;
}
ExeLength = wcslen(lpExeName) + 1;
SourceLength = wcslen(lpSource) + 1;
/* Determine the needed sizes */
ConsoleAlias->SourceLength = (wcslen(lpSource ) + 1) * sizeof(WCHAR);
ConsoleAlias->ExeLength = (wcslen(lpExeName) + 1) * sizeof(WCHAR);
Size = (ExeLength + SourceLength) * sizeof(WCHAR);
ConsoleAlias->Target = NULL;
ConsoleAlias->TargetLength = TargetBufferLength;
RequestLength = Size + sizeof(CSR_API_MESSAGE);
Request = RtlAllocateHeap(GetProcessHeap(), 0, RequestLength);
if (Request == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
CaptureBuffer = CsrAllocateCaptureBuffer(1, TargetBufferLength);
/* Allocate a Capture Buffer */
CaptureBuffer = CsrAllocateCaptureBuffer(3, ConsoleAlias->SourceLength +
ConsoleAlias->ExeLength +
ConsoleAlias->TargetLength);
if (!CaptureBuffer)
{
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
RtlFreeHeap(GetProcessHeap(), 0, Request);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
Request->Data.GetConsoleAlias.TargetBuffer = NULL;
/* Capture the strings */
CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpSource,
ConsoleAlias->SourceLength,
&ConsoleAlias->Source);
CsrCaptureMessageBuffer(CaptureBuffer,
NULL,
TargetBufferLength,
(PVOID*)&Request->Data.GetConsoleAlias.TargetBuffer);
(PVOID)lpExeName,
ConsoleAlias->ExeLength,
&ConsoleAlias->Exe);
Request->Data.GetConsoleAlias.TargetBufferLength = TargetBufferLength;
/* Allocate space for the target buffer */
CsrAllocateMessagePointer(CaptureBuffer,
ConsoleAlias->TargetLength,
(PVOID*)&ConsoleAlias->Target);
Ptr = (LPWSTR)((ULONG_PTR)Request + sizeof(CSR_API_MESSAGE));
wcscpy(Ptr, lpSource);
Ptr += SourceLength;
wcscpy(Ptr, lpExeName);
Request->Data.GetConsoleAlias.ExeLength = ExeLength;
Request->Data.GetConsoleAlias.SourceLength = SourceLength;
Status = CsrClientCallServer(Request,
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
CaptureBuffer,
CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIAS),
sizeof(CSR_API_MESSAGE) + Size);
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status))
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAlias),
sizeof(CSRSS_CONSOLE_ALIAS));
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
{
RtlFreeHeap(GetProcessHeap(), 0, Request);
CsrFreeCaptureBuffer(CaptureBuffer);
BaseSetLastNTError(Status);
return 0;
}
wcscpy(lpTargetBuffer, Request->Data.GetConsoleAlias.TargetBuffer);
RtlFreeHeap(GetProcessHeap(), 0, Request);
/* Copy the returned target string into the user buffer */
// wcscpy(lpTargetBuffer, ConsoleAlias->Target);
memcpy(lpTargetBuffer,
ConsoleAlias->Target,
ConsoleAlias->TargetLength);
/* Release the capture buffer and exits */
CsrFreeCaptureBuffer(CaptureBuffer);
return Request->Data.GetConsoleAlias.BytesWritten;
return ConsoleAlias->TargetLength;
}
@ -267,6 +285,188 @@ GetConsoleAliasA(LPSTR lpSource,
}
/*
* @implemented
*/
DWORD
WINAPI
GetConsoleAliasesW(LPWSTR AliasBuffer,
DWORD AliasBufferLength,
LPWSTR ExeName)
{
NTSTATUS Status;
CONSOLE_API_MESSAGE ApiMessage;
PCSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAliases = &ApiMessage.Data.GetAllConsoleAliases;
PCSR_CAPTURE_BUFFER CaptureBuffer;
DPRINT("GetConsoleAliasesW entered\n");
/* Determine the needed sizes */
GetAllConsoleAliases->ExeLength = GetConsoleAliasesLengthW(ExeName);
if (GetAllConsoleAliases->ExeLength == 0 ||
GetAllConsoleAliases->ExeLength > AliasBufferLength)
{
return 0;
}
GetAllConsoleAliases->AliasesBufferLength = AliasBufferLength;
/* Allocate a Capture Buffer */
CaptureBuffer = CsrAllocateCaptureBuffer(2, GetAllConsoleAliases->ExeLength +
GetAllConsoleAliases->AliasesBufferLength);
if (!CaptureBuffer)
{
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
/* Capture the exe name and allocate space for the aliases buffer */
CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)ExeName,
GetAllConsoleAliases->ExeLength,
(PVOID*)&GetAllConsoleAliases->ExeName);
CsrAllocateMessagePointer(CaptureBuffer,
GetAllConsoleAliases->AliasesBufferLength,
(PVOID*)&GetAllConsoleAliases->AliasesBuffer);
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
CaptureBuffer,
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliases),
sizeof(CSRSS_GET_ALL_CONSOLE_ALIASES));
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
{
BaseSetLastNTError(Status);
return 0;
}
/* Copy the returned aliases string into the user buffer */
// wcscpy(AliasBuffer, GetAllConsoleAliases->AliasesBuffer);
memcpy(AliasBuffer,
GetAllConsoleAliases->AliasesBuffer,
GetAllConsoleAliases->AliasesBufferLength);
/* Release the capture buffer and exits */
CsrFreeCaptureBuffer(CaptureBuffer);
return GetAllConsoleAliases->AliasesBufferLength; // / sizeof(WCHAR); (original code)
}
/*
* @implemented
*/
DWORD
WINAPI
GetConsoleAliasesA(LPSTR AliasBuffer,
DWORD AliasBufferLength,
LPSTR ExeName)
{
DWORD dwRetVal = 0;
LPWSTR lpwExeName = NULL;
LPWSTR lpwAliasBuffer;
DPRINT("GetConsoleAliasesA entered\n");
if (ExeName)
BasepAnsiStringToHeapUnicodeString(ExeName, (LPWSTR*)&lpwExeName);
lpwAliasBuffer = HeapAlloc(GetProcessHeap(), 0, AliasBufferLength * sizeof(WCHAR));
dwRetVal = GetConsoleAliasesW(lpwAliasBuffer, AliasBufferLength * sizeof(WCHAR), lpwExeName);
if (lpwExeName)
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpwExeName);
if (dwRetVal)
dwRetVal = WideCharToMultiByte(CP_ACP, 0, lpwAliasBuffer, dwRetVal /**/ / sizeof(WCHAR) /**/, AliasBuffer, AliasBufferLength, NULL, NULL);
HeapFree(GetProcessHeap(), 0, lpwAliasBuffer);
return dwRetVal;
}
/*
* @implemented
*/
DWORD
WINAPI
GetConsoleAliasesLengthW(LPWSTR lpExeName)
{
NTSTATUS Status;
CONSOLE_API_MESSAGE ApiMessage;
PCSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH GetAllConsoleAliasesLength = &ApiMessage.Data.GetAllConsoleAliasesLength;
PCSR_CAPTURE_BUFFER CaptureBuffer;
DPRINT("GetConsoleAliasesLengthW entered\n");
if (lpExeName == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
GetAllConsoleAliasesLength->ExeLength = (wcslen(lpExeName) + 1) * sizeof(WCHAR);
GetAllConsoleAliasesLength->Length = 0;
/* Allocate a Capture Buffer */
CaptureBuffer = CsrAllocateCaptureBuffer(1, GetAllConsoleAliasesLength->ExeLength);
if (!CaptureBuffer)
{
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
/* Capture the exe name */
CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpExeName,
GetAllConsoleAliasesLength->ExeLength,
(PVOID)&GetAllConsoleAliasesLength->ExeName);
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
CaptureBuffer,
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasesLength),
sizeof(CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH));
CsrFreeCaptureBuffer(CaptureBuffer);
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
{
BaseSetLastNTError(Status);
return 0;
}
return GetAllConsoleAliasesLength->Length;
}
/*
* @implemented
*/
DWORD
WINAPI
GetConsoleAliasesLengthA(LPSTR lpExeName)
{
DWORD dwRetVal = 0;
LPWSTR lpExeNameW = NULL;
if (lpExeName)
BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*)&lpExeNameW);
dwRetVal = GetConsoleAliasesLengthW(lpExeNameW);
if (dwRetVal)
dwRetVal /= sizeof(WCHAR);
/* Clean up */
if (lpExeNameW)
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpExeNameW);
return dwRetVal;
}
/*
* @implemented
*/
@ -275,12 +475,14 @@ WINAPI
GetConsoleAliasExesW(LPWSTR lpExeNameBuffer,
DWORD ExeNameBufferLength)
{
CSR_API_MESSAGE Request;
PCSR_CAPTURE_BUFFER CaptureBuffer;
NTSTATUS Status;
CONSOLE_API_MESSAGE ApiMessage;
PCSRSS_GET_CONSOLE_ALIASES_EXES GetConsoleAliasesExes = &ApiMessage.Data.GetConsoleAliasesExes;
PCSR_CAPTURE_BUFFER CaptureBuffer;
DPRINT("GetConsoleAliasExesW entered\n");
/* Allocate a Capture Buffer */
CaptureBuffer = CsrAllocateCaptureBuffer(1, ExeNameBufferLength);
if (!CaptureBuffer)
{
@ -289,29 +491,33 @@ GetConsoleAliasExesW(LPWSTR lpExeNameBuffer,
return 0;
}
GetConsoleAliasesExes->Length = ExeNameBufferLength;
/* Allocate space for the exe name buffer */
CsrAllocateMessagePointer(CaptureBuffer,
ExeNameBufferLength,
(PVOID*)&Request.Data.GetConsoleAliasesExes.ExeNames);
Request.Data.GetConsoleAliasesExes.Length = ExeNameBufferLength;
(PVOID*)&GetConsoleAliasesExes->ExeNames);
Status = CsrClientCallServer(&Request,
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
CaptureBuffer,
CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIASES_EXES),
sizeof(CSR_API_MESSAGE));
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasExes),
sizeof(CSRSS_GET_CONSOLE_ALIASES_EXES));
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
{
BaseSetLastNTError(Status);
CsrFreeCaptureBuffer(CaptureBuffer);
BaseSetLastNTError(Status);
return 0;
}
/* Copy the returned target string into the user buffer */
memcpy(lpExeNameBuffer,
Request.Data.GetConsoleAliasesExes.ExeNames,
Request.Data.GetConsoleAliasesExes.BytesWritten);
GetConsoleAliasesExes->ExeNames,
GetConsoleAliasesExes->Length);
/* Release the capture buffer and exits */
CsrFreeCaptureBuffer(CaptureBuffer);
return Request.Data.GetConsoleAliasesExes.BytesWritten;
return GetConsoleAliasesExes->Length;
}
@ -347,25 +553,26 @@ DWORD
WINAPI
GetConsoleAliasExesLengthW(VOID)
{
CSR_API_MESSAGE Request;
NTSTATUS Status;
CONSOLE_API_MESSAGE ApiMessage;
PCSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH GetConsoleAliasesExesLength = &ApiMessage.Data.GetConsoleAliasesExesLength;
DPRINT("GetConsoleAliasExesLengthW entered\n");
Request.Data.GetConsoleAliasesExesLength.Length = 0;
GetConsoleAliasesExesLength->Length = 0;
Status = CsrClientCallServer(&Request,
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
NULL,
CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIASES_EXES_LENGTH),
sizeof(CSR_API_MESSAGE));
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasExesLength),
sizeof(CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH));
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
{
BaseSetLastNTError(Status);
return 0;
}
return Request.Data.GetConsoleAliasesExesLength.Length;
return GetConsoleAliasesExesLength->Length;
}
@ -388,130 +595,4 @@ GetConsoleAliasExesLengthA(VOID)
return dwLength;
}
/*
* @implemented
*/
DWORD
WINAPI
GetConsoleAliasesW(LPWSTR AliasBuffer,
DWORD AliasBufferLength,
LPWSTR ExeName)
{
CSR_API_MESSAGE Request;
NTSTATUS Status;
DWORD dwLength;
DPRINT("GetConsoleAliasesW entered\n");
dwLength = GetConsoleAliasesLengthW(ExeName);
if (!dwLength || dwLength > AliasBufferLength)
return 0;
Request.Data.GetAllConsoleAlias.AliasBuffer = AliasBuffer;
Request.Data.GetAllConsoleAlias.AliasBufferLength = AliasBufferLength;
Request.Data.GetAllConsoleAlias.lpExeName = ExeName;
Status = CsrClientCallServer(&Request,
NULL,
CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_ALL_CONSOLE_ALIASES),
sizeof(CSR_API_MESSAGE));
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
{
BaseSetLastNTError(Status);
return 0;
}
return Request.Data.GetAllConsoleAlias.BytesWritten / sizeof(WCHAR);
}
/*
* @implemented
*/
DWORD
WINAPI
GetConsoleAliasesA(LPSTR AliasBuffer,
DWORD AliasBufferLength,
LPSTR ExeName)
{
DWORD dwRetVal = 0;
LPWSTR lpwExeName = NULL;
LPWSTR lpwAliasBuffer;
DPRINT("GetConsoleAliasesA entered\n");
if (ExeName)
BasepAnsiStringToHeapUnicodeString(ExeName, (LPWSTR*) &lpwExeName);
lpwAliasBuffer = HeapAlloc(GetProcessHeap(), 0, AliasBufferLength * sizeof(WCHAR));
dwRetVal = GetConsoleAliasesW(lpwAliasBuffer, AliasBufferLength, lpwExeName);
if (lpwExeName)
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpwExeName);
if (dwRetVal)
dwRetVal = WideCharToMultiByte(CP_ACP, 0, lpwAliasBuffer, dwRetVal, AliasBuffer, AliasBufferLength, NULL, NULL);
HeapFree(GetProcessHeap(), 0, lpwAliasBuffer);
return dwRetVal;
}
/*
* @implemented
*/
DWORD
WINAPI
GetConsoleAliasesLengthW(LPWSTR lpExeName)
{
CSR_API_MESSAGE Request;
NTSTATUS Status;
DPRINT("GetConsoleAliasesLengthW entered\n");
Request.Data.GetAllConsoleAliasesLength.lpExeName = lpExeName;
Request.Data.GetAllConsoleAliasesLength.Length = 0;
Status = CsrClientCallServer(&Request,
NULL,
CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_ALL_CONSOLE_ALIASES_LENGTH),
sizeof(CSR_API_MESSAGE));
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
{
BaseSetLastNTError(Status);
return 0;
}
return Request.Data.GetAllConsoleAliasesLength.Length;
}
/*
* @implemented
*/
DWORD
WINAPI
GetConsoleAliasesLengthA(LPSTR lpExeName)
{
DWORD dwRetVal = 0;
LPWSTR lpExeNameW = NULL;
if (lpExeName)
BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*) &lpExeNameW);
dwRetVal = GetConsoleAliasesLengthW(lpExeNameW);
if (dwRetVal)
dwRetVal /= sizeof(WCHAR);
/* Clean up */
if (lpExeNameW)
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpExeNameW);
return dwRetVal;
}
/* EOF */

View file

@ -416,39 +416,41 @@ typedef struct
HICON WindowIcon;
} CSRSS_SET_CONSOLE_ICON, *PCSRSS_SET_CONSOLE_ICON;
typedef struct
{
ULONG SourceLength;
ULONG ExeLength;
ULONG TargetLength;
} CSRSS_ADD_CONSOLE_ALIAS, *PCSRSS_ADD_CONSOLE_ALIAS;
typedef struct
{
ULONG SourceLength;
ULONG ExeLength;
ULONG BytesWritten;
ULONG TargetBufferLength;
PVOID TargetBuffer;
} CSRSS_GET_CONSOLE_ALIAS, *PCSRSS_GET_CONSOLE_ALIAS;
ULONG SourceLength;
ULONG TargetLength; // Also used for storing the number of bytes written.
ULONG ExeLength;
LPWSTR Source;
LPWSTR Target;
LPWSTR Exe;
} CSRSS_CONSOLE_ALIAS, *PCSRSS_CONSOLE_ALIAS;
typedef struct
{
LPWSTR lpExeName;
DWORD BytesWritten;
DWORD AliasBufferLength;
LPWSTR AliasBuffer;
DWORD ExeLength;
DWORD AliasesBufferLength;
LPWSTR ExeName;
LPWSTR AliasesBuffer;
} CSRSS_GET_ALL_CONSOLE_ALIASES, *PCSRSS_GET_ALL_CONSOLE_ALIASES;
typedef struct
{
LPWSTR lpExeName;
DWORD Length;
DWORD ExeLength;
LPWSTR ExeName;
} CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH, *PCSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH;
typedef struct
{
DWORD BytesWritten;
DWORD Length;
LPWSTR ExeNames;
} CSRSS_GET_CONSOLE_ALIASES_EXES, *PCSRSS_GET_CONSOLE_ALIASES_EXES;
@ -458,28 +460,10 @@ typedef struct
DWORD Length;
} CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH, *PCSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH;
typedef struct
{
DWORD Event;
DWORD ProcessGroup;
} CSRSS_GENERATE_CTRL_EVENT, *PCSRSS_GENERATE_CTRL_EVENT;
typedef struct
{
HANDLE ConsoleHandle;
DWORD NumInputEvents;
} CSRSS_GET_NUM_INPUT_EVENTS, *PCSRSS_GET_NUM_INPUT_EVENTS;
typedef struct
{
HANDLE OutputHandle;
COORD Size;
} CSRSS_SET_SCREEN_BUFFER_SIZE, *PCSRSS_SET_SCREEN_BUFFER_SIZE;
typedef struct
{
CONSOLE_SELECTION_INFO Info;
} CSRSS_GET_CONSOLE_SELECTION_INFO, *PCSRSS_GET_CONSOLE_SELECTION_INFO;
typedef struct
{
@ -513,6 +497,38 @@ typedef struct
} CSRSS_GET_HISTORY_INFO, *PCSRSS_GET_HISTORY_INFO,
CSRSS_SET_HISTORY_INFO, *PCSRSS_SET_HISTORY_INFO;;
typedef struct
{
DWORD Event;
DWORD ProcessGroup;
} CSRSS_GENERATE_CTRL_EVENT, *PCSRSS_GENERATE_CTRL_EVENT;
typedef struct
{
HANDLE ConsoleHandle;
DWORD NumInputEvents;
} CSRSS_GET_NUM_INPUT_EVENTS, *PCSRSS_GET_NUM_INPUT_EVENTS;
typedef struct
{
HANDLE OutputHandle;
COORD Size;
} CSRSS_SET_SCREEN_BUFFER_SIZE, *PCSRSS_SET_SCREEN_BUFFER_SIZE;
typedef struct
{
CONSOLE_SELECTION_INFO Info;
} CSRSS_GET_CONSOLE_SELECTION_INFO, *PCSRSS_GET_CONSOLE_SELECTION_INFO;
typedef struct
{
UINT CodePage;
@ -580,22 +596,24 @@ typedef struct _CONSOLE_API_MESSAGE
CSRSS_SETGET_CONSOLE_HW_STATE ConsoleHardwareStateRequest;
CSRSS_GET_CONSOLE_WINDOW GetConsoleWindowRequest;
CSRSS_SET_CONSOLE_ICON SetConsoleIconRequest;
CSRSS_ADD_CONSOLE_ALIAS AddConsoleAlias;
CSRSS_GET_CONSOLE_ALIAS GetConsoleAlias;
CSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAlias;
CSRSS_CONSOLE_ALIAS ConsoleAlias;
CSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAliases;
CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH GetAllConsoleAliasesLength;
CSRSS_GET_CONSOLE_ALIASES_EXES GetConsoleAliasesExes;
CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH GetConsoleAliasesExesLength;
CSRSS_GENERATE_CTRL_EVENT GenerateCtrlEvent;
CSRSS_GET_NUM_INPUT_EVENTS GetNumInputEventsRequest;
CSRSS_SET_SCREEN_BUFFER_SIZE SetScreenBufferSize;
CSRSS_GET_CONSOLE_SELECTION_INFO GetConsoleSelectionInfo;
CSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength;
CSRSS_GET_COMMAND_HISTORY GetCommandHistory;
CSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength;
CSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory;
CSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands;
CSRSS_GET_HISTORY_INFO GetHistoryInfo;
CSRSS_SET_HISTORY_INFO SetHistoryInfo;
CSRSS_GENERATE_CTRL_EVENT GenerateCtrlEvent;
CSRSS_GET_NUM_INPUT_EVENTS GetNumInputEventsRequest;
CSRSS_SET_SCREEN_BUFFER_SIZE SetScreenBufferSize;
CSRSS_GET_CONSOLE_SELECTION_INFO GetConsoleSelectionInfo;
CSRSS_GET_CONSOLE_CP GetConsoleCodePage;
CSRSS_SET_CONSOLE_CP SetConsoleCodePage;
CSRSS_GET_CONSOLE_OUTPUT_CP GetConsoleOutputCodePage;

View file

@ -7,7 +7,7 @@
* Johannes Anderwald
*/
/* INCLUDES ******************************************************************/
/* INCLUDES *******************************************************************/
#include "consrv.h"
#include "conio.h"
@ -16,22 +16,25 @@
#include <debug.h>
/* TYPES **********************************************************************/
typedef struct tagALIAS_ENTRY
{
LPCWSTR lpSource;
LPCWSTR lpTarget;
struct tagALIAS_ENTRY * Next;
struct tagALIAS_ENTRY* Next;
} ALIAS_ENTRY, *PALIAS_ENTRY;
typedef struct tagALIAS_HEADER
{
LPCWSTR lpExeName;
PALIAS_ENTRY Data;
struct tagALIAS_HEADER * Next;
struct tagALIAS_HEADER* Next;
} ALIAS_HEADER, *PALIAS_HEADER;
/* PRIVATE FUNCTIONS **********************************************************/
static
PALIAS_HEADER
IntFindAliasHeader(PALIAS_HEADER RootHeader, LPCWSTR lpExeName)
@ -99,7 +102,7 @@ IntGetAliasEntry(PALIAS_HEADER Header, LPCWSTR lpSrcName)
while(RootHeader)
{
INT diff;
DPRINT("IntGetAliasEntry>lpSource %S\n", RootHeader->lpSource);
DPRINT("IntGetAliasEntry->lpSource %S\n", RootHeader->lpSource);
diff = _wcsicmp(RootHeader->lpSource, lpSrcName);
if (!diff)
return RootHeader;
@ -112,7 +115,6 @@ IntGetAliasEntry(PALIAS_HEADER Header, LPCWSTR lpSrcName)
return NULL;
}
VOID
IntInsertAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY NewEntry)
{
@ -218,6 +220,7 @@ IntGetAllConsoleAliasesLength(PALIAS_HEADER Header)
}
return 0;
}
UINT
IntGetAllConsoleAliases(PALIAS_HEADER Header, LPWSTR TargetBuffer, UINT TargetBufferLength)
{
@ -244,6 +247,7 @@ IntGetAllConsoleAliases(PALIAS_HEADER Header, LPWSTR TargetBuffer, UINT TargetBu
TargetBuffer[Offset] = L'\0';
return Offset * sizeof(WCHAR);
}
VOID
IntDeleteAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY Entry)
{
@ -261,11 +265,13 @@ IntDeleteAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY Entry)
LastLink = &CurEntry->Next;
}
}
VOID
IntDeleteAllAliases(PALIAS_HEADER RootHeader)
{
PALIAS_HEADER Header, NextHeader;
PALIAS_ENTRY Entry, NextEntry;
for (Header = RootHeader; Header; Header = NextHeader)
{
NextHeader = Header->Next;
@ -278,33 +284,47 @@ IntDeleteAllAliases(PALIAS_HEADER RootHeader)
}
}
/* PUBLIC SERVER APIS *********************************************************/
CSR_API(SrvAddConsoleAlias)
{
PCSRSS_ADD_CONSOLE_ALIAS AddConsoleAlias = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.AddConsoleAlias;
PCSRSS_CONSOLE_ALIAS ConsoleAlias = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleAlias;
PCSRSS_CONSOLE Console;
PALIAS_HEADER Header;
PALIAS_ENTRY Entry;
WCHAR * lpExeName;
WCHAR * lpSource;
WCHAR * lpTarget;
//ULONG TotalLength;
//WCHAR * Ptr;
LPWSTR lpSource, lpTarget, lpExeName;
//TotalLength = AddConsoleAlias->SourceLength + AddConsoleAlias->ExeLength + AddConsoleAlias->TargetLength;
//Ptr = (WCHAR*)((ULONG_PTR)ApiMessage + sizeof(CSR_API_MESSAGE));
DPRINT("SrvAddConsoleAlias entered ApiMessage %p\n", ApiMessage);
lpSource = (WCHAR*)((ULONG_PTR)ApiMessage + sizeof(CSR_API_MESSAGE));
lpExeName = (WCHAR*)((ULONG_PTR)ApiMessage + sizeof(CSR_API_MESSAGE) + AddConsoleAlias->SourceLength * sizeof(WCHAR));
lpTarget = (AddConsoleAlias->TargetLength != 0 ? lpExeName + AddConsoleAlias->ExeLength : NULL);
if ( !CsrValidateMessageBuffer(ApiMessage,
&ConsoleAlias->Source,
ConsoleAlias->SourceLength,
sizeof(BYTE)) ||
!CsrValidateMessageBuffer(ApiMessage,
&ConsoleAlias->Target,
ConsoleAlias->TargetLength,
sizeof(BYTE)) ||
!CsrValidateMessageBuffer(ApiMessage,
&ConsoleAlias->Exe,
ConsoleAlias->ExeLength,
sizeof(BYTE)) )
{
return STATUS_INVALID_PARAMETER;
}
DPRINT("SrvAddConsoleAlias entered ApiMessage %p lpSource %p lpExeName %p lpTarget %p\n", ApiMessage, lpSource, lpExeName, lpTarget);
lpSource = ConsoleAlias->Source;
lpTarget = (ConsoleAlias->TargetLength != 0 ? ConsoleAlias->Target : NULL);
lpExeName = ConsoleAlias->Exe;
DPRINT("SrvAddConsoleAlias lpSource %p lpExeName %p lpTarget %p\n", lpSource, lpExeName, lpTarget);
if (lpExeName == NULL || lpSource == NULL)
{
return STATUS_INVALID_PARAMETER;
}
ApiMessage->Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console);
ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
@ -322,7 +342,7 @@ CSR_API(SrvAddConsoleAlias)
IntInsertAliasHeader(&Console->Aliases, Header);
}
if (lpTarget == NULL) // delete the entry
if (lpTarget == NULL) // Delete the entry
{
Entry = IntGetAliasEntry(Header, lpSource);
if (Entry)
@ -353,30 +373,45 @@ CSR_API(SrvAddConsoleAlias)
CSR_API(SrvGetConsoleAlias)
{
PCSRSS_GET_CONSOLE_ALIAS GetConsoleAlias = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetConsoleAlias;
PCSRSS_CONSOLE_ALIAS ConsoleAlias = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleAlias;
PCSRSS_CONSOLE Console;
PALIAS_HEADER Header;
PALIAS_ENTRY Entry;
UINT Length;
WCHAR * lpExeName;
WCHAR * lpSource;
WCHAR * lpTarget;
LPWSTR lpSource, lpTarget, lpExeName;
lpSource = (LPWSTR)((ULONG_PTR)ApiMessage + sizeof(CSR_API_MESSAGE));
lpExeName = lpSource + GetConsoleAlias->SourceLength;
lpTarget = GetConsoleAlias->TargetBuffer;
DPRINT("SrvGetConsoleAlias entered ApiMessage %p\n", ApiMessage);
DPRINT("SrvGetConsoleAlias entered lpExeName %p lpSource %p TargetBuffer %p TargetBufferLength %u\n",
lpExeName, lpSource, lpTarget, GetConsoleAlias->TargetBufferLength);
if (GetConsoleAlias->ExeLength == 0 || lpTarget == NULL ||
GetConsoleAlias->TargetBufferLength == 0 || GetConsoleAlias->SourceLength == 0)
if ( !CsrValidateMessageBuffer(ApiMessage,
&ConsoleAlias->Source,
ConsoleAlias->SourceLength,
sizeof(BYTE)) ||
!CsrValidateMessageBuffer(ApiMessage,
&ConsoleAlias->Target,
ConsoleAlias->TargetLength,
sizeof(BYTE)) ||
!CsrValidateMessageBuffer(ApiMessage,
&ConsoleAlias->Exe,
ConsoleAlias->ExeLength,
sizeof(BYTE)) )
{
return STATUS_INVALID_PARAMETER;
}
ApiMessage->Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console);
lpSource = ConsoleAlias->Source;
lpTarget = ConsoleAlias->Target;
lpExeName = ConsoleAlias->Exe;
DPRINT("SrvGetConsoleAlias lpExeName %p lpSource %p TargetBuffer %p TargetLength %u\n",
lpExeName, lpSource, lpTarget, ConsoleAlias->TargetLength);
if (ConsoleAlias->ExeLength == 0 || lpTarget == NULL ||
ConsoleAlias->TargetLength == 0 || ConsoleAlias->SourceLength == 0)
{
return STATUS_INVALID_PARAMETER;
}
ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
@ -396,71 +431,87 @@ CSR_API(SrvGetConsoleAlias)
return STATUS_INVALID_PARAMETER;
}
Length = (wcslen(Entry->lpTarget)+1) * sizeof(WCHAR);
if (Length > GetConsoleAlias->TargetBufferLength)
Length = (wcslen(Entry->lpTarget) + 1) * sizeof(WCHAR);
if (Length > ConsoleAlias->TargetLength)
{
ConioUnlockConsole(Console);
return STATUS_BUFFER_TOO_SMALL;
}
/*
if (!Win32CsrValidateBuffer(CsrGetClientThread()->Process, lpTarget,
GetConsoleAlias->TargetBufferLength, 1))
ConsoleAlias->TargetLength, 1))
{
ConioUnlockConsole(Console);
return STATUS_ACCESS_VIOLATION;
}
*/
wcscpy(lpTarget, Entry->lpTarget);
GetConsoleAlias->BytesWritten = Length;
ConsoleAlias->TargetLength = Length;
ConioUnlockConsole(Console);
return STATUS_SUCCESS;
}
CSR_API(SrvGetConsoleAliases)
{
PCSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAlias = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAllConsoleAlias;
PCSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAliases = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAllConsoleAliases;
PCSRSS_CONSOLE Console;
ULONG BytesWritten;
PALIAS_HEADER Header;
if (GetAllConsoleAlias->lpExeName == NULL)
if ( !CsrValidateMessageBuffer(ApiMessage,
(PVOID)&GetAllConsoleAliases->ExeName,
GetAllConsoleAliases->ExeLength,
sizeof(BYTE)) ||
!CsrValidateMessageBuffer(ApiMessage,
(PVOID)&GetAllConsoleAliases->AliasesBuffer,
GetAllConsoleAliases->AliasesBufferLength,
sizeof(BYTE)) )
{
return STATUS_INVALID_PARAMETER;
}
ApiMessage->Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console);
if (GetAllConsoleAliases->ExeName == NULL)
{
return STATUS_INVALID_PARAMETER;
}
ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
}
Header = IntFindAliasHeader(Console->Aliases, GetAllConsoleAlias->lpExeName);
Header = IntFindAliasHeader(Console->Aliases, GetAllConsoleAliases->ExeName);
if (!Header)
{
ConioUnlockConsole(Console);
return STATUS_INVALID_PARAMETER;
}
if (IntGetAllConsoleAliasesLength(Header) > GetAllConsoleAlias->AliasBufferLength)
if (IntGetAllConsoleAliasesLength(Header) > GetAllConsoleAliases->AliasesBufferLength)
{
ConioUnlockConsole(Console);
return STATUS_BUFFER_OVERFLOW;
}
/*
if (!Win32CsrValidateBuffer(CsrGetClientThread()->Process,
GetAllConsoleAlias->AliasBuffer,
GetAllConsoleAlias->AliasBufferLength,
GetAllConsoleAliases->AliasesBuffer,
GetAllConsoleAliases->AliasesBufferLength,
1))
{
ConioUnlockConsole(Console);
return STATUS_ACCESS_VIOLATION;
}
*/
BytesWritten = IntGetAllConsoleAliases(Header,
GetAllConsoleAlias->AliasBuffer,
GetAllConsoleAlias->AliasBufferLength);
GetAllConsoleAliases->AliasesBuffer,
GetAllConsoleAliases->AliasesBufferLength);
GetAllConsoleAlias->BytesWritten = BytesWritten;
GetAllConsoleAliases->AliasesBufferLength = BytesWritten;
ConioUnlockConsole(Console);
return STATUS_SUCCESS;
}
@ -472,18 +523,26 @@ CSR_API(SrvGetConsoleAliasesLength)
PALIAS_HEADER Header;
UINT Length;
if (GetAllConsoleAliasesLength->lpExeName == NULL)
if (!CsrValidateMessageBuffer(ApiMessage,
(PVOID)&GetAllConsoleAliasesLength->ExeName,
GetAllConsoleAliasesLength->ExeLength,
sizeof(BYTE)))
{
return STATUS_INVALID_PARAMETER;
}
ApiMessage->Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console);
if (GetAllConsoleAliasesLength->ExeName == NULL)
{
return STATUS_INVALID_PARAMETER;
}
ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
}
Header = IntFindAliasHeader(Console->Aliases, GetAllConsoleAliasesLength->lpExeName);
Header = IntFindAliasHeader(Console->Aliases, GetAllConsoleAliasesLength->ExeName);
if (!Header)
{
ConioUnlockConsole(Console);
@ -505,7 +564,15 @@ CSR_API(SrvGetConsoleAliasExes)
DPRINT("SrvGetConsoleAliasExes entered\n");
ApiMessage->Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console);
if (!CsrValidateMessageBuffer(ApiMessage,
(PVOID)&GetConsoleAliasesExes->ExeNames,
GetConsoleAliasesExes->Length,
sizeof(BYTE)))
{
return STATUS_INVALID_PARAMETER;
}
ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
@ -525,6 +592,7 @@ CSR_API(SrvGetConsoleAliasExes)
return STATUS_INVALID_PARAMETER;
}
/*
if (!Win32CsrValidateBuffer(CsrGetClientThread()->Process,
GetConsoleAliasesExes->ExeNames,
GetConsoleAliasesExes->Length,
@ -533,12 +601,13 @@ CSR_API(SrvGetConsoleAliasExes)
ConioUnlockConsole(Console);
return STATUS_ACCESS_VIOLATION;
}
*/
BytesWritten = IntGetConsoleAliasesExes(Console->Aliases,
GetConsoleAliasesExes->ExeNames,
GetConsoleAliasesExes->Length);
GetConsoleAliasesExes->BytesWritten = BytesWritten;
GetConsoleAliasesExes->Length = BytesWritten;
ConioUnlockConsole(Console);
return STATUS_SUCCESS;
}
@ -549,7 +618,7 @@ CSR_API(SrvGetConsoleAliasExesLength)
PCSRSS_CONSOLE Console;
DPRINT("SrvGetConsoleAliasExesLength entered\n");
ApiMessage->Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console);
ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
if (NT_SUCCESS(ApiMessage->Status))
{
GetConsoleAliasesExesLength->Length = IntGetConsoleAliasesExesLength(Console->Aliases);
@ -557,3 +626,5 @@ CSR_API(SrvGetConsoleAliasExesLength)
}
return ApiMessage->Status;
}
/* EOF */