diff --git a/dll/win32/kernel32/client/path.c b/dll/win32/kernel32/client/path.c index 1db9082..c23ebf0 100644 --- a/dll/win32/kernel32/client/path.c +++ b/dll/win32/kernel32/client/path.c @@ -1,7 +1,6 @@ /* * PROJECT: ReactOS Win32 Base API * LICENSE: GPL - See COPYING in the top level directory - * FILE: dll/win32/kernel32/client/path.c * PURPOSE: Handles path APIs * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) */ @@ -2320,7 +2319,7 @@ GetSystemDirectoryW(OUT LPWSTR lpBuffer, RtlCopyMemory(lpBuffer, BaseWindowsSystemDirectory.Buffer, BaseWindowsSystemDirectory.Length); - lpBuffer[BaseWindowsSystemDirectory.Length / sizeof(WCHAR)] = ANSI_NULL; + lpBuffer[BaseWindowsSystemDirectory.Length / sizeof(WCHAR)] = UNICODE_NULL; ReturnLength = BaseWindowsSystemDirectory.Length; } @@ -2404,7 +2403,7 @@ GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, RtlCopyMemory(lpBuffer, BaseWindowsDirectory.Buffer, BaseWindowsDirectory.Length); - lpBuffer[BaseWindowsDirectory.Length / sizeof(WCHAR)] = ANSI_NULL; + lpBuffer[BaseWindowsDirectory.Length / sizeof(WCHAR)] = UNICODE_NULL; ReturnLength = BaseWindowsDirectory.Length; } diff --git a/dll/win32/shell32/shlexec.cpp b/dll/win32/shell32/shlexec.cpp index 824990e..c8fe110 100644 --- a/dll/win32/shell32/shlexec.cpp +++ b/dll/win32/shell32/shlexec.cpp @@ -2450,6 +2450,8 @@ HRESULT WINAPI ShellExecCmdLine( } else { + PCWSTR apPathList[2]; + pchParams = SplitParams(lpCommand, szFile, _countof(szFile)); if (szFile[0] != UNICODE_NULL && szFile[1] == L':' && szFile[2] == UNICODE_NULL) @@ -2470,30 +2472,10 @@ HRESULT WINAPI ShellExecCmdLine( { StringCchCopyW(szFile, _countof(szFile), szFile2); } - else if (SearchPathW(NULL, szFile, NULL, _countof(szFile2), szFile2, NULL) || - SearchPathW(NULL, szFile, wszExe, _countof(szFile2), szFile2, NULL) || - SearchPathW(NULL, szFile, wszCom, _countof(szFile2), szFile2, NULL) || - SearchPathW(pwszStartDir, szFile, NULL, _countof(szFile2), szFile2, NULL) || - SearchPathW(pwszStartDir, szFile, wszExe, _countof(szFile2), szFile2, NULL) || - SearchPathW(pwszStartDir, szFile, wszCom, _countof(szFile2), szFile2, NULL)) - { - StringCchCopyW(szFile, _countof(szFile), szFile2); - } - else if (SearchPathW(NULL, lpCommand, NULL, _countof(szFile2), szFile2, NULL) || - SearchPathW(NULL, lpCommand, wszExe, _countof(szFile2), szFile2, NULL) || - SearchPathW(NULL, lpCommand, wszCom, _countof(szFile2), szFile2, NULL) || - SearchPathW(pwszStartDir, lpCommand, NULL, _countof(szFile2), szFile2, NULL) || - SearchPathW(pwszStartDir, lpCommand, wszExe, _countof(szFile2), szFile2, NULL) || - SearchPathW(pwszStartDir, lpCommand, wszCom, _countof(szFile2), szFile2, NULL)) - { - StringCchCopyW(szFile, _countof(szFile), szFile2); - pchParams = NULL; - } - if (pwszStartDir) - { - SetCurrentDirectoryW(szCurDir); - } + apPathList[0] = pwszStartDir; + apPathList[1] = NULL; + PathFindOnPathExW(szFile, apPathList, WHICH_DEFAULT); if (!(dwSeclFlags & SECL_ALLOW_NONEXE)) { diff --git a/dll/win32/shlwapi/path.c b/dll/win32/shlwapi/path.c index f3149f3..c298d48 100644 --- a/dll/win32/shlwapi/path.c +++ b/dll/win32/shlwapi/path.c @@ -323,8 +323,6 @@ LPWSTR WINAPI PathAddBackslashW( LPWSTR lpszPath ) */ LPSTR WINAPI PathBuildRootA(LPSTR lpszPath, int drive) { - TRACE("(%p,%d)\n", lpszPath, drive); - if (lpszPath && drive >= 0 && drive < 26) { lpszPath[0] = 'A' + drive; @@ -342,8 +340,6 @@ LPSTR WINAPI PathBuildRootA(LPSTR lpszPath, int drive) */ LPWSTR WINAPI PathBuildRootW(LPWSTR lpszPath, int drive) { - TRACE("(%p,%d)\n", lpszPath, drive); - if (lpszPath && drive >= 0 && drive < 26) { lpszPath[0] = 'A' + drive; @@ -1135,7 +1131,8 @@ BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath,DWORD dwWhich) return FALSE; while ( (dwWhich & 0x1) && pszExts[iChoose][0] ) { - lstrcpyW(lpszPath + iLen, pszExts[iChoose]); + if (GetFileAttributesW((LPCWSTR)lpszPath) != FILE_ATTRIBUTE_DIRECTORY) + lstrcpyW(lpszPath + iLen, pszExts[iChoose]); if (PathFileExistsW(lpszPath)) return TRUE; iChoose++; @@ -2850,8 +2847,6 @@ BOOL WINAPI PathCompactPathA(HDC hDC, LPSTR lpszPath, UINT dx) { BOOL bRet = FALSE; - TRACE("(%p,%s,%d)\n", hDC, debugstr_a(lpszPath), dx); - if (lpszPath) { WCHAR szPath[MAX_PATH]; @@ -2876,8 +2871,6 @@ BOOL WINAPI PathCompactPathW(HDC hDC, LPWSTR lpszPath, UINT dx) SIZE size; DWORD dwLen; - TRACE("(%p,%s,%d)\n", hDC, debugstr_w(lpszPath), dx); - if (!lpszPath) return FALSE; @@ -3190,8 +3183,6 @@ BOOL WINAPI PathRenameExtensionW(LPWSTR lpszPath, LPCWSTR lpszExt) */ BOOL WINAPI PathSearchAndQualifyA(LPCSTR lpszPath, LPSTR lpszBuf, UINT cchBuf) { - TRACE("(%s,%p,0x%08x)\n", debugstr_a(lpszPath), lpszBuf, cchBuf); - if(SearchPathA(NULL, lpszPath, NULL, cchBuf, lpszBuf, NULL)) return TRUE; return !!GetFullPathNameA(lpszPath, cchBuf, lpszBuf, NULL); @@ -3204,8 +3195,6 @@ BOOL WINAPI PathSearchAndQualifyA(LPCSTR lpszPath, LPSTR lpszBuf, UINT cchBuf) */ BOOL WINAPI PathSearchAndQualifyW(LPCWSTR lpszPath, LPWSTR lpszBuf, UINT cchBuf) { - TRACE("(%s,%p,0x%08x)\n", debugstr_w(lpszPath), lpszBuf, cchBuf); - if(SearchPathW(NULL, lpszPath, NULL, cchBuf, lpszBuf, NULL)) return TRUE; return !!GetFullPathNameW(lpszPath, cchBuf, lpszBuf, NULL); diff --git a/sdk/include/reactos/shlwapi_undoc.h b/sdk/include/reactos/shlwapi_undoc.h index 08af859..3b7aa04 100644 --- a/sdk/include/reactos/shlwapi_undoc.h +++ b/sdk/include/reactos/shlwapi_undoc.h @@ -120,6 +120,18 @@ INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen); PVOID WINAPI SHLockSharedEx(HANDLE hData, DWORD dwProcessId, BOOL bWriteAccess); +/* dwWhich flags for PathFileExistsDefExtW and PathFindOnPathExW */ +#define WHICH_PIF (1 << 0) +#define WHICH_COM (1 << 1) +#define WHICH_EXE (1 << 2) +#define WHICH_BAT (1 << 3) +#define WHICH_LNK (1 << 4) +#define WHICH_CMD (1 << 5) + +#define WHICH_DEFAULT (WHICH_PIF | WHICH_COM | WHICH_EXE | WHICH_BAT | WHICH_LNK | WHICH_CMD) + +BOOL WINAPI PathFindOnPathExW(LPWSTR lpszFile, LPCWSTR *lppszOtherDirs, DWORD dwWhich); + #ifdef __cplusplus } /* extern "C" */ #endif /* defined(__cplusplus) */