ReactOS  0.4.14-dev-1296-g56aa513
mscat.h File Reference
#include <mssip.h>
#include <pshpack8.h>
#include <poppack.h>
Include dependency graph for mscat.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CRYPTCATATTRIBUTE_
 
struct  CRYPTCATMEMBER_
 
struct  CATALOG_INFO_
 
struct  CRYPTCATCDF_
 

Macros

#define CRYPTCAT_OPEN_CREATENEW   0x00000001
 
#define CRYPTCAT_OPEN_ALWAYS   0x00000002
 
#define CRYPTCAT_OPEN_EXISTING   0x00000004
 
#define CRYPTCAT_OPEN_EXCLUDE_PAGE_HASHES   0x00010000
 
#define CRYPTCAT_OPEN_INCLUDE_PAGE_HASHES   0x00020000
 
#define CRYPTCAT_OPEN_VERIFYSIGHASH   0x10000000
 
#define CRYPTCAT_OPEN_NO_CONTENT_HCRYPTMSG   0x20000000
 
#define CRYPTCAT_OPEN_SORTED   0x40000000
 
#define CRYPTCAT_OPEN_FLAGS_MASK   0xffff0000
 
#define CRYPTCAT_E_AREA_HEADER   0x00000000
 
#define CRYPTCAT_E_AREA_MEMBER   0x00010000
 
#define CRYPTCAT_E_AREA_ATTRIBUTE   0x00020000
 
#define CRYPTCAT_E_CDF_UNSUPPORTED   0x00000001
 
#define CRYPTCAT_E_CDF_DUPLICATE   0x00000002
 
#define CRYPTCAT_E_CDF_TAGNOTFOUND   0x00000004
 
#define CRYPTCAT_E_CDF_MEMBER_FILE_PATH   0x00010001
 
#define CRYPTCAT_E_CDF_MEMBER_INDIRECTDATA   0x00010002
 
#define CRYPTCAT_E_CDF_MEMBER_FILENOTFOUND   0x00010004
 
#define CRYPTCAT_E_CDF_BAD_GUID_CONV   0x00020001
 
#define CRYPTCAT_E_CDF_ATTR_TOOFEWVALUES   0x00020002
 
#define CRYPTCAT_E_CDF_ATTR_TYPECOMBO   0x00020004
 

Typedefs

typedef HANDLE HCATADMIN
 
typedef HANDLE HCATINFO
 
typedef struct CRYPTCATATTRIBUTE_ CRYPTCATATTRIBUTE
 
typedef struct CRYPTCATMEMBER_ CRYPTCATMEMBER
 
typedef struct CATALOG_INFO_ CATALOG_INFO
 
typedef struct CRYPTCATCDF_ CRYPTCATCDF
 
typedef void(WINAPIPFN_CDF_PARSE_ERROR_CALLBACK) (DWORD, DWORD, WCHAR *)
 

Functions

BOOL WINAPI CryptCATAdminAcquireContext (HCATADMIN *, const GUID *, DWORD)
 
HCATINFO WINAPI CryptCATAdminAddCatalog (HCATADMIN, PWSTR, PWSTR, DWORD)
 
BOOL WINAPI CryptCATAdminCalcHashFromFileHandle (HANDLE, DWORD *, BYTE *, DWORD)
 
HCATINFO WINAPI CryptCATAdminEnumCatalogFromHash (HCATADMIN, BYTE *, DWORD, DWORD, HCATINFO *)
 
BOOL WINAPI CryptCATAdminReleaseCatalogContext (HCATADMIN, HCATINFO, DWORD)
 
BOOL WINAPI CryptCATAdminReleaseContext (HCATADMIN, DWORD)
 
BOOL WINAPI CryptCATAdminRemoveCatalog (HCATADMIN, LPCWSTR, DWORD)
 
BOOL WINAPI CryptCATAdminResolveCatalogPath (HCATADMIN, WCHAR *, CATALOG_INFO *, DWORD)
 
BOOL WINAPI CryptCATCatalogInfoFromContext (HCATINFO, CATALOG_INFO *, DWORD)
 
BOOL WINAPI CryptCATCDFClose (CRYPTCATCDF *)
 
CRYPTCATATTRIBUTE *WINAPI CryptCATCDFEnumCatAttributes (CRYPTCATCDF *, CRYPTCATATTRIBUTE *, PFN_CDF_PARSE_ERROR_CALLBACK)
 
LPWSTR WINAPI CryptCATCDFEnumMembersByCDFTagEx (CRYPTCATCDF *, LPWSTR, PFN_CDF_PARSE_ERROR_CALLBACK, CRYPTCATMEMBER **, BOOL, LPVOID)
 
CRYPTCATCDF *WINAPI CryptCATCDFOpen (LPWSTR, PFN_CDF_PARSE_ERROR_CALLBACK)
 
BOOL WINAPI CryptCATClose (HANDLE)
 
CRYPTCATATTRIBUTE *WINAPI CryptCATEnumerateAttr (HANDLE, CRYPTCATMEMBER *, CRYPTCATATTRIBUTE *)
 
CRYPTCATATTRIBUTE *WINAPI CryptCATEnumerateCatAttr (HANDLE, CRYPTCATATTRIBUTE *)
 
CRYPTCATMEMBER *WINAPI CryptCATEnumerateMember (HANDLE, CRYPTCATMEMBER *)
 
CRYPTCATATTRIBUTE *WINAPI CryptCATGetAttrInfo (HANDLE, CRYPTCATMEMBER *, LPWSTR)
 
CRYPTCATATTRIBUTE *WINAPI CryptCATGetCatAttrInfo (HANDLE, LPWSTR)
 
CRYPTCATMEMBER *WINAPI CryptCATGetMemberInfo (HANDLE, LPWSTR)
 
HANDLE WINAPI CryptCATOpen (LPWSTR, DWORD, HCRYPTPROV, DWORD, DWORD)
 

Macro Definition Documentation

◆ CRYPTCAT_E_AREA_ATTRIBUTE

#define CRYPTCAT_E_AREA_ATTRIBUTE   0x00020000

Definition at line 43 of file mscat.h.

◆ CRYPTCAT_E_AREA_HEADER

#define CRYPTCAT_E_AREA_HEADER   0x00000000

Definition at line 41 of file mscat.h.

◆ CRYPTCAT_E_AREA_MEMBER

#define CRYPTCAT_E_AREA_MEMBER   0x00010000

Definition at line 42 of file mscat.h.

◆ CRYPTCAT_E_CDF_ATTR_TOOFEWVALUES

#define CRYPTCAT_E_CDF_ATTR_TOOFEWVALUES   0x00020002

Definition at line 54 of file mscat.h.

◆ CRYPTCAT_E_CDF_ATTR_TYPECOMBO

#define CRYPTCAT_E_CDF_ATTR_TYPECOMBO   0x00020004

Definition at line 55 of file mscat.h.

◆ CRYPTCAT_E_CDF_BAD_GUID_CONV

#define CRYPTCAT_E_CDF_BAD_GUID_CONV   0x00020001

Definition at line 53 of file mscat.h.

◆ CRYPTCAT_E_CDF_DUPLICATE

#define CRYPTCAT_E_CDF_DUPLICATE   0x00000002

Definition at line 46 of file mscat.h.

◆ CRYPTCAT_E_CDF_MEMBER_FILE_PATH

#define CRYPTCAT_E_CDF_MEMBER_FILE_PATH   0x00010001

Definition at line 49 of file mscat.h.

◆ CRYPTCAT_E_CDF_MEMBER_FILENOTFOUND

#define CRYPTCAT_E_CDF_MEMBER_FILENOTFOUND   0x00010004

Definition at line 51 of file mscat.h.

◆ CRYPTCAT_E_CDF_MEMBER_INDIRECTDATA

#define CRYPTCAT_E_CDF_MEMBER_INDIRECTDATA   0x00010002

Definition at line 50 of file mscat.h.

◆ CRYPTCAT_E_CDF_TAGNOTFOUND

#define CRYPTCAT_E_CDF_TAGNOTFOUND   0x00000004

Definition at line 47 of file mscat.h.

◆ CRYPTCAT_E_CDF_UNSUPPORTED

#define CRYPTCAT_E_CDF_UNSUPPORTED   0x00000001

Definition at line 45 of file mscat.h.

◆ CRYPTCAT_OPEN_ALWAYS

#define CRYPTCAT_OPEN_ALWAYS   0x00000002

Definition at line 32 of file mscat.h.

◆ CRYPTCAT_OPEN_CREATENEW

#define CRYPTCAT_OPEN_CREATENEW   0x00000001

Definition at line 31 of file mscat.h.

◆ CRYPTCAT_OPEN_EXCLUDE_PAGE_HASHES

#define CRYPTCAT_OPEN_EXCLUDE_PAGE_HASHES   0x00010000

Definition at line 34 of file mscat.h.

◆ CRYPTCAT_OPEN_EXISTING

#define CRYPTCAT_OPEN_EXISTING   0x00000004

Definition at line 33 of file mscat.h.

◆ CRYPTCAT_OPEN_FLAGS_MASK

#define CRYPTCAT_OPEN_FLAGS_MASK   0xffff0000

Definition at line 39 of file mscat.h.

◆ CRYPTCAT_OPEN_INCLUDE_PAGE_HASHES

#define CRYPTCAT_OPEN_INCLUDE_PAGE_HASHES   0x00020000

Definition at line 35 of file mscat.h.

◆ CRYPTCAT_OPEN_NO_CONTENT_HCRYPTMSG

#define CRYPTCAT_OPEN_NO_CONTENT_HCRYPTMSG   0x20000000

Definition at line 37 of file mscat.h.

◆ CRYPTCAT_OPEN_SORTED

#define CRYPTCAT_OPEN_SORTED   0x40000000

Definition at line 38 of file mscat.h.

◆ CRYPTCAT_OPEN_VERIFYSIGHASH

#define CRYPTCAT_OPEN_VERIFYSIGHASH   0x10000000

Definition at line 36 of file mscat.h.

Typedef Documentation

◆ CATALOG_INFO

◆ CRYPTCATATTRIBUTE

◆ CRYPTCATCDF

◆ CRYPTCATMEMBER

◆ HCATADMIN

typedef HANDLE HCATADMIN

Definition at line 24 of file mscat.h.

◆ HCATINFO

typedef HANDLE HCATINFO

Definition at line 25 of file mscat.h.

◆ PFN_CDF_PARSE_ERROR_CALLBACK

typedef void(WINAPI * PFN_CDF_PARSE_ERROR_CALLBACK) (DWORD, DWORD, WCHAR *)

Definition at line 103 of file mscat.h.

Function Documentation

◆ CryptCATAdminAcquireContext()

BOOL WINAPI CryptCATAdminAcquireContext ( HCATADMIN ,
const GUID ,
DWORD   
)

Definition at line 97 of file crypt.c.

99 {
100  static const WCHAR catroot[] =
101  {'\\','c','a','t','r','o','o','t',0};
102  static const WCHAR fmt[] =
103  {'%','s','\\','{','%','0','8','x','-','%','0','4','x','-','%','0',
104  '4','x','-','%','0','2','x','%','0','2','x','-','%','0','2','x',
105  '%','0','2','x','%','0','2','x','%','0','2','x','%','0','2','x',
106  '%','0','2','x','}',0};
107  static const GUID defsys =
108  {0x127d0a1d,0x4ef2,0x11d1,{0x86,0x08,0x00,0xc0,0x4f,0xc2,0x95,0xee}};
109 
110  WCHAR catroot_dir[MAX_PATH];
111  struct catadmin *ca;
112 
113  TRACE("%p %s %x\n", catAdmin, debugstr_guid(sys), dwFlags);
114 
115  if (!catAdmin || dwFlags)
116  {
118  return FALSE;
119  }
120  if (!(ca = HeapAlloc(GetProcessHeap(), 0, sizeof(*ca))))
121  {
123  return FALSE;
124  }
125 
126  GetSystemDirectoryW(catroot_dir, MAX_PATH);
127  lstrcatW(catroot_dir, catroot);
128 
129  /* create the directory if it doesn't exist */
130  CreateDirectoryW(catroot_dir, NULL);
131 
132  if (!sys) sys = &defsys;
133  swprintf(ca->path, fmt, catroot_dir, sys->Data1, sys->Data2,
134  sys->Data3, sys->Data4[0], sys->Data4[1], sys->Data4[2],
135  sys->Data4[3], sys->Data4[4], sys->Data4[5], sys->Data4[6],
136  sys->Data4[7]);
137 
138  /* create the directory if it doesn't exist */
139  CreateDirectoryW(ca->path, NULL);
140 
141  ca->magic = CATADMIN_MAGIC;
142  ca->find = INVALID_HANDLE_VALUE;
143 
144  *catAdmin = ca;
145  return TRUE;
146 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
#define TRUE
Definition: types.h:120
static CHAR catroot[MAX_PATH]
Definition: crypt.c:33
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define SetLastError(x)
Definition: compat.h:417
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define CATADMIN_MAGIC
Definition: crypt.c:39
Definition: crypt.c:55
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
static const WCHAR ca[]
Definition: main.c:455
Definition: dsound.c:943
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by InitFunctionPtrs(), and pSetupInstallCatalog().

◆ CryptCATAdminAddCatalog()

HCATINFO WINAPI CryptCATAdminAddCatalog ( HCATADMIN  ,
PWSTR  ,
PWSTR  ,
DWORD   
)

Definition at line 162 of file crypt.c.

164 {
165  static const WCHAR slashW[] = {'\\',0};
166  struct catadmin *ca = catAdmin;
167  struct catinfo *ci;
168  WCHAR *target;
169  DWORD len;
170 
171  TRACE("%p %s %s %d\n", catAdmin, debugstr_w(catalogFile),
172  debugstr_w(selectBaseName), flags);
173 
174  if (!selectBaseName)
175  {
176  FIXME("NULL basename not handled\n");
178  return NULL;
179  }
180  if (!ca || ca->magic != CATADMIN_MAGIC || !catalogFile || flags)
181  {
183  return NULL;
184  }
185 
186  len = lstrlenW(ca->path) + lstrlenW(selectBaseName) + 2;
187  if (!(target = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
188  {
190  return NULL;
191  }
192  lstrcpyW(target, ca->path);
194  lstrcatW(target, selectBaseName);
195 
196  if (!CopyFileW(catalogFile, target, FALSE))
197  {
199  return NULL;
200  }
202 
203  if (!(ci = HeapAlloc(GetProcessHeap(), 0, sizeof(*ci))))
204  {
207  return NULL;
208  }
209  ci->magic = CATINFO_MAGIC;
210  lstrcpyW(ci->file, target);
211 
213  return ci;
214 }
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:944
DWORD magic
Definition: crypt.c:64
Definition: crypt.c:62
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define lstrlenW
Definition: compat.h:415
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
WCHAR file[MAX_PATH]
Definition: crypt.c:65
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
#define CATADMIN_MAGIC
Definition: crypt.c:39
#define lstrcpyW
Definition: compat.h:414
Definition: crypt.c:55
#define CATINFO_MAGIC
Definition: crypt.c:41
GLenum target
Definition: glext.h:7315
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
static const WCHAR ca[]
Definition: main.c:455
#define HeapFree(x, y, z)
Definition: compat.h:402
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
static const WCHAR slashW[]
Definition: devenum.c:59

Referenced by InitFunctionPtrs(), and pSetupInstallCatalog().

◆ CryptCATAdminCalcHashFromFileHandle()

BOOL WINAPI CryptCATAdminCalcHashFromFileHandle ( HANDLE  ,
DWORD ,
BYTE ,
DWORD   
)

Definition at line 219 of file crypt.c.

221 {
222  BOOL ret = FALSE;
223 
224  TRACE("%p %p %p %x\n", hFile, pcbHash, pbHash, dwFlags);
225 
226  if (!hFile || !pcbHash || dwFlags)
227  {
229  return FALSE;
230  }
231  if (*pcbHash < 20)
232  {
233  *pcbHash = 20;
235  return TRUE;
236  }
237 
238  *pcbHash = 20;
239  if (pbHash)
240  {
241  HCRYPTPROV prov;
243  DWORD bytes_read;
244  BYTE *buffer;
245 
246  if (!(buffer = HeapAlloc(GetProcessHeap(), 0, 4096)))
247  {
249  return FALSE;
250  }
252  if (!ret)
253  {
255  return FALSE;
256  }
257  ret = CryptCreateHash(prov, CALG_SHA1, 0, 0, &hash);
258  if (!ret)
259  {
261  CryptReleaseContext(prov, 0);
262  return FALSE;
263  }
264  while ((ret = ReadFile(hFile, buffer, 4096, &bytes_read, NULL)) && bytes_read)
265  {
266  CryptHashData(hash, buffer, bytes_read, 0);
267  }
268  if (ret) ret = CryptGetHashParam(hash, HP_HASHVAL, pbHash, pcbHash, 0);
269 
272  CryptReleaseContext(prov, 0);
273  }
274  return ret;
275 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
GLuint buffer
Definition: glext.h:5915
BOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv, LPCWSTR pszContainer, LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
Definition: crypt.c:358
BOOL WINAPI CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1610
int hash
Definition: main.c:58
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:648
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
static const WCHAR MS_DEF_PROV_W[]
Definition: wincrypt.h:1868
BOOL WINAPI CryptDestroyHash(HCRYPTHASH hHash)
Definition: crypt.c:890
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
unsigned char BYTE
Definition: mem.h:68
BOOL WINAPI CryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash)
Definition: crypt.c:740
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CRYPT_VERIFYCONTEXT
Definition: wincrypt.h:2069
ULONG_PTR HCRYPTHASH
Definition: wincrypt.h:50
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:46
BOOL WINAPI CryptHashData(HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
Definition: crypt.c:1771
#define CALG_SHA1
Definition: wincrypt.h:1807
#define HP_HASHVAL
Definition: wincrypt.h:2183
Definition: _hash_fun.h:40
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define HeapFree(x, y, z)
Definition: compat.h:402
#define PROV_RSA_FULL
Definition: wincrypt.h:2039
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by InitFunctionPtrs().

◆ CryptCATAdminEnumCatalogFromHash()

HCATINFO WINAPI CryptCATAdminEnumCatalogFromHash ( HCATADMIN  ,
BYTE ,
DWORD  ,
DWORD  ,
HCATINFO  
)

Definition at line 280 of file crypt.c.

283 {
284  static const WCHAR slashW[] = {'\\',0};
285  static const WCHAR globW[] = {'\\','*','.','c','a','t',0};
286 
287  struct catadmin *ca = hCatAdmin;
289  HCATINFO prev = NULL;
290  HCRYPTPROV prov;
291  DWORD size;
292  BOOL ret;
293 
294  TRACE("%p %p %d %x %p\n", hCatAdmin, pbHash, cbHash, dwFlags, phPrevCatInfo);
295 
296  if (!ca || ca->magic != CATADMIN_MAGIC || !pbHash || cbHash != 20 || dwFlags)
297  {
299  return NULL;
300  }
301  if (phPrevCatInfo) prev = *phPrevCatInfo;
302 
304  if (!ret) return NULL;
305 
306  if (!prev)
307  {
308  WCHAR *path;
309 
310  size = lstrlenW(ca->path) * sizeof(WCHAR) + sizeof(globW);
311  if (!(path = HeapAlloc(GetProcessHeap(), 0, size)))
312  {
313  CryptReleaseContext(prov, 0);
315  return NULL;
316  }
317  lstrcpyW(path, ca->path);
318  lstrcatW(path, globW);
319 
320  FindClose(ca->find);
321  ca->find = FindFirstFileW(path, &data);
322 
324  if (ca->find == INVALID_HANDLE_VALUE)
325  {
326  CryptReleaseContext(prov, 0);
327  return NULL;
328  }
329  }
330  else if (!FindNextFileW(ca->find, &data))
331  {
332  CryptCATAdminReleaseCatalogContext(hCatAdmin, prev, 0);
333  CryptReleaseContext(prov, 0);
334  return NULL;
335  }
336 
337  while (1)
338  {
339  WCHAR *filename;
341  struct catinfo *ci;
342  HANDLE hcat;
343 
344  size = (lstrlenW(ca->path) + lstrlenW(data.cFileName) + 2) * sizeof(WCHAR);
345  if (!(filename = HeapAlloc(GetProcessHeap(), 0, size)))
346  {
348  return NULL;
349  }
350  lstrcpyW(filename, ca->path);
352  lstrcatW(filename, data.cFileName);
353 
354  hcat = CryptCATOpen(filename, CRYPTCAT_OPEN_EXISTING, prov, 0, 0);
355  if (hcat == INVALID_HANDLE_VALUE)
356  {
357  WARN("couldn't open %s (%u)\n", debugstr_w(filename), GetLastError());
358  continue;
359  }
360  while ((member = CryptCATEnumerateMember(hcat, member)))
361  {
362  if (member->pIndirectData->Digest.cbData != cbHash)
363  {
364  WARN("amount of hash bytes differs: %u/%u\n", member->pIndirectData->Digest.cbData, cbHash);
365  continue;
366  }
367  if (!memcmp(member->pIndirectData->Digest.pbData, pbHash, cbHash))
368  {
369  TRACE("file %s matches\n", debugstr_w(data.cFileName));
370 
371  CryptCATClose(hcat);
372  CryptReleaseContext(prov, 0);
373  if (!phPrevCatInfo)
374  {
375  FindClose(ca->find);
376  ca->find = INVALID_HANDLE_VALUE;
377  }
378  ci = create_catinfo(filename);
380  return ci;
381  }
382  }
383  CryptCATClose(hcat);
385 
386  if (!FindNextFileW(ca->find, &data))
387  {
388  FindClose(ca->find);
389  ca->find = INVALID_HANDLE_VALUE;
390  CryptReleaseContext(prov, 0);
391  return NULL;
392  }
393  }
394  return NULL;
395 }
Definition: crypt.c:62
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLsizei const GLchar ** path
Definition: glext.h:7234
#define WARN(fmt,...)
Definition: debug.h:111
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
const char * filename
Definition: ioapi.h:135
#define lstrlenW
Definition: compat.h:415
BOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv, LPCWSTR pszContainer, LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
Definition: crypt.c:358
BOOL WINAPI CryptCATClose(HANDLE hCatalog)
Definition: crypt.c:540
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:648
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
BOOL WINAPI CryptCATAdminReleaseCatalogContext(HCATADMIN hCatAdmin, HCATINFO hCatInfo, DWORD dwFlags)
Definition: crypt.c:412
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
CRYPTCATMEMBER *WINAPI CryptCATEnumerateMember(HANDLE hCatalog, CRYPTCATMEMBER *prev)
Definition: crypt.c:650
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static const WCHAR MS_DEF_PROV_W[]
Definition: wincrypt.h:1868
#define CRYPTCAT_OPEN_EXISTING
Definition: mscat.h:33
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define CATADMIN_MAGIC
Definition: crypt.c:39
#define CRYPT_VERIFYCONTEXT
Definition: wincrypt.h:2069
#define lstrcpyW
Definition: compat.h:414
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:46
Definition: crypt.c:55
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
static HCATINFO create_catinfo(const WCHAR *filename)
Definition: crypt.c:68
static const WCHAR ca[]
Definition: main.c:455
#define HeapFree(x, y, z)
Definition: compat.h:402
#define PROV_RSA_FULL
Definition: wincrypt.h:2039
HANDLE WINAPI CryptCATOpen(LPWSTR pwszFileName, DWORD fdwOpenFlags, HCRYPTPROV hProv, DWORD dwPublicVersion, DWORD dwEncodingType)
Definition: crypt.c:854
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
static const WCHAR slashW[]
Definition: devenum.c:59

◆ CryptCATAdminReleaseCatalogContext()

BOOL WINAPI CryptCATAdminReleaseCatalogContext ( HCATADMIN  ,
HCATINFO  ,
DWORD   
)

Definition at line 412 of file crypt.c.

415 {
416  struct catinfo *ci = hCatInfo;
417  struct catadmin *ca = hCatAdmin;
418 
419  TRACE("%p %p %x\n", hCatAdmin, hCatInfo, dwFlags);
420 
421  if (!ca || ca->magic != CATADMIN_MAGIC || !ci || ci->magic != CATINFO_MAGIC)
422  {
424  return FALSE;
425  }
426  ci->magic = 0;
427  return HeapFree(GetProcessHeap(), 0, ci);
428 }
DWORD magic
Definition: crypt.c:64
Definition: crypt.c:62
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
#define SetLastError(x)
Definition: compat.h:417
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define CATADMIN_MAGIC
Definition: crypt.c:39
Definition: crypt.c:55
#define CATINFO_MAGIC
Definition: crypt.c:41
static const WCHAR ca[]
Definition: main.c:455
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by CryptCATAdminEnumCatalogFromHash(), InitFunctionPtrs(), and pSetupInstallCatalog().

◆ CryptCATAdminReleaseContext()

BOOL WINAPI CryptCATAdminReleaseContext ( HCATADMIN  ,
DWORD   
)

Definition at line 444 of file crypt.c.

445 {
446  struct catadmin *ca = hCatAdmin;
447 
448  TRACE("%p %x\n", hCatAdmin, dwFlags);
449 
450  if (!ca || ca->magic != CATADMIN_MAGIC)
451  {
453  return FALSE;
454  }
455  if (ca->find != INVALID_HANDLE_VALUE) FindClose(ca->find);
456  ca->magic = 0;
457  return HeapFree(GetProcessHeap(), 0, ca);
458 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
#define SetLastError(x)
Definition: compat.h:417
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define CATADMIN_MAGIC
Definition: crypt.c:39
Definition: crypt.c:55
static const WCHAR ca[]
Definition: main.c:455
#define HeapFree(x, y, z)
Definition: compat.h:402
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by InitFunctionPtrs(), and pSetupInstallCatalog().

◆ CryptCATAdminRemoveCatalog()

BOOL WINAPI CryptCATAdminRemoveCatalog ( HCATADMIN  ,
LPCWSTR  ,
DWORD   
)

Definition at line 475 of file crypt.c.

476 {
477  struct catadmin *ca = hCatAdmin;
478 
479  TRACE("%p %s %x\n", hCatAdmin, debugstr_w(pwszCatalogFile), dwFlags);
480 
481  if (!ca || ca->magic != CATADMIN_MAGIC)
482  {
484  return FALSE;
485  }
486 
487  /* Only delete when there is a filename and no path */
488  if (pwszCatalogFile && pwszCatalogFile[0] != 0 &&
489  !wcschr(pwszCatalogFile, '\\') && !wcschr(pwszCatalogFile, '/') &&
490  !wcschr(pwszCatalogFile, ':'))
491  {
492  static const WCHAR slashW[] = {'\\',0};
493  WCHAR *target;
494  DWORD len;
495 
496  len = lstrlenW(ca->path) + lstrlenW(pwszCatalogFile) + 2;
497  if (!(target = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
498  {
500  return FALSE;
501  }
502  lstrcpyW(target, ca->path);
504  lstrcatW(target, pwszCatalogFile);
505 
507 
509  }
510 
511  return TRUE;
512 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define lstrlenW
Definition: compat.h:415
#define debugstr_w
Definition: kernel32.h:32
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLenum GLsizei len
Definition: glext.h:6722
#define CATADMIN_MAGIC
Definition: crypt.c:39
#define lstrcpyW
Definition: compat.h:414
Definition: crypt.c:55
GLenum target
Definition: glext.h:7315
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
static const WCHAR ca[]
Definition: main.c:455
#define HeapFree(x, y, z)
Definition: compat.h:402
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
static const WCHAR slashW[]
Definition: devenum.c:59

Referenced by InitFunctionPtrs().

◆ CryptCATAdminResolveCatalogPath()

BOOL WINAPI CryptCATAdminResolveCatalogPath ( HCATADMIN  ,
WCHAR ,
CATALOG_INFO ,
DWORD   
)

Definition at line 517 of file crypt.c.

519 {
520  static const WCHAR slashW[] = {'\\',0};
521  struct catadmin *ca = hcatadmin;
522 
523  TRACE("%p %s %p %x\n", hcatadmin, debugstr_w(catalog_file), info, flags);
524 
525  if (!ca || ca->magic != CATADMIN_MAGIC || !info || info->cbStruct != sizeof(*info) || flags)
526  {
528  return FALSE;
529  }
530  lstrcpyW(info->wszCatalogFile, ca->path);
531  lstrcatW(info->wszCatalogFile, slashW);
532  lstrcatW(info->wszCatalogFile, catalog_file);
533 
534  return TRUE;
535 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:417
GLbitfield flags
Definition: glext.h:7161
#define CATADMIN_MAGIC
Definition: crypt.c:39
#define lstrcpyW
Definition: compat.h:414
Definition: crypt.c:55
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
static const WCHAR ca[]
Definition: main.c:455
static const WCHAR slashW[]
Definition: devenum.c:59

◆ CryptCATCatalogInfoFromContext()

BOOL WINAPI CryptCATCatalogInfoFromContext ( HCATINFO  ,
CATALOG_INFO ,
DWORD   
)

Definition at line 835 of file crypt.c.

836 {
837  struct catinfo *ci = hcatinfo;
838 
839  TRACE("%p, %p, %x\n", hcatinfo, info, flags);
840 
841  if (!hcatinfo || hcatinfo == INVALID_HANDLE_VALUE || ci->magic != CATINFO_MAGIC ||
842  flags || !info || info->cbStruct != sizeof(*info))
843  {
845  return FALSE;
846  }
847  lstrcpyW(info->wszCatalogFile, ci->file);
848  return TRUE;
849 }
DWORD magic
Definition: crypt.c:64
Definition: crypt.c:62
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
WCHAR file[MAX_PATH]
Definition: crypt.c:65
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:417
GLbitfield flags
Definition: glext.h:7161
#define lstrcpyW
Definition: compat.h:414
#define CATINFO_MAGIC
Definition: crypt.c:41

Referenced by InitFunctionPtrs().

◆ CryptCATCDFClose()

BOOL WINAPI CryptCATCDFClose ( CRYPTCATCDF )

Definition at line 984 of file crypt.c.

985 {
986  FIXME("(%p) stub\n", pCDF);
987 
988  return FALSE;
989 }
#define FIXME(fmt,...)
Definition: debug.h:110

Referenced by InitFunctionPtrs().

◆ CryptCATCDFEnumCatAttributes()

CRYPTCATATTRIBUTE* WINAPI CryptCATCDFEnumCatAttributes ( CRYPTCATCDF ,
CRYPTCATATTRIBUTE ,
PFN_CDF_PARSE_ERROR_CALLBACK   
)

Definition at line 994 of file crypt.c.

997 {
998  FIXME("(%p %p %p) stub\n", pCDF, pPrevAttr, pfnParseError);
999 
1000  return NULL;
1001 }
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416

Referenced by InitFunctionPtrs().

◆ CryptCATCDFEnumMembersByCDFTagEx()

LPWSTR WINAPI CryptCATCDFEnumMembersByCDFTagEx ( CRYPTCATCDF ,
LPWSTR  ,
PFN_CDF_PARSE_ERROR_CALLBACK  ,
CRYPTCATMEMBER **  ,
BOOL  ,
LPVOID   
)

Definition at line 1006 of file crypt.c.

1010 {
1011  FIXME("(%p %s %p %p %d %p) stub\n", pCDF, debugstr_w(pwszPrevCDFTag), pfnParseError,
1012  ppMember, fContinueOnError, pvReserved);
1013 
1014  return NULL;
1015 }
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
static LPCSTR DWORD void * pvReserved
Definition: str.c:196

Referenced by InitFunctionPtrs().

◆ CryptCATCDFOpen()

CRYPTCATCDF* WINAPI CryptCATCDFOpen ( LPWSTR  ,
PFN_CDF_PARSE_ERROR_CALLBACK   
)

Definition at line 1020 of file crypt.c.

1022 {
1023  FIXME("(%s %p) stub\n", debugstr_w(pwszFilePath), pfnParseError);
1024 
1025  return NULL;
1026 }
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416

Referenced by InitFunctionPtrs().

◆ CryptCATClose()

BOOL WINAPI CryptCATClose ( HANDLE  )

Definition at line 540 of file crypt.c.

541 {
542  struct cryptcat *cc = hCatalog;
543 
544  TRACE("(%p)\n", hCatalog);
545 
546  if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
547  {
549  return FALSE;
550  }
551  HeapFree(GetProcessHeap(), 0, cc->attr);
552  HeapFree(GetProcessHeap(), 0, cc->inner);
553  CryptMsgClose(cc->msg);
554 
555  cc->magic = 0;
556  HeapFree(GetProcessHeap(), 0, cc);
557  return TRUE;
558 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
Definition: crypt.c:43
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
#define SetLastError(x)
Definition: compat.h:417
uint32_t cc
Definition: isohybrid.c:75
#define CRYPTCAT_MAGIC
Definition: crypt.c:40
BOOL WINAPI CryptMsgClose(HCRYPTMSG hCryptMsg)
Definition: msg.c:3598
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by CryptCATAdminEnumCatalogFromHash(), and InitFunctionPtrs().

◆ CryptCATEnumerateAttr()

CRYPTCATATTRIBUTE* WINAPI CryptCATEnumerateAttr ( HANDLE  ,
CRYPTCATMEMBER ,
CRYPTCATATTRIBUTE  
)

Definition at line 614 of file crypt.c.

615 {
616  struct cryptcat *cc = hCatalog;
617 
618  FIXME("%p, %p, %p\n", hCatalog, member, prev);
619 
620  if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
621  {
623  return NULL;
624  }
626  return NULL;
627 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007
Definition: crypt.c:43
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:417
uint32_t cc
Definition: isohybrid.c:75
#define CRYPTCAT_MAGIC
Definition: crypt.c:40

Referenced by InitFunctionPtrs().

◆ CryptCATEnumerateCatAttr()

CRYPTCATATTRIBUTE* WINAPI CryptCATEnumerateCatAttr ( HANDLE  ,
CRYPTCATATTRIBUTE  
)

Definition at line 632 of file crypt.c.

633 {
634  struct cryptcat *cc = hCatalog;
635 
636  FIXME("%p, %p\n", hCatalog, prev);
637 
638  if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
639  {
641  return NULL;
642  }
644  return NULL;
645 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007
Definition: crypt.c:43
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:417
uint32_t cc
Definition: isohybrid.c:75
#define CRYPTCAT_MAGIC
Definition: crypt.c:40

Referenced by InitFunctionPtrs().

◆ CryptCATEnumerateMember()

CRYPTCATMEMBER* WINAPI CryptCATEnumerateMember ( HANDLE  ,
CRYPTCATMEMBER  
)

Definition at line 650 of file crypt.c.

651 {
652  struct cryptcat *cc = hCatalog;
653  CRYPTCATMEMBER *member = prev;
654  CTL_ENTRY *entry;
655  DWORD size, i;
656 
657  TRACE("%p, %p\n", hCatalog, prev);
658 
659  if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
660  {
662  return NULL;
663  }
664 
665  /* dumping the contents makes me think that dwReserved is the iteration number */
666  if (!member)
667  {
668  if (!(member = HeapAlloc(GetProcessHeap(), 0, sizeof(*member))))
669  {
671  return NULL;
672  }
673  member->cbStruct = sizeof(*member);
674  member->pwszFileName = member->pwszReferenceTag = NULL;
675  member->dwReserved = 0;
676  member->hReserved = NULL;
677  member->gSubjectType = cc->subject;
678  member->fdwMemberFlags = 0;
679  member->pIndirectData = NULL;
680  member->dwCertVersion = cc->inner->dwVersion;
681  }
682  else member->dwReserved++;
683 
684  if (member->dwReserved >= cc->inner->cCTLEntry)
685  {
687  goto error;
688  }
689 
690  /* list them backwards, like native */
691  entry = &cc->inner->rgCTLEntry[cc->inner->cCTLEntry - member->dwReserved - 1];
692 
693  member->sEncodedIndirectData.cbData = member->sEncodedMemberInfo.cbData = 0;
694  member->sEncodedIndirectData.pbData = member->sEncodedMemberInfo.pbData = NULL;
695  HeapFree(GetProcessHeap(), 0, member->pIndirectData);
696  member->pIndirectData = NULL;
697 
698  for (i = 0; i < entry->cAttribute; i++)
699  {
700  CRYPT_ATTRIBUTE *attr = entry->rgAttribute + i;
701 
702  if (attr->cValue != 1)
703  {
704  ERR("Can't handle attr->cValue of %u\n", attr->cValue);
705  continue;
706  }
707  if (!strcmp(attr->pszObjId, CAT_MEMBERINFO_OBJID))
708  {
710  BOOL ret;
711 
712  member->sEncodedMemberInfo.cbData = attr->rgValue->cbData;
713  member->sEncodedMemberInfo.pbData = attr->rgValue->pbData;
714 
715  CryptDecodeObject(cc->encoding, CAT_MEMBERINFO_OBJID, attr->rgValue->pbData, attr->rgValue->cbData, 0, NULL, &size);
716 
717  if (!(mi = HeapAlloc(GetProcessHeap(), 0, size)))
718  {
720  goto error;
721  }
722  ret = CryptDecodeObject(cc->encoding, CAT_MEMBERINFO_OBJID, attr->rgValue->pbData, attr->rgValue->cbData, 0, mi, &size);
723  if (ret)
724  {
726 
727  member->dwCertVersion = mi->dwCertVersion;
728  RtlInitUnicodeString(&guid, mi->pwszSubjGuid);
729  if (RtlGUIDFromString(&guid, &member->gSubjectType))
730  {
731  HeapFree(GetProcessHeap(), 0, mi);
732  goto error;
733  }
734  }
735  HeapFree(GetProcessHeap(), 0, mi);
736  if (!ret) goto error;
737  }
738  else if (!strcmp(attr->pszObjId, SPC_INDIRECT_DATA_OBJID))
739  {
740  /* SPC_INDIRECT_DATA_CONTENT is equal to SIP_INDIRECT_DATA */
741 
742  member->sEncodedIndirectData.cbData = attr->rgValue->cbData;
743  member->sEncodedIndirectData.pbData = attr->rgValue->pbData;
744 
745  CryptDecodeObject(cc->encoding, SPC_INDIRECT_DATA_OBJID, attr->rgValue->pbData, attr->rgValue->cbData, 0, NULL, &size);
746 
747  if (!(member->pIndirectData = HeapAlloc(GetProcessHeap(), 0, size)))
748  {
750  goto error;
751  }
752  CryptDecodeObject(cc->encoding, SPC_INDIRECT_DATA_OBJID, attr->rgValue->pbData, attr->rgValue->cbData, 0, member->pIndirectData, &size);
753  }
754  else
755  /* this object id should probably be handled in CryptCATEnumerateAttr */
756  FIXME("unhandled object id \"%s\"\n", attr->pszObjId);
757  }
758 
759  if (!member->sEncodedMemberInfo.cbData || !member->sEncodedIndirectData.cbData)
760  {
761  ERR("Corrupted catalog entry?\n");
763  goto error;
764  }
765  size = (2 * member->pIndirectData->Digest.cbData + 1) * sizeof(WCHAR);
766  if (member->pwszReferenceTag)
767  member->pwszReferenceTag = HeapReAlloc(GetProcessHeap(), 0, member->pwszReferenceTag, size);
768  else
769  member->pwszReferenceTag = HeapAlloc(GetProcessHeap(), 0, size);
770 
771  if (!member->pwszReferenceTag)
772  {
774  goto error;
775  }
776  /* FIXME: reference tag is usually the file hash but doesn't have to be */
777  for (i = 0; i < member->pIndirectData->Digest.cbData; i++)
778  {
779  DWORD sub;
780 
781  sub = member->pIndirectData->Digest.pbData[i] >> 4;
782  member->pwszReferenceTag[i * 2] = (sub < 10 ? '0' + sub : 'A' + sub - 10);
783  sub = member->pIndirectData->Digest.pbData[i] & 0xf;
784  member->pwszReferenceTag[i * 2 + 1] = (sub < 10 ? '0' + sub : 'A' + sub - 10);
785  }
786  member->pwszReferenceTag[i * 2] = 0;
787  return member;
788 
789 error:
790  HeapFree(GetProcessHeap(), 0, member->pIndirectData);
791  HeapFree(GetProcessHeap(), 0, member->pwszReferenceTag);
793  return NULL;
794 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define error(str)
Definition: mkdosfs.c:1605
BOOL WINAPI CryptDecodeObject(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, void *pvStructInfo, DWORD *pcbStructInfo)
Definition: decode.c:6278
Definition: crypt.c:43
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
static MONITORINFO mi
Definition: win.c:7339
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
const GUID * guid
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
Definition: cookie.c:201
int ret
NTSYSAPI NTSTATUS WINAPI RtlGUIDFromString(PUNICODE_STRING, GUID *)
uint32_t entry
Definition: isohybrid.c:63
#define ERR(fmt,...)
Definition: debug.h:109
uint32_t cc
Definition: isohybrid.c:75
#define CRYPT_E_ATTRIBUTES_MISSING
Definition: winerror.h:2999
#define CRYPTCAT_MAGIC
Definition: crypt.c:40
#define HeapReAlloc
Definition: compat.h:401
#define CAT_MEMBERINFO_OBJID
Definition: wintrust.h:499
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define SPC_INDIRECT_DATA_OBJID
Definition: wintrust.h:481
Definition: wincrypt.h:723
#define HeapFree(x, y, z)
Definition: compat.h:402
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by CryptCATAdminEnumCatalogFromHash(), and InitFunctionPtrs().

◆ CryptCATGetAttrInfo()

CRYPTCATATTRIBUTE* WINAPI CryptCATGetAttrInfo ( HANDLE  ,
CRYPTCATMEMBER ,
LPWSTR   
)

Definition at line 563 of file crypt.c.

564 {
565  struct cryptcat *cc = hCatalog;
566 
567  FIXME("%p, %p, %s\n", hCatalog, member, debugstr_w(tag));
568 
569  if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
570  {
572  return NULL;
573  }
575  return NULL;
576 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007
Definition: crypt.c:43
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
Definition: ecma_167.h:138
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:417
uint32_t cc
Definition: isohybrid.c:75
#define CRYPTCAT_MAGIC
Definition: crypt.c:40

◆ CryptCATGetCatAttrInfo()

CRYPTCATATTRIBUTE* WINAPI CryptCATGetCatAttrInfo ( HANDLE  ,
LPWSTR   
)

Definition at line 581 of file crypt.c.

582 {
583  struct cryptcat *cc = hCatalog;
584 
585  FIXME("%p, %s\n", hCatalog, debugstr_w(tag));
586 
587  if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
588  {
590  return NULL;
591  }
593  return NULL;
594 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007
Definition: crypt.c:43
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
Definition: ecma_167.h:138
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:417
uint32_t cc
Definition: isohybrid.c:75
#define CRYPTCAT_MAGIC
Definition: crypt.c:40

◆ CryptCATGetMemberInfo()

CRYPTCATMEMBER* WINAPI CryptCATGetMemberInfo ( HANDLE  ,
LPWSTR   
)

Definition at line 596 of file crypt.c.

597 {
598  struct cryptcat *cc = hCatalog;
599 
600  FIXME("%p, %s\n", hCatalog, debugstr_w(tag));
601 
602  if (!hCatalog || hCatalog == INVALID_HANDLE_VALUE || cc->magic != CRYPTCAT_MAGIC)
603  {
605  return NULL;
606  }
608  return NULL;
609 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CRYPT_E_NOT_FOUND
Definition: winerror.h:3007
Definition: crypt.c:43
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
Definition: ecma_167.h:138
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:417
uint32_t cc
Definition: isohybrid.c:75
#define CRYPTCAT_MAGIC
Definition: crypt.c:40

◆ CryptCATOpen()

HANDLE WINAPI CryptCATOpen ( LPWSTR  ,
DWORD  ,
HCRYPTPROV  ,
DWORD  ,
DWORD   
)

Definition at line 854 of file crypt.c.

856 {
857  HANDLE file, hmsg;
858  BYTE *buffer = NULL;
860  struct cryptcat *cc;
861 
862  TRACE("%s, %x, %lx, %x, %x\n", debugstr_w(pwszFileName), fdwOpenFlags,
863  hProv, dwPublicVersion, dwEncodingType);
864 
865  if (!pwszFileName)
866  {
868  return INVALID_HANDLE_VALUE;
869  }
870 
872 
873  if (fdwOpenFlags & CRYPTCAT_OPEN_ALWAYS) flags |= OPEN_ALWAYS;
874  if (fdwOpenFlags & CRYPTCAT_OPEN_CREATENEW) flags |= CREATE_NEW;
875 
876  file = CreateFileW(pwszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, flags, 0, NULL);
878 
880  if (!(buffer = HeapAlloc(GetProcessHeap(), 0, size)))
881  {
882  CloseHandle(file);
884  return INVALID_HANDLE_VALUE;
885  }
886  if (!(hmsg = CryptMsgOpenToDecode(dwEncodingType, 0, 0, hProv, NULL, NULL)))
887  {
888  CloseHandle(file);
890  return INVALID_HANDLE_VALUE;
891  }
892  if (!ReadFile(file, buffer, size, &size, NULL) || !CryptMsgUpdate(hmsg, buffer, size, TRUE))
893  {
894  CloseHandle(file);
896  CryptMsgClose(hmsg);
897  return INVALID_HANDLE_VALUE;
898  }
900  CloseHandle(file);
901 
902  size = sizeof(DWORD);
903  if (!(cc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cc))))
904  {
905  CryptMsgClose(hmsg);
907  return INVALID_HANDLE_VALUE;
908  }
909 
910  cc->msg = hmsg;
911  cc->encoding = dwEncodingType;
912  if (CryptMsgGetParam(hmsg, CMSG_ATTR_CERT_COUNT_PARAM, 0, &cc->attr_count, &size))
913  {
914  DWORD i, sum = 0;
915  BYTE *p;
916 
917  for (i = 0; i < cc->attr_count; i++)
918  {
920  {
921  CryptMsgClose(hmsg);
922  HeapFree(GetProcessHeap(), 0, cc);
923  return INVALID_HANDLE_VALUE;
924  }
925  sum += size;
926  }
927  if (!(cc->attr = HeapAlloc(GetProcessHeap(), 0, sizeof(*cc->attr) * cc->attr_count + sum)))
928  {
929  CryptMsgClose(hmsg);
930  HeapFree(GetProcessHeap(), 0, cc);
932  return INVALID_HANDLE_VALUE;
933  }
934  p = (BYTE *)(cc->attr + cc->attr_count);
935  for (i = 0; i < cc->attr_count; i++)
936  {
938  {
939  CryptMsgClose(hmsg);
940  HeapFree(GetProcessHeap(), 0, cc->attr);
941  HeapFree(GetProcessHeap(), 0, cc);
942  return INVALID_HANDLE_VALUE;
943  }
944  if (!CryptMsgGetParam(hmsg, CMSG_ATTR_CERT_PARAM, i, p, &size))
945  {
946  CryptMsgClose(hmsg);
947  HeapFree(GetProcessHeap(), 0, cc->attr);
948  HeapFree(GetProcessHeap(), 0, cc);
949  return INVALID_HANDLE_VALUE;
950  }
951  p += size;
952  }
953  cc->inner = decode_inner_content(hmsg, dwEncodingType, &cc->inner_len);
954  if (!cc->inner || !CryptSIPRetrieveSubjectGuid(pwszFileName, NULL, &cc->subject))
955  {
956  CryptMsgClose(hmsg);
957  HeapFree(GetProcessHeap(), 0, cc->attr);
958  HeapFree(GetProcessHeap(), 0, cc->inner);
959  HeapFree(GetProcessHeap(), 0, cc);
960  return INVALID_HANDLE_VALUE;
961  }
962  cc->magic = CRYPTCAT_MAGIC;
963  return cc;
964  }
965  HeapFree(GetProcessHeap(), 0, cc);
966  return INVALID_HANDLE_VALUE;
967 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
#define CMSG_ATTR_CERT_COUNT_PARAM
Definition: wincrypt.h:3951
Definition: crypt.c:43
BOOL WINAPI CryptSIPRetrieveSubjectGuid(LPCWSTR FileName, HANDLE hFileIn, GUID *pgSubject)
Definition: sip.c:310
#define CMSG_ATTR_CERT_PARAM
Definition: wincrypt.h:3952
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
GLuint buffer
Definition: glext.h:5915
#define PKCS_7_ASN_ENCODING
Definition: wincrypt.h:2299
#define FILE_SHARE_READ
Definition: compat.h:125
static HCRYPTPROV hProv
Definition: rsaenh.c:32
HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags, DWORD dwMsgType, HCRYPTPROV_LEGACY hCryptProv, PCERT_INFO pRecipientInfo, PCMSG_STREAM_INFO pStreamInfo)
Definition: msg.c:3553
static DWORD
Definition: crypt.c:45
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
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
_In_ DWORD dwEncodingType
Definition: wincrypt.h:4625
#define debugstr_w
Definition: kernel32.h:32
#define CRYPTCAT_OPEN_CREATENEW
Definition: mscat.h:31
smooth NULL
Definition: ftsmooth.c:416
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
#define OPEN_EXISTING
Definition: compat.h:434
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
#define CRYPTCAT_OPEN_ALWAYS
Definition: mscat.h:32
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
#define SetLastError(x)
Definition: compat.h:417
#define OPEN_ALWAYS
Definition: disk.h:70
GLbitfield flags
Definition: glext.h:7161
unsigned char BYTE
Definition: mem.h:68
#define GENERIC_READ
Definition: compat.h:124
static CTL_INFO * decode_inner_content(HANDLE hmsg, DWORD encoding, DWORD *len)
Definition: crypt.c:796
uint32_t cc
Definition: isohybrid.c:75
#define CRYPTCAT_MAGIC
Definition: crypt.c:40
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define CreateFileW
Definition: compat.h:408
BOOL WINAPI CryptMsgClose(HCRYPTMSG hCryptMsg)
Definition: msg.c:3598
BOOL WINAPI CryptMsgUpdate(HCRYPTMSG hCryptMsg, const BYTE *pbData, DWORD cbData, BOOL fFinal)
Definition: msg.c:3617
BOOL WINAPI CryptMsgGetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex, void *pvData, DWORD *pcbData)
Definition: msg.c:3627
#define CREATE_NEW
Definition: disk.h:69
GLfloat GLfloat p
Definition: glext.h:8902
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define HeapFree(x, y, z)
Definition: compat.h:402
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
Definition: fci.c:126

Referenced by CryptCATAdminEnumCatalogFromHash(), and InitFunctionPtrs().