Author: cwittich Date: Sun Jan 18 04:06:34 2009 New Revision: 38879
URL: http://svn.reactos.org/svn/reactos?rev=38879&view=rev Log: fix kernel32 console winetest crash
Modified: trunk/reactos/dll/win32/kernel32/misc/console.c
Modified: trunk/reactos/dll/win32/kernel32/misc/console.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/con... ============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] Sun Jan 18 04:06:34 2009 @@ -3763,6 +3763,7 @@ BOOL WINAPI SetConsoleInputExeNameW(LPCWSTR lpInputExeName) { + NTSTATUS Status = STATUS_SUCCESS; int lenName = lstrlenW(lpInputExeName);
if(lenName < 1 || @@ -3776,14 +3777,28 @@ RtlEnterCriticalSection(&ConsoleLock); _SEH2_TRY { - RtlCopyMemory(InputExeName, lpInputExeName, lenName * sizeof(WCHAR)); - InputExeName[lenName] = L'\0'; + _SEH2_TRY + { + RtlCopyMemory(InputExeName, lpInputExeName, lenName * sizeof(WCHAR)); + InputExeName[lenName] = L'\0'; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END; } _SEH2_FINALLY { RtlLeaveCriticalSection(&ConsoleLock); } _SEH2_END; + + if (!NT_SUCCESS(Status)) + { + SetLastErrorByStatus(Status); + return FALSE; + }
return TRUE; } @@ -3836,26 +3851,40 @@ DWORD WINAPI GetConsoleInputExeNameW(DWORD nBufferLength, LPWSTR lpBuffer) { + NTSTATUS Status = STATUS_SUCCESS; int lenName = 0;
RtlEnterCriticalSection(&ConsoleLock); - _SEH2_TRY { - lenName = lstrlenW(InputExeName); - if(lenName >= (int)nBufferLength) + _SEH2_TRY { - /* buffer is not large enough, return the required size */ - SetLastError(ERROR_BUFFER_OVERFLOW); - lenName += 1; + lenName = lstrlenW(InputExeName); + if(lenName >= (int)nBufferLength) + { + /* 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 { RtlLeaveCriticalSection(&ConsoleLock); } _SEH2_END; + + if (!NT_SUCCESS(Status)) + { + SetLastError(ERROR_BUFFER_OVERFLOW); + return lenName + 1; + }
return lenName; }