fix kernel32 console winetest crash

svn path=/trunk/; revision=38879
This commit is contained in:
Christoph von Wittich 2009-01-18 10:06:34 +00:00
parent 0195906a3c
commit d068ad2d69

View file

@ -3763,6 +3763,7 @@ BOOL WINAPI SetConsoleIcon(HICON hicon)
BOOL WINAPI BOOL WINAPI
SetConsoleInputExeNameW(LPCWSTR lpInputExeName) SetConsoleInputExeNameW(LPCWSTR lpInputExeName)
{ {
NTSTATUS Status = STATUS_SUCCESS;
int lenName = lstrlenW(lpInputExeName); int lenName = lstrlenW(lpInputExeName);
if(lenName < 1 || if(lenName < 1 ||
@ -3776,8 +3777,16 @@ SetConsoleInputExeNameW(LPCWSTR lpInputExeName)
RtlEnterCriticalSection(&ConsoleLock); RtlEnterCriticalSection(&ConsoleLock);
_SEH2_TRY _SEH2_TRY
{ {
RtlCopyMemory(InputExeName, lpInputExeName, lenName * sizeof(WCHAR)); _SEH2_TRY
InputExeName[lenName] = L'\0'; {
RtlCopyMemory(InputExeName, lpInputExeName, lenName * sizeof(WCHAR));
InputExeName[lenName] = L'\0';
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
} }
_SEH2_FINALLY _SEH2_FINALLY
{ {
@ -3785,6 +3794,12 @@ SetConsoleInputExeNameW(LPCWSTR lpInputExeName)
} }
_SEH2_END; _SEH2_END;
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return FALSE;
}
return TRUE; return TRUE;
} }
@ -3836,20 +3851,28 @@ SetConsoleInputExeNameA(LPCSTR lpInputExeName)
DWORD WINAPI DWORD WINAPI
GetConsoleInputExeNameW(DWORD nBufferLength, LPWSTR lpBuffer) GetConsoleInputExeNameW(DWORD nBufferLength, LPWSTR lpBuffer)
{ {
NTSTATUS Status = STATUS_SUCCESS;
int lenName = 0; int lenName = 0;
RtlEnterCriticalSection(&ConsoleLock); RtlEnterCriticalSection(&ConsoleLock);
_SEH2_TRY _SEH2_TRY
{ {
lenName = lstrlenW(InputExeName); _SEH2_TRY
if(lenName >= (int)nBufferLength)
{ {
/* buffer is not large enough, return the required size */ lenName = lstrlenW(InputExeName);
SetLastError(ERROR_BUFFER_OVERFLOW); if(lenName >= (int)nBufferLength)
lenName += 1; {
/* buffer is not large enough, return the required size */
SetLastError(ERROR_BUFFER_OVERFLOW);
lenName += 1;
}
RtlCopyMemory(lpBuffer, InputExeName, (lenName + 1) * sizeof(WCHAR));
} }
RtlCopyMemory(lpBuffer, InputExeName, (lenName + 1) * sizeof(WCHAR)); _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
} }
_SEH2_FINALLY _SEH2_FINALLY
{ {
@ -3857,6 +3880,12 @@ GetConsoleInputExeNameW(DWORD nBufferLength, LPWSTR lpBuffer)
} }
_SEH2_END; _SEH2_END;
if (!NT_SUCCESS(Status))
{
SetLastError(ERROR_BUFFER_OVERFLOW);
return lenName + 1;
}
return lenName; return lenName;
} }