' ########################################################################################
' Microsoft Windows
' File: mscat.inc
' Contents: Microsoft Internet Security Catalog API
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_mscat_PBI)
#DEFINE PBX_mscat_PBI
%EQUATE `MSCAT_INC = 1
#INCLUDE ONCE "Core/Windows.inc"
#INCLUDE ONCE "Legacy/Platform/WinCrypt.inc"
#INCLUDE ONCE "Legacy/System/mssip.inc"
'/////////////////////////////////////////////////////////////////////////////
'//
'// defines:
'//
'/////////////////////////////////////////////////////////////////////////////
$szOID_CATALOG_LIST = "1.3.6.1.4.1.311.12.1.1"
$szOID_CATALOG_LIST_MEMBER = "1.3.6.1.4.1.311.12.1.2"
$$CRYPTCAT_FILEEXT = "CAT"$$
%EQUATE `CRYPTCAT_MAX_MEMBERTAG = 64
'//
'// fdwOpenFlags
'//
%EQUATE `CRYPTCAT_OPEN_CREATENEW = &H00000001 ' // creates/overwrites
%EQUATE `CRYPTCAT_OPEN_ALWAYS = &H00000002 ' // opens/creates
%EQUATE `CRYPTCAT_OPEN_EXISTING = &H00000004 ' // opens only
%EQUATE `CRYPTCAT_OPEN_EXCLUDE_PAGE_HASHES = &H00010000 ' // Exclude page hashes in SPC_INDIRECT_DATA
'// The above CRYPTCAT_OPEN_EXCLUDE_PAGE_HASHES takes precedence if also set.
%EQUATE `CRYPTCAT_OPEN_INCLUDE_PAGE_HASHES = &H00020000 ' // Include page hashes in SPC_INDIRECT_DATA
%EQUATE `CRYPTCAT_OPEN_VERIFYSIGHASH = &H10000000 ' // verifies the signature (not the certs!)
%EQUATE `CRYPTCAT_OPEN_NO_CONTENT_HCRYPTMSG = &H20000000 ' // does CryptMsgDecode without content
%EQUATE `CRYPTCAT_OPEN_SORTED = &H40000000 ' // does CertCreateContext(CERT_CREATE_CONTEXT_SORTED_FLAG)
%EQUATE `CRYPTCAT_OPEN_FLAGS_MASK = &Hffff0000 ' // mask for upper word
'//
'// fdwMemberFlags (used internal -- do not fill)
'//
%EQUATE `CRYPTCAT_MEMBER_SORTED = &H40000000
'//
'// dwAttrTypeAndAction
'//
%EQUATE `CRYPTCAT_ATTR_AUTHENTICATED = &H10000000
%EQUATE `CRYPTCAT_ATTR_UNAUTHENTICATED = &H20000000
%EQUATE `CRYPTCAT_ATTR_NAMEASCII = &H00000001 ' // ascii string
%EQUATE `CRYPTCAT_ATTR_NAMEOBJID = &H00000002 ' // crypt obj id
%EQUATE `CRYPTCAT_ATTR_DATAASCII = &H00010000 ' // do not decode simple ascii chars
%EQUATE `CRYPTCAT_ATTR_DATABASE64 = &H00020000 ' // base 64
%EQUATE `CRYPTCAT_ATTR_DATAREPLACE = &H00040000 ' // this data is a replacment for an existing attr
'//
'// dwLocalError - CDF Parse
'//
%EQUATE `CRYPTCAT_E_AREA_HEADER = &H00000000
%EQUATE `CRYPTCAT_E_AREA_MEMBER = &H00010000
%EQUATE `CRYPTCAT_E_AREA_ATTRIBUTE = &H00020000
%EQUATE `CRYPTCAT_E_CDF_UNSUPPORTED = &H00000001
%EQUATE `CRYPTCAT_E_CDF_DUPLICATE = &H00000002
%EQUATE `CRYPTCAT_E_CDF_TAGNOTFOUND = &H00000004
%EQUATE `CRYPTCAT_E_CDF_MEMBER_FILE_PATH = &H00010001
%EQUATE `CRYPTCAT_E_CDF_MEMBER_INDIRECTDATA = &H00010002
%EQUATE `CRYPTCAT_E_CDF_MEMBER_FILENOTFOUND = &H00010004
%EQUATE `CRYPTCAT_E_CDF_BAD_GUID_CONV = &H00020001
%EQUATE `CRYPTCAT_E_CDF_ATTR_TOOFEWVALUES = &H00020002
%EQUATE `CRYPTCAT_E_CDF_ATTR_TYPECOMBO = &H00020004
'/////////////////////////////////////////////////////////////////////////////
'//
'// structures:
'//
'/////////////////////////////////////////////////////////////////////////////
'#include <pshpack8.h>
' Also declared in mssip.inc
#IF NOT %DEF(%SIP_INDIRECT_DATA_DEFINED)
%EQUATE `SIP_INDIRECT_DATA_DEFINED = 1
' // Size = 32 bytes
TYPE SIP_INDIRECT_DATA DWORD
 Data AS CRYPT_ATTRIBUTE_TYPE_VALUE
 DigestAlgorithm AS CRYPT_ALGORITHM_IDENTIFIER
 Digest AS CRYPT_HASH_BLOB
END TYPE
#ENDIF
' Also declared in mssip.inc
#IF NOT %DEF(%CRYPTCATSTORE_DEFINED)
%EQUATE `CRYPTCATSTORE_DEFINED = 1
' // Size = 40 bytes
TYPE CRYPTCATSTORE DWORD
 cbStruct AS DWORD ' DWORD // = sizeof(CRYPTCATSTORE)
 dwPublicVersion AS DWORD
 pwszP7File AS WSTRINGZ PTR
 hProv AS DWORD ' HCRYPTPROV
 dwEncodingType AS DWORD
 fdwStoreFlags AS DWORD
 hReserved AS DWORD ' HANDLE // pStack(members) (null if init/pbData) INTERNAL!
 hAttrs AS DWORD ' HANDLE // pStack(Catalog attrs) INTERNAL!
 ' // Following is only set if opened with CRYPTCAT_OPEN_NO_CONTENT_HCRYPTMSG
 hCryptMsg AS DWORD ' HCRYPTMSG
 ' // Following is only set if opened with CRYPTCAT_OPEN_SORTED
 hSorted AS DWORD ' HANDLE // INTERNAL ONLY!
END TYPE
#ENDIF
' Also declared in mssip.inc
#IF NOT %DEF(%CRYPTCATMEMBER_DEFINED)
%EQUATE `CRYPTCATMEMBER_DEFINED = 1
' // Size = 64 bytes
TYPE CRYPTCATMEMBER DWORD
 cbStruct AS DWORD ' DWORD // = sizeof(CRYPTCATMEMBER)
 pwszReferenceTag AS WSTRINGZ PTR
 pwszFileName AS WSTRINGZ PTR ' LPWSTR // used only by the CDF APIs
 gSubjectType AS GUID ' GUID // may be zeros -- see sEncodedMemberInfo
 fdwMemberFlags AS DWORD
 pIndirectData AS SIP_INDIRECT_DATA PTR ' struct SIP_INDIRECT_DATA_* // may be null -- see sEncodedIndirectData
 dwCertVersion AS DWORD ' DWORD // may be zero -- see sEncodedMemberInfo
 dwReserved AS DWORD ' DWORD // used by enum -- DO NOT USE!
 hReserved AS DWORD ' HANDLE // pStack(attrs) (null if init) INTERNAL!
 sEncodedIndirectData AS CRYPT_ATTR_BLOB ' CRYPT_ATTR_BLOB // lazy decode
 sEncodedMemberInfo AS CRYPT_ATTR_BLOB ' CRYPT_ATTR_BLOB // lazy decode
END TYPE
#ENDIF
' // Size = 24 bytes
TYPE CRYPTCATATTRIBUTE DWORD
 cbStruct AS DWORD ' DWORD // = sizeof(CRYPTCATATTRIBUTE)
 pwszReferenceTag AS WSTRINGZ PTR
 dwAttrTypeAndAction AS DWORD
 cbValue AS DWORD
 pbValue AS BYTE PTR ' BYTE* // encoded CAT_NAMEVALUE struct
 dwReserved AS DWORD ' DWORD // used by enum -- DO NOT USE!
END TYPE
' // Size = 28 bytes
TYPE CRYPTCATCDF DWORD
 cbStruct AS DWORD ' DWORD // = sizeof(CRYPTCATCDF)
 hFile AS DWORD
 dwCurFilePos AS DWORD
 dwLastMemberOffset AS DWORD
 fEOF AS LONG
 pwszResultDir AS WSTRINGZ PTR
 hCATStore AS DWORD
END TYPE
' // Size = 524 bytes
TYPE CATALOG_INFO DWORD
 cbStruct AS DWORD ' DWORD // set to sizeof(CATALOG_INFO)
 wszCatalogFile AS WSTRINGZ * %MAX_PATH ' WCHAR
END TYPE
'typedef HANDLE HCATADMIN;
'typedef HANDLE HCATINFO;
'#include <poppack.h>
'typedef void (WINAPI *PFN_CDF_PARSE_ERROR_CALLBACK)(IN DWORD dwErrorArea,
' IN DWORD dwLocalError,
' IN WCHAR *pwszLine);
'SUB CDF_PARSE_ERROR_CALLBACK (BYVAL dwErrorArea AS DWORD, BYVAL dwLocalError AS DWORD, BYVAL pwszLine AS DWORD)
'/////////////////////////////////////////////////////////////////////////////
'//
'// Prototypes:
'//
'/////////////////////////////////////////////////////////////////////////////
'/////////////////////////////////////////////////////////////////////////////
'//
'// Open:
'// --------------------------------------------------------------------------
'// Usage:
'// open the catalog for Get/Put operations.
'//
'// Return:
'// INVALID_HANDLE_VALUE: an error occured while opening Catalog
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATOpen LIB "wintrust.dll" ALIAS "CryptCATOpen" ( BYREF pwszFileName AS WSTRINGZ , BYVAL fdwOpenFlags AS QUAD , BYVAL hProv AS QUAD , BYVAL dwPublicVersion AS QUAD , BYVAL dwEncodingType AS QUAD ) AS QUAD
'/////////////////////////////////////////////////////////////////////////////
'//
'// Close:
'// --------------------------------------------------------------------------
'// Usage:
'// close the catalog handle.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATClose LIB "wintrust.dll" ALIAS "CryptCATClose" ( BYVAL hCatalog AS QUAD ) AS LONG
'// WOB #1496767
'/////////////////////////////////////////////////////////////////////////////
'//
'// Set or clear page-hashes bit:
'// --------------------------------------------------------------------------
'// Usage:
'// set a new value into the bit that suppresses page-hash generation.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATSetCreatePageHashesFlag LIB "wintrust.dll" ALIAS "CryptCATSetCreatePageHashesFlag" ( BYVAL hCatalog AS QUAD , BYVAL newCreatePageHashesFlag AS LONG ) AS LONG
'/////////////////////////////////////////////////////////////////////////////
'//
'// StoreFromHandle:
'// --------------------------------------------------------------------------
'// Usage:
'// retrieve the CRYPTCATSTORE from the store handle.
'//
'// *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATStoreFromHandle LIB "wintrust.dll" ALIAS "CryptCATStoreFromHandle" ( BYVAL hCatalog AS QUAD ) AS QUAD ' CRYPTCATSTORE*
'/////////////////////////////////////////////////////////////////////////////
'//
'// HandleFromStore:
'// --------------------------------------------------------------------------
'// Usage:
'// retrieve the handle from a CRYPTCATSTORE pointer.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATHandleFromStore LIB "wintrust.dll" ALIAS "CryptCATHandleFromStore" ( BYREF pCatStore AS CRYPTCATSTORE ) AS QUAD
'/////////////////////////////////////////////////////////////////////////////
'//
'// PersistStore
'// --------------------------------------------------------------------------
'// Usage:
'// Persist the information in the current Catalog Store to an unsigned
'// Catalog File. It is REQUIRED to fill in the pwszP7File member
'// of CRYPTCATSTORE prior to this call!
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATPersistStore LIB "wintrust.dll" ALIAS "CryptCATPersistStore" ( BYVAL hCatalog AS QUAD ) AS LONG
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATGetCatAttrInfo
'// --------------------------------------------------------------------------
'// Usage:
'//
'// *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATGetCatAttrInfo LIB "wintrust.dll" ALIAS "CryptCATGetCatAttrInfo" ( BYVAL hCatalog AS QUAD , BYREF pwszReferenceTag AS WSTRINGZ ) AS QUAD ' CRYPTCATATTRIBUTE*
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATPutCatAttrInfo
'// --------------------------------------------------------------------------
'// Usage:
'// Allocates and adds the attribute to the catalog. Returns a pointer
'// to the allocated attribute.
'//
'// *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATPutCatAttrInfo LIB "wintrust.dll" ALIAS "CryptCATPutCatAttrInfo" ( BYVAL hCatalog AS QUAD , BYREF pwszReferenceTag AS WSTRINGZ , BYVAL dwAttrTypeAndAction AS QUAD , BYVAL cbData AS QUAD , BYVAL pbData AS BYTE PTR ) AS QUAD ' CRYPTCATATTRIBUTE*
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATEnumerateCatAttr
'// --------------------------------------------------------------------------
'// Usage:
'// Enumerates through the list of attributes associated with the catalog.
'// Returns a pointer to the attribute. This return should be passed in
'// as the 'PrevAttr' to continue the enumeration. On the first call,
'// the 'PrevAttr' should be set to NULL.
'//
'// *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATEnumerateCatAttr LIB "wintrust.dll" ALIAS "CryptCATEnumerateCatAttr" ( BYVAL hCatalog AS QUAD , BYREF pPrevAttr AS CRYPTCATATTRIBUTE ) AS QUAD ' CRYPTCATATTRIBUTE*
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATGetMemberInfo
'// --------------------------------------------------------------------------
'// Usage:
'// Retrieve the Tag info (member info) structure from the catalog
'// PKCS#7, fill the CRYPTCATMEMBER structure, and return. -- Opens a
'// member context.
'//
'// *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATGetMemberInfo LIB "wintrust.dll" ALIAS "CryptCATGetMemberInfo" ( BYVAL hCatalog AS QUAD , BYREF pwszReferenceTag AS WSTRINGZ ) AS QUAD ' CRYPTCATMEMBER*
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATAllocSortedMemberInfo
'// --------------------------------------------------------------------------
'// Usage:
'// If CryptCATOpen is called with CRYPTCAT_OPEN_SORTED, this function
'// must be called instead of the above CryptCATGetMemberInfo().
'//
'// The returned member context must be freed by calling
'// CryptCATFreeSortedMemberInfo()
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATAllocSortedMemberInfo LIB "wintrust.dll" ALIAS "CryptCATAllocSortedMemberInfo" ( BYVAL hCatalog AS QUAD , BYREF pwszReferenceTag AS WSTRINGZ ) AS QUAD ' CRYPTCATMEMBER*
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATFreeSortedMemberInfo
'// --------------------------------------------------------------------------
'// Usage:
'// Free member context returned by the above
'// CryptCATAllocSortedMemberInfo().
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE SUB CryptCATFreeSortedMemberInfo LIB "wintrust.dll" ALIAS "CryptCATFreeSortedMemberInfo" ( BYVAL hCatalog AS QUAD , BYREF pCatMember AS CRYPTCATMEMBER ) ' void
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATGetAttr:
'// --------------------------------------------------------------------------
'// Usage:
'// get pwszReferenceTag attribute information for a member.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATGetAttrInfo LIB "wintrust.dll" ALIAS "CryptCATGetAttrInfo" ( BYVAL hCatalog AS QUAD , BYREF pCatMember AS CRYPTCATMEMBER , BYREF pwszReferenceTag AS WSTRINGZ ) AS QUAD ' CRYPTCATATTRIBUTE*
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATPutMemberInfo
'// --------------------------------------------------------------------------
'// Usage:
'// Allocates and adds the member to the catalog. Returns a pointer
'// to the allocated member.
'//
'// *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'// CRYPT_E_EXISTS: the reference tag already exists
'// CRYPT_E_NOT_FOUND: the attr was not found
'//
DECLARE FUNCTION CryptCATPutMemberInfo LIB "wintrust.dll" ALIAS "CryptCATPutMemberInfo" ( BYVAL hCatalog AS QUAD , BYREF pwszFileName AS WSTRINGZ , BYREF pwszReferenceTag AS WSTRINGZ , BYREF pgSubjectType AS GUID , BYVAL dwCertVersion AS QUAD , BYVAL cbSIPIndirectData AS QUAD , BYVAL pbSIPIndirectData AS BYTE PTR ) AS QUAD ' CRYPTCATMEMBER*
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATPutAttrInfo
'// --------------------------------------------------------------------------
'// Usage:
'// Allocates and adds the attribute to the member. Returns a pointer
'// to the allocated attribute.
'//
'// *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATPutAttrInfo LIB "wintrust.dll" ALIAS "CryptCATPutAttrInfo" ( BYVAL hCatalog AS QUAD , BYREF pCatMember AS CRYPTCATMEMBER , BYREF pwszReferenceTag AS WSTRINGZ , BYVAL dwAttrTypeAndAction AS QUAD , BYVAL cbData AS QUAD , BYVAL pbData AS BYTE PTR ) AS QUAD ' CRYPTCATATTRIBUTE*
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATEnumerateMember
'// --------------------------------------------------------------------------
'// Usage:
'// Enumerates through the list of members in the store. Returns a pointer
'// to the member. This return should be passed in as the 'PrevMember' to
'// continue the enumeration. On the first call, the 'PrevMember' should
'// be set to NULL.
'//
'// *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATEnumerateMember LIB "wintrust.dll" ALIAS "CryptCATEnumerateMember" ( BYVAL hCatalog AS QUAD , BYREF pPrevMember AS CRYPTCATMEMBER ) AS QUAD ' CRYPTCATMEMBER*
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATEnumerateAttr
'// --------------------------------------------------------------------------
'// Usage:
'// Enumerates through the list of attributes associated with the member.
'// Returns a pointer to the attribute. This return should be passed in
'// as the 'PrevAttr' to continue the enumeration. On the first call,
'// the 'PrevAttr' should be set to NULL.
'//
'// *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATEnumerateAttr LIB "wintrust.dll" ALIAS "CryptCATEnumerateAttr" ( BYVAL hCatalog AS QUAD , BYREF pCatMember AS CRYPTCATMEMBER , BYREF pPrevAttr AS CRYPTCATATTRIBUTE ) AS QUAD ' CRYPTCATATTRIBUTE*
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATCDFOpen
'// --------------------------------------------------------------------------
'// Usage:
'// Opens the specified CDF file and initialized the structure
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'// ERROR_FILE_NOT_FOUND: the CDF file was not found
'//
DECLARE FUNCTION CryptCATCDFOpen LIB "wintrust.dll" ALIAS "CryptCATCDFOpen" ( BYREF pwszFilePath AS WSTRINGZ , BYVAL pfnParseError AS QUAD ) AS QUAD ' CRYPTCATCDF*
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATCDFClose
'// --------------------------------------------------------------------------
'// Usage:
'// Closes the CDF file and deallocates the structure
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATCDFClose LIB "wintrust.dll" ALIAS "CryptCATCDFClose" ( BYREF pCDF AS CRYPTCATCDF ) AS LONG
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATCDFEnumCatAttributes
'// --------------------------------------------------------------------------
'// Usage:
'// Enumerates Catalog level attributes within the "[CatalogFiles]"
'// section of the CDF.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATCDFEnumCatAttributes LIB "wintrust.dll" ALIAS "CryptCATCDFEnumCatAttributes" ( BYREF pCDF AS CRYPTCATCDF , BYREF pPrevAttr AS CRYPTCATATTRIBUTE , BYVAL pfnParseError AS QUAD ) AS QUAD ' CRYPTCATATTRIBUTE*
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATCDFEnumMembers
'// --------------------------------------------------------------------------
'// Usage:
'// Enumerates files within the "[CatalogFiles]" section of the CDF.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATCDFEnumMembers LIB "wintrust.dll" ALIAS "CryptCATCDFEnumMembers" ( BYREF pCDF AS CRYPTCATCDF , BYREF pPrevMember AS CRYPTCATMEMBER , BYVAL pfnParseError AS QUAD ) AS QUAD ' CRYPTCATMEMBER*
'/////////////////////////////////////////////////////////////////////////////
'//
'// CryptCATCDFEnumAttributes
'// --------------------------------------------------------------------------
'// Usage:
'// Enumerates the files attributes within the "[CatalogFiles]" section
'// of the CDF.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
DECLARE FUNCTION CryptCATCDFEnumAttributes LIB "wintrust.dll" ALIAS "CryptCATCDFEnumAttributes" ( BYREF pCDF AS CRYPTCATCDF , BYREF pPrevMember AS CRYPTCATMEMBER , BYREF pPrevAttr AS CRYPTCATATTRIBUTE , BYVAL pfnParseError AS QUAD ) AS QUAD ' CRYPTCATATTRIBUTE*
'//////////////////////////////////////////////////////////////////////////
'//
'// IsCatalogFile
'// --------------------------------------------------------------------------
'// Usage:
'// Call this function to determine if the file is a Catalog File. Both
'// parameters are optional. HOWEVER, one of them MUST be passed!
'//
'// Return:
'// TRUE if it is.
'// FALSE if it isn't or an error occured.
'//
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'// ERROR_NOT_ENOUGH_MEMORY: a memory allocation failed
'// {file errors} a file error occured
'//
DECLARE FUNCTION IsCatalogFile LIB "wintrust.dll" ALIAS "IsCatalogFile" ( BYVAL hFile AS QUAD , BYVAL pwszFileName AS QUAD ) AS LONG
'//////////////////////////////////////////////////////////////////////////
'//
'// CryptCATAdminAcquireContext
'// --------------------------------------------------------------------------
'// Usage:
'// Opens a new Admin Context based on the pgSubsystem Id.
'//
'// the Guid passed in will be converted to a string and used as the
'// sub-directory under %SystemRoot%\CatRoot to store all Catalog files
'// for this app/sub-system.
'//
'// if a NULL is passed in to the pgSubsystem parameter, all finds will be
'// "global" and any Adds will be under the "default" Subsystem.
'//
'// Return:
'// TRUE if phCatAdmin points to a valid context.
'// FALSE if an error occurs.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'// ERROR_NOT_ENOUGH_MEMORY: a memory allocation failed
'// ERROR_DATABASE_FAILURE: an error occured while processing
'// the database.
'//
'// Comments:
'// The dwFlags parameter is reserved for future use. Must
'// be set to NULL.
'//
'//
DECLARE FUNCTION CryptCATAdminAcquireContext LIB "wintrust.dll" ALIAS "CryptCATAdminAcquireContext" ( BYREF phCatAdmin AS QUAD , BYREF pgSubsystem AS GUID , BYVAL dwFlags AS QUAD ) AS LONG
'//////////////////////////////////////////////////////////////////////////
'//
'// CryptCATAdminReleaseContext
'// --------------------------------------------------------------------------
'// Usage:
'// Releases (frees) all information related to the Admin Context
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
'// Comments:
'// The dwFlags parameter is reserved for future use. Must
'// be set to NULL.
'//
DECLARE FUNCTION CryptCATAdminReleaseContext LIB "wintrust.dll" ALIAS "CryptCATAdminReleaseContext" ( BYVAL hCatAdmin AS QUAD , BYVAL dwFlags AS QUAD ) AS LONG
'//////////////////////////////////////////////////////////////////////////
'//
'// CryptCATAdminReleaseCatalogContext
'// -----------------------------------------------------------------------
'// Usage:
'// Call this function to release memory associated with the Catalog
'// Info Context.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
'// Comments:
'// the dwFlags parameter is reserved for future use and must be assigned
'// to NULL.
'//
DECLARE FUNCTION CryptCATAdminReleaseCatalogContext LIB "wintrust.dll" ALIAS "CryptCATAdminReleaseCatalogContext" ( BYVAL hCatAdmin AS QUAD , BYVAL hCatInfo AS QUAD , BYVAL dwFlags AS QUAD ) AS LONG
'//////////////////////////////////////////////////////////////////////////
'//
'// CryptCATAdminEnumCatalogFromHash
'// --------------------------------------------------------------------------
'// Usage:
'// Call this function to retrieve the Catalog Info handle of the Catalog
'// file that currently "points" to the specified Member Hash.
'//
'// if hCatInfo is NULL, the first catalog found that contains the
'// hash will be returned.
'//
'// if hCatInfo is not NULL, the content must be initialized to NULL prior
'// to going into the enum loop -- this starts the first/next search.
'// This function uses this parameter to determine the last catalog returned.
'//
'// if hCatInfo is not NULL, and the loop is terminated prior to this
'// function returning NULL, the application must call
'// CryptCATAdminReleaseCatalogContext to free all memory associated with
'// ppPrevContext.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'// ERROR_NOT_ENOUGH_MEMORY: a memory allocation failed
'// ERROR_DATABASE_FAILURE: an error occurred while processing
'// the database.
'//
DECLARE FUNCTION CryptCATAdminEnumCatalogFromHash LIB "wintrust.dll" ALIAS "CryptCATAdminEnumCatalogFromHash" ( BYVAL hCatAdmin AS QUAD , BYVAL pbHash AS BYTE PTR , BYVAL cbHash AS QUAD , BYVAL dwFlags AS QUAD , BYREF phPrevCatInfo AS QUAD ) AS QUAD ' HCATINFO
'//////////////////////////////////////////////////////////////////////////
'//
'// CryptCATAdminCalcHashFromFileHandle
'// --------------------------------------------------------------------------
'// Usage:
'// Call this function to calculate the has based on an open file handle.
'//
'// Return:
'// TRUE if the pbHash was filled with the calculated hash.
'// FALSE if an error occured
'//
'// To obtain the size required for pbHash, set pbHash to NULL. The
'// correct size will be returned in pcbHash, the return value will
'// be TRUE and a call to GetLastError() will equal ERROR_INSUFFICIENT_BUFFER.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'// ERROR_INSUFFICIENT_BUFFER: the *pbHash was not big enough.
'// ERROR_NOT_ENOUGH_MEMORY: a memory allocation failed
'//
'// Comments:
'// the dwFlags parameter is reserved for future use and must be assigned
'// to NULL.
'//
DECLARE FUNCTION CryptCATAdminCalcHashFromFileHandle LIB "wintrust.dll" ALIAS "CryptCATAdminCalcHashFromFileHandle" ( BYVAL hFile AS QUAD , BYREF pcbHash AS QUAD , BYVAL pbHash AS BYTE PTR , BYVAL dwFlags AS QUAD ) AS LONG
'//////////////////////////////////////////////////////////////////////////
'//
'// CryptCATAdminAddCatalog
'// --------------------------------------------------------------------------
'// Usage:
'// Call this function to add a catalog file to the CAT Maintenance
'// subsystem.
'//
'// if the pwszSelectedBaseName is NULL, the Catalog Admin system will
'// generate a file base name for you. Otherwise, this parameter is
'// used as the file name (base & extension only) of the copied Catalog
'// file.
'//
'// Call CryptCATAdminReleaseCatalogContext to free the memory associated
'// with the Catalog Context returned if not NULL.
'//
'// Return:
'// On success, the HCATINFO of the catalog that was successfully added
'// is returned. On failure, NULL is returned.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'// ERROR_NOT_ENOUGH_MEMORY: a memory allocation failed
'// ERROR_BAD_FORMAT: the file is not a catalog file.
'// ERROR_DATABASE_FAILURE: an error occurred while processing
'// the database.
'//
'// Comments:
'// the dwFlags parameter is reserved for future use and must be assigned
'// to NULL.
'//
DECLARE FUNCTION CryptCATAdminAddCatalog LIB "wintrust.dll" ALIAS "CryptCATAdminAddCatalog" ( BYVAL hCatAdmin AS QUAD , BYVAL pwszCatalogFile AS QUAD , BYVAL pwszSelectBaseName AS QUAD , BYVAL dwFlags AS QUAD ) AS QUAD ' HCATINFO
'//////////////////////////////////////////////////////////////////////////
'//
'// CryptCATAdminRemoveCatalog
'// --------------------------------------------------------------------------
'// Usage:
'// Call this function to remove a catalog file from the CAT Maintenance
'// subsystem.
'//
'// Return:
'// On success, TRUE is returned. FALSE if an error occurs.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
'// Comments:
'// pwszCatalogFile must point to a string that contains only the name
'// of the catalog file, ex. "foo.cat", and not a fully qualified path
'// name
'//
DECLARE FUNCTION CryptCATAdminRemoveCatalog LIB "wintrust.dll" ALIAS "CryptCATAdminRemoveCatalog" ( BYVAL hCatAdmin AS QUAD , BYREF pwszCatalogFile AS WSTRINGZ , BYVAL dwFlags AS QUAD ) AS LONG
'//////////////////////////////////////////////////////////////////////////
'//
'// CryptCATCatalogInfoFromContext
'// --------------------------------------------------------------------------
'// Usage:
'// call this function to retrieve information relating to the
'// Catalog info handle passed from the Add Catalog function.
'//
'// Return:
'// On success, TRUE is returned and the CATALOG_INFO structure
'// is filled in.
'// FALSE if an error occurs.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'//
'// Comments:
'// the dwFlags parameter is reserved for future use and must be assigned
'// to NULL.
'//
DECLARE FUNCTION CryptCATCatalogInfoFromContext LIB "wintrust.dll" ALIAS "CryptCATCatalogInfoFromContext" ( BYVAL hCatInfo AS QUAD , BYREF psCatInfo AS CATALOG_INFO , BYVAL dwFlags AS QUAD ) AS LONG
'//////////////////////////////////////////////////////////////////////////
'//
'// CryptCATAdminResolveCatalogPath
'// --------------------------------------------------------------------------
'// Usage:
'// call this function to retrieve the fully qualified path to the
'// catalog specified by pwszCatalogFile
'//
'// Return:
'// On success, TRUE is returned and the CATALOG_INFO structure
'// is filled in.
'// FALSE if an error occurs.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'// ERROR_NOT_ENOUGH_MEMORY: if the fully qualified path is longer
'// than MAX_PATH
'//
'// Comments:
'// the dwFlags parameter is reserved for future use and must be assigned
'// to NULL.
'//
DECLARE FUNCTION CryptCATAdminResolveCatalogPath LIB "wintrust.dll" ALIAS "CryptCATAdminResolveCatalogPath" ( BYVAL hCatAdmin AS QUAD , BYVAL pwszCatalogFile AS QUAD , BYREF psCatInfo AS CATALOG_INFO , BYVAL dwFlags AS QUAD ) AS LONG
'//////////////////////////////////////////////////////////////////////////
'//
'// CryptCATAdminPauseServiceForBackup
'// --------------------------------------------------------------------------
'// Usage:
'// call this function to pause the catalog sub-system in preparation
'// for backing up the catalog sub-systems files.
'//
'// Return:
'// On success, TRUE is returned. FALSE if an error occurs.
'//
'// Errors:
'// ERROR_INVALID_PARAMETER: an input parameter is incorrect
'// ERROR_TIMEOUT: if clients are accessing database files
'// and fail to relinquish them in a timely
'// manner.
'//
'// Comments:
'// the dwFlags parameter is reserved for future use and must be assigned
'// to NULL. Set fResume to FALSE when pausing the catalog service, and
'// set it to TRUE to resume service.
'//
DECLARE FUNCTION CryptCATAdminPauseServiceForBackup LIB "wintrust.dll" ALIAS "CryptCATAdminPauseServiceForBackup" ( BYVAL dwFlags AS QUAD , BYVAL fResume AS LONG ) AS LONG
#ENDIF
