CryptRegisterOIDFunction

The CryptRegisterOIDFunction registers the Dll containing the function to be called for the specified encoding type, function name, and OID.

By default the functions are installed at the end of the list. To register the functions before the installed functions, call CryptSetOIDFunctionValue with dwValueType set to REG_DWORD and pwszValueName set to CRYPT_OID_REG_FLAGS_VALUE_NAME.

In addition to registering the DLL, you may override the name of the function to be called. For example,

pszFuncName = "CryptDllEncodeObject",

pszOverrideFuncName = "MyEncodeXyz".

This allows a Dll to export multiple OID functions for the same function name without needing to interpose its own OID dispatcher function.

CRYPT_OID_REG_FLAGS_VALUE_NAME is defined as L"CryptFlags"

#include <wincrypt.h>
BOOL WINAPI CryptRegisterOIDFunction(
  DWORD dwEncodingType,       // in
  LPCSTR pszFuncName,         // in
  LPCSTR pszOID,              // in
  LPCWSTR pwszDll,            // in
  LPCSTR pszOverrideFuncName  // in, optional
);
 

Parameters

dwEncodingType
The type of encoding specified. Note that either a certificate or message encoding type is required. If the low-order word containing the certificate encoding type is nonzero, then it is used. Otherwise, the high-order word containing the message encoding type is used. If both are specified, the certificate encoding type in the low-order word is used.

Currently defined encoding types are shown in the following table:
Encoding type Value
None 0x00000000
CRYPT_ASN_ENCODING 0x00000001
X509_ASN_ENCODING 0x00000001
PKCS_7_ASN_ENCODING 0x00010000

pszFuncName
The name of the function being registered.
pszOID
The OID correlating to the function to be registered. If the high-order word of the OID is non-zero, pszOID is a pointer to either an OID string, such as "2.5.29.1" or an ASCII string, such as "file". If the high-order word of the OID is zero, the low-order word specifies the numeric identifier to be used as the object identifier.
pwszDll
The name of the DLL to be registered should be passed in this parameter.

This parameter may contain environment-variable strings, which are expanded via ExpandEnvironmentStrings before loading the Dll.

pszOverrideFuncName
If pszOverrideFuncName is not NULL, this parameter specifies the name of the function exported in the Dll. If pszOverrideFuncName is NULL, then the function name specified by pszFuncName is exported in the Dll.

Return Values

TRUE if the function succeeded. FALSE if the function failed.

Call GetLastError to see the reason for any failures.

QuickInfo

  Windows NT: Requires version 4.0 SP3 or later. Available also in IE 3.02 and later.
  Windows: Requires Windows 98 (or Windows 95 with IE 3.02 or later).
  Windows CE: Unsupported.
  Header: Declared in wincrypt.h.
  Import Library: Use crypt32.lib.

See Also

CryptSetOIDFunctionValue