shlwapi: Fix tests under w2k8.
[wine] / dlls / shlwapi / tests / ordinal.c
1 /* Unit test suite for SHLWAPI ordinal functions
2  *
3  * Copyright 2004 Jon Griffiths
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19
20 #include <stdio.h>
21
22 #include "wine/test.h"
23 #include "winbase.h"
24 #include "winerror.h"
25 #include "winuser.h"
26 #include "ole2.h"
27 #include "oaidl.h"
28
29 /* Function ptrs for ordinal calls */
30 static HMODULE hShlwapi;
31 static int (WINAPI *pSHSearchMapInt)(const int*,const int*,int,int);
32 static HRESULT (WINAPI *pGetAcceptLanguagesA)(LPSTR,LPDWORD);
33
34 static HANDLE (WINAPI *pSHAllocShared)(LPCVOID,DWORD,DWORD);
35 static LPVOID (WINAPI *pSHLockShared)(HANDLE,DWORD);
36 static BOOL   (WINAPI *pSHUnlockShared)(LPVOID);
37 static BOOL   (WINAPI *pSHFreeShared)(HANDLE,DWORD);
38 static HRESULT(WINAPIV *pSHPackDispParams)(DISPPARAMS*,VARIANTARG*,UINT,...);
39
40 static void test_GetAcceptLanguagesA(void)
41 {   HRESULT retval;
42     DWORD buffersize, buffersize2, exactsize;
43     char buffer[100];
44
45     if (!pGetAcceptLanguagesA)
46         return;
47
48     buffersize = sizeof(buffer);
49     memset(buffer, 0, sizeof(buffer));
50     SetLastError(ERROR_SUCCESS);
51     retval = pGetAcceptLanguagesA( buffer, &buffersize);
52     trace("GetAcceptLanguagesA: retval %08x, size %08x, buffer (%s),"
53         " last error %u\n", retval, buffersize, buffer, GetLastError());
54     if(retval != S_OK) {
55         trace("GetAcceptLanguagesA: skipping tests\n");
56         return;
57     }
58     ok( (ERROR_NO_IMPERSONATION_TOKEN == GetLastError()) || 
59         (ERROR_CLASS_DOES_NOT_EXIST == GetLastError()) ||
60         (ERROR_PROC_NOT_FOUND == GetLastError()) ||
61         (ERROR_CALL_NOT_IMPLEMENTED == GetLastError()) ||
62         (ERROR_SUCCESS == GetLastError()), "last error set to %u\n", GetLastError());
63     exactsize = strlen(buffer);
64
65     SetLastError(ERROR_SUCCESS);
66     retval = pGetAcceptLanguagesA( NULL, NULL);
67     ok(retval == E_FAIL ||
68        retval == E_INVALIDARG, /* w2k8 */
69        "function result wrong: got %08x; expected E_FAIL\n", retval);
70     ok(ERROR_SUCCESS == GetLastError(), "last error set to %u\n", GetLastError());
71
72     buffersize = sizeof(buffer);
73     SetLastError(ERROR_SUCCESS);
74     retval = pGetAcceptLanguagesA( NULL, &buffersize);
75     ok(retval == E_FAIL ||
76        retval == E_INVALIDARG, /* w2k8 */
77        "function result wrong: got %08x; expected E_FAIL\n", retval);
78     ok(buffersize == sizeof(buffer) ||
79        buffersize == 0, /* w2k8*/
80        "buffersize was changed and is not 0; size (%d))\n", buffersize);
81     ok(ERROR_SUCCESS == GetLastError(), "last error set to %u\n", GetLastError());
82
83     SetLastError(ERROR_SUCCESS);
84     retval = pGetAcceptLanguagesA( buffer, NULL);
85     ok(retval == E_FAIL ||
86        retval == E_INVALIDARG, /* w2k8 */
87        "function result wrong: got %08x; expected E_FAIL\n", retval);
88     ok(ERROR_SUCCESS == GetLastError(), "last error set to %u\n", GetLastError());
89
90     buffersize = 0;
91     memset(buffer, 0, sizeof(buffer));
92     SetLastError(ERROR_SUCCESS);
93     retval = pGetAcceptLanguagesA( buffer, &buffersize);
94     ok(retval == E_FAIL ||
95        retval == E_INVALIDARG, /* w2k8 */
96        "function result wrong: got %08x; expected E_FAIL\n", retval);
97     ok(buffersize == 0,
98        "buffersize wrong(changed) got %08x; expected 0 (2nd parameter; not on Win2k)\n", buffersize);
99     ok(ERROR_SUCCESS == GetLastError(), "last error set to %u\n", GetLastError());
100
101     buffersize = buffersize2 = 1;
102     memset(buffer, 0, sizeof(buffer));
103     SetLastError(ERROR_SUCCESS);
104     retval = pGetAcceptLanguagesA( buffer, &buffersize);
105     switch(retval) {
106         case 0L:
107             if(buffersize == exactsize) {
108             ok( (ERROR_SUCCESS == GetLastError()) || (ERROR_CALL_NOT_IMPLEMENTED == GetLastError()) ||
109                 (ERROR_PROC_NOT_FOUND == GetLastError()) || (ERROR_NO_IMPERSONATION_TOKEN == GetLastError()),
110                 "last error wrong: got %u; expected ERROR_SUCCESS(NT4)/ERROR_CALL_NOT_IMPLEMENTED(98/ME)/"
111                 "ERROR_PROC_NOT_FOUND(NT4)/ERROR_NO_IMPERSONATION_TOKEN(XP)\n", GetLastError());
112             ok(exactsize == strlen(buffer),
113                  "buffer content (length) wrong: got %08x, expected %08x\n", lstrlenA(buffer), exactsize);
114             } else if((buffersize +1) == buffersize2) {
115                 ok(ERROR_SUCCESS == GetLastError(),
116                     "last error wrong: got %u; expected ERROR_SUCCESS\n", GetLastError());
117                 ok(buffersize == strlen(buffer),
118                     "buffer content (length) wrong: got %08x, expected %08x\n", lstrlenA(buffer), buffersize);
119             } else
120                 ok( 0, "retval %08x, size %08x, buffer (%s), last error %u\n",
121                     retval, buffersize, buffer, GetLastError());
122             break;
123         case E_INVALIDARG:
124             ok(buffersize == 0,
125                "buffersize wrong: got %08x, expected 0 (2nd parameter;Win2k)\n", buffersize);
126             ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
127                "last error wrong: got %u; expected ERROR_INSUFFICIENT_BUFFER\n", GetLastError());
128             ok(buffersize2 == strlen(buffer),
129                "buffer content (length) wrong: got %08x, expected %08x\n", lstrlenA(buffer), buffersize2);
130             break;
131         default:
132             ok( 0, "retval %08x, size %08x, buffer (%s), last error %u\n",
133                 retval, buffersize, buffer, GetLastError());
134             break;
135     }
136
137     buffersize = buffersize2 = exactsize;
138     memset(buffer, 0, sizeof(buffer));
139     SetLastError(ERROR_SUCCESS);
140     retval = pGetAcceptLanguagesA( buffer, &buffersize);
141     switch(retval) {
142         case 0L:
143             ok(ERROR_SUCCESS == GetLastError(),
144                  "last error wrong: got %u; expected ERROR_SUCCESS\n", GetLastError());
145             if((buffersize == exactsize) /* XP */ ||
146                ((buffersize +1)== exactsize) /* 98 */)
147                 ok(buffersize == strlen(buffer),
148                     "buffer content (length) wrong: got %08x, expected %08x\n", lstrlenA(buffer), buffersize);
149             else
150                 ok( 0, "retval %08x, size %08x, buffer (%s), last error %u\n",
151                     retval, buffersize, buffer, GetLastError());
152             break;
153         case E_INVALIDARG:
154             ok(buffersize == 0,
155                "buffersize wrong: got %08x, expected 0 (2nd parameter;Win2k)\n", buffersize);
156             ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
157                "last error wrong: got %u; expected ERROR_INSUFFICIENT_BUFFER\n", GetLastError());
158             ok(buffersize2 == strlen(buffer),
159                "buffer content (length) wrong: got %08x, expected %08x\n", lstrlenA(buffer), buffersize2);
160             break;
161         default:
162             ok( 0, "retval %08x, size %08x, buffer (%s), last error %u\n",
163                 retval, buffersize, buffer, GetLastError());
164             break;
165     }
166 }
167
168 static void test_SHSearchMapInt(void)
169 {
170   int keys[8], values[8];
171   int i = 0;
172
173   if (!pSHSearchMapInt)
174     return;
175
176   memset(keys, 0, sizeof(keys));
177   memset(values, 0, sizeof(values));
178   keys[0] = 99; values[0] = 101;
179
180   /* NULL key/value lists crash native, so skip testing them */
181
182   /* 1 element */
183   i = pSHSearchMapInt(keys, values, 1, keys[0]);
184   ok(i == values[0], "Len 1, expected %d, got %d\n", values[0], i);
185
186   /* Key doesn't exist */
187   i = pSHSearchMapInt(keys, values, 1, 100);
188   ok(i == -1, "Len 1 - bad key, expected -1, got %d\n", i);
189
190   /* Len = 0 => not found */
191   i = pSHSearchMapInt(keys, values, 0, keys[0]);
192   ok(i == -1, "Len 1 - passed len 0, expected -1, got %d\n", i);
193
194   /* 2 elements, len = 1 */
195   keys[1] = 98; values[1] = 102;
196   i = pSHSearchMapInt(keys, values, 1, keys[1]);
197   ok(i == -1, "Len 1 - array len 2, expected -1, got %d\n", i);
198
199   /* 2 elements, len = 2 */
200   i = pSHSearchMapInt(keys, values, 2, keys[1]);
201   ok(i == values[1], "Len 2, expected %d, got %d\n", values[1], i);
202
203   /* Searches forward */
204   keys[2] = 99; values[2] = 103;
205   i = pSHSearchMapInt(keys, values, 3, keys[0]);
206   ok(i == values[0], "Len 3, expected %d, got %d\n", values[0], i);
207 }
208
209 static void test_alloc_shared(void)
210 {
211     DWORD procid;
212     HANDLE hmem;
213     int val;
214     int* p;
215     BOOL ret;
216
217     procid=GetCurrentProcessId();
218     hmem=pSHAllocShared(NULL,10,procid);
219     ok(hmem!=NULL,"SHAllocShared(NULL...) failed: %u\n", GetLastError());
220     ret = pSHFreeShared(hmem, procid);
221     ok( ret, "SHFreeShared failed: %u\n", GetLastError());
222
223     val=0x12345678;
224     hmem=pSHAllocShared(&val,4,procid);
225     ok(hmem!=NULL,"SHAllocShared(NULL...) failed: %u\n", GetLastError());
226
227     p=(int*)pSHLockShared(hmem,procid);
228     ok(p!=NULL,"SHLockShared failed: %u\n", GetLastError());
229     if (p!=NULL)
230         ok(*p==val,"Wrong value in shared memory: %d instead of %d\n",*p,val);
231     ret = pSHUnlockShared(p);
232     ok( ret, "SHUnlockShared failed: %u\n", GetLastError());
233
234     ret = pSHFreeShared(hmem, procid);
235     ok( ret, "SHFreeShared failed: %u\n", GetLastError());
236 }
237
238 static void test_fdsa(void)
239 {
240     typedef struct
241     {
242         DWORD num_items;       /* Number of elements inserted */
243         void *mem;             /* Ptr to array */
244         DWORD blocks_alloced;  /* Number of elements allocated */
245         BYTE inc;              /* Number of elements to grow by when we need to expand */
246         BYTE block_size;       /* Size in bytes of an element */
247         BYTE flags;            /* Flags */
248     } FDSA_info;
249
250     BOOL (WINAPI *pFDSA_Initialize)(DWORD block_size, DWORD inc, FDSA_info *info, void *mem,
251                                     DWORD init_blocks);
252     BOOL (WINAPI *pFDSA_Destroy)(FDSA_info *info);
253     DWORD (WINAPI *pFDSA_InsertItem)(FDSA_info *info, DWORD where, const void *block);
254     BOOL (WINAPI *pFDSA_DeleteItem)(FDSA_info *info, DWORD where);
255
256     FDSA_info info;
257     int block_size = 10, init_blocks = 4, inc = 2;
258     DWORD ret;
259     char *mem;
260
261     pFDSA_Initialize = (void *)GetProcAddress(hShlwapi, (LPSTR)208);
262     pFDSA_Destroy    = (void *)GetProcAddress(hShlwapi, (LPSTR)209);
263     pFDSA_InsertItem = (void *)GetProcAddress(hShlwapi, (LPSTR)210);
264     pFDSA_DeleteItem = (void *)GetProcAddress(hShlwapi, (LPSTR)211);
265
266     mem = HeapAlloc(GetProcessHeap(), 0, block_size * init_blocks);
267     memset(&info, 0, sizeof(info));
268
269     ok(pFDSA_Initialize(block_size, inc, &info, mem, init_blocks), "FDSA_Initialize rets FALSE\n");
270     ok(info.num_items == 0, "num_items = %d\n", info.num_items);
271     ok(info.mem == mem, "mem = %p\n", info.mem);
272     ok(info.blocks_alloced == init_blocks, "blocks_alloced = %d\n", info.blocks_alloced);
273     ok(info.inc == inc, "inc = %d\n", info.inc);
274     ok(info.block_size == block_size, "block_size = %d\n", info.block_size);
275     ok(info.flags == 0, "flags = %d\n", info.flags);
276
277     ret = pFDSA_InsertItem(&info, 1234, "1234567890");
278     ok(ret == 0, "ret = %d\n", ret);
279     ok(info.num_items == 1, "num_items = %d\n", info.num_items);
280     ok(info.mem == mem, "mem = %p\n", info.mem);
281     ok(info.blocks_alloced == init_blocks, "blocks_alloced = %d\n", info.blocks_alloced);
282     ok(info.inc == inc, "inc = %d\n", info.inc);
283     ok(info.block_size == block_size, "block_size = %d\n", info.block_size);
284     ok(info.flags == 0, "flags = %d\n", info.flags);
285
286     ret = pFDSA_InsertItem(&info, 1234, "abcdefghij");
287     ok(ret == 1, "ret = %d\n", ret);
288
289     ret = pFDSA_InsertItem(&info, 1, "klmnopqrst");
290     ok(ret == 1, "ret = %d\n", ret);
291
292     ret = pFDSA_InsertItem(&info, 0, "uvwxyzABCD");
293     ok(ret == 0, "ret = %d\n", ret);
294     ok(info.mem == mem, "mem = %p\n", info.mem);
295     ok(info.flags == 0, "flags = %d\n", info.flags);
296
297     /* This next InsertItem will cause shlwapi to allocate its own mem buffer */
298     ret = pFDSA_InsertItem(&info, 0, "EFGHIJKLMN");
299     ok(ret == 0, "ret = %d\n", ret);
300     ok(info.mem != mem, "mem = %p\n", info.mem);
301     ok(info.blocks_alloced == init_blocks + inc, "blocks_alloced = %d\n", info.blocks_alloced);
302     ok(info.flags == 0x1, "flags = %d\n", info.flags);
303
304     ok(!memcmp(info.mem, "EFGHIJKLMNuvwxyzABCD1234567890klmnopqrstabcdefghij", 50), "mem %s\n", (char*)info.mem);
305
306     ok(pFDSA_DeleteItem(&info, 2), "rets FALSE\n");
307     ok(info.mem != mem, "mem = %p\n", info.mem);
308     ok(info.blocks_alloced == init_blocks + inc, "blocks_alloced = %d\n", info.blocks_alloced);
309     ok(info.flags == 0x1, "flags = %d\n", info.flags);
310
311     ok(!memcmp(info.mem, "EFGHIJKLMNuvwxyzABCDklmnopqrstabcdefghij", 40), "mem %s\n", (char*)info.mem);
312
313     ok(pFDSA_DeleteItem(&info, 3), "rets FALSE\n");
314     ok(info.mem != mem, "mem = %p\n", info.mem);
315     ok(info.blocks_alloced == init_blocks + inc, "blocks_alloced = %d\n", info.blocks_alloced);
316     ok(info.flags == 0x1, "flags = %d\n", info.flags);
317
318     ok(!memcmp(info.mem, "EFGHIJKLMNuvwxyzABCDklmnopqrst", 30), "mem %s\n", (char*)info.mem);
319
320     ok(!pFDSA_DeleteItem(&info, 4), "does not ret FALSE\n");
321
322     /* As shlwapi has allocated memory internally, Destroy will ret FALSE */
323     ok(!pFDSA_Destroy(&info), "FDSA_Destroy does not ret FALSE\n");
324
325
326     /* When Initialize is called with inc = 0, set it to 1 */
327     ok(pFDSA_Initialize(block_size, 0, &info, mem, init_blocks), "FDSA_Initialize rets FALSE\n");
328     ok(info.inc == 1, "inc = %d\n", info.inc);
329
330     /* This time, because shlwapi hasn't had to allocate memory
331        internally, Destroy rets non-zero */
332     ok(pFDSA_Destroy(&info), "FDSA_Destroy rets FALSE\n");
333
334
335     HeapFree(GetProcessHeap(), 0, mem);
336 }
337
338
339 typedef struct SHELL_USER_SID {
340     SID_IDENTIFIER_AUTHORITY sidAuthority;
341     DWORD                    dwUserGroupID;
342     DWORD                    dwUserID;
343 } SHELL_USER_SID, *PSHELL_USER_SID;
344 typedef struct SHELL_USER_PERMISSION {
345     SHELL_USER_SID susID;
346     DWORD          dwAccessType;
347     BOOL           fInherit;
348     DWORD          dwAccessMask;
349     DWORD          dwInheritMask;
350     DWORD          dwInheritAccessMask;
351 } SHELL_USER_PERMISSION, *PSHELL_USER_PERMISSION;
352 static void test_GetShellSecurityDescriptor(void)
353 {
354     SHELL_USER_PERMISSION supCurrentUserFull = {
355         { {SECURITY_NULL_SID_AUTHORITY}, 0, 0 },
356         ACCESS_ALLOWED_ACE_TYPE, FALSE,
357         GENERIC_ALL, 0, 0 };
358 #define MY_INHERITANCE 0xBE /* invalid value to proof behavior */
359     SHELL_USER_PERMISSION supEveryoneDenied = {
360         { {SECURITY_WORLD_SID_AUTHORITY}, SECURITY_WORLD_RID, 0 },
361         ACCESS_DENIED_ACE_TYPE, TRUE,
362         GENERIC_WRITE, MY_INHERITANCE | 0xDEADBA00, GENERIC_READ };
363     PSHELL_USER_PERMISSION rgsup[2] = {
364         &supCurrentUserFull, &supEveryoneDenied,
365     };
366     SECURITY_DESCRIPTOR* psd;
367     SECURITY_DESCRIPTOR* (WINAPI*pGetShellSecurityDescriptor)(PSHELL_USER_PERMISSION*,int);
368
369     pGetShellSecurityDescriptor=(void*)GetProcAddress(hShlwapi,(char*)475);
370
371     if(!pGetShellSecurityDescriptor)
372     {
373         skip("GetShellSecurityDescriptor not available\n");
374         return;
375     }
376
377     psd = pGetShellSecurityDescriptor(NULL, 2);
378     ok(psd==NULL, "GetShellSecurityDescriptor should fail\n");
379     psd = pGetShellSecurityDescriptor(rgsup, 0);
380     ok(psd==NULL, "GetShellSecurityDescriptor should fail\n");
381
382     psd = pGetShellSecurityDescriptor(rgsup, 2);
383     ok(psd!=NULL, "GetShellSecurityDescriptor failed\n");
384     if (psd!=NULL)
385     {
386         BOOL bHasDacl = FALSE, bDefaulted;
387         PACL pAcl;
388         DWORD dwRev;
389         SECURITY_DESCRIPTOR_CONTROL control;
390
391         ok(IsValidSecurityDescriptor(psd), "returned value is not valid SD\n");
392
393         ok(GetSecurityDescriptorControl(psd, &control, &dwRev),
394                 "GetSecurityDescriptorControl failed with error %u\n", GetLastError());
395         ok(0 == (control & SE_SELF_RELATIVE), "SD should be absolute\n");
396
397         ok(GetSecurityDescriptorDacl(psd, &bHasDacl, &pAcl, &bDefaulted), 
398             "GetSecurityDescriptorDacl failed with error %u\n", GetLastError());
399
400         ok(bHasDacl, "SD has no DACL\n");
401         if (bHasDacl)
402         {
403             ok(!bDefaulted, "DACL should not be defaulted\n");
404
405             ok(pAcl != NULL, "NULL DACL!\n");
406             if (pAcl != NULL)
407             {
408                 ACL_SIZE_INFORMATION asiSize;
409
410                 ok(IsValidAcl(pAcl), "DACL is not valid\n");
411
412                 ok(GetAclInformation(pAcl, &asiSize, sizeof(asiSize), AclSizeInformation),
413                         "GetAclInformation failed with error %u\n", GetLastError());
414
415                 ok(asiSize.AceCount == 3, "Incorrect number of ACEs: %d entries\n", asiSize.AceCount);
416                 if (asiSize.AceCount == 3)
417                 {
418                     ACCESS_ALLOWED_ACE *paaa; /* will use for DENIED too */
419
420                     ok(GetAce(pAcl, 0, (LPVOID*)&paaa), "GetAce failed with error %u\n", GetLastError());
421                     ok(paaa->Header.AceType == ACCESS_ALLOWED_ACE_TYPE, 
422                             "Invalid ACE type %d\n", paaa->Header.AceType); 
423                     ok(paaa->Header.AceFlags == 0, "Invalid ACE flags %x\n", paaa->Header.AceFlags);
424                     ok(paaa->Mask == GENERIC_ALL, "Invalid ACE mask %x\n", paaa->Mask);
425
426                     ok(GetAce(pAcl, 1, (LPVOID*)&paaa), "GetAce failed with error %u\n", GetLastError());
427                     ok(paaa->Header.AceType == ACCESS_DENIED_ACE_TYPE, 
428                             "Invalid ACE type %d\n", paaa->Header.AceType); 
429                     /* first one of two ACEs generated from inheritable entry - without inheritance */
430                     ok(paaa->Header.AceFlags == 0, "Invalid ACE flags %x\n", paaa->Header.AceFlags);
431                     ok(paaa->Mask == GENERIC_WRITE, "Invalid ACE mask %x\n", paaa->Mask);
432
433                     ok(GetAce(pAcl, 2, (LPVOID*)&paaa), "GetAce failed with error %u\n", GetLastError());
434                     ok(paaa->Header.AceType == ACCESS_DENIED_ACE_TYPE, 
435                             "Invalid ACE type %d\n", paaa->Header.AceType); 
436                     /* second ACE - with inheritance */
437                     ok(paaa->Header.AceFlags == MY_INHERITANCE,
438                             "Invalid ACE flags %x\n", paaa->Header.AceFlags);
439                     ok(paaa->Mask == GENERIC_READ, "Invalid ACE mask %x\n", paaa->Mask);
440                 }
441             }
442         }
443
444         LocalFree(psd);
445     }
446 }
447
448 static void test_SHPackDispParams(void)
449 {
450     DISPPARAMS params;
451     VARIANT vars[10];
452     HRESULT hres;
453
454     if(!pSHPackDispParams)
455         skip("SHPackSidpParams not available\n");
456
457     memset(&params, 0xc0, sizeof(params));
458     memset(vars, 0xc0, sizeof(vars));
459     hres = pSHPackDispParams(&params, vars, 1, VT_I4, 0xdeadbeef);
460     ok(hres == S_OK, "SHPackDispParams failed: %08x\n", hres);
461     ok(params.cArgs == 1, "params.cArgs = %d\n", params.cArgs);
462     ok(params.cNamedArgs == 0, "params.cNamedArgs = %d\n", params.cArgs);
463     ok(params.rgdispidNamedArgs == NULL, "params.rgdispidNamedArgs = %p\n", params.rgdispidNamedArgs);
464     ok(params.rgvarg == vars, "params.rgvarg = %p\n", params.rgvarg);
465     ok(V_VT(vars) == VT_I4, "V_VT(var) = %d\n", V_VT(vars));
466     ok(V_DISPATCH(vars) == (void*)0xdeadbeef, "failed\n");
467
468     memset(&params, 0xc0, sizeof(params));
469     hres = pSHPackDispParams(&params, NULL, 0, 0);
470     ok(hres == S_OK, "SHPackDispParams failed: %08x\n", hres);
471     ok(params.cArgs == 0, "params.cArgs = %d\n", params.cArgs);
472     ok(params.cNamedArgs == 0, "params.cNamedArgs = %d\n", params.cArgs);
473     ok(params.rgdispidNamedArgs == NULL, "params.rgdispidNamedArgs = %p\n", params.rgdispidNamedArgs);
474     ok(params.rgvarg == NULL, "params.rgvarg = %p\n", params.rgvarg);
475
476     memset(vars, 0xc0, sizeof(vars));
477     memset(&params, 0xc0, sizeof(params));
478     hres = pSHPackDispParams(&params, vars, 4, VT_BSTR, (void*)0xdeadbeef, VT_EMPTY, 10,
479             VT_I4, 100, VT_DISPATCH, (void*)0xdeadbeef);
480     ok(hres == S_OK, "SHPackDispParams failed: %08x\n", hres);
481     ok(params.cArgs == 4, "params.cArgs = %d\n", params.cArgs);
482     ok(params.cNamedArgs == 0, "params.cNamedArgs = %d\n", params.cArgs);
483     ok(params.rgdispidNamedArgs == NULL, "params.rgdispidNamedArgs = %p\n", params.rgdispidNamedArgs);
484     ok(params.rgvarg == vars, "params.rgvarg = %p\n", params.rgvarg);
485     ok(V_VT(vars) == VT_DISPATCH, "V_VT(vars[0]) = %x\n", V_VT(vars));
486     ok(V_I4(vars) == 0xdeadbeef, "V_I4(vars[0]) = %x\n", V_I4(vars));
487     ok(V_VT(vars+1) == VT_I4, "V_VT(vars[1]) = %d\n", V_VT(vars+1));
488     ok(V_I4(vars+1) == 100, "V_I4(vars[1]) = %x\n", V_I4(vars+1));
489     ok(V_VT(vars+2) == VT_I4, "V_VT(vars[2]) = %d\n", V_VT(vars+2));
490     ok(V_I4(vars+2) == 10, "V_I4(vars[2]) = %x\n", V_I4(vars+2));
491     ok(V_VT(vars+3) == VT_BSTR, "V_VT(vars[3]) = %d\n", V_VT(vars+3));
492     ok(V_BSTR(vars+3) == (void*)0xdeadbeef, "V_BSTR(vars[3]) = %p\n", V_BSTR(vars+3));
493 }
494
495 START_TEST(ordinal)
496 {
497   hShlwapi = GetModuleHandleA("shlwapi.dll");
498
499   pGetAcceptLanguagesA = (void*)GetProcAddress(hShlwapi, (LPSTR)14);
500   pSHSearchMapInt = (void*)GetProcAddress(hShlwapi, (LPSTR)198);
501   pSHAllocShared=(void*)GetProcAddress(hShlwapi,(char*)7);
502   pSHLockShared=(void*)GetProcAddress(hShlwapi,(char*)8);
503   pSHUnlockShared=(void*)GetProcAddress(hShlwapi,(char*)9);
504   pSHFreeShared=(void*)GetProcAddress(hShlwapi,(char*)10);
505   pSHPackDispParams=(void*)GetProcAddress(hShlwapi,(char*)282);
506
507   test_GetAcceptLanguagesA();
508   test_SHSearchMapInt();
509   test_alloc_shared();
510   test_fdsa();
511   test_GetShellSecurityDescriptor();
512   test_SHPackDispParams();
513 }