mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 01:39:30 +00:00
- call csrss for Console alias related functions
svn path=/trunk/; revision=32118
This commit is contained in:
parent
188cc187b1
commit
f63b6c9df1
1 changed files with 214 additions and 230 deletions
|
@ -27,14 +27,10 @@ typedef struct tagALIAS
|
||||||
DWORD dwUsed;
|
DWORD dwUsed;
|
||||||
} ALIAS, *LPALIAS;
|
} ALIAS, *LPALIAS;
|
||||||
|
|
||||||
static LPALIAS lpFirst = NULL;
|
|
||||||
static LPALIAS lpLast = NULL;
|
|
||||||
|
|
||||||
extern BOOL WINAPI DefaultConsoleCtrlHandler(DWORD Event);
|
extern BOOL WINAPI DefaultConsoleCtrlHandler(DWORD Event);
|
||||||
extern __declspec(noreturn) VOID CALLBACK ConsoleControlDispatcher(DWORD CodeAndFlag);
|
extern __declspec(noreturn) VOID CALLBACK ConsoleControlDispatcher(DWORD CodeAndFlag);
|
||||||
extern RTL_CRITICAL_SECTION ConsoleLock;
|
extern RTL_CRITICAL_SECTION ConsoleLock;
|
||||||
extern BOOL WINAPI IsDebuggerPresent(VOID);
|
extern BOOL WINAPI IsDebuggerPresent(VOID);
|
||||||
static VOID partstrlwr (LPWSTR str);
|
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
|
@ -44,19 +40,6 @@ static PHANDLER_ROUTINE* CtrlHandlers = NULL;
|
||||||
static ULONG NrCtrlHandlers = 0;
|
static ULONG NrCtrlHandlers = 0;
|
||||||
static WCHAR InputExeName[MAX_PATH + 1] = L"";
|
static WCHAR InputExeName[MAX_PATH + 1] = L"";
|
||||||
|
|
||||||
/* module internal functions */
|
|
||||||
/* strlwr only for first word in string */
|
|
||||||
static VOID
|
|
||||||
partstrlwr (LPWSTR str)
|
|
||||||
{
|
|
||||||
LPWSTR c = str;
|
|
||||||
while (*c && !iswspace (*c) && *c != L'=')
|
|
||||||
{
|
|
||||||
*c = towlower (*c);
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Default Console Control Handler *******************************************/
|
/* Default Console Control Handler *******************************************/
|
||||||
|
|
||||||
BOOL WINAPI DefaultConsoleCtrlHandler(DWORD Event)
|
BOOL WINAPI DefaultConsoleCtrlHandler(DWORD Event)
|
||||||
|
@ -206,124 +189,27 @@ AddConsoleAliasW (LPCWSTR lpSource,
|
||||||
LPCWSTR lpTarget,
|
LPCWSTR lpTarget,
|
||||||
LPCWSTR lpExeName /* FIXME: currently ignored */)
|
LPCWSTR lpExeName /* FIXME: currently ignored */)
|
||||||
{
|
{
|
||||||
LPALIAS ptr = lpFirst;
|
CSR_API_MESSAGE Request;
|
||||||
LPALIAS prev = NULL;
|
ULONG CsrRequest;
|
||||||
LPALIAS entry = NULL;
|
NTSTATUS Status;
|
||||||
LPWSTR s;
|
|
||||||
|
|
||||||
if (!lpTarget)
|
CsrRequest = MAKE_CSR_API(ADD_CONSOLE_ALIAS, CSR_NATIVE);
|
||||||
{
|
|
||||||
/* delete */
|
Request.Data.AddConsoleAlias.lpExeName = lpExeName;
|
||||||
while (ptr)
|
Request.Data.AddConsoleAlias.lpTarget = lpTarget;
|
||||||
{
|
Request.Data.AddConsoleAlias.lpSource = lpSource;
|
||||||
if (!wcsicmp (ptr->lpName, lpSource))
|
|
||||||
{
|
Status = CsrClientCallServer(& Request,
|
||||||
if (prev)
|
NULL,
|
||||||
prev->next = ptr->next;
|
CsrRequest,
|
||||||
else
|
sizeof(CSR_API_MESSAGE));
|
||||||
lpFirst = ptr->next;
|
|
||||||
RtlFreeHeap (GetProcessHeap(), 0, ptr->lpName);
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
|
||||||
RtlFreeHeap (GetProcessHeap(), 0, ptr->lpSubst);
|
|
||||||
RtlFreeHeap (GetProcessHeap(), 0, ptr);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
prev = ptr;
|
|
||||||
ptr = ptr->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* add */
|
|
||||||
while (ptr)
|
|
||||||
{
|
|
||||||
if (!wcsicmp (ptr->lpName, lpSource))
|
|
||||||
{
|
|
||||||
s = (LPWSTR) RtlAllocateHeap (GetProcessHeap(), 0, ((wcslen (lpTarget) + 1) * sizeof(WCHAR)));
|
|
||||||
if (!s)
|
|
||||||
{
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlFreeHeap (GetProcessHeap(), 0, ptr->lpSubst);
|
|
||||||
ptr->lpSubst = s;
|
|
||||||
wcscpy (ptr->lpSubst, lpTarget);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
ptr = ptr->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
ptr = (LPALIAS) RtlAllocateHeap (GetProcessHeap(), 0, sizeof(ALIAS));
|
|
||||||
if (!ptr)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
ptr->next = 0;
|
|
||||||
|
|
||||||
ptr->lpName = (LPWSTR) RtlAllocateHeap (GetProcessHeap(), 0, ((wcslen (lpSource) + 1) * sizeof(WCHAR)));
|
|
||||||
if (!ptr->lpName)
|
|
||||||
{
|
|
||||||
RtlFreeHeap (GetProcessHeap(), 0, ptr);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
wcscpy (ptr->lpName, lpSource);
|
|
||||||
|
|
||||||
ptr->lpSubst = (LPWSTR) RtlAllocateHeap (GetProcessHeap(), 0, ((wcslen (lpTarget) + 1) * sizeof(WCHAR)));
|
|
||||||
if (!ptr->lpSubst)
|
|
||||||
{
|
|
||||||
RtlFreeHeap (GetProcessHeap(), 0, ptr->lpName);
|
|
||||||
RtlFreeHeap (GetProcessHeap(), 0, ptr);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
wcscpy (ptr->lpSubst, lpTarget);
|
|
||||||
|
|
||||||
/* it's necessary for recursive substitution */
|
|
||||||
partstrlwr (ptr->lpSubst);
|
|
||||||
|
|
||||||
ptr->dwUsed = 0;
|
|
||||||
|
|
||||||
/* Alias table must be sorted!
|
|
||||||
* Here a little example:
|
|
||||||
* command line = "ls -c"
|
|
||||||
* If the entries are
|
|
||||||
* ls=dir
|
|
||||||
* ls -c=ls /w
|
|
||||||
* command line will be expanded to "dir -c" which is not correct.
|
|
||||||
* If the entries are sortet as
|
|
||||||
* ls -c=ls /w
|
|
||||||
* ls=dir
|
|
||||||
* it will be expanded to "dir /w" which is a valid DOS command.
|
|
||||||
*/
|
|
||||||
entry = lpFirst;
|
|
||||||
prev = 0;
|
|
||||||
while (entry)
|
|
||||||
{
|
|
||||||
if (wcsicmp (ptr->lpName, entry->lpName) > 0)
|
|
||||||
|
|
||||||
{
|
|
||||||
if (prev)
|
|
||||||
{
|
|
||||||
prev->next = ptr;
|
|
||||||
ptr->next = entry;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ptr->next = entry;
|
|
||||||
lpFirst = ptr;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
prev = entry;
|
|
||||||
entry = entry->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The new entry is the smallest (or the first) and must be
|
|
||||||
* added to the end of the list.
|
|
||||||
*/
|
|
||||||
if (!lpFirst)
|
|
||||||
lpFirst = ptr;
|
|
||||||
else
|
|
||||||
lpLast->next = ptr;
|
|
||||||
lpLast = ptr;
|
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,38 +304,36 @@ DWORD STDCALL
|
||||||
GetConsoleAliasW (LPWSTR lpSource,
|
GetConsoleAliasW (LPWSTR lpSource,
|
||||||
LPWSTR lpTargetBuffer,
|
LPWSTR lpTargetBuffer,
|
||||||
DWORD TargetBufferLength,
|
DWORD TargetBufferLength,
|
||||||
LPWSTR lpExeName) /* FIXME: currently ignored */
|
LPWSTR lpExeName)
|
||||||
{
|
{
|
||||||
DWORD dwRet = 0;
|
CSR_API_MESSAGE Request;
|
||||||
|
ULONG CsrRequest;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
if (!lpTargetBuffer)
|
CsrRequest = MAKE_CSR_API(GET_CONSOLE_ALIAS, CSR_NATIVE);
|
||||||
return 0;
|
|
||||||
|
|
||||||
LPALIAS ptr = lpFirst;
|
Request.Data.GetConsoleAlias.lpExeName = lpExeName;
|
||||||
while (ptr)
|
Request.Data.GetConsoleAlias.lpSource = lpSource;
|
||||||
|
Request.Data.GetConsoleAlias.TargetBuffer = lpTargetBuffer;
|
||||||
|
Request.Data.GetConsoleAlias.TargetBufferLength = TargetBufferLength;
|
||||||
|
|
||||||
|
Status = CsrClientCallServer(& Request,
|
||||||
|
NULL,
|
||||||
|
CsrRequest,
|
||||||
|
sizeof(CSR_API_MESSAGE));
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
|
||||||
{
|
{
|
||||||
if (wcscmp(ptr->lpName, lpSource) == 0)
|
SetLastErrorByStatus(Status);
|
||||||
{
|
return FALSE;
|
||||||
if (TargetBufferLength >= wcslen(ptr->lpSubst) +1)
|
|
||||||
{
|
|
||||||
wcscpy(lpTargetBuffer, ptr->lpSubst);
|
|
||||||
dwRet = wcslen(ptr->lpSubst);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ptr = ptr->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dwRet;
|
return Request.Data.GetConsoleAlias.BytesWritten / sizeof(WCHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
DWORD STDCALL
|
DWORD STDCALL
|
||||||
GetConsoleAliasA (LPSTR lpSource,
|
GetConsoleAliasA (LPSTR lpSource,
|
||||||
|
@ -457,59 +341,130 @@ GetConsoleAliasA (LPSTR lpSource,
|
||||||
DWORD TargetBufferLength,
|
DWORD TargetBufferLength,
|
||||||
LPSTR lpExeName)
|
LPSTR lpExeName)
|
||||||
{
|
{
|
||||||
DPRINT1("GetConsoleAliasA(0x%p, 0x%p, 0x%x, 0x%p) UNIMPLEMENTED!\n", lpSource, lpTargetBuffer, TargetBufferLength, lpExeName);
|
LPWSTR lpwSource;
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
LPWSTR lpwExeName;
|
||||||
return 0;
|
LPWSTR lpwTargetBuffer;
|
||||||
|
UINT dwSourceSize;
|
||||||
|
UINT dwExeNameSize;
|
||||||
|
UINT dwResult;
|
||||||
|
|
||||||
|
dwSourceSize = (strlen(lpSource)+1) * sizeof(WCHAR);
|
||||||
|
lpwSource = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSourceSize);
|
||||||
|
MultiByteToWideChar(CP_ACP, 0, lpSource, -1, lpwSource, dwSourceSize);
|
||||||
|
|
||||||
|
dwExeNameSize = (strlen(lpExeName)+1) * sizeof(WCHAR);
|
||||||
|
lpwExeName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwExeNameSize);
|
||||||
|
MultiByteToWideChar(CP_ACP, 0, lpExeName, -1, lpwExeName, dwExeNameSize);
|
||||||
|
|
||||||
|
lpwTargetBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, TargetBufferLength * sizeof(WCHAR));
|
||||||
|
|
||||||
|
dwResult = GetConsoleAliasW(lpwSource, lpwTargetBuffer, TargetBufferLength, lpwExeName);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, lpwSource);
|
||||||
|
HeapFree(GetProcessHeap(), 0, lpwExeName);
|
||||||
|
|
||||||
|
if (dwResult)
|
||||||
|
dwResult = WideCharToMultiByte(CP_ACP, 0, lpwTargetBuffer, dwResult, lpTargetBuffer, TargetBufferLength, NULL, NULL);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, lpwTargetBuffer);
|
||||||
|
|
||||||
|
return dwResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
DWORD STDCALL
|
DWORD STDCALL
|
||||||
GetConsoleAliasExesW (LPWSTR lpExeNameBuffer,
|
GetConsoleAliasExesW (LPWSTR lpExeNameBuffer,
|
||||||
DWORD ExeNameBufferLength)
|
DWORD ExeNameBufferLength)
|
||||||
{
|
{
|
||||||
DPRINT1("GetConsoleAliasExesW(0x%p, 0x%x) UNIMPLEMENTED!\n", lpExeNameBuffer, ExeNameBufferLength);
|
CSR_API_MESSAGE Request;
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
ULONG CsrRequest;
|
||||||
return 0;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
CsrRequest = MAKE_CSR_API(GET_CONSOLE_ALIASES_EXES, CSR_NATIVE);
|
||||||
|
Request.Data.GetConsoleAliasesExes.ExeNames = lpExeNameBuffer;
|
||||||
|
Request.Data.GetConsoleAliasesExes.Length = ExeNameBufferLength;
|
||||||
|
|
||||||
|
Status = CsrClientCallServer(& Request,
|
||||||
|
NULL,
|
||||||
|
CsrRequest,
|
||||||
|
sizeof(CSR_API_MESSAGE));
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Request.Data.GetConsoleAliasesExes.BytesWritten / sizeof(WCHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
DWORD STDCALL
|
DWORD STDCALL
|
||||||
GetConsoleAliasExesA (LPSTR lpExeNameBuffer,
|
GetConsoleAliasExesA (LPSTR lpExeNameBuffer,
|
||||||
DWORD ExeNameBufferLength)
|
DWORD ExeNameBufferLength)
|
||||||
{
|
{
|
||||||
DPRINT1("GetConsoleAliasExesA(0x%p, 0x%x) UNIMPLEMENTED!\n", lpExeNameBuffer, ExeNameBufferLength);
|
LPWSTR lpwExeNameBuffer;
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
DWORD dwResult;
|
||||||
return 0;
|
|
||||||
|
lpwExeNameBuffer = HeapAlloc(GetProcessHeap(), 0, ExeNameBufferLength * sizeof(WCHAR));
|
||||||
|
|
||||||
|
dwResult = GetConsoleAliasExesW(lpwExeNameBuffer, ExeNameBufferLength);
|
||||||
|
|
||||||
|
if (dwResult)
|
||||||
|
dwResult = WideCharToMultiByte(CP_ACP, 0, lpwExeNameBuffer, dwResult, lpExeNameBuffer, ExeNameBufferLength, NULL, NULL);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, lpwExeNameBuffer);
|
||||||
|
return dwResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
|
||||||
DWORD STDCALL
|
|
||||||
GetConsoleAliasExesLengthA (VOID)
|
|
||||||
{
|
|
||||||
DPRINT1("GetConsoleAliasExesLengthA() UNIMPLEMENTED!\n");
|
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @unimplemented
|
|
||||||
*/
|
*/
|
||||||
DWORD STDCALL
|
DWORD STDCALL
|
||||||
GetConsoleAliasExesLengthW (VOID)
|
GetConsoleAliasExesLengthW (VOID)
|
||||||
{
|
{
|
||||||
DPRINT1("GetConsoleAliasExesLengthW() UNIMPLEMENTED!\n");
|
CSR_API_MESSAGE Request;
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
ULONG CsrRequest;
|
||||||
return 0;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
CsrRequest = MAKE_CSR_API(GET_CONSOLE_ALIASES_EXES_LENGTH, CSR_NATIVE);
|
||||||
|
Request.Data.GetConsoleAliasesExesLength.Length = 0;
|
||||||
|
|
||||||
|
|
||||||
|
Status = CsrClientCallServer(& Request,
|
||||||
|
NULL,
|
||||||
|
CsrRequest,
|
||||||
|
sizeof(CSR_API_MESSAGE));
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Request.Data.GetConsoleAliasesExesLength.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
DWORD STDCALL
|
||||||
|
GetConsoleAliasExesLengthA (VOID)
|
||||||
|
{
|
||||||
|
DWORD dwLength;
|
||||||
|
|
||||||
|
dwLength = GetConsoleAliasExesLengthW();
|
||||||
|
|
||||||
|
if (dwLength)
|
||||||
|
dwLength /= sizeof(WCHAR);
|
||||||
|
|
||||||
|
return dwLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -519,47 +474,34 @@ GetConsoleAliasExesLengthW (VOID)
|
||||||
DWORD STDCALL
|
DWORD STDCALL
|
||||||
GetConsoleAliasesW (LPWSTR AliasBuffer,
|
GetConsoleAliasesW (LPWSTR AliasBuffer,
|
||||||
DWORD AliasBufferLength,
|
DWORD AliasBufferLength,
|
||||||
LPWSTR ExeName) /* FIXME: currently ignored */
|
LPWSTR ExeName)
|
||||||
{
|
{
|
||||||
DWORD len;
|
CSR_API_MESSAGE Request;
|
||||||
WCHAR Buffer[MAX_PATH];
|
ULONG CsrRequest;
|
||||||
LPWSTR AliasPtr;
|
NTSTATUS Status;
|
||||||
|
DWORD dwLength;
|
||||||
|
|
||||||
if (!AliasBuffer)
|
dwLength = GetConsoleAliasesLengthW(ExeName);
|
||||||
return 0;
|
if (!dwLength || dwLength > AliasBufferLength)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
AliasPtr = AliasBuffer;
|
CsrRequest = MAKE_CSR_API(GET_ALL_CONSOLE_ALIASES, CSR_NATIVE);
|
||||||
len = GetConsoleAliasesLengthW (ExeName);
|
Request.Data.GetAllConsoleAlias.AliasBuffer = AliasBuffer;
|
||||||
if (len > AliasBufferLength)
|
Request.Data.GetAllConsoleAlias.AliasBufferLength = AliasBufferLength;
|
||||||
return 0;
|
Request.Data.GetAllConsoleAlias.lpExeName = ExeName;
|
||||||
|
|
||||||
LPALIAS ptr = lpFirst;
|
Status = CsrClientCallServer(& Request,
|
||||||
while (ptr)
|
NULL,
|
||||||
|
CsrRequest,
|
||||||
|
sizeof(CSR_API_MESSAGE));
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
|
||||||
{
|
{
|
||||||
swprintf(Buffer, L"%s=%s" , ptr->lpName, ptr->lpSubst);
|
SetLastErrorByStatus(Status);
|
||||||
wcscpy(AliasBuffer, Buffer);
|
return FALSE;
|
||||||
AliasBuffer += wcslen(Buffer) + 1;
|
|
||||||
ptr = ptr->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (INT) (AliasBuffer - AliasPtr);
|
return Request.Data.GetAllConsoleAlias.BytesWritten / sizeof(WCHAR);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @unimplemented
|
|
||||||
*/
|
|
||||||
DWORD STDCALL
|
|
||||||
GetConsoleAliasesA (LPSTR AliasBuffer,
|
|
||||||
DWORD AliasBufferLength,
|
|
||||||
LPSTR ExeName)
|
|
||||||
/*
|
|
||||||
* Undocumented
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
DPRINT1("GetConsoleAliasesA(0x%p, 0x%x, 0x%p) UNIMPLEMENTED!\n", AliasBuffer, AliasBufferLength, ExeName);
|
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -567,18 +509,58 @@ GetConsoleAliasesA (LPSTR AliasBuffer,
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
DWORD STDCALL
|
DWORD STDCALL
|
||||||
GetConsoleAliasesLengthW (LPWSTR lpExeName /* FIXME: currently ignored */)
|
GetConsoleAliasesA (LPSTR AliasBuffer,
|
||||||
|
DWORD AliasBufferLength,
|
||||||
|
LPSTR ExeName)
|
||||||
{
|
{
|
||||||
DWORD len = 0;
|
DWORD dwRetVal = 0;
|
||||||
LPALIAS ptr = lpFirst;
|
LPWSTR lpwExeName = NULL;
|
||||||
while (ptr)
|
LPWSTR lpwAliasBuffer;
|
||||||
{
|
|
||||||
len += wcslen(ptr->lpName) * sizeof(WCHAR);
|
if (ExeName)
|
||||||
len += wcslen(ptr->lpSubst) * sizeof(WCHAR);
|
BasepAnsiStringToHeapUnicodeString(ExeName, (LPWSTR*) &lpwExeName);
|
||||||
len += 2 * sizeof(WCHAR); /* '=' + '\0' */
|
|
||||||
ptr = ptr->next;
|
lpwAliasBuffer = HeapAlloc(GetProcessHeap(), 0, AliasBufferLength * sizeof(WCHAR));
|
||||||
|
|
||||||
|
dwRetVal = GetConsoleAliasesW(lpwAliasBuffer, AliasBufferLength, lpwExeName);
|
||||||
|
|
||||||
|
if (lpwExeName)
|
||||||
|
RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpwExeName);
|
||||||
|
|
||||||
|
if (dwRetVal)
|
||||||
|
dwRetVal = WideCharToMultiByte(CP_ACP, 0, lpwAliasBuffer, dwRetVal, AliasBuffer, AliasBufferLength, NULL, NULL);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, lpwAliasBuffer);
|
||||||
|
return dwRetVal;
|
||||||
}
|
}
|
||||||
return len;
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
DWORD STDCALL
|
||||||
|
GetConsoleAliasesLengthW (LPWSTR lpExeName)
|
||||||
|
{
|
||||||
|
CSR_API_MESSAGE Request;
|
||||||
|
ULONG CsrRequest;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
CsrRequest = MAKE_CSR_API(GET_ALL_CONSOLE_ALIASES_LENGTH, CSR_NATIVE);
|
||||||
|
Request.Data.GetAllConsoleAliasesLength.lpExeName = lpExeName;
|
||||||
|
Request.Data.GetAllConsoleAliasesLength.Length = 0;
|
||||||
|
|
||||||
|
Status = CsrClientCallServer(&Request,
|
||||||
|
NULL,
|
||||||
|
CsrRequest,
|
||||||
|
sizeof(CSR_API_MESSAGE));
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Request.Data.GetAllConsoleAliasesLength.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -594,7 +576,9 @@ GetConsoleAliasesLengthA (LPSTR lpExeName)
|
||||||
if (lpExeName)
|
if (lpExeName)
|
||||||
BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*) &lpExeNameW);
|
BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*) &lpExeNameW);
|
||||||
|
|
||||||
dwRetVal = (GetConsoleAliasesLengthW(lpExeNameW) / sizeof(WCHAR));
|
dwRetVal = GetConsoleAliasesLengthW(lpExeNameW);
|
||||||
|
if (dwRetVal)
|
||||||
|
dwRetVal /= sizeof(WCHAR);
|
||||||
|
|
||||||
/* Clean up */
|
/* Clean up */
|
||||||
if (lpExeNameW)
|
if (lpExeNameW)
|
||||||
|
|
Loading…
Reference in a new issue