mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 06:15:26 +00:00
[KERNEL32][CONSRV]
Make kernel32 / winsrv console CSR structures Win2k3-compliant. The aim is to be able to put our kernel32.dll or winsrv.dll on win2k3, and vice-versa. - Fix almost all the alias APIs and the history APIs. Unicode versions is OK, ANSI ones need correct fixes in server-side (see CORE-7931 for more details). - Half-plement SetConsoleCommandHistoryMode (client-side OK, server-side unimplemented). Part 4/X CORE-7931 svn path=/branches/condrv_restructure/; revision=63194
This commit is contained in:
parent
7a0c3bde06
commit
c26bc793ac
6 changed files with 501 additions and 347 deletions
|
@ -387,30 +387,24 @@ GetConsoleAliasesA(LPSTR AliasBuffer,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
DWORD
|
||||
WINAPI
|
||||
GetConsoleAliasesLengthW(LPWSTR lpExeName)
|
||||
static DWORD
|
||||
IntGetConsoleAliasesLength(LPVOID lpExeName, DWORD dwNumChars, BOOLEAN bUnicode)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_GETALLALIASESLENGTH GetAllAliasesLengthRequest = &ApiMessage.Data.GetAllAliasesLengthRequest;
|
||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||
|
||||
DPRINT("GetConsoleAliasesLengthW entered\n");
|
||||
|
||||
if (lpExeName == NULL)
|
||||
if (lpExeName == NULL || dwNumChars == 0)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GetAllAliasesLengthRequest->ExeLength = (wcslen(lpExeName) + 1) * sizeof(WCHAR);
|
||||
GetAllAliasesLengthRequest->Length = 0;
|
||||
GetAllAliasesLengthRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||
GetAllAliasesLengthRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
|
||||
GetAllAliasesLengthRequest->Unicode =
|
||||
GetAllAliasesLengthRequest->Unicode2 = bUnicode;
|
||||
|
||||
/* Allocate a Capture Buffer */
|
||||
CaptureBuffer = CsrAllocateCaptureBuffer(1, GetAllAliasesLengthRequest->ExeLength);
|
||||
if (!CaptureBuffer)
|
||||
{
|
||||
|
@ -419,22 +413,21 @@ GetConsoleAliasesLengthW(LPWSTR lpExeName)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Capture the exe name */
|
||||
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||
(PVOID)lpExeName,
|
||||
GetAllAliasesLengthRequest->ExeLength,
|
||||
(PVOID)&GetAllAliasesLengthRequest->ExeName);
|
||||
|
||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasesLength),
|
||||
sizeof(CONSOLE_GETALLALIASESLENGTH));
|
||||
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasesLength),
|
||||
sizeof(*GetAllAliasesLengthRequest));
|
||||
|
||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
if (!NT_SUCCESS(ApiMessage.Status))
|
||||
{
|
||||
BaseSetLastNTError(Status);
|
||||
BaseSetLastNTError(ApiMessage.Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -447,26 +440,80 @@ GetConsoleAliasesLengthW(LPWSTR lpExeName)
|
|||
*/
|
||||
DWORD
|
||||
WINAPI
|
||||
GetConsoleAliasesLengthA(LPSTR lpExeName)
|
||||
GetConsoleAliasesLengthW(LPWSTR lpExeName)
|
||||
{
|
||||
DWORD dwRetVal = 0;
|
||||
LPWSTR lpExeNameW = NULL;
|
||||
if (lpExeName == NULL)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
return IntGetConsoleAliasesLength(lpExeName, wcslen(lpExeName), TRUE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
DWORD
|
||||
WINAPI
|
||||
GetConsoleAliasesLengthA(LPSTR lpExeName)
|
||||
{
|
||||
if (lpExeName == NULL)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return IntGetConsoleAliasesLength(lpExeName, strlen(lpExeName), FALSE);
|
||||
}
|
||||
|
||||
|
||||
static DWORD
|
||||
IntGetConsoleAliasExes(PVOID lpExeNameBuffer,
|
||||
DWORD ExeNameBufferLength,
|
||||
BOOLEAN bUnicode)
|
||||
{
|
||||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_GETALIASESEXES GetAliasesExesRequest = &ApiMessage.Data.GetAliasesExesRequest;
|
||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||
|
||||
GetAliasesExesRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||
GetAliasesExesRequest->Length = ExeNameBufferLength;
|
||||
GetAliasesExesRequest->Unicode = bUnicode;
|
||||
|
||||
CaptureBuffer = CsrAllocateCaptureBuffer(1, ExeNameBufferLength);
|
||||
if (!CaptureBuffer)
|
||||
{
|
||||
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CsrAllocateMessagePointer(CaptureBuffer,
|
||||
ExeNameBufferLength,
|
||||
(PVOID*)&GetAliasesExesRequest->ExeNames);
|
||||
|
||||
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasExes),
|
||||
sizeof(*GetAliasesExesRequest));
|
||||
if (!NT_SUCCESS(ApiMessage.Status))
|
||||
{
|
||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||
BaseSetLastNTError(ApiMessage.Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(lpExeNameBuffer,
|
||||
GetAliasesExesRequest->ExeNames,
|
||||
GetAliasesExesRequest->Length);
|
||||
|
||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||
|
||||
return GetAliasesExesRequest->Length;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
|
@ -475,49 +522,7 @@ WINAPI
|
|||
GetConsoleAliasExesW(LPWSTR lpExeNameBuffer,
|
||||
DWORD ExeNameBufferLength)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_GETALIASESEXES GetAliasesExesRequest = &ApiMessage.Data.GetAliasesExesRequest;
|
||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||
|
||||
DPRINT("GetConsoleAliasExesW entered\n");
|
||||
|
||||
/* Allocate a Capture Buffer */
|
||||
CaptureBuffer = CsrAllocateCaptureBuffer(1, ExeNameBufferLength);
|
||||
if (!CaptureBuffer)
|
||||
{
|
||||
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GetAliasesExesRequest->Length = ExeNameBufferLength;
|
||||
|
||||
/* Allocate space for the exe name buffer */
|
||||
CsrAllocateMessagePointer(CaptureBuffer,
|
||||
ExeNameBufferLength,
|
||||
(PVOID*)&GetAliasesExesRequest->ExeNames);
|
||||
|
||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasExes),
|
||||
sizeof(CONSOLE_GETALIASESEXES));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||
BaseSetLastNTError(Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy the returned target string into the user buffer */
|
||||
memcpy(lpExeNameBuffer,
|
||||
GetAliasesExesRequest->ExeNames,
|
||||
GetAliasesExesRequest->Length);
|
||||
|
||||
/* Release the capture buffer and exit */
|
||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||
|
||||
return GetAliasesExesRequest->Length;
|
||||
return IntGetConsoleAliasExes(lpExeNameBuffer, ExeNameBufferLength, TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -529,46 +534,26 @@ WINAPI
|
|||
GetConsoleAliasExesA(LPSTR lpExeNameBuffer,
|
||||
DWORD ExeNameBufferLength)
|
||||
{
|
||||
LPWSTR lpwExeNameBuffer;
|
||||
DWORD dwResult;
|
||||
|
||||
DPRINT("GetConsoleAliasExesA entered\n");
|
||||
|
||||
lpwExeNameBuffer = HeapAlloc(GetProcessHeap(), 0, ExeNameBufferLength * sizeof(WCHAR));
|
||||
|
||||
dwResult = GetConsoleAliasExesW(lpwExeNameBuffer, ExeNameBufferLength * sizeof(WCHAR));
|
||||
|
||||
if (dwResult)
|
||||
dwResult = WideCharToMultiByte(CP_ACP, 0, lpwExeNameBuffer, dwResult / sizeof(WCHAR), lpExeNameBuffer, ExeNameBufferLength, NULL, NULL);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, lpwExeNameBuffer);
|
||||
return dwResult;
|
||||
return IntGetConsoleAliasExes(lpExeNameBuffer, ExeNameBufferLength, FALSE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
DWORD
|
||||
WINAPI
|
||||
GetConsoleAliasExesLengthW(VOID)
|
||||
static DWORD
|
||||
IntGetConsoleAliasExesLength(BOOLEAN bUnicode)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_GETALIASESEXESLENGTH GetAliasesExesLengthRequest = &ApiMessage.Data.GetAliasesExesLengthRequest;
|
||||
|
||||
DPRINT("GetConsoleAliasExesLengthW entered\n");
|
||||
GetAliasesExesLengthRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||
GetAliasesExesLengthRequest->Unicode = bUnicode;
|
||||
|
||||
GetAliasesExesLengthRequest->Length = 0;
|
||||
|
||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
NULL,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasExesLength),
|
||||
sizeof(CONSOLE_GETALIASESEXESLENGTH));
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
NULL,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasExesLength),
|
||||
sizeof(*GetAliasesExesLengthRequest));
|
||||
if (!NT_SUCCESS(ApiMessage.Status))
|
||||
{
|
||||
BaseSetLastNTError(Status);
|
||||
BaseSetLastNTError(ApiMessage.Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -576,6 +561,17 @@ GetConsoleAliasExesLengthW(VOID)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
DWORD
|
||||
WINAPI
|
||||
GetConsoleAliasExesLengthW(VOID)
|
||||
{
|
||||
return IntGetConsoleAliasExesLength(TRUE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
|
@ -583,16 +579,7 @@ DWORD
|
|||
WINAPI
|
||||
GetConsoleAliasExesLengthA(VOID)
|
||||
{
|
||||
DWORD dwLength;
|
||||
|
||||
DPRINT("GetConsoleAliasExesLengthA entered\n");
|
||||
|
||||
dwLength = GetConsoleAliasExesLengthW();
|
||||
|
||||
if (dwLength)
|
||||
dwLength /= sizeof(WCHAR);
|
||||
|
||||
return dwLength;
|
||||
return IntGetConsoleAliasExesLength(FALSE);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1496,18 +1496,17 @@ SetConsoleScreenBufferSize(HANDLE hConsoleOutput,
|
|||
static
|
||||
BOOL
|
||||
IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput,
|
||||
const SMALL_RECT *lpScrollRectangle,
|
||||
const SMALL_RECT *lpClipRectangle,
|
||||
CONST SMALL_RECT* lpScrollRectangle,
|
||||
CONST SMALL_RECT* lpClipRectangle,
|
||||
COORD dwDestinationOrigin,
|
||||
const CHAR_INFO *lpFill,
|
||||
CONST CHAR_INFO* lpFill,
|
||||
BOOL bUnicode)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest = &ApiMessage.Data.ScrollScreenBufferRequest;
|
||||
|
||||
ScrollScreenBufferRequest->OutputHandle = hConsoleOutput;
|
||||
ScrollScreenBufferRequest->Unicode = bUnicode;
|
||||
ScrollScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||
ScrollScreenBufferRequest->OutputHandle = hConsoleOutput;
|
||||
ScrollScreenBufferRequest->ScrollRectangle = *lpScrollRectangle;
|
||||
|
||||
if (lpClipRectangle != NULL)
|
||||
|
@ -1521,16 +1520,16 @@ IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput,
|
|||
}
|
||||
|
||||
ScrollScreenBufferRequest->DestinationOrigin = dwDestinationOrigin;
|
||||
ScrollScreenBufferRequest->Fill = *lpFill;
|
||||
ScrollScreenBufferRequest->Fill = *lpFill;
|
||||
ScrollScreenBufferRequest->Unicode = bUnicode;
|
||||
|
||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
NULL,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepScrollScreenBuffer),
|
||||
sizeof(CONSOLE_SCROLLSCREENBUFFER));
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
NULL,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepScrollScreenBuffer),
|
||||
sizeof(*ScrollScreenBufferRequest));
|
||||
if (!NT_SUCCESS(ApiMessage.Status))
|
||||
{
|
||||
BaseSetLastNTError(Status);
|
||||
BaseSetLastNTError(ApiMessage.Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1546,16 +1545,16 @@ IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput,
|
|||
BOOL
|
||||
WINAPI
|
||||
ScrollConsoleScreenBufferA(HANDLE hConsoleOutput,
|
||||
CONST SMALL_RECT *lpScrollRectangle,
|
||||
CONST SMALL_RECT *lpClipRectangle,
|
||||
CONST SMALL_RECT* lpScrollRectangle,
|
||||
CONST SMALL_RECT* lpClipRectangle,
|
||||
COORD dwDestinationOrigin,
|
||||
CONST CHAR_INFO *lpFill)
|
||||
CONST CHAR_INFO* lpFill)
|
||||
{
|
||||
return IntScrollConsoleScreenBuffer(hConsoleOutput,
|
||||
(PSMALL_RECT)lpScrollRectangle,
|
||||
(PSMALL_RECT)lpClipRectangle,
|
||||
lpScrollRectangle,
|
||||
lpClipRectangle,
|
||||
dwDestinationOrigin,
|
||||
(PCHAR_INFO)lpFill,
|
||||
lpFill,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,14 @@
|
|||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
||||
#if 0
|
||||
/* Get the size needed to copy a string to a capture buffer, including alignment */
|
||||
static ULONG
|
||||
IntStringSize(LPCVOID String,
|
||||
BOOL Unicode)
|
||||
{
|
||||
ULONG Size = (Unicode ? wcslen(String) : strlen(String)) * sizeof(WCHAR);
|
||||
return (Size + 3) & -4;
|
||||
return (Size + 3) & ~3;
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,67 +49,77 @@ IntCaptureMessageString(PCSR_CAPTURE_BUFFER CaptureBuffer,
|
|||
}
|
||||
RequestString->Length = RequestString->MaximumLength = (USHORT)Size;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static BOOL
|
||||
IntExpungeConsoleCommandHistory(LPCVOID lpExeName, BOOL bUnicode)
|
||||
static VOID
|
||||
IntExpungeConsoleCommandHistory(LPCVOID lpExeName, DWORD dwNumChars, BOOLEAN bUnicode)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &ApiMessage.Data.ExpungeCommandHistoryRequest;
|
||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||
|
||||
if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName))
|
||||
if (lpExeName == NULL || dwNumChars == 0)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode));
|
||||
ExpungeCommandHistoryRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||
ExpungeCommandHistoryRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
|
||||
ExpungeCommandHistoryRequest->Unicode =
|
||||
ExpungeCommandHistoryRequest->Unicode2 = bUnicode;
|
||||
|
||||
// CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode));
|
||||
CaptureBuffer = CsrAllocateCaptureBuffer(1, ExpungeCommandHistoryRequest->ExeLength);
|
||||
if (!CaptureBuffer)
|
||||
{
|
||||
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
||||
&ExpungeCommandHistoryRequest->ExeName);
|
||||
// IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
||||
// &ExpungeCommandHistoryRequest->ExeName);
|
||||
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||
(PVOID)lpExeName,
|
||||
ExpungeCommandHistoryRequest->ExeLength,
|
||||
(PVOID)&ExpungeCommandHistoryRequest->ExeName);
|
||||
|
||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepExpungeCommandHistory),
|
||||
sizeof(CONSOLE_EXPUNGECOMMANDHISTORY));
|
||||
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepExpungeCommandHistory),
|
||||
sizeof(*ExpungeCommandHistoryRequest));
|
||||
|
||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
BaseSetLastNTError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
if (!NT_SUCCESS(ApiMessage.Status))
|
||||
BaseSetLastNTError(ApiMessage.Status);
|
||||
}
|
||||
|
||||
|
||||
static DWORD
|
||||
IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName, BOOL bUnicode)
|
||||
IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName, DWORD dwNumChars, BOOLEAN bUnicode)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &ApiMessage.Data.GetCommandHistoryRequest;
|
||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||
DWORD HistoryLength = cbHistory * (bUnicode ? 1 : sizeof(WCHAR));
|
||||
|
||||
if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName))
|
||||
if (lpExeName == NULL || dwNumChars == 0)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CaptureBuffer = CsrAllocateCaptureBuffer(2, IntStringSize(lpExeName, bUnicode) +
|
||||
HistoryLength);
|
||||
GetCommandHistoryRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||
GetCommandHistoryRequest->HistoryLength = cbHistory;
|
||||
GetCommandHistoryRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
|
||||
GetCommandHistoryRequest->Unicode =
|
||||
GetCommandHistoryRequest->Unicode2 = bUnicode;
|
||||
|
||||
// CaptureBuffer = CsrAllocateCaptureBuffer(2, IntStringSize(lpExeName, bUnicode) +
|
||||
// HistoryLength);
|
||||
CaptureBuffer = CsrAllocateCaptureBuffer(2, GetCommandHistoryRequest->ExeLength +
|
||||
GetCommandHistoryRequest->HistoryLength);
|
||||
if (!CaptureBuffer)
|
||||
{
|
||||
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
||||
|
@ -116,60 +127,58 @@ IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName
|
|||
return 0;
|
||||
}
|
||||
|
||||
IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
||||
&GetCommandHistoryRequest->ExeName);
|
||||
GetCommandHistoryRequest->Length = HistoryLength;
|
||||
CsrAllocateMessagePointer(CaptureBuffer, HistoryLength,
|
||||
// IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
||||
// &GetCommandHistoryRequest->ExeName);
|
||||
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||
(PVOID)lpExeName,
|
||||
GetCommandHistoryRequest->ExeLength,
|
||||
(PVOID)&GetCommandHistoryRequest->ExeName);
|
||||
|
||||
// CsrAllocateMessagePointer(CaptureBuffer, HistoryLength,
|
||||
CsrAllocateMessagePointer(CaptureBuffer, GetCommandHistoryRequest->HistoryLength,
|
||||
(PVOID*)&GetCommandHistoryRequest->History);
|
||||
|
||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCommandHistory),
|
||||
sizeof(CONSOLE_GETCOMMANDHISTORY));
|
||||
if (!NT_SUCCESS(Status))
|
||||
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCommandHistory),
|
||||
sizeof(*GetCommandHistoryRequest));
|
||||
if (!NT_SUCCESS(ApiMessage.Status))
|
||||
{
|
||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||
BaseSetLastNTError(Status);
|
||||
BaseSetLastNTError(ApiMessage.Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bUnicode)
|
||||
{
|
||||
memcpy(lpHistory,
|
||||
GetCommandHistoryRequest->History,
|
||||
GetCommandHistoryRequest->Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
WideCharToMultiByte(CP_ACP, 0,
|
||||
GetCommandHistoryRequest->History,
|
||||
GetCommandHistoryRequest->Length / sizeof(WCHAR),
|
||||
lpHistory,
|
||||
cbHistory,
|
||||
NULL, NULL);
|
||||
}
|
||||
memcpy(lpHistory,
|
||||
GetCommandHistoryRequest->History,
|
||||
GetCommandHistoryRequest->HistoryLength);
|
||||
|
||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||
|
||||
return GetCommandHistoryRequest->Length;
|
||||
return GetCommandHistoryRequest->HistoryLength;
|
||||
}
|
||||
|
||||
|
||||
static DWORD
|
||||
IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, BOOL bUnicode)
|
||||
IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, DWORD dwNumChars, BOOL bUnicode)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &ApiMessage.Data.GetCommandHistoryLengthRequest;
|
||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||
|
||||
if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName))
|
||||
if (lpExeName == NULL || dwNumChars == 0)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode));
|
||||
GetCommandHistoryLengthRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||
GetCommandHistoryLengthRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
|
||||
GetCommandHistoryLengthRequest->Unicode =
|
||||
GetCommandHistoryLengthRequest->Unicode2 = bUnicode;
|
||||
|
||||
// CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode));
|
||||
CaptureBuffer = CsrAllocateCaptureBuffer(1, GetCommandHistoryLengthRequest->ExeLength);
|
||||
if (!CaptureBuffer)
|
||||
{
|
||||
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
||||
|
@ -177,43 +186,54 @@ IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, BOOL bUnicode)
|
|||
return 0;
|
||||
}
|
||||
|
||||
IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
||||
&GetCommandHistoryLengthRequest->ExeName);
|
||||
// IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
||||
// &GetCommandHistoryLengthRequest->ExeName);
|
||||
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||
(PVOID)lpExeName,
|
||||
GetCommandHistoryLengthRequest->ExeLength,
|
||||
(PVOID)&GetCommandHistoryLengthRequest->ExeName);
|
||||
|
||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCommandHistoryLength),
|
||||
sizeof(CONSOLE_GETCOMMANDHISTORYLENGTH));
|
||||
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCommandHistoryLength),
|
||||
sizeof(*GetCommandHistoryLengthRequest));
|
||||
|
||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
if (!NT_SUCCESS(ApiMessage.Status))
|
||||
{
|
||||
BaseSetLastNTError(Status);
|
||||
BaseSetLastNTError(ApiMessage.Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return GetCommandHistoryLengthRequest->Length;
|
||||
return GetCommandHistoryLengthRequest->HistoryLength;
|
||||
}
|
||||
|
||||
|
||||
static BOOL
|
||||
IntSetConsoleNumberOfCommands(DWORD dwNumCommands,
|
||||
LPCVOID lpExeName,
|
||||
BOOL bUnicode)
|
||||
DWORD dwNumChars,
|
||||
BOOLEAN bUnicode)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &ApiMessage.Data.SetHistoryNumberCommandsRequest;
|
||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||
|
||||
if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName))
|
||||
if (lpExeName == NULL || dwNumChars == 0)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode));
|
||||
SetHistoryNumberCommandsRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||
SetHistoryNumberCommandsRequest->NumCommands = dwNumCommands;
|
||||
SetHistoryNumberCommandsRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
|
||||
SetHistoryNumberCommandsRequest->Unicode =
|
||||
SetHistoryNumberCommandsRequest->Unicode2 = bUnicode;
|
||||
|
||||
// CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode));
|
||||
CaptureBuffer = CsrAllocateCaptureBuffer(1, SetHistoryNumberCommandsRequest->ExeLength);
|
||||
if (!CaptureBuffer)
|
||||
{
|
||||
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
||||
|
@ -221,20 +241,23 @@ IntSetConsoleNumberOfCommands(DWORD dwNumCommands,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
||||
&SetHistoryNumberCommandsRequest->ExeName);
|
||||
SetHistoryNumberCommandsRequest->NumCommands = dwNumCommands;
|
||||
// IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
||||
// &SetHistoryNumberCommandsRequest->ExeName);
|
||||
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||
(PVOID)lpExeName,
|
||||
SetHistoryNumberCommandsRequest->ExeLength,
|
||||
(PVOID)&SetHistoryNumberCommandsRequest->ExeName);
|
||||
|
||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetNumberOfCommands),
|
||||
sizeof(CONSOLE_SETHISTORYNUMBERCOMMANDS));
|
||||
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetNumberOfCommands),
|
||||
sizeof(*SetHistoryNumberCommandsRequest));
|
||||
|
||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
if (!NT_SUCCESS(ApiMessage.Status))
|
||||
{
|
||||
BaseSetLastNTError(Status);
|
||||
BaseSetLastNTError(ApiMessage.Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -247,22 +270,34 @@ IntSetConsoleNumberOfCommands(DWORD dwNumCommands,
|
|||
/*
|
||||
* @implemented (Undocumented)
|
||||
*/
|
||||
BOOL
|
||||
VOID
|
||||
WINAPI
|
||||
ExpungeConsoleCommandHistoryW(LPCWSTR lpExeName)
|
||||
{
|
||||
return IntExpungeConsoleCommandHistory(lpExeName, TRUE);
|
||||
if (lpExeName == NULL)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return;
|
||||
}
|
||||
|
||||
IntExpungeConsoleCommandHistory(lpExeName, wcslen(lpExeName), TRUE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented (Undocumented)
|
||||
*/
|
||||
BOOL
|
||||
VOID
|
||||
WINAPI
|
||||
ExpungeConsoleCommandHistoryA(LPCSTR lpExeName)
|
||||
{
|
||||
return IntExpungeConsoleCommandHistory(lpExeName, FALSE);
|
||||
if (lpExeName == NULL)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return;
|
||||
}
|
||||
|
||||
IntExpungeConsoleCommandHistory(lpExeName, strlen(lpExeName), FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -275,7 +310,13 @@ GetConsoleCommandHistoryW(LPWSTR lpHistory,
|
|||
DWORD cbHistory,
|
||||
LPCWSTR lpExeName)
|
||||
{
|
||||
return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName, TRUE);
|
||||
if (lpExeName == NULL)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName, wcslen(lpExeName), TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -288,7 +329,13 @@ GetConsoleCommandHistoryA(LPSTR lpHistory,
|
|||
DWORD cbHistory,
|
||||
LPCSTR lpExeName)
|
||||
{
|
||||
return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName, FALSE);
|
||||
if (lpExeName == NULL)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName, strlen(lpExeName), FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -299,7 +346,13 @@ DWORD
|
|||
WINAPI
|
||||
GetConsoleCommandHistoryLengthW(LPCWSTR lpExeName)
|
||||
{
|
||||
return IntGetConsoleCommandHistoryLength(lpExeName, TRUE);
|
||||
if (lpExeName == NULL)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return IntGetConsoleCommandHistoryLength(lpExeName, wcslen(lpExeName), TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -310,7 +363,13 @@ DWORD
|
|||
WINAPI
|
||||
GetConsoleCommandHistoryLengthA(LPCSTR lpExeName)
|
||||
{
|
||||
return IntGetConsoleCommandHistoryLength(lpExeName, FALSE) / sizeof(WCHAR);
|
||||
if (lpExeName == NULL)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return IntGetConsoleCommandHistoryLength(lpExeName, strlen(lpExeName), FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -320,9 +379,15 @@ GetConsoleCommandHistoryLengthA(LPCSTR lpExeName)
|
|||
BOOL
|
||||
WINAPI
|
||||
SetConsoleNumberOfCommandsW(DWORD dwNumCommands,
|
||||
LPCSTR lpExeName)
|
||||
LPCWSTR lpExeName)
|
||||
{
|
||||
return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, TRUE);
|
||||
if (lpExeName == NULL)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, wcslen(lpExeName), TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -332,21 +397,42 @@ SetConsoleNumberOfCommandsW(DWORD dwNumCommands,
|
|||
BOOL
|
||||
WINAPI
|
||||
SetConsoleNumberOfCommandsA(DWORD dwNumCommands,
|
||||
LPCWSTR lpExeName)
|
||||
LPCSTR lpExeName)
|
||||
{
|
||||
return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, FALSE);
|
||||
if (lpExeName == NULL)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, strlen(lpExeName), FALSE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
* @implemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
SetConsoleCommandHistoryMode(IN DWORD dwMode)
|
||||
{
|
||||
STUB;
|
||||
return FALSE;
|
||||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_SETHISTORYMODE SetHistoryModeRequest = &ApiMessage.Data.SetHistoryModeRequest;
|
||||
|
||||
SetHistoryModeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||
SetHistoryModeRequest->Mode = dwMode;
|
||||
|
||||
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
NULL,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetCommandHistoryMode),
|
||||
sizeof(*SetHistoryModeRequest));
|
||||
if (!NT_SUCCESS(ApiMessage.Status))
|
||||
{
|
||||
BaseSetLastNTError(ApiMessage.Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -701,20 +701,35 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
UNICODE_STRING ExeName;
|
||||
PWCHAR History;
|
||||
DWORD Length;
|
||||
HANDLE ConsoleHandle;
|
||||
ULONG HistoryLength;
|
||||
PVOID History;
|
||||
// UNICODE_STRING ExeName;
|
||||
USHORT ExeLength;
|
||||
PVOID ExeName;
|
||||
BOOLEAN Unicode;
|
||||
BOOLEAN Unicode2;
|
||||
} CONSOLE_GETCOMMANDHISTORY, *PCONSOLE_GETCOMMANDHISTORY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UNICODE_STRING ExeName;
|
||||
DWORD Length;
|
||||
HANDLE ConsoleHandle;
|
||||
ULONG HistoryLength;
|
||||
// UNICODE_STRING ExeName;
|
||||
USHORT ExeLength;
|
||||
PVOID ExeName;
|
||||
BOOLEAN Unicode;
|
||||
BOOLEAN Unicode2;
|
||||
} CONSOLE_GETCOMMANDHISTORYLENGTH, *PCONSOLE_GETCOMMANDHISTORYLENGTH;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UNICODE_STRING ExeName;
|
||||
HANDLE ConsoleHandle;
|
||||
// UNICODE_STRING ExeName;
|
||||
USHORT ExeLength;
|
||||
PVOID ExeName;
|
||||
BOOLEAN Unicode;
|
||||
BOOLEAN Unicode2;
|
||||
} CONSOLE_EXPUNGECOMMANDHISTORY, *PCONSOLE_EXPUNGECOMMANDHISTORY;
|
||||
|
||||
typedef struct
|
||||
|
@ -726,8 +741,13 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
UNICODE_STRING ExeName;
|
||||
DWORD NumCommands;
|
||||
HANDLE ConsoleHandle;
|
||||
ULONG NumCommands;
|
||||
// UNICODE_STRING ExeName;
|
||||
USHORT ExeLength;
|
||||
PVOID ExeName;
|
||||
BOOLEAN Unicode;
|
||||
BOOLEAN Unicode2;
|
||||
} CONSOLE_SETHISTORYNUMBERCOMMANDS, *PCONSOLE_SETHISTORYNUMBERCOMMANDS;
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -483,6 +483,7 @@ CSR_API(SrvGetConsoleAliases)
|
|||
|
||||
CSR_API(SrvGetConsoleAliasesLength)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETALLALIASESLENGTH GetAllAliasesLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAllAliasesLengthRequest;
|
||||
PCONSOLE Console;
|
||||
PALIAS_HEADER Header;
|
||||
|
@ -496,28 +497,34 @@ CSR_API(SrvGetConsoleAliasesLength)
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (GetAllAliasesLengthRequest->ExeName == NULL)
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
ApiMessage->Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||
if (!NT_SUCCESS(ApiMessage->Status))
|
||||
{
|
||||
return ApiMessage->Status;
|
||||
}
|
||||
// FIXME!! Convert GetAllAliasesLengthRequest->ExeName into UNICODE if Unicode2 is FALSE
|
||||
// and make use of GetAllAliasesLengthRequest->ExeLength
|
||||
|
||||
Header = IntFindAliasHeader(Console->Aliases, GetAllAliasesLengthRequest->ExeName);
|
||||
if (!Header)
|
||||
if (Header)
|
||||
{
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
Length = IntGetAllConsoleAliasesLength(Header);
|
||||
GetAllAliasesLengthRequest->Length = Length;
|
||||
|
||||
/*
|
||||
* Quick and dirty way of getting the number of bytes of the
|
||||
* corresponding ANSI string from the one in UNICODE.
|
||||
*/
|
||||
if (!GetAllAliasesLengthRequest->Unicode)
|
||||
GetAllAliasesLengthRequest->Length /= sizeof(WCHAR);
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Length = IntGetAllConsoleAliasesLength(Header);
|
||||
GetAllAliasesLengthRequest->Length = Length;
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
return STATUS_SUCCESS;
|
||||
return Status;
|
||||
}
|
||||
|
||||
CSR_API(SrvGetConsoleAliasExes)
|
||||
|
@ -530,7 +537,7 @@ CSR_API(SrvGetConsoleAliasExes)
|
|||
DPRINT("SrvGetConsoleAliasExes entered\n");
|
||||
|
||||
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||
(PVOID)&GetAliasesExesRequest->ExeNames,
|
||||
(PVOID*)&GetAliasesExesRequest->ExeNames,
|
||||
GetAliasesExesRequest->Length,
|
||||
sizeof(BYTE)))
|
||||
{
|
||||
|
@ -568,17 +575,24 @@ CSR_API(SrvGetConsoleAliasExes)
|
|||
|
||||
CSR_API(SrvGetConsoleAliasExesLength)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETALIASESEXESLENGTH GetAliasesExesLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAliasesExesLengthRequest;
|
||||
PCONSOLE Console;
|
||||
DPRINT("SrvGetConsoleAliasExesLength entered\n");
|
||||
|
||||
ApiMessage->Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||
if (NT_SUCCESS(ApiMessage->Status))
|
||||
{
|
||||
GetAliasesExesLengthRequest->Length = IntGetConsoleAliasesExesLength(Console->Aliases);
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
}
|
||||
return ApiMessage->Status;
|
||||
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
GetAliasesExesLengthRequest->Length = IntGetConsoleAliasesExesLength(Console->Aliases);
|
||||
|
||||
/*
|
||||
* Quick and dirty way of getting the number of bytes of the
|
||||
* corresponding ANSI string from the one in UNICODE.
|
||||
*/
|
||||
if (!GetAliasesExesLengthRequest->Unicode)
|
||||
GetAliasesExesLengthRequest->Length /= sizeof(WCHAR);
|
||||
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -455,158 +455,193 @@ LineInputKeyDown(PCONSOLE Console, KEY_EVENT_RECORD *KeyEvent)
|
|||
|
||||
CSR_API(SrvGetConsoleCommandHistory)
|
||||
{
|
||||
PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryRequest;
|
||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
PCONSOLE Console;
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryRequest;
|
||||
PCONSOLE Console;
|
||||
PHISTORY_BUFFER Hist;
|
||||
UNICODE_STRING ExeName;
|
||||
PBYTE Buffer = (PBYTE)GetCommandHistoryRequest->History;
|
||||
ULONG BufferSize = GetCommandHistoryRequest->Length;
|
||||
ULONG BufferSize = GetCommandHistoryRequest->HistoryLength;
|
||||
UINT i;
|
||||
|
||||
if ( !CsrValidateMessageBuffer(ApiMessage,
|
||||
(PVOID*)&GetCommandHistoryRequest->History,
|
||||
GetCommandHistoryRequest->Length,
|
||||
GetCommandHistoryRequest->HistoryLength,
|
||||
sizeof(BYTE)) ||
|
||||
!CsrValidateMessageBuffer(ApiMessage,
|
||||
(PVOID*)&GetCommandHistoryRequest->ExeName.Buffer,
|
||||
GetCommandHistoryRequest->ExeName.Length,
|
||||
(PVOID*)&GetCommandHistoryRequest->ExeName,
|
||||
GetCommandHistoryRequest->ExeLength,
|
||||
sizeof(BYTE)) )
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
|
||||
if (NT_SUCCESS(Status))
|
||||
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
// FIXME: convert to UNICODE if Unicode(2) == FALSE
|
||||
ExeName.Length = ExeName.MaximumLength = GetCommandHistoryRequest->ExeLength;
|
||||
ExeName.Buffer = GetCommandHistoryRequest->ExeName;
|
||||
|
||||
Hist = HistoryFindBuffer(Console, &ExeName);
|
||||
if (Hist)
|
||||
{
|
||||
Hist = HistoryFindBuffer(Console, &GetCommandHistoryRequest->ExeName);
|
||||
if (Hist)
|
||||
for (i = 0; i < Hist->NumEntries; i++)
|
||||
{
|
||||
for (i = 0; i < Hist->NumEntries; i++)
|
||||
if (BufferSize < (Hist->Entries[i].Length + sizeof(WCHAR)))
|
||||
{
|
||||
if (BufferSize < (Hist->Entries[i].Length + sizeof(WCHAR)))
|
||||
{
|
||||
Status = STATUS_BUFFER_OVERFLOW;
|
||||
break;
|
||||
}
|
||||
memcpy(Buffer, Hist->Entries[i].Buffer, Hist->Entries[i].Length);
|
||||
Buffer += Hist->Entries[i].Length;
|
||||
*(PWCHAR)Buffer = L'\0';
|
||||
Buffer += sizeof(WCHAR);
|
||||
Status = STATUS_BUFFER_OVERFLOW;
|
||||
break;
|
||||
}
|
||||
// FIXME: convert to UNICODE if Unicode == FALSE
|
||||
memcpy(Buffer, Hist->Entries[i].Buffer, Hist->Entries[i].Length);
|
||||
Buffer += Hist->Entries[i].Length;
|
||||
*(PWCHAR)Buffer = L'\0';
|
||||
Buffer += sizeof(WCHAR);
|
||||
|
||||
// {
|
||||
// WideCharToMultiByte(CP_ACP, 0,
|
||||
// GetCommandHistoryRequest->History,
|
||||
// GetCommandHistoryRequest->HistoryLength / sizeof(WCHAR),
|
||||
// lpHistory,
|
||||
// cbHistory,
|
||||
// NULL, NULL);
|
||||
// }
|
||||
|
||||
}
|
||||
GetCommandHistoryRequest->Length = Buffer - (PBYTE)GetCommandHistoryRequest->History;
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
}
|
||||
// FIXME: convert to UNICODE if Unicode == FALSE
|
||||
GetCommandHistoryRequest->HistoryLength = Buffer - (PBYTE)GetCommandHistoryRequest->History;
|
||||
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
return Status;
|
||||
}
|
||||
|
||||
CSR_API(SrvGetConsoleCommandHistoryLength)
|
||||
{
|
||||
PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryLengthRequest;
|
||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
PCONSOLE Console;
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryLengthRequest;
|
||||
PCONSOLE Console;
|
||||
PHISTORY_BUFFER Hist;
|
||||
UNICODE_STRING ExeName;
|
||||
ULONG Length = 0;
|
||||
UINT i;
|
||||
|
||||
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||
(PVOID*)&GetCommandHistoryLengthRequest->ExeName.Buffer,
|
||||
GetCommandHistoryLengthRequest->ExeName.Length,
|
||||
(PVOID*)&GetCommandHistoryLengthRequest->ExeName,
|
||||
GetCommandHistoryLengthRequest->ExeLength,
|
||||
sizeof(BYTE)))
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
|
||||
if (NT_SUCCESS(Status))
|
||||
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
// FIXME: convert to UNICODE if Unicode(2) == FALSE
|
||||
ExeName.Length = ExeName.MaximumLength = GetCommandHistoryLengthRequest->ExeLength;
|
||||
ExeName.Buffer = GetCommandHistoryLengthRequest->ExeName;
|
||||
|
||||
Hist = HistoryFindBuffer(Console, &ExeName);
|
||||
if (Hist)
|
||||
{
|
||||
Hist = HistoryFindBuffer(Console, &GetCommandHistoryLengthRequest->ExeName);
|
||||
if (Hist)
|
||||
{
|
||||
for (i = 0; i < Hist->NumEntries; i++)
|
||||
Length += Hist->Entries[i].Length + sizeof(WCHAR);
|
||||
}
|
||||
GetCommandHistoryLengthRequest->Length = Length;
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
for (i = 0; i < Hist->NumEntries; i++)
|
||||
Length += Hist->Entries[i].Length + sizeof(WCHAR);
|
||||
}
|
||||
GetCommandHistoryLengthRequest->HistoryLength = Length;
|
||||
|
||||
/*
|
||||
* Quick and dirty way of getting the number of bytes of the
|
||||
* corresponding ANSI string from the one in UNICODE.
|
||||
*/
|
||||
if (!GetCommandHistoryLengthRequest->Unicode)
|
||||
GetCommandHistoryLengthRequest->HistoryLength /= sizeof(WCHAR);
|
||||
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
return Status;
|
||||
}
|
||||
|
||||
CSR_API(SrvExpungeConsoleCommandHistory)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ExpungeCommandHistoryRequest;
|
||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
PCONSOLE Console;
|
||||
PHISTORY_BUFFER Hist;
|
||||
NTSTATUS Status;
|
||||
UNICODE_STRING ExeName;
|
||||
|
||||
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||
(PVOID*)&ExpungeCommandHistoryRequest->ExeName.Buffer,
|
||||
ExpungeCommandHistoryRequest->ExeName.Length,
|
||||
(PVOID*)&ExpungeCommandHistoryRequest->ExeName,
|
||||
ExpungeCommandHistoryRequest->ExeLength,
|
||||
sizeof(BYTE)))
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Hist = HistoryFindBuffer(Console, &ExpungeCommandHistoryRequest->ExeName);
|
||||
HistoryDeleteBuffer(Hist);
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
}
|
||||
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
// FIXME: convert to UNICODE if Unicode(2) == FALSE
|
||||
ExeName.Length = ExeName.MaximumLength = ExpungeCommandHistoryRequest->ExeLength;
|
||||
ExeName.Buffer = ExpungeCommandHistoryRequest->ExeName;
|
||||
|
||||
Hist = HistoryFindBuffer(Console, &ExeName);
|
||||
HistoryDeleteBuffer(Hist);
|
||||
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
return Status;
|
||||
}
|
||||
|
||||
CSR_API(SrvSetConsoleNumberOfCommands)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryNumberCommandsRequest;
|
||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
||||
PCONSOLE Console;
|
||||
PHISTORY_BUFFER Hist;
|
||||
NTSTATUS Status;
|
||||
UINT MaxEntries = SetHistoryNumberCommandsRequest->NumCommands;
|
||||
UNICODE_STRING ExeName;
|
||||
PUNICODE_STRING OldEntryList, NewEntryList;
|
||||
|
||||
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||
(PVOID*)&SetHistoryNumberCommandsRequest->ExeName.Buffer,
|
||||
SetHistoryNumberCommandsRequest->ExeName.Length,
|
||||
(PVOID*)&SetHistoryNumberCommandsRequest->ExeName,
|
||||
SetHistoryNumberCommandsRequest->ExeLength,
|
||||
sizeof(BYTE)))
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Hist = HistoryFindBuffer(Console, &SetHistoryNumberCommandsRequest->ExeName);
|
||||
if (Hist)
|
||||
{
|
||||
OldEntryList = Hist->Entries;
|
||||
NewEntryList = ConsoleAllocHeap(0, MaxEntries * sizeof(UNICODE_STRING));
|
||||
if (!NewEntryList)
|
||||
{
|
||||
Status = STATUS_NO_MEMORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If necessary, shrink by removing oldest entries */
|
||||
for (; Hist->NumEntries > MaxEntries; Hist->NumEntries--)
|
||||
{
|
||||
RtlFreeUnicodeString(Hist->Entries++);
|
||||
Hist->Position += (Hist->Position == 0);
|
||||
}
|
||||
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
Hist->MaxEntries = MaxEntries;
|
||||
Hist->Entries = memcpy(NewEntryList, Hist->Entries,
|
||||
Hist->NumEntries * sizeof(UNICODE_STRING));
|
||||
ConsoleFreeHeap(OldEntryList);
|
||||
}
|
||||
// FIXME: convert to UNICODE if Unicode(2) == FALSE
|
||||
ExeName.Length = ExeName.MaximumLength = SetHistoryNumberCommandsRequest->ExeLength;
|
||||
ExeName.Buffer = SetHistoryNumberCommandsRequest->ExeName;
|
||||
|
||||
Hist = HistoryFindBuffer(Console, &ExeName);
|
||||
if (Hist)
|
||||
{
|
||||
OldEntryList = Hist->Entries;
|
||||
NewEntryList = ConsoleAllocHeap(0, MaxEntries * sizeof(UNICODE_STRING));
|
||||
if (!NewEntryList)
|
||||
{
|
||||
Status = STATUS_NO_MEMORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If necessary, shrink by removing oldest entries */
|
||||
for (; Hist->NumEntries > MaxEntries; Hist->NumEntries--)
|
||||
{
|
||||
RtlFreeUnicodeString(Hist->Entries++);
|
||||
Hist->Position += (Hist->Position == 0);
|
||||
}
|
||||
|
||||
Hist->MaxEntries = MaxEntries;
|
||||
Hist->Entries = memcpy(NewEntryList, Hist->Entries,
|
||||
Hist->NumEntries * sizeof(UNICODE_STRING));
|
||||
ConsoleFreeHeap(OldEntryList);
|
||||
}
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
}
|
||||
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -642,8 +677,21 @@ CSR_API(SrvSetConsoleHistory)
|
|||
|
||||
CSR_API(SrvSetConsoleCommandHistoryMode)
|
||||
{
|
||||
DPRINT1("%s not yet implemented\n", __FUNCTION__);
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_SETHISTORYMODE SetHistoryModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryModeRequest;
|
||||
PCONSOLE Console;
|
||||
|
||||
DPRINT1("SrvSetConsoleCommandHistoryMode(Mode = %d) is not yet implemented\n",
|
||||
SetHistoryModeRequest->Mode);
|
||||
|
||||
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
/* This API is not yet implemented */
|
||||
Status = STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Reference in a new issue