Fix Windows compilation issues (by RaptorFactor) (#444)
* Fix compilation on Windows with /DUNICODE * Fix linking of fipstest for MSVC targeting ARM (__crt_debugger_hook is not available). * Fix build for Clang on Windows with optimizations on. * Fix a warning about a non-existant warning under Clang. * Fix compilation under Intel C++ 18.0 on Windowspull/397/merge
parent
50d1ea8314
commit
d9de314e86
2
crc.cpp
2
crc.cpp
|
|
@ -14,7 +14,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64
|
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64
|
||||||
#if (CRYPTOPP_GCC_VERSION >= 40300 || __INTEL_COMPILER >= 1000 || __SUNPRO_CC >= 0x5110 || CRYPTOPP_LLVM_CLANG_VERSION >= 20300 || CRYPTOPP_APPLE_CLANG_VERSION >= 40000) && !defined(__SSE4_2__)
|
#if (CRYPTOPP_GCC_VERSION >= 40300 || __INTEL_COMPILER >= 1000 || __SUNPRO_CC >= 0x5110 || CRYPTOPP_LLVM_CLANG_VERSION >= 20300 || CRYPTOPP_APPLE_CLANG_VERSION >= 40000) && !defined(__SSE4_2__) && !defined(_MSC_VER)
|
||||||
GCC_INLINE unsigned int GCC_INLINE_ATTRIB
|
GCC_INLINE unsigned int GCC_INLINE_ATTRIB
|
||||||
MM_CRC32_U8(unsigned int crc, unsigned char val)
|
MM_CRC32_U8(unsigned int crc, unsigned char val)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
2
dll.cpp
2
dll.cpp
|
|
@ -121,7 +121,7 @@ static void SetNewAndDeleteFunctionPointers()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputDebugString("Crypto++ DLL was not able to obtain new and delete function pointers.\n");
|
OutputDebugStringA("Crypto++ DLL was not able to obtain new and delete function pointers.\n");
|
||||||
throw 0;
|
throw 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
12
fipstest.cpp
12
fipstest.cpp
|
|
@ -328,21 +328,21 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "Crypto++ DLL loaded at base address 0x" << std::hex << h << ".\n";
|
oss << "Crypto++ DLL loaded at base address 0x" << std::hex << h << ".\n";
|
||||||
OutputDebugString(oss.str().c_str());
|
OutputDebugStringA(oss.str().c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "Crypto++ DLL integrity check may fail. Expected module base address is 0x";
|
oss << "Crypto++ DLL integrity check may fail. Expected module base address is 0x";
|
||||||
oss << std::hex << g_BaseAddressOfMAC << ", but module loaded at 0x" << h << ".\n";
|
oss << std::hex << g_BaseAddressOfMAC << ", but module loaded at 0x" << h << ".\n";
|
||||||
OutputDebugString(oss.str().c_str());
|
OutputDebugStringA(oss.str().c_str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!moduleStream)
|
if (!moduleStream)
|
||||||
{
|
{
|
||||||
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
||||||
OutputDebugString("Crypto++ DLL integrity check failed. Cannot open file for reading.");
|
OutputDebugStringA("Crypto++ DLL integrity check failed. Cannot open file for reading.");
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -400,7 +400,7 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(_M_ARM)
|
||||||
// first byte of _CRT_DEBUGGER_HOOK gets modified in memory by the debugger invisibly, so read it from file
|
// first byte of _CRT_DEBUGGER_HOOK gets modified in memory by the debugger invisibly, so read it from file
|
||||||
if (IsDebuggerPresent())
|
if (IsDebuggerPresent())
|
||||||
{
|
{
|
||||||
|
|
@ -436,7 +436,7 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule
|
||||||
// hash from disk instead
|
// hash from disk instead
|
||||||
if (!VerifyBufsEqual(expectedModuleMac, actualMac, macSize))
|
if (!VerifyBufsEqual(expectedModuleMac, actualMac, macSize))
|
||||||
{
|
{
|
||||||
OutputDebugString("Crypto++ DLL in-memory integrity check failed. This may be caused by debug breakpoints or DLL relocation.\n");
|
OutputDebugStringA("Crypto++ DLL in-memory integrity check failed. This may be caused by debug breakpoints or DLL relocation.\n");
|
||||||
moduleStream.clear();
|
moduleStream.clear();
|
||||||
moduleStream.seekg(0);
|
moduleStream.seekg(0);
|
||||||
verifier.Initialize(MakeParameters(Name::OutputBuffer(), ByteArrayParameter(actualMac, (unsigned int)actualMac.size())));
|
verifier.Initialize(MakeParameters(Name::OutputBuffer(), ByteArrayParameter(actualMac, (unsigned int)actualMac.size())));
|
||||||
|
|
@ -455,7 +455,7 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule
|
||||||
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
||||||
std::string hexMac;
|
std::string hexMac;
|
||||||
HexEncoder(new StringSink(hexMac)).PutMessageEnd(actualMac, actualMac.size());
|
HexEncoder(new StringSink(hexMac)).PutMessageEnd(actualMac, actualMac.size());
|
||||||
OutputDebugString((("Crypto++ DLL integrity check failed. Actual MAC is: " + hexMac) + ".\n").c_str());
|
OutputDebugStringA((("Crypto++ DLL integrity check failed. Actual MAC is: " + hexMac) + ".\n").c_str());
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,10 @@
|
||||||
|
|
||||||
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
|
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
|
||||||
# pragma GCC diagnostic ignored "-Wunused"
|
# pragma GCC diagnostic ignored "-Wunused"
|
||||||
|
#if !defined(__clang__)
|
||||||
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// Issue 340
|
// Issue 340
|
||||||
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
|
#if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ template <class T, class BASE> void IteratedHashBase<T, BASE>::TruncatedFinal(by
|
||||||
this->Restart(); // reinit for next use
|
this->Restart(); // reinit for next use
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
template class IteratedHashBase<word64, HashTransformation>;
|
template class IteratedHashBase<word64, HashTransformation>;
|
||||||
template class IteratedHashBase<word64, MessageAuthenticationCode>;
|
template class IteratedHashBase<word64, MessageAuthenticationCode>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ protected:
|
||||||
FixedSizeAlignedSecBlock<T_HashWordType, T_BlockSize/sizeof(T_HashWordType), T_StateAligned> m_state;
|
FixedSizeAlignedSecBlock<T_HashWordType, T_BlockSize/sizeof(T_HashWordType), T_StateAligned> m_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef __GNUC__
|
#if !defined(__GNUC__) && !defined(__clang__)
|
||||||
CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word64, HashTransformation>;
|
CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word64, HashTransformation>;
|
||||||
CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase<word64, MessageAuthenticationCode>;
|
CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase<word64, MessageAuthenticationCode>;
|
||||||
|
|
||||||
|
|
|
||||||
12
network.cpp
12
network.cpp
|
|
@ -287,7 +287,7 @@ size_t NetworkSource::DoPump(lword &byteCount, bool blockingOutput, unsigned lon
|
||||||
|
|
||||||
unsigned int recvResult = receiver.GetReceiveResult();
|
unsigned int recvResult = receiver.GetReceiveResult();
|
||||||
#if CRYPTOPP_TRACE_NETWORK
|
#if CRYPTOPP_TRACE_NETWORK
|
||||||
OutputDebugString((IntToString((unsigned int)this) + ": Received " + IntToString(recvResult) + " bytes\n").c_str());
|
OutputDebugStringA((IntToString((unsigned int)this) + ": Received " + IntToString(recvResult) + " bytes\n").c_str());
|
||||||
#endif
|
#endif
|
||||||
m_dataEnd += recvResult;
|
m_dataEnd += recvResult;
|
||||||
m_waitingForResult = false;
|
m_waitingForResult = false;
|
||||||
|
|
@ -315,13 +315,13 @@ ReceiveNoWait:
|
||||||
// call Receive repeatedly as long as data is immediately available,
|
// call Receive repeatedly as long as data is immediately available,
|
||||||
// because some receivers tend to return data in small pieces
|
// because some receivers tend to return data in small pieces
|
||||||
#if CRYPTOPP_TRACE_NETWORK
|
#if CRYPTOPP_TRACE_NETWORK
|
||||||
OutputDebugString((IntToString((unsigned int)this) + ": Receiving " + IntToString(m_buf.size()-m_dataEnd) + " bytes\n").c_str());
|
OutputDebugStringA((IntToString((unsigned int)this) + ": Receiving " + IntToString(m_buf.size()-m_dataEnd) + " bytes\n").c_str());
|
||||||
#endif
|
#endif
|
||||||
while (receiver.Receive(m_buf+m_dataEnd, m_buf.size()-m_dataEnd))
|
while (receiver.Receive(m_buf+m_dataEnd, m_buf.size()-m_dataEnd))
|
||||||
{
|
{
|
||||||
unsigned int recvResult = receiver.GetReceiveResult();
|
unsigned int recvResult = receiver.GetReceiveResult();
|
||||||
#if CRYPTOPP_TRACE_NETWORK
|
#if CRYPTOPP_TRACE_NETWORK
|
||||||
OutputDebugString((IntToString((unsigned int)this) + ": Received " + IntToString(recvResult) + " bytes\n").c_str());
|
OutputDebugStringA((IntToString((unsigned int)this) + ": Received " + IntToString(recvResult) + " bytes\n").c_str());
|
||||||
#endif
|
#endif
|
||||||
m_dataEnd += recvResult;
|
m_dataEnd += recvResult;
|
||||||
if (receiver.EofReceived() || m_dataEnd > m_buf.size() /2)
|
if (receiver.EofReceived() || m_dataEnd > m_buf.size() /2)
|
||||||
|
|
@ -391,7 +391,7 @@ float NetworkSink::ComputeCurrentSpeed()
|
||||||
m_maxObservedSpeed = STDMAX(m_currentSpeed, m_maxObservedSpeed * 0.98f);
|
m_maxObservedSpeed = STDMAX(m_currentSpeed, m_maxObservedSpeed * 0.98f);
|
||||||
m_byteCountSinceLastTimerReset = 0;
|
m_byteCountSinceLastTimerReset = 0;
|
||||||
m_speedTimer.StartTimer();
|
m_speedTimer.StartTimer();
|
||||||
// OutputDebugString(("max speed: " + IntToString((int)m_maxObservedSpeed) + " current speed: " + IntToString((int)m_currentSpeed) + "\n").c_str());
|
// OutputDebugStringA(("max speed: " + IntToString((int)m_maxObservedSpeed) + " current speed: " + IntToString((int)m_currentSpeed) + "\n").c_str());
|
||||||
}
|
}
|
||||||
return m_currentSpeed;
|
return m_currentSpeed;
|
||||||
}
|
}
|
||||||
|
|
@ -497,7 +497,7 @@ lword NetworkSink::DoFlush(unsigned long maxTime, size_t targetSize)
|
||||||
|
|
||||||
unsigned int sendResult = sender.GetSendResult();
|
unsigned int sendResult = sender.GetSendResult();
|
||||||
#if CRYPTOPP_TRACE_NETWORK
|
#if CRYPTOPP_TRACE_NETWORK
|
||||||
OutputDebugString((IntToString((unsigned int)this) + ": Sent " + IntToString(sendResult) + " bytes\n").c_str());
|
OutputDebugStringA((IntToString((unsigned int)this) + ": Sent " + IntToString(sendResult) + " bytes\n").c_str());
|
||||||
#endif
|
#endif
|
||||||
m_buffer.Skip(sendResult);
|
m_buffer.Skip(sendResult);
|
||||||
totalFlushSize += sendResult;
|
totalFlushSize += sendResult;
|
||||||
|
|
@ -515,7 +515,7 @@ lword NetworkSink::DoFlush(unsigned long maxTime, size_t targetSize)
|
||||||
const byte *block = m_buffer.Spy(contiguousSize);
|
const byte *block = m_buffer.Spy(contiguousSize);
|
||||||
|
|
||||||
#if CRYPTOPP_TRACE_NETWORK
|
#if CRYPTOPP_TRACE_NETWORK
|
||||||
OutputDebugString((IntToString((unsigned int)this) + ": Sending " + IntToString(contiguousSize) + " bytes\n").c_str());
|
OutputDebugStringA((IntToString((unsigned int)this) + ": Sending " + IntToString(contiguousSize) + " bytes\n").c_str());
|
||||||
#endif
|
#endif
|
||||||
sender.Send(block, contiguousSize);
|
sender.Send(block, contiguousSize);
|
||||||
m_needSendResult = true;
|
m_needSendResult = true;
|
||||||
|
|
|
||||||
2
wait.cpp
2
wait.cpp
|
|
@ -373,7 +373,7 @@ bool WaitObjectContainer::Wait(unsigned long milliseconds)
|
||||||
if (milliseconds > 0)
|
if (milliseconds > 0)
|
||||||
{
|
{
|
||||||
unsigned long timeAfterWait = t.ElapsedTime();
|
unsigned long timeAfterWait = t.ElapsedTime();
|
||||||
OutputDebugString(("Handles " + IntToString(m_handles.size()) + ", Woke up by " + IntToString(result-WAIT_OBJECT_0) + ", Busied for " + IntToString(timeBeforeWait-lastTime) + " us, Waited for " + IntToString(timeAfterWait-timeBeforeWait) + " us, max " + IntToString(milliseconds) + "ms\n").c_str());
|
OutputDebugStringA(("Handles " + IntToString(m_handles.size()) + ", Woke up by " + IntToString(result-WAIT_OBJECT_0) + ", Busied for " + IntToString(timeBeforeWait-lastTime) + " us, Waited for " + IntToString(timeAfterWait-timeBeforeWait) + " us, max " + IntToString(milliseconds) + "ms\n").c_str());
|
||||||
lastTime = timeAfterWait;
|
lastTime = timeAfterWait;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue