1 /* 2 * PROJECT: ReactOS api tests 3 * LICENSE: GPLv2+ - See COPYING in the top level directory 4 * PURPOSE: Test for SHExplorerParseCmdLine 5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org 6 */ 7 8 #include <apitest.h> 9 10 //#define UNICODE 11 #include <strsafe.h> 12 #include <shlobj.h> 13 14 // Macro parameters are only expanded in the second nesting... 15 #define _WIDEN(x) L##x 16 #define WIDEN(x) _WIDEN(x) 17 18 #define TEST_FILENAMEA "SHExplorerParseCmdLine.test" 19 #define TEST_FILENAMEW WIDEN(TEST_FILENAMEA) 20 21 #define TEST_PATHA "C:\\SHExplorerParseCmdLine.test" 22 #define TEST_PATHW WIDEN(TEST_PATHA) 23 24 #define PADDING_SIZE 0x100 25 26 typedef struct _EXPLORER_INFO 27 { 28 PWSTR FileName; 29 PIDLIST_ABSOLUTE pidl; 30 DWORD dwFlags; 31 ULONG Unknown1[5]; 32 PIDLIST_ABSOLUTE pidlRoot; 33 ULONG Unknown3[4]; 34 GUID guidInproc; 35 ULONG Padding[PADDING_SIZE]; 36 } EXPLORER_INFO, *PEXPLORER_INFO; 37 38 UINT (WINAPI *SHExplorerParseCmdLine)(_Out_ PEXPLORER_INFO Info); 39 40 #define PIDL_IS_UNTOUCHED -1 41 #define PIDL_IS_NULL -2 42 #define PIDL_IS_PATH -3 43 #define PIDL_IS_EMPTY -4 44 #define PIDL_PATH_EQUALS_PATH -5 45 46 #define InvalidPointer ((PVOID)0x5555555555555555ULL) 47 48 static 49 VOID 50 TestCommandLine( 51 _In_ INT ExpectedRet, 52 _In_ INT ExpectedCsidl, 53 _In_ DWORD ExpectedFlags, 54 _In_ PCWSTR ExpectedFileName, 55 _In_ PCWSTR PidlPath, 56 _Out_opt_ PUINT PWriteEnd) 57 { 58 EXPLORER_INFO Info; 59 UINT Ret; 60 ULONG i; 61 PDWORD InfoWords = (PDWORD) &Info; 62 63 FillMemory(&Info, sizeof(Info), 0x55); 64 Info.dwFlags = 0x00000000; 65 Ret = SHExplorerParseCmdLine(&Info); 66 67 // Special case for empty cmdline: Ret is the PIDL for the selected folder. 68 if (ExpectedRet == -1) 69 ok((LPITEMIDLIST) Ret == Info.pidl, "Ret = %x, expected %p\n", Ret, Info.pidl); 70 else 71 ok(Ret == ExpectedRet, "Ret = %x, expected %p\n", Ret, (PVOID) ExpectedRet); 72 73 if (ExpectedFileName == NULL) 74 ok(Info.FileName == InvalidPointer, "FileName = %p\n", Info.FileName); 75 else 76 { 77 ok(Info.FileName != NULL && Info.FileName != InvalidPointer, "FileName = %p\n", Info.FileName); 78 if (Info.FileName != NULL && Info.FileName != InvalidPointer) 79 { 80 ok(!wcscmp(Info.FileName, ExpectedFileName), "FileName = %ls, expected %ls\n", Info.FileName, ExpectedFileName); 81 LocalFree(Info.FileName); 82 } 83 } 84 85 ok(Info.dwFlags == ExpectedFlags, "dwFlags = %08lx, expected %08lx\n", Info.dwFlags, ExpectedFlags); 86 87 if (ExpectedCsidl == PIDL_IS_UNTOUCHED) 88 ok(Info.pidl == InvalidPointer, "pidl = %p\n", Info.pidl); 89 else if (ExpectedCsidl == PIDL_IS_NULL) 90 ok(Info.pidl == NULL, "pidl = %p\n", Info.pidl); 91 else 92 { 93 PIDLIST_ABSOLUTE ExpectedPidl; 94 HRESULT hr; 95 96 ok(Info.pidl != NULL, "pidl = %p\n", Info.pidl); 97 if (Info.pidl != NULL && Info.pidl != InvalidPointer) 98 { 99 WCHAR pidlPathName[MAX_PATH] = L""; 100 101 if (Info.pidl != NULL && Info.pidl != (LPITEMIDLIST) 0x55555555) 102 { 103 SHGetPathFromIDListW(Info.pidl, pidlPathName); 104 } 105 106 if (ExpectedCsidl == PIDL_PATH_EQUALS_PATH) 107 { 108 ok(wcsicmp(pidlPathName, PidlPath) == 0, "Path from pidl does not match; pidlPathName=%S\n", pidlPathName); 109 } 110 else if (ExpectedCsidl == PIDL_IS_EMPTY) 111 { 112 ok(wcslen(pidlPathName) == 0, "Unexpected non-empty path from pidl; pidlPathName=%S\n", pidlPathName); 113 } 114 else 115 { 116 if (ExpectedCsidl == PIDL_IS_PATH) 117 { 118 ExpectedPidl = SHSimpleIDListFromPath(PidlPath); 119 hr = ExpectedPidl == NULL ? E_FAIL : S_OK; 120 ok(ExpectedPidl != NULL, "SHSimpleIDListFromPath(%S) failed. pidlPathName=%S\n", PidlPath, pidlPathName); 121 if (SUCCEEDED(hr)) 122 { 123 ok(ILIsEqual(Info.pidl, ExpectedPidl), "Unexpected pidl value %p; pidlPathName=%S PidlPath=%S\n", Info.pidl, pidlPathName, PidlPath); 124 ILFree(ExpectedPidl); 125 } 126 } 127 else 128 { 129 hr = SHGetFolderLocation(NULL, ExpectedCsidl, NULL, 0, &ExpectedPidl); 130 ok(hr == S_OK, "SHGetFolderLocation returned %08lx\n", hr); 131 if (SUCCEEDED(hr)) 132 { 133 BOOL eq = ILIsEqual(Info.pidl, ExpectedPidl); 134 ILFree(ExpectedPidl); 135 136 ok(eq, "Unexpected pidl value %p; pidlPathName=%S CSIDL=%d\n", Info.pidl, pidlPathName, ExpectedCsidl); 137 } 138 } 139 } 140 141 if (Info.pidl != NULL && Info.pidl != (LPITEMIDLIST) 0x55555555) 142 ILFree(Info.pidl); 143 } 144 } 145 146 for (i = 0; i < sizeof(Info) / sizeof(DWORD); i++) 147 { 148 switch (i*4) 149 { 150 case 0x00: // FileName 151 case 0x04: // pidl 152 case 0x08: // dwFlags 153 case 0x20: // pidlRoot 154 case 0x34: // guidInproc (1/4) 155 case 0x38: // guidInproc (2/4) 156 case 0x3C: // guidInproc (3/4) 157 case 0x40: // guidInproc (4/4) 158 break; 159 default: 160 ok(InfoWords[i] == 0x55555555, "Word 0x%02lx has been set to 0x%08lx\n", i * 4, InfoWords[i]); 161 } 162 } 163 164 if (PWriteEnd) 165 { 166 PBYTE data = (PBYTE)&Info; 167 168 *PWriteEnd = 0; 169 170 for (i = sizeof(Info); i > 0; i--) 171 { 172 if (data[i - 1] != 0x55) 173 { 174 *PWriteEnd = i; 175 break; 176 } 177 } 178 } 179 } 180 181 START_TEST(SHExplorerParseCmdLine) 182 { 183 static struct 184 { 185 INT TestLine; 186 PCWSTR CommandLine; 187 INT ExpectedRet; 188 INT ExpectedCsidl; 189 DWORD ExpectedFlags; 190 PCWSTR ExpectedFileName; 191 PCWSTR PidlPath; 192 } Tests [] = 193 { 194 { __LINE__, L"", -1, CSIDL_MYDOCUMENTS, 0x00000009 }, 195 { __LINE__, L"/e", TRUE, PIDL_IS_UNTOUCHED, 0x00000008 }, 196 { __LINE__, L"/n", TRUE, PIDL_IS_UNTOUCHED, 0x00004001 }, 197 { __LINE__, L"/x", TRUE, PIDL_IS_NULL, 0x02000000, L"/x" }, 198 { __LINE__, L"-e", TRUE, PIDL_IS_NULL, 0x02000000, L"-e" }, 199 { __LINE__, L"C:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" }, 200 { __LINE__, L"/e,C:\\", TRUE, PIDL_IS_PATH, 0x00000208, NULL, L"C:\\" }, 201 { __LINE__, L"/select,C:\\", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" }, 202 { __LINE__, L"/e,::{20d04fe0-3aea-1069-a2d8-08002b30309d}", TRUE, PIDL_IS_PATH, 0x00000208, NULL, L"::{20d04fe0-3aea-1069-a2d8-08002b30309d}" }, 203 { __LINE__, L"::{645ff040-5081-101b-9f08-00aa002f954e}", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"::{645ff040-5081-101b-9f08-00aa002f954e}" }, 204 { __LINE__, L"/select,::{450d8fba-ad25-11d0-98a8-0800361b1103}", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"::{450d8fba-ad25-11d0-98a8-0800361b1103}" }, 205 { __LINE__, L"=", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"::{20d04fe0-3aea-1069-a2d8-08002b30309d}" }, 206 { __LINE__, L".", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Documents and Settings\\gigaherz\\Desktop" }, 207 { __LINE__, L"..", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Documents and Settings\\gigaherz" }, 208 { __LINE__, L"wrongpath", TRUE, PIDL_IS_NULL, 0x02000000, L"wrongpath"}, 209 { __LINE__, L"%wrongdir%", TRUE, PIDL_IS_NULL, 0x02000000, L"%wrongdir%"}, 210 { __LINE__, L"%programfiles#", TRUE, PIDL_IS_NULL, 0x02000000, L"%programfiles#"}, 211 { __LINE__, L",", TRUE, PIDL_IS_EMPTY, 0x00000200}, 212 { __LINE__, L"c:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" }, 213 { __LINE__, L"c:", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" }, 214 { __LINE__, L"c", TRUE, PIDL_IS_NULL, 0x02000000, L"c"}, 215 { __LINE__, L"c:\\Program Files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" }, 216 { __LINE__, L"c:\\Program Files\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" }, 217 { __LINE__, L"c:\\Program Files/", TRUE, PIDL_IS_NULL, 0x02000000, L"c:\\Program Files/"}, 218 { __LINE__, L"c:/Program Files/", TRUE, PIDL_IS_NULL, 0x02000000, L"c:/Program Files/"}, 219 { __LINE__, L"fonts", TRUE, PIDL_IS_NULL, 0x02000000, L"fonts" }, 220 { __LINE__, L"winsxs", TRUE, PIDL_IS_NULL, 0x02000000, L"winsxs" }, 221 { __LINE__, L"system32", TRUE, PIDL_IS_NULL, 0x02000000, L"system32" }, 222 { __LINE__, TEST_PATHW, TRUE, PIDL_IS_PATH, 0x00000200, NULL, TEST_PATHW }, 223 { __LINE__, L"\"c:\\\"\"program files\"", TRUE, PIDL_IS_NULL, 0x02000000, L"c:\\\"program files"}, 224 { __LINE__, L"\"c:\\\"program files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" }, 225 { __LINE__, L"\"c:\\ \"program files", TRUE, PIDL_IS_NULL, 0x02000000, L"c:\\ program files"}, 226 { __LINE__, L"\"c:\\\" program files", TRUE, PIDL_IS_NULL, 0x02000000, L"c:\\ program files"}, 227 { __LINE__, L"\"c:\\\", \"c:\\program files\"", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" }, 228 { __LINE__, L"c:\\,c:\\program files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" }, 229 { __LINE__, L"/root", 0, CSIDL_MYDOCUMENTS, 0x00000000}, 230 { __LINE__, L"\"/root\"", 0, CSIDL_MYDOCUMENTS, 0x00000000}, 231 { __LINE__, L"/root,", TRUE, CSIDL_MYDOCUMENTS, 0x00000000}, 232 { __LINE__, L"/root,c", TRUE, CSIDL_MYDOCUMENTS, 0x00000000}, 233 { __LINE__, L"/root,\"\"", TRUE, CSIDL_MYDOCUMENTS, 0x00000000}, 234 { __LINE__, L"/root,wrong", TRUE, CSIDL_MYDOCUMENTS, 0x00000000}, 235 { __LINE__, L"/root,0", TRUE, CSIDL_MYDOCUMENTS, 0x00000000}, 236 { __LINE__, L"/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"c:\\" }, 237 { __LINE__, L"/root,\"c:\\\"", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"c:\\" }, 238 { __LINE__, L"/root \"c:\\\"", TRUE, PIDL_IS_NULL, 0x02000000, L"/root c:\\"}, 239 { __LINE__, L"/root,\"c:\\\"\"program files\"", TRUE, PIDL_IS_PATH, 0x00000000}, 240 { __LINE__, L"/root,\"c:\\\"program files", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"c:\\Program Files" }, 241 { __LINE__, L"/root,c:\\,c:\\Program Files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" }, 242 { __LINE__, L"/root,c:\\,Program Files", TRUE, PIDL_IS_NULL, 0x02000000, L"Program Files"}, 243 { __LINE__, L"/root,\"c:\\\"", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"c:\\" }, 244 { __LINE__, L"c:\\Program Files,/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000200, NULL, L"c:\\" }, 245 { __LINE__, L"a:\\,/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000200, NULL, L"c:\\" }, 246 { __LINE__, L"a:\\,/root,c", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"A:\\" }, 247 { __LINE__, L"c:\\,/root,c", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" }, 248 { __LINE__, L"/select", TRUE, CSIDL_MYDOCUMENTS, 0x00000040}, 249 { __LINE__, L"/select,", TRUE, CSIDL_DRIVES, 0x00000240 }, 250 { __LINE__, L"/select,c", TRUE, PIDL_IS_NULL, 0x02000040, L"c"}, 251 { __LINE__, L"/select,0", TRUE, PIDL_IS_NULL, 0x02000040, L"0"}, 252 { __LINE__, L"/select,c:\\", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" }, 253 { __LINE__, L"c:\\,/select", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" }, 254 { __LINE__, L"/select," TEST_PATHW, TRUE, PIDL_IS_PATH, 0x00000240, NULL, TEST_PATHW }, 255 { __LINE__, L"/select,c:\\Program Files,c:\\Documents and settings", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\Documents and Settings" }, 256 { __LINE__, L"c:\\,/select," TEST_FILENAMEW, TRUE, PIDL_IS_NULL, 0x02000240, TEST_FILENAMEW }, 257 { __LINE__, L"c:\\,/select," TEST_PATHW, TRUE, PIDL_IS_PATH, 0x00000240, NULL, TEST_PATHW }, 258 { __LINE__, L"a:\\,/select," TEST_PATHW, TRUE, PIDL_IS_PATH, 0x00000240, NULL, TEST_PATHW }, 259 { __LINE__, L"z:\\,/select," TEST_PATHW, TRUE, PIDL_IS_PATH, 0x02000240, L"z:\\", TEST_PATHW }, 260 { __LINE__, L"select,c:\\ ", TRUE, PIDL_IS_PATH, 0x02000200, L"select", L"C:\\" }, 261 { __LINE__, L"/select c:\\ ", TRUE, PIDL_IS_NULL, 0x02000000, L"/select c:\\"}, 262 { __LINE__, L"a:\\,/select,c:\\", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" }, 263 { __LINE__, L"a:\\,/select,c", TRUE, PIDL_IS_NULL, 0x02000240, L"c"}, 264 { __LINE__, L"c:\\,/select,c", TRUE, PIDL_IS_NULL, 0x02000240, L"c"}, 265 { __LINE__, L"/e", TRUE, CSIDL_MYDOCUMENTS, 0x00000008}, 266 { __LINE__, L"/e,", TRUE, CSIDL_DRIVES, 0x00000208 }, 267 { __LINE__, L"/e,\"", TRUE, CSIDL_DRIVES, 0x00000208 }, 268 { __LINE__, L"/e,\"\"", TRUE, CSIDL_DRIVES, 0x00000208 }, 269 { __LINE__, L"/e,c:\\", TRUE, PIDL_IS_PATH, 0x00000208, NULL, L"C:\\" }, 270 { __LINE__, L"c:\\,/e", TRUE, PIDL_IS_PATH, 0x00000208, NULL, L"C:\\" }, 271 { __LINE__, L"/e,c", TRUE, PIDL_IS_NULL, 0x02000008, L"c"}, 272 { __LINE__, L"/root,c:\\,/select," TEST_FILENAMEW, TRUE, PIDL_IS_NULL, 0x02000040, TEST_FILENAMEW }, 273 { __LINE__, L"/select," TEST_FILENAMEW L",/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x02000040, TEST_FILENAMEW, L"c:\\" }, 274 { __LINE__, L"/root,c:\\,/select," TEST_PATHW, TRUE, PIDL_IS_PATH, 0x00000240, NULL, TEST_PATHW }, 275 { __LINE__, L"/select," TEST_PATHW L",/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000240, NULL, L"c:\\" }, 276 { __LINE__, L"/e,/select," TEST_FILENAMEW L",/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x02000048, TEST_FILENAMEW, L"c:\\" }, 277 { __LINE__, L"/e,/root,c:\\,/select," TEST_FILENAMEW, TRUE, PIDL_IS_NULL, 0x02000048, TEST_FILENAMEW }, 278 { __LINE__, L"/e,/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000008, NULL, L"c:\\" }, 279 { __LINE__, L"/e,c:\\,/select," TEST_FILENAMEW, TRUE, PIDL_IS_NULL, 0x02000248, TEST_FILENAMEW }, 280 { __LINE__, L"c:\\,/e,/select," TEST_FILENAMEW, TRUE, PIDL_IS_NULL, 0x02000248, TEST_FILENAMEW }, 281 { __LINE__, L"c:\\,/select," TEST_FILENAMEW L",/e", TRUE, PIDL_IS_NULL, 0x02000248, TEST_FILENAMEW }, 282 { __LINE__, L"http:\\\\www.reactos.org", TRUE, PIDL_IS_NULL, 0x02000000, L"http:\\\\www.reactos.org"}, 283 { __LINE__, L"/e,http:\\\\www.reactos.org", TRUE, PIDL_IS_NULL, 0x02000008, L"http:\\\\www.reactos.org"}, 284 { __LINE__, L"/root,c:\\,http:\\\\www.reactos.org", TRUE, PIDL_IS_NULL, 0x02000000, L"http:\\\\www.reactos.org"}, 285 { __LINE__, L"/separate ", TRUE, CSIDL_MYDOCUMENTS, 0x00020000}, 286 { __LINE__, L"/separate,c:\\ program files", TRUE, PIDL_IS_NULL, 0x02020000, L"c:\\ program files"}, 287 { __LINE__, L"/separate, c:\\program files", TRUE, PIDL_IS_PATH, 0x00020200, NULL, L"C:\\Program Files" }, 288 { __LINE__, L"/separate, c:\\program files ,/e", TRUE, PIDL_IS_PATH, 0x00020208, NULL, L"C:\\Program Files" }, 289 { __LINE__, L"/separate, c:\\program files ,\\e", TRUE, PIDL_IS_NULL, 0x02020200, L"\\e"}, 290 { __LINE__, L"c:\\Documents and settings,/separate,/n,/e,/root,c:\\,/select,c:\\Program files,", TRUE, CSIDL_DRIVES, 0x00024249 }, 291 { __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" }, 292 { __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" }, 293 { __LINE__, L"=", TRUE, CSIDL_DRIVES, 0x00000200 }, 294 { __LINE__, L"=c:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" }, 295 { __LINE__, L"=" TEST_PATHW, TRUE, PIDL_IS_PATH, 0x00000200, NULL, TEST_PATHW }, 296 { __LINE__, L"/root,=", TRUE, CSIDL_DRIVES, 0x00000200 }, 297 { __LINE__, L"/root=c:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" }, 298 { __LINE__, L"/root=c:\\Program files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" }, 299 { __LINE__, L"/root=\"c:\\Program files\"", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" }, 300 { __LINE__, L"/root=\"\"c:\\Program files\"\"", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" }, 301 { __LINE__, L"c:\\=/root=\"c:\\Program files\"", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"C:\\Program Files" }, 302 { __LINE__, L"/select=c:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" }, 303 { __LINE__, L"/select=c:\\Program files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" }, 304 { __LINE__, L"=,/select,c:\\", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" }, 305 { __LINE__, L"/select,c:\\,=", TRUE, CSIDL_DRIVES, 0x00000240 }, 306 { __LINE__, L"c:\\=/select=c:\\windows\\system32", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\WINDOWS\\system32" }, 307 { __LINE__, L"/select=c:\\windows\\system32", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\WINDOWS\\system32" }, 308 { __LINE__, L"=/select=c:\\windows\\system32", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\WINDOWS\\system32" }, 309 { __LINE__, L"/e,=", TRUE, CSIDL_DRIVES, 0x00000208 }, 310 { __LINE__, L"/e=", TRUE, CSIDL_DRIVES, 0x00000200 }, 311 { __LINE__, L"/e=\"", TRUE, CSIDL_DRIVES, 0x00000200 }, 312 { __LINE__, L"/e=\"\"", TRUE, CSIDL_DRIVES, 0x00000200 }, 313 { __LINE__, L"=\"=\"", TRUE, PIDL_IS_NULL, 0x02000000, L"="}, 314 { __LINE__, L"==\"=\"", TRUE, PIDL_IS_NULL, 0x02000200, L"="}, 315 { __LINE__, L"===\"=\"", TRUE, PIDL_IS_NULL, 0x02000200, L"="}, 316 { __LINE__, L"=\"=\"", TRUE, PIDL_IS_NULL, 0x02000000, L"="}, 317 { __LINE__, L"==\"==\"", TRUE, PIDL_IS_NULL, 0x02000200, L"=="}, 318 { __LINE__, L"===\"===\"", TRUE, PIDL_IS_NULL, 0x02000200, L"==="}, 319 { __LINE__, L"=\"=a\"", TRUE, PIDL_IS_NULL, 0x02000000, L"=a"}, 320 { __LINE__, L"==\"=a=\"", TRUE, PIDL_IS_NULL, 0x02000200, L"=a="}, 321 { __LINE__, L"===\"=a=a=\"", TRUE, PIDL_IS_NULL, 0x02000200, L"=a=a="}, 322 { __LINE__, L"=\"=a\"==", TRUE, CSIDL_DRIVES, 0x02000200, L"=a" }, 323 { __LINE__, L"==\"=a=\"=", TRUE, CSIDL_DRIVES, 0x02000200, L"=a=" }, 324 { __LINE__, L"===\"=a=a=\"===", TRUE, CSIDL_DRIVES, 0x02000200, L"=a=a=" }, 325 { __LINE__, L"=,=,=,\"=a=a=\",=,=,=", TRUE, CSIDL_DRIVES, 0x02000200, L"=a=a=" }, 326 { __LINE__, L"\"", TRUE, CSIDL_DRIVES, 0x00000200 }, 327 { __LINE__, L"\"\"", TRUE, CSIDL_DRIVES, 0x00000200 }, 328 { __LINE__, L"\"\"\"", TRUE, PIDL_IS_NULL, 0x02000000, L"\""}, 329 { __LINE__, L"\"\"\"\"", TRUE, PIDL_IS_NULL, 0x02000000, L"\""}, 330 { __LINE__, L"\"\"\"\"\"", TRUE, PIDL_IS_NULL, 0x02000000, L"\"\""}, 331 { __LINE__, L"/s", TRUE, CSIDL_MYDOCUMENTS, 0x00000002}, 332 { __LINE__, L"/noui", TRUE, CSIDL_MYDOCUMENTS, 0x00001000}, 333 { __LINE__, L"/idlist", TRUE, PIDL_IS_UNTOUCHED, 0x00000000}, 334 { __LINE__, L"-embedding", TRUE, CSIDL_MYDOCUMENTS, 0x00000080 }, 335 { __LINE__, L"/inproc", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 }, 336 { __LINE__, L"/inproc,1", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 }, 337 { __LINE__, L"/inproc,a", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 }, 338 { __LINE__, L"/inproc,c:\\", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 }, 339 { __LINE__, L"/inproc,\"c:\\\"", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 }, 340 { __LINE__, L"/inproc,{20d04fe0-3aea-1069-a2d8-08002b30309d}", TRUE, PIDL_IS_UNTOUCHED, 0x00000400 }, 341 }; 342 const int TestCount = sizeof(Tests) / sizeof(Tests[0]); 343 PWSTR CommandLine; 344 WCHAR OriginalCommandLine[1024]; 345 int i; 346 UINT maxWrite = 0; 347 FILE * ff; 348 349 HMODULE browseui = LoadLibraryA("browseui.dll"); 350 SHExplorerParseCmdLine = (UINT (__stdcall *)(PEXPLORER_INFO))GetProcAddress(browseui, MAKEINTRESOURCEA(107)); 351 if (!SHExplorerParseCmdLine) 352 { 353 skip("SHExplorerParseCmdLine not found, NT 6.0?\n"); 354 return; 355 } 356 357 CommandLine = GetCommandLineW(); 358 StringCbCopyW(OriginalCommandLine, sizeof(OriginalCommandLine), CommandLine); 359 360 ff = fopen(TEST_PATHA, "wb"); 361 fclose(ff); 362 363 for (i = 0; i < TestCount; i++) 364 { 365 UINT cWrite; 366 367 wcscpy(CommandLine, L"browseui_apitest.exe "); 368 wcscat(CommandLine, Tests[i].CommandLine); 369 trace("Command line (%d): %ls\n", Tests[i].TestLine, CommandLine); 370 TestCommandLine(Tests[i].ExpectedRet, 371 Tests[i].ExpectedCsidl, 372 Tests[i].ExpectedFlags, 373 Tests[i].ExpectedFileName, 374 Tests[i].PidlPath, 375 &cWrite); 376 377 if (cWrite > maxWrite) 378 maxWrite = cWrite; 379 } 380 381 trace("Writes reached the byte right before 0x%08x\n", maxWrite); 382 383 wcscpy(CommandLine, OriginalCommandLine); 384 385 remove(TEST_PATHA); 386 } 387