From 96974169199d347172fc5d4a2924f092d602b3de Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 30 Jun 2024 01:22:05 +0200 Subject: Linux: Make the C++ code compatible with old compilers (g++ 4.4.7 on CentOS 6) --- src/Common/SCard.cpp | 2 +- src/Common/SCardLoader.cpp | 4 ++-- src/Common/SCardLoader.h | 9 +++------ src/Common/SCardReader.cpp | 4 ++-- src/Common/TLVParser.cpp | 8 ++++---- 5 files changed, 12 insertions(+), 15 deletions(-) (limited to 'src/Common') diff --git a/src/Common/SCard.cpp b/src/Common/SCard.cpp index 9f8d1145..edd315f6 100644 --- a/src/Common/SCard.cpp +++ b/src/Common/SCard.cpp @@ -6,7 +6,7 @@ namespace VeraCrypt { SCardManager SCard::manager; - SCard::SCard() : m_reader(NULL) + SCard::SCard() { } diff --git a/src/Common/SCardLoader.cpp b/src/Common/SCardLoader.cpp index 16026e62..24486002 100644 --- a/src/Common/SCardLoader.cpp +++ b/src/Common/SCardLoader.cpp @@ -320,7 +320,7 @@ namespace VeraCrypt return scardStatus(hCard, mszReaderNames, pcchReaderLen, pdwState, pdwProtocol, pbAtr, pcbAtrLen); } - LONG SCardLoader::SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATE rgReaderStates, DWORD cReaders) + LONG SCardLoader::SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE* rgReaderStates, DWORD cReaders) { Initialize(); @@ -399,4 +399,4 @@ namespace VeraCrypt return scardSetAttrib(hCard, dwAttrId, pbAttr, cbAttrLen); } -} \ No newline at end of file +} diff --git a/src/Common/SCardLoader.h b/src/Common/SCardLoader.h index a7243d82..af0758ed 100644 --- a/src/Common/SCardLoader.h +++ b/src/Common/SCardLoader.h @@ -13,8 +13,6 @@ #include #include #include "reader.h" -typedef LPSCARD_READERSTATE_A LPSCARD_READERSTATE; -using VeraCrypt::uint8; #define BOOL int #else #undef BOOL @@ -22,7 +20,6 @@ using VeraCrypt::uint8; #include #include #include -using VeraCrypt::uint8; #define BOOL int #endif #endif @@ -48,7 +45,7 @@ namespace VeraCrypt typedef LONG (SCARD_CALL_SPEC *SCardBeginTransactionPtr)(SCARDHANDLE hCard); typedef LONG (SCARD_CALL_SPEC *SCardEndTransactionPtr)(SCARDHANDLE hCard, DWORD dwDisposition); typedef LONG (SCARD_CALL_SPEC *SCardStatusPtr)(SCARDHANDLE hCard, LPTSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, BYTE* pbAtr, LPDWORD pcbAtrLen); - typedef LONG (SCARD_CALL_SPEC *SCardGetStatusChangePtr)(SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATE rgReaderStates, DWORD cReaders); + typedef LONG (SCARD_CALL_SPEC *SCardGetStatusChangePtr)(SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE* rgReaderStates, DWORD cReaders); typedef LONG (SCARD_CALL_SPEC *SCardControlPtr)(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned); typedef LONG (SCARD_CALL_SPEC *SCardTransmitPtr)(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, const BYTE* pbSendBuffer, DWORD cbSendLength, LPSCARD_IO_REQUEST pioRecvPci, BYTE* pbRecvBuffer, LPDWORD pcbRecvLength); typedef LONG (SCARD_CALL_SPEC *SCardListReaderGroupsPtr)(SCARDCONTEXT hContext, LPTSTR mszGroups, LPDWORD pcchGroups); @@ -111,7 +108,7 @@ namespace VeraCrypt static LONG SCardBeginTransaction(SCARDHANDLE hCard); static LONG SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition); static LONG SCardStatus(SCARDHANDLE hCard, LPTSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, BYTE* pbAtr, LPDWORD pcbAtrLen); - static LONG SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATE rgReaderStates, DWORD cReaders); + static LONG SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE* rgReaderStates, DWORD cReaders); static LONG SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned); static LONG SCardTransmit(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, const BYTE* pbSendBuffer, DWORD cbSendLength, LPSCARD_IO_REQUEST pioRecvPci, BYTE* pbRecvBuffer, LPDWORD pcbRecvLength); static LONG SCardListReaderGroups(SCARDCONTEXT hContext, LPTSTR mszGroups, LPDWORD pcchGroups); @@ -122,4 +119,4 @@ namespace VeraCrypt }; }; -#endif // TC_HEADER_Common_SCardLoader \ No newline at end of file +#endif // TC_HEADER_Common_SCardLoader diff --git a/src/Common/SCardReader.cpp b/src/Common/SCardReader.cpp index de269ce6..6c5f654a 100644 --- a/src/Common/SCardReader.cpp +++ b/src/Common/SCardReader.cpp @@ -17,7 +17,7 @@ namespace VeraCrypt } else { - m_scardLoader = NULL; + m_scardLoader.reset(); m_hSCReaderContext = 0; } m_hCard = hCard; @@ -84,7 +84,7 @@ namespace VeraCrypt void SCardReader::Clear(void) { m_szSCReaderName = L""; - m_scardLoader = NULL; + m_scardLoader.reset(); m_hSCReaderContext = 0; m_hCard = 0; m_dwProtocol = 0; diff --git a/src/Common/TLVParser.cpp b/src/Common/TLVParser.cpp index 1e51739c..5ddf37e5 100644 --- a/src/Common/TLVParser.cpp +++ b/src/Common/TLVParser.cpp @@ -169,7 +169,7 @@ namespace VeraCrypt shared_ptr TLVParser::TLV_Find(shared_ptr node, uint16 tag) { size_t i = 0; - shared_ptr tmpnode = NULL; + shared_ptr tmpnode; if (node->Tag == tag) { return node; @@ -177,11 +177,11 @@ namespace VeraCrypt for (i = 0; i < node->Subs->size(); i++) { tmpnode = TLV_Find(node->Subs->at(i),tag); - if (tmpnode != NULL) + if (tmpnode) { return tmpnode; } } - return NULL; + return shared_ptr(); } -} \ No newline at end of file +} -- cgit v1.2.3