summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.h2
-rw-r--r--dll.cpp8
-rw-r--r--dll.h10
-rw-r--r--dlltest.cpp2
-rw-r--r--test.cpp4
5 files changed, 17 insertions, 9 deletions
diff --git a/config.h b/config.h
index 044ac21..6b61a48 100644
--- a/config.h
+++ b/config.h
@@ -264,11 +264,13 @@ NAMESPACE_END
#endif
#define CRYPTOPP_API __stdcall
+#define CRYPTOPP_CDECL _cdecl
#else // CRYPTOPP_WIN32_AVAILABLE
#define CRYPTOPP_DLL
#define CRYPTOPP_API
+#define CRYPTOPP_CDECL
#endif // CRYPTOPP_WIN32_AVAILABLE
diff --git a/dll.cpp b/dll.cpp
index d8638a9..63d5427 100644
--- a/dll.cpp
+++ b/dll.cpp
@@ -6,7 +6,9 @@
#include "dll.h"
#pragma warning(default: 4660)
+#ifdef CRYPTOPP_WIN32_AVAILABLE
#include <windows.h>
+#endif
#include "iterhash.cpp"
#include "strciphr.cpp"
@@ -23,13 +25,19 @@ template<> const byte PKCS_DigestDecoration<SHA>::decoration[] = {0x30,0x21,0x30
template<> const unsigned int PKCS_DigestDecoration<SHA>::length = sizeof(PKCS_DigestDecoration<SHA>::decoration);
static const byte s_moduleMac[CryptoPP::HMAC<CryptoPP::SHA1>::DIGESTSIZE] = "reserved for mac";
+#ifdef CRYPTOPP_WIN32_AVAILABLE
static HMODULE s_hModule = NULL;
+#endif
void DoDllPowerUpSelfTest()
{
+#ifdef CRYPTOPP_WIN32_AVAILABLE
char moduleFileName[MAX_PATH];
GetModuleFileNameA(s_hModule, moduleFileName, sizeof(moduleFileName));
CryptoPP::DoPowerUpSelfTest(moduleFileName, s_moduleMac);
+#else
+ throw NotImplemented("DoDllPowerUpSelfTest() only available on Windows");
+#endif
}
NAMESPACE_END
diff --git a/dll.h b/dll.h
index 50ec948..4bf44ee 100644
--- a/dll.h
+++ b/dll.h
@@ -55,11 +55,11 @@ NAMESPACE_BEGIN(CryptoPP)
using std::new_handler;
#endif
-typedef void * (_cdecl * PNew)(size_t);
-typedef void (_cdecl * PDelete)(void *);
-typedef void (_cdecl * PGetNewAndDelete)(PNew &, PDelete &);
-typedef new_handler (_cdecl * PSetNewHandler)(new_handler);
-typedef void (_cdecl * PSetNewAndDelete)(PNew, PDelete, PSetNewHandler);
+typedef void * (CRYPTOPP_CDECL * PNew)(size_t);
+typedef void (CRYPTOPP_CDECL * PDelete)(void *);
+typedef void (CRYPTOPP_CDECL * PGetNewAndDelete)(PNew &, PDelete &);
+typedef new_handler (CRYPTOPP_CDECL * PSetNewHandler)(new_handler);
+typedef void (CRYPTOPP_CDECL * PSetNewAndDelete)(PNew, PDelete, PSetNewHandler);
CRYPTOPP_DLL void DoDllPowerUpSelfTest();
diff --git a/dlltest.cpp b/dlltest.cpp
index c74cbe7..5a49513 100644
--- a/dlltest.cpp
+++ b/dlltest.cpp
@@ -173,7 +173,7 @@ void FIPS140_SampleApplication()
#ifdef CRYPTOPP_DLL_ONLY
-int __cdecl main()
+int CRYPTOPP_CDECL main()
{
FIPS140_SampleApplication();
return 0;
diff --git a/test.cpp b/test.cpp
index 39699e0..de7fdaf 100644
--- a/test.cpp
+++ b/test.cpp
@@ -85,10 +85,8 @@ int (*AdhocTest)(int argc, char *argv[]) = NULL;
#ifdef __BCPLUSPLUS__
int cmain(int argc, char *argv[])
-#elif defined(_MSC_VER)
-int __cdecl main(int argc, char *argv[])
#else
-int main(int argc, char *argv[])
+int CRYPTOPP_CDECL main(int argc, char *argv[])
#endif
{
#ifdef _CRTDBG_LEAK_CHECK_DF