Registering the New Functionality

Support for registering the new functionality in a system registry must be provided in the new DLL along with the new function. OID Support Functions provide assistance with this registration. Regsvr32.exe registers new functions. This tool is included with Windows.

The new DLL must provide DllRegisterServer and DllUnregisterServer entry points for use by Regsvr32.exe. CryptoAPI functions, such as CryptRegisterOIDFunction or CryptUnregisterOIDFunction, can be used within these entry points, as shown in the following example.

//  The DllRegisterServer Entry Point
STDAPI DllRegisterServer(void)
		 X509_ASN_ENCODING,                  // Encoding type
		 CRYPT_OID_ENCODE_OBJECT_FUNC,       // Function name
		 L"NewCert.dll",                     // Dll name
		 L"NewCertificateTypeEncodeObject"   // Override function
		 ))                                  //   name
		 return E_FAIL;
		 return S_OK;

// The DllUnregisterServer Entry Point
STDAPI DllUnregisterServer(void)
	HRESULT     hr = S_OK;

		  X509_ASN_ENCODING,             // Encoding type
		  CRYPT_OID_ENCODE_OBJECT_FUNC,  // Function name
	   if(ERROR_FILE_NOT_FOUND != GetLastError())
			   hr = E_FAIL;
	return hr;

This example must be compiled and linked into the new DLL. These two entry points, along with the function entry point, must be exported.

To install the new functionality on a computer, run Regsvr32.exe from a command prompt, specifying the name and path of the new DLL. Regsvr32.exe accesses the CryptRegisterOIDFunction function through the DllRegisterServer function entry point and registers the new function and DLL.