ReactOS 0.4.16-dev-1946-g52006dd
sip.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winerror.h>
#include <winnls.h>
#include <wincrypt.h>
#include <mssip.h>
#include "wine/test.h"
Include dependency graph for sip.c:

Go to the source code of this file.

Functions

static BOOL (WINAPI *funcCryptSIPGetSignedDataMsg)(SIP_SUBJECTINFO *
 
static void test_AddRemoveProvider (void)
 
static void test_SIPRetrieveSubjectGUID (void)
 
static void test_SIPLoad (void)
 
 START_TEST (sip)
 

Variables

static DWORD DWORD
 
static const BYTE cabFileData []
 

Function Documentation

◆ BOOL()

static BOOL ( WINAPI funcCryptSIPGetSignedDataMsg)
static

◆ START_TEST()

START_TEST ( sip  )

Definition at line 411 of file sip.c.

412{
414 /* It seems that the caching for loaded dlls is shared between CryptSIPRetrieveSubjectGUID
415 * and CryptSIPLoad. The tests have to be in this order to succeed. This is because in the last
416 * test for CryptSIPRetrieveSubjectGUID, several SIPs will be loaded (on Windows).
417 */
418 test_SIPLoad();
420}
static void test_SIPLoad(void)
Definition: sip.c:282
static void test_AddRemoveProvider(void)
Definition: sip.c:39
static void test_SIPRetrieveSubjectGUID(void)
Definition: sip.c:124

◆ test_AddRemoveProvider()

static void test_AddRemoveProvider ( void  )
static

Definition at line 39 of file sip.c.

40{
41 BOOL ret;
42 SIP_ADD_NEWPROVIDER newprov;
43 GUID actionid = { 0xdeadbe, 0xefde, 0xadbe, { 0xef,0xde,0xad,0xbe,0xef,0xde,0xad,0xbe }};
44
45 /* NULL check */
46 SetLastError(0xdeadbeef);
48 ok (!ret, "Expected CryptSIPRemoveProvider to fail.\n");
50 "Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
51
52 /* nonexistent provider should result in a registry error */
53 SetLastError(0xdeadbeef);
54 ret = CryptSIPRemoveProvider(&actionid);
56 {
57 /* Apparently the needed rights are checked before the existence of the provider */
58 skip("Need admin rights\n");
59 }
60
61 /* Everything OK, pwszIsFunctionName and pwszIsFunctionNameFmt2 are left NULL
62 * as allowed */
63
64 memset(&newprov, 0, sizeof(SIP_ADD_NEWPROVIDER));
65 newprov.cbStruct = sizeof(SIP_ADD_NEWPROVIDER);
66 newprov.pgSubject = &actionid;
67 newprov.pwszDLLFileName = (WCHAR *)L"deadbeef.dll";
68 newprov.pwszGetFuncName = (WCHAR *)L"dummyfunction";
69 newprov.pwszPutFuncName = (WCHAR *)L"dummyfunction";
70 newprov.pwszCreateFuncName = (WCHAR *)L"dummyfunction";
71 newprov.pwszVerifyFuncName = (WCHAR *)L"dummyfunction";
72 newprov.pwszRemoveFuncName = (WCHAR *)L"dummyfunction";
73 SetLastError(0xdeadbeef);
74 ret = CryptSIPAddProvider(&newprov);
76 {
77 skip("Need admin rights\n");
78 return;
79 }
80 ok ( ret, "CryptSIPAddProvider should have succeeded, last error %ld\n", GetLastError());
81
82 /* Dummy provider will be deleted, but the function still fails because
83 * pwszIsFunctionName and pwszIsFunctionNameFmt2 are not present in the
84 * registry.
85 */
86 SetLastError(0xdeadbeef);
87 ret = CryptSIPRemoveProvider(&actionid);
89 "Expected ERROR_FILE_NOT_FOUND, got %ld.\n", GetLastError());
90
91 /* Everything OK */
92 memset(&newprov, 0, sizeof(SIP_ADD_NEWPROVIDER));
93 newprov.cbStruct = sizeof(SIP_ADD_NEWPROVIDER);
94 newprov.pgSubject = &actionid;
95 newprov.pwszDLLFileName = (WCHAR *)L"deadbeef.dll";
96 newprov.pwszGetFuncName = (WCHAR *)L"dummyfunction";
97 newprov.pwszPutFuncName = (WCHAR *)L"dummyfunction";
98 newprov.pwszCreateFuncName = (WCHAR *)L"dummyfunction";
99 newprov.pwszVerifyFuncName = (WCHAR *)L"dummyfunction";
100 newprov.pwszRemoveFuncName = (WCHAR *)L"dummyfunction";
101 newprov.pwszIsFunctionNameFmt2 = (WCHAR *)L"dummyfunction";
102 newprov.pwszIsFunctionName = (WCHAR *)L"dummyfunction";
103 /* If GetCapFuncName set to NULL, then CryptSIPRemoveProvider fails on win 8 */
104 newprov.pwszGetCapFuncName = (WCHAR *)L"dummyfunction";
105
106 SetLastError(0xdeadbeef);
107 ret = CryptSIPAddProvider(&newprov);
108 ok ( ret, "CryptSIPAddProvider should have succeeded, last error %ld\n", GetLastError());
109
110 /* Dummy provider should be deleted */
111 SetLastError(0xdeadbeef);
112 ret = CryptSIPRemoveProvider(&actionid);
113 ok ( ret, "CryptSIPRemoveProvider should have succeeded, last error %ld\n", GetLastError());
114}
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define NULL
Definition: types.h:112
BOOL WINAPI CryptSIPRemoveProvider(GUID *pgProv)
Definition: sip.c:112
BOOL WINAPI CryptSIPAddProvider(SIP_ADD_NEWPROVIDER *psNewProv)
Definition: sip.c:207
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
struct SIP_ADD_NEWPROVIDER_ SIP_ADD_NEWPROVIDER
#define memset(x, y, z)
Definition: compat.h:39
WCHAR * pwszPutFuncName
Definition: mssip.h:153
WCHAR * pwszCreateFuncName
Definition: mssip.h:154
GUID * pgSubject
Definition: mssip.h:145
WCHAR * pwszGetCapFuncName
Definition: mssip.h:161
WCHAR * pwszRemoveFuncName
Definition: mssip.h:156
WCHAR * pwszIsFunctionName
Definition: mssip.h:150
WCHAR * pwszGetFuncName
Definition: mssip.h:152
WCHAR * pwszIsFunctionNameFmt2
Definition: mssip.h:158
WCHAR * pwszVerifyFuncName
Definition: mssip.h:155
WCHAR * pwszDLLFileName
Definition: mssip.h:147
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_SIPLoad()

static void test_SIPLoad ( void  )
static

Definition at line 282 of file sip.c.

283{
284 BOOL ret;
285 GUID subject;
286 static GUID dummySubject = { 0xdeadbeef, 0xdead, 0xbeef, { 0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef }};
287 static GUID unknown = { 0xC689AABA, 0x8E78, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }}; /* WINTRUST.DLL */
288 static GUID unknown2 = { 0xDE351A43, 0x8E59, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }}; /* WINTRUST.DLL */
289 /* The next SIP is available on Windows and on Wine */
290 static GUID unknown3 = { 0x000C10F1, 0x0000, 0x0000, { 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 }}; /* MSISIP.DLL */
293
294 /* All NULL */
295 SetLastError(0xdeadbeef);
296 ret = CryptSIPLoad(NULL, 0, NULL);
297 ok ( !ret, "Expected CryptSIPLoad to fail\n");
299 "Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError());
300
301 /* Only pSipDispatch NULL */
302 SetLastError(0xdeadbeef);
303 ret = CryptSIPLoad(&subject, 0, NULL);
304 ok ( !ret, "Expected CryptSIPLoad to fail\n");
306 "Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError());
307
308 /* No NULLs, but nonexistent pgSubject */
309 SetLastError(0xdeadbeef);
310 memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
311 sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
312 sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
313 ret = CryptSIPLoad(&dummySubject, 0, &sdi);
314 ok ( !ret, "Expected CryptSIPLoad to fail\n");
316 "Expected TRUST_E_SUBJECT_FORM_UNKNOWN, got 0x%08lx\n", GetLastError());
317 ok( sdi.pfGet == (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected no change to the function pointer\n");
318
319 hCrypt = GetModuleHandleA("crypt32.dll");
320 funcCryptSIPGetSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPGetSignedDataMsg");
321 funcCryptSIPPutSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPPutSignedDataMsg");
322 funcCryptSIPCreateIndirectData = (void*)GetProcAddress(hCrypt, "CryptSIPCreateIndirectData");
323 funcCryptSIPVerifyIndirectData = (void*)GetProcAddress(hCrypt, "CryptSIPVerifyIndirectData");
324 funcCryptSIPRemoveSignedDataMsg = (void*)GetProcAddress(hCrypt, "CryptSIPRemoveSignedDataMsg");
325
326 /* All OK */
327 SetLastError(0xdeadbeef);
328 memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
329 sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
330 sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
331 ret = CryptSIPLoad(&unknown, 0, &sdi);
332 ok ( ret, "Expected CryptSIPLoad to succeed\n");
333 /* On native the last error will always be ERROR_PROC_NOT_FOUND as native searches for the function DllCanUnloadNow
334 * in WINTRUST.DLL (in this case). This function is not available in WINTRUST.DLL.
335 * For now there's no need to implement this is Wine as I doubt any program will rely on
336 * this last error when the call succeeded.
337 */
338 ok( sdi.pfGet != (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected a function pointer to be loaded.\n");
339
340 /* The function addresses returned by CryptSIPLoad are actually the addresses of
341 * crypt32's own functions. A function calling these addresses will end up first
342 * calling crypt32 functions which in its turn call the equivalent in the SIP
343 * as dictated by the given GUID.
344 */
345 if (funcCryptSIPGetSignedDataMsg && funcCryptSIPPutSignedDataMsg && funcCryptSIPCreateIndirectData &&
346 funcCryptSIPVerifyIndirectData && funcCryptSIPRemoveSignedDataMsg)
347 ok (sdi.pfGet == funcCryptSIPGetSignedDataMsg &&
348 sdi.pfPut == funcCryptSIPPutSignedDataMsg &&
349 sdi.pfCreate == funcCryptSIPCreateIndirectData &&
350 sdi.pfVerify == funcCryptSIPVerifyIndirectData &&
351 sdi.pfRemove == funcCryptSIPRemoveSignedDataMsg,
352 "Expected function addresses to be from crypt32\n");
353 else
354 trace("Couldn't load function pointers\n");
355
356 /* All OK, but different GUID (same SIP though) */
357 SetLastError(0xdeadbeef);
358 memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
359 sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
360 sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
361 ret = CryptSIPLoad(&unknown2, 0, &sdi);
362 ok ( ret, "Expected CryptSIPLoad to succeed\n");
363 /* This call on its own would have resulted in an ERROR_PROC_NOT_FOUND, but the previous
364 * call to CryptSIPLoad already loaded wintrust.dll. As this information is cached,
365 * CryptSIPLoad will not try to search for the already mentioned DllCanUnloadNow.
366 */
367 ok( sdi.pfGet != (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected a function pointer to be loaded.\n");
368
369 /* All OK, but other SIP */
370 SetLastError(0xdeadbeef);
371 memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
372 sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
373 sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
374 ret = CryptSIPLoad(&unknown3, 0, &sdi);
375 if (ret)
376 {
377 /* The SIP is known so we can safely assume that the next tests can be done */
378
379 /* As msisip.dll is not checked yet by any of the previous calls, the
380 * function DllCanUnloadNow will be checked again in msisip.dll (it's not present)
381 */
382 ok( sdi.pfGet != (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected a function pointer to be loaded.\n");
383
384 /* This is another SIP but this test proves the function addresses are the same as
385 * in the previous test.
386 */
387 if (funcCryptSIPGetSignedDataMsg && funcCryptSIPPutSignedDataMsg && funcCryptSIPCreateIndirectData &&
388 funcCryptSIPVerifyIndirectData && funcCryptSIPRemoveSignedDataMsg)
389 ok (sdi.pfGet == funcCryptSIPGetSignedDataMsg &&
390 sdi.pfPut == funcCryptSIPPutSignedDataMsg &&
391 sdi.pfCreate == funcCryptSIPCreateIndirectData &&
392 sdi.pfVerify == funcCryptSIPVerifyIndirectData &&
393 sdi.pfRemove == funcCryptSIPRemoveSignedDataMsg,
394 "Expected function addresses to be from crypt32\n");
395 else
396 trace("Couldn't load function pointers\n");
397 }
398
399 /* Reserved parameter not 0 */
400 SetLastError(0xdeadbeef);
401 memset(&sdi, 0, sizeof(SIP_DISPATCH_INFO));
402 sdi.cbSize = sizeof(SIP_DISPATCH_INFO);
403 sdi.pfGet = (pCryptSIPGetSignedDataMsg)0xdeadbeef;
404 ret = CryptSIPLoad(&unknown, 1, &sdi);
405 ok ( !ret, "Expected CryptSIPLoad to fail\n");
407 "Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError());
408 ok( sdi.pfGet == (pCryptSIPGetSignedDataMsg)0xdeadbeef, "Expected no change to the function pointer\n");
409}
#define trace
Definition: atltest.h:70
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605
BOOL WINAPI CryptSIPLoad(const GUID *pgSubject, DWORD dwFlags, SIP_DISPATCH_INFO *pSipDispatch)
Definition: sip.c:690
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static HMODULE hCrypt
Definition: main.c:31
BOOL(WINAPI * pCryptSIPGetSignedDataMsg)(SIP_SUBJECTINFO *, DWORD *, DWORD, DWORD *, BYTE *)
Definition: mssip.h:117
struct SIP_DISPATCH_INFO_ SIP_DISPATCH_INFO
pCryptSIPVerifyIndirectData pfVerify
Definition: mssip.h:132
pCryptSIPRemoveSignedDataMsg pfRemove
Definition: mssip.h:133
pCryptSIPGetSignedDataMsg pfGet
Definition: mssip.h:129
pCryptSIPPutSignedDataMsg pfPut
Definition: mssip.h:130
pCryptSIPCreateIndirectData pfCreate
Definition: mssip.h:131
#define TRUST_E_SUBJECT_FORM_UNKNOWN
Definition: winerror.h:4621

Referenced by START_TEST().

◆ test_SIPRetrieveSubjectGUID()

static void test_SIPRetrieveSubjectGUID ( void  )
static

Definition at line 124 of file sip.c.

125{
126 BOOL ret;
127 GUID subject;
128 HANDLE file;
129 static const CHAR windir[] = "windir";
130 static const CHAR regeditExe[] = "regedit.exe";
131 static const GUID nullSubject = { 0x0, 0x0, 0x0, { 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0 }};
132 /* Couldn't find a name for this GUID, it's the one used for 95% of the files */
133 static const GUID unknownGUID = { 0xC689AAB8, 0x8E78, 0x11D0, { 0x8C,0x47,0x00,0xC0,0x4F,0xC2,0x95,0xEE }};
134 static const GUID cabGUID = { 0xc689aaba, 0x8e78, 0x11d0, {0x8c,0x47,0x00,0xc0,0x4f,0xc2,0x95,0xee }};
135 static CHAR regeditPath[MAX_PATH];
136 static WCHAR regeditPathW[MAX_PATH];
137 static CHAR path[MAX_PATH];
138 static CHAR tempfile[MAX_PATH];
139 static WCHAR tempfileW[MAX_PATH];
140 DWORD written;
141
142 /* NULL check */
143 SetLastError(0xdeadbeef);
145 ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
147 "Expected ERROR_INVALID_PARAMETER, got %ld.\n", GetLastError());
148
149 /* Test with a nonexistent file (hopefully) */
150 SetLastError(0xdeadbeef);
151 /* Set subject to something other than zeros */
152 memset(&subject, 1, sizeof(GUID));
153 ret = CryptSIPRetrieveSubjectGuid(L"c:\\deadbeef.dbf", NULL, &subject);
154 ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
157 "Expected ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND, got %ld.\n",
158 GetLastError());
159 ok(IsEqualGUID(&subject, &nullSubject),
160 "Expected a NULL GUID for c:\\deadbeef.dbf, not %s\n", wine_dbgstr_guid(&subject));
161
162 /* Now with an executable that should exist
163 *
164 * Use A-functions where possible as that should be available on all platforms
165 */
166 ret = GetEnvironmentVariableA(windir, regeditPath, MAX_PATH);
167 ok (ret > 0, "expected GEVA(windir) to succeed, last error %ld\n", GetLastError());
168 strcat(regeditPath, "\\");
169 strcat(regeditPath, regeditExe);
170 MultiByteToWideChar(CP_ACP, 0, regeditPath, strlen(regeditPath)+1, regeditPathW,
171 ARRAY_SIZE(regeditPathW));
172
173 SetLastError(0xdeadbeef);
174 memset(&subject, 1, sizeof(GUID));
175 ret = CryptSIPRetrieveSubjectGuid(regeditPathW, NULL, &subject);
176 ok ( ret, "Expected CryptSIPRetrieveSubjectGuid to succeed\n");
177 ok(IsEqualGUID(&subject, &unknownGUID),
178 "Expected (%s), got (%s).\n", wine_dbgstr_guid(&unknownGUID), wine_dbgstr_guid(&subject));
179
180 /* The same thing but now with a handle instead of a filename */
181 file = CreateFileA(regeditPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
182 SetLastError(0xdeadbeef);
183 memset(&subject, 1, sizeof(GUID));
185 ok ( ret, "Expected CryptSIPRetrieveSubjectGuid to succeed\n");
186 ok(IsEqualGUID(&subject, &unknownGUID),
187 "Expected (%s), got (%s).\n", wine_dbgstr_guid(&unknownGUID), wine_dbgstr_guid(&subject));
189
190 /* And both */
191 file = CreateFileA(regeditPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
192 SetLastError(0xdeadbeef);
193 memset(&subject, 1, sizeof(GUID));
194 ret = CryptSIPRetrieveSubjectGuid(regeditPathW, file, &subject);
195 ok ( ret, "Expected CryptSIPRetrieveSubjectGuid to succeed\n");
196 ok(IsEqualGUID(&subject, &unknownGUID),
197 "Expected (%s), got (%s).\n", wine_dbgstr_guid(&unknownGUID), wine_dbgstr_guid(&subject));
199
200 /* Now with an empty file */
201 GetTempPathA(sizeof(path), path);
202 GetTempFileNameA(path, "sip", 0 , tempfile);
203 MultiByteToWideChar(CP_ACP, 0, tempfile, strlen(tempfile)+1, tempfileW, ARRAY_SIZE(tempfileW));
204
205 SetLastError(0xdeadbeef);
206 memset(&subject, 1, sizeof(GUID));
208 ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
210 "Expected ERROR_FILE_INVALID, ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError());
211 ok(IsEqualGUID(&subject, &nullSubject),
212 "Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject));
213
214 /* Use a file with a size of 3 (at least < 4) */
215 file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
216 WriteFile(file, "123", 3, &written, NULL);
218
219 SetLastError(0xdeadbeef);
220 memset(&subject, 1, sizeof(GUID));
222 ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
224 "Expected ERROR_INVALID_PARAMETER, got 0x%08lx\n", GetLastError());
225 ok(IsEqualGUID(&subject, &nullSubject),
226 "Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject));
227
228 /* And now >= 4 */
229 file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
230 WriteFile(file, "1234", 4, &written, NULL);
232
233 SetLastError(0xdeadbeef);
234 memset(&subject, 1, sizeof(GUID));
236 ok ( !ret, "Expected CryptSIPRetrieveSubjectGuid to fail\n");
238 "Expected TRUST_E_SUBJECT_FORM_UNKNOWN or ERROR_SUCCESS, got 0x%08lx\n", GetLastError());
239 ok(IsEqualGUID(&subject, &nullSubject),
240 "Expected a NULL GUID for empty file %s, not %s\n", tempfile, wine_dbgstr_guid(&subject));
241
242 /* Clean up */
243 DeleteFileA(tempfile);
244
245 /* Create a file with just the .cab header 'MSCF' */
246 SetLastError(0xdeadbeef);
247 file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
248 ok(file != INVALID_HANDLE_VALUE, "failed with %lu\n", GetLastError());
249 WriteFile(file, cabFileData, 4, &written, NULL);
251
252 SetLastError(0xdeadbeef);
253 memset(&subject, 1, sizeof(GUID));
255 ok( ret, "CryptSIPRetrieveSubjectGuid failed: %ld (0x%08lx)\n",
257 ok(IsEqualGUID(&subject, &cabGUID),
258 "Expected GUID %s for cabinet file, not %s\n", wine_dbgstr_guid(&cabGUID), wine_dbgstr_guid(&subject));
259
260 /* Clean up */
261 DeleteFileA(tempfile);
262
263 /* Create a .cab file */
264 SetLastError(0xdeadbeef);
265 file = CreateFileA(tempfile, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
266 ok(file != INVALID_HANDLE_VALUE, "failed with %lu\n", GetLastError());
267 WriteFile(file, cabFileData, sizeof(cabFileData), &written, NULL);
269
270 SetLastError(0xdeadbeef);
271 memset(&subject, 1, sizeof(GUID));
273 ok( ret, "CryptSIPRetrieveSubjectGuid failed: %ld (0x%08lx)\n",
275 ok(IsEqualGUID(&subject, &cabGUID),
276 "Expected GUID %s for cabinet file, not %s\n", wine_dbgstr_guid(&cabGUID), wine_dbgstr_guid(&subject));
277
278 /* Clean up */
279 DeleteFileA(tempfile);
280}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ARRAY_SIZE(A)
Definition: main.h:20
BOOL WINAPI CryptSIPRetrieveSubjectGuid(LPCWSTR FileName, HANDLE hFileIn, GUID *pgSubject)
Definition: sip.c:310
#define CloseHandle
Definition: compat.h:739
#define CP_ACP
Definition: compat.h:109
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define MAX_PATH
Definition: compat.h:34
#define GetEnvironmentVariableA(x, y, z)
Definition: compat.h:754
#define MultiByteToWideChar
Definition: compat.h:110
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
static const GUID cabGUID
Definition: crypt.c:1367
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static WCHAR tempfileW[MAX_PATH]
Definition: localmon.c:131
#define CREATE_NEW
Definition: disk.h:69
static const BYTE cabFileData[]
Definition: sip.c:116
#define GENERIC_WRITE
Definition: nt_native.h:90
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
strcat
Definition: string.h:92
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
Definition: fci.c:127
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:228
#define ERROR_FILE_INVALID
Definition: winerror.h:909
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

Variable Documentation

◆ cabFileData

const BYTE cabFileData[]
static
Initial value:
= {
0x4d,0x53,0x43,0x46,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x2c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x01,0x01,0x00,0x01,0x00,0x00,0x00,
0xef,0xbe,0xff,0xff,0x42,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xf7,0x38,0x4b,0xac,0x00,0x00,0x61,0x2e,0x74,0x78,
0x74,0x00,0x6d,0x5a,0x72,0x78,0x06,0x00,0x06,0x00,0x61,0x2e,0x74,0x78,0x74,0x0a,
}

Definition at line 116 of file sip.c.

Referenced by test_SIPRetrieveSubjectGUID().

◆ DWORD

Definition at line 33 of file sip.c.