[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:
Hermès Bélusca-Maïto 2014-07-28 13:20:54 +00:00
parent 9ed2e0b5bc
commit b06a89c070
7 changed files with 946 additions and 544 deletions

View file

@ -18,31 +18,40 @@
/* FUNCTIONS ******************************************************************/ /* FUNCTIONS ******************************************************************/
/* static BOOL
* @implemented IntAddConsoleAlias(LPCVOID Source,
*/ DWORD SourceBufferLength,
BOOL LPCVOID Target,
WINAPI DWORD TargetBufferLength,
AddConsoleAliasW(LPCWSTR lpSource, LPCVOID lpExeName,
LPCWSTR lpTarget, BOOLEAN bUnicode)
LPCWSTR lpExeName)
{ {
NTSTATUS Status;
CONSOLE_API_MESSAGE ApiMessage; CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_ADDGETALIAS ConsoleAliasRequest = &ApiMessage.Data.ConsoleAliasRequest; PCONSOLE_ADDGETALIAS ConsoleAliasRequest = &ApiMessage.Data.ConsoleAliasRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer; PCSR_CAPTURE_BUFFER CaptureBuffer;
ULONG CapturedStrings; 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 */ /* Determine the needed sizes */
ConsoleAliasRequest->SourceLength = (wcslen(lpSource ) + 1) * sizeof(WCHAR); ConsoleAliasRequest->SourceLength = SourceBufferLength;
ConsoleAliasRequest->ExeLength = (wcslen(lpExeName) + 1) * sizeof(WCHAR); ConsoleAliasRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
ConsoleAliasRequest->Unicode =
ConsoleAliasRequest->Unicode2 = bUnicode;
CapturedStrings = 2; 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++; CapturedStrings++;
} }
else else
@ -64,19 +73,19 @@ AddConsoleAliasW(LPCWSTR lpSource,
/* Capture the strings */ /* Capture the strings */
CsrCaptureMessageBuffer(CaptureBuffer, CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpSource, (PVOID)Source,
ConsoleAliasRequest->SourceLength, ConsoleAliasRequest->SourceLength,
(PVOID*)&ConsoleAliasRequest->Source); (PVOID*)&ConsoleAliasRequest->Source);
CsrCaptureMessageBuffer(CaptureBuffer, CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpExeName, (PVOID)lpExeName,
ConsoleAliasRequest->ExeLength, ConsoleAliasRequest->ExeLength,
(PVOID*)&ConsoleAliasRequest->Exe); (PVOID*)&ConsoleAliasRequest->ExeName);
if (lpTarget) /* The target can be optional */ if (Target) /* The target can be optional */
{ {
CsrCaptureMessageBuffer(CaptureBuffer, CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpTarget, (PVOID)Target,
ConsoleAliasRequest->TargetLength, ConsoleAliasRequest->TargetLength,
(PVOID*)&ConsoleAliasRequest->Target); (PVOID*)&ConsoleAliasRequest->Target);
} }
@ -85,16 +94,16 @@ AddConsoleAliasW(LPCWSTR lpSource,
ConsoleAliasRequest->Target = NULL; ConsoleAliasRequest->Target = NULL;
} }
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
CaptureBuffer, CaptureBuffer,
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepAddAlias), CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepAddAlias),
sizeof(CONSOLE_ADDGETALIAS)); sizeof(*ConsoleAliasRequest));
CsrFreeCaptureBuffer(CaptureBuffer); CsrFreeCaptureBuffer(CaptureBuffer);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(ApiMessage.Status))
{ {
BaseSetLastNTError(Status); BaseSetLastNTError(ApiMessage.Status);
return FALSE; return FALSE;
} }
@ -107,64 +116,85 @@ AddConsoleAliasW(LPCWSTR lpSource,
*/ */
BOOL BOOL
WINAPI WINAPI
AddConsoleAliasA(LPCSTR lpSource, AddConsoleAliasW(LPCWSTR lpSource,
LPCSTR lpTarget, LPCWSTR lpTarget,
LPCSTR lpExeName) LPCWSTR lpExeName)
{ {
LPWSTR lpSourceW = NULL; DWORD SourceBufferLength, TargetBufferLength;
LPWSTR lpTargetW = NULL; SourceBufferLength = wcslen(lpSource) * sizeof(WCHAR);
LPWSTR lpExeNameW = NULL; TargetBufferLength = (lpTarget ? wcslen(lpTarget) * sizeof(WCHAR) : 0);
BOOL bRetVal;
if (lpSource) DPRINT1("AddConsoleAliasW entered with lpSource '%S' lpTarget '%S' lpExeName '%S'\n",
BasepAnsiStringToHeapUnicodeString(lpSource, (LPWSTR*)&lpSourceW); lpSource, lpTarget, lpExeName);
if (lpTarget)
BasepAnsiStringToHeapUnicodeString(lpTarget, (LPWSTR*)&lpTargetW);
if (lpExeName)
BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*)&lpExeNameW);
bRetVal = AddConsoleAliasW(lpSourceW, lpTargetW, lpExeNameW); return IntAddConsoleAlias(lpSource,
SourceBufferLength,
/* Clean up */ lpTarget,
if (lpSourceW) TargetBufferLength,
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpSourceW); lpExeName,
if (lpTargetW) TRUE);
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpTargetW);
if (lpExeNameW)
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpExeNameW);
return bRetVal;
} }
/* /*
* @implemented * @implemented
*/ */
DWORD BOOL
WINAPI WINAPI
GetConsoleAliasW(LPWSTR lpSource, AddConsoleAliasA(LPCSTR lpSource,
LPWSTR lpTargetBuffer, LPCSTR lpTarget,
DWORD TargetBufferLength, LPCSTR lpExeName)
LPWSTR 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; CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_ADDGETALIAS ConsoleAliasRequest = &ApiMessage.Data.ConsoleAliasRequest; PCONSOLE_ADDGETALIAS ConsoleAliasRequest = &ApiMessage.Data.ConsoleAliasRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer; 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); SetLastError(ERROR_INVALID_PARAMETER);
return 0; return 0;
} }
/* Determine the needed sizes */ if (lpExeName == NULL || dwNumChars == 0)
ConsoleAliasRequest->SourceLength = (wcslen(lpSource ) + 1) * sizeof(WCHAR); {
ConsoleAliasRequest->ExeLength = (wcslen(lpExeName) + 1) * sizeof(WCHAR); 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; ConsoleAliasRequest->TargetLength = TargetBufferLength;
/* Allocate a Capture Buffer */ /* Allocate a Capture Buffer */
@ -180,34 +210,37 @@ GetConsoleAliasW(LPWSTR lpSource,
/* Capture the strings */ /* Capture the strings */
CsrCaptureMessageBuffer(CaptureBuffer, CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpSource, (PVOID)Source,
ConsoleAliasRequest->SourceLength, ConsoleAliasRequest->SourceLength,
(PVOID*)&ConsoleAliasRequest->Source); (PVOID*)&ConsoleAliasRequest->Source);
CsrCaptureMessageBuffer(CaptureBuffer, CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpExeName, (PVOID)lpExeName,
ConsoleAliasRequest->ExeLength, ConsoleAliasRequest->ExeLength,
(PVOID*)&ConsoleAliasRequest->Exe); (PVOID*)&ConsoleAliasRequest->ExeName);
/* Allocate space for the target buffer */ /* Allocate space for the target buffer */
CsrAllocateMessagePointer(CaptureBuffer, CsrAllocateMessagePointer(CaptureBuffer,
ConsoleAliasRequest->TargetLength, ConsoleAliasRequest->TargetLength,
(PVOID*)&ConsoleAliasRequest->Target); (PVOID*)&ConsoleAliasRequest->Target);
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
CaptureBuffer, CaptureBuffer,
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAlias), CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAlias),
sizeof(CONSOLE_ADDGETALIAS)); sizeof(*ConsoleAliasRequest));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(ApiMessage.Status))
{ {
CsrFreeCaptureBuffer(CaptureBuffer); CsrFreeCaptureBuffer(CaptureBuffer);
BaseSetLastNTError(Status); BaseSetLastNTError(ApiMessage.Status);
return 0;
if (ApiMessage.Status == STATUS_BUFFER_TOO_SMALL)
return ConsoleAliasRequest->TargetLength;
else
return 0;
} }
/* Copy the returned target string into the user buffer */ /* Copy the returned target string into the user buffer */
// wcscpy(lpTargetBuffer, ConsoleAliasRequest->Target); memcpy(Target,
memcpy(lpTargetBuffer,
ConsoleAliasRequest->Target, ConsoleAliasRequest->Target,
ConsoleAliasRequest->TargetLength); ConsoleAliasRequest->TargetLength);
@ -223,65 +256,20 @@ GetConsoleAliasW(LPWSTR lpSource,
*/ */
DWORD DWORD
WINAPI WINAPI
GetConsoleAliasA(LPSTR lpSource, GetConsoleAliasW(LPWSTR lpSource,
LPSTR lpTargetBuffer, LPWSTR lpTargetBuffer,
DWORD TargetBufferLength, DWORD TargetBufferLength,
LPSTR lpExeName) LPWSTR lpExeName)
{ {
LPWSTR lpwSource; DPRINT1("GetConsoleAliasW entered with lpSource '%S' lpExeName '%S'\n",
LPWSTR lpwExeName; lpSource, lpExeName);
LPWSTR lpwTargetBuffer;
UINT dwSourceSize;
UINT dwExeNameSize;
UINT dwResult;
DPRINT("GetConsoleAliasA entered\n"); return IntGetConsoleAlias(lpSource,
wcslen(lpSource) * sizeof(WCHAR),
if (lpTargetBuffer == NULL) lpTargetBuffer,
{ TargetBufferLength,
SetLastError(ERROR_INVALID_PARAMETER); lpExeName,
return 0; TRUE);
}
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;
} }
@ -290,25 +278,48 @@ GetConsoleAliasA(LPSTR lpSource,
*/ */
DWORD DWORD
WINAPI WINAPI
GetConsoleAliasesW(LPWSTR AliasBuffer, GetConsoleAliasA(LPSTR lpSource,
DWORD AliasBufferLength, LPSTR lpTargetBuffer,
LPWSTR ExeName) 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; CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_GETALLALIASES GetAllAliasesRequest = &ApiMessage.Data.GetAllAliasesRequest; PCONSOLE_GETALLALIASES GetAllAliasesRequest = &ApiMessage.Data.GetAllAliasesRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer; PCSR_CAPTURE_BUFFER CaptureBuffer;
DPRINT("GetConsoleAliasesW entered\n"); DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) : 0);
/* Determine the needed sizes */ if (lpExeName == NULL || dwNumChars == 0)
GetAllAliasesRequest->ExeLength = GetConsoleAliasesLengthW(ExeName);
if (GetAllAliasesRequest->ExeLength == 0 ||
GetAllAliasesRequest->ExeLength > AliasBufferLength)
{ {
SetLastError(ERROR_INVALID_PARAMETER);
return 0; 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; GetAllAliasesRequest->AliasesBufferLength = AliasBufferLength;
/* Allocate a Capture Buffer */ /* Allocate a Capture Buffer */
@ -323,7 +334,7 @@ GetConsoleAliasesW(LPWSTR AliasBuffer,
/* Capture the exe name and allocate space for the aliases buffer */ /* Capture the exe name and allocate space for the aliases buffer */
CsrCaptureMessageBuffer(CaptureBuffer, CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)ExeName, (PVOID)lpExeName,
GetAllAliasesRequest->ExeLength, GetAllAliasesRequest->ExeLength,
(PVOID*)&GetAllAliasesRequest->ExeName); (PVOID*)&GetAllAliasesRequest->ExeName);
@ -331,18 +342,18 @@ GetConsoleAliasesW(LPWSTR AliasBuffer,
GetAllAliasesRequest->AliasesBufferLength, GetAllAliasesRequest->AliasesBufferLength,
(PVOID*)&GetAllAliasesRequest->AliasesBuffer); (PVOID*)&GetAllAliasesRequest->AliasesBuffer);
Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
CaptureBuffer, CaptureBuffer,
CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliases), CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliases),
sizeof(CONSOLE_GETALLALIASES)); sizeof(*GetAllAliasesRequest));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(ApiMessage.Status))
{ {
BaseSetLastNTError(Status); CsrFreeCaptureBuffer(CaptureBuffer);
BaseSetLastNTError(ApiMessage.Status);
return 0; return 0;
} }
/* Copy the returned aliases string into the user buffer */ /* Copy the returned aliases string into the user buffer */
// wcscpy(AliasBuffer, GetAllAliasesRequest->AliasesBuffer);
memcpy(AliasBuffer, memcpy(AliasBuffer,
GetAllAliasesRequest->AliasesBuffer, GetAllAliasesRequest->AliasesBuffer,
GetAllAliasesRequest->AliasesBufferLength); GetAllAliasesRequest->AliasesBufferLength);
@ -350,7 +361,26 @@ GetConsoleAliasesW(LPWSTR AliasBuffer,
/* Release the capture buffer and exit */ /* Release the capture buffer and exit */
CsrFreeCaptureBuffer(CaptureBuffer); 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, DWORD AliasBufferLength,
LPSTR ExeName) LPSTR ExeName)
{ {
DWORD dwRetVal = 0; DPRINT1("GetConsoleAliasesA entered with lpExeName '%s'\n",
LPWSTR lpwExeName = NULL; ExeName);
LPWSTR lpwAliasBuffer;
DPRINT("GetConsoleAliasesA entered\n"); return IntGetConsoleAliases(AliasBuffer,
AliasBufferLength,
if (ExeName) ExeName,
BasepAnsiStringToHeapUnicodeString(ExeName, (LPWSTR*)&lpwExeName); FALSE);
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;
} }
@ -512,6 +528,7 @@ WINAPI
GetConsoleAliasExesW(LPWSTR lpExeNameBuffer, GetConsoleAliasExesW(LPWSTR lpExeNameBuffer,
DWORD ExeNameBufferLength) DWORD ExeNameBufferLength)
{ {
DPRINT1("GetConsoleAliasExesW called\n");
return IntGetConsoleAliasExes(lpExeNameBuffer, ExeNameBufferLength, TRUE); return IntGetConsoleAliasExes(lpExeNameBuffer, ExeNameBufferLength, TRUE);
} }
@ -524,6 +541,7 @@ WINAPI
GetConsoleAliasExesA(LPSTR lpExeNameBuffer, GetConsoleAliasExesA(LPSTR lpExeNameBuffer,
DWORD ExeNameBufferLength) DWORD ExeNameBufferLength)
{ {
DPRINT1("GetConsoleAliasExesA called\n");
return IntGetConsoleAliasExes(lpExeNameBuffer, ExeNameBufferLength, FALSE); return IntGetConsoleAliasExes(lpExeNameBuffer, ExeNameBufferLength, FALSE);
} }
@ -558,6 +576,7 @@ DWORD
WINAPI WINAPI
GetConsoleAliasExesLengthW(VOID) GetConsoleAliasExesLengthW(VOID)
{ {
DPRINT1("GetConsoleAliasExesLengthW called\n");
return IntGetConsoleAliasExesLength(TRUE); return IntGetConsoleAliasExesLength(TRUE);
} }
@ -569,6 +588,7 @@ DWORD
WINAPI WINAPI
GetConsoleAliasExesLengthA(VOID) GetConsoleAliasExesLengthA(VOID)
{ {
DPRINT1("GetConsoleAliasExesLengthA called\n");
return IntGetConsoleAliasExesLength(FALSE); return IntGetConsoleAliasExesLength(FALSE);
} }

View file

@ -1392,15 +1392,29 @@ SetConsoleCursorInfo(HANDLE hConsoleOutput,
/*-------------------------------------------------------------- /*--------------------------------------------------------------
* GetNumberOfConsoleMouseButtons * GetNumberOfConsoleMouseButtons
* *
* @unimplemented * @implemented
*/ */
BOOL BOOL
WINAPI WINAPI
GetNumberOfConsoleMouseButtons(LPDWORD lpNumberOfMouseButtons) GetNumberOfConsoleMouseButtons(LPDWORD lpNumberOfMouseButtons)
{ {
DPRINT1("GetNumberOfConsoleMouseButtons(0x%p) UNIMPLEMENTED!\n", lpNumberOfMouseButtons); CONSOLE_API_MESSAGE ApiMessage;
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); PCONSOLE_GETMOUSEINFO GetMouseInfoRequest = &ApiMessage.Data.GetMouseInfoRequest;
return FALSE;
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; return FALSE;
} }
BOOL
WINAPI
GetConsoleNlsMode(HANDLE hConsole, LPDWORD lpMode)
{
STUB;
return FALSE;
}
BOOL BOOL
WINAPI WINAPI
SetConsoleCursorMode(HANDLE hConsole, BOOL Unknown1, BOOL Unknown2) SetConsoleCursorMode(HANDLE hConsole, BOOL Unknown1, BOOL Unknown2)
@ -2541,7 +2547,7 @@ SetConsoleCursorMode(HANDLE hConsole, BOOL Unknown1, BOOL Unknown2)
BOOL BOOL
WINAPI WINAPI
SetConsoleLocalEUDC(DWORD Unknown1, DWORD Unknown2, DWORD Unknown3, DWORD Unknown4) GetConsoleNlsMode(HANDLE hConsole, LPDWORD lpMode)
{ {
STUB; STUB;
return FALSE; return FALSE;
@ -2555,6 +2561,14 @@ SetConsoleNlsMode(HANDLE hConsole, DWORD dwMode)
return FALSE; return FALSE;
} }
BOOL
WINAPI
SetConsoleLocalEUDC(DWORD Unknown1, DWORD Unknown2, DWORD Unknown3, DWORD Unknown4)
{
STUB;
return FALSE;
}
BOOL BOOL
WINAPI WINAPI
RegisterConsoleIME(HWND hWnd, LPDWORD ThreadId) RegisterConsoleIME(HWND hWnd, LPDWORD ThreadId)

View file

@ -319,6 +319,12 @@ typedef struct
*/ */
} CONSOLE_GETSETCURSORINFO, *PCONSOLE_GETSETCURSORINFO; } CONSOLE_GETSETCURSORINFO, *PCONSOLE_GETSETCURSORINFO;
typedef struct
{
HANDLE ConsoleHandle;
ULONG NumButtons;
} CONSOLE_GETMOUSEINFO, *PCONSOLE_GETMOUSEINFO;
typedef struct typedef struct
{ {
HANDLE ConsoleHandle; HANDLE ConsoleHandle;
@ -370,7 +376,8 @@ typedef struct
DWORD DesiredAccess; DWORD DesiredAccess;
BOOL InheritHandle; BOOL InheritHandle;
DWORD ShareMode; 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 * This structure holds the initialization information
* for graphics screen buffers. * for graphics screen buffers.
@ -656,20 +663,26 @@ typedef struct
typedef struct typedef struct
{ {
ULONG SourceLength; HANDLE ConsoleHandle;
ULONG TargetLength; // Also used for storing the number of bytes written. USHORT SourceLength;
ULONG ExeLength; USHORT TargetLength; // Also used for storing the number of bytes written.
LPWSTR Source; USHORT ExeLength;
LPWSTR Target; PVOID Source;
LPWSTR Exe; PVOID Target;
PVOID ExeName;
BOOLEAN Unicode;
BOOLEAN Unicode2;
} CONSOLE_ADDGETALIAS, *PCONSOLE_ADDGETALIAS; } CONSOLE_ADDGETALIAS, *PCONSOLE_ADDGETALIAS;
typedef struct typedef struct
{ {
DWORD ExeLength; HANDLE ConsoleHandle;
DWORD AliasesBufferLength; USHORT ExeLength;
LPWSTR ExeName; PVOID ExeName;
LPWSTR AliasesBuffer; BOOLEAN Unicode;
BOOLEAN Unicode2;
ULONG AliasesBufferLength;
PVOID AliasesBuffer;
} CONSOLE_GETALLALIASES, *PCONSOLE_GETALLALIASES; } CONSOLE_GETALLALIASES, *PCONSOLE_GETALLALIASES;
typedef struct typedef struct
@ -704,7 +717,6 @@ typedef struct
HANDLE ConsoleHandle; HANDLE ConsoleHandle;
ULONG HistoryLength; ULONG HistoryLength;
PVOID History; PVOID History;
// UNICODE_STRING ExeName;
USHORT ExeLength; USHORT ExeLength;
PVOID ExeName; PVOID ExeName;
BOOLEAN Unicode; BOOLEAN Unicode;
@ -715,7 +727,6 @@ typedef struct
{ {
HANDLE ConsoleHandle; HANDLE ConsoleHandle;
ULONG HistoryLength; ULONG HistoryLength;
// UNICODE_STRING ExeName;
USHORT ExeLength; USHORT ExeLength;
PVOID ExeName; PVOID ExeName;
BOOLEAN Unicode; BOOLEAN Unicode;
@ -725,7 +736,6 @@ typedef struct
typedef struct typedef struct
{ {
HANDLE ConsoleHandle; HANDLE ConsoleHandle;
// UNICODE_STRING ExeName;
USHORT ExeLength; USHORT ExeLength;
PVOID ExeName; PVOID ExeName;
BOOLEAN Unicode; BOOLEAN Unicode;
@ -743,7 +753,6 @@ typedef struct
{ {
HANDLE ConsoleHandle; HANDLE ConsoleHandle;
ULONG NumCommands; ULONG NumCommands;
// UNICODE_STRING ExeName;
USHORT ExeLength; USHORT ExeLength;
PVOID ExeName; PVOID ExeName;
BOOLEAN Unicode; BOOLEAN Unicode;
@ -814,11 +823,12 @@ typedef struct _CONSOLE_API_MESSAGE
CONSOLE_GETHANDLEINFO GetHandleInfoRequest; CONSOLE_GETHANDLEINFO GetHandleInfoRequest;
CONSOLE_SETHANDLEINFO SetHandleInfoRequest; CONSOLE_SETHANDLEINFO SetHandleInfoRequest;
/* Cursor */ /* Cursor & Mouse */
CONSOLE_SHOWCURSOR ShowCursorRequest; CONSOLE_SHOWCURSOR ShowCursorRequest;
CONSOLE_SETCURSOR SetCursorRequest; CONSOLE_SETCURSOR SetCursorRequest;
CONSOLE_GETSETCURSORINFO CursorInfoRequest; CONSOLE_GETSETCURSORINFO CursorInfoRequest;
CONSOLE_SETCURSORPOSITION SetCursorPositionRequest; CONSOLE_SETCURSORPOSITION SetCursorPositionRequest;
CONSOLE_GETMOUSEINFO GetMouseInfoRequest;
/* Screen-buffer */ /* Screen-buffer */
CONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest; CONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest;

File diff suppressed because it is too large Load diff

View file

@ -389,10 +389,11 @@ ConDrvWriteConsoleInput(IN PCONSOLE Console,
ASSERT( (InputRecord != NULL && NumEventsToWrite > 0) || ASSERT( (InputRecord != NULL && NumEventsToWrite > 0) ||
(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; // 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) if (!Unicode)
{ {

View file

@ -977,8 +977,18 @@ CSR_API(SrvConsoleNotifyLastClose)
CSR_API(SrvGetConsoleMouseInfo) CSR_API(SrvGetConsoleMouseInfo)
{ {
DPRINT1("%s not yet implemented\n", __FUNCTION__); NTSTATUS Status;
return STATUS_NOT_IMPLEMENTED; 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) CSR_API(SrvSetConsoleKeyShortcuts)

View file

@ -4,8 +4,6 @@
* FILE: win32ss/user/winsrv/consrv/lineinput.c * FILE: win32ss/user/winsrv/consrv/lineinput.c
* PURPOSE: Console line input functions * PURPOSE: Console line input functions
* PROGRAMMERS: Jeffrey Morlan * PROGRAMMERS: Jeffrey Morlan
*
* NOTE: It's something frontend-related... (--> read my mind... ;) )
*/ */
/* INCLUDES *******************************************************************/ /* INCLUDES *******************************************************************/
@ -21,11 +19,27 @@ typedef struct _HISTORY_BUFFER
UINT Position; UINT Position;
UINT MaxEntries; UINT MaxEntries;
UINT NumEntries; UINT NumEntries;
PUNICODE_STRING Entries;
UNICODE_STRING ExeName; UNICODE_STRING ExeName;
PUNICODE_STRING Entries;
} HISTORY_BUFFER, *PHISTORY_BUFFER; } 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 **********************************************************/ /* PRIVATE FUNCTIONS **********************************************************/
static PHISTORY_BUFFER static PHISTORY_BUFFER
@ -124,17 +138,51 @@ HistoryGetCurrentEntry(PCONSOLE Console, PUNICODE_STRING Entry)
} }
static PHISTORY_BUFFER 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) 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 */ /* 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(&ExeNameU, &Hist->ExeName, TRUE))
if (RtlPrefixUnicodeString(ExeName, &Hist->ExeName, TRUE)) {
if (!UnicodeExe) ConsoleFreeHeap(ExeNameU.Buffer);
return Hist; return Hist;
}
Entry = Entry->Flink; Entry = Entry->Flink;
} }
if (!UnicodeExe) ConsoleFreeHeap(ExeNameU.Buffer);
return NULL; return NULL;
} }
@ -190,7 +238,7 @@ LineInputSetPos(PCONSOLE Console, UINT Pos)
} }
static VOID static VOID
LineInputEdit(PCONSOLE Console, UINT NumToDelete, UINT NumToInsert, WCHAR *Insertion) LineInputEdit(PCONSOLE Console, UINT NumToDelete, UINT NumToInsert, PWCHAR Insertion)
{ {
PTEXTMODE_SCREEN_BUFFER ActiveBuffer; PTEXTMODE_SCREEN_BUFFER ActiveBuffer;
UINT Pos = Console->LinePos; UINT Pos = Console->LinePos;
@ -458,11 +506,10 @@ CSR_API(SrvGetConsoleCommandHistory)
NTSTATUS Status; NTSTATUS Status;
PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryRequest; PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryRequest;
PCONSOLE Console; PCONSOLE Console;
ULONG BytesWritten = 0;
PHISTORY_BUFFER Hist; PHISTORY_BUFFER Hist;
UNICODE_STRING ExeName;
PBYTE Buffer = (PBYTE)GetCommandHistoryRequest->History; DPRINT1("SrvGetConsoleCommandHistory entered\n");
ULONG BufferSize = GetCommandHistoryRequest->HistoryLength;
UINT i;
if ( !CsrValidateMessageBuffer(ApiMessage, if ( !CsrValidateMessageBuffer(ApiMessage,
(PVOID*)&GetCommandHistoryRequest->History, (PVOID*)&GetCommandHistoryRequest->History,
@ -479,39 +526,64 @@ CSR_API(SrvGetConsoleCommandHistory)
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE); Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status; if (!NT_SUCCESS(Status)) return Status;
// FIXME: convert to UNICODE if Unicode(2) == FALSE Hist = HistoryFindBuffer(Console,
ExeName.Length = ExeName.MaximumLength = GetCommandHistoryRequest->ExeLength; GetCommandHistoryRequest->ExeName,
ExeName.Buffer = GetCommandHistoryRequest->ExeName; GetCommandHistoryRequest->ExeLength,
GetCommandHistoryRequest->Unicode2);
Hist = HistoryFindBuffer(Console, &ExeName);
if (Hist) 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++) 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; Status = STATUS_BUFFER_OVERFLOW;
break; 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); ConSrvReleaseConsole(Console, TRUE);
return Status; return Status;
@ -523,7 +595,6 @@ CSR_API(SrvGetConsoleCommandHistoryLength)
PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryLengthRequest; PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryLengthRequest;
PCONSOLE Console; PCONSOLE Console;
PHISTORY_BUFFER Hist; PHISTORY_BUFFER Hist;
UNICODE_STRING ExeName;
ULONG Length = 0; ULONG Length = 0;
UINT i; UINT i;
@ -538,24 +609,23 @@ CSR_API(SrvGetConsoleCommandHistoryLength)
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE); Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status; if (!NT_SUCCESS(Status)) return Status;
// FIXME: convert to UNICODE if Unicode(2) == FALSE Hist = HistoryFindBuffer(Console,
ExeName.Length = ExeName.MaximumLength = GetCommandHistoryLengthRequest->ExeLength; GetCommandHistoryLengthRequest->ExeName,
ExeName.Buffer = GetCommandHistoryLengthRequest->ExeName; GetCommandHistoryLengthRequest->ExeLength,
GetCommandHistoryLengthRequest->Unicode2);
Hist = HistoryFindBuffer(Console, &ExeName);
if (Hist) if (Hist)
{ {
for (i = 0; i < Hist->NumEntries; i++) 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 * Quick and dirty way of getting the number of bytes of the
* corresponding ANSI string from the one in UNICODE. * corresponding ANSI string from the one in UNICODE.
*/ */
if (!GetCommandHistoryLengthRequest->Unicode) if (!GetCommandHistoryLengthRequest->Unicode)
GetCommandHistoryLengthRequest->HistoryLength /= sizeof(WCHAR); Length /= sizeof(WCHAR);
GetCommandHistoryLengthRequest->HistoryLength = Length;
ConSrvReleaseConsole(Console, TRUE); ConSrvReleaseConsole(Console, TRUE);
return Status; return Status;
@ -567,7 +637,6 @@ CSR_API(SrvExpungeConsoleCommandHistory)
PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ExpungeCommandHistoryRequest; PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ExpungeCommandHistoryRequest;
PCONSOLE Console; PCONSOLE Console;
PHISTORY_BUFFER Hist; PHISTORY_BUFFER Hist;
UNICODE_STRING ExeName;
if (!CsrValidateMessageBuffer(ApiMessage, if (!CsrValidateMessageBuffer(ApiMessage,
(PVOID*)&ExpungeCommandHistoryRequest->ExeName, (PVOID*)&ExpungeCommandHistoryRequest->ExeName,
@ -580,11 +649,10 @@ CSR_API(SrvExpungeConsoleCommandHistory)
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE); Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status; if (!NT_SUCCESS(Status)) return Status;
// FIXME: convert to UNICODE if Unicode(2) == FALSE Hist = HistoryFindBuffer(Console,
ExeName.Length = ExeName.MaximumLength = ExpungeCommandHistoryRequest->ExeLength; ExpungeCommandHistoryRequest->ExeName,
ExeName.Buffer = ExpungeCommandHistoryRequest->ExeName; ExpungeCommandHistoryRequest->ExeLength,
ExpungeCommandHistoryRequest->Unicode2);
Hist = HistoryFindBuffer(Console, &ExeName);
HistoryDeleteBuffer(Hist); HistoryDeleteBuffer(Hist);
ConSrvReleaseConsole(Console, TRUE); ConSrvReleaseConsole(Console, TRUE);
@ -597,9 +665,6 @@ CSR_API(SrvSetConsoleNumberOfCommands)
PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryNumberCommandsRequest; PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryNumberCommandsRequest;
PCONSOLE Console; PCONSOLE Console;
PHISTORY_BUFFER Hist; PHISTORY_BUFFER Hist;
UINT MaxEntries = SetHistoryNumberCommandsRequest->NumCommands;
UNICODE_STRING ExeName;
PUNICODE_STRING OldEntryList, NewEntryList;
if (!CsrValidateMessageBuffer(ApiMessage, if (!CsrValidateMessageBuffer(ApiMessage,
(PVOID*)&SetHistoryNumberCommandsRequest->ExeName, (PVOID*)&SetHistoryNumberCommandsRequest->ExeName,
@ -612,15 +677,15 @@ CSR_API(SrvSetConsoleNumberOfCommands)
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE); Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status; if (!NT_SUCCESS(Status)) return Status;
// FIXME: convert to UNICODE if Unicode(2) == FALSE Hist = HistoryFindBuffer(Console,
ExeName.Length = ExeName.MaximumLength = SetHistoryNumberCommandsRequest->ExeLength; SetHistoryNumberCommandsRequest->ExeName,
ExeName.Buffer = SetHistoryNumberCommandsRequest->ExeName; SetHistoryNumberCommandsRequest->ExeLength,
SetHistoryNumberCommandsRequest->Unicode2);
Hist = HistoryFindBuffer(Console, &ExeName);
if (Hist) if (Hist)
{ {
OldEntryList = Hist->Entries; UINT MaxEntries = SetHistoryNumberCommandsRequest->NumCommands;
NewEntryList = ConsoleAllocHeap(0, MaxEntries * sizeof(UNICODE_STRING)); PUNICODE_STRING OldEntryList = Hist->Entries;
PUNICODE_STRING NewEntryList = ConsoleAllocHeap(0, MaxEntries * sizeof(UNICODE_STRING));
if (!NewEntryList) if (!NewEntryList)
{ {
Status = STATUS_NO_MEMORY; Status = STATUS_NO_MEMORY;
@ -647,6 +712,7 @@ CSR_API(SrvSetConsoleNumberOfCommands)
CSR_API(SrvGetConsoleHistory) CSR_API(SrvGetConsoleHistory)
{ {
#if 0 // Vista+
PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest; PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
PCONSOLE Console; PCONSOLE Console;
NTSTATUS Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE); NTSTATUS Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
@ -658,10 +724,15 @@ CSR_API(SrvGetConsoleHistory)
ConSrvReleaseConsole(Console, TRUE); ConSrvReleaseConsole(Console, TRUE);
} }
return Status; return Status;
#else
DPRINT1("%s not yet implemented\n", __FUNCTION__);
return STATUS_NOT_IMPLEMENTED;
#endif
} }
CSR_API(SrvSetConsoleHistory) CSR_API(SrvSetConsoleHistory)
{ {
#if 0 // Vista+
PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest; PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
PCONSOLE Console; PCONSOLE Console;
NTSTATUS Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE); NTSTATUS Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
@ -673,6 +744,10 @@ CSR_API(SrvSetConsoleHistory)
ConSrvReleaseConsole(Console, TRUE); ConSrvReleaseConsole(Console, TRUE);
} }
return Status; return Status;
#else
DPRINT1("%s not yet implemented\n", __FUNCTION__);
return STATUS_NOT_IMPLEMENTED;
#endif
} }
CSR_API(SrvSetConsoleCommandHistoryMode) CSR_API(SrvSetConsoleCommandHistoryMode)