18#define WIDEN(x) _WIDEN(x)
20#define TEST_FILENAMEA "SHExplorerParseCmdLine.test"
21#define TEST_FILENAMEW WIDEN(TEST_FILENAMEA)
23#define TEST_PATHA "C:\\SHExplorerParseCmdLine.test"
24#define TEST_PATHW WIDEN(TEST_PATHA)
29#define PIDL_IS_UNTOUCHED -1
30#define PIDL_IS_NULL -2
31#define PIDL_IS_PATH -3
32#define PIDL_IS_EMPTY -4
33#define PIDL_PATH_EQUALS_PATH -5
35#define InvalidPointer ((PVOID)0x5555555555555555ULL)
87 Info.dwFlags = 0x00000000;
91 if (ExpectedRet == -1)
97 ok(Ret == ExpectedRet,
"Line %lu: Ret = 0x%Ix, expected 0x%Ix\n", TestLine, Ret, ExpectedRet);
100 if (ExpectedFileName ==
NULL)
107 ok(
Info.strPath !=
NULL,
"Line %lu: strPath = NULL\n", TestLine);
110 ok(!
wcscmp(
Info.strPath, ExpectedFileName),
"Line %lu: strPath = %ls, expected %ls\n", TestLine,
Info.strPath, ExpectedFileName);
115 ok(
Info.dwFlags == ExpectedFlags,
"Line %lu: dwFlags = %08lx, expected %08lx\n", TestLine,
Info.dwFlags, ExpectedFlags);
123 ok(
Info.pidlPath ==
NULL,
"Line %lu: pidlPath = %p\n", TestLine,
Info.pidlPath);
131 ok(
Info.pidlPath !=
NULL,
"Line %lu: pidlPath = NULL\n", TestLine);
143 if (
wcslen(curDir) != 0 && curDir[
wcslen(curDir) - 1] !=
L'\\')
167 ok(
_wcsicmp(pidlPathName, pidlPathTest) == 0,
"Line %lu: Path from pidl does not match; pidlPathName=%S\n", TestLine, pidlPathName);
171 ok(
wcslen(pidlPathName) == 0,
"Line %lu: Unexpected non-empty path from pidl; pidlPathName=%S\n", TestLine, pidlPathName);
179 ok(ExpectedPidl !=
NULL,
"Line %lu: SHSimpleIDListFromPath(%S) failed. pidlPathName=%S\n", TestLine, pidlPathTest, pidlPathName);
182 ok(
ILIsEqual(
Info.pidlPath, ExpectedPidl),
"Line %lu: Unexpected pidlPath value %p; pidlPathName=%S pidlPathTest=%S\n", TestLine,
Info.pidlPath, pidlPathName, pidlPathTest);
189 ok(
hr ==
S_OK,
"Line %lu: SHGetFolderLocation returned %08lx\n", TestLine,
hr);
195 ok(
eq,
"Line %lu: Unexpected pidlPath value %p; pidlPathName=%S CSIDL=%d\n", TestLine,
Info.pidlPath, pidlPathName, ExpectedCsidl);
206 switch (
i *
sizeof(
DWORD))
225 ok(InfoWords[
i] == 0x55555555,
"Line %lu: Word 0x%02lx has been set to 0x%08lx\n", TestLine,
i *
sizeof(
DWORD), InfoWords[
i]);
237 ok(
memcmp(
ab, &
Info.clsid,
sizeof(
ab)) == 0,
"Line %lu: CLSID was %ls.\n", TestLine, psz);
241 ok(
lstrcmpiW(psz, pclsid) == 0,
"Line %lu: CLSID was %ls.\n", TestLine, psz);
252 for (
i =
sizeof(
Info);
i > 0;
i--)
254 if (
data[
i - 1] != 0x55)
285 { __LINE__,
L"/e,::{20d04fe0-3aea-1069-a2d8-08002b30309d}",
TRUE,
PIDL_IS_PATH, 0x00000208,
NULL,
L"::{20d04fe0-3aea-1069-a2d8-08002b30309d}" },
286 { __LINE__,
L"::{645ff040-5081-101b-9f08-00aa002f954e}",
TRUE,
PIDL_IS_PATH, 0x00000200,
NULL,
L"::{645ff040-5081-101b-9f08-00aa002f954e}" },
287 { __LINE__,
L"/select,::{450d8fba-ad25-11d0-98a8-0800361b1103}",
TRUE,
PIDL_IS_PATH, 0x00000240,
NULL,
L"::{450d8fba-ad25-11d0-98a8-0800361b1103}" },
301 { __LINE__,
L"c:\\Program Files/",
TRUE,
PIDL_IS_NULL, 0x02000000,
L"c:\\Program Files/"},
302 { __LINE__,
L"c:/Program Files/",
TRUE,
PIDL_IS_NULL, 0x02000000,
L"c:/Program Files/"},
310 { __LINE__,
L"\"c:\\\"\"program files\"",
TRUE,
PIDL_IS_NULL, 0x02000000,
L"c:\\\"program files"},
312 { __LINE__,
L"\"c:\\ \"program files",
TRUE,
PIDL_IS_NULL, 0x02000000,
L"c:\\ program files"},
313 { __LINE__,
L"\"c:\\\" program files",
TRUE,
PIDL_IS_NULL, 0x02000000,
L"c:\\ program files"},
314 { __LINE__,
L"\"c:\\\", \"c:\\program files\"",
TRUE,
PIDL_IS_PATH, 0x00000200,
NULL,
L"C:\\Program Files" },
328 { __LINE__,
L"/root,c:\\,c:\\Program Files",
TRUE,
PIDL_IS_PATH, 0x00000200,
NULL,
L"C:\\Program Files" },
329 { __LINE__,
L"/root,c:\\,Program Files",
TRUE,
PIDL_IS_NULL, 0x02000000,
L"Program Files"},
342 { __LINE__,
L"/select,c:\\Program Files,c:\\Documents and settings",
TRUE,
PIDL_IS_PATH, 0x00000240,
NULL,
L"C:\\Documents and Settings" },
360 { __LINE__,
L"/select," TEST_FILENAMEW L",/root,c:\\",
TRUE,
PIDL_PATH_EQUALS_PATH, 0x02000040,
TEST_FILENAMEW,
L"c:\\" },
361 { __LINE__,
L"/root,c:\\,/select," TEST_PATHW,
TRUE,
PIDL_IS_PATH, 0x00000240,
NULL,
TEST_PATHW },
362 { __LINE__,
L"/select," TEST_PATHW L",/root,c:\\",
TRUE,
PIDL_PATH_EQUALS_PATH, 0x00000240,
NULL,
L"c:\\" },
363 { __LINE__,
L"/e,/select," TEST_FILENAMEW L",/root,c:\\",
TRUE,
PIDL_PATH_EQUALS_PATH, 0x02000048,
TEST_FILENAMEW,
L"c:\\" },
364 { __LINE__,
L"/e,/root,c:\\,/select," TEST_FILENAMEW,
TRUE,
PIDL_IS_NULL, 0x02000048,
TEST_FILENAMEW },
369 { __LINE__,
L"http:\\\\www.reactos.org",
TRUE,
PIDL_IS_NULL, 0x02000000,
L"http:\\\\www.reactos.org"},
370 { __LINE__,
L"/e,http:\\\\www.reactos.org",
TRUE,
PIDL_IS_NULL, 0x02000008,
L"http:\\\\www.reactos.org"},
371 { __LINE__,
L"/root,c:\\,http:\\\\www.reactos.org",
TRUE,
PIDL_IS_NULL, 0x02000000,
L"http:\\\\www.reactos.org"},
373 { __LINE__,
L"/separate,c:\\ program files",
TRUE,
PIDL_IS_NULL, 0x02020000,
L"c:\\ program files"},
374 { __LINE__,
L"/separate, c:\\program files",
TRUE,
PIDL_IS_PATH, 0x00020200,
NULL,
L"C:\\Program Files" },
375 { __LINE__,
L"/separate, c:\\program files ,/e",
TRUE,
PIDL_IS_PATH, 0x00020208,
NULL,
L"C:\\Program Files" },
376 { __LINE__,
L"/separate, c:\\program files ,\\e",
TRUE,
PIDL_IS_NULL, 0x02020200,
L"\\e"},
377 { __LINE__,
L"c:\\Documents and settings,/separate,/n,/e,/root,c:\\,/select,c:\\Program files,",
TRUE,
CSIDL_DRIVES, 0x00024249 },
378 { __LINE__,
L"c:\\Documents and settings,/separate,/n,/e,/root,{450D8FBA-AD25-11D0-98A8-0800361B1103, 0},test,/select,c:\\Program files,",
TRUE,
CSIDL_DRIVES, 0x02024249,
L"test" },
379 { __LINE__,
L"c:\\Documents and settings,/inproc,/noui,/s,/separate,/n,/e,/root,{450D8FBA-AD25-11D0-98A8-0800361B1103, 0},test,/select,c:\\Program files,",
FALSE,
PIDL_PATH_EQUALS_PATH, 0x00000200,
NULL,
L"C:\\Documents and Settings" },
387 { __LINE__,
L"/root=\"\"c:\\Program files\"\"",
TRUE,
PIDL_IS_PATH, 0x00000200,
NULL,
L"C:\\Program Files" },
393 { __LINE__,
L"c:\\=/select=c:\\windows\\system32",
TRUE,
PIDL_IS_PATH, 0x00000240,
NULL,
L"C:\\WINDOWS\\system32" },
394 { __LINE__,
L"/select=c:\\windows\\system32",
TRUE,
PIDL_IS_PATH, 0x00000200,
NULL,
L"C:\\WINDOWS\\system32" },
395 { __LINE__,
L"=/select=c:\\windows\\system32",
TRUE,
PIDL_IS_PATH, 0x00000240,
NULL,
L"C:\\WINDOWS\\system32" },
412 { __LINE__,
L"=,=,=,\"=a=a=\",=,=,=",
TRUE,
CSIDL_DRIVES, 0x02000200,
L"=a=a=" },
431 const int TestCount =
sizeof(
Tests) /
sizeof(
Tests[0]);
433 WCHAR OriginalCommandLine[1024];
443 skip(
"SHExplorerParseCmdLine not found, as on NT6+\n");
448 StringCbCopyW(OriginalCommandLine,
sizeof(OriginalCommandLine), CommandLine);
456 for (
i = 0;
i < TestCount;
i++)
460 wcscpy(CommandLine,
L"browseui_apitest.exe ");
462 trace(
"Command line (%d): %ls\n",
Tests[
i].TestLine, CommandLine);
467 Tests[
i].ExpectedFileName,
472 if (cWrite > maxWrite)
476 trace(
"Writes reached the byte right before 0x%08x\n", maxWrite);
478 wcscpy(CommandLine, OriginalCommandLine);
static SHExplorerParseCmdLine_Type pSHExplorerParseCmdLine
UINT_PTR(WINAPI * SHExplorerParseCmdLine_Type)(PEXPLORER_CMDLINE_PARSE_RESULTS)
static DWORD ReplaceSubstr(_Out_ PWCHAR OutputStr, _In_ DWORD OutputLen, _In_ PCWSTR InputStr, _In_ PCWSTR ReplaceStr, _In_ PCWSTR ReplaceWith)
#define PIDL_PATH_EQUALS_PATH
static VOID TestCommandLine(_In_ ULONG TestLine, _In_ UINT_PTR ExpectedRet, _In_ INT ExpectedCsidl, _In_ DWORD ExpectedFlags, _In_ PCWSTR ExpectedFileName, _In_ PCWSTR PidlPath, _In_ PCWSTR pclsid, _Out_opt_ PUINT PWriteEnd)
#define PIDL_IS_UNTOUCHED
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
struct ExplorerCommandLineParseResults * PEXPLORER_CMDLINE_PARSE_RESULTS
#define GetCurrentDirectoryW(x, y)
#define GetProcAddress(x, y)
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
LPWSTR WINAPI GetCommandLineW(VOID)
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
#define FillMemory(BUF, SIZ, MASK)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
HLOCAL NTAPI LocalFree(HLOCAL hMem)
VOID WINAPI CoTaskMemFree(LPVOID ptr)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
UCHAR ab[sizeof("Hello World!") -1]
#define eq(received, expected, label, type)
unsigned __int3264 UINT_PTR
UINT_PTR WINAPI SHExplorerParseCmdLine(_Out_ PEXPLORER_CMDLINE_PARSE_RESULTS pInfo)
void WINAPI ILFree(LPITEMIDLIST pidl)
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define CSIDL_MYDOCUMENTS
PIDLIST_ABSOLUTE WINAPI SHSimpleIDListFromPath(PCWSTR)
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
STRSAFEAPI StringCchCatNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToAppend)
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
#define STRSAFE_E_INSUFFICIENT_BUFFER
#define FIELD_OFFSET(t, f)
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
#define MAKEINTRESOURCEA(i)