18#define PATH_VALID_CHARS \
19 (PATH_CHAR_CLASS_DOT | PATH_CHAR_CLASS_SEMICOLON | PATH_CHAR_CLASS_COMMA | \
20 PATH_CHAR_CLASS_SPACE | PATH_CHAR_CLASS_OTHER_VALID)
28 if (*lpString ==
L'"')
45 return &lpString[
lstrlenW(lpString)];
74 for (; *pszPath && bValid; ++pszPath)
80 pSpaceStart = pszPath;
102 while (*pSpaceStart ==
L' ')
107 return bValid ? pszPath :
NULL;
113 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths",
189 UINT cchArgs = (
UINT)(pszArgs - pszCmdTemplate);
195 bQuoted = (szExe[0] ==
L'"');
219 if (bQuoted || !*pszArgs)
226 cchArgs = (
UINT)(pszArgs - pszCmdTemplate);
257 *ppszApplication =
NULL;
259 *ppszCommandLine =
NULL;
261 *ppszParameters =
NULL;
284 if (*ppszApplication)
287 *ppszApplication =
NULL;
289 if (ppszCommandLine && *ppszCommandLine)
292 *ppszCommandLine =
NULL;
294 if (ppszParameters && *ppszParameters)
297 *ppszParameters =
NULL;
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
void WINAPI CoTaskMemFree(void *ptr)
LPWSTR WINAPI StrChrW(LPCWSTR lpszStr, WCHAR ch)
INT WINAPI StrCmpNIW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
BOOL WINAPI PathIsUNCW(const WCHAR *path)
void WINAPI PathUnquoteSpacesW(WCHAR *path)
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
HRESULT WINAPI PathCchAddExtension(WCHAR *path, SIZE_T size, const WCHAR *extension)
BOOL WINAPI PathIsValidCharW(WCHAR c, DWORD class)
BOOL WINAPI PathIsFileSpecW(const WCHAR *path)
HRESULT WINAPI PathCchCombineEx(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2, DWORD flags)
BOOL WINAPI StrTrimW(WCHAR *str, const WCHAR *trim)
HRESULT WINAPI SHStrDupW(const WCHAR *src, WCHAR **dest)
DWORD WINAPI SHGetValueW(HKEY hkey, const WCHAR *subkey, const WCHAR *value, DWORD *type, void *data, DWORD *data_len)
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
BOOL WINAPI PathFindOnPathExW(LPWSTR lpszFile, LPCWSTR *lppszOtherDirs, DWORD dwWhich)
BOOL WINAPI PathFileExistsDefExtAndAttributesW(_Inout_ LPWSTR pszPath, _In_ DWORD dwWhich, _Out_opt_ LPDWORD pdwFileAttributes)
static VOID _MakeAppPathKey(PCWSTR pszPath, PWSTR pszDest, UINT cchDest)
static HRESULT _PathExeExists(_In_ PCWSTR pszPath)
static BOOL _PathMatchesSuspicious(PCWSTR lpString)
"Program Files" contains space. It needs special handling. This function will detect it.
static HRESULT _PathFindInSystem(_Inout_ PWSTR pszPath, _In_ UINT cchPath)
static PCWSTR _PathGetArgsLikeCreateProcess(PCWSTR lpString)
static BOOL _GetAppPath(PCWSTR pszPath, PWSTR pszValue, DWORD cchValue)
static HRESULT _PathCopyExeAndTrimWhiteSpaces(PWSTR pszBuff, size_t cchBuff, PCWSTR pszSrc, size_t cchSrc)
static PCWSTR _PathGuessNextBestArgs(PCWSTR pszPath)
static HRESULT _PathFindInFolder(_In_ INT csidl, _In_ PCWSTR pszSrc, _Out_ PWSTR pszPath, _In_ UINT cchPath)
EXTERN_C HRESULT WINAPI SHEvaluateSystemCommandTemplate(_In_ PCWSTR pszCmdTemplate, _Outptr_ PWSTR *ppszApplication, _Outptr_opt_ PWSTR *ppszCommandLine, _Outptr_opt_ PWSTR *ppszParameters)
#define FILE_ATTRIBUTE_DIRECTORY
_In_opt_ _In_opt_ _In_ _In_ DWORD cbData
_In_opt_ LPCSTR _In_opt_ LPCSTR pszValue
#define CSIDL_PROGRAM_FILES
static HRESULT SHCoAlloc(_In_ SIZE_T cb, _Outptr_ PVOID *ppData)
static DWORD SHWindowsPolicyEx(_In_ REFGUID rpolid, _In_ DWORD dwDefaultValue)
static BOOL PathIsAbsolute(_In_ PCWSTR pszPath)
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
#define ERROR_PATH_NOT_FOUND
_In_ DWORD _In_ int cchSrc
#define HKEY_LOCAL_MACHINE