Author: hbelusca
Date: Mon Jul 28 13:20:54 2014
New Revision: 63751
URL:
http://svn.reactos.org/svn/reactos?rev=63751&view=rev
Log:
[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
Modified:
branches/condrv_restructure/dll/win32/kernel32/client/console/alias.c
branches/condrv_restructure/dll/win32/kernel32/client/console/console.c
branches/condrv_restructure/include/reactos/subsys/win/conmsg.h
branches/condrv_restructure/win32ss/user/winsrv/consrv/alias.c
branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/coninput.c
branches/condrv_restructure/win32ss/user/winsrv/consrv/console.c
branches/condrv_restructure/win32ss/user/winsrv/consrv/lineinput.c
Modified: branches/condrv_restructure/dll/win32/kernel32/client/console/alias.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/dll/win32/ke…
==============================================================================
--- branches/condrv_restructure/dll/win32/kernel32/client/console/alias.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/dll/win32/kernel32/client/console/alias.c [iso-8859-1] Mon
Jul 28 13:20:54 2014
@@ -18,31 +18,40 @@
/* FUNCTIONS ******************************************************************/
-/*
- * @implemented
- */
-BOOL
-WINAPI
-AddConsoleAliasW(LPCWSTR lpSource,
- LPCWSTR lpTarget,
- LPCWSTR lpExeName)
-{
- NTSTATUS Status;
+static BOOL
+IntAddConsoleAlias(LPCVOID Source,
+ DWORD SourceBufferLength,
+ LPCVOID Target,
+ DWORD TargetBufferLength,
+ LPCVOID lpExeName,
+ BOOLEAN bUnicode)
+{
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 */
- {
- ConsoleAliasRequest->TargetLength = (wcslen(lpTarget) + 1) * sizeof(WCHAR);
+ if (Target) /* The target can be optional */
+ {
+ ConsoleAliasRequest->TargetLength = TargetBufferLength;
CapturedStrings++;
}
else
@@ -64,19 +73,19 @@
/* Capture the strings */
CsrCaptureMessageBuffer(CaptureBuffer,
- (PVOID)lpSource,
+ (PVOID)Source,
ConsoleAliasRequest->SourceLength,
(PVOID*)&ConsoleAliasRequest->Source);
CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpExeName,
ConsoleAliasRequest->ExeLength,
- (PVOID*)&ConsoleAliasRequest->Exe);
-
- if (lpTarget) /* The target can be optional */
+ (PVOID*)&ConsoleAliasRequest->ExeName);
+
+ if (Target) /* The target can be optional */
{
CsrCaptureMessageBuffer(CaptureBuffer,
- (PVOID)lpTarget,
+ (PVOID)Target,
ConsoleAliasRequest->TargetLength,
(PVOID*)&ConsoleAliasRequest->Target);
}
@@ -85,20 +94,45 @@
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))
- {
- BaseSetLastNTError(Status);
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
return FALSE;
}
return TRUE;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+AddConsoleAliasW(LPCWSTR lpSource,
+ LPCWSTR lpTarget,
+ LPCWSTR lpExeName)
+{
+ DWORD SourceBufferLength, TargetBufferLength;
+ SourceBufferLength = wcslen(lpSource) * sizeof(WCHAR);
+ TargetBufferLength = (lpTarget ? wcslen(lpTarget) * sizeof(WCHAR) : 0);
+
+ DPRINT1("AddConsoleAliasW entered with lpSource '%S' lpTarget
'%S' lpExeName '%S'\n",
+ lpSource, lpTarget, lpExeName);
+
+ return IntAddConsoleAlias(lpSource,
+ SourceBufferLength,
+ lpTarget,
+ TargetBufferLength,
+ lpExeName,
+ TRUE);
}
@@ -111,60 +145,56 @@
LPCSTR lpTarget,
LPCSTR lpExeName)
{
- LPWSTR lpSourceW = NULL;
- LPWSTR lpTargetW = NULL;
- LPWSTR lpExeNameW = NULL;
- BOOL bRetVal;
-
- if (lpSource)
- BasepAnsiStringToHeapUnicodeString(lpSource, (LPWSTR*)&lpSourceW);
- if (lpTarget)
- BasepAnsiStringToHeapUnicodeString(lpTarget, (LPWSTR*)&lpTargetW);
- if (lpExeName)
- BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*)&lpExeNameW);
-
- 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;
-}
-
-
-/*
- * @implemented
- */
-DWORD
-WINAPI
-GetConsoleAliasW(LPWSTR lpSource,
- LPWSTR lpTargetBuffer,
- DWORD TargetBufferLength,
- LPWSTR lpExeName)
-{
- NTSTATUS Status;
+ 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)
+{
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);
-
- if (lpTargetBuffer == NULL)
+ DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) :
0);
+
+ if (Source == NULL || Target == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
+ if (lpExeName == NULL || dwNumChars == 0)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ ConsoleAliasRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+
/* Determine the needed sizes */
- ConsoleAliasRequest->SourceLength = (wcslen(lpSource ) + 1) * sizeof(WCHAR);
- ConsoleAliasRequest->ExeLength = (wcslen(lpExeName) + 1) * sizeof(WCHAR);
-
- ConsoleAliasRequest->Target = NULL;
+ ConsoleAliasRequest->SourceLength = SourceBufferLength;
+ ConsoleAliasRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) :
sizeof(CHAR));
+ ConsoleAliasRequest->Unicode =
+ ConsoleAliasRequest->Unicode2 = bUnicode;
+
ConsoleAliasRequest->TargetLength = TargetBufferLength;
/* Allocate a Capture Buffer */
@@ -180,34 +210,37 @@
/* 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);
@@ -215,6 +248,28 @@
CsrFreeCaptureBuffer(CaptureBuffer);
return ConsoleAliasRequest->TargetLength;
+}
+
+
+/*
+ * @implemented
+ */
+DWORD
+WINAPI
+GetConsoleAliasW(LPWSTR lpSource,
+ LPWSTR lpTargetBuffer,
+ DWORD TargetBufferLength,
+ LPWSTR lpExeName)
+{
+ DPRINT1("GetConsoleAliasW entered with lpSource '%S' lpExeName
'%S'\n",
+ lpSource, lpExeName);
+
+ return IntGetConsoleAlias(lpSource,
+ wcslen(lpSource) * sizeof(WCHAR),
+ lpTargetBuffer,
+ TargetBufferLength,
+ lpExeName,
+ TRUE);
}
@@ -228,86 +283,42 @@
DWORD TargetBufferLength,
LPSTR lpExeName)
{
- LPWSTR lpwSource;
- LPWSTR lpwExeName;
- LPWSTR lpwTargetBuffer;
- UINT dwSourceSize;
- UINT dwExeNameSize;
- UINT dwResult;
-
- 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;
-}
-
-
-/*
- * @implemented
- */
-DWORD
-WINAPI
-GetConsoleAliasesW(LPWSTR AliasBuffer,
- DWORD AliasBufferLength,
- LPWSTR ExeName)
-{
- NTSTATUS Status;
+ 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)
+{
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);
+
+ if (lpExeName == NULL || dwNumChars == 0)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ GetAllAliasesRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
/* Determine the needed sizes */
- GetAllAliasesRequest->ExeLength = GetConsoleAliasesLengthW(ExeName);
- if (GetAllAliasesRequest->ExeLength == 0 ||
- GetAllAliasesRequest->ExeLength > AliasBufferLength)
- {
- return 0;
- }
+ GetAllAliasesRequest->ExeLength = dwNumChars * (bUnicode ? sizeof(WCHAR) :
sizeof(CHAR));
+ GetAllAliasesRequest->Unicode =
+ GetAllAliasesRequest->Unicode2 = bUnicode;
GetAllAliasesRequest->AliasesBufferLength = AliasBufferLength;
@@ -323,7 +334,7 @@
/* 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 @@
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))
- {
- BaseSetLastNTError(Status);
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ CaptureBuffer,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetAliases),
+ sizeof(*GetAllAliasesRequest));
+ if (!NT_SUCCESS(ApiMessage.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 @@
/* 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 @@
DWORD AliasBufferLength,
LPSTR ExeName)
{
- DWORD dwRetVal = 0;
- LPWSTR lpwExeName = NULL;
- LPWSTR lpwAliasBuffer;
-
- DPRINT("GetConsoleAliasesA entered\n");
-
- if (ExeName)
- BasepAnsiStringToHeapUnicodeString(ExeName, (LPWSTR*)&lpwExeName);
-
- lpwAliasBuffer = HeapAlloc(GetProcessHeap(), 0, AliasBufferLength * sizeof(WCHAR));
-
- dwRetVal = GetConsoleAliasesW(lpwAliasBuffer, AliasBufferLength * sizeof(WCHAR),
lpwExeName);
-
- if (lpwExeName)
- RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpwExeName);
-
- if (dwRetVal)
- dwRetVal = WideCharToMultiByte(CP_ACP, 0, lpwAliasBuffer, dwRetVal /**/ /
sizeof(WCHAR) /**/, AliasBuffer, AliasBufferLength, NULL, NULL);
-
- HeapFree(GetProcessHeap(), 0, lpwAliasBuffer);
- return dwRetVal;
+ DPRINT1("GetConsoleAliasesA entered with lpExeName '%s'\n",
+ ExeName);
+
+ return IntGetConsoleAliases(AliasBuffer,
+ AliasBufferLength,
+ ExeName,
+ FALSE);
}
@@ -512,6 +528,7 @@
GetConsoleAliasExesW(LPWSTR lpExeNameBuffer,
DWORD ExeNameBufferLength)
{
+ DPRINT1("GetConsoleAliasExesW called\n");
return IntGetConsoleAliasExes(lpExeNameBuffer, ExeNameBufferLength, TRUE);
}
@@ -524,6 +541,7 @@
GetConsoleAliasExesA(LPSTR lpExeNameBuffer,
DWORD ExeNameBufferLength)
{
+ DPRINT1("GetConsoleAliasExesA called\n");
return IntGetConsoleAliasExes(lpExeNameBuffer, ExeNameBufferLength, FALSE);
}
@@ -558,6 +576,7 @@
WINAPI
GetConsoleAliasExesLengthW(VOID)
{
+ DPRINT1("GetConsoleAliasExesLengthW called\n");
return IntGetConsoleAliasExesLength(TRUE);
}
@@ -569,6 +588,7 @@
WINAPI
GetConsoleAliasExesLengthA(VOID)
{
+ DPRINT1("GetConsoleAliasExesLengthA called\n");
return IntGetConsoleAliasExesLength(FALSE);
}
Modified: branches/condrv_restructure/dll/win32/kernel32/client/console/console.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/dll/win32/ke…
==============================================================================
--- branches/condrv_restructure/dll/win32/kernel32/client/console/console.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/dll/win32/kernel32/client/console/console.c [iso-8859-1]
Mon Jul 28 13:20:54 2014
@@ -1392,15 +1392,29 @@
/*--------------------------------------------------------------
* 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;
}
@@ -2525,7 +2539,7 @@
BOOL
WINAPI
-GetConsoleNlsMode(HANDLE hConsole, LPDWORD lpMode)
+SetConsoleCursorMode(HANDLE hConsole, BOOL Unknown1, BOOL Unknown2)
{
STUB;
return FALSE;
@@ -2533,7 +2547,7 @@
BOOL
WINAPI
-SetConsoleCursorMode(HANDLE hConsole, BOOL Unknown1, BOOL Unknown2)
+GetConsoleNlsMode(HANDLE hConsole, LPDWORD lpMode)
{
STUB;
return FALSE;
@@ -2541,7 +2555,7 @@
BOOL
WINAPI
-SetConsoleLocalEUDC(DWORD Unknown1, DWORD Unknown2, DWORD Unknown3, DWORD Unknown4)
+SetConsoleNlsMode(HANDLE hConsole, DWORD dwMode)
{
STUB;
return FALSE;
@@ -2549,7 +2563,7 @@
BOOL
WINAPI
-SetConsoleNlsMode(HANDLE hConsole, DWORD dwMode)
+SetConsoleLocalEUDC(DWORD Unknown1, DWORD Unknown2, DWORD Unknown3, DWORD Unknown4)
{
STUB;
return FALSE;
Modified: branches/condrv_restructure/include/reactos/subsys/win/conmsg.h
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/include/reac…
==============================================================================
--- branches/condrv_restructure/include/reactos/subsys/win/conmsg.h [iso-8859-1]
(original)
+++ branches/condrv_restructure/include/reactos/subsys/win/conmsg.h [iso-8859-1] Mon Jul
28 13:20:54 2014
@@ -322,6 +322,12 @@
typedef struct
{
HANDLE ConsoleHandle;
+ ULONG NumButtons;
+} CONSOLE_GETMOUSEINFO, *PCONSOLE_GETMOUSEINFO;
+
+typedef struct
+{
+ HANDLE ConsoleHandle;
HANDLE OutputHandle;
WORD Attributes;
} CONSOLE_SETTEXTATTRIB, *PCONSOLE_SETTEXTATTRIB;
@@ -370,7 +376,8 @@
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
{
- 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 @@
HANDLE ConsoleHandle;
ULONG HistoryLength;
PVOID History;
- // UNICODE_STRING ExeName;
USHORT ExeLength;
PVOID ExeName;
BOOLEAN Unicode;
@@ -715,7 +727,6 @@
{
HANDLE ConsoleHandle;
ULONG HistoryLength;
- // UNICODE_STRING ExeName;
USHORT ExeLength;
PVOID ExeName;
BOOLEAN Unicode;
@@ -725,7 +736,6 @@
typedef struct
{
HANDLE ConsoleHandle;
- // UNICODE_STRING ExeName;
USHORT ExeLength;
PVOID ExeName;
BOOLEAN Unicode;
@@ -743,7 +753,6 @@
{
HANDLE ConsoleHandle;
ULONG NumCommands;
- // UNICODE_STRING ExeName;
USHORT ExeLength;
PVOID ExeName;
BOOLEAN Unicode;
@@ -814,11 +823,12 @@
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;
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/alias.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
--- branches/condrv_restructure/win32ss/user/winsrv/consrv/alias.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/win32ss/user/winsrv/consrv/alias.c [iso-8859-1] Mon Jul 28
13:20:54 2014
@@ -18,61 +18,187 @@
typedef struct _ALIAS_ENTRY
{
- LPCWSTR lpSource;
- LPCWSTR lpTarget;
+ UNICODE_STRING Source;
+ UNICODE_STRING Target;
struct _ALIAS_ENTRY* Next;
} ALIAS_ENTRY, *PALIAS_ENTRY;
typedef struct _ALIAS_HEADER
{
- LPCWSTR lpExeName;
- PALIAS_ENTRY Data;
+ UNICODE_STRING ExeName;
+ PALIAS_ENTRY Data;
struct _ALIAS_HEADER* Next;
} ALIAS_HEADER, *PALIAS_HEADER;
+
+
+BOOLEAN
+ConvertInputAnsiToUnicode(PCONSOLE Console,
+ PVOID Source,
+ USHORT SourceLength,
+ // BOOLEAN IsUnicode,
+ PWCHAR* Target,
+ PUSHORT TargetLength)
+{
+ ASSERT(Source && Target && TargetLength);
+
+ /* Use the console input CP for the conversion */
+ *TargetLength = MultiByteToWideChar(Console->InputCodePage, 0,
+ Source, SourceLength,
+ NULL, 0);
+ *Target = ConsoleAllocHeap(0, *TargetLength * sizeof(WCHAR));
+ if (*Target == NULL) return FALSE;
+
+ MultiByteToWideChar(Console->InputCodePage, 0,
+ Source, SourceLength,
+ *Target, *TargetLength);
+
+ /* The returned Length was in number of WCHARs, convert it in bytes */
+ *TargetLength *= sizeof(WCHAR);
+
+ return TRUE;
+}
+
+BOOLEAN
+ConvertInputUnicodeToAnsi(PCONSOLE Console,
+ PVOID Source,
+ USHORT SourceLength,
+ // BOOLEAN IsAnsi,
+ PCHAR/* * */ Target,
+ /*P*/USHORT TargetLength)
+{
+ ASSERT(Source && Target && TargetLength);
+
+ /* Use the console input CP for the conversion */
+ // *TargetLength = WideCharToMultiByte(Console->InputCodePage, 0,
+ // Source, SourceLength,
+ // NULL, 0, NULL, NULL);
+ // *Target = ConsoleAllocHeap(0, *TargetLength * sizeof(WCHAR));
+ // if (*Target == NULL) return FALSE;
+
+ WideCharToMultiByte(Console->InputCodePage, 0,
+ Source, SourceLength,
+ /* * */Target, /* * */TargetLength,
+ NULL, NULL);
+
+ // /* The returned Length was in number of WCHARs, convert it in bytes */
+ // *TargetLength *= sizeof(WCHAR);
+
+ return TRUE;
+}
+
+
+
+
/* PRIVATE FUNCTIONS **********************************************************/
-static
-PALIAS_HEADER
-IntFindAliasHeader(PALIAS_HEADER RootHeader, LPCWSTR lpExeName)
-{
+static PALIAS_HEADER
+IntFindAliasHeader(PCONSOLE Console,
+ PVOID ExeName,
+ USHORT ExeLength,
+ BOOLEAN UnicodeExe)
+{
+ UNICODE_STRING ExeNameU;
+
+ PALIAS_HEADER RootHeader = Console->Aliases;
+ INT Diff;
+
+ 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;
+
while (RootHeader)
{
- INT diff = _wcsicmp(RootHeader->lpExeName, lpExeName);
- if (!diff) return RootHeader;
- if (diff > 0) break;
+ Diff = RtlCompareUnicodeString(&RootHeader->ExeName, &ExeNameU,
TRUE);
+ if (!Diff)
+ {
+ if (!UnicodeExe) ConsoleFreeHeap(ExeNameU.Buffer);
+ return RootHeader;
+ }
+ if (Diff > 0) break;
RootHeader = RootHeader->Next;
}
+
+ if (!UnicodeExe) ConsoleFreeHeap(ExeNameU.Buffer);
return NULL;
}
-PALIAS_HEADER
-IntCreateAliasHeader(LPCWSTR lpExeName)
-{
+static PALIAS_HEADER
+IntCreateAliasHeader(PCONSOLE Console,
+ PVOID ExeName,
+ USHORT ExeLength,
+ BOOLEAN UnicodeExe)
+{
+ UNICODE_STRING ExeNameU;
+
PALIAS_HEADER Entry;
- UINT dwLength = wcslen(lpExeName) + 1;
-
- Entry = ConsoleAllocHeap(0, sizeof(ALIAS_HEADER) + sizeof(WCHAR) * dwLength);
- if (!Entry) return Entry;
-
- Entry->lpExeName = (LPCWSTR)(Entry + 1);
- wcscpy((PWCHAR)Entry->lpExeName, lpExeName);
+
+ 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 = ConsoleAllocHeap(0, sizeof(ALIAS_HEADER) + ExeNameU.Length);
+ if (!Entry)
+ {
+ if (!UnicodeExe) ConsoleFreeHeap(ExeNameU.Buffer);
+ return Entry;
+ }
+
+ Entry->ExeName.Buffer = (PWSTR)(Entry + 1);
+ Entry->ExeName.Length = 0;
+ Entry->ExeName.MaximumLength = ExeNameU.Length;
+ RtlCopyUnicodeString(&Entry->ExeName, &ExeNameU);
+
Entry->Data = NULL;
Entry->Next = NULL;
+
+ if (!UnicodeExe) ConsoleFreeHeap(ExeNameU.Buffer);
return Entry;
}
-VOID
-IntInsertAliasHeader(PALIAS_HEADER * RootHeader, PALIAS_HEADER NewHeader)
+static VOID
+IntInsertAliasHeader(PALIAS_HEADER* RootHeader,
+ PALIAS_HEADER NewHeader)
{
PALIAS_HEADER CurrentHeader;
PALIAS_HEADER *LastLink = RootHeader;
+ INT Diff;
while ((CurrentHeader = *LastLink) != NULL)
{
- INT Diff = _wcsicmp(NewHeader->lpExeName, CurrentHeader->lpExeName);
+ Diff = RtlCompareUnicodeString(&NewHeader->ExeName,
&CurrentHeader->ExeName, TRUE);
if (Diff < 0) break;
LastLink = &CurrentHeader->Next;
@@ -82,36 +208,139 @@
NewHeader->Next = CurrentHeader;
}
-PALIAS_ENTRY
-IntGetAliasEntry(PALIAS_HEADER Header, LPCWSTR lpSrcName)
-{
- PALIAS_ENTRY RootHeader;
-
- if (Header == NULL) return NULL;
-
- RootHeader = Header->Data;
- while (RootHeader)
- {
- INT diff;
- DPRINT("IntGetAliasEntry->lpSource %S\n", RootHeader->lpSource);
- diff = _wcsicmp(RootHeader->lpSource, lpSrcName);
- if (!diff) return RootHeader;
- if (diff > 0) break;
-
- RootHeader = RootHeader->Next;
- }
+static PALIAS_ENTRY
+IntGetAliasEntry(PCONSOLE Console,
+ PALIAS_HEADER Header,
+ PVOID Source,
+ USHORT SourceLength,
+ BOOLEAN Unicode)
+{
+ UNICODE_STRING SourceU;
+
+ PALIAS_ENTRY Entry;
+ INT Diff;
+
+ if (Header == NULL || Source == NULL) return NULL;
+
+ if (Unicode)
+ {
+ SourceU.Buffer = Source;
+ /* Length is in bytes */
+ SourceU.MaximumLength = SourceLength;
+ }
+ else
+ {
+ if (!ConvertInputAnsiToUnicode(Console,
+ Source, SourceLength,
+ &SourceU.Buffer, &SourceU.MaximumLength))
+ {
+ return NULL;
+ }
+ }
+ SourceU.Length = SourceU.MaximumLength;
+
+ Entry = Header->Data;
+ while (Entry)
+ {
+ Diff = RtlCompareUnicodeString(&Entry->Source, &SourceU, TRUE);
+ if (!Diff)
+ {
+ if (!Unicode) ConsoleFreeHeap(SourceU.Buffer);
+ return Entry;
+ }
+ if (Diff > 0) break;
+
+ Entry = Entry->Next;
+ }
+
+ if (!Unicode) ConsoleFreeHeap(SourceU.Buffer);
return NULL;
}
-VOID
-IntInsertAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY NewEntry)
+static PALIAS_ENTRY
+IntCreateAliasEntry(PCONSOLE Console,
+ PVOID Source,
+ USHORT SourceLength,
+ PVOID Target,
+ USHORT TargetLength,
+ BOOLEAN Unicode)
+{
+ UNICODE_STRING SourceU;
+ UNICODE_STRING TargetU;
+
+ PALIAS_ENTRY Entry;
+
+ if (Unicode)
+ {
+ SourceU.Buffer = Source;
+ TargetU.Buffer = Target;
+ /* Length is in bytes */
+ SourceU.MaximumLength = SourceLength;
+ TargetU.MaximumLength = TargetLength;
+ }
+ else
+ {
+ if (!ConvertInputAnsiToUnicode(Console,
+ Source, SourceLength,
+ &SourceU.Buffer, &SourceU.MaximumLength))
+ {
+ return NULL;
+ }
+
+ if (!ConvertInputAnsiToUnicode(Console,
+ Target, TargetLength,
+ &TargetU.Buffer, &TargetU.MaximumLength))
+ {
+ ConsoleFreeHeap(SourceU.Buffer);
+ return NULL;
+ }
+ }
+ SourceU.Length = SourceU.MaximumLength;
+ TargetU.Length = TargetU.MaximumLength;
+
+ Entry = ConsoleAllocHeap(0, sizeof(ALIAS_ENTRY) +
+ SourceU.Length + TargetU.Length);
+ if (!Entry)
+ {
+ if (!Unicode)
+ {
+ ConsoleFreeHeap(TargetU.Buffer);
+ ConsoleFreeHeap(SourceU.Buffer);
+ }
+ return Entry;
+ }
+
+ Entry->Source.Buffer = (PWSTR)(Entry + 1);
+ Entry->Source.Length = 0;
+ Entry->Source.MaximumLength = SourceU.Length;
+ RtlCopyUnicodeString(&Entry->Source, &SourceU);
+
+ Entry->Target.Buffer = (PWSTR)((ULONG_PTR)Entry->Source.Buffer +
Entry->Source.MaximumLength);
+ Entry->Target.Length = 0;
+ Entry->Target.MaximumLength = TargetU.Length;
+ RtlCopyUnicodeString(&Entry->Target, &TargetU);
+
+ Entry->Next = NULL;
+
+ if (!Unicode)
+ {
+ ConsoleFreeHeap(TargetU.Buffer);
+ ConsoleFreeHeap(SourceU.Buffer);
+ }
+ return Entry;
+}
+
+static VOID
+IntInsertAliasEntry(PALIAS_HEADER Header,
+ PALIAS_ENTRY NewEntry)
{
PALIAS_ENTRY CurrentEntry;
PALIAS_ENTRY *LastLink = &Header->Data;
+ INT Diff;
while ((CurrentEntry = *LastLink) != NULL)
{
- INT Diff = _wcsicmp(NewEntry->lpSource, CurrentEntry->lpSource);
+ Diff = RtlCompareUnicodeString(&NewEntry->Source,
&CurrentEntry->Source, TRUE);
if (Diff < 0) break;
LastLink = &CurrentEntry->Next;
@@ -121,120 +350,9 @@
NewEntry->Next = CurrentEntry;
}
-PALIAS_ENTRY
-IntCreateAliasEntry(LPCWSTR lpSource, LPCWSTR lpTarget)
-{
- UINT dwSource;
- UINT dwTarget;
- PALIAS_ENTRY Entry;
-
- dwSource = wcslen(lpSource) + 1;
- dwTarget = wcslen(lpTarget) + 1;
-
- Entry = ConsoleAllocHeap(0, sizeof(ALIAS_ENTRY) + sizeof(WCHAR) * (dwSource +
dwTarget));
- if (!Entry) return Entry;
-
- Entry->lpSource = (LPCWSTR)(Entry + 1);
- wcscpy((LPWSTR)Entry->lpSource, lpSource);
- Entry->lpTarget = Entry->lpSource + dwSource;
- wcscpy((LPWSTR)Entry->lpTarget, lpTarget);
- Entry->Next = NULL;
-
- return Entry;
-}
-
-UINT
-IntGetConsoleAliasesExesLength(PALIAS_HEADER RootHeader)
-{
- UINT length = 0;
-
- while (RootHeader)
- {
- length += (wcslen(RootHeader->lpExeName) + 1) * sizeof(WCHAR);
- RootHeader = RootHeader->Next;
- }
- if (length)
- length += sizeof(WCHAR); // last entry entry is terminated with 2 zero bytes
-
- return length;
-}
-
-UINT
-IntGetConsoleAliasesExes(PALIAS_HEADER RootHeader, LPWSTR TargetBuffer, UINT
TargetBufferSize)
-{
- UINT Offset = 0;
- UINT Length;
-
- TargetBufferSize /= sizeof(WCHAR);
- while (RootHeader)
- {
- Length = wcslen(RootHeader->lpExeName) + 1;
- if (TargetBufferSize > Offset + Length)
- {
- wcscpy(&TargetBuffer[Offset], RootHeader->lpExeName);
- Offset += Length;
- }
- else
- {
- break;
- }
- RootHeader = RootHeader->Next;
- }
- Length = min(Offset+1, TargetBufferSize);
- TargetBuffer[Length] = L'\0';
- return Length * sizeof(WCHAR);
-}
-
-UINT
-IntGetAllConsoleAliasesLength(PALIAS_HEADER Header)
-{
- UINT Length = 0;
- PALIAS_ENTRY CurEntry = Header->Data;
-
- while (CurEntry)
- {
- Length += wcslen(CurEntry->lpSource);
- Length += wcslen(CurEntry->lpTarget);
- Length += 2; // zero byte and '='
- CurEntry = CurEntry->Next;
- }
-
- if (Length)
- {
- return (Length+1) * sizeof(WCHAR);
- }
- return 0;
-}
-
-UINT
-IntGetAllConsoleAliases(PALIAS_HEADER Header, LPWSTR TargetBuffer, UINT
TargetBufferLength)
-{
- PALIAS_ENTRY CurEntry = Header->Data;
- UINT Offset = 0;
- UINT SrcLength, TargetLength;
-
- TargetBufferLength /= sizeof(WCHAR);
- while (CurEntry)
- {
- SrcLength = wcslen(CurEntry->lpSource) + 1;
- TargetLength = wcslen(CurEntry->lpTarget) + 1;
- if (Offset + TargetLength + SrcLength >= TargetBufferLength)
- break;
-
- wcscpy(&TargetBuffer[Offset], CurEntry->lpSource);
- Offset += SrcLength;
- TargetBuffer[Offset] = L'=';
- wcscpy(&TargetBuffer[Offset], CurEntry->lpTarget);
- Offset += TargetLength;
-
- CurEntry = CurEntry->Next;
- }
- TargetBuffer[Offset] = L'\0';
- return Offset * sizeof(WCHAR);
-}
-
-VOID
-IntDeleteAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY Entry)
+static VOID
+IntDeleteAliasEntry(PALIAS_HEADER Header,
+ PALIAS_ENTRY Entry)
{
PALIAS_ENTRY *LastLink = &Header->Data;
PALIAS_ENTRY CurEntry;
@@ -251,6 +369,53 @@
}
}
+static UINT
+IntGetConsoleAliasesExesLength(PALIAS_HEADER RootHeader,
+ BOOLEAN IsUnicode)
+{
+ UINT Length = 0;
+
+ while (RootHeader)
+ {
+ Length += RootHeader->ExeName.Length + sizeof(WCHAR); // NULL-termination
+ RootHeader = RootHeader->Next;
+ }
+
+ /*
+ * Quick and dirty way of getting the number of bytes of the
+ * corresponding ANSI string from the one in UNICODE.
+ */
+ if (!IsUnicode)
+ Length /= sizeof(WCHAR);
+
+ return Length;
+}
+
+static UINT
+IntGetAllConsoleAliasesLength(PALIAS_HEADER Header,
+ BOOLEAN IsUnicode)
+{
+ UINT Length = 0;
+ PALIAS_ENTRY CurEntry = Header->Data;
+
+ while (CurEntry)
+ {
+ Length += CurEntry->Source.Length;
+ Length += CurEntry->Target.Length;
+ Length += 2 * sizeof(WCHAR); // '=' and NULL-termination
+ CurEntry = CurEntry->Next;
+ }
+
+ /*
+ * Quick and dirty way of getting the number of bytes of the
+ * corresponding ANSI string from the one in UNICODE.
+ */
+ if (!IsUnicode)
+ Length /= sizeof(WCHAR);
+
+ return Length;
+}
+
VOID
IntDeleteAllAliases(PCONSOLE Console)
{
@@ -274,13 +439,14 @@
CSR_API(SrvAddConsoleAlias)
{
+ NTSTATUS Status;
PCONSOLE_ADDGETALIAS ConsoleAliasRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleAliasRequest;
PCONSOLE Console;
PALIAS_HEADER Header;
PALIAS_ENTRY Entry;
- LPWSTR lpSource, lpTarget, lpExeName;
-
- DPRINT("SrvAddConsoleAlias entered ApiMessage %p\n", ApiMessage);
+ PVOID lpTarget;
+
+ DPRINT1("SrvAddConsoleAlias entered ApiMessage %p\n", ApiMessage);
if ( !CsrValidateMessageBuffer(ApiMessage,
(PVOID*)&ConsoleAliasRequest->Source,
@@ -291,81 +457,86 @@
ConsoleAliasRequest->TargetLength,
sizeof(BYTE)) ||
!CsrValidateMessageBuffer(ApiMessage,
- (PVOID*)&ConsoleAliasRequest->Exe,
+ (PVOID*)&ConsoleAliasRequest->ExeName,
ConsoleAliasRequest->ExeLength,
sizeof(BYTE)) )
{
return STATUS_INVALID_PARAMETER;
}
- lpSource = ConsoleAliasRequest->Source;
- lpTarget = (ConsoleAliasRequest->TargetLength != 0 ?
ConsoleAliasRequest->Target : NULL);
- lpExeName = ConsoleAliasRequest->Exe;
-
- DPRINT("SrvAddConsoleAlias lpSource %p lpExeName %p lpTarget %p\n",
lpSource, lpExeName, lpTarget);
-
- if (lpExeName == NULL || lpSource == NULL)
- {
- return STATUS_INVALID_PARAMETER;
- }
-
- ApiMessage->Status =
ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console,
TRUE);
- if (!NT_SUCCESS(ApiMessage->Status))
- {
- return ApiMessage->Status;
- }
-
- Header = IntFindAliasHeader(Console->Aliases, lpExeName);
+ lpTarget = (ConsoleAliasRequest->TargetLength != 0 ?
ConsoleAliasRequest->Target : NULL);
+
+ Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ Status = STATUS_SUCCESS;
+
+ Header = IntFindAliasHeader(Console,
+ ConsoleAliasRequest->ExeName,
+ ConsoleAliasRequest->ExeLength,
+ ConsoleAliasRequest->Unicode2);
if (!Header && lpTarget != NULL)
{
- Header = IntCreateAliasHeader(lpExeName);
+ Header = IntCreateAliasHeader(Console,
+ ConsoleAliasRequest->ExeName,
+ ConsoleAliasRequest->ExeLength,
+ ConsoleAliasRequest->Unicode2);
if (!Header)
{
- ConSrvReleaseConsole(Console, TRUE);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
+ Status = STATUS_NO_MEMORY;
+ goto Quit;
+ }
+
IntInsertAliasHeader(&Console->Aliases, Header);
}
if (lpTarget == NULL) // Delete the entry
{
- Entry = IntGetAliasEntry(Header, lpSource);
- if (Entry)
- {
- IntDeleteAliasEntry(Header, Entry);
- ApiMessage->Status = STATUS_SUCCESS;
- }
- else
- {
- ApiMessage->Status = STATUS_INVALID_PARAMETER;
- }
- ConSrvReleaseConsole(Console, TRUE);
- return ApiMessage->Status;
- }
-
- Entry = IntCreateAliasEntry(lpSource, lpTarget);
-
- if (!Entry)
- {
- ConSrvReleaseConsole(Console, TRUE);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- IntInsertAliasEntry(Header, Entry);
+ Entry = IntGetAliasEntry(Console, Header,
+ ConsoleAliasRequest->Source,
+ ConsoleAliasRequest->SourceLength,
+ ConsoleAliasRequest->Unicode);
+ if (!Entry)
+ {
+ Status = STATUS_UNSUCCESSFUL;
+ goto Quit;
+ }
+
+ IntDeleteAliasEntry(Header, Entry);
+ }
+ else // Add the entry
+ {
+ Entry = IntCreateAliasEntry(Console,
+ ConsoleAliasRequest->Source,
+ ConsoleAliasRequest->SourceLength,
+ ConsoleAliasRequest->Target,
+ ConsoleAliasRequest->TargetLength,
+ ConsoleAliasRequest->Unicode);
+ if (!Entry)
+ {
+ Status = STATUS_NO_MEMORY;
+ goto Quit;
+ }
+
+ IntInsertAliasEntry(Header, Entry);
+ }
+
+Quit:
ConSrvReleaseConsole(Console, TRUE);
- return STATUS_SUCCESS;
+ return Status;
}
CSR_API(SrvGetConsoleAlias)
{
+ NTSTATUS Status;
PCONSOLE_ADDGETALIAS ConsoleAliasRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleAliasRequest;
PCONSOLE Console;
PALIAS_HEADER Header;
PALIAS_ENTRY Entry;
UINT Length;
- LPWSTR lpSource, lpTarget, lpExeName;
-
- DPRINT("SrvGetConsoleAlias entered ApiMessage %p\n", ApiMessage);
+ PVOID lpTarget;
+
+ DPRINT1("SrvGetConsoleAlias entered ApiMessage %p\n", ApiMessage);
if ( !CsrValidateMessageBuffer(ApiMessage,
(PVOID*)&ConsoleAliasRequest->Source,
@@ -376,19 +547,14 @@
ConsoleAliasRequest->TargetLength,
sizeof(BYTE)) ||
!CsrValidateMessageBuffer(ApiMessage,
- (PVOID*)&ConsoleAliasRequest->Exe,
+ (PVOID*)&ConsoleAliasRequest->ExeName,
ConsoleAliasRequest->ExeLength,
sizeof(BYTE)) )
{
return STATUS_INVALID_PARAMETER;
}
- lpSource = ConsoleAliasRequest->Source;
- lpTarget = ConsoleAliasRequest->Target;
- lpExeName = ConsoleAliasRequest->Exe;
-
- DPRINT("SrvGetConsoleAlias lpExeName %p lpSource %p TargetBuffer %p TargetLength
%u\n",
- lpExeName, lpSource, lpTarget, ConsoleAliasRequest->TargetLength);
+ lpTarget = ConsoleAliasRequest->Target;
if (ConsoleAliasRequest->ExeLength == 0 || lpTarget == NULL ||
ConsoleAliasRequest->TargetLength == 0 ||
ConsoleAliasRequest->SourceLength == 0)
@@ -396,45 +562,70 @@
return STATUS_INVALID_PARAMETER;
}
- ApiMessage->Status =
ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console,
TRUE);
- if (!NT_SUCCESS(ApiMessage->Status))
- {
- return ApiMessage->Status;
- }
-
- Header = IntFindAliasHeader(Console->Aliases, lpExeName);
+ Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ Header = IntFindAliasHeader(Console,
+ ConsoleAliasRequest->ExeName,
+ ConsoleAliasRequest->ExeLength,
+ ConsoleAliasRequest->Unicode2);
if (!Header)
{
- ConSrvReleaseConsole(Console, TRUE);
- return STATUS_INVALID_PARAMETER;
- }
-
- Entry = IntGetAliasEntry(Header, lpSource);
+ Status = STATUS_UNSUCCESSFUL;
+ goto Quit;
+ }
+
+ Entry = IntGetAliasEntry(Console, Header,
+ ConsoleAliasRequest->Source,
+ ConsoleAliasRequest->SourceLength,
+ ConsoleAliasRequest->Unicode);
if (!Entry)
{
- ConSrvReleaseConsole(Console, TRUE);
- return STATUS_INVALID_PARAMETER;
- }
-
- Length = (wcslen(Entry->lpTarget) + 1) * sizeof(WCHAR);
- if (Length > ConsoleAliasRequest->TargetLength)
- {
- ConSrvReleaseConsole(Console, TRUE);
- return STATUS_BUFFER_TOO_SMALL;
- }
-
- wcscpy(lpTarget, Entry->lpTarget);
- ConsoleAliasRequest->TargetLength = Length;
+ Status = STATUS_UNSUCCESSFUL;
+ goto Quit;
+ }
+
+ if (ConsoleAliasRequest->Unicode)
+ {
+ Length = Entry->Target.Length + sizeof(WCHAR);
+ if (Length > ConsoleAliasRequest->TargetLength) // FIXME: Refine
computation.
+ {
+ Status = STATUS_BUFFER_TOO_SMALL;
+ goto Quit;
+ }
+
+ RtlCopyMemory(lpTarget, Entry->Target.Buffer, Entry->Target.Length);
+ ConsoleAliasRequest->TargetLength = Length;
+ }
+ else
+ {
+ Length = (Entry->Target.Length + sizeof(WCHAR)) / sizeof(WCHAR);
+ if (Length > ConsoleAliasRequest->TargetLength) // FIXME: Refine
computation.
+ {
+ Status = STATUS_BUFFER_TOO_SMALL;
+ goto Quit;
+ }
+
+ ConvertInputUnicodeToAnsi(Console,
+ Entry->Target.Buffer, Entry->Target.Length,
+ lpTarget, Entry->Target.Length / sizeof(WCHAR));
+ ConsoleAliasRequest->TargetLength = Length;
+ }
+
+Quit:
ConSrvReleaseConsole(Console, TRUE);
- return STATUS_SUCCESS;
+ return Status;
}
CSR_API(SrvGetConsoleAliases)
{
+ NTSTATUS Status;
PCONSOLE_GETALLALIASES GetAllAliasesRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAllAliasesRequest;
PCONSOLE Console;
- ULONG BytesWritten;
+ ULONG BytesWritten = 0;
PALIAS_HEADER Header;
+
+ DPRINT1("SrvGetConsoleAliases entered ApiMessage %p\n", ApiMessage);
if ( !CsrValidateMessageBuffer(ApiMessage,
(PVOID)&GetAllAliasesRequest->ExeName,
@@ -448,37 +639,87 @@
return STATUS_INVALID_PARAMETER;
}
- if (GetAllAliasesRequest->ExeName == NULL)
- {
- return STATUS_INVALID_PARAMETER;
- }
-
- ApiMessage->Status =
ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console,
TRUE);
- if (!NT_SUCCESS(ApiMessage->Status))
- {
- return ApiMessage->Status;
- }
-
- Header = IntFindAliasHeader(Console->Aliases, GetAllAliasesRequest->ExeName);
- if (!Header)
- {
- ConSrvReleaseConsole(Console, TRUE);
- return STATUS_INVALID_PARAMETER;
- }
-
- if (IntGetAllConsoleAliasesLength(Header) >
GetAllAliasesRequest->AliasesBufferLength)
- {
- ConSrvReleaseConsole(Console, TRUE);
- return STATUS_BUFFER_OVERFLOW;
- }
-
- BytesWritten = IntGetAllConsoleAliases(Header,
- GetAllAliasesRequest->AliasesBuffer,
-
GetAllAliasesRequest->AliasesBufferLength);
-
+ Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ Header = IntFindAliasHeader(Console,
+ GetAllAliasesRequest->ExeName,
+ GetAllAliasesRequest->ExeLength,
+ GetAllAliasesRequest->Unicode2);
+ if (!Header) goto Quit;
+
+ if (IntGetAllConsoleAliasesLength(Header, GetAllAliasesRequest->Unicode) >
GetAllAliasesRequest->AliasesBufferLength)
+ {
+ Status = STATUS_BUFFER_OVERFLOW;
+ goto Quit;
+ }
+
+ {
+ LPSTR TargetBufferA;
+ LPWSTR TargetBufferW;
+ UINT TargetBufferLength = GetAllAliasesRequest->AliasesBufferLength;
+
+ PALIAS_ENTRY CurEntry = Header->Data;
+ UINT Offset = 0;
+ UINT SourceLength, TargetLength;
+
+ if (GetAllAliasesRequest->Unicode)
+ {
+ TargetBufferW = GetAllAliasesRequest->AliasesBuffer;
+ TargetBufferLength /= sizeof(WCHAR);
+ }
+ else
+ {
+ TargetBufferA = GetAllAliasesRequest->AliasesBuffer;
+ }
+
+ while (CurEntry)
+ {
+ SourceLength = CurEntry->Source.Length / sizeof(WCHAR);
+ TargetLength = CurEntry->Target.Length / sizeof(WCHAR);
+ if (Offset + TargetLength + SourceLength + 2 > TargetBufferLength)
+ {
+ Status = STATUS_BUFFER_OVERFLOW;
+ break;
+ }
+
+ if (GetAllAliasesRequest->Unicode)
+ {
+ RtlCopyMemory(&TargetBufferW[Offset], CurEntry->Source.Buffer,
SourceLength * sizeof(WCHAR));
+ Offset += SourceLength;
+ TargetBufferW[Offset++] = L'=';
+ RtlCopyMemory(&TargetBufferW[Offset], CurEntry->Target.Buffer,
TargetLength * sizeof(WCHAR));
+ Offset += TargetLength;
+ TargetBufferW[Offset++] = L'\0';
+ }
+ else
+ {
+ ConvertInputUnicodeToAnsi(Console,
+ CurEntry->Source.Buffer, SourceLength *
sizeof(WCHAR),
+ &TargetBufferA[Offset], SourceLength);
+ Offset += SourceLength;
+ TargetBufferA[Offset++] = '=';
+ ConvertInputUnicodeToAnsi(Console,
+ CurEntry->Target.Buffer, TargetLength *
sizeof(WCHAR),
+ &TargetBufferA[Offset], TargetLength);
+ Offset += TargetLength;
+ TargetBufferA[Offset++] = '\0';
+ }
+
+ CurEntry = CurEntry->Next;
+ }
+
+ if (GetAllAliasesRequest->Unicode)
+ BytesWritten = Offset * sizeof(WCHAR);
+ else
+ BytesWritten = Offset;
+ }
+
+Quit:
GetAllAliasesRequest->AliasesBufferLength = BytesWritten;
+
ConSrvReleaseConsole(Console, TRUE);
- return STATUS_SUCCESS;
+ return Status;
}
CSR_API(SrvGetConsoleAliasesLength)
@@ -487,7 +728,8 @@
PCONSOLE_GETALLALIASESLENGTH GetAllAliasesLengthRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAllAliasesLengthRequest;
PCONSOLE Console;
PALIAS_HEADER Header;
- UINT Length;
+
+ DPRINT1("SrvGetConsoleAliasesLength entered ApiMessage %p\n", ApiMessage);
if (!CsrValidateMessageBuffer(ApiMessage,
(PVOID)&GetAllAliasesLengthRequest->ExeName,
@@ -500,27 +742,20 @@
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
- // FIXME!! Convert GetAllAliasesLengthRequest->ExeName into UNICODE if Unicode2 is
FALSE
- // and make use of GetAllAliasesLengthRequest->ExeLength
-
- Header = IntFindAliasHeader(Console->Aliases,
GetAllAliasesLengthRequest->ExeName);
+ Header = IntFindAliasHeader(Console,
+ GetAllAliasesLengthRequest->ExeName,
+ GetAllAliasesLengthRequest->ExeLength,
+ GetAllAliasesLengthRequest->Unicode2);
if (Header)
{
- Length = IntGetAllConsoleAliasesLength(Header);
- GetAllAliasesLengthRequest->Length = Length;
-
- /*
- * Quick and dirty way of getting the number of bytes of the
- * corresponding ANSI string from the one in UNICODE.
- */
- if (!GetAllAliasesLengthRequest->Unicode)
- GetAllAliasesLengthRequest->Length /= sizeof(WCHAR);
-
+ GetAllAliasesLengthRequest->Length =
+ IntGetAllConsoleAliasesLength(Header,
+ GetAllAliasesLengthRequest->Unicode);
Status = STATUS_SUCCESS;
}
else
{
- Status = STATUS_INVALID_PARAMETER;
+ GetAllAliasesLengthRequest->Length = 0;
}
ConSrvReleaseConsole(Console, TRUE);
@@ -529,12 +764,12 @@
CSR_API(SrvGetConsoleAliasExes)
{
+ NTSTATUS Status;
PCONSOLE_GETALIASESEXES GetAliasesExesRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAliasesExesRequest;
PCONSOLE Console;
- UINT BytesWritten;
- UINT ExesLength;
-
- DPRINT("SrvGetConsoleAliasExes entered\n");
+ UINT BytesWritten = 0;
+
+ DPRINT1("SrvGetConsoleAliasExes entered\n");
if (!CsrValidateMessageBuffer(ApiMessage,
(PVOID*)&GetAliasesExesRequest->ExeNames,
@@ -544,33 +779,73 @@
return STATUS_INVALID_PARAMETER;
}
- ApiMessage->Status =
ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console,
TRUE);
- if (!NT_SUCCESS(ApiMessage->Status))
- {
- return ApiMessage->Status;
- }
-
- ExesLength = IntGetConsoleAliasesExesLength(Console->Aliases);
-
- if (ExesLength > GetAliasesExesRequest->Length)
- {
- ConSrvReleaseConsole(Console, TRUE);
- return STATUS_BUFFER_OVERFLOW;
- }
-
- if (GetAliasesExesRequest->ExeNames == NULL)
- {
- ConSrvReleaseConsole(Console, TRUE);
- return STATUS_INVALID_PARAMETER;
- }
-
- BytesWritten = IntGetConsoleAliasesExes(Console->Aliases,
- GetAliasesExesRequest->ExeNames,
- GetAliasesExesRequest->Length);
-
+ Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ if (IntGetConsoleAliasesExesLength(Console->Aliases,
GetAliasesExesRequest->Unicode) > GetAliasesExesRequest->Length)
+ {
+ Status = STATUS_BUFFER_OVERFLOW;
+ goto Quit;
+ }
+
+ {
+ PALIAS_HEADER RootHeader = Console->Aliases;
+
+ LPSTR TargetBufferA;
+ LPWSTR TargetBufferW;
+ UINT TargetBufferSize = GetAliasesExesRequest->Length;
+
+ UINT Offset = 0;
+ UINT Length;
+
+ if (GetAliasesExesRequest->Unicode)
+ {
+ TargetBufferW = GetAliasesExesRequest->ExeNames;
+ TargetBufferSize /= sizeof(WCHAR);
+ }
+ else
+ {
+ TargetBufferA = GetAliasesExesRequest->ExeNames;
+ }
+
+ while (RootHeader)
+ {
+ Length = RootHeader->ExeName.Length / sizeof(WCHAR);
+ if (Offset + Length + 1 > TargetBufferSize)
+ {
+ Status = STATUS_BUFFER_OVERFLOW;
+ break;
+ }
+
+ if (GetAliasesExesRequest->Unicode)
+ {
+ RtlCopyMemory(&TargetBufferW[Offset], RootHeader->ExeName.Buffer,
Length * sizeof(WCHAR));
+ Offset += Length;
+ TargetBufferW[Offset++] = L'\0';
+ }
+ else
+ {
+ ConvertInputUnicodeToAnsi(Console,
+ RootHeader->ExeName.Buffer, Length *
sizeof(WCHAR),
+ &TargetBufferA[Offset], Length);
+ Offset += Length;
+ TargetBufferA[Offset++] = '\0';
+ }
+
+ RootHeader = RootHeader->Next;
+ }
+
+ if (GetAliasesExesRequest->Unicode)
+ BytesWritten = Offset * sizeof(WCHAR);
+ else
+ BytesWritten = Offset;
+ }
+
+Quit:
GetAliasesExesRequest->Length = BytesWritten;
+
ConSrvReleaseConsole(Console, TRUE);
- return STATUS_SUCCESS;
+ return Status;
}
CSR_API(SrvGetConsoleAliasExesLength)
@@ -579,17 +854,14 @@
PCONSOLE_GETALIASESEXESLENGTH GetAliasesExesLengthRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAliasesExesLengthRequest;
PCONSOLE Console;
+ DPRINT1("SrvGetConsoleAliasExesLength entered ApiMessage %p\n",
ApiMessage);
+
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
- GetAliasesExesLengthRequest->Length =
IntGetConsoleAliasesExesLength(Console->Aliases);
-
- /*
- * Quick and dirty way of getting the number of bytes of the
- * corresponding ANSI string from the one in UNICODE.
- */
- if (!GetAliasesExesLengthRequest->Unicode)
- GetAliasesExesLengthRequest->Length /= sizeof(WCHAR);
+ GetAliasesExesLengthRequest->Length =
+ IntGetConsoleAliasesExesLength(Console->Aliases,
+ GetAliasesExesLengthRequest->Unicode);
ConSrvReleaseConsole(Console, TRUE);
return Status;
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/coninput.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
--- branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/coninput.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/coninput.c [iso-8859-1]
Mon Jul 28 13:20:54 2014
@@ -389,10 +389,11 @@
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)
{
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/console.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
--- branches/condrv_restructure/win32ss/user/winsrv/consrv/console.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/win32ss/user/winsrv/consrv/console.c [iso-8859-1] Mon Jul
28 13:20:54 2014
@@ -977,62 +977,72 @@
CSR_API(SrvGetConsoleMouseInfo)
{
+ 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)
+{
DPRINT1("%s not yet implemented\n", __FUNCTION__);
return STATUS_NOT_IMPLEMENTED;
}
-CSR_API(SrvSetConsoleKeyShortcuts)
+CSR_API(SrvGetConsoleKeyboardLayoutName)
{
DPRINT1("%s not yet implemented\n", __FUNCTION__);
return STATUS_NOT_IMPLEMENTED;
}
-CSR_API(SrvGetConsoleKeyboardLayoutName)
+CSR_API(SrvGetConsoleCharType)
{
DPRINT1("%s not yet implemented\n", __FUNCTION__);
return STATUS_NOT_IMPLEMENTED;
}
-CSR_API(SrvGetConsoleCharType)
+CSR_API(SrvSetConsoleLocalEUDC)
{
DPRINT1("%s not yet implemented\n", __FUNCTION__);
return STATUS_NOT_IMPLEMENTED;
}
-CSR_API(SrvSetConsoleLocalEUDC)
+CSR_API(SrvSetConsoleCursorMode)
{
DPRINT1("%s not yet implemented\n", __FUNCTION__);
return STATUS_NOT_IMPLEMENTED;
}
-CSR_API(SrvSetConsoleCursorMode)
+CSR_API(SrvGetConsoleCursorMode)
{
DPRINT1("%s not yet implemented\n", __FUNCTION__);
return STATUS_NOT_IMPLEMENTED;
}
-CSR_API(SrvGetConsoleCursorMode)
+CSR_API(SrvGetConsoleNlsMode)
{
DPRINT1("%s not yet implemented\n", __FUNCTION__);
return STATUS_NOT_IMPLEMENTED;
}
-CSR_API(SrvGetConsoleNlsMode)
+CSR_API(SrvSetConsoleNlsMode)
{
DPRINT1("%s not yet implemented\n", __FUNCTION__);
return STATUS_NOT_IMPLEMENTED;
}
-CSR_API(SrvSetConsoleNlsMode)
+CSR_API(SrvGetConsoleLangId)
{
DPRINT1("%s not yet implemented\n", __FUNCTION__);
return STATUS_NOT_IMPLEMENTED;
}
-CSR_API(SrvGetConsoleLangId)
-{
- DPRINT1("%s not yet implemented\n", __FUNCTION__);
- return STATUS_NOT_IMPLEMENTED;
-}
-
/* EOF */
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/lineinput.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
--- branches/condrv_restructure/win32ss/user/winsrv/consrv/lineinput.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/win32ss/user/winsrv/consrv/lineinput.c [iso-8859-1] Mon
Jul 28 13:20:54 2014
@@ -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,9 +19,25 @@
UINT Position;
UINT MaxEntries;
UINT NumEntries;
+ UNICODE_STRING ExeName;
PUNICODE_STRING Entries;
- UNICODE_STRING ExeName;
} 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 **********************************************************/
@@ -124,17 +138,51 @@
}
static PHISTORY_BUFFER
-HistoryFindBuffer(PCONSOLE Console, PUNICODE_STRING ExeName)
-{
- PLIST_ENTRY Entry = Console->HistoryBuffers.Flink;
+HistoryFindBuffer(PCONSOLE Console,
+ PVOID ExeName,
+ USHORT ExeLength,
+ BOOLEAN UnicodeExe)
+{
+ 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 @@
}
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 @@
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 @@
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);
- // }
-
- }
- }
- // FIXME: convert to UNICODE if Unicode == FALSE
- GetCommandHistoryRequest->HistoryLength = Buffer -
(PBYTE)GetCommandHistoryRequest->History;
+
+ 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;
+ }
+
+ // GetCommandHistoryRequest->HistoryLength = TargetBuffer -
(PBYTE)GetCommandHistoryRequest->History;
+ GetCommandHistoryRequest->HistoryLength = BytesWritten;
ConSrvReleaseConsole(Console, TRUE);
return Status;
@@ -523,7 +595,6 @@
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 @@
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);
- }
- GetCommandHistoryLengthRequest->HistoryLength = Length;
-
+ Length += Hist->Entries[i].Length + sizeof(WCHAR); // Each entry is
returned NULL-terminated
+ }
/*
* 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 @@
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 @@
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 @@
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 @@
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(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 @@
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 @@
ConSrvReleaseConsole(Console, TRUE);
}
return Status;
+#else
+ DPRINT1("%s not yet implemented\n", __FUNCTION__);
+ return STATUS_NOT_IMPLEMENTED;
+#endif
}
CSR_API(SrvSetConsoleCommandHistoryMode)