I'm going to write a simple algorithm provider under CNG (Cryptography Next Generation), exactly an user-mode Hash Provider.
According to the instruction in CNG Development Kit Help "A hash provider must implement the GetHashInterface
function and export it by name".
To implement an algorithm provider, I need to include the "bcrypt.h" file from the CNG Development Kit. This file also define the interface for GetHashInterface
function but WITHOUT an export
directive, exactly:
__checkReturn
NTSTATUS
WINAPI
GetHashInterface(
__in LPCWSTR pszProviderName,
__in LPCWSTR pszAlgId,
__out BCRYPT_HASH_FUNCTION_TABLE **ppFunctionTable,
__in ULONG dwFlags);
If I redefine the function in my header file as an exportable function, for example
#ifndef __CngHashProvider
#define __CngHashProvider
///////////////////////////////////////////////////////////////
#ifndef EXPORT
#define EXPORT extern "C" __declspec(dllexport)
#endif
EXPORT NTSTATUS WINAPI GetHashInterface(
__in LPCWSTR pszProviderName,
__in LPCWSTR pszAlgId,
__out BCRYPT_HASH_FUNCTION_TABLE **ppFunctionTable,
__in ULONG dwFlags
);
////////////////////////////////////////////////////////////////
#endif __CngHashProvider
I should get an error message:
Error C2375 'GetHashInterface': redefinition; different linkage
If I remove the EXPORT directive (or remove the whole of interface predefinition for the function), the error message should disappear, but the function can not be exported from my DLL.
So please help me, telling me the way to solve the problem to export the needed GetHashInterface
function.