hhctrl.ocx: Add a missing Release call.
[wine/multimedia.git] / dlls / crypt32 / tests / sip.c
blob8d9af75a73c0295559037178e8a0df2a45187b48
1 /*
2 * Subject Interface Package tests
4 * Copyright 2006 Paul Vriens
5 * Copyright 2008 Juan Lang
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <stdio.h>
23 #include <stdarg.h>
24 #include <windef.h>
25 #include <winbase.h>
26 #include <winerror.h>
27 #include <winnls.h>
28 #include <wincrypt.h>
29 #include <mssip.h>
31 #include "wine/test.h"
33 static BOOL (WINAPI * funcCryptSIPGetSignedDataMsg)(SIP_SUBJECTINFO *,DWORD *,DWORD,DWORD *,BYTE *);
34 static BOOL (WINAPI * funcCryptSIPPutSignedDataMsg)(SIP_SUBJECTINFO *,DWORD,DWORD *,DWORD,BYTE *);
35 static BOOL (WINAPI * funcCryptSIPCreateIndirectData)(SIP_SUBJECTINFO *,DWORD *,SIP_INDIRECT_DATA *);
36 static BOOL (WINAPI * funcCryptSIPVerifyIndirectData)(SIP_SUBJECTINFO *,SIP_INDIRECT_DATA *);
37 static BOOL (WINAPI * funcCryptSIPRemoveSignedDataMsg)(SIP_SUBJECTINFO *,DWORD);
39 static char *show_guid(const GUID *guid, char *buf)
41 sprintf(buf,
42 "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
43 guid->Data1, guid->Data2, guid->Data3,
44 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
45 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
47 return buf;
50 static void test_AddRemoveProvider(void)
52 BOOL ret;
53 SIP_ADD_NEWPROVIDER newprov;
54 GUID actionid = { 0xdeadbe, 0xefde, 0xadbe, { 0xef,0xde,0xad,0xbe,0xef,0xde,0xad,0xbe }};
55 static WCHAR dummydll[] = {'d','e','a','d','b','e','e','f','.','d','l','l',0 };
56 static WCHAR dummyfunction[] = {'d','u','m','m','y','f','u','n','c','t','i','o','n',0 };
58 /* NULL check */
59 SetLastError(0xdeadbeef);
60 ret = CryptSIPRemoveProvider(NULL);
61 ok (!ret, "Expected CryptSIPRemoveProvider to fail.\n");
62 ok (GetLastError() == ERROR_INVALID_PARAMETER,
63 "Expected ERROR_INVALID_PARAMETER, got %d.\n", GetLastError());
65 /* nonexistent provider should result in a registry error */
66 SetLastError(0xdeadbeef);
67 ret = CryptSIPRemoveProvider(&actionid);
68 if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
70 /* Apparently the needed rights are checked before the existence of the provider */
71 skip("Need admin rights\n");
73 else
75 /* On some Win98 systems, CryptSIPRemoveProvider always succeeds if
76 * the arguments are correct, whether or not the registry key is
77 * present, so don't test ret, just check the last error if it does
78 * return FALSE.
80 if (!ret)
81 ok (GetLastError() == ERROR_FILE_NOT_FOUND,
82 "Expected ERROR_FILE_NOT_FOUND, got %d.\n", GetLastError());
85 /* Everything OK, pwszIsFunctionName and pwszIsFunctionNameFmt2 are left NULL
86 * as allowed */
88 memset(&newprov, 0, sizeof(SIP_ADD_NEWPROVIDER));
89 newprov.cbStruct = sizeof(SIP_ADD_NEWPROVIDER);
90 newprov.pgSubject = &actionid;
91 newprov.pwszDLLFileName = dummydll;
92 newprov.pwszGetFuncName = dummyfunction;
93 newprov.pwszPutFuncName = dummyfunction;
94 newprov.pwszCreateFuncName = dummyfunction;
95 newprov.pwszVerifyFuncName = dummyfunction;
96 newprov.pwszRemoveFuncName = dummyfunction;
97 SetLastError(0xdeadbeef);
98 ret = CryptSIPAddProvider(&newprov);
99 if (!ret && GetLastError() == ERROR_ACCESS_DENIED)
101 skip("Need admin rights\n");
102 return;
104 ok ( ret, "CryptSIPAddProvider should have succeeded\n");
106 /* Dummy provider will be deleted, but the function still fails because
107 * pwszIsFunctionName and pwszIsFunctionNameFmt2 are not present in the
108 * registry.
110 SetLastError(0xdeadbeef);
111 ret = CryptSIPRemoveProvider(&actionid);
112 /* On some Win98 systems, CryptSIPRemoveProvider always succeeds if
113 * the arguments are correct, whether or not the registry key is
114 * present, so don't test ret, just check the last error if it does
115 * return FALSE.
117 if (!ret)
118 ok (GetLastError() == ERROR_FILE_NOT_FOUND,
119 "Expected ERROR_FILE_NOT_FOUND, got %d.\n", GetLastError());
121 /* Everything OK */
122 memset(&newprov, 0, sizeof(SIP_ADD_NEWPROVIDER));
123 newprov.cbStruct = sizeof(SIP_ADD_NEWPROVIDER);
124 newprov.pgSubject = &actionid;
125 newprov.pwszDLLFileName = dummydll;
126 newprov.pwszGetFuncName = dummyfunction;
127 newprov.pwszPutFuncName = dummyfunction;
128 newprov.pwszCreateFuncName = dummyfunction;
129 newprov.pwszVerifyFuncName = dummyfunction;
130 newprov.pwszRemoveFuncName = dummyfunction;
131 newprov.pwszIsFunctionNameFmt2 = dummyfunction;
132 newprov.pwszIsFunctionName = dummyfunction;
133 SetLastError(0xdeadbeef);
134 ret = CryptSIPAddProvider(&newprov);
135 ok ( ret, "CryptSIPAddProvider should have succeeded\n");
137 /* Dummy provider should be deleted */
138 SetLastError(0xdeadbeef);
139 ret = CryptSIPRemoveProvider(&actionid);
140 ok ( ret, "CryptSIPRemoveProvider should have succeeded\n");
143 static const BYTE cabFileData[] = {
144 0x4d,0x53,0x43,0x46,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
145 0x2c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x01,0x01,0x00,0x01,0x00,0x00,0x00,
146 0xef,0xbe,0xff,0xff,0x42,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00,
147 0x00,0x00,0x00,0x00,0x00,0x00,0xf7,0x38,0x4b,0xac,0x00,0x00,0x61,0x2e,0x74,0x78,
148 0x74,0x00,0x6d,0x5a,0x72,0x78,0x06,0x00,0x06,0x00,0x61,0x2e,0x74,0x78,0x74,0x0a,
151 static void test_SIPRetrieveSubjectGUID(void)
153 BOOL ret;
154 GUID subject;
155 HANDLE file;
156 static const CHAR windir[] = "windir";
157 static const CHAR regeditExe[] = "regedit.exe";
158 static const GUID nullSubject = { 0x0, 0x0, 0x0, { 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 }};
159 static const WCHAR deadbeef[] = { 'c',':','\\','d','e','a','d','b','e','e','f','.','d','b','f',0 };
160 /* Couldn't find a name for this GUID, it's the one used for 95% of the files */
161 static const GUID unknownGUID = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }};
162 static const GUID cabGUID = { 0xc689aaba, 0x8e78, 0x11d0, {0x8c,0x47,0x00,0xc0,0x4f,0xc2,0x95,0xee }};
163 static CHAR regeditPath[MAX_PATH];
164 static WCHAR regeditPathW[MAX_PATH];
165 static CHAR path[MAX_PATH];
166 static CHAR tempfile[MAX_PATH];
167 static WCHAR tempfileW[MAX_PATH];
168 static char guid1[39], guid2[39];
169 DWORD written;
171 /* NULL check */
172 SetLastError(0xdeadbeef);
173 ret = CryptSIPRetrieveSubjectGuid(NULL, NULL, NULL);
174 ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
175 ok (GetLastError() == ERROR_INVALID_PARAMETER,
176 "Expected ERROR_INVALID_PARAMETER, got %d.\n", GetLastError());
178 /* Test with a nonexistent file (hopefully) */
179 SetLastError(0xdeadbeef);
180 /* Set subject to something other than zeros */
181 memset(&subject, 1, sizeof(GUID));
182 ret = CryptSIPRetrieveSubjectGuid(deadbeef, NULL, &subject);
183 ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
184 ok (GetLastError() == ERROR_FILE_NOT_FOUND ||
185 GetLastError() == ERROR_PATH_NOT_FOUND,
186 "Expected ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND, got %d.\n",
187 GetLastError());
188 ok ( !memcmp(&subject, &nullSubject, sizeof(GUID)),
189 "Expected a NULL GUID for c:\\deadbeef.dbf, not %s\n", show_guid(&subject, guid1));
191 /* Now with an executable that should exist
193 * Use A-functions where possible as that should be available on all platforms
195 ret = GetEnvironmentVariableA(windir, regeditPath, MAX_PATH);
196 ok (ret > 0, "expected GEVA(windir) to succeed, last error %d\n", GetLastError());
197 strcat(regeditPath, "\\");
198 strcat(regeditPath, regeditExe);
199 MultiByteToWideChar( CP_ACP, 0, regeditPath,
200 strlen(regeditPath)+1, regeditPathW,
201 sizeof(regeditPathW)/sizeof(regeditPathW[0]) );
203 SetLastError(0xdeadbeef);
204 memset(&subject, 1, sizeof(GUID));
205 ret = CryptSIPRetrieveSubjectGuid(regeditPathW, NULL, &subject);
206 ok ( ret, "Expected CryptSIPRetrieveSubjectGuid to succeed\n");
207 ok ( !memcmp(&subject, &unknownGUID, sizeof(GUID)),
208 "Expected (%s), got (%s).\n", show_guid(&unknownGUID, guid1), show_guid(&subject, guid2));
210 /* The same thing but now with a handle instead of a filename */
211 file = CreateFileA(regeditPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
212 SetLastError(0xdeadbeef);
213 memset(&subject, 1, sizeof(GUID));
214 ret = CryptSIPRetrieveSubjectGuid(NULL, file, &subject);
215 ok ( ret, "Expected CryptSIPRetrieveSubjectGuid to succeed\n");
216 ok ( !memcmp(&subject, &unknownGUID, sizeof(GUID)),
217 "Expected (%s), got (%s).\n", show_guid(&unknownGUID, guid1), show_guid(&subject, guid2));
218 CloseHandle(file);
220 /* And both */
221 file = CreateFileA(regeditPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
222 SetLastError(0xdeadbeef);
223 memset(&subject, 1, sizeof(GUID));
224 ret = CryptSIPRetrieveSubjectGuid(regeditPathW, file, &subject);
225 ok ( ret, "Expected CryptSIPRetrieveSubjectGuid to succeed\n");
226 ok ( !memcmp(&subject, &unknownGUID, sizeof(GUID)),
227 "Expected (%s), got (%s).\n", show_guid(&unknownGUID, guid1), show_guid(&subject, guid2));
228 CloseHandle(file);
230 /* Now with an empty file */
231 GetTempPathA(sizeof(path), path);
232 GetTempFileNameA(path, "sip", 0 , tempfile);
233 MultiByteToWideChar( CP_ACP, 0, tempfile,
234 strlen(tempfile)+1, tempfileW,
235 sizeof(tempfileW)/sizeof(tempfileW[0]) );
237 SetLastError(0xdeadbeef);
238 memset(&subject, 1, sizeof(GUID));
239 ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
240 ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
241 ok ( GetLastError() == ERROR_FILE_INVALID ||
242 GetLastError() == ERROR_INVALID_PARAMETER /* Vista */ ||
243 GetLastError() == ERROR_SUCCESS /* most Win98 */ ||
244 GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN /* some Win98 */,
245 "Expected ERROR_FILE_INVALID, ERROR_INVALID_PARAMETER, ERROR_SUCCESS or TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08x\n", GetLastError());
246 ok ( !memcmp(&subject, &nullSubject, sizeof(GUID)),
247 "Expected a NULL GUID for empty file %s, not %s\n", tempfile, show_guid(&subject, guid1));
249 /* Use a file with a size of 3 (at least < 4) */
250 file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
251 WriteFile(file, "123", 3, &written, NULL);
252 CloseHandle(file);
254 SetLastError(0xdeadbeef);
255 memset(&subject, 1, sizeof(GUID));
256 ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
257 ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
258 ok ( GetLastError() == ERROR_INVALID_PARAMETER ||
259 GetLastError() == ERROR_SUCCESS /* most Win98 */ ||
260 GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN /* some Win98 */,
261 "Expected ERROR_INVALID_PARAMETER, ERROR_SUCCESS or TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08x\n", GetLastError());
262 ok ( !memcmp(&subject, &nullSubject, sizeof(GUID)),
263 "Expected a NULL GUID for empty file %s, not %s\n", tempfile, show_guid(&subject, guid1));
265 /* And now >= 4 */
266 file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
267 WriteFile(file, "1234", 4, &written, NULL);
268 CloseHandle(file);
270 SetLastError(0xdeadbeef);
271 memset(&subject, 1, sizeof(GUID));
272 ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
273 ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
274 ok ( GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN ||
275 GetLastError() == ERROR_SUCCESS /* Win98 */,
276 "Expected TRUST_E_SUBJECT_FORM_UNKNOWN or ERROR_SUCCESS, got 0x%08x\n", GetLastError());
277 ok ( !memcmp(&subject, &nullSubject, sizeof(GUID)),
278 "Expected a NULL GUID for empty file %s, not %s\n", tempfile, show_guid(&subject, guid1));
280 /* Clean up */
281 DeleteFileA(tempfile);
283 /* Create a file with just the .cab header 'MSCF' */
284 SetLastError(0xdeadbeef);
285 file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
286 ok(file != INVALID_HANDLE_VALUE, "failed with %u\n", GetLastError());
287 WriteFile(file, cabFileData, 4, &written, NULL);
288 CloseHandle(file);
290 SetLastError(0xdeadbeef);
291 memset(&subject, 1, sizeof(GUID));
292 ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
293 ok( ret, "CryptSIPRetrieveSubjectGuid failed: %d (0x%08x)\n",
294 GetLastError(), GetLastError() );
295 ok ( !memcmp(&subject, &cabGUID, sizeof(GUID)),
296 "Expected GUID %s for cabinet file, not %s\n", show_guid(&cabGUID, guid1), show_guid(&subject, guid2));
298 /* Clean up */
299 DeleteFileA(tempfile);
301 /* Create a .cab file */
302 SetLastError(0xdeadbeef);
303 file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
304 ok(file != INVALID_HANDLE_VALUE, "failed with %u\n", GetLastError());
305 WriteFile(file, cabFileData, sizeof(cabFileData), &written, NULL);
306 CloseHandle(file);
308 SetLastError(0xdeadbeef);
309 memset(&subject, 1, sizeof(GUID));
310 ret = CryptSIPRetrieveSubjectGuid(tempfileW, NULL, &subject);
311 ok( ret, "CryptSIPRetrieveSubjectGuid failed: %d (0x%08x)\n",
312 GetLastError(), GetLastError() );
313 ok ( !memcmp(&subject, &cabGUID, sizeof(GUID)),
314 "Expected GUID %s for cabinet file, not %s\n", show_guid(&cabGUID, guid1), show_guid(&subject, guid2));
316 /* Clean up */
317 DeleteFileA(tempfile);
320 static void test_SIPLoad(void)
322 BOOL ret;
323 GUID subject;
324 static GUID dummySubject = { 0xdeadbeef, 0xdead, 0xbeef, { 0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef }};
325 static GUID unknown = { 0xC689AABA, 0x8E78, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }}; /* WINTRUST.DLL */
326 static GUID unknown2 = { 0xDE351A43, 0x8E59, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }}; /* WINTRUST.DLL */
327 /* The next SIP is available on Windows and on Wine */
328 static GUID unknown3 = { 0x000C10F1, 0x0000, 0x0000, { 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 }}; /* MSISIP.DLL */
329 SIP_DISPATCH_INFO sdi;
330 HMODULE hCrypt;
332 /* All NULL */
333 SetLastError(0xdeadbeef);
334 ret = CryptSIPLoad(NULL, 0, NULL);
335 ok ( !ret, "Expected CryptSIPLoad to fail\n");
336 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
337 "Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError());
339 /* Only pSipDispatch NULL */
340 SetLastError(0xdeadbeef);
341 ret = CryptSIPLoad(&subject, 0, NULL);
342 ok ( !ret, "Expected CryptSIPLoad to fail\n");
343 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
344 "Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError());
346 /* No NULLs, but nonexistent pgSubject */
347 SetLastError(0xdeadbeef);
348 memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
349 sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
350 sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
351 ret = CryptSIPLoad(&dummySubject, 0, &sdi);
352 ok ( !ret, "Expected CryptSIPLoad to fail\n");
353 ok ( GetLastError() == TRUST_E_SUBJECT_FORM_UNKNOWN,
354 "Expected TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08x\n", GetLastError());
355 ok( sdi.pfGet == (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected no change to the function pointer\n");
357 hCrypt = GetModuleHandleA("crypt32.dll");
358 funcCryptSIPGetSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPGetSignedDataMsg");
359 funcCryptSIPPutSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPPutSignedDataMsg");
360 funcCryptSIPCreateIndirectData = (void*)GetProcAddress(hCrypt, "CryptSIPCreateIndirectData");
361 funcCryptSIPVerifyIndirectData = (void*)GetProcAddress(hCrypt, "CryptSIPVerifyIndirectData");
362 funcCryptSIPRemoveSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPRemoveSignedDataMsg");
364 /* All OK */
365 SetLastError(0xdeadbeef);
366 memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
367 sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
368 sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
369 ret = CryptSIPLoad(&unknown, 0, &sdi);
370 ok ( ret, "Expected CryptSIPLoad to succeed\n");
371 /* On native the last error will always be ERROR_PROC_NOT_FOUND as native searches for the function DllCanUnloadNow
372 * in WINTRUST.DLL (in this case). This function is not available in WINTRUST.DLL.
373 * For now there's no need to implement this is Wine as I doubt any program will rely on
374 * this last error when the call succeeded.
376 ok( sdi.pfGet != (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected a function pointer to be loaded.\n");
378 /* The function addresses returned by CryptSIPLoad are actually the addresses of
379 * crypt32's own functions. A function calling these addresses will end up first
380 * calling crypt32 functions which in its turn call the equivalent in the SIP
381 * as dictated by the given GUID.
383 if (funcCryptSIPGetSignedDataMsg && funcCryptSIPPutSignedDataMsg && funcCryptSIPCreateIndirectData &&
384 funcCryptSIPVerifyIndirectData && funcCryptSIPRemoveSignedDataMsg)
385 ok (sdi.pfGet == funcCryptSIPGetSignedDataMsg &&
386 sdi.pfPut == funcCryptSIPPutSignedDataMsg &&
387 sdi.pfCreate == funcCryptSIPCreateIndirectData &&
388 sdi.pfVerify == funcCryptSIPVerifyIndirectData &&
389 sdi.pfRemove == funcCryptSIPRemoveSignedDataMsg,
390 "Expected function addresses to be from crypt32\n");
391 else
392 trace("Couldn't load function pointers\n");
394 /* All OK, but different GUID (same SIP though) */
395 SetLastError(0xdeadbeef);
396 memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
397 sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
398 sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
399 ret = CryptSIPLoad(&unknown2, 0, &sdi);
400 ok ( ret, "Expected CryptSIPLoad to succeed\n");
401 /* This call on its own would have resulted in an ERROR_PROC_NOT_FOUND, but the previous
402 * call to CryptSIPLoad already loaded wintrust.dll. As this information is cached,
403 * CryptSIPLoad will not try to search for the already mentioned DllCanUnloadNow.
405 ok( sdi.pfGet != (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected a function pointer to be loaded.\n");
407 /* All OK, but other SIP */
408 SetLastError(0xdeadbeef);
409 memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
410 sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
411 sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
412 ret = CryptSIPLoad(&unknown3, 0, &sdi);
413 if (ret)
415 /* The SIP is known so we can safely assume that the next tests can be done */
417 /* As msisip.dll is not checked yet by any of the previous calls, the
418 * function DllCanUnloadNow will be checked again in msisip.dll (it's not present)
420 ok( sdi.pfGet != (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected a function pointer to be loaded.\n");
422 /* This is another SIP but this test proves the function addresses are the same as
423 * in the previous test.
425 if (funcCryptSIPGetSignedDataMsg && funcCryptSIPPutSignedDataMsg && funcCryptSIPCreateIndirectData &&
426 funcCryptSIPVerifyIndirectData && funcCryptSIPRemoveSignedDataMsg)
427 ok (sdi.pfGet == funcCryptSIPGetSignedDataMsg &&
428 sdi.pfPut == funcCryptSIPPutSignedDataMsg &&
429 sdi.pfCreate == funcCryptSIPCreateIndirectData &&
430 sdi.pfVerify == funcCryptSIPVerifyIndirectData &&
431 sdi.pfRemove == funcCryptSIPRemoveSignedDataMsg,
432 "Expected function addresses to be from crypt32\n");
433 else
434 trace("Couldn't load function pointers\n");
437 /* Reserved parameter not 0 */
438 SetLastError(0xdeadbeef);
439 memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
440 sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
441 sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
442 ret = CryptSIPLoad(&unknown, 1, &sdi);
443 ok ( !ret, "Expected CryptSIPLoad to fail\n");
444 ok ( GetLastError() == ERROR_INVALID_PARAMETER,
445 "Expected ERROR_INVALID_PARAMETER, got 0x%08x\n", GetLastError());
446 ok( sdi.pfGet == (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected no change to the function pointer\n");
449 START_TEST(sip)
451 test_AddRemoveProvider();
452 /* It seems that the caching for loaded dlls is shared between CryptSIPRetrieveSubjectGUID
453 * and CryptSIPLoad. The tests have to be in this order to succeed. This is because in the last
454 * test for CryptSIPRetrieveSubjectGUID, several SIPs will be loaded (on Windows).
456 test_SIPLoad();
457 test_SIPRetrieveSubjectGUID();