mirror of
https://github.com/reactos/reactos.git
synced 2024-10-20 08:01:05 +00:00
[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:
parent
d6b0ad349a
commit
1ccafa6cae
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
* FILE: dll/win32/kernel32/client/console/console.c
|
* FILE: dll/win32/kernel32/client/console/alias.c
|
||||||
* PURPOSE: Win32 server console functions
|
* PURPOSE: Win32 Console Client Alias support functions
|
||||||
* PROGRAMMERS: David Welch (welch@cwcom.net) (welch@mcmail.com)
|
* PROGRAMMERS: David Welch (welch@cwcom.net) (welch@mcmail.com)
|
||||||
* Christoph von Wittich (christoph_vw@reactos.org)
|
* Christoph von Wittich (christoph_vw@reactos.org)
|
||||||
* Johannes Anderwald (janderwald@reactos.org)
|
* Johannes Anderwald (janderwald@reactos.org)
|
||||||
|
@ -15,10 +15,11 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL
|
BOOL
|
||||||
WINAPI
|
WINAPI
|
||||||
|
@ -26,54 +27,77 @@ AddConsoleAliasW(LPCWSTR lpSource,
|
||||||
LPCWSTR lpTarget,
|
LPCWSTR lpTarget,
|
||||||
LPCWSTR lpExeName)
|
LPCWSTR lpExeName)
|
||||||
{
|
{
|
||||||
PCSR_API_MESSAGE Request;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG SourceLength;
|
CONSOLE_API_MESSAGE ApiMessage;
|
||||||
ULONG TargetLength = 0;
|
PCSRSS_CONSOLE_ALIAS ConsoleAlias = &ApiMessage.Data.ConsoleAlias;
|
||||||
ULONG ExeLength;
|
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||||
ULONG Size;
|
ULONG CapturedStrings;
|
||||||
ULONG RequestLength;
|
|
||||||
WCHAR * Ptr;
|
|
||||||
|
|
||||||
DPRINT("AddConsoleAliasW enterd with lpSource %S lpTarget %S lpExeName %S\n", lpSource, lpTarget, lpExeName);
|
DPRINT("AddConsoleAliasW enterd with lpSource %S lpTarget %S lpExeName %S\n", lpSource, lpTarget, lpExeName);
|
||||||
|
|
||||||
ExeLength = wcslen(lpExeName) + 1;
|
/* Determine the needed sizes */
|
||||||
SourceLength = wcslen(lpSource)+ 1;
|
ConsoleAlias->SourceLength = (wcslen(lpSource ) + 1) * sizeof(WCHAR);
|
||||||
if (lpTarget)
|
ConsoleAlias->ExeLength = (wcslen(lpExeName) + 1) * sizeof(WCHAR);
|
||||||
TargetLength = wcslen(lpTarget) + 1;
|
CapturedStrings = 2;
|
||||||
|
|
||||||
Size = (ExeLength + SourceLength + TargetLength) * sizeof(WCHAR);
|
if (lpTarget) /* The target can be optional */
|
||||||
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))
|
|
||||||
{
|
{
|
||||||
BaseSetLastNTError(Status);
|
ConsoleAlias->TargetLength = (wcslen(lpTarget) + 1) * sizeof(WCHAR);
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, Request);
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, Request);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,21 +117,21 @@ AddConsoleAliasA(LPCSTR lpSource,
|
||||||
BOOL bRetVal;
|
BOOL bRetVal;
|
||||||
|
|
||||||
if (lpSource)
|
if (lpSource)
|
||||||
BasepAnsiStringToHeapUnicodeString(lpSource, (LPWSTR*) &lpSourceW);
|
BasepAnsiStringToHeapUnicodeString(lpSource, (LPWSTR*)&lpSourceW);
|
||||||
if (lpTarget)
|
if (lpTarget)
|
||||||
BasepAnsiStringToHeapUnicodeString(lpTarget, (LPWSTR*) &lpTargetW);
|
BasepAnsiStringToHeapUnicodeString(lpTarget, (LPWSTR*)&lpTargetW);
|
||||||
if (lpExeName)
|
if (lpExeName)
|
||||||
BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*) &lpExeNameW);
|
BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*)&lpExeNameW);
|
||||||
|
|
||||||
bRetVal = AddConsoleAliasW(lpSourceW, lpTargetW, lpExeNameW);
|
bRetVal = AddConsoleAliasW(lpSourceW, lpTargetW, lpExeNameW);
|
||||||
|
|
||||||
/* Clean up */
|
/* Clean up */
|
||||||
if (lpSourceW)
|
if (lpSourceW)
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpSourceW);
|
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpSourceW);
|
||||||
if (lpTargetW)
|
if (lpTargetW)
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpTargetW);
|
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpTargetW);
|
||||||
if (lpExeNameW)
|
if (lpExeNameW)
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpExeNameW);
|
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpExeNameW);
|
||||||
|
|
||||||
return bRetVal;
|
return bRetVal;
|
||||||
}
|
}
|
||||||
|
@ -123,16 +147,12 @@ GetConsoleAliasW(LPWSTR lpSource,
|
||||||
DWORD TargetBufferLength,
|
DWORD TargetBufferLength,
|
||||||
LPWSTR lpExeName)
|
LPWSTR lpExeName)
|
||||||
{
|
{
|
||||||
PCSR_API_MESSAGE Request;
|
|
||||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG Size;
|
CONSOLE_API_MESSAGE ApiMessage;
|
||||||
ULONG ExeLength;
|
PCSRSS_CONSOLE_ALIAS ConsoleAlias = &ApiMessage.Data.ConsoleAlias;
|
||||||
ULONG SourceLength;
|
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||||
ULONG RequestLength;
|
|
||||||
WCHAR * Ptr;
|
|
||||||
|
|
||||||
DPRINT("GetConsoleAliasW entered lpSource %S lpExeName %S\n", lpSource, lpExeName);
|
DPRINT("GetConsoleAliasW entered with lpSource %S lpExeName %S\n", lpSource, lpExeName);
|
||||||
|
|
||||||
if (lpTargetBuffer == NULL)
|
if (lpTargetBuffer == NULL)
|
||||||
{
|
{
|
||||||
|
@ -140,63 +160,61 @@ GetConsoleAliasW(LPWSTR lpSource,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExeLength = wcslen(lpExeName) + 1;
|
/* Determine the needed sizes */
|
||||||
SourceLength = wcslen(lpSource) + 1;
|
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);
|
/* Allocate a Capture Buffer */
|
||||||
Request = RtlAllocateHeap(GetProcessHeap(), 0, RequestLength);
|
CaptureBuffer = CsrAllocateCaptureBuffer(3, ConsoleAlias->SourceLength +
|
||||||
if (Request == NULL)
|
ConsoleAlias->ExeLength +
|
||||||
{
|
ConsoleAlias->TargetLength);
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CaptureBuffer = CsrAllocateCaptureBuffer(1, TargetBufferLength);
|
|
||||||
if (!CaptureBuffer)
|
if (!CaptureBuffer)
|
||||||
{
|
{
|
||||||
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, Request);
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Request->Data.GetConsoleAlias.TargetBuffer = NULL;
|
/* Capture the strings */
|
||||||
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||||
|
(PVOID)lpSource,
|
||||||
|
ConsoleAlias->SourceLength,
|
||||||
|
&ConsoleAlias->Source);
|
||||||
|
|
||||||
CsrCaptureMessageBuffer(CaptureBuffer,
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||||
NULL,
|
(PVOID)lpExeName,
|
||||||
TargetBufferLength,
|
ConsoleAlias->ExeLength,
|
||||||
(PVOID*)&Request->Data.GetConsoleAlias.TargetBuffer);
|
&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));
|
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||||
wcscpy(Ptr, lpSource);
|
|
||||||
Ptr += SourceLength;
|
|
||||||
wcscpy(Ptr, lpExeName);
|
|
||||||
|
|
||||||
Request->Data.GetConsoleAlias.ExeLength = ExeLength;
|
|
||||||
Request->Data.GetConsoleAlias.SourceLength = SourceLength;
|
|
||||||
|
|
||||||
Status = CsrClientCallServer(Request,
|
|
||||||
CaptureBuffer,
|
CaptureBuffer,
|
||||||
CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIAS),
|
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAlias),
|
||||||
sizeof(CSR_API_MESSAGE) + Size);
|
sizeof(CSRSS_CONSOLE_ALIAS));
|
||||||
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
|
||||||
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status))
|
|
||||||
{
|
{
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, Request);
|
|
||||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||||
BaseSetLastNTError(Status);
|
BaseSetLastNTError(Status);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wcscpy(lpTargetBuffer, Request->Data.GetConsoleAlias.TargetBuffer);
|
/* Copy the returned target string into the user buffer */
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, Request);
|
// wcscpy(lpTargetBuffer, ConsoleAlias->Target);
|
||||||
|
memcpy(lpTargetBuffer,
|
||||||
|
ConsoleAlias->Target,
|
||||||
|
ConsoleAlias->TargetLength);
|
||||||
|
|
||||||
|
/* Release the capture buffer and exits */
|
||||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
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
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -275,12 +475,14 @@ WINAPI
|
||||||
GetConsoleAliasExesW(LPWSTR lpExeNameBuffer,
|
GetConsoleAliasExesW(LPWSTR lpExeNameBuffer,
|
||||||
DWORD ExeNameBufferLength)
|
DWORD ExeNameBufferLength)
|
||||||
{
|
{
|
||||||
CSR_API_MESSAGE Request;
|
|
||||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
CONSOLE_API_MESSAGE ApiMessage;
|
||||||
|
PCSRSS_GET_CONSOLE_ALIASES_EXES GetConsoleAliasesExes = &ApiMessage.Data.GetConsoleAliasesExes;
|
||||||
|
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||||
|
|
||||||
DPRINT("GetConsoleAliasExesW entered\n");
|
DPRINT("GetConsoleAliasExesW entered\n");
|
||||||
|
|
||||||
|
/* Allocate a Capture Buffer */
|
||||||
CaptureBuffer = CsrAllocateCaptureBuffer(1, ExeNameBufferLength);
|
CaptureBuffer = CsrAllocateCaptureBuffer(1, ExeNameBufferLength);
|
||||||
if (!CaptureBuffer)
|
if (!CaptureBuffer)
|
||||||
{
|
{
|
||||||
|
@ -289,29 +491,33 @@ GetConsoleAliasExesW(LPWSTR lpExeNameBuffer,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GetConsoleAliasesExes->Length = ExeNameBufferLength;
|
||||||
|
|
||||||
|
/* Allocate space for the exe name buffer */
|
||||||
CsrAllocateMessagePointer(CaptureBuffer,
|
CsrAllocateMessagePointer(CaptureBuffer,
|
||||||
ExeNameBufferLength,
|
ExeNameBufferLength,
|
||||||
(PVOID*)&Request.Data.GetConsoleAliasesExes.ExeNames);
|
(PVOID*)&GetConsoleAliasesExes->ExeNames);
|
||||||
Request.Data.GetConsoleAliasesExes.Length = ExeNameBufferLength;
|
|
||||||
|
|
||||||
Status = CsrClientCallServer(&Request,
|
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||||
CaptureBuffer,
|
CaptureBuffer,
|
||||||
CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIASES_EXES),
|
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasExes),
|
||||||
sizeof(CSR_API_MESSAGE));
|
sizeof(CSRSS_GET_CONSOLE_ALIASES_EXES));
|
||||||
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
|
||||||
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
|
|
||||||
{
|
{
|
||||||
BaseSetLastNTError(Status);
|
|
||||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||||
|
BaseSetLastNTError(Status);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Copy the returned target string into the user buffer */
|
||||||
memcpy(lpExeNameBuffer,
|
memcpy(lpExeNameBuffer,
|
||||||
Request.Data.GetConsoleAliasesExes.ExeNames,
|
GetConsoleAliasesExes->ExeNames,
|
||||||
Request.Data.GetConsoleAliasesExes.BytesWritten);
|
GetConsoleAliasesExes->Length);
|
||||||
|
|
||||||
|
/* Release the capture buffer and exits */
|
||||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||||
return Request.Data.GetConsoleAliasesExes.BytesWritten;
|
|
||||||
|
return GetConsoleAliasesExes->Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -347,25 +553,26 @@ DWORD
|
||||||
WINAPI
|
WINAPI
|
||||||
GetConsoleAliasExesLengthW(VOID)
|
GetConsoleAliasExesLengthW(VOID)
|
||||||
{
|
{
|
||||||
CSR_API_MESSAGE Request;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
CONSOLE_API_MESSAGE ApiMessage;
|
||||||
|
PCSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH GetConsoleAliasesExesLength = &ApiMessage.Data.GetConsoleAliasesExesLength;
|
||||||
|
|
||||||
DPRINT("GetConsoleAliasExesLengthW entered\n");
|
DPRINT("GetConsoleAliasExesLengthW entered\n");
|
||||||
|
|
||||||
Request.Data.GetConsoleAliasesExesLength.Length = 0;
|
GetConsoleAliasesExesLength->Length = 0;
|
||||||
|
|
||||||
Status = CsrClientCallServer(&Request,
|
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||||
NULL,
|
NULL,
|
||||||
CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIASES_EXES_LENGTH),
|
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasExesLength),
|
||||||
sizeof(CSR_API_MESSAGE));
|
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);
|
BaseSetLastNTError(Status);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Request.Data.GetConsoleAliasesExesLength.Length;
|
return GetConsoleAliasesExesLength->Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -388,130 +595,4 @@ GetConsoleAliasExesLengthA(VOID)
|
||||||
return dwLength;
|
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 */
|
/* EOF */
|
||||||
|
|
|
@ -416,39 +416,41 @@ typedef struct
|
||||||
HICON WindowIcon;
|
HICON WindowIcon;
|
||||||
} CSRSS_SET_CONSOLE_ICON, *PCSRSS_SET_CONSOLE_ICON;
|
} 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
|
typedef struct
|
||||||
{
|
{
|
||||||
ULONG SourceLength;
|
ULONG SourceLength;
|
||||||
|
ULONG TargetLength; // Also used for storing the number of bytes written.
|
||||||
ULONG ExeLength;
|
ULONG ExeLength;
|
||||||
ULONG BytesWritten;
|
LPWSTR Source;
|
||||||
ULONG TargetBufferLength;
|
LPWSTR Target;
|
||||||
PVOID TargetBuffer;
|
LPWSTR Exe;
|
||||||
} CSRSS_GET_CONSOLE_ALIAS, *PCSRSS_GET_CONSOLE_ALIAS;
|
} CSRSS_CONSOLE_ALIAS, *PCSRSS_CONSOLE_ALIAS;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
LPWSTR lpExeName;
|
DWORD ExeLength;
|
||||||
DWORD BytesWritten;
|
DWORD AliasesBufferLength;
|
||||||
DWORD AliasBufferLength;
|
LPWSTR ExeName;
|
||||||
LPWSTR AliasBuffer;
|
LPWSTR AliasesBuffer;
|
||||||
} CSRSS_GET_ALL_CONSOLE_ALIASES, *PCSRSS_GET_ALL_CONSOLE_ALIASES;
|
} CSRSS_GET_ALL_CONSOLE_ALIASES, *PCSRSS_GET_ALL_CONSOLE_ALIASES;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
LPWSTR lpExeName;
|
|
||||||
DWORD Length;
|
DWORD Length;
|
||||||
|
DWORD ExeLength;
|
||||||
|
LPWSTR ExeName;
|
||||||
} CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH, *PCSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH;
|
} CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH, *PCSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
DWORD BytesWritten;
|
|
||||||
DWORD Length;
|
DWORD Length;
|
||||||
LPWSTR ExeNames;
|
LPWSTR ExeNames;
|
||||||
} CSRSS_GET_CONSOLE_ALIASES_EXES, *PCSRSS_GET_CONSOLE_ALIASES_EXES;
|
} CSRSS_GET_CONSOLE_ALIASES_EXES, *PCSRSS_GET_CONSOLE_ALIASES_EXES;
|
||||||
|
@ -458,28 +460,10 @@ typedef struct
|
||||||
DWORD Length;
|
DWORD Length;
|
||||||
} CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH, *PCSRSS_GET_CONSOLE_ALIASES_EXES_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
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -513,6 +497,38 @@ typedef struct
|
||||||
} CSRSS_GET_HISTORY_INFO, *PCSRSS_GET_HISTORY_INFO,
|
} CSRSS_GET_HISTORY_INFO, *PCSRSS_GET_HISTORY_INFO,
|
||||||
CSRSS_SET_HISTORY_INFO, *PCSRSS_SET_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
|
typedef struct
|
||||||
{
|
{
|
||||||
UINT CodePage;
|
UINT CodePage;
|
||||||
|
@ -580,22 +596,24 @@ typedef struct _CONSOLE_API_MESSAGE
|
||||||
CSRSS_SETGET_CONSOLE_HW_STATE ConsoleHardwareStateRequest;
|
CSRSS_SETGET_CONSOLE_HW_STATE ConsoleHardwareStateRequest;
|
||||||
CSRSS_GET_CONSOLE_WINDOW GetConsoleWindowRequest;
|
CSRSS_GET_CONSOLE_WINDOW GetConsoleWindowRequest;
|
||||||
CSRSS_SET_CONSOLE_ICON SetConsoleIconRequest;
|
CSRSS_SET_CONSOLE_ICON SetConsoleIconRequest;
|
||||||
CSRSS_ADD_CONSOLE_ALIAS AddConsoleAlias;
|
|
||||||
CSRSS_GET_CONSOLE_ALIAS GetConsoleAlias;
|
CSRSS_CONSOLE_ALIAS ConsoleAlias;
|
||||||
CSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAlias;
|
CSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAliases;
|
||||||
CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH GetAllConsoleAliasesLength;
|
CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH GetAllConsoleAliasesLength;
|
||||||
CSRSS_GET_CONSOLE_ALIASES_EXES GetConsoleAliasesExes;
|
CSRSS_GET_CONSOLE_ALIASES_EXES GetConsoleAliasesExes;
|
||||||
CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH GetConsoleAliasesExesLength;
|
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 GetCommandHistory;
|
||||||
|
CSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength;
|
||||||
CSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory;
|
CSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory;
|
||||||
CSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands;
|
CSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands;
|
||||||
CSRSS_GET_HISTORY_INFO GetHistoryInfo;
|
CSRSS_GET_HISTORY_INFO GetHistoryInfo;
|
||||||
CSRSS_SET_HISTORY_INFO SetHistoryInfo;
|
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_GET_CONSOLE_CP GetConsoleCodePage;
|
||||||
CSRSS_SET_CONSOLE_CP SetConsoleCodePage;
|
CSRSS_SET_CONSOLE_CP SetConsoleCodePage;
|
||||||
CSRSS_GET_CONSOLE_OUTPUT_CP GetConsoleOutputCodePage;
|
CSRSS_GET_CONSOLE_OUTPUT_CP GetConsoleOutputCodePage;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* Johannes Anderwald
|
* Johannes Anderwald
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES *******************************************************************/
|
||||||
|
|
||||||
#include "consrv.h"
|
#include "consrv.h"
|
||||||
#include "conio.h"
|
#include "conio.h"
|
||||||
|
@ -16,22 +16,25 @@
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* TYPES **********************************************************************/
|
||||||
|
|
||||||
typedef struct tagALIAS_ENTRY
|
typedef struct tagALIAS_ENTRY
|
||||||
{
|
{
|
||||||
LPCWSTR lpSource;
|
LPCWSTR lpSource;
|
||||||
LPCWSTR lpTarget;
|
LPCWSTR lpTarget;
|
||||||
struct tagALIAS_ENTRY * Next;
|
struct tagALIAS_ENTRY* Next;
|
||||||
} ALIAS_ENTRY, *PALIAS_ENTRY;
|
} ALIAS_ENTRY, *PALIAS_ENTRY;
|
||||||
|
|
||||||
typedef struct tagALIAS_HEADER
|
typedef struct tagALIAS_HEADER
|
||||||
{
|
{
|
||||||
LPCWSTR lpExeName;
|
LPCWSTR lpExeName;
|
||||||
PALIAS_ENTRY Data;
|
PALIAS_ENTRY Data;
|
||||||
struct tagALIAS_HEADER * Next;
|
struct tagALIAS_HEADER* Next;
|
||||||
|
|
||||||
} ALIAS_HEADER, *PALIAS_HEADER;
|
} ALIAS_HEADER, *PALIAS_HEADER;
|
||||||
|
|
||||||
|
|
||||||
|
/* PRIVATE FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
static
|
static
|
||||||
PALIAS_HEADER
|
PALIAS_HEADER
|
||||||
IntFindAliasHeader(PALIAS_HEADER RootHeader, LPCWSTR lpExeName)
|
IntFindAliasHeader(PALIAS_HEADER RootHeader, LPCWSTR lpExeName)
|
||||||
|
@ -99,7 +102,7 @@ IntGetAliasEntry(PALIAS_HEADER Header, LPCWSTR lpSrcName)
|
||||||
while(RootHeader)
|
while(RootHeader)
|
||||||
{
|
{
|
||||||
INT diff;
|
INT diff;
|
||||||
DPRINT("IntGetAliasEntry>lpSource %S\n", RootHeader->lpSource);
|
DPRINT("IntGetAliasEntry->lpSource %S\n", RootHeader->lpSource);
|
||||||
diff = _wcsicmp(RootHeader->lpSource, lpSrcName);
|
diff = _wcsicmp(RootHeader->lpSource, lpSrcName);
|
||||||
if (!diff)
|
if (!diff)
|
||||||
return RootHeader;
|
return RootHeader;
|
||||||
|
@ -112,7 +115,6 @@ IntGetAliasEntry(PALIAS_HEADER Header, LPCWSTR lpSrcName)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
IntInsertAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY NewEntry)
|
IntInsertAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY NewEntry)
|
||||||
{
|
{
|
||||||
|
@ -218,6 +220,7 @@ IntGetAllConsoleAliasesLength(PALIAS_HEADER Header)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT
|
UINT
|
||||||
IntGetAllConsoleAliases(PALIAS_HEADER Header, LPWSTR TargetBuffer, UINT TargetBufferLength)
|
IntGetAllConsoleAliases(PALIAS_HEADER Header, LPWSTR TargetBuffer, UINT TargetBufferLength)
|
||||||
{
|
{
|
||||||
|
@ -244,6 +247,7 @@ IntGetAllConsoleAliases(PALIAS_HEADER Header, LPWSTR TargetBuffer, UINT TargetBu
|
||||||
TargetBuffer[Offset] = L'\0';
|
TargetBuffer[Offset] = L'\0';
|
||||||
return Offset * sizeof(WCHAR);
|
return Offset * sizeof(WCHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
IntDeleteAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY Entry)
|
IntDeleteAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY Entry)
|
||||||
{
|
{
|
||||||
|
@ -261,11 +265,13 @@ IntDeleteAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY Entry)
|
||||||
LastLink = &CurEntry->Next;
|
LastLink = &CurEntry->Next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
IntDeleteAllAliases(PALIAS_HEADER RootHeader)
|
IntDeleteAllAliases(PALIAS_HEADER RootHeader)
|
||||||
{
|
{
|
||||||
PALIAS_HEADER Header, NextHeader;
|
PALIAS_HEADER Header, NextHeader;
|
||||||
PALIAS_ENTRY Entry, NextEntry;
|
PALIAS_ENTRY Entry, NextEntry;
|
||||||
|
|
||||||
for (Header = RootHeader; Header; Header = NextHeader)
|
for (Header = RootHeader; Header; Header = NextHeader)
|
||||||
{
|
{
|
||||||
NextHeader = Header->Next;
|
NextHeader = Header->Next;
|
||||||
|
@ -278,33 +284,47 @@ IntDeleteAllAliases(PALIAS_HEADER RootHeader)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* PUBLIC SERVER APIS *********************************************************/
|
||||||
|
|
||||||
CSR_API(SrvAddConsoleAlias)
|
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;
|
PCSRSS_CONSOLE Console;
|
||||||
PALIAS_HEADER Header;
|
PALIAS_HEADER Header;
|
||||||
PALIAS_ENTRY Entry;
|
PALIAS_ENTRY Entry;
|
||||||
WCHAR * lpExeName;
|
LPWSTR lpSource, lpTarget, lpExeName;
|
||||||
WCHAR * lpSource;
|
|
||||||
WCHAR * lpTarget;
|
|
||||||
//ULONG TotalLength;
|
|
||||||
//WCHAR * Ptr;
|
|
||||||
|
|
||||||
//TotalLength = AddConsoleAlias->SourceLength + AddConsoleAlias->ExeLength + AddConsoleAlias->TargetLength;
|
DPRINT("SrvAddConsoleAlias entered ApiMessage %p\n", ApiMessage);
|
||||||
//Ptr = (WCHAR*)((ULONG_PTR)ApiMessage + sizeof(CSR_API_MESSAGE));
|
|
||||||
|
|
||||||
lpSource = (WCHAR*)((ULONG_PTR)ApiMessage + sizeof(CSR_API_MESSAGE));
|
if ( !CsrValidateMessageBuffer(ApiMessage,
|
||||||
lpExeName = (WCHAR*)((ULONG_PTR)ApiMessage + sizeof(CSR_API_MESSAGE) + AddConsoleAlias->SourceLength * sizeof(WCHAR));
|
&ConsoleAlias->Source,
|
||||||
lpTarget = (AddConsoleAlias->TargetLength != 0 ? lpExeName + AddConsoleAlias->ExeLength : NULL);
|
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)
|
if (lpExeName == NULL || lpSource == NULL)
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiMessage->Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console);
|
ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||||
if (!NT_SUCCESS(ApiMessage->Status))
|
if (!NT_SUCCESS(ApiMessage->Status))
|
||||||
{
|
{
|
||||||
return ApiMessage->Status;
|
return ApiMessage->Status;
|
||||||
|
@ -322,7 +342,7 @@ CSR_API(SrvAddConsoleAlias)
|
||||||
IntInsertAliasHeader(&Console->Aliases, Header);
|
IntInsertAliasHeader(&Console->Aliases, Header);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpTarget == NULL) // delete the entry
|
if (lpTarget == NULL) // Delete the entry
|
||||||
{
|
{
|
||||||
Entry = IntGetAliasEntry(Header, lpSource);
|
Entry = IntGetAliasEntry(Header, lpSource);
|
||||||
if (Entry)
|
if (Entry)
|
||||||
|
@ -353,30 +373,45 @@ CSR_API(SrvAddConsoleAlias)
|
||||||
|
|
||||||
CSR_API(SrvGetConsoleAlias)
|
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;
|
PCSRSS_CONSOLE Console;
|
||||||
PALIAS_HEADER Header;
|
PALIAS_HEADER Header;
|
||||||
PALIAS_ENTRY Entry;
|
PALIAS_ENTRY Entry;
|
||||||
UINT Length;
|
UINT Length;
|
||||||
WCHAR * lpExeName;
|
LPWSTR lpSource, lpTarget, lpExeName;
|
||||||
WCHAR * lpSource;
|
|
||||||
WCHAR * lpTarget;
|
|
||||||
|
|
||||||
lpSource = (LPWSTR)((ULONG_PTR)ApiMessage + sizeof(CSR_API_MESSAGE));
|
DPRINT("SrvGetConsoleAlias entered ApiMessage %p\n", ApiMessage);
|
||||||
lpExeName = lpSource + GetConsoleAlias->SourceLength;
|
|
||||||
lpTarget = GetConsoleAlias->TargetBuffer;
|
|
||||||
|
|
||||||
|
if ( !CsrValidateMessageBuffer(ApiMessage,
|
||||||
DPRINT("SrvGetConsoleAlias entered lpExeName %p lpSource %p TargetBuffer %p TargetBufferLength %u\n",
|
&ConsoleAlias->Source,
|
||||||
lpExeName, lpSource, lpTarget, GetConsoleAlias->TargetBufferLength);
|
ConsoleAlias->SourceLength,
|
||||||
|
sizeof(BYTE)) ||
|
||||||
if (GetConsoleAlias->ExeLength == 0 || lpTarget == NULL ||
|
!CsrValidateMessageBuffer(ApiMessage,
|
||||||
GetConsoleAlias->TargetBufferLength == 0 || GetConsoleAlias->SourceLength == 0)
|
&ConsoleAlias->Target,
|
||||||
|
ConsoleAlias->TargetLength,
|
||||||
|
sizeof(BYTE)) ||
|
||||||
|
!CsrValidateMessageBuffer(ApiMessage,
|
||||||
|
&ConsoleAlias->Exe,
|
||||||
|
ConsoleAlias->ExeLength,
|
||||||
|
sizeof(BYTE)) )
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER;
|
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))
|
if (!NT_SUCCESS(ApiMessage->Status))
|
||||||
{
|
{
|
||||||
return ApiMessage->Status;
|
return ApiMessage->Status;
|
||||||
|
@ -396,71 +431,87 @@ CSR_API(SrvGetConsoleAlias)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
Length = (wcslen(Entry->lpTarget)+1) * sizeof(WCHAR);
|
Length = (wcslen(Entry->lpTarget) + 1) * sizeof(WCHAR);
|
||||||
if (Length > GetConsoleAlias->TargetBufferLength)
|
if (Length > ConsoleAlias->TargetLength)
|
||||||
{
|
{
|
||||||
ConioUnlockConsole(Console);
|
ConioUnlockConsole(Console);
|
||||||
return STATUS_BUFFER_TOO_SMALL;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (!Win32CsrValidateBuffer(CsrGetClientThread()->Process, lpTarget,
|
if (!Win32CsrValidateBuffer(CsrGetClientThread()->Process, lpTarget,
|
||||||
GetConsoleAlias->TargetBufferLength, 1))
|
ConsoleAlias->TargetLength, 1))
|
||||||
{
|
{
|
||||||
ConioUnlockConsole(Console);
|
ConioUnlockConsole(Console);
|
||||||
return STATUS_ACCESS_VIOLATION;
|
return STATUS_ACCESS_VIOLATION;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
wcscpy(lpTarget, Entry->lpTarget);
|
wcscpy(lpTarget, Entry->lpTarget);
|
||||||
GetConsoleAlias->BytesWritten = Length;
|
ConsoleAlias->TargetLength = Length;
|
||||||
ConioUnlockConsole(Console);
|
ConioUnlockConsole(Console);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSR_API(SrvGetConsoleAliases)
|
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;
|
PCSRSS_CONSOLE Console;
|
||||||
ULONG BytesWritten;
|
ULONG BytesWritten;
|
||||||
PALIAS_HEADER Header;
|
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;
|
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))
|
if (!NT_SUCCESS(ApiMessage->Status))
|
||||||
{
|
{
|
||||||
return ApiMessage->Status;
|
return ApiMessage->Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Header = IntFindAliasHeader(Console->Aliases, GetAllConsoleAlias->lpExeName);
|
Header = IntFindAliasHeader(Console->Aliases, GetAllConsoleAliases->ExeName);
|
||||||
if (!Header)
|
if (!Header)
|
||||||
{
|
{
|
||||||
ConioUnlockConsole(Console);
|
ConioUnlockConsole(Console);
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IntGetAllConsoleAliasesLength(Header) > GetAllConsoleAlias->AliasBufferLength)
|
if (IntGetAllConsoleAliasesLength(Header) > GetAllConsoleAliases->AliasesBufferLength)
|
||||||
{
|
{
|
||||||
ConioUnlockConsole(Console);
|
ConioUnlockConsole(Console);
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_OVERFLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (!Win32CsrValidateBuffer(CsrGetClientThread()->Process,
|
if (!Win32CsrValidateBuffer(CsrGetClientThread()->Process,
|
||||||
GetAllConsoleAlias->AliasBuffer,
|
GetAllConsoleAliases->AliasesBuffer,
|
||||||
GetAllConsoleAlias->AliasBufferLength,
|
GetAllConsoleAliases->AliasesBufferLength,
|
||||||
1))
|
1))
|
||||||
{
|
{
|
||||||
ConioUnlockConsole(Console);
|
ConioUnlockConsole(Console);
|
||||||
return STATUS_ACCESS_VIOLATION;
|
return STATUS_ACCESS_VIOLATION;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
BytesWritten = IntGetAllConsoleAliases(Header,
|
BytesWritten = IntGetAllConsoleAliases(Header,
|
||||||
GetAllConsoleAlias->AliasBuffer,
|
GetAllConsoleAliases->AliasesBuffer,
|
||||||
GetAllConsoleAlias->AliasBufferLength);
|
GetAllConsoleAliases->AliasesBufferLength);
|
||||||
|
|
||||||
GetAllConsoleAlias->BytesWritten = BytesWritten;
|
GetAllConsoleAliases->AliasesBufferLength = BytesWritten;
|
||||||
ConioUnlockConsole(Console);
|
ConioUnlockConsole(Console);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -472,18 +523,26 @@ CSR_API(SrvGetConsoleAliasesLength)
|
||||||
PALIAS_HEADER Header;
|
PALIAS_HEADER Header;
|
||||||
UINT Length;
|
UINT Length;
|
||||||
|
|
||||||
if (GetAllConsoleAliasesLength->lpExeName == NULL)
|
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||||
|
(PVOID)&GetAllConsoleAliasesLength->ExeName,
|
||||||
|
GetAllConsoleAliasesLength->ExeLength,
|
||||||
|
sizeof(BYTE)))
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER;
|
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))
|
if (!NT_SUCCESS(ApiMessage->Status))
|
||||||
{
|
{
|
||||||
return ApiMessage->Status;
|
return ApiMessage->Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Header = IntFindAliasHeader(Console->Aliases, GetAllConsoleAliasesLength->lpExeName);
|
Header = IntFindAliasHeader(Console->Aliases, GetAllConsoleAliasesLength->ExeName);
|
||||||
if (!Header)
|
if (!Header)
|
||||||
{
|
{
|
||||||
ConioUnlockConsole(Console);
|
ConioUnlockConsole(Console);
|
||||||
|
@ -505,7 +564,15 @@ CSR_API(SrvGetConsoleAliasExes)
|
||||||
|
|
||||||
DPRINT("SrvGetConsoleAliasExes entered\n");
|
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))
|
if (!NT_SUCCESS(ApiMessage->Status))
|
||||||
{
|
{
|
||||||
return ApiMessage->Status;
|
return ApiMessage->Status;
|
||||||
|
@ -525,6 +592,7 @@ CSR_API(SrvGetConsoleAliasExes)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (!Win32CsrValidateBuffer(CsrGetClientThread()->Process,
|
if (!Win32CsrValidateBuffer(CsrGetClientThread()->Process,
|
||||||
GetConsoleAliasesExes->ExeNames,
|
GetConsoleAliasesExes->ExeNames,
|
||||||
GetConsoleAliasesExes->Length,
|
GetConsoleAliasesExes->Length,
|
||||||
|
@ -533,12 +601,13 @@ CSR_API(SrvGetConsoleAliasExes)
|
||||||
ConioUnlockConsole(Console);
|
ConioUnlockConsole(Console);
|
||||||
return STATUS_ACCESS_VIOLATION;
|
return STATUS_ACCESS_VIOLATION;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
BytesWritten = IntGetConsoleAliasesExes(Console->Aliases,
|
BytesWritten = IntGetConsoleAliasesExes(Console->Aliases,
|
||||||
GetConsoleAliasesExes->ExeNames,
|
GetConsoleAliasesExes->ExeNames,
|
||||||
GetConsoleAliasesExes->Length);
|
GetConsoleAliasesExes->Length);
|
||||||
|
|
||||||
GetConsoleAliasesExes->BytesWritten = BytesWritten;
|
GetConsoleAliasesExes->Length = BytesWritten;
|
||||||
ConioUnlockConsole(Console);
|
ConioUnlockConsole(Console);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -549,7 +618,7 @@ CSR_API(SrvGetConsoleAliasExesLength)
|
||||||
PCSRSS_CONSOLE Console;
|
PCSRSS_CONSOLE Console;
|
||||||
DPRINT("SrvGetConsoleAliasExesLength entered\n");
|
DPRINT("SrvGetConsoleAliasExesLength entered\n");
|
||||||
|
|
||||||
ApiMessage->Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console);
|
ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
|
||||||
if (NT_SUCCESS(ApiMessage->Status))
|
if (NT_SUCCESS(ApiMessage->Status))
|
||||||
{
|
{
|
||||||
GetConsoleAliasesExesLength->Length = IntGetConsoleAliasesExesLength(Console->Aliases);
|
GetConsoleAliasesExesLength->Length = IntGetConsoleAliasesExesLength(Console->Aliases);
|
||||||
|
@ -557,3 +626,5 @@ CSR_API(SrvGetConsoleAliasExesLength)
|
||||||
}
|
}
|
||||||
return ApiMessage->Status;
|
return ApiMessage->Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue