Fixed GetConsoleTitleA/W.

svn path=/trunk/; revision=17777
This commit is contained in:
Hartmut Birr 2005-09-10 15:18:42 +00:00
parent f03b5bcdff
commit a03dfb5235

View file

@ -3056,18 +3056,17 @@ GetConsoleTitleW(
return 0; return 0;
} }
if(nSize * sizeof(WCHAR) < Request->Data.GetTitleRequest.Length) if(nSize * sizeof(WCHAR) <= Request->Data.GetTitleRequest.Length)
{ {
wcsncpy(lpConsoleTitle, Request->Data.GetTitleRequest.Title, nSize - 1); nSize--;
lpConsoleTitle[nSize--] = L'\0';
} }
else else
{ {
nSize = Request->Data.GetTitleRequest.Length / sizeof (WCHAR); nSize = Request->Data.GetTitleRequest.Length / sizeof (WCHAR);
wcscpy(lpConsoleTitle, Request->Data.GetTitleRequest.Title);
lpConsoleTitle[nSize] = L'\0';
} }
memcpy(lpConsoleTitle, Request->Data.GetTitleRequest.Title, nSize * sizeof(WCHAR));
lpConsoleTitle[nSize] = L'\0';
RtlFreeHeap(RtlGetProcessHeap(), 0, Request); RtlFreeHeap(RtlGetProcessHeap(), 0, Request);
return nSize; return nSize;
@ -3088,8 +3087,8 @@ GetConsoleTitleA(
DWORD nSize DWORD nSize
) )
{ {
wchar_t WideTitle [CSRSS_MAX_TITLE_LENGTH]; WCHAR WideTitle [CSRSS_MAX_TITLE_LENGTH + 1];
DWORD nWideTitle = sizeof WideTitle; DWORD nWideTitle = CSRSS_MAX_TITLE_LENGTH + 1;
DWORD nWritten; DWORD nWritten;
if (!lpConsoleTitle || !nSize) return 0; if (!lpConsoleTitle || !nSize) return 0;
@ -3102,7 +3101,7 @@ GetConsoleTitleA(
(LPWSTR) WideTitle, // address of wide-character string (LPWSTR) WideTitle, // address of wide-character string
nWideTitle, // number of characters in string nWideTitle, // number of characters in string
lpConsoleTitle, // address of buffer for new string lpConsoleTitle, // address of buffer for new string
nSize, // size of buffer nSize - 1, // size of buffer
NULL, // FAST NULL, // FAST
NULL // FAST NULL // FAST
))) )))