mirror of
https://github.com/reactos/reactos.git
synced 2024-07-06 04:35:07 +00:00
[KERNEL32][CONSRV]
Make kernel32 / winsrv console CSR structures Win2k3-compliant. - Fix UNICODE and ANSI versions of the Alias and History APIs. Tested with unicode and ansi version of our doskey.exe - Implement GetNumberOfConsoleMouseButtons. Part 5/X CORE-7931 svn path=/branches/condrv_restructure/; revision=63751
This commit is contained in:
parent
9ed2e0b5bc
commit
b06a89c070
|
@ -18,31 +18,40 @@
|
|||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
AddConsoleAliasW(LPCWSTR lpSource,
|
||||
LPCWSTR lpTarget,
|
||||
LPCWSTR lpExeName)
|
||||
static BOOL
|
||||
IntAddConsoleAlias(LPCVOID Source,
|
||||
DWORD SourceBufferLength,
|
||||
LPCVOID Target,
|
||||
DWORD TargetBufferLength,
|
||||
LPCVOID lpExeName,
|
||||
BOOLEAN bUnicode)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_ADDGETALIAS ConsoleAliasRequest = &ApiMessage.Data.ConsoleAliasRequest;
|
||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||
ULONG CapturedStrings;
|
||||
|
||||
DPRINT("AddConsoleAliasW enterd with lpSource %S lpTarget %S lpExeName %S\n", lpSource, lpTarget, lpExeName);
|
||||
DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
|
||||
|
||||
if (lpExeName == NULL || dwNumChars == 0)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ConsoleAliasRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||
|
||||
/* Determine the needed sizes */
|
||||
ConsoleAliasRequest->SourceLength = (wcslen(lpSource ) + 1) * sizeof(WCHAR);
|
||||
ConsoleAliasRequest->ExeLength = (wcslen(lpExeName) + 1) * sizeof(WCHAR);
|
||||
ConsoleAliasRequest->SourceLength = SourceBufferLength;
|
||||
ConsoleAliasRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
|
||||
ConsoleAliasRequest->Unicode =
|
||||
ConsoleAliasRequest->Unicode2 = bUnicode;
|
||||
|
||||
CapturedStrings = 2;
|
||||
|
||||
if (lpTarget) /* The target can be optional */
|
||||
if (Target) /* The target can be optional */
|
||||
{
|
||||
ConsoleAliasRequest->TargetLength = (wcslen(lpTarget) + 1) * sizeof(WCHAR);
|
||||
ConsoleAliasRequest->TargetLength = TargetBufferLength;
|
||||
CapturedStrings++;
|
||||
}
|
||||
else
|
||||
|
@ -64,19 +73,19 @@ AddConsoleAliasW(LPCWSTR lpSource,
|
|||
|
||||
/* Capture the strings */
|
||||
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||
(PVOID)lpSource,
|
||||
(PVOID)Source,
|
||||
ConsoleAliasRequest->SourceLength,
|
||||
(PVOID*)&ConsoleAliasRequest->Source);
|
||||
|
||||
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||
(PVOID)lpExeName,
|
||||
ConsoleAliasRequest->ExeLength,
|
||||
(PVOID*)&ConsoleAliasRequest->Exe);
|
||||
(PVOID*)&ConsoleAliasRequest->ExeName);
|
||||
|
||||
if (lpTarget) /* The target can be optional */
|
||||
if (Target) /* The target can be optional */
|
||||
{
|
||||
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||
(PVOID)lpTarget,
|
||||
(PVOID)Target,
|
||||
ConsoleAliasRequest->TargetLength,
|
||||
(PVOID*)&ConsoleAliasRequest->Target);
|
||||
}
|
||||
|
@ -85,16 +94,16 @@ AddConsoleAliasW(LPCWSTR lpSource,
|
|||
ConsoleAliasRequest->Target = NULL;
|
||||
}
|
||||
|
||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepAddAlias),
|
||||
sizeof(CONSOLE_ADDGETALIAS));
|
||||
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepAddAlias),
|
||||
sizeof(*ConsoleAliasRequest));
|
||||
|
||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
if (!NT_SUCCESS(ApiMessage.Status))
|
||||
{
|
||||
BaseSetLastNTError(Status);
|
||||
BaseSetLastNTError(ApiMessage.Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -107,64 +116,85 @@ AddConsoleAliasW(LPCWSTR lpSource,
|
|||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
AddConsoleAliasA(LPCSTR lpSource,
|
||||
LPCSTR lpTarget,
|
||||
LPCSTR lpExeName)
|
||||
AddConsoleAliasW(LPCWSTR lpSource,
|
||||
LPCWSTR lpTarget,
|
||||
LPCWSTR lpExeName)
|
||||
{
|
||||
LPWSTR lpSourceW = NULL;
|
||||
LPWSTR lpTargetW = NULL;
|
||||
LPWSTR lpExeNameW = NULL;
|
||||
BOOL bRetVal;
|
||||
DWORD SourceBufferLength, TargetBufferLength;
|
||||
SourceBufferLength = wcslen(lpSource) * sizeof(WCHAR);
|
||||
TargetBufferLength = (lpTarget ? wcslen(lpTarget) * sizeof(WCHAR) : 0);
|
||||
|
||||
if (lpSource)
|
||||
BasepAnsiStringToHeapUnicodeString(lpSource, (LPWSTR*)&lpSourceW);
|
||||
if (lpTarget)
|
||||
BasepAnsiStringToHeapUnicodeString(lpTarget, (LPWSTR*)&lpTargetW);
|
||||
if (lpExeName)
|
||||
BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*)&lpExeNameW);
|
||||
DPRINT1("AddConsoleAliasW entered with lpSource '%S' lpTarget '%S' lpExeName '%S'\n",
|
||||
lpSource, lpTarget, lpExeName);
|
||||
|
||||
bRetVal = AddConsoleAliasW(lpSourceW, lpTargetW, lpExeNameW);
|
||||
|
||||
/* Clean up */
|
||||
if (lpSourceW)
|
||||
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpSourceW);
|
||||
if (lpTargetW)
|
||||
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpTargetW);
|
||||
if (lpExeNameW)
|
||||
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpExeNameW);
|
||||
|
||||
return bRetVal;
|
||||
return IntAddConsoleAlias(lpSource,
|
||||
SourceBufferLength,
|
||||
lpTarget,
|
||||
TargetBufferLength,
|
||||
lpExeName,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
DWORD
|
||||
BOOL
|
||||
WINAPI
|
||||
GetConsoleAliasW(LPWSTR lpSource,
|
||||
LPWSTR lpTargetBuffer,
|
||||
DWORD TargetBufferLength,
|
||||
LPWSTR lpExeName)
|
||||
AddConsoleAliasA(LPCSTR lpSource,
|
||||
LPCSTR lpTarget,
|
||||
LPCSTR lpExeName)
|
||||
{
|
||||
DWORD SourceBufferLength, TargetBufferLength;
|
||||
SourceBufferLength = strlen(lpSource) * sizeof(CHAR);
|
||||
TargetBufferLength = (lpTarget ? strlen(lpTarget) * sizeof(CHAR) : 0);
|
||||
|
||||
DPRINT1("AddConsoleAliasA entered with lpSource '%s' lpTarget '%s' lpExeName '%s'\n",
|
||||
lpSource, lpTarget, lpExeName);
|
||||
|
||||
return IntAddConsoleAlias(lpSource,
|
||||
SourceBufferLength,
|
||||
lpTarget,
|
||||
TargetBufferLength,
|
||||
lpExeName,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
|
||||
static DWORD
|
||||
IntGetConsoleAlias(LPVOID Source,
|
||||
DWORD SourceBufferLength,
|
||||
LPVOID Target,
|
||||
DWORD TargetBufferLength,
|
||||
LPVOID lpExeName,
|
||||
BOOLEAN bUnicode)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_ADDGETALIAS ConsoleAliasRequest = &ApiMessage.Data.ConsoleAliasRequest;
|
||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||
|
||||
DPRINT("GetConsoleAliasW entered with lpSource %S lpExeName %S\n", lpSource, lpExeName);
|
||||
DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
|
||||
|
||||
if (lpTargetBuffer == NULL)
|
||||
if (Source == NULL || Target == NULL)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Determine the needed sizes */
|
||||
ConsoleAliasRequest->SourceLength = (wcslen(lpSource ) + 1) * sizeof(WCHAR);
|
||||
ConsoleAliasRequest->ExeLength = (wcslen(lpExeName) + 1) * sizeof(WCHAR);
|
||||
if (lpExeName == NULL || dwNumChars == 0)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ConsoleAliasRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||
|
||||
/* Determine the needed sizes */
|
||||
ConsoleAliasRequest->SourceLength = SourceBufferLength;
|
||||
ConsoleAliasRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
|
||||
ConsoleAliasRequest->Unicode =
|
||||
ConsoleAliasRequest->Unicode2 = bUnicode;
|
||||
|
||||
ConsoleAliasRequest->Target = NULL;
|
||||
ConsoleAliasRequest->TargetLength = TargetBufferLength;
|
||||
|
||||
/* Allocate a Capture Buffer */
|
||||
|
@ -180,34 +210,37 @@ GetConsoleAliasW(LPWSTR lpSource,
|
|||
|
||||
/* Capture the strings */
|
||||
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||
(PVOID)lpSource,
|
||||
(PVOID)Source,
|
||||
ConsoleAliasRequest->SourceLength,
|
||||
(PVOID*)&ConsoleAliasRequest->Source);
|
||||
|
||||
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||
(PVOID)lpExeName,
|
||||
ConsoleAliasRequest->ExeLength,
|
||||
(PVOID*)&ConsoleAliasRequest->Exe);
|
||||
(PVOID*)&ConsoleAliasRequest->ExeName);
|
||||
|
||||
/* Allocate space for the target buffer */
|
||||
CsrAllocateMessagePointer(CaptureBuffer,
|
||||
ConsoleAliasRequest->TargetLength,
|
||||
(PVOID*)&ConsoleAliasRequest->Target);
|
||||
|
||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAlias),
|
||||
sizeof(CONSOLE_ADDGETALIAS));
|
||||
if (!NT_SUCCESS(Status))
|
||||
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAlias),
|
||||
sizeof(*ConsoleAliasRequest));
|
||||
if (!NT_SUCCESS(ApiMessage.Status))
|
||||
{
|
||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||
BaseSetLastNTError(Status);
|
||||
return 0;
|
||||
BaseSetLastNTError(ApiMessage.Status);
|
||||
|
||||
if (ApiMessage.Status == STATUS_BUFFER_TOO_SMALL)
|
||||
return ConsoleAliasRequest->TargetLength;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy the returned target string into the user buffer */
|
||||
// wcscpy(lpTargetBuffer, ConsoleAliasRequest->Target);
|
||||
memcpy(lpTargetBuffer,
|
||||
memcpy(Target,
|
||||
ConsoleAliasRequest->Target,
|
||||
ConsoleAliasRequest->TargetLength);
|
||||
|
||||
|
@ -223,65 +256,20 @@ GetConsoleAliasW(LPWSTR lpSource,
|
|||
*/
|
||||
DWORD
|
||||
WINAPI
|
||||
GetConsoleAliasA(LPSTR lpSource,
|
||||
LPSTR lpTargetBuffer,
|
||||
GetConsoleAliasW(LPWSTR lpSource,
|
||||
LPWSTR lpTargetBuffer,
|
||||
DWORD TargetBufferLength,
|
||||
LPSTR lpExeName)
|
||||
LPWSTR lpExeName)
|
||||
{
|
||||
LPWSTR lpwSource;
|
||||
LPWSTR lpwExeName;
|
||||
LPWSTR lpwTargetBuffer;
|
||||
UINT dwSourceSize;
|
||||
UINT dwExeNameSize;
|
||||
UINT dwResult;
|
||||
DPRINT1("GetConsoleAliasW entered with lpSource '%S' lpExeName '%S'\n",
|
||||
lpSource, lpExeName);
|
||||
|
||||
DPRINT("GetConsoleAliasA entered\n");
|
||||
|
||||
if (lpTargetBuffer == NULL)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dwSourceSize = (strlen(lpSource)+1) * sizeof(WCHAR);
|
||||
lpwSource = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSourceSize);
|
||||
if (lpwSource == NULL)
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return 0;
|
||||
}
|
||||
MultiByteToWideChar(CP_ACP, 0, lpSource, -1, lpwSource, dwSourceSize);
|
||||
|
||||
dwExeNameSize = (strlen(lpExeName)+1) * sizeof(WCHAR);
|
||||
lpwExeName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwExeNameSize);
|
||||
if (lpwExeName == NULL)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, lpwSource);
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return 0;
|
||||
}
|
||||
MultiByteToWideChar(CP_ACP, 0, lpExeName, -1, lpwExeName, dwExeNameSize);
|
||||
|
||||
lpwTargetBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, TargetBufferLength * sizeof(WCHAR));
|
||||
if (lpwTargetBuffer == NULL)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, lpwSource);
|
||||
HeapFree(GetProcessHeap(), 0, lpwExeName);
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dwResult = GetConsoleAliasW(lpwSource, lpwTargetBuffer, TargetBufferLength * sizeof(WCHAR), lpwExeName);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, lpwSource);
|
||||
HeapFree(GetProcessHeap(), 0, lpwExeName);
|
||||
|
||||
if (dwResult)
|
||||
dwResult = WideCharToMultiByte(CP_ACP, 0, lpwTargetBuffer, dwResult / sizeof(WCHAR), lpTargetBuffer, TargetBufferLength, NULL, NULL);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, lpwTargetBuffer);
|
||||
|
||||
return dwResult;
|
||||
return IntGetConsoleAlias(lpSource,
|
||||
wcslen(lpSource) * sizeof(WCHAR),
|
||||
lpTargetBuffer,
|
||||
TargetBufferLength,
|
||||
lpExeName,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -290,25 +278,48 @@ GetConsoleAliasA(LPSTR lpSource,
|
|||
*/
|
||||
DWORD
|
||||
WINAPI
|
||||
GetConsoleAliasesW(LPWSTR AliasBuffer,
|
||||
DWORD AliasBufferLength,
|
||||
LPWSTR ExeName)
|
||||
GetConsoleAliasA(LPSTR lpSource,
|
||||
LPSTR lpTargetBuffer,
|
||||
DWORD TargetBufferLength,
|
||||
LPSTR lpExeName)
|
||||
{
|
||||
DPRINT1("GetConsoleAliasA entered with lpSource '%s' lpExeName '%s'\n",
|
||||
lpSource, lpExeName);
|
||||
|
||||
return IntGetConsoleAlias(lpSource,
|
||||
strlen(lpSource) * sizeof(CHAR),
|
||||
lpTargetBuffer,
|
||||
TargetBufferLength,
|
||||
lpExeName,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
|
||||
static DWORD
|
||||
IntGetConsoleAliases(LPVOID AliasBuffer,
|
||||
DWORD AliasBufferLength,
|
||||
LPVOID lpExeName,
|
||||
BOOLEAN bUnicode)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_GETALLALIASES GetAllAliasesRequest = &ApiMessage.Data.GetAllAliasesRequest;
|
||||
PCSR_CAPTURE_BUFFER CaptureBuffer;
|
||||
|
||||
DPRINT("GetConsoleAliasesW entered\n");
|
||||
DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
|
||||
|
||||
/* Determine the needed sizes */
|
||||
GetAllAliasesRequest->ExeLength = GetConsoleAliasesLengthW(ExeName);
|
||||
if (GetAllAliasesRequest->ExeLength == 0 ||
|
||||
GetAllAliasesRequest->ExeLength > AliasBufferLength)
|
||||
if (lpExeName == NULL || dwNumChars == 0)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GetAllAliasesRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||
|
||||
/* Determine the needed sizes */
|
||||
GetAllAliasesRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
|
||||
GetAllAliasesRequest->Unicode =
|
||||
GetAllAliasesRequest->Unicode2 = bUnicode;
|
||||
|
||||
GetAllAliasesRequest->AliasesBufferLength = AliasBufferLength;
|
||||
|
||||
/* Allocate a Capture Buffer */
|
||||
|
@ -323,7 +334,7 @@ GetConsoleAliasesW(LPWSTR AliasBuffer,
|
|||
|
||||
/* Capture the exe name and allocate space for the aliases buffer */
|
||||
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||
(PVOID)ExeName,
|
||||
(PVOID)lpExeName,
|
||||
GetAllAliasesRequest->ExeLength,
|
||||
(PVOID*)&GetAllAliasesRequest->ExeName);
|
||||
|
||||
|
@ -331,18 +342,18 @@ GetConsoleAliasesW(LPWSTR AliasBuffer,
|
|||
GetAllAliasesRequest->AliasesBufferLength,
|
||||
(PVOID*)&GetAllAliasesRequest->AliasesBuffer);
|
||||
|
||||
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliases),
|
||||
sizeof(CONSOLE_GETALLALIASES));
|
||||
if (!NT_SUCCESS(Status))
|
||||
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
CaptureBuffer,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliases),
|
||||
sizeof(*GetAllAliasesRequest));
|
||||
if (!NT_SUCCESS(ApiMessage.Status))
|
||||
{
|
||||
BaseSetLastNTError(Status);
|
||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||
BaseSetLastNTError(ApiMessage.Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy the returned aliases string into the user buffer */
|
||||
// wcscpy(AliasBuffer, GetAllAliasesRequest->AliasesBuffer);
|
||||
memcpy(AliasBuffer,
|
||||
GetAllAliasesRequest->AliasesBuffer,
|
||||
GetAllAliasesRequest->AliasesBufferLength);
|
||||
|
@ -350,7 +361,26 @@ GetConsoleAliasesW(LPWSTR AliasBuffer,
|
|||
/* Release the capture buffer and exit */
|
||||
CsrFreeCaptureBuffer(CaptureBuffer);
|
||||
|
||||
return GetAllAliasesRequest->AliasesBufferLength; // / sizeof(WCHAR); (original code)
|
||||
return GetAllAliasesRequest->AliasesBufferLength;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
DWORD
|
||||
WINAPI
|
||||
GetConsoleAliasesW(LPWSTR AliasBuffer,
|
||||
DWORD AliasBufferLength,
|
||||
LPWSTR ExeName)
|
||||
{
|
||||
DPRINT1("GetConsoleAliasesW entered with lpExeName '%S'\n",
|
||||
ExeName);
|
||||
|
||||
return IntGetConsoleAliases(AliasBuffer,
|
||||
AliasBufferLength,
|
||||
ExeName,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -363,27 +393,13 @@ GetConsoleAliasesA(LPSTR AliasBuffer,
|
|||
DWORD AliasBufferLength,
|
||||
LPSTR ExeName)
|
||||
{
|
||||
DWORD dwRetVal = 0;
|
||||
LPWSTR lpwExeName = NULL;
|
||||
LPWSTR lpwAliasBuffer;
|
||||
DPRINT1("GetConsoleAliasesA entered with lpExeName '%s'\n",
|
||||
ExeName);
|
||||
|
||||
DPRINT("GetConsoleAliasesA entered\n");
|
||||
|
||||
if (ExeName)
|
||||
BasepAnsiStringToHeapUnicodeString(ExeName, (LPWSTR*)&lpwExeName);
|
||||
|
||||
lpwAliasBuffer = HeapAlloc(GetProcessHeap(), 0, AliasBufferLength * sizeof(WCHAR));
|
||||
|
||||
dwRetVal = GetConsoleAliasesW(lpwAliasBuffer, AliasBufferLength * sizeof(WCHAR), lpwExeName);
|
||||
|
||||
if (lpwExeName)
|
||||
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpwExeName);
|
||||
|
||||
if (dwRetVal)
|
||||
dwRetVal = WideCharToMultiByte(CP_ACP, 0, lpwAliasBuffer, dwRetVal /**/ / sizeof(WCHAR) /**/, AliasBuffer, AliasBufferLength, NULL, NULL);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, lpwAliasBuffer);
|
||||
return dwRetVal;
|
||||
return IntGetConsoleAliases(AliasBuffer,
|
||||
AliasBufferLength,
|
||||
ExeName,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
@ -512,6 +528,7 @@ WINAPI
|
|||
GetConsoleAliasExesW(LPWSTR lpExeNameBuffer,
|
||||
DWORD ExeNameBufferLength)
|
||||
{
|
||||
DPRINT1("GetConsoleAliasExesW called\n");
|
||||
return IntGetConsoleAliasExes(lpExeNameBuffer, ExeNameBufferLength, TRUE);
|
||||
}
|
||||
|
||||
|
@ -524,6 +541,7 @@ WINAPI
|
|||
GetConsoleAliasExesA(LPSTR lpExeNameBuffer,
|
||||
DWORD ExeNameBufferLength)
|
||||
{
|
||||
DPRINT1("GetConsoleAliasExesA called\n");
|
||||
return IntGetConsoleAliasExes(lpExeNameBuffer, ExeNameBufferLength, FALSE);
|
||||
}
|
||||
|
||||
|
@ -558,6 +576,7 @@ DWORD
|
|||
WINAPI
|
||||
GetConsoleAliasExesLengthW(VOID)
|
||||
{
|
||||
DPRINT1("GetConsoleAliasExesLengthW called\n");
|
||||
return IntGetConsoleAliasExesLength(TRUE);
|
||||
}
|
||||
|
||||
|
@ -569,6 +588,7 @@ DWORD
|
|||
WINAPI
|
||||
GetConsoleAliasExesLengthA(VOID)
|
||||
{
|
||||
DPRINT1("GetConsoleAliasExesLengthA called\n");
|
||||
return IntGetConsoleAliasExesLength(FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -1392,15 +1392,29 @@ SetConsoleCursorInfo(HANDLE hConsoleOutput,
|
|||
/*--------------------------------------------------------------
|
||||
* GetNumberOfConsoleMouseButtons
|
||||
*
|
||||
* @unimplemented
|
||||
* @implemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
GetNumberOfConsoleMouseButtons(LPDWORD lpNumberOfMouseButtons)
|
||||
{
|
||||
DPRINT1("GetNumberOfConsoleMouseButtons(0x%p) UNIMPLEMENTED!\n", lpNumberOfMouseButtons);
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_GETMOUSEINFO GetMouseInfoRequest = &ApiMessage.Data.GetMouseInfoRequest;
|
||||
|
||||
GetMouseInfoRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||
|
||||
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
|
||||
NULL,
|
||||
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetMouseInfo),
|
||||
sizeof(*GetMouseInfoRequest));
|
||||
if (!NT_SUCCESS(ApiMessage.Status))
|
||||
{
|
||||
BaseSetLastNTError(ApiMessage.Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*lpNumberOfMouseButtons = GetMouseInfoRequest->NumButtons;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2523,14 +2537,6 @@ GetConsoleCursorMode(HANDLE hConsole, PBOOL pUnknown1, PBOOL pUnknown2)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
GetConsoleNlsMode(HANDLE hConsole, LPDWORD lpMode)
|
||||
{
|
||||
STUB;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
SetConsoleCursorMode(HANDLE hConsole, BOOL Unknown1, BOOL Unknown2)
|
||||
|
@ -2541,7 +2547,7 @@ SetConsoleCursorMode(HANDLE hConsole, BOOL Unknown1, BOOL Unknown2)
|
|||
|
||||
BOOL
|
||||
WINAPI
|
||||
SetConsoleLocalEUDC(DWORD Unknown1, DWORD Unknown2, DWORD Unknown3, DWORD Unknown4)
|
||||
GetConsoleNlsMode(HANDLE hConsole, LPDWORD lpMode)
|
||||
{
|
||||
STUB;
|
||||
return FALSE;
|
||||
|
@ -2555,6 +2561,14 @@ SetConsoleNlsMode(HANDLE hConsole, DWORD dwMode)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
SetConsoleLocalEUDC(DWORD Unknown1, DWORD Unknown2, DWORD Unknown3, DWORD Unknown4)
|
||||
{
|
||||
STUB;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
RegisterConsoleIME(HWND hWnd, LPDWORD ThreadId)
|
||||
|
|
|
@ -319,6 +319,12 @@ typedef struct
|
|||
*/
|
||||
} CONSOLE_GETSETCURSORINFO, *PCONSOLE_GETSETCURSORINFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HANDLE ConsoleHandle;
|
||||
ULONG NumButtons;
|
||||
} CONSOLE_GETMOUSEINFO, *PCONSOLE_GETMOUSEINFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HANDLE ConsoleHandle;
|
||||
|
@ -370,7 +376,8 @@ typedef struct
|
|||
DWORD DesiredAccess;
|
||||
BOOL InheritHandle;
|
||||
DWORD ShareMode;
|
||||
DWORD ScreenBufferType; /* Type of the screen buffer: CONSOLE_TEXTMODE_BUFFER or CONSOLE_GRAPHICS_BUFFER */
|
||||
/* Type of the screen buffer: CONSOLE_TEXTMODE_BUFFER or CONSOLE_GRAPHICS_BUFFER */
|
||||
DWORD ScreenBufferType;
|
||||
/*
|
||||
* This structure holds the initialization information
|
||||
* for graphics screen buffers.
|
||||
|
@ -656,20 +663,26 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
ULONG SourceLength;
|
||||
ULONG TargetLength; // Also used for storing the number of bytes written.
|
||||
ULONG ExeLength;
|
||||
LPWSTR Source;
|
||||
LPWSTR Target;
|
||||
LPWSTR Exe;
|
||||
HANDLE ConsoleHandle;
|
||||
USHORT SourceLength;
|
||||
USHORT TargetLength; // Also used for storing the number of bytes written.
|
||||
USHORT ExeLength;
|
||||
PVOID Source;
|
||||
PVOID Target;
|
||||
PVOID ExeName;
|
||||
BOOLEAN Unicode;
|
||||
BOOLEAN Unicode2;
|
||||
} CONSOLE_ADDGETALIAS, *PCONSOLE_ADDGETALIAS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD ExeLength;
|
||||
DWORD AliasesBufferLength;
|
||||
LPWSTR ExeName;
|
||||
LPWSTR AliasesBuffer;
|
||||
HANDLE ConsoleHandle;
|
||||
USHORT ExeLength;
|
||||
PVOID ExeName;
|
||||
BOOLEAN Unicode;
|
||||
BOOLEAN Unicode2;
|
||||
ULONG AliasesBufferLength;
|
||||
PVOID AliasesBuffer;
|
||||
} CONSOLE_GETALLALIASES, *PCONSOLE_GETALLALIASES;
|
||||
|
||||
typedef struct
|
||||
|
@ -704,7 +717,6 @@ typedef struct
|
|||
HANDLE ConsoleHandle;
|
||||
ULONG HistoryLength;
|
||||
PVOID History;
|
||||
// UNICODE_STRING ExeName;
|
||||
USHORT ExeLength;
|
||||
PVOID ExeName;
|
||||
BOOLEAN Unicode;
|
||||
|
@ -715,7 +727,6 @@ typedef struct
|
|||
{
|
||||
HANDLE ConsoleHandle;
|
||||
ULONG HistoryLength;
|
||||
// UNICODE_STRING ExeName;
|
||||
USHORT ExeLength;
|
||||
PVOID ExeName;
|
||||
BOOLEAN Unicode;
|
||||
|
@ -725,7 +736,6 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
HANDLE ConsoleHandle;
|
||||
// UNICODE_STRING ExeName;
|
||||
USHORT ExeLength;
|
||||
PVOID ExeName;
|
||||
BOOLEAN Unicode;
|
||||
|
@ -743,7 +753,6 @@ typedef struct
|
|||
{
|
||||
HANDLE ConsoleHandle;
|
||||
ULONG NumCommands;
|
||||
// UNICODE_STRING ExeName;
|
||||
USHORT ExeLength;
|
||||
PVOID ExeName;
|
||||
BOOLEAN Unicode;
|
||||
|
@ -814,11 +823,12 @@ typedef struct _CONSOLE_API_MESSAGE
|
|||
CONSOLE_GETHANDLEINFO GetHandleInfoRequest;
|
||||
CONSOLE_SETHANDLEINFO SetHandleInfoRequest;
|
||||
|
||||
/* Cursor */
|
||||
/* Cursor & Mouse */
|
||||
CONSOLE_SHOWCURSOR ShowCursorRequest;
|
||||
CONSOLE_SETCURSOR SetCursorRequest;
|
||||
CONSOLE_GETSETCURSORINFO CursorInfoRequest;
|
||||
CONSOLE_SETCURSORPOSITION SetCursorPositionRequest;
|
||||
CONSOLE_GETMOUSEINFO GetMouseInfoRequest;
|
||||
|
||||
/* Screen-buffer */
|
||||
CONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -389,10 +389,11 @@ ConDrvWriteConsoleInput(IN PCONSOLE Console,
|
|||
ASSERT( (InputRecord != NULL && NumEventsToWrite > 0) ||
|
||||
(InputRecord == NULL && NumEventsToWrite == 0) );
|
||||
|
||||
// Do NOT do that !! Use the existing number of events already written, if any...
|
||||
// if (NumEventsWritten) *NumEventsWritten = 0;
|
||||
|
||||
for (i = (NumEventsWritten ? *NumEventsWritten : 0); i < NumEventsToWrite && NT_SUCCESS(Status); ++i)
|
||||
/// Status = ConioAddInputEvents(Console, InputRecord, NumEventsToWrite, NumEventsWritten, AppendToEnd);
|
||||
|
||||
for (i = 0; i < NumEventsToWrite && NT_SUCCESS(Status); ++i)
|
||||
{
|
||||
if (!Unicode)
|
||||
{
|
||||
|
|
|
@ -977,8 +977,18 @@ CSR_API(SrvConsoleNotifyLastClose)
|
|||
|
||||
CSR_API(SrvGetConsoleMouseInfo)
|
||||
{
|
||||
DPRINT1("%s not yet implemented\n", __FUNCTION__);
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
NTSTATUS Status;
|
||||
PCONSOLE_GETMOUSEINFO GetMouseInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetMouseInfoRequest;
|
||||
PCONSOLE Console;
|
||||
|
||||
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
|
||||
/* Just retrieve the number of buttons of the mouse attached to this console */
|
||||
GetMouseInfoRequest->NumButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
|
||||
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
CSR_API(SrvSetConsoleKeyShortcuts)
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
* FILE: win32ss/user/winsrv/consrv/lineinput.c
|
||||
* PURPOSE: Console line input functions
|
||||
* PROGRAMMERS: Jeffrey Morlan
|
||||
*
|
||||
* NOTE: It's something frontend-related... (--> read my mind... ;) )
|
||||
*/
|
||||
|
||||
/* INCLUDES *******************************************************************/
|
||||
|
@ -21,11 +19,27 @@ typedef struct _HISTORY_BUFFER
|
|||
UINT Position;
|
||||
UINT MaxEntries;
|
||||
UINT NumEntries;
|
||||
PUNICODE_STRING Entries;
|
||||
UNICODE_STRING ExeName;
|
||||
PUNICODE_STRING Entries;
|
||||
} HISTORY_BUFFER, *PHISTORY_BUFFER;
|
||||
|
||||
|
||||
BOOLEAN
|
||||
ConvertInputAnsiToUnicode(PCONSOLE Console,
|
||||
PVOID Source,
|
||||
USHORT SourceLength,
|
||||
// BOOLEAN IsUnicode,
|
||||
PWCHAR* Target,
|
||||
PUSHORT TargetLength);
|
||||
BOOLEAN
|
||||
ConvertInputUnicodeToAnsi(PCONSOLE Console,
|
||||
PVOID Source,
|
||||
USHORT SourceLength,
|
||||
// BOOLEAN IsAnsi,
|
||||
PCHAR/* * */ Target,
|
||||
/*P*/USHORT TargetLength);
|
||||
|
||||
|
||||
/* PRIVATE FUNCTIONS **********************************************************/
|
||||
|
||||
static PHISTORY_BUFFER
|
||||
|
@ -124,17 +138,51 @@ HistoryGetCurrentEntry(PCONSOLE Console, PUNICODE_STRING Entry)
|
|||
}
|
||||
|
||||
static PHISTORY_BUFFER
|
||||
HistoryFindBuffer(PCONSOLE Console, PUNICODE_STRING ExeName)
|
||||
HistoryFindBuffer(PCONSOLE Console,
|
||||
PVOID ExeName,
|
||||
USHORT ExeLength,
|
||||
BOOLEAN UnicodeExe)
|
||||
{
|
||||
PLIST_ENTRY Entry = Console->HistoryBuffers.Flink;
|
||||
UNICODE_STRING ExeNameU;
|
||||
|
||||
PLIST_ENTRY Entry;
|
||||
PHISTORY_BUFFER Hist = NULL;
|
||||
|
||||
if (ExeName == NULL) return NULL;
|
||||
|
||||
if (UnicodeExe)
|
||||
{
|
||||
ExeNameU.Buffer = ExeName;
|
||||
/* Length is in bytes */
|
||||
ExeNameU.MaximumLength = ExeLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ConvertInputAnsiToUnicode(Console,
|
||||
ExeName, ExeLength,
|
||||
&ExeNameU.Buffer, &ExeNameU.MaximumLength))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
ExeNameU.Length = ExeNameU.MaximumLength;
|
||||
|
||||
Entry = Console->HistoryBuffers.Flink;
|
||||
while (Entry != &Console->HistoryBuffers)
|
||||
{
|
||||
Hist = CONTAINING_RECORD(Entry, HISTORY_BUFFER, ListEntry);
|
||||
|
||||
/* For the history APIs, the caller is allowed to give only part of the name */
|
||||
PHISTORY_BUFFER Hist = CONTAINING_RECORD(Entry, HISTORY_BUFFER, ListEntry);
|
||||
if (RtlPrefixUnicodeString(ExeName, &Hist->ExeName, TRUE))
|
||||
if (RtlPrefixUnicodeString(&ExeNameU, &Hist->ExeName, TRUE))
|
||||
{
|
||||
if (!UnicodeExe) ConsoleFreeHeap(ExeNameU.Buffer);
|
||||
return Hist;
|
||||
}
|
||||
|
||||
Entry = Entry->Flink;
|
||||
}
|
||||
|
||||
if (!UnicodeExe) ConsoleFreeHeap(ExeNameU.Buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -190,7 +238,7 @@ LineInputSetPos(PCONSOLE Console, UINT Pos)
|
|||
}
|
||||
|
||||
static VOID
|
||||
LineInputEdit(PCONSOLE Console, UINT NumToDelete, UINT NumToInsert, WCHAR *Insertion)
|
||||
LineInputEdit(PCONSOLE Console, UINT NumToDelete, UINT NumToInsert, PWCHAR Insertion)
|
||||
{
|
||||
PTEXTMODE_SCREEN_BUFFER ActiveBuffer;
|
||||
UINT Pos = Console->LinePos;
|
||||
|
@ -458,11 +506,10 @@ CSR_API(SrvGetConsoleCommandHistory)
|
|||
NTSTATUS Status;
|
||||
PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryRequest;
|
||||
PCONSOLE Console;
|
||||
ULONG BytesWritten = 0;
|
||||
PHISTORY_BUFFER Hist;
|
||||
UNICODE_STRING ExeName;
|
||||
PBYTE Buffer = (PBYTE)GetCommandHistoryRequest->History;
|
||||
ULONG BufferSize = GetCommandHistoryRequest->HistoryLength;
|
||||
UINT i;
|
||||
|
||||
DPRINT1("SrvGetConsoleCommandHistory entered\n");
|
||||
|
||||
if ( !CsrValidateMessageBuffer(ApiMessage,
|
||||
(PVOID*)&GetCommandHistoryRequest->History,
|
||||
|
@ -479,39 +526,64 @@ CSR_API(SrvGetConsoleCommandHistory)
|
|||
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);
|
||||
Hist = HistoryFindBuffer(Console,
|
||||
GetCommandHistoryRequest->ExeName,
|
||||
GetCommandHistoryRequest->ExeLength,
|
||||
GetCommandHistoryRequest->Unicode2);
|
||||
if (Hist)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
LPSTR TargetBufferA;
|
||||
LPWSTR TargetBufferW;
|
||||
ULONG BufferSize = GetCommandHistoryRequest->HistoryLength;
|
||||
|
||||
UINT Offset = 0;
|
||||
UINT SourceLength;
|
||||
|
||||
if (GetCommandHistoryRequest->Unicode)
|
||||
{
|
||||
TargetBufferW = GetCommandHistoryRequest->History;
|
||||
BufferSize /= sizeof(WCHAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetBufferA = GetCommandHistoryRequest->History;
|
||||
}
|
||||
|
||||
for (i = 0; i < Hist->NumEntries; i++)
|
||||
{
|
||||
if (BufferSize < (Hist->Entries[i].Length + sizeof(WCHAR)))
|
||||
SourceLength = Hist->Entries[i].Length / sizeof(WCHAR);
|
||||
if (Offset + SourceLength + 1 > BufferSize)
|
||||
{
|
||||
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);
|
||||
// }
|
||||
|
||||
if (GetCommandHistoryRequest->Unicode)
|
||||
{
|
||||
RtlCopyMemory(&TargetBufferW[Offset], Hist->Entries[i].Buffer, SourceLength * sizeof(WCHAR));
|
||||
Offset += SourceLength;
|
||||
TargetBufferW[Offset++] = L'\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
ConvertInputUnicodeToAnsi(Console,
|
||||
Hist->Entries[i].Buffer, SourceLength * sizeof(WCHAR),
|
||||
&TargetBufferA[Offset], SourceLength);
|
||||
Offset += SourceLength;
|
||||
TargetBufferA[Offset++] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (GetCommandHistoryRequest->Unicode)
|
||||
BytesWritten = Offset * sizeof(WCHAR);
|
||||
else
|
||||
BytesWritten = Offset;
|
||||
}
|
||||
// FIXME: convert to UNICODE if Unicode == FALSE
|
||||
GetCommandHistoryRequest->HistoryLength = Buffer - (PBYTE)GetCommandHistoryRequest->History;
|
||||
|
||||
// GetCommandHistoryRequest->HistoryLength = TargetBuffer - (PBYTE)GetCommandHistoryRequest->History;
|
||||
GetCommandHistoryRequest->HistoryLength = BytesWritten;
|
||||
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
return Status;
|
||||
|
@ -523,7 +595,6 @@ CSR_API(SrvGetConsoleCommandHistoryLength)
|
|||
PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryLengthRequest;
|
||||
PCONSOLE Console;
|
||||
PHISTORY_BUFFER Hist;
|
||||
UNICODE_STRING ExeName;
|
||||
ULONG Length = 0;
|
||||
UINT i;
|
||||
|
||||
|
@ -538,24 +609,23 @@ CSR_API(SrvGetConsoleCommandHistoryLength)
|
|||
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);
|
||||
Hist = HistoryFindBuffer(Console,
|
||||
GetCommandHistoryLengthRequest->ExeName,
|
||||
GetCommandHistoryLengthRequest->ExeLength,
|
||||
GetCommandHistoryLengthRequest->Unicode2);
|
||||
if (Hist)
|
||||
{
|
||||
for (i = 0; i < Hist->NumEntries; i++)
|
||||
Length += Hist->Entries[i].Length + sizeof(WCHAR);
|
||||
Length += Hist->Entries[i].Length + sizeof(WCHAR); // Each entry is returned NULL-terminated
|
||||
}
|
||||
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);
|
||||
Length /= sizeof(WCHAR);
|
||||
|
||||
GetCommandHistoryLengthRequest->HistoryLength = Length;
|
||||
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
return Status;
|
||||
|
@ -567,7 +637,6 @@ CSR_API(SrvExpungeConsoleCommandHistory)
|
|||
PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ExpungeCommandHistoryRequest;
|
||||
PCONSOLE Console;
|
||||
PHISTORY_BUFFER Hist;
|
||||
UNICODE_STRING ExeName;
|
||||
|
||||
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||
(PVOID*)&ExpungeCommandHistoryRequest->ExeName,
|
||||
|
@ -580,11 +649,10 @@ CSR_API(SrvExpungeConsoleCommandHistory)
|
|||
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);
|
||||
Hist = HistoryFindBuffer(Console,
|
||||
ExpungeCommandHistoryRequest->ExeName,
|
||||
ExpungeCommandHistoryRequest->ExeLength,
|
||||
ExpungeCommandHistoryRequest->Unicode2);
|
||||
HistoryDeleteBuffer(Hist);
|
||||
|
||||
ConSrvReleaseConsole(Console, TRUE);
|
||||
|
@ -597,9 +665,6 @@ CSR_API(SrvSetConsoleNumberOfCommands)
|
|||
PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryNumberCommandsRequest;
|
||||
PCONSOLE Console;
|
||||
PHISTORY_BUFFER Hist;
|
||||
UINT MaxEntries = SetHistoryNumberCommandsRequest->NumCommands;
|
||||
UNICODE_STRING ExeName;
|
||||
PUNICODE_STRING OldEntryList, NewEntryList;
|
||||
|
||||
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||
(PVOID*)&SetHistoryNumberCommandsRequest->ExeName,
|
||||
|
@ -612,15 +677,15 @@ CSR_API(SrvSetConsoleNumberOfCommands)
|
|||
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 = SetHistoryNumberCommandsRequest->ExeLength;
|
||||
ExeName.Buffer = SetHistoryNumberCommandsRequest->ExeName;
|
||||
|
||||
Hist = HistoryFindBuffer(Console, &ExeName);
|
||||
Hist = HistoryFindBuffer(Console,
|
||||
SetHistoryNumberCommandsRequest->ExeName,
|
||||
SetHistoryNumberCommandsRequest->ExeLength,
|
||||
SetHistoryNumberCommandsRequest->Unicode2);
|
||||
if (Hist)
|
||||
{
|
||||
OldEntryList = Hist->Entries;
|
||||
NewEntryList = ConsoleAllocHeap(0, MaxEntries * sizeof(UNICODE_STRING));
|
||||
UINT MaxEntries = SetHistoryNumberCommandsRequest->NumCommands;
|
||||
PUNICODE_STRING OldEntryList = Hist->Entries;
|
||||
PUNICODE_STRING NewEntryList = ConsoleAllocHeap(0, MaxEntries * sizeof(UNICODE_STRING));
|
||||
if (!NewEntryList)
|
||||
{
|
||||
Status = STATUS_NO_MEMORY;
|
||||
|
@ -647,6 +712,7 @@ CSR_API(SrvSetConsoleNumberOfCommands)
|
|||
|
||||
CSR_API(SrvGetConsoleHistory)
|
||||
{
|
||||
#if 0 // Vista+
|
||||
PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
|
||||
PCONSOLE Console;
|
||||
NTSTATUS Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||
|
@ -658,10 +724,15 @@ CSR_API(SrvGetConsoleHistory)
|
|||
ConSrvReleaseConsole(Console, TRUE);
|
||||
}
|
||||
return Status;
|
||||
#else
|
||||
DPRINT1("%s not yet implemented\n", __FUNCTION__);
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
CSR_API(SrvSetConsoleHistory)
|
||||
{
|
||||
#if 0 // Vista+
|
||||
PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
|
||||
PCONSOLE Console;
|
||||
NTSTATUS Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
|
||||
|
@ -673,6 +744,10 @@ CSR_API(SrvSetConsoleHistory)
|
|||
ConSrvReleaseConsole(Console, TRUE);
|
||||
}
|
||||
return Status;
|
||||
#else
|
||||
DPRINT1("%s not yet implemented\n", __FUNCTION__);
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
CSR_API(SrvSetConsoleCommandHistoryMode)
|
||||
|
|
Loading…
Reference in a new issue