ReactOS  0.4.15-dev-1200-gc3b3fcd
SHExplorerParseCmdLine.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: GPLv2+ - See COPYING in the top level directory
4  * PURPOSE: Test for SHExplorerParseCmdLine
5  * PROGRAMMERS: Thomas Faber <thomas.faber@reactos.org>
6  * Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
7  */
8 
9 #include <apitest.h>
10 
11 //#define UNICODE
12 #include <strsafe.h>
13 #include <shlobj.h>
14 
15 // Macro parameters are only expanded in the second nesting...
16 #define _WIDEN(x) L##x
17 #define WIDEN(x) _WIDEN(x)
18 
19 #define TEST_FILENAMEA "SHExplorerParseCmdLine.test"
20 #define TEST_FILENAMEW WIDEN(TEST_FILENAMEA)
21 
22 #define TEST_PATHA "C:\\SHExplorerParseCmdLine.test"
23 #define TEST_PATHW WIDEN(TEST_PATHA)
24 
25 #define PADDING_SIZE 0x100
26 
27 typedef struct _EXPLORER_INFO
28 {
38 
40 
41 #define PIDL_IS_UNTOUCHED -1
42 #define PIDL_IS_NULL -2
43 #define PIDL_IS_PATH -3
44 #define PIDL_IS_EMPTY -4
45 #define PIDL_PATH_EQUALS_PATH -5
46 
47 #define InvalidPointer ((PVOID)0x5555555555555555ULL)
48 
50 _Out_ PWCHAR OutputStr,
51 _In_ DWORD OutputLen,
52 _In_ PCWSTR InputStr,
53 _In_ PCWSTR ReplaceStr,
54 _In_ PCWSTR ReplaceWith)
55 {
56  DWORD result = 0;
57  PCWSTR pos;
58  PCWSTR pwc;
59 
60  if (!OutputLen)
61  return result;
62 
63  OutputStr[0] = 0;
64  pos = InputStr;
65  pwc = wcsstr(pos, ReplaceStr);
66  while (pwc)
67  {
68  if (StringCchCatNW(OutputStr, OutputLen, pos, pwc - pos) == STRSAFE_E_INSUFFICIENT_BUFFER)
69  break;
70  if (StringCchCatW(OutputStr, OutputLen, ReplaceWith) == STRSAFE_E_INSUFFICIENT_BUFFER)
71  break;
72  result++;
73  pos = pwc + wcslen(ReplaceStr);
74  pwc = wcsstr(pos, ReplaceStr);
75  }
76  StringCchCatW(OutputStr, OutputLen, pos);
77  return result;
78 }
79 
80 static
81 VOID
83 _In_ ULONG TestLine,
84 _In_ INT ExpectedRet,
85 _In_ INT ExpectedCsidl,
86 _In_ DWORD ExpectedFlags,
87 _In_ PCWSTR ExpectedFileName,
88 _In_ PCWSTR PidlPath,
89 _In_ PCWSTR pclsid,
90 _Out_opt_ PUINT PWriteEnd)
91 {
93  UINT_PTR Ret;
94  ULONG i;
95  PDWORD InfoWords = (PDWORD) &Info;
96 
97  FillMemory(&Info, sizeof(Info), 0x55);
98  Info.dwFlags = 0x00000000;
100 
101  // Special case for empty cmdline: Ret is the PIDL for the selected folder.
102  if (ExpectedRet == -1)
103  ok((LPITEMIDLIST) Ret == Info.pidl, "Line %lu: Ret = %x, expected %p\n", TestLine, Ret, Info.pidl);
104  else
105  ok(Ret == ExpectedRet, "Line %lu: Ret = %x, expected %08x\n", TestLine, Ret, ExpectedRet);
106 
107  if (ExpectedFileName == NULL)
108  ok(Info.FileName == InvalidPointer, "Line %lu: FileName = %p\n", TestLine, Info.FileName);
109  else
110  {
111  ok(Info.FileName != NULL && Info.FileName != InvalidPointer, "Line %lu: FileName = %p\n", TestLine, Info.FileName);
112  if (Info.FileName != NULL && Info.FileName != InvalidPointer)
113  {
114  ok(!wcscmp(Info.FileName, ExpectedFileName), "Line %lu: FileName = %ls, expected %ls\n", TestLine, Info.FileName, ExpectedFileName);
115  LocalFree(Info.FileName);
116  }
117  }
118 
119  ok(Info.dwFlags == ExpectedFlags, "Line %lu: dwFlags = %08lx, expected %08lx\n", TestLine, Info.dwFlags, ExpectedFlags);
120 
121  if (ExpectedCsidl == PIDL_IS_UNTOUCHED)
122  ok(Info.pidl == InvalidPointer, "Line %lu: pidl = %p\n", TestLine, Info.pidl);
123  else if (ExpectedCsidl == PIDL_IS_NULL)
124  ok(Info.pidl == NULL, "Line %lu: pidl = %p\n", TestLine, Info.pidl);
125  else
126  {
127  PIDLIST_ABSOLUTE ExpectedPidl;
128  HRESULT hr;
129 
130  ok(Info.pidl != NULL, "Line %lu: pidl = %p\n", TestLine, Info.pidl);
131  if (Info.pidl != NULL && Info.pidl != InvalidPointer)
132  {
133  WCHAR pidlPathName[MAX_PATH] = L"";
134  WCHAR pidlPathTest[MAX_PATH] = L"";
135  WCHAR rootDir[MAX_PATH] = L"";
136  WCHAR curDir[MAX_PATH] = L"";
137  WCHAR replaceName[MAX_PATH];
138 
139  GetFullPathNameW(L"\\", _countof(rootDir), rootDir, NULL);
140 
141  GetCurrentDirectoryW(_countof(curDir), curDir);
142  if (wcslen(curDir) != 0 && curDir[wcslen(curDir) - 1] != L'\\')
143  StringCchCatW(curDir, _countof(curDir), L"\\");
144 
145  if (PidlPath)
146  {
147  StringCchCopyW(pidlPathTest, _countof(pidlPathTest), PidlPath);
148 
149  if (wcsstr(pidlPathTest, L"::ROOT::") != NULL && wcslen(rootDir) > 0)
150  {
151  if (ReplaceSubstr(replaceName, _countof(replaceName), pidlPathTest, L"::ROOT::", rootDir))
152  StringCchCopyW(pidlPathTest, _countof(pidlPathTest), replaceName);
153  }
154 
155  if (wcsstr(pidlPathTest, L"::CURDIR::") != NULL && wcslen(curDir) > 0)
156  {
157  if (ReplaceSubstr(replaceName, _countof(replaceName), pidlPathTest, L"::CURDIR::", curDir))
158  StringCchCopyW(pidlPathTest, _countof(pidlPathTest), replaceName);
159  }
160  }
161 
162  if (Info.pidl != NULL && Info.pidl != (LPITEMIDLIST) 0x55555555)
163  {
164  SHGetPathFromIDListW(Info.pidl, pidlPathName);
165  }
166 
167  if (ExpectedCsidl == PIDL_PATH_EQUALS_PATH)
168  {
169  ok(wcsicmp(pidlPathName, pidlPathTest) == 0, "Line %lu: Path from pidl does not match; pidlPathName=%S\n", TestLine, pidlPathName);
170  }
171  else if (ExpectedCsidl == PIDL_IS_EMPTY)
172  {
173  ok(wcslen(pidlPathName) == 0, "Line %lu: Unexpected non-empty path from pidl; pidlPathName=%S\n", TestLine, pidlPathName);
174  }
175  else
176  {
177  if (ExpectedCsidl == PIDL_IS_PATH)
178  {
179  ExpectedPidl = SHSimpleIDListFromPath(pidlPathTest);
180  hr = ExpectedPidl == NULL ? E_FAIL : S_OK;
181  ok(ExpectedPidl != NULL, "Line %lu: SHSimpleIDListFromPath(%S) failed. pidlPathName=%S\n", TestLine, pidlPathTest, pidlPathName);
182  if (SUCCEEDED(hr))
183  {
184  ok(ILIsEqual(Info.pidl, ExpectedPidl), "Line %lu: Unexpected pidl value %p; pidlPathName=%S pidlPathTest=%S\n", TestLine, Info.pidl, pidlPathName, pidlPathTest);
185  ILFree(ExpectedPidl);
186  }
187  }
188  else
189  {
190  hr = SHGetFolderLocation(NULL, ExpectedCsidl, NULL, 0, &ExpectedPidl);
191  ok(hr == S_OK, "Line %lu: SHGetFolderLocation returned %08lx\n", TestLine, hr);
192  if (SUCCEEDED(hr))
193  {
194  BOOL eq = ILIsEqual(Info.pidl, ExpectedPidl);
195  ILFree(ExpectedPidl);
196 
197  ok(eq, "Line %lu: Unexpected pidl value %p; pidlPathName=%S CSIDL=%d\n", TestLine, Info.pidl, pidlPathName, ExpectedCsidl);
198  }
199  }
200  }
201 
202  if (Info.pidl != NULL && Info.pidl != (LPITEMIDLIST) 0x55555555)
203  ILFree(Info.pidl);
204  }
205  }
206 
207  for (i = 0; i < sizeof(Info) / sizeof(DWORD); i++)
208  {
209  switch (i*4)
210  {
211  case 0x00: // FileName
212  case 0x04: // pidl
213  case 0x08: // dwFlags
214  case 0x20: // pidlRoot
215  case 0x34: // guidInproc (1/4)
216  case 0x38: // guidInproc (2/4)
217  case 0x3C: // guidInproc (3/4)
218  case 0x40: // guidInproc (4/4)
219  break;
220  default:
221  ok(InfoWords[i] == 0x55555555, "Line %lu: Word 0x%02lx has been set to 0x%08lx\n", TestLine, i * 4, InfoWords[i]);
222  }
223  }
224 
225  {
226  LPOLESTR psz;
227  BYTE ab[sizeof(CLSID)];
228 
229  StringFromCLSID(&Info.clsid, &psz);
230  if (pclsid == NULL)
231  {
232  FillMemory(ab, sizeof(ab), 0x55);
233  ok(memcmp(ab, &Info.clsid, sizeof(ab)) == 0, "Line %lu: CLSID was %ls.\n", TestLine, psz);
234  }
235  else
236  {
237  ok(lstrcmpiW(psz, pclsid) == 0, "Line %lu: CLSID was %ls.\n", TestLine, psz);
238  }
239  CoTaskMemFree(psz);
240  }
241 
242  if (PWriteEnd)
243  {
244  PBYTE data = (PBYTE)&Info;
245 
246  *PWriteEnd = 0;
247 
248  for (i = sizeof(Info); i > 0; i--)
249  {
250  if (data[i - 1] != 0x55)
251  {
252  *PWriteEnd = i;
253  break;
254  }
255  }
256  }
257 }
258 
260 {
261  static struct
262  {
263  INT TestLine;
264  PCWSTR CommandLine;
265  INT ExpectedRet;
266  INT ExpectedCsidl;
267  DWORD ExpectedFlags;
268  PCWSTR ExpectedFileName;
269  PCWSTR PidlPath;
270  PCWSTR pclsid;
271  } Tests [] =
272  {
273  { __LINE__, L"", -1, CSIDL_MYDOCUMENTS, 0x00000009 },
274  { __LINE__, L"/e", TRUE, PIDL_IS_UNTOUCHED, 0x00000008 },
275  { __LINE__, L"/n", TRUE, PIDL_IS_UNTOUCHED, 0x00004001 },
276  { __LINE__, L"/x", TRUE, PIDL_IS_NULL, 0x02000000, L"/x" },
277  { __LINE__, L"-e", TRUE, PIDL_IS_NULL, 0x02000000, L"-e" },
278  { __LINE__, L"C:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" },
279  { __LINE__, L"/e,C:\\", TRUE, PIDL_IS_PATH, 0x00000208, NULL, L"C:\\" },
280  { __LINE__, L"/select,C:\\", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" },
281  { __LINE__, L"/e,::{20d04fe0-3aea-1069-a2d8-08002b30309d}", TRUE, PIDL_IS_PATH, 0x00000208, NULL, L"::{20d04fe0-3aea-1069-a2d8-08002b30309d}" },
282  { __LINE__, L"::{645ff040-5081-101b-9f08-00aa002f954e}", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"::{645ff040-5081-101b-9f08-00aa002f954e}" },
283  { __LINE__, L"/select,::{450d8fba-ad25-11d0-98a8-0800361b1103}", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"::{450d8fba-ad25-11d0-98a8-0800361b1103}" },
284  { __LINE__, L"=", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"::{20d04fe0-3aea-1069-a2d8-08002b30309d}" },
285 // { __LINE__, L".", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Documents and Settings\\gigaherz\\Desktop" },
286 // { __LINE__, L"..", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Documents and Settings\\gigaherz" },
287  { __LINE__, L"wrongpath", TRUE, PIDL_IS_NULL, 0x02000000, L"wrongpath"},
288  { __LINE__, L"%wrongdir%", TRUE, PIDL_IS_NULL, 0x02000000, L"%wrongdir%"},
289  { __LINE__, L"%programfiles#", TRUE, PIDL_IS_NULL, 0x02000000, L"%programfiles#"},
290  { __LINE__, L",", TRUE, PIDL_IS_EMPTY, 0x00000200},
291  { __LINE__, L"\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"::ROOT::" }, // disk letter depends on current directory
292  { __LINE__, L"c:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" },
293  { __LINE__, L"c:", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" },
294  { __LINE__, L"c", TRUE, PIDL_IS_NULL, 0x02000000, L"c"},
295  { __LINE__, L"c:\\Program Files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
296  { __LINE__, L"c:\\Program Files\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
297  { __LINE__, L"c:\\Program Files/", TRUE, PIDL_IS_NULL, 0x02000000, L"c:\\Program Files/"},
298  { __LINE__, L"c:/Program Files/", TRUE, PIDL_IS_NULL, 0x02000000, L"c:/Program Files/"},
299  { __LINE__, L"fonts", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"::CURDIR::fonts" }, // this would not fail if we are in Windows directory
300  { __LINE__, L"winsxs", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"::CURDIR::winsxs" },
301  { __LINE__, L"system32", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"::CURDIR::system32" },
302  { __LINE__, L"drivers", TRUE, PIDL_IS_NULL, 0x02000000, L"drivers" }, // this would fail since we are not in system32 directory
303  { __LINE__, L"spool", TRUE, PIDL_IS_NULL, 0x02000000, L"spool" },
304  // { __LINE__, L"wbem", TRUE, PIDL_IS_NULL, 0x02000000, L"wbem" },
305  { __LINE__, TEST_PATHW, TRUE, PIDL_IS_PATH, 0x00000200, NULL, TEST_PATHW },
306  { __LINE__, L"\"c:\\\"\"program files\"", TRUE, PIDL_IS_NULL, 0x02000000, L"c:\\\"program files"},
307  { __LINE__, L"\"c:\\\"program files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
308  { __LINE__, L"\"c:\\ \"program files", TRUE, PIDL_IS_NULL, 0x02000000, L"c:\\ program files"},
309  { __LINE__, L"\"c:\\\" program files", TRUE, PIDL_IS_NULL, 0x02000000, L"c:\\ program files"},
310  { __LINE__, L"\"c:\\\", \"c:\\program files\"", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
311  { __LINE__, L"c:\\,c:\\program files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
312  { __LINE__, L"/root", 0, CSIDL_MYDOCUMENTS, 0x00000000},
313  { __LINE__, L"\"/root\"", 0, CSIDL_MYDOCUMENTS, 0x00000000},
314  { __LINE__, L"/root,", TRUE, CSIDL_MYDOCUMENTS, 0x00000000},
315  { __LINE__, L"/root,c", TRUE, CSIDL_MYDOCUMENTS, 0x00000000},
316  { __LINE__, L"/root,\"\"", TRUE, CSIDL_MYDOCUMENTS, 0x00000000},
317  { __LINE__, L"/root,wrong", TRUE, CSIDL_MYDOCUMENTS, 0x00000000},
318  { __LINE__, L"/root,0", TRUE, CSIDL_MYDOCUMENTS, 0x00000000},
319  { __LINE__, L"/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"c:\\" },
320  { __LINE__, L"/root,\"c:\\\"", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"c:\\" },
321  { __LINE__, L"/root \"c:\\\"", TRUE, PIDL_IS_NULL, 0x02000000, L"/root c:\\"},
322  { __LINE__, L"/root,\"c:\\\"\"program files\"", TRUE, PIDL_IS_PATH, 0x00000000},
323  { __LINE__, L"/root,\"c:\\\"program files", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"c:\\Program Files" },
324  { __LINE__, L"/root,c:\\,c:\\Program Files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
325  { __LINE__, L"/root,c:\\,Program Files", TRUE, PIDL_IS_NULL, 0x02000000, L"Program Files"},
326  { __LINE__, L"/root,\"c:\\\"", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"c:\\" },
327  { __LINE__, L"c:\\Program Files,/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000200, NULL, L"c:\\" },
328 // { __LINE__, L"a:\\,/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000200, NULL, L"c:\\" },
329 // { __LINE__, L"a:\\,/root,c", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"A:\\" },
330  { __LINE__, L"c:\\,/root,c", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" },
331  { __LINE__, L"/select", TRUE, CSIDL_MYDOCUMENTS, 0x00000040},
332  { __LINE__, L"/select,", TRUE, CSIDL_DRIVES, 0x00000240 },
333  { __LINE__, L"/select,c", TRUE, PIDL_IS_NULL, 0x02000040, L"c"},
334  { __LINE__, L"/select,0", TRUE, PIDL_IS_NULL, 0x02000040, L"0"},
335  { __LINE__, L"/select,c:\\", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" },
336  { __LINE__, L"c:\\,/select", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" },
337  { __LINE__, L"/select," TEST_PATHW, TRUE, PIDL_IS_PATH, 0x00000240, NULL, TEST_PATHW },
338  { __LINE__, L"/select,c:\\Program Files,c:\\Documents and settings", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\Documents and Settings" },
339  { __LINE__, L"c:\\,/select," TEST_FILENAMEW, TRUE, PIDL_IS_NULL, 0x02000240, TEST_FILENAMEW },
340  { __LINE__, L"c:\\,/select," TEST_PATHW, TRUE, PIDL_IS_PATH, 0x00000240, NULL, TEST_PATHW },
341 // { __LINE__, L"a:\\,/select," TEST_PATHW, TRUE, PIDL_IS_PATH, 0x00000240, NULL, TEST_PATHW },
342  { __LINE__, L"z:\\,/select," TEST_PATHW, TRUE, PIDL_IS_PATH, 0x02000240, L"z:\\", TEST_PATHW },
343  { __LINE__, L"select,c:\\ ", TRUE, PIDL_IS_PATH, 0x02000200, L"select", L"C:\\" },
344  { __LINE__, L"/select c:\\ ", TRUE, PIDL_IS_NULL, 0x02000000, L"/select c:\\"},
345 // { __LINE__, L"a:\\,/select,c:\\", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" },
346  { __LINE__, L"a:\\,/select,c", TRUE, PIDL_IS_NULL, 0x02000040, L"c"},
347  { __LINE__, L"c:\\,/select,c", TRUE, PIDL_IS_NULL, 0x02000240, L"c"},
348  { __LINE__, L"/e", TRUE, CSIDL_MYDOCUMENTS, 0x00000008},
349  { __LINE__, L"/e,", TRUE, CSIDL_DRIVES, 0x00000208 },
350  { __LINE__, L"/e,\"", TRUE, CSIDL_DRIVES, 0x00000208 },
351  { __LINE__, L"/e,\"\"", TRUE, CSIDL_DRIVES, 0x00000208 },
352  { __LINE__, L"/e,c:\\", TRUE, PIDL_IS_PATH, 0x00000208, NULL, L"C:\\" },
353  { __LINE__, L"c:\\,/e", TRUE, PIDL_IS_PATH, 0x00000208, NULL, L"C:\\" },
354  { __LINE__, L"/e,c", TRUE, PIDL_IS_NULL, 0x02000008, L"c"},
355  { __LINE__, L"/root,c:\\,/select," TEST_FILENAMEW, TRUE, PIDL_IS_NULL, 0x02000040, TEST_FILENAMEW },
356  { __LINE__, L"/select," TEST_FILENAMEW L",/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x02000040, TEST_FILENAMEW, L"c:\\" },
357  { __LINE__, L"/root,c:\\,/select," TEST_PATHW, TRUE, PIDL_IS_PATH, 0x00000240, NULL, TEST_PATHW },
358  { __LINE__, L"/select," TEST_PATHW L",/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000240, NULL, L"c:\\" },
359  { __LINE__, L"/e,/select," TEST_FILENAMEW L",/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x02000048, TEST_FILENAMEW, L"c:\\" },
360  { __LINE__, L"/e,/root,c:\\,/select," TEST_FILENAMEW, TRUE, PIDL_IS_NULL, 0x02000048, TEST_FILENAMEW },
361  { __LINE__, L"/e,/root,c:\\", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000008, NULL, L"c:\\" },
362  { __LINE__, L"/e,c:\\,/select," TEST_FILENAMEW, TRUE, PIDL_IS_NULL, 0x02000248, TEST_FILENAMEW },
363  { __LINE__, L"c:\\,/e,/select," TEST_FILENAMEW, TRUE, PIDL_IS_NULL, 0x02000248, TEST_FILENAMEW },
364  { __LINE__, L"c:\\,/select," TEST_FILENAMEW L",/e", TRUE, PIDL_IS_NULL, 0x02000248, TEST_FILENAMEW },
365  { __LINE__, L"http:\\\\www.reactos.org", TRUE, PIDL_IS_NULL, 0x02000000, L"http:\\\\www.reactos.org"},
366  { __LINE__, L"/e,http:\\\\www.reactos.org", TRUE, PIDL_IS_NULL, 0x02000008, L"http:\\\\www.reactos.org"},
367  { __LINE__, L"/root,c:\\,http:\\\\www.reactos.org", TRUE, PIDL_IS_NULL, 0x02000000, L"http:\\\\www.reactos.org"},
368  { __LINE__, L"/separate ", TRUE, CSIDL_MYDOCUMENTS, 0x00020000},
369  { __LINE__, L"/separate,c:\\ program files", TRUE, PIDL_IS_NULL, 0x02020000, L"c:\\ program files"},
370  { __LINE__, L"/separate, c:\\program files", TRUE, PIDL_IS_PATH, 0x00020200, NULL, L"C:\\Program Files" },
371  { __LINE__, L"/separate, c:\\program files ,/e", TRUE, PIDL_IS_PATH, 0x00020208, NULL, L"C:\\Program Files" },
372  { __LINE__, L"/separate, c:\\program files ,\\e", TRUE, PIDL_IS_NULL, 0x02020200, L"\\e"},
373  { __LINE__, L"c:\\Documents and settings,/separate,/n,/e,/root,c:\\,/select,c:\\Program files,", TRUE, CSIDL_DRIVES, 0x00024249 },
374  { __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" },
375  { __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" },
376  { __LINE__, L"=", TRUE, CSIDL_DRIVES, 0x00000200 },
377  { __LINE__, L"=c:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" },
378  { __LINE__, L"=" TEST_PATHW, TRUE, PIDL_IS_PATH, 0x00000200, NULL, TEST_PATHW },
379  { __LINE__, L"/root,=", TRUE, CSIDL_DRIVES, 0x00000200 },
380  { __LINE__, L"/root=c:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" },
381  { __LINE__, L"/root=c:\\Program files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
382  { __LINE__, L"/root=\"c:\\Program files\"", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
383  { __LINE__, L"/root=\"\"c:\\Program files\"\"", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
384  { __LINE__, L"c:\\=/root=\"c:\\Program files\"", TRUE, PIDL_PATH_EQUALS_PATH, 0x00000000, NULL, L"C:\\Program Files" },
385  { __LINE__, L"/select=c:\\", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\" },
386  { __LINE__, L"/select=c:\\Program files", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\Program Files" },
387  { __LINE__, L"=,/select,c:\\", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\" },
388  { __LINE__, L"/select,c:\\,=", TRUE, CSIDL_DRIVES, 0x00000240 },
389  { __LINE__, L"c:\\=/select=c:\\windows\\system32", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\WINDOWS\\system32" },
390  { __LINE__, L"/select=c:\\windows\\system32", TRUE, PIDL_IS_PATH, 0x00000200, NULL, L"C:\\WINDOWS\\system32" },
391  { __LINE__, L"=/select=c:\\windows\\system32", TRUE, PIDL_IS_PATH, 0x00000240, NULL, L"C:\\WINDOWS\\system32" },
392  { __LINE__, L"/e,=", TRUE, CSIDL_DRIVES, 0x00000208 },
393  { __LINE__, L"/e=", TRUE, CSIDL_DRIVES, 0x00000200 },
394  { __LINE__, L"/e=\"", TRUE, CSIDL_DRIVES, 0x00000200 },
395  { __LINE__, L"/e=\"\"", TRUE, CSIDL_DRIVES, 0x00000200 },
396  { __LINE__, L"=\"=\"", TRUE, PIDL_IS_NULL, 0x02000000, L"="},
397  { __LINE__, L"==\"=\"", TRUE, PIDL_IS_NULL, 0x02000200, L"="},
398  { __LINE__, L"===\"=\"", TRUE, PIDL_IS_NULL, 0x02000200, L"="},
399  { __LINE__, L"=\"=\"", TRUE, PIDL_IS_NULL, 0x02000000, L"="},
400  { __LINE__, L"==\"==\"", TRUE, PIDL_IS_NULL, 0x02000200, L"=="},
401  { __LINE__, L"===\"===\"", TRUE, PIDL_IS_NULL, 0x02000200, L"==="},
402  { __LINE__, L"=\"=a\"", TRUE, PIDL_IS_NULL, 0x02000000, L"=a"},
403  { __LINE__, L"==\"=a=\"", TRUE, PIDL_IS_NULL, 0x02000200, L"=a="},
404  { __LINE__, L"===\"=a=a=\"", TRUE, PIDL_IS_NULL, 0x02000200, L"=a=a="},
405  { __LINE__, L"=\"=a\"==", TRUE, CSIDL_DRIVES, 0x02000200, L"=a" },
406  { __LINE__, L"==\"=a=\"=", TRUE, CSIDL_DRIVES, 0x02000200, L"=a=" },
407  { __LINE__, L"===\"=a=a=\"===", TRUE, CSIDL_DRIVES, 0x02000200, L"=a=a=" },
408  { __LINE__, L"=,=,=,\"=a=a=\",=,=,=", TRUE, CSIDL_DRIVES, 0x02000200, L"=a=a=" },
409  { __LINE__, L"\"", TRUE, CSIDL_DRIVES, 0x00000200 },
410  { __LINE__, L"\"\"", TRUE, CSIDL_DRIVES, 0x00000200 },
411  { __LINE__, L"\"\"\"", TRUE, PIDL_IS_NULL, 0x02000000, L"\""},
412  { __LINE__, L"\"\"\"\"", TRUE, PIDL_IS_NULL, 0x02000000, L"\""},
413  { __LINE__, L"\"\"\"\"\"", TRUE, PIDL_IS_NULL, 0x02000000, L"\"\""},
414  { __LINE__, L"/s", TRUE, CSIDL_MYDOCUMENTS, 0x00000002},
415  { __LINE__, L"/noui", TRUE, CSIDL_MYDOCUMENTS, 0x00001000},
416  { __LINE__, L"/idlist", TRUE, PIDL_IS_UNTOUCHED, 0x00000000},
417  { __LINE__, L"-embedding", TRUE, CSIDL_MYDOCUMENTS, 0x00000080 },
418  { __LINE__, L"/inproc", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 },
419  { __LINE__, L"/inproc,1", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 },
420  { __LINE__, L"/inproc,a", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 },
421  { __LINE__, L"/inproc,c:\\", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 },
422  { __LINE__, L"/inproc,\"c:\\\"", FALSE, PIDL_IS_UNTOUCHED, 0x00000000 },
423  { __LINE__, L"/inproc,{20d04fe0-3aea-1069-a2d8-08002b30309d}", TRUE, PIDL_IS_UNTOUCHED, 0x00000400 },
424  { __LINE__, L"shell:::{450D8FBA-AD25-11D0-98A8-0800361B1103}", TRUE, CSIDL_MYDOCUMENTS, 0x00000200 },
425  { __LINE__, L"::{450d8fba-ad25-11d0-98a8-0800361b1103}", TRUE, CSIDL_MYDOCUMENTS, 0x00000200 },
426  };
427  const int TestCount = sizeof(Tests) / sizeof(Tests[0]);
428  PWSTR CommandLine;
429  WCHAR OriginalCommandLine[1024];
430  int i;
431  UINT maxWrite = 0;
432  FILE * ff;
433  WCHAR winDir[MAX_PATH];
434 
435  HMODULE browseui = LoadLibraryA("browseui.dll");
438  {
439  skip("SHExplorerParseCmdLine not found, NT 6.0?\n");
440  return;
441  }
442 
443  CommandLine = GetCommandLineW();
444  StringCbCopyW(OriginalCommandLine, sizeof(OriginalCommandLine), CommandLine);
445 
446  ff = fopen(TEST_PATHA, "wb");
447  fclose(ff);
448 
449  GetWindowsDirectoryW(winDir, _countof(winDir));
450  SetCurrentDirectoryW(winDir);
451 
452  for (i = 0; i < TestCount; i++)
453  {
454  UINT cWrite;
455 
456  wcscpy(CommandLine, L"browseui_apitest.exe ");
457  wcscat(CommandLine, Tests[i].CommandLine);
458  trace("Command line (%d): %ls\n", Tests[i].TestLine, CommandLine);
459  TestCommandLine(Tests[i].TestLine,
460  Tests[i].ExpectedRet,
461  Tests[i].ExpectedCsidl,
462  Tests[i].ExpectedFlags,
463  Tests[i].ExpectedFileName,
464  Tests[i].PidlPath,
465  Tests[i].pclsid,
466  &cWrite);
467 
468  if (cWrite > maxWrite)
469  maxWrite = cWrite;
470  }
471 
472  trace("Writes reached the byte right before 0x%08x\n", maxWrite);
473 
474  wcscpy(CommandLine, OriginalCommandLine);
475 
477 }
PIDLIST_ABSOLUTE pidl
#define PIDL_IS_EMPTY
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define PIDL_IS_PATH
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
ULONG Padding[PADDING_SIZE]
HRESULT hr
Definition: shlfolder.c:183
struct _EXPLORER_INFO * PEXPLORER_INFO
#define TRUE
Definition: types.h:120
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
uint16_t * PWSTR
Definition: typedefs.h:56
#define PIDL_PATH_EQUALS_PATH
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1294
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:615
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1105
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:535
uint16_t * PWCHAR
Definition: typedefs.h:56
static LPOLESTR
Definition: stg_prop.c:27
#define E_FAIL
Definition: ddrawi.h:102
#define STRSAFE_E_INSUFFICIENT_BUFFER
Definition: strsafe.h:103
#define eq(received, expected, label, type)
Definition: locale.c:144
int32_t INT
Definition: typedefs.h:58
struct TraceInfo Info
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
#define CSIDL_MYDOCUMENTS
Definition: shlobj.h:2024
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
Definition: glfuncs.h:248
#define CSIDL_DRIVES
Definition: shlobj.h:2028
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
LPWSTR WINAPI GetCommandLineW(VOID)
Definition: proc.c:2015
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
START_TEST(SHExplorerParseCmdLine)
PIDLIST_ABSOLUTE WINAPI SHSimpleIDListFromPath(PCWSTR)
static VOID TestCommandLine(_In_ ULONG TestLine, _In_ INT ExpectedRet, _In_ INT ExpectedCsidl, _In_ DWORD ExpectedFlags, _In_ PCWSTR ExpectedFileName, _In_ PCWSTR PidlPath, _In_ PCWSTR pclsid, _Out_opt_ PUINT PWriteEnd)
smooth NULL
Definition: ftsmooth.c:416
#define _Out_
Definition: no_sal2.h:323
UCHAR ab[sizeof("Hello World!") -1]
Definition: fdi.c:106
#define InvalidPointer
#define _Out_opt_
Definition: no_sal2.h:339
#define trace
Definition: atltest.h:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define TEST_PATHW
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FillMemory(BUF, SIZ, MASK)
Definition: strucsup.c:31
#define __stdcall
Definition: typedefs.h:25
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
UINT_PTR WINAPI SHExplorerParseCmdLine(ExplorerCommandLineParseResults *pInfo)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define wcsicmp
Definition: compat.h:15
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
#define PADDING_SIZE
#define PIDL_IS_UNTOUCHED
STRSAFEAPI StringCchCatNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToAppend)
Definition: strsafe.h:407
unsigned char BYTE
Definition: xxhash.c:193
#define _In_
Definition: no_sal2.h:204
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define S_OK
Definition: intsafe.h:51
DWORD ReplaceSubstr(_Out_ PWCHAR OutputStr, _In_ DWORD OutputLen, _In_ PCWSTR InputStr, _In_ PCWSTR ReplaceStr, _In_ PCWSTR ReplaceWith)
PIDLIST_ABSOLUTE pidlRoot
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2248
#define ok(value,...)
Definition: atltest.h:57
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
unsigned int UINT
Definition: ndis.h:50
DWORD * PDWORD
Definition: pedump.c:68
#define skip(...)
Definition: atltest.h:64
UINT_PTR(WINAPI *SHExplorerParseCmdLine)(_Out_ PEXPLORER_INFO Info)
#define PIDL_IS_NULL
#define TEST_FILENAMEW
unsigned int ULONG
Definition: retypes.h:1
#define GetProcAddress(x, y)
Definition: compat.h:612
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2741
struct _EXPLORER_INFO EXPLORER_INFO
int remove
Definition: msacm.c:1365
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
GLuint64EXT * result
Definition: glext.h:11304
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
BYTE * PBYTE
Definition: pedump.c:66
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
struct test_data Tests[]
#define TEST_PATHA
unsigned int * PUINT
Definition: ndis.h:50
#define SUCCEEDED(hr)
Definition: intsafe.h:49
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412