From 1487d68971c2842cd7efd459b421c225051a5965 Mon Sep 17 00:00:00 2001 From: Dmitry Chapyshev Date: Wed, 15 Apr 2009 17:18:20 +0000 Subject: [PATCH] - Revert r40529 svn path=/trunk/; revision=40532 --- reactos/dll/win32/kernel32/process/procsup.c | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/reactos/dll/win32/kernel32/process/procsup.c b/reactos/dll/win32/kernel32/process/procsup.c index 7b8bafbb84b..d84384ab9ba 100644 --- a/reactos/dll/win32/kernel32/process/procsup.c +++ b/reactos/dll/win32/kernel32/process/procsup.c @@ -718,6 +718,38 @@ CreateProcessInternalW(HANDLE hToken, return FALSE; } + if (lpCurrentDirectory) + { + LPWSTR FilePart, Buffer = NULL; + + Buffer = RtlAllocateHeap(RtlGetProcessHeap(), + 0, + (MAX_PATH + 1) * sizeof(WCHAR)); + + if (!Buffer) + { + SetLastErrorByStatus(STATUS_NO_MEMORY); + return FALSE; + } + + if (GetFullPathNameW(lpCurrentDirectory, MAX_PATH, Buffer, &FilePart) > MAX_PATH) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); + SetLastError(ERROR_DIRECTORY); + return FALSE; + } + + if ((GetFileAttributesW(Buffer) == INVALID_FILE_ATTRIBUTES) || + !(GetFileAttributesW(Buffer) & FILE_ATTRIBUTE_DIRECTORY)) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); + SetLastError(ERROR_DIRECTORY); + return FALSE; + } + + RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); + } + /* * We're going to modify and mask out flags and stuff in lpStartupInfo, * so we'll use our own local copy for that.