mirror of
https://github.com/reactos/reactos.git
synced 2024-07-31 08:39:05 +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
|
@ -387,30 +387,24 @@ GetConsoleAliasesA(LPSTR AliasBuffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
static DWORD
|
||||||
* @implemented
|
IntGetConsoleAliasesLength(LPVOID lpExeName, DWORD dwNumChars, BOOLEAN bUnicode)
|
||||||
*/
|
|
||||||
DWORD
|
|
||||||
WINAPI
|
|
||||||
GetConsoleAliasesLengthW(LPWSTR lpExeName)
|
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
|
||||||
CONSOLE_API_MESSAGE ApiMessage;
|
CONSOLE_API_MESSAGE ApiMessage;
|
||||||
PCONSOLE_GETALLALIASESLENGTH GetAllAliasesLengthRequest = &ApiMessage.Data.GetAllAliasesLengthRequest;
|
PCONSOLE_GETALLALIASESLENGTH GetAllAliasesLengthRequest = &ApiMessage.Data.GetAllAliasesLengthRequest;
|
||||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||||
|
|
||||||
DPRINT("GetConsoleAliasesLengthW entered\n");
|
if (lpExeName == NULL || dwNumChars == 0)
|
||||||
|
|
||||||
if (lpExeName == NULL)
|
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetAllAliasesLengthRequest->ExeLength = (wcslen(lpExeName) + 1) * sizeof(WCHAR);
|
GetAllAliasesLengthRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||||
GetAllAliasesLengthRequest->Length = 0;
|
GetAllAliasesLengthRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
|
||||||
|
GetAllAliasesLengthRequest->Unicode =
|
||||||
|
GetAllAliasesLengthRequest->Unicode2 = bUnicode;
|
||||||
|
|
||||||
/* Allocate a Capture Buffer */
|
|
||||||
CaptureBuffer = CsrAllocateCaptureBuffer(1, GetAllAliasesLengthRequest->ExeLength);
|
CaptureBuffer = CsrAllocateCaptureBuffer(1, GetAllAliasesLengthRequest->ExeLength);
|
||||||
if (!CaptureBuffer)
|
if (!CaptureBuffer)
|
||||||
{
|
{
|
||||||
|
@ -419,22 +413,21 @@ GetConsoleAliasesLengthW(LPWSTR lpExeName)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Capture the exe name */
|
|
||||||
CsrCaptureMessageBuffer(CaptureBuffer,
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||||
(PVOID)lpExeName,
|
(PVOID)lpExeName,
|
||||||
GetAllAliasesLengthRequest->ExeLength,
|
GetAllAliasesLengthRequest->ExeLength,
|
||||||
(PVOID)&GetAllAliasesLengthRequest->ExeName);
|
(PVOID)&GetAllAliasesLengthRequest->ExeName);
|
||||||
|
|
||||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||||
CaptureBuffer,
|
CaptureBuffer,
|
||||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasesLength),
|
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasesLength),
|
||||||
sizeof(CONSOLE_GETALLALIASESLENGTH));
|
sizeof(*GetAllAliasesLengthRequest));
|
||||||
|
|
||||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(ApiMessage.Status))
|
||||||
{
|
{
|
||||||
BaseSetLastNTError(Status);
|
BaseSetLastNTError(ApiMessage.Status);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,26 +440,80 @@ GetConsoleAliasesLengthW(LPWSTR lpExeName)
|
||||||
*/
|
*/
|
||||||
DWORD
|
DWORD
|
||||||
WINAPI
|
WINAPI
|
||||||
GetConsoleAliasesLengthA(LPSTR lpExeName)
|
GetConsoleAliasesLengthW(LPWSTR lpExeName)
|
||||||
{
|
{
|
||||||
DWORD dwRetVal = 0;
|
if (lpExeName == NULL)
|
||||||
LPWSTR lpExeNameW = NULL;
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (lpExeName)
|
return IntGetConsoleAliasesLength(lpExeName, wcslen(lpExeName), TRUE);
|
||||||
BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*)&lpExeNameW);
|
|
||||||
|
|
||||||
dwRetVal = GetConsoleAliasesLengthW(lpExeNameW);
|
|
||||||
if (dwRetVal)
|
|
||||||
dwRetVal /= sizeof(WCHAR);
|
|
||||||
|
|
||||||
/* Clean up */
|
|
||||||
if (lpExeNameW)
|
|
||||||
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpExeNameW);
|
|
||||||
|
|
||||||
return dwRetVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @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
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -475,49 +522,7 @@ WINAPI
|
||||||
GetConsoleAliasExesW(LPWSTR lpExeNameBuffer,
|
GetConsoleAliasExesW(LPWSTR lpExeNameBuffer,
|
||||||
DWORD ExeNameBufferLength)
|
DWORD ExeNameBufferLength)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
return IntGetConsoleAliasExes(lpExeNameBuffer, ExeNameBufferLength, TRUE);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -529,46 +534,26 @@ WINAPI
|
||||||
GetConsoleAliasExesA(LPSTR lpExeNameBuffer,
|
GetConsoleAliasExesA(LPSTR lpExeNameBuffer,
|
||||||
DWORD ExeNameBufferLength)
|
DWORD ExeNameBufferLength)
|
||||||
{
|
{
|
||||||
LPWSTR lpwExeNameBuffer;
|
return IntGetConsoleAliasExes(lpExeNameBuffer, ExeNameBufferLength, FALSE);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
static DWORD
|
||||||
* @implemented
|
IntGetConsoleAliasExesLength(BOOLEAN bUnicode)
|
||||||
*/
|
|
||||||
DWORD
|
|
||||||
WINAPI
|
|
||||||
GetConsoleAliasExesLengthW(VOID)
|
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
|
||||||
CONSOLE_API_MESSAGE ApiMessage;
|
CONSOLE_API_MESSAGE ApiMessage;
|
||||||
PCONSOLE_GETALIASESEXESLENGTH GetAliasesExesLengthRequest = &ApiMessage.Data.GetAliasesExesLengthRequest;
|
PCONSOLE_GETALIASESEXESLENGTH GetAliasesExesLengthRequest = &ApiMessage.Data.GetAliasesExesLengthRequest;
|
||||||
|
|
||||||
DPRINT("GetConsoleAliasExesLengthW entered\n");
|
GetAliasesExesLengthRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||||
|
GetAliasesExesLengthRequest->Unicode = bUnicode;
|
||||||
|
|
||||||
GetAliasesExesLengthRequest->Length = 0;
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||||
|
NULL,
|
||||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasExesLength),
|
||||||
NULL,
|
sizeof(*GetAliasesExesLengthRequest));
|
||||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasExesLength),
|
if (!NT_SUCCESS(ApiMessage.Status))
|
||||||
sizeof(CONSOLE_GETALIASESEXESLENGTH));
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
BaseSetLastNTError(Status);
|
BaseSetLastNTError(ApiMessage.Status);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,6 +561,17 @@ GetConsoleAliasExesLengthW(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
DWORD
|
||||||
|
WINAPI
|
||||||
|
GetConsoleAliasExesLengthW(VOID)
|
||||||
|
{
|
||||||
|
return IntGetConsoleAliasExesLength(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -583,16 +579,7 @@ DWORD
|
||||||
WINAPI
|
WINAPI
|
||||||
GetConsoleAliasExesLengthA(VOID)
|
GetConsoleAliasExesLengthA(VOID)
|
||||||
{
|
{
|
||||||
DWORD dwLength;
|
return IntGetConsoleAliasExesLength(FALSE);
|
||||||
|
|
||||||
DPRINT("GetConsoleAliasExesLengthA entered\n");
|
|
||||||
|
|
||||||
dwLength = GetConsoleAliasExesLengthW();
|
|
||||||
|
|
||||||
if (dwLength)
|
|
||||||
dwLength /= sizeof(WCHAR);
|
|
||||||
|
|
||||||
return dwLength;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1496,18 +1496,17 @@ SetConsoleScreenBufferSize(HANDLE hConsoleOutput,
|
||||||
static
|
static
|
||||||
BOOL
|
BOOL
|
||||||
IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput,
|
IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput,
|
||||||
const SMALL_RECT *lpScrollRectangle,
|
CONST SMALL_RECT* lpScrollRectangle,
|
||||||
const SMALL_RECT *lpClipRectangle,
|
CONST SMALL_RECT* lpClipRectangle,
|
||||||
COORD dwDestinationOrigin,
|
COORD dwDestinationOrigin,
|
||||||
const CHAR_INFO *lpFill,
|
CONST CHAR_INFO* lpFill,
|
||||||
BOOL bUnicode)
|
BOOL bUnicode)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
|
||||||
CONSOLE_API_MESSAGE ApiMessage;
|
CONSOLE_API_MESSAGE ApiMessage;
|
||||||
PCONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest = &ApiMessage.Data.ScrollScreenBufferRequest;
|
PCONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest = &ApiMessage.Data.ScrollScreenBufferRequest;
|
||||||
|
|
||||||
ScrollScreenBufferRequest->OutputHandle = hConsoleOutput;
|
ScrollScreenBufferRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||||
ScrollScreenBufferRequest->Unicode = bUnicode;
|
ScrollScreenBufferRequest->OutputHandle = hConsoleOutput;
|
||||||
ScrollScreenBufferRequest->ScrollRectangle = *lpScrollRectangle;
|
ScrollScreenBufferRequest->ScrollRectangle = *lpScrollRectangle;
|
||||||
|
|
||||||
if (lpClipRectangle != NULL)
|
if (lpClipRectangle != NULL)
|
||||||
|
@ -1521,16 +1520,16 @@ IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput,
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollScreenBufferRequest->DestinationOrigin = dwDestinationOrigin;
|
ScrollScreenBufferRequest->DestinationOrigin = dwDestinationOrigin;
|
||||||
ScrollScreenBufferRequest->Fill = *lpFill;
|
ScrollScreenBufferRequest->Fill = *lpFill;
|
||||||
|
ScrollScreenBufferRequest->Unicode = bUnicode;
|
||||||
|
|
||||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||||
NULL,
|
NULL,
|
||||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepScrollScreenBuffer),
|
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepScrollScreenBuffer),
|
||||||
sizeof(CONSOLE_SCROLLSCREENBUFFER));
|
sizeof(*ScrollScreenBufferRequest));
|
||||||
|
if (!NT_SUCCESS(ApiMessage.Status))
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
BaseSetLastNTError(Status);
|
BaseSetLastNTError(ApiMessage.Status);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1546,16 +1545,16 @@ IntScrollConsoleScreenBuffer(HANDLE hConsoleOutput,
|
||||||
BOOL
|
BOOL
|
||||||
WINAPI
|
WINAPI
|
||||||
ScrollConsoleScreenBufferA(HANDLE hConsoleOutput,
|
ScrollConsoleScreenBufferA(HANDLE hConsoleOutput,
|
||||||
CONST SMALL_RECT *lpScrollRectangle,
|
CONST SMALL_RECT* lpScrollRectangle,
|
||||||
CONST SMALL_RECT *lpClipRectangle,
|
CONST SMALL_RECT* lpClipRectangle,
|
||||||
COORD dwDestinationOrigin,
|
COORD dwDestinationOrigin,
|
||||||
CONST CHAR_INFO *lpFill)
|
CONST CHAR_INFO* lpFill)
|
||||||
{
|
{
|
||||||
return IntScrollConsoleScreenBuffer(hConsoleOutput,
|
return IntScrollConsoleScreenBuffer(hConsoleOutput,
|
||||||
(PSMALL_RECT)lpScrollRectangle,
|
lpScrollRectangle,
|
||||||
(PSMALL_RECT)lpClipRectangle,
|
lpClipRectangle,
|
||||||
dwDestinationOrigin,
|
dwDestinationOrigin,
|
||||||
(PCHAR_INFO)lpFill,
|
lpFill,
|
||||||
FALSE);
|
FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,14 @@
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS **********************************************************/
|
/* PRIVATE FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* Get the size needed to copy a string to a capture buffer, including alignment */
|
/* Get the size needed to copy a string to a capture buffer, including alignment */
|
||||||
static ULONG
|
static ULONG
|
||||||
IntStringSize(LPCVOID String,
|
IntStringSize(LPCVOID String,
|
||||||
BOOL Unicode)
|
BOOL Unicode)
|
||||||
{
|
{
|
||||||
ULONG Size = (Unicode ? wcslen(String) : strlen(String)) * sizeof(WCHAR);
|
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;
|
RequestString->Length = RequestString->MaximumLength = (USHORT)Size;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static VOID
|
||||||
static BOOL
|
IntExpungeConsoleCommandHistory(LPCVOID lpExeName, DWORD dwNumChars, BOOLEAN bUnicode)
|
||||||
IntExpungeConsoleCommandHistory(LPCVOID lpExeName, BOOL bUnicode)
|
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
|
||||||
CONSOLE_API_MESSAGE ApiMessage;
|
CONSOLE_API_MESSAGE ApiMessage;
|
||||||
PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &ApiMessage.Data.ExpungeCommandHistoryRequest;
|
PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &ApiMessage.Data.ExpungeCommandHistoryRequest;
|
||||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||||
|
|
||||||
if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName))
|
if (lpExeName == NULL || dwNumChars == 0)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
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)
|
if (!CaptureBuffer)
|
||||||
{
|
{
|
||||||
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
return FALSE;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
// IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
||||||
&ExpungeCommandHistoryRequest->ExeName);
|
// &ExpungeCommandHistoryRequest->ExeName);
|
||||||
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||||
|
(PVOID)lpExeName,
|
||||||
|
ExpungeCommandHistoryRequest->ExeLength,
|
||||||
|
(PVOID)&ExpungeCommandHistoryRequest->ExeName);
|
||||||
|
|
||||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||||
CaptureBuffer,
|
CaptureBuffer,
|
||||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepExpungeCommandHistory),
|
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepExpungeCommandHistory),
|
||||||
sizeof(CONSOLE_EXPUNGECOMMANDHISTORY));
|
sizeof(*ExpungeCommandHistoryRequest));
|
||||||
|
|
||||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(ApiMessage.Status))
|
||||||
{
|
BaseSetLastNTError(ApiMessage.Status);
|
||||||
BaseSetLastNTError(Status);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static DWORD
|
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;
|
CONSOLE_API_MESSAGE ApiMessage;
|
||||||
PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &ApiMessage.Data.GetCommandHistoryRequest;
|
PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &ApiMessage.Data.GetCommandHistoryRequest;
|
||||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
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);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CaptureBuffer = CsrAllocateCaptureBuffer(2, IntStringSize(lpExeName, bUnicode) +
|
GetCommandHistoryRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||||
HistoryLength);
|
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)
|
if (!CaptureBuffer)
|
||||||
{
|
{
|
||||||
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
||||||
|
@ -116,60 +127,58 @@ IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
// IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
||||||
&GetCommandHistoryRequest->ExeName);
|
// &GetCommandHistoryRequest->ExeName);
|
||||||
GetCommandHistoryRequest->Length = HistoryLength;
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||||
CsrAllocateMessagePointer(CaptureBuffer, HistoryLength,
|
(PVOID)lpExeName,
|
||||||
|
GetCommandHistoryRequest->ExeLength,
|
||||||
|
(PVOID)&GetCommandHistoryRequest->ExeName);
|
||||||
|
|
||||||
|
// CsrAllocateMessagePointer(CaptureBuffer, HistoryLength,
|
||||||
|
CsrAllocateMessagePointer(CaptureBuffer, GetCommandHistoryRequest->HistoryLength,
|
||||||
(PVOID*)&GetCommandHistoryRequest->History);
|
(PVOID*)&GetCommandHistoryRequest->History);
|
||||||
|
|
||||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||||
CaptureBuffer,
|
CaptureBuffer,
|
||||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCommandHistory),
|
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCommandHistory),
|
||||||
sizeof(CONSOLE_GETCOMMANDHISTORY));
|
sizeof(*GetCommandHistoryRequest));
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(ApiMessage.Status))
|
||||||
{
|
{
|
||||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||||
BaseSetLastNTError(Status);
|
BaseSetLastNTError(ApiMessage.Status);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bUnicode)
|
memcpy(lpHistory,
|
||||||
{
|
GetCommandHistoryRequest->History,
|
||||||
memcpy(lpHistory,
|
GetCommandHistoryRequest->HistoryLength);
|
||||||
GetCommandHistoryRequest->History,
|
|
||||||
GetCommandHistoryRequest->Length);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WideCharToMultiByte(CP_ACP, 0,
|
|
||||||
GetCommandHistoryRequest->History,
|
|
||||||
GetCommandHistoryRequest->Length / sizeof(WCHAR),
|
|
||||||
lpHistory,
|
|
||||||
cbHistory,
|
|
||||||
NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||||
|
|
||||||
return GetCommandHistoryRequest->Length;
|
return GetCommandHistoryRequest->HistoryLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static DWORD
|
static DWORD
|
||||||
IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, BOOL bUnicode)
|
IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, DWORD dwNumChars, BOOL bUnicode)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
|
||||||
CONSOLE_API_MESSAGE ApiMessage;
|
CONSOLE_API_MESSAGE ApiMessage;
|
||||||
PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &ApiMessage.Data.GetCommandHistoryLengthRequest;
|
PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &ApiMessage.Data.GetCommandHistoryLengthRequest;
|
||||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||||
|
|
||||||
if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName))
|
if (lpExeName == NULL || dwNumChars == 0)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return 0;
|
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)
|
if (!CaptureBuffer)
|
||||||
{
|
{
|
||||||
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
||||||
|
@ -177,43 +186,54 @@ IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, BOOL bUnicode)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
// IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
||||||
&GetCommandHistoryLengthRequest->ExeName);
|
// &GetCommandHistoryLengthRequest->ExeName);
|
||||||
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||||
|
(PVOID)lpExeName,
|
||||||
|
GetCommandHistoryLengthRequest->ExeLength,
|
||||||
|
(PVOID)&GetCommandHistoryLengthRequest->ExeName);
|
||||||
|
|
||||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||||
CaptureBuffer,
|
CaptureBuffer,
|
||||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCommandHistoryLength),
|
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCommandHistoryLength),
|
||||||
sizeof(CONSOLE_GETCOMMANDHISTORYLENGTH));
|
sizeof(*GetCommandHistoryLengthRequest));
|
||||||
|
|
||||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(ApiMessage.Status))
|
||||||
{
|
{
|
||||||
BaseSetLastNTError(Status);
|
BaseSetLastNTError(ApiMessage.Status);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetCommandHistoryLengthRequest->Length;
|
return GetCommandHistoryLengthRequest->HistoryLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
IntSetConsoleNumberOfCommands(DWORD dwNumCommands,
|
IntSetConsoleNumberOfCommands(DWORD dwNumCommands,
|
||||||
LPCVOID lpExeName,
|
LPCVOID lpExeName,
|
||||||
BOOL bUnicode)
|
DWORD dwNumChars,
|
||||||
|
BOOLEAN bUnicode)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
|
||||||
CONSOLE_API_MESSAGE ApiMessage;
|
CONSOLE_API_MESSAGE ApiMessage;
|
||||||
PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &ApiMessage.Data.SetHistoryNumberCommandsRequest;
|
PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &ApiMessage.Data.SetHistoryNumberCommandsRequest;
|
||||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||||
|
|
||||||
if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName))
|
if (lpExeName == NULL || dwNumChars == 0)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
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)
|
if (!CaptureBuffer)
|
||||||
{
|
{
|
||||||
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
DPRINT1("CsrAllocateCaptureBuffer failed!\n");
|
||||||
|
@ -221,20 +241,23 @@ IntSetConsoleNumberOfCommands(DWORD dwNumCommands,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
// IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
|
||||||
&SetHistoryNumberCommandsRequest->ExeName);
|
// &SetHistoryNumberCommandsRequest->ExeName);
|
||||||
SetHistoryNumberCommandsRequest->NumCommands = dwNumCommands;
|
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||||
|
(PVOID)lpExeName,
|
||||||
|
SetHistoryNumberCommandsRequest->ExeLength,
|
||||||
|
(PVOID)&SetHistoryNumberCommandsRequest->ExeName);
|
||||||
|
|
||||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||||
CaptureBuffer,
|
CaptureBuffer,
|
||||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetNumberOfCommands),
|
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetNumberOfCommands),
|
||||||
sizeof(CONSOLE_SETHISTORYNUMBERCOMMANDS));
|
sizeof(*SetHistoryNumberCommandsRequest));
|
||||||
|
|
||||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(ApiMessage.Status))
|
||||||
{
|
{
|
||||||
BaseSetLastNTError(Status);
|
BaseSetLastNTError(ApiMessage.Status);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,22 +270,34 @@ IntSetConsoleNumberOfCommands(DWORD dwNumCommands,
|
||||||
/*
|
/*
|
||||||
* @implemented (Undocumented)
|
* @implemented (Undocumented)
|
||||||
*/
|
*/
|
||||||
BOOL
|
VOID
|
||||||
WINAPI
|
WINAPI
|
||||||
ExpungeConsoleCommandHistoryW(LPCWSTR lpExeName)
|
ExpungeConsoleCommandHistoryW(LPCWSTR lpExeName)
|
||||||
{
|
{
|
||||||
return IntExpungeConsoleCommandHistory(lpExeName, TRUE);
|
if (lpExeName == NULL)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IntExpungeConsoleCommandHistory(lpExeName, wcslen(lpExeName), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented (Undocumented)
|
* @implemented (Undocumented)
|
||||||
*/
|
*/
|
||||||
BOOL
|
VOID
|
||||||
WINAPI
|
WINAPI
|
||||||
ExpungeConsoleCommandHistoryA(LPCSTR lpExeName)
|
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,
|
DWORD cbHistory,
|
||||||
LPCWSTR lpExeName)
|
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,
|
DWORD cbHistory,
|
||||||
LPCSTR lpExeName)
|
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
|
WINAPI
|
||||||
GetConsoleCommandHistoryLengthW(LPCWSTR lpExeName)
|
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
|
WINAPI
|
||||||
GetConsoleCommandHistoryLengthA(LPCSTR lpExeName)
|
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
|
BOOL
|
||||||
WINAPI
|
WINAPI
|
||||||
SetConsoleNumberOfCommandsW(DWORD dwNumCommands,
|
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
|
BOOL
|
||||||
WINAPI
|
WINAPI
|
||||||
SetConsoleNumberOfCommandsA(DWORD dwNumCommands,
|
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
|
BOOL
|
||||||
WINAPI
|
WINAPI
|
||||||
SetConsoleCommandHistoryMode(IN DWORD dwMode)
|
SetConsoleCommandHistoryMode(IN DWORD dwMode)
|
||||||
{
|
{
|
||||||
STUB;
|
CONSOLE_API_MESSAGE ApiMessage;
|
||||||
return FALSE;
|
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 */
|
/* EOF */
|
||||||
|
|
|
@ -701,20 +701,35 @@ typedef struct
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
UNICODE_STRING ExeName;
|
HANDLE ConsoleHandle;
|
||||||
PWCHAR History;
|
ULONG HistoryLength;
|
||||||
DWORD Length;
|
PVOID History;
|
||||||
|
// UNICODE_STRING ExeName;
|
||||||
|
USHORT ExeLength;
|
||||||
|
PVOID ExeName;
|
||||||
|
BOOLEAN Unicode;
|
||||||
|
BOOLEAN Unicode2;
|
||||||
} CONSOLE_GETCOMMANDHISTORY, *PCONSOLE_GETCOMMANDHISTORY;
|
} CONSOLE_GETCOMMANDHISTORY, *PCONSOLE_GETCOMMANDHISTORY;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
UNICODE_STRING ExeName;
|
HANDLE ConsoleHandle;
|
||||||
DWORD Length;
|
ULONG HistoryLength;
|
||||||
|
// UNICODE_STRING ExeName;
|
||||||
|
USHORT ExeLength;
|
||||||
|
PVOID ExeName;
|
||||||
|
BOOLEAN Unicode;
|
||||||
|
BOOLEAN Unicode2;
|
||||||
} CONSOLE_GETCOMMANDHISTORYLENGTH, *PCONSOLE_GETCOMMANDHISTORYLENGTH;
|
} CONSOLE_GETCOMMANDHISTORYLENGTH, *PCONSOLE_GETCOMMANDHISTORYLENGTH;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
UNICODE_STRING ExeName;
|
HANDLE ConsoleHandle;
|
||||||
|
// UNICODE_STRING ExeName;
|
||||||
|
USHORT ExeLength;
|
||||||
|
PVOID ExeName;
|
||||||
|
BOOLEAN Unicode;
|
||||||
|
BOOLEAN Unicode2;
|
||||||
} CONSOLE_EXPUNGECOMMANDHISTORY, *PCONSOLE_EXPUNGECOMMANDHISTORY;
|
} CONSOLE_EXPUNGECOMMANDHISTORY, *PCONSOLE_EXPUNGECOMMANDHISTORY;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -726,8 +741,13 @@ typedef struct
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
UNICODE_STRING ExeName;
|
HANDLE ConsoleHandle;
|
||||||
DWORD NumCommands;
|
ULONG NumCommands;
|
||||||
|
// UNICODE_STRING ExeName;
|
||||||
|
USHORT ExeLength;
|
||||||
|
PVOID ExeName;
|
||||||
|
BOOLEAN Unicode;
|
||||||
|
BOOLEAN Unicode2;
|
||||||
} CONSOLE_SETHISTORYNUMBERCOMMANDS, *PCONSOLE_SETHISTORYNUMBERCOMMANDS;
|
} CONSOLE_SETHISTORYNUMBERCOMMANDS, *PCONSOLE_SETHISTORYNUMBERCOMMANDS;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -483,6 +483,7 @@ CSR_API(SrvGetConsoleAliases)
|
||||||
|
|
||||||
CSR_API(SrvGetConsoleAliasesLength)
|
CSR_API(SrvGetConsoleAliasesLength)
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
PCONSOLE_GETALLALIASESLENGTH GetAllAliasesLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAllAliasesLengthRequest;
|
PCONSOLE_GETALLALIASESLENGTH GetAllAliasesLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAllAliasesLengthRequest;
|
||||||
PCONSOLE Console;
|
PCONSOLE Console;
|
||||||
PALIAS_HEADER Header;
|
PALIAS_HEADER Header;
|
||||||
|
@ -496,28 +497,34 @@ CSR_API(SrvGetConsoleAliasesLength)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetAllAliasesLengthRequest->ExeName == NULL)
|
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||||
{
|
if (!NT_SUCCESS(Status)) return Status;
|
||||||
return STATUS_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApiMessage->Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
// FIXME!! Convert GetAllAliasesLengthRequest->ExeName into UNICODE if Unicode2 is FALSE
|
||||||
if (!NT_SUCCESS(ApiMessage->Status))
|
// and make use of GetAllAliasesLengthRequest->ExeLength
|
||||||
{
|
|
||||||
return ApiMessage->Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
Header = IntFindAliasHeader(Console->Aliases, GetAllAliasesLengthRequest->ExeName);
|
Header = IntFindAliasHeader(Console->Aliases, GetAllAliasesLengthRequest->ExeName);
|
||||||
if (!Header)
|
if (Header)
|
||||||
{
|
{
|
||||||
ConSrvReleaseConsole(Console, TRUE);
|
Length = IntGetAllConsoleAliasesLength(Header);
|
||||||
return STATUS_INVALID_PARAMETER;
|
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);
|
ConSrvReleaseConsole(Console, TRUE);
|
||||||
return STATUS_SUCCESS;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSR_API(SrvGetConsoleAliasExes)
|
CSR_API(SrvGetConsoleAliasExes)
|
||||||
|
@ -530,7 +537,7 @@ CSR_API(SrvGetConsoleAliasExes)
|
||||||
DPRINT("SrvGetConsoleAliasExes entered\n");
|
DPRINT("SrvGetConsoleAliasExes entered\n");
|
||||||
|
|
||||||
if (!CsrValidateMessageBuffer(ApiMessage,
|
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||||
(PVOID)&GetAliasesExesRequest->ExeNames,
|
(PVOID*)&GetAliasesExesRequest->ExeNames,
|
||||||
GetAliasesExesRequest->Length,
|
GetAliasesExesRequest->Length,
|
||||||
sizeof(BYTE)))
|
sizeof(BYTE)))
|
||||||
{
|
{
|
||||||
|
@ -568,17 +575,24 @@ CSR_API(SrvGetConsoleAliasExes)
|
||||||
|
|
||||||
CSR_API(SrvGetConsoleAliasExesLength)
|
CSR_API(SrvGetConsoleAliasExesLength)
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
PCONSOLE_GETALIASESEXESLENGTH GetAliasesExesLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAliasesExesLengthRequest;
|
PCONSOLE_GETALIASESEXESLENGTH GetAliasesExesLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAliasesExesLengthRequest;
|
||||||
PCONSOLE Console;
|
PCONSOLE Console;
|
||||||
DPRINT("SrvGetConsoleAliasExesLength entered\n");
|
|
||||||
|
|
||||||
ApiMessage->Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||||
if (NT_SUCCESS(ApiMessage->Status))
|
if (!NT_SUCCESS(Status)) return Status;
|
||||||
{
|
|
||||||
GetAliasesExesLengthRequest->Length = IntGetConsoleAliasesExesLength(Console->Aliases);
|
GetAliasesExesLengthRequest->Length = IntGetConsoleAliasesExesLength(Console->Aliases);
|
||||||
ConSrvReleaseConsole(Console, TRUE);
|
|
||||||
}
|
/*
|
||||||
return ApiMessage->Status;
|
* 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 */
|
/* EOF */
|
||||||
|
|
|
@ -455,158 +455,193 @@ LineInputKeyDown(PCONSOLE Console, KEY_EVENT_RECORD *KeyEvent)
|
||||||
|
|
||||||
CSR_API(SrvGetConsoleCommandHistory)
|
CSR_API(SrvGetConsoleCommandHistory)
|
||||||
{
|
{
|
||||||
PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryRequest;
|
|
||||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
|
||||||
PCONSOLE Console;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryRequest;
|
||||||
|
PCONSOLE Console;
|
||||||
PHISTORY_BUFFER Hist;
|
PHISTORY_BUFFER Hist;
|
||||||
|
UNICODE_STRING ExeName;
|
||||||
PBYTE Buffer = (PBYTE)GetCommandHistoryRequest->History;
|
PBYTE Buffer = (PBYTE)GetCommandHistoryRequest->History;
|
||||||
ULONG BufferSize = GetCommandHistoryRequest->Length;
|
ULONG BufferSize = GetCommandHistoryRequest->HistoryLength;
|
||||||
UINT i;
|
UINT i;
|
||||||
|
|
||||||
if ( !CsrValidateMessageBuffer(ApiMessage,
|
if ( !CsrValidateMessageBuffer(ApiMessage,
|
||||||
(PVOID*)&GetCommandHistoryRequest->History,
|
(PVOID*)&GetCommandHistoryRequest->History,
|
||||||
GetCommandHistoryRequest->Length,
|
GetCommandHistoryRequest->HistoryLength,
|
||||||
sizeof(BYTE)) ||
|
sizeof(BYTE)) ||
|
||||||
!CsrValidateMessageBuffer(ApiMessage,
|
!CsrValidateMessageBuffer(ApiMessage,
|
||||||
(PVOID*)&GetCommandHistoryRequest->ExeName.Buffer,
|
(PVOID*)&GetCommandHistoryRequest->ExeName,
|
||||||
GetCommandHistoryRequest->ExeName.Length,
|
GetCommandHistoryRequest->ExeLength,
|
||||||
sizeof(BYTE)) )
|
sizeof(BYTE)) )
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
|
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||||
if (NT_SUCCESS(Status))
|
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);
|
for (i = 0; i < Hist->NumEntries; i++)
|
||||||
if (Hist)
|
|
||||||
{
|
{
|
||||||
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;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
// 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;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSR_API(SrvGetConsoleCommandHistoryLength)
|
CSR_API(SrvGetConsoleCommandHistoryLength)
|
||||||
{
|
{
|
||||||
PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryLengthRequest;
|
|
||||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
|
||||||
PCONSOLE Console;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryLengthRequest;
|
||||||
|
PCONSOLE Console;
|
||||||
PHISTORY_BUFFER Hist;
|
PHISTORY_BUFFER Hist;
|
||||||
|
UNICODE_STRING ExeName;
|
||||||
ULONG Length = 0;
|
ULONG Length = 0;
|
||||||
UINT i;
|
UINT i;
|
||||||
|
|
||||||
if (!CsrValidateMessageBuffer(ApiMessage,
|
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||||
(PVOID*)&GetCommandHistoryLengthRequest->ExeName.Buffer,
|
(PVOID*)&GetCommandHistoryLengthRequest->ExeName,
|
||||||
GetCommandHistoryLengthRequest->ExeName.Length,
|
GetCommandHistoryLengthRequest->ExeLength,
|
||||||
sizeof(BYTE)))
|
sizeof(BYTE)))
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
|
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||||
if (NT_SUCCESS(Status))
|
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);
|
for (i = 0; i < Hist->NumEntries; i++)
|
||||||
if (Hist)
|
Length += Hist->Entries[i].Length + sizeof(WCHAR);
|
||||||
{
|
|
||||||
for (i = 0; i < Hist->NumEntries; i++)
|
|
||||||
Length += Hist->Entries[i].Length + sizeof(WCHAR);
|
|
||||||
}
|
|
||||||
GetCommandHistoryLengthRequest->Length = Length;
|
|
||||||
ConSrvReleaseConsole(Console, TRUE);
|
|
||||||
}
|
}
|
||||||
|
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;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSR_API(SrvExpungeConsoleCommandHistory)
|
CSR_API(SrvExpungeConsoleCommandHistory)
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ExpungeCommandHistoryRequest;
|
PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ExpungeCommandHistoryRequest;
|
||||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
|
||||||
PCONSOLE Console;
|
PCONSOLE Console;
|
||||||
PHISTORY_BUFFER Hist;
|
PHISTORY_BUFFER Hist;
|
||||||
NTSTATUS Status;
|
UNICODE_STRING ExeName;
|
||||||
|
|
||||||
if (!CsrValidateMessageBuffer(ApiMessage,
|
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||||
(PVOID*)&ExpungeCommandHistoryRequest->ExeName.Buffer,
|
(PVOID*)&ExpungeCommandHistoryRequest->ExeName,
|
||||||
ExpungeCommandHistoryRequest->ExeName.Length,
|
ExpungeCommandHistoryRequest->ExeLength,
|
||||||
sizeof(BYTE)))
|
sizeof(BYTE)))
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
|
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||||
if (NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status)) return Status;
|
||||||
{
|
|
||||||
Hist = HistoryFindBuffer(Console, &ExpungeCommandHistoryRequest->ExeName);
|
// FIXME: convert to UNICODE if Unicode(2) == FALSE
|
||||||
HistoryDeleteBuffer(Hist);
|
ExeName.Length = ExeName.MaximumLength = ExpungeCommandHistoryRequest->ExeLength;
|
||||||
ConSrvReleaseConsole(Console, TRUE);
|
ExeName.Buffer = ExpungeCommandHistoryRequest->ExeName;
|
||||||
}
|
|
||||||
|
Hist = HistoryFindBuffer(Console, &ExeName);
|
||||||
|
HistoryDeleteBuffer(Hist);
|
||||||
|
|
||||||
|
ConSrvReleaseConsole(Console, TRUE);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSR_API(SrvSetConsoleNumberOfCommands)
|
CSR_API(SrvSetConsoleNumberOfCommands)
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryNumberCommandsRequest;
|
PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryNumberCommandsRequest;
|
||||||
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
|
|
||||||
PCONSOLE Console;
|
PCONSOLE Console;
|
||||||
PHISTORY_BUFFER Hist;
|
PHISTORY_BUFFER Hist;
|
||||||
NTSTATUS Status;
|
|
||||||
UINT MaxEntries = SetHistoryNumberCommandsRequest->NumCommands;
|
UINT MaxEntries = SetHistoryNumberCommandsRequest->NumCommands;
|
||||||
|
UNICODE_STRING ExeName;
|
||||||
PUNICODE_STRING OldEntryList, NewEntryList;
|
PUNICODE_STRING OldEntryList, NewEntryList;
|
||||||
|
|
||||||
if (!CsrValidateMessageBuffer(ApiMessage,
|
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||||
(PVOID*)&SetHistoryNumberCommandsRequest->ExeName.Buffer,
|
(PVOID*)&SetHistoryNumberCommandsRequest->ExeName,
|
||||||
SetHistoryNumberCommandsRequest->ExeName.Length,
|
SetHistoryNumberCommandsRequest->ExeLength,
|
||||||
sizeof(BYTE)))
|
sizeof(BYTE)))
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
|
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||||
if (NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status)) return 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
Hist->MaxEntries = MaxEntries;
|
// FIXME: convert to UNICODE if Unicode(2) == FALSE
|
||||||
Hist->Entries = memcpy(NewEntryList, Hist->Entries,
|
ExeName.Length = ExeName.MaximumLength = SetHistoryNumberCommandsRequest->ExeLength;
|
||||||
Hist->NumEntries * sizeof(UNICODE_STRING));
|
ExeName.Buffer = SetHistoryNumberCommandsRequest->ExeName;
|
||||||
ConsoleFreeHeap(OldEntryList);
|
|
||||||
}
|
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;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,8 +677,21 @@ CSR_API(SrvSetConsoleHistory)
|
||||||
|
|
||||||
CSR_API(SrvSetConsoleCommandHistoryMode)
|
CSR_API(SrvSetConsoleCommandHistoryMode)
|
||||||
{
|
{
|
||||||
DPRINT1("%s not yet implemented\n", __FUNCTION__);
|
NTSTATUS Status;
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
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 */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue