From 6fb5cb88d28cccaeb499d704a27b1827297b9866 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Thu, 22 Aug 2019 20:44:38 +0200 Subject: [PATCH] Address code analysis warnings Signed-off-by: Simon Rozman --- CredWrite/Main.cpp | 3 +- EAPMethods/src/Main.cpp | 860 ++++++++++++++---------------- EAPMethods/src/Main_UI.cpp | 360 ++++++------- EventMonitor/App.cpp | 1 + EventMonitor/ETWLog.cpp | 40 +- EventMonitor/ETWLog.h | 2 +- EventMonitor/Frame.h | 5 + MsiUseFeature/Main.cpp | 3 +- WLANManager/Main.cpp | 4 +- include/Common.props | 4 + lib/EAPBase/include/Config.h | 20 +- lib/EAPBase/include/Credentials.h | 22 +- lib/EAPBase/include/EAP.h | 25 +- lib/EAPBase/include/EAPXML.h | 27 +- lib/EAPBase/include/Method.h | 24 +- lib/EAPBase/include/Module.h | 85 ++- lib/EAPBase/include/UIContext.h | 4 +- lib/EAPBase/src/Config.cpp | 20 +- lib/EAPBase/src/Credentials.cpp | 22 +- lib/EAPBase/src/Method.cpp | 20 +- lib/EAPBase/src/Module.cpp | 32 +- lib/EAPBase/src/UIContext.cpp | 4 +- lib/EAPBase_UI/include/EAP_UI.h | 20 +- lib/EapHost/include/Config.h | 4 +- lib/EapHost/include/Credentials.h | 6 +- lib/EapHost/include/Method.h | 8 +- lib/EapHost/src/Config.cpp | 4 +- lib/EapHost/src/Credentials.cpp | 6 +- lib/EapHost/src/Method.cpp | 6 +- lib/GTC/include/Config.h | 4 +- lib/GTC/include/Method.h | 8 +- lib/GTC/src/Config.cpp | 4 +- lib/GTC/src/Method.cpp | 6 +- lib/GTC_UI/include/GTC_UI.h | 5 + lib/MSCHAPv2/include/Config.h | 8 +- lib/MSCHAPv2/include/Method.h | 16 +- lib/MSCHAPv2/src/Config.cpp | 8 +- lib/MSCHAPv2/src/Method.cpp | 14 +- lib/PAP/include/Config.h | 4 +- lib/PAP/include/Method.h | 8 +- lib/PAP/src/Config.cpp | 4 +- lib/PAP/src/Method.cpp | 6 +- lib/TLS/include/Config.h | 4 +- lib/TLS/include/Credentials.h | 6 +- lib/TLS/src/Config.cpp | 4 +- lib/TLS/src/Credentials.cpp | 10 +- lib/TLS_UI/src/TLS_UI.cpp | 5 +- lib/TTLS/include/Config.h | 4 +- lib/TTLS/include/Credentials.h | 6 +- lib/TTLS/include/Method.h | 17 +- lib/TTLS/include/Module.h | 20 +- lib/TTLS/include/UIContext.h | 4 +- lib/TTLS/src/Config.cpp | 4 +- lib/TTLS/src/Credentials.cpp | 6 +- lib/TTLS/src/Method.cpp | 28 +- lib/TTLS/src/Module.cpp | 29 +- lib/TTLS/src/UIContext.cpp | 4 +- lib/TTLS_UI/src/Module.cpp | 4 +- lib/WinStd | 2 +- lib/wxExtend | 2 +- 60 files changed, 935 insertions(+), 960 deletions(-) diff --git a/CredWrite/Main.cpp b/CredWrite/Main.cpp index 66d121c..b023c7d 100644 --- a/CredWrite/Main.cpp +++ b/CredWrite/Main.cpp @@ -116,7 +116,8 @@ static int CredWrite() } -int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) +_Use_decl_annotations_ +int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); diff --git a/EAPMethods/src/Main.cpp b/EAPMethods/src/Main.cpp index e070b1f..7ad9afc 100644 --- a/EAPMethods/src/Main.cpp +++ b/EAPMethods/src/Main.cpp @@ -60,7 +60,8 @@ BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID l /// /// \sa [EapPeerFreeMemory function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363606.aspx) /// -VOID WINAPI EapPeerFreeMemory(_In_ void *pUIContextData) +_Use_decl_annotations_ +VOID WINAPI EapPeerFreeMemory(void *pUIContextData) { event_fn_auto event_auto(g_peer.get_event_fn_auto(__FUNCTION__)); @@ -74,7 +75,8 @@ VOID WINAPI EapPeerFreeMemory(_In_ void *pUIContextData) /// /// \sa [EapPeerFreeErrorMemory function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363605.aspx) /// -VOID WINAPI EapPeerFreeErrorMemory(_In_ EAP_ERROR *ppEapError) +_Use_decl_annotations_ +VOID WINAPI EapPeerFreeErrorMemory(EAP_ERROR *ppEapError) { event_fn_auto event_auto(g_peer.get_event_fn_auto(__FUNCTION__)); @@ -88,7 +90,8 @@ VOID WINAPI EapPeerFreeErrorMemory(_In_ EAP_ERROR *ppEapError) /// /// \sa [EapPeerGetInfo function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363608.aspx) /// -DWORD WINAPI EapPeerGetInfo(_In_ EAP_TYPE* pEapType, _Out_ EAP_PEER_METHOD_ROUTINES* pEapPeerMethodRoutines, _Out_ EAP_ERROR **ppEapError) +_Use_decl_annotations_ +DWORD WINAPI EapPeerGetInfo(EAP_TYPE* pEapType, EAP_PEER_METHOD_ROUTINES* pEapPeerMethodRoutines, EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -96,36 +99,34 @@ DWORD WINAPI EapPeerGetInfo(_In_ EAP_TYPE* pEapType, _Out_ EAP_PEER_METHOD_ROUTI //Sleep(10000); #endif + // Initialize output parameters. + if (pEapPeerMethodRoutines) + memset(pEapPeerMethodRoutines, 0, sizeof(*pEapPeerMethodRoutines)); + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!pEapType || !pEapPeerMethodRoutines) return dwResult = ERROR_INVALID_PARAMETER; + if (pEapType->type != EAPMETHOD_TYPE) + return dwResult = ERROR_NOT_SUPPORTED; - assert(!*ppEapError); + pEapPeerMethodRoutines->dwVersion = PRODUCT_VERSION; + pEapPeerMethodRoutines->pEapType = NULL; - if (!pEapType) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapType is NULL."))); - else if (pEapType->type != EAPMETHOD_TYPE) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)pEapType->type, (int)EAPMETHOD_TYPE).c_str())); - else if (!pEapPeerMethodRoutines) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapPeerMethodRoutines is NULL."))); - else { - pEapPeerMethodRoutines->dwVersion = PRODUCT_VERSION; - pEapPeerMethodRoutines->pEapType = NULL; - - pEapPeerMethodRoutines->EapPeerInitialize = EapPeerInitialize; - pEapPeerMethodRoutines->EapPeerShutdown = EapPeerShutdown; - pEapPeerMethodRoutines->EapPeerBeginSession = EapPeerBeginSession; - pEapPeerMethodRoutines->EapPeerEndSession = EapPeerEndSession; - pEapPeerMethodRoutines->EapPeerSetCredentials = NULL; // Always NULL unless we want to use generic credential UI - pEapPeerMethodRoutines->EapPeerGetIdentity = EapPeerGetIdentity; - pEapPeerMethodRoutines->EapPeerProcessRequestPacket = EapPeerProcessRequestPacket; - pEapPeerMethodRoutines->EapPeerGetResponsePacket = EapPeerGetResponsePacket; - pEapPeerMethodRoutines->EapPeerGetResult = EapPeerGetResult; - pEapPeerMethodRoutines->EapPeerGetUIContext = EapPeerGetUIContext; - pEapPeerMethodRoutines->EapPeerSetUIContext = EapPeerSetUIContext; - pEapPeerMethodRoutines->EapPeerGetResponseAttributes = EapPeerGetResponseAttributes; - pEapPeerMethodRoutines->EapPeerSetResponseAttributes = EapPeerSetResponseAttributes; - } + pEapPeerMethodRoutines->EapPeerInitialize = EapPeerInitialize; + pEapPeerMethodRoutines->EapPeerShutdown = EapPeerShutdown; + pEapPeerMethodRoutines->EapPeerBeginSession = EapPeerBeginSession; + pEapPeerMethodRoutines->EapPeerEndSession = EapPeerEndSession; + pEapPeerMethodRoutines->EapPeerSetCredentials = NULL; // Always NULL unless we want to use generic credential UI + pEapPeerMethodRoutines->EapPeerGetIdentity = EapPeerGetIdentity; + pEapPeerMethodRoutines->EapPeerProcessRequestPacket = EapPeerProcessRequestPacket; + pEapPeerMethodRoutines->EapPeerGetResponsePacket = EapPeerGetResponsePacket; + pEapPeerMethodRoutines->EapPeerGetResult = EapPeerGetResult; + pEapPeerMethodRoutines->EapPeerGetUIContext = EapPeerGetUIContext; + pEapPeerMethodRoutines->EapPeerSetUIContext = EapPeerSetUIContext; + pEapPeerMethodRoutines->EapPeerGetResponseAttributes = EapPeerGetResponseAttributes; + pEapPeerMethodRoutines->EapPeerSetResponseAttributes = EapPeerSetResponseAttributes; return dwResult; } @@ -137,9 +138,10 @@ DWORD WINAPI EapPeerGetInfo(_In_ EAP_TYPE* pEapType, _Out_ EAP_PEER_METHOD_ROUTI /// /// Initializes an EAP peer method for EapHost. /// -/// \sa [EapPeerGetInfo function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363613.aspx) +/// \sa [EapPeerInitialize function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363613.aspx) /// -DWORD APIENTRY EapPeerInitialize(_Out_ EAP_ERROR **ppEapError) +//_Use_decl_annotations_ +DWORD APIENTRY EapPeerInitialize(EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -147,17 +149,14 @@ DWORD APIENTRY EapPeerInitialize(_Out_ EAP_ERROR **ppEapError) //Sleep(10000); #endif - // Parameter check - if (!ppEapError) - return dwResult = ERROR_INVALID_PARAMETER; - - assert(!*ppEapError); + // Initialize output parameters. + if (ppEapError) + *ppEapError = NULL; try { g_peer.initialize(); } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; + dwResult = g_peer.log_error(ppEapError, err); } catch (...) { dwResult = ERROR_INVALID_DATA; } @@ -176,7 +175,8 @@ DWORD APIENTRY EapPeerInitialize(_Out_ EAP_ERROR **ppEapError) /// /// \sa [EapPeerShutdown function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363627.aspx) /// -DWORD APIENTRY EapPeerShutdown(_Out_ EAP_ERROR **ppEapError) +//_Use_decl_annotations_ +DWORD APIENTRY EapPeerShutdown(EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -184,17 +184,14 @@ DWORD APIENTRY EapPeerShutdown(_Out_ EAP_ERROR **ppEapError) //Sleep(10000); #endif - // Parameter check - if (!ppEapError) - return dwResult = ERROR_INVALID_PARAMETER; - - assert(!*ppEapError); + // Initialize output parameters. + if (ppEapError) + *ppEapError = NULL; try { g_peer.shutdown(); } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; + dwResult = g_peer.log_error(ppEapError, err); } catch (...) { dwResult = ERROR_INVALID_DATA; } @@ -210,18 +207,19 @@ DWORD APIENTRY EapPeerShutdown(_Out_ EAP_ERROR **ppEapError) /// /// \sa [EapPeerGetIdentity function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363607.aspx) /// +_Use_decl_annotations_ DWORD APIENTRY EapPeerGetIdentity( - _In_ DWORD dwFlags, - _In_ DWORD dwConnectionDataSize, - _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, - _In_ DWORD dwUserDataSize, - _In_count_(dwUserDataSize) const BYTE *pUserData, - _In_ HANDLE hTokenImpersonateUser, - _Out_ BOOL *pfInvokeUI, - _Out_ DWORD *pdwUserDataOutSize, - _Out_ BYTE **ppUserDataOut, - _Out_ WCHAR **ppwszIdentity, - _Out_ EAP_ERROR **ppEapError) + DWORD dwFlags, + DWORD dwConnectionDataSize, + const BYTE *pConnectionData, + DWORD dwUserDataSize, + const BYTE *pUserData, + HANDLE hTokenImpersonateUser, + BOOL *pfInvokeUI, + DWORD *pdwUserDataOutSize, + BYTE **ppUserDataOut, + WCHAR **ppwszIdentity, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -229,33 +227,28 @@ DWORD APIENTRY EapPeerGetIdentity( //Sleep(10000); #endif + // Initialize output parameters. + if (pfInvokeUI) + *pfInvokeUI = FALSE; + if (pdwUserDataOutSize) + *pdwUserDataOutSize = 0; + if (ppUserDataOut) + *ppUserDataOut = NULL; + if (ppwszIdentity) + *ppwszIdentity = NULL; + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!pConnectionData && dwConnectionDataSize || !pUserData && dwUserDataSize || !pfInvokeUI || !pdwUserDataOutSize || !ppUserDataOut || !ppwszIdentity) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (!pConnectionData && dwConnectionDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConnectionData is NULL."))); - else if (!pUserData && dwUserDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUserData is NULL."))); - else if (!pfInvokeUI) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pfInvokeUI is NULL."))); - else if (!pdwUserDataOutSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwUserDataOutSize is NULL."))); - else if (!ppUserDataOut) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppUserDataOut is NULL."))); - else if (!ppwszIdentity) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppwszIdentity is NULL."))); - else { - try { - g_peer.get_identity(dwFlags, pConnectionData, dwConnectionDataSize, pUserData, dwUserDataSize, ppUserDataOut, pdwUserDataOutSize, hTokenImpersonateUser, pfInvokeUI, ppwszIdentity); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.get_identity(dwFlags, pConnectionData, dwConnectionDataSize, pUserData, dwUserDataSize, ppUserDataOut, pdwUserDataOutSize, hTokenImpersonateUser, pfInvokeUI, ppwszIdentity); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -267,17 +260,18 @@ DWORD APIENTRY EapPeerGetIdentity( /// /// \sa [EapPeerBeginSession function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363600.aspx) /// +//_Use_decl_annotations_ DWORD APIENTRY EapPeerBeginSession( - _In_ DWORD dwFlags, - _In_ const EapAttributes *pAttributeArray, - _In_ HANDLE hTokenImpersonateUser, - _In_ DWORD dwConnectionDataSize, - _In_count_(dwConnectionDataSize) /*const*/ BYTE *pConnectionData, - _In_ DWORD dwUserDataSize, - _In_count_(dwUserDataSize) /*const*/ BYTE *pUserData, - _In_ DWORD dwMaxSendPacketSize, - _Out_ EAP_SESSION_HANDLE *phSession, - _Out_ EAP_ERROR **ppEapError) + DWORD dwFlags, + const EapAttributes *pAttributeArray, + HANDLE hTokenImpersonateUser, + DWORD dwConnectionDataSize, + /*const*/ BYTE *pConnectionData, + DWORD dwUserDataSize, + /*const*/ BYTE *pUserData, + DWORD dwMaxSendPacketSize, + EAP_SESSION_HANDLE *phSession, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -285,27 +279,22 @@ DWORD APIENTRY EapPeerBeginSession( //Sleep(10000); #endif + // Initialize output parameters. + if (phSession) + *phSession = NULL; + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!pConnectionData && dwConnectionDataSize || !pUserData && dwUserDataSize || !phSession) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (!pConnectionData && dwConnectionDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConnectionData is NULL."))); - else if (!pUserData && dwUserDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUserData is NULL."))); - else if (!phSession) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" phSession is NULL."))); - else { - try { - *phSession = g_peer.begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, pConnectionData, dwConnectionDataSize, pUserData, dwUserDataSize, dwMaxSendPacketSize); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + *phSession = g_peer.begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, pConnectionData, dwConnectionDataSize, pUserData, dwUserDataSize, dwMaxSendPacketSize); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -317,9 +306,10 @@ DWORD APIENTRY EapPeerBeginSession( /// /// \sa [EapPeerEndSession function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363604.aspx) /// +//_Use_decl_annotations_ DWORD APIENTRY EapPeerEndSession( - _In_ EAP_SESSION_HANDLE hSession, - _Out_ EAP_ERROR **ppEapError) + EAP_SESSION_HANDLE hSession, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -327,23 +317,20 @@ DWORD APIENTRY EapPeerEndSession( //Sleep(10000); #endif + // Initialize output parameters. + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!hSession) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (!hSession) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL."))); - else { - try { - g_peer.end_session(hSession); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.end_session(hSession); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -355,12 +342,13 @@ DWORD APIENTRY EapPeerEndSession( /// /// \sa [EapPeerProcessRequestPacket function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363621.aspx) /// +//_Use_decl_annotations_ DWORD APIENTRY EapPeerProcessRequestPacket( - _In_ EAP_SESSION_HANDLE hSession, - _In_ DWORD dwReceivedPacketSize, - _In_bytecount_(dwReceivedPacketSize) /*const*/ EapPacket *pReceivedPacket, - _Out_ EapPeerMethodOutput *pEapOutput, - _Out_ EAP_ERROR **ppEapError) + EAP_SESSION_HANDLE hSession, + DWORD dwReceivedPacketSize, + /*const*/ EapPacket *pReceivedPacket, + EapPeerMethodOutput *pEapOutput, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -368,29 +356,22 @@ DWORD APIENTRY EapPeerProcessRequestPacket( //Sleep(10000); #endif + // Initialize output parameters. + if (pEapOutput) + memset(pEapOutput, 0, sizeof(*pEapOutput)); + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!hSession || !pReceivedPacket || dwReceivedPacketSize < 6 || pReceivedPacket->Data[0] != EAPMETHOD_TYPE || !pEapOutput) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (!hSession) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL."))); - else if (!pReceivedPacket || dwReceivedPacketSize < 6) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pReceivedPacket is NULL or too short."))); - else if (pReceivedPacket->Data[0] != EAPMETHOD_TYPE) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, wstring_printf(_T(__FUNCTION__) _T(" Packet EAP type (%d) does not match the supported EAP type (%d)."), (int)pReceivedPacket->Data[0], (int)EAPMETHOD_TYPE).c_str())); - else if (!pEapOutput) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapOutput is NULL."))); - else { - try { - g_peer.process_request_packet(hSession, pReceivedPacket, dwReceivedPacketSize, pEapOutput); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.process_request_packet(hSession, pReceivedPacket, dwReceivedPacketSize, pEapOutput); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -402,11 +383,12 @@ DWORD APIENTRY EapPeerProcessRequestPacket( /// /// \sa [EapPeerGetResponsePacket function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363610.aspx) /// +//_Use_decl_annotations_ DWORD APIENTRY EapPeerGetResponsePacket( - _In_ EAP_SESSION_HANDLE hSession, - _Inout_ DWORD *pdwSendPacketSize, - _Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket, - _Out_ EAP_ERROR **ppEapError) + EAP_SESSION_HANDLE hSession, + DWORD *pdwSendPacketSize, + EapPacket *pSendPacket, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -414,27 +396,20 @@ DWORD APIENTRY EapPeerGetResponsePacket( //Sleep(10000); #endif + // Initialize output parameters. + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!hSession || !pdwSendPacketSize || !pSendPacket && *pdwSendPacketSize) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (!hSession) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL."))); - else if (!pdwSendPacketSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwSendPacketSize is NULL."))); - else if (!pSendPacket && *pdwSendPacketSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pSendPacket is NULL."))); - else { - try { - g_peer.get_response_packet(hSession, pSendPacket, pdwSendPacketSize); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.get_response_packet(hSession, pSendPacket, pdwSendPacketSize); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -446,11 +421,12 @@ DWORD APIENTRY EapPeerGetResponsePacket( /// /// \sa [EapPeerGetResult function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363611.aspx) /// +//_Use_decl_annotations_ DWORD APIENTRY EapPeerGetResult( - _In_ EAP_SESSION_HANDLE hSession, - _In_ EapPeerMethodResultReason reason, - _Out_ EapPeerMethodResult *pResult, - _Out_ EAP_ERROR **ppEapError) + EAP_SESSION_HANDLE hSession, + EapPeerMethodResultReason reason, + EapPeerMethodResult *pResult, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -458,25 +434,20 @@ DWORD APIENTRY EapPeerGetResult( //Sleep(10000); #endif + // Initialize output parameters. + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!hSession || !pResult) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (!hSession) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL."))); - else if (!pResult) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pResult is NULL."))); - else { - try { - g_peer.get_result(hSession, reason, pResult); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.get_result(hSession, reason, pResult); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -490,11 +461,12 @@ DWORD APIENTRY EapPeerGetResult( /// /// \sa [EapPeerGetUIContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363612.aspx) /// +//_Use_decl_annotations_ DWORD APIENTRY EapPeerGetUIContext( - _In_ EAP_SESSION_HANDLE hSession, - _Out_ DWORD *pdwUIContextDataSize, - _Out_ BYTE **ppUIContextData, - _Out_ EAP_ERROR **ppEapError) + EAP_SESSION_HANDLE hSession, + DWORD *pdwUIContextDataSize, + BYTE **ppUIContextData, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -502,27 +474,24 @@ DWORD APIENTRY EapPeerGetUIContext( //Sleep(10000); #endif + // Initialize output parameters. + if (pdwUIContextDataSize) + *pdwUIContextDataSize = 0; + if (ppUIContextData) + *ppUIContextData = NULL; + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!hSession || !pdwUIContextDataSize || !ppUIContextData) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (!hSession) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL."))); - else if (!pdwUIContextDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwUIContextDataSize is NULL."))); - else if (!ppUIContextData) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppUIContextData is NULL."))); - else { - try { - g_peer.get_ui_context(hSession, ppUIContextData, pdwUIContextDataSize); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.get_ui_context(hSession, ppUIContextData, pdwUIContextDataSize); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -536,12 +505,13 @@ DWORD APIENTRY EapPeerGetUIContext( /// /// \sa [EapPeerSetUIContext function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363626.aspx) /// +//_Use_decl_annotations_ DWORD APIENTRY EapPeerSetUIContext( - _In_ EAP_SESSION_HANDLE hSession, - _In_ DWORD dwUIContextDataSize, - _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, - _Out_ EapPeerMethodOutput *pEapOutput, - _Out_ EAP_ERROR **ppEapError) + EAP_SESSION_HANDLE hSession, + DWORD dwUIContextDataSize, + const BYTE *pUIContextData, + EapPeerMethodOutput *pEapOutput, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -549,27 +519,22 @@ DWORD APIENTRY EapPeerSetUIContext( //Sleep(10000); #endif + // Initialize output parameters. + if (pEapOutput) + memset(pEapOutput, 0, sizeof(*pEapOutput)); + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!hSession || !pUIContextData && dwUIContextDataSize || !pEapOutput) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (!hSession) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL."))); - else if (!pUIContextData && dwUIContextDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUIContextData is NULL."))); - else if (!pEapOutput) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapOutput is NULL."))); - else { - try { - g_peer.set_ui_context(hSession, pUIContextData, dwUIContextDataSize, pEapOutput); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.set_ui_context(hSession, pUIContextData, dwUIContextDataSize, pEapOutput); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -581,10 +546,11 @@ DWORD APIENTRY EapPeerSetUIContext( /// /// \sa [EapPeerGetResponseAttributes function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363609.aspx) /// +//_Use_decl_annotations_ DWORD APIENTRY EapPeerGetResponseAttributes( - _In_ EAP_SESSION_HANDLE hSession, - _Out_ EapAttributes *pAttribs, - _Out_ EAP_ERROR **ppEapError) + EAP_SESSION_HANDLE hSession, + EapAttributes *pAttribs, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -592,25 +558,22 @@ DWORD APIENTRY EapPeerGetResponseAttributes( //Sleep(10000); #endif + // Initialize output parameters. + if (pAttribs) + memset(pAttribs, 0, sizeof(*pAttribs)); + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!hSession || !pAttribs) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (!hSession) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL."))); - else if (!pAttribs) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pAttribs is NULL."))); - else { - try { - g_peer.get_response_attributes(hSession, pAttribs); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.get_response_attributes(hSession, pAttribs); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -622,11 +585,12 @@ DWORD APIENTRY EapPeerGetResponseAttributes( /// /// \sa [EapPeerSetResponseAttributes function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363625.aspx) /// +//_Use_decl_annotations_ DWORD APIENTRY EapPeerSetResponseAttributes( - _In_ EAP_SESSION_HANDLE hSession, - _In_ /*const*/ EapAttributes *pAttribs, - _Out_ EapPeerMethodOutput *pEapOutput, - _Out_ EAP_ERROR **ppEapError) + EAP_SESSION_HANDLE hSession, + /*const*/ EapAttributes *pAttribs, + EapPeerMethodOutput *pEapOutput, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -634,25 +598,22 @@ DWORD APIENTRY EapPeerSetResponseAttributes( //Sleep(10000); #endif + // Initialize output parameters. + if (pEapOutput) + memset(pEapOutput, 0, sizeof(*pEapOutput)); + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!hSession || !pEapOutput) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (!hSession) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" hSession is NULL."))); - else if (!pEapOutput) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapOutput is NULL."))); - else { - try { - g_peer.set_response_attributes(hSession, pAttribs, pEapOutput); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.set_response_attributes(hSession, pAttribs, pEapOutput); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -664,17 +625,18 @@ DWORD APIENTRY EapPeerSetResponseAttributes( /// /// \sa [EapPeerGetMethodProperties function](https://msdn.microsoft.com/en-us/library/windows/desktop/hh706636.aspx) /// +_Use_decl_annotations_ DWORD WINAPI EapPeerGetMethodProperties( - _In_ DWORD dwVersion, - _In_ DWORD dwFlags, - _In_ EAP_METHOD_TYPE eapMethodType, - _In_ HANDLE hUserImpersonationToken, - _In_ DWORD dwConnectionDataSize, - _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, - _In_ DWORD dwUserDataSize, - _In_count_(dwUserDataSize) const BYTE *pUserData, - _Out_ EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray, - _Out_ EAP_ERROR **ppEapError) + DWORD dwVersion, + DWORD dwFlags, + EAP_METHOD_TYPE eapMethodType, + HANDLE hUserImpersonationToken, + DWORD dwConnectionDataSize, + /*const*/ BYTE *pConnectionData, + DWORD dwUserDataSize, + /*const*/ BYTE *pUserData, + EAP_METHOD_PROPERTY_ARRAY *pMethodPropertyArray, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -682,31 +644,24 @@ DWORD WINAPI EapPeerGetMethodProperties( //Sleep(10000); #endif + // Initialize output parameters. + if (pMethodPropertyArray) + memset(pMethodPropertyArray, 0, sizeof(*pMethodPropertyArray)); + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (eapMethodType.eapType.type != EAPMETHOD_TYPE || eapMethodType.dwAuthorId != 67532) + return dwResult = ERROR_NOT_SUPPORTED; + if (!pConnectionData && dwConnectionDataSize || !pUserData && dwUserDataSize || !pMethodPropertyArray) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (eapMethodType.eapType.type != EAPMETHOD_TYPE) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str())); - else if (eapMethodType.dwAuthorId != 67532) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str())); - else if (!pConnectionData && dwConnectionDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConnectionData is NULL."))); - else if (!pUserData && dwUserDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUserData is NULL."))); - else if (!pMethodPropertyArray) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pMethodPropertyArray is NULL."))); - else { - try { - g_peer.get_method_properties(dwVersion, dwFlags, hUserImpersonationToken, pConnectionData, dwConnectionDataSize, pUserData, dwUserDataSize, pMethodPropertyArray); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.get_method_properties(dwVersion, dwFlags, hUserImpersonationToken, pConnectionData, dwConnectionDataSize, pUserData, dwUserDataSize, pMethodPropertyArray); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -718,15 +673,16 @@ DWORD WINAPI EapPeerGetMethodProperties( /// /// \sa [EapPeerCredentialsXml2Blob function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363603.aspx) /// +_Use_decl_annotations_ DWORD WINAPI EapPeerCredentialsXml2Blob( - _In_ DWORD dwFlags, - _In_ EAP_METHOD_TYPE eapMethodType, - _In_ IXMLDOMDocument2 *pCredentialsDoc, - _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, - _In_ DWORD dwConnectionDataSize, - _Out_ BYTE **ppCredentialsOut, - _Out_ DWORD *pdwCredentialsOutSize, - _Out_ EAP_ERROR **ppEapError) + DWORD dwFlags, + EAP_METHOD_TYPE eapMethodType, + IXMLDOMDocument2 *pCredentialsDoc, + const BYTE *pConnectionData, + DWORD dwConnectionDataSize, + BYTE **ppCredentialsOut, + DWORD *pdwCredentialsOutSize, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -734,42 +690,33 @@ DWORD WINAPI EapPeerCredentialsXml2Blob( //Sleep(10000); #endif + // Initialize output parameters. + if (ppCredentialsOut) + *ppCredentialsOut = NULL; + if (pdwCredentialsOutSize) + *pdwCredentialsOutSize = 0; + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (eapMethodType.eapType.type != EAPMETHOD_TYPE || eapMethodType.dwAuthorId != 67532) + return dwResult = ERROR_NOT_SUPPORTED; + if (!pCredentialsDoc || !pConnectionData && dwConnectionDataSize || !ppCredentialsOut || !pdwCredentialsOutSize) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); + // + com_obj pXmlElCredentials; + if (FAILED(eapxml::select_node(pCredentialsDoc, bstr(L"//EapHostUserCredentials/Credentials"), pXmlElCredentials))) + return dwResult = g_peer.log_error(ppEapError, ERROR_NOT_FOUND, _T(__FUNCTION__) _T(" Error selecting element.")); - if (eapMethodType.eapType.type != EAPMETHOD_TYPE) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str())); - else if (eapMethodType.dwAuthorId != 67532) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str())); - else if (!pCredentialsDoc) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pCredentialsDoc is NULL."))); - else if (!pConnectionData && dwConnectionDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConnectionData is NULL."))); - else if (!ppCredentialsOut) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppCredentialsOut is NULL."))); - else if (!pdwCredentialsOutSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwCredentialsOutSize is NULL."))); - else { - // - com_obj pXmlElCredentials; - if (FAILED(eapxml::select_node(pCredentialsDoc, bstr(L"//EapHostUserCredentials/Credentials"), pXmlElCredentials))) { - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_FOUND, _T(__FUNCTION__) _T(" Error selecting element."))); - return dwResult; - } - - // Load credentials. - pCredentialsDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\"")); - try { - g_peer.credentials_xml2blob(dwFlags, pXmlElCredentials, pConnectionData, dwConnectionDataSize, ppCredentialsOut, pdwCredentialsOutSize); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + // Load credentials. + pCredentialsDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\"")); + try { + g_peer.credentials_xml2blob(dwFlags, pXmlElCredentials, pConnectionData, dwConnectionDataSize, ppCredentialsOut, pdwCredentialsOutSize); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -781,14 +728,15 @@ DWORD WINAPI EapPeerCredentialsXml2Blob( /// /// \sa [EapPeerQueryCredentialInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363622.aspx) /// +_Use_decl_annotations_ DWORD WINAPI EapPeerQueryCredentialInputFields( - _In_ HANDLE hUserImpersonationToken, - _In_ EAP_METHOD_TYPE eapMethodType, - _In_ DWORD dwFlags, - _In_ DWORD dwConnectionDataSize, - _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, - _Out_ EAP_CONFIG_INPUT_FIELD_ARRAY *pEapConfigInputFieldsArray, - _Out_ EAP_ERROR **ppEapError) + HANDLE hUserImpersonationToken, + EAP_METHOD_TYPE eapMethodType, + DWORD dwFlags, + DWORD dwConnectionDataSize, + /*const*/ BYTE *pConnectionData, + EAP_CONFIG_INPUT_FIELD_ARRAY *pEapConfigInputFieldsArray, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -796,29 +744,24 @@ DWORD WINAPI EapPeerQueryCredentialInputFields( //Sleep(10000); #endif + // Initialize output parameters. + if (pEapConfigInputFieldsArray) + memset(pEapConfigInputFieldsArray, 0, sizeof(*pEapConfigInputFieldsArray)); + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (eapMethodType.eapType.type != EAPMETHOD_TYPE || eapMethodType.dwAuthorId != 67532) + return dwResult = ERROR_NOT_SUPPORTED; + if (!pConnectionData && dwConnectionDataSize || !pEapConfigInputFieldsArray) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (eapMethodType.eapType.type != EAPMETHOD_TYPE) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str())); - else if (eapMethodType.dwAuthorId != 67532) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str())); - else if (!pConnectionData && dwConnectionDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConnectionData is NULL."))); - else if (!pEapConfigInputFieldsArray) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapConfigInputFieldsArray is NULL."))); - else { - try { - g_peer.query_credential_input_fields(hUserImpersonationToken, dwFlags, dwConnectionDataSize, pConnectionData, pEapConfigInputFieldsArray); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.query_credential_input_fields(hUserImpersonationToken, dwFlags, dwConnectionDataSize, pConnectionData, pEapConfigInputFieldsArray); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -830,16 +773,18 @@ DWORD WINAPI EapPeerQueryCredentialInputFields( /// /// \sa [EapPeerQueryUserBlobFromCredentialInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb204697.aspx) /// +#pragma warning(suppress: 6101) // Function is incorrectly annotated and code analysis gets confused +_Use_decl_annotations_ DWORD WINAPI EapPeerQueryUserBlobFromCredentialInputFields( - _In_ HANDLE hUserImpersonationToken, - _In_ EAP_METHOD_TYPE eapMethodType, - _In_ DWORD dwFlags, - _In_ DWORD dwConnectionDataSize, - _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, - _In_ const EAP_CONFIG_INPUT_FIELD_ARRAY *pEapConfigInputFieldArray, - _Inout_ DWORD *pdwUsersBlobSize, - _Inout_ BYTE **ppUserBlob, - _Out_ EAP_ERROR **ppEapError) + HANDLE hUserImpersonationToken, + EAP_METHOD_TYPE eapMethodType, + DWORD dwFlags, + DWORD dwConnectionDataSize, + /*const*/ BYTE *pConnectionData, + const EAP_CONFIG_INPUT_FIELD_ARRAY *pEapConfigInputFieldArray, + DWORD *pdwUsersBlobSize, + BYTE **ppUserBlob, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -847,33 +792,22 @@ DWORD WINAPI EapPeerQueryUserBlobFromCredentialInputFields( //Sleep(10000); #endif + // Initialize output parameters. + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (eapMethodType.eapType.type != EAPMETHOD_TYPE || eapMethodType.dwAuthorId != 67532) + return dwResult = ERROR_NOT_SUPPORTED; + if (!pConnectionData && dwConnectionDataSize || !pEapConfigInputFieldArray || !pdwUsersBlobSize || !ppUserBlob) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (eapMethodType.eapType.type != EAPMETHOD_TYPE) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str())); - else if (eapMethodType.dwAuthorId != 67532) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str())); - else if (!pConnectionData && dwConnectionDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConnectionData is NULL."))); - else if (!pEapConfigInputFieldArray) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapConfigInputFieldArray is NULL."))); - else if (!pdwUsersBlobSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwUsersBlobSize is NULL."))); - else if (!ppUserBlob) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppUserBlob is NULL."))); - else { - try { - g_peer.query_user_blob_from_credential_input_fields(hUserImpersonationToken, dwFlags, dwConnectionDataSize, pConnectionData, pEapConfigInputFieldArray, pdwUsersBlobSize, ppUserBlob); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.query_user_blob_from_credential_input_fields(hUserImpersonationToken, dwFlags, dwConnectionDataSize, pConnectionData, pEapConfigInputFieldArray, pdwUsersBlobSize, ppUserBlob); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -885,44 +819,40 @@ DWORD WINAPI EapPeerQueryUserBlobFromCredentialInputFields( /// /// \sa [EapPeerQueryInteractiveUIInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb204695.aspx) /// +_Use_decl_annotations_ DWORD WINAPI EapPeerQueryInteractiveUIInputFields( - _In_ DWORD dwVersion, - _In_ DWORD dwFlags, - _In_ DWORD dwUIContextDataSize, - _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, - _Out_ EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData, - _Out_ EAP_ERROR **ppEapError, - _Inout_ LPVOID *ppvReserved) + DWORD dwVersion, + DWORD dwFlags, + DWORD dwUIContextDataSize, + const BYTE *pUIContextData, + EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData, + EAP_ERROR **ppEapError, + LPVOID *ppvReserved) { + UNREFERENCED_PARAMETER(ppvReserved); + DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); #ifdef _DEBUG //Sleep(10000); #endif + // Initialize output parameters. + if (pEapInteractiveUIData) + memset(pEapInteractiveUIData, 0, sizeof(*pEapInteractiveUIData)); + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!pUIContextData && dwUIContextDataSize || !pEapInteractiveUIData) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (!pUIContextData && dwUIContextDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUIContextData is NULL."))); - else if (!pUIContextData && dwUIContextDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUIContextData is NULL."))); - else if (!pEapInteractiveUIData) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapInteractiveUIData is NULL."))); - else { - UNREFERENCED_PARAMETER(ppvReserved); - - try { - g_peer.query_interactive_ui_input_fields(dwVersion, dwFlags, dwUIContextDataSize, pUIContextData, pEapInteractiveUIData); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.query_interactive_ui_input_fields(dwVersion, dwFlags, dwUIContextDataSize, pUIContextData, pEapInteractiveUIData); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -934,48 +864,46 @@ DWORD WINAPI EapPeerQueryInteractiveUIInputFields( /// /// \sa [EapPeerQueryUIBlobFromInteractiveUIInputFields function](https://msdn.microsoft.com/en-us/library/windows/desktop/bb204696.aspx) /// +#pragma warning(suppress: 6387) // Function is incorrectly annotated and code analysis gets confused +#pragma warning(suppress: 28196) +_Use_decl_annotations_ DWORD WINAPI EapPeerQueryUIBlobFromInteractiveUIInputFields( - _In_ DWORD dwVersion, - _In_ DWORD dwFlags, - _In_ DWORD dwUIContextDataSize, - _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, - _In_ const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData, - _Out_ DWORD *pdwDataFromInteractiveUISize, - _Out_ BYTE **ppDataFromInteractiveUI, - _Out_ EAP_ERROR **ppEapError, - _Inout_ LPVOID *ppvReserved) + DWORD dwVersion, + DWORD dwFlags, + DWORD dwUIContextDataSize, + const BYTE *pUIContextData, + const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData, + DWORD *pdwDataFromInteractiveUISize, + BYTE **ppDataFromInteractiveUI, + EAP_ERROR **ppEapError, + LPVOID *ppvReserved) { + UNREFERENCED_PARAMETER(ppvReserved); + DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); #ifdef _DEBUG //Sleep(10000); #endif + // Initialize output parameters. + if (pdwDataFromInteractiveUISize) + *pdwDataFromInteractiveUISize = 0; + if (ppDataFromInteractiveUI) + *ppDataFromInteractiveUI = NULL; + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!pUIContextData && dwUIContextDataSize || !pEapInteractiveUIData || !pdwDataFromInteractiveUISize || !ppDataFromInteractiveUI) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); - - if (!pUIContextData && dwUIContextDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapConfigInputFieldArray is NULL."))); - else if (!pEapInteractiveUIData) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapInteractiveUIData is NULL."))); - else if (!pdwDataFromInteractiveUISize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwDataFromInteractiveUISize is NULL."))); - else if (!ppDataFromInteractiveUI) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppDataFromInteractiveUI is NULL."))); - else { - UNREFERENCED_PARAMETER(ppvReserved); - - try { - g_peer.query_ui_blob_from_interactive_ui_input_fields(dwVersion, dwFlags, dwUIContextDataSize, pUIContextData, pEapInteractiveUIData, pdwDataFromInteractiveUISize, ppDataFromInteractiveUI); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.query_ui_blob_from_interactive_ui_input_fields(dwVersion, dwFlags, dwUIContextDataSize, pUIContextData, pEapInteractiveUIData, pdwDataFromInteractiveUISize, ppDataFromInteractiveUI); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; diff --git a/EAPMethods/src/Main_UI.cpp b/EAPMethods/src/Main_UI.cpp index 58bee06..412da48 100644 --- a/EAPMethods/src/Main_UI.cpp +++ b/EAPMethods/src/Main_UI.cpp @@ -76,7 +76,8 @@ BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID l /// /// \sa [EapPeerFreeMemory function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363606.aspx) /// -VOID WINAPI EapPeerFreeMemory(_In_ void *pUIContextData) +_Use_decl_annotations_ +VOID WINAPI EapPeerFreeMemory(void *pUIContextData) { event_fn_auto event_auto(g_peer.get_event_fn_auto(__FUNCTION__)); @@ -90,7 +91,8 @@ VOID WINAPI EapPeerFreeMemory(_In_ void *pUIContextData) /// /// \sa [EapPeerFreeErrorMemory function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363605.aspx) /// -VOID WINAPI EapPeerFreeErrorMemory(_In_ EAP_ERROR *ppEapError) +_Use_decl_annotations_ +VOID WINAPI EapPeerFreeErrorMemory(EAP_ERROR *ppEapError) { event_fn_auto event_auto(g_peer.get_event_fn_auto(__FUNCTION__)); @@ -104,13 +106,14 @@ VOID WINAPI EapPeerFreeErrorMemory(_In_ EAP_ERROR *ppEapError) /// /// \sa [EapPeerConfigXml2Blob function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363602.aspx) /// +_Use_decl_annotations_ DWORD WINAPI EapPeerConfigXml2Blob( - _In_ DWORD dwFlags, - _In_ EAP_METHOD_TYPE eapMethodType, - _In_ IXMLDOMDocument2 *pConfigDoc, - _Out_ BYTE **pConnectionDataOut, - _Out_ DWORD *pdwConnectionDataOutSize, - _Out_ EAP_ERROR **ppEapError) + DWORD dwFlags, + EAP_METHOD_TYPE eapMethodType, + IXMLDOMDocument2 *pConfigDoc, + BYTE **pConnectionDataOut, + DWORD *pdwConnectionDataOutSize, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -118,42 +121,35 @@ DWORD WINAPI EapPeerConfigXml2Blob( //Sleep(10000); #endif + // Initialize output parameters. + if (pConnectionDataOut) + *pConnectionDataOut = NULL; + if (pdwConnectionDataOutSize) + *pdwConnectionDataOutSize = 0; + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (eapMethodType.eapType.type != EAPMETHOD_TYPE || eapMethodType.dwAuthorId != 67532) + return dwResult = ERROR_NOT_SUPPORTED; + if (!pConfigDoc || !pConnectionDataOut || !pdwConnectionDataOutSize) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); + // Configure XML selection namespaces used. + pConfigDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\" xmlns:eaphostconfig=\"http://www.microsoft.com/provisioning/EapHostConfig\"")); - if (eapMethodType.eapType.type != EAPMETHOD_TYPE) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str())); - else if (eapMethodType.dwAuthorId != 67532) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str())); - else if (!pConfigDoc) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConfigDoc is NULL."))); - else if (!pConnectionDataOut) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConnectionDataOut is NULL."))); - else if (!pdwConnectionDataOutSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwConnectionDataOutSize is NULL."))); - else { - // Configure XML selection namespaces used. - pConfigDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\" xmlns:eaphostconfig=\"http://www.microsoft.com/provisioning/EapHostConfig\"")); + // + com_obj pXmlElConfig; + if (FAILED(eapxml::select_element(pConfigDoc, bstr(L"//eaphostconfig:Config"), pXmlElConfig))) + return dwResult = g_peer.log_error(ppEapError, ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" Error reading element.")); - // - com_obj pXmlElConfig; - if (FAILED(eapxml::select_element(pConfigDoc, bstr(L"//eaphostconfig:Config"), pXmlElConfig))) { - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" Error reading element."))); - return dwResult; - } - - // Load configuration. - try { - g_peer.config_xml2blob(dwFlags, pXmlElConfig, pConnectionDataOut, pdwConnectionDataOutSize); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + // Load configuration. + try { + g_peer.config_xml2blob(dwFlags, pXmlElConfig, pConnectionDataOut, pdwConnectionDataOutSize); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -167,13 +163,14 @@ DWORD WINAPI EapPeerConfigXml2Blob( /// /// \sa [EapPeerConfigBlob2Xml function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363601.aspx) /// +_Use_decl_annotations_ DWORD WINAPI EapPeerConfigBlob2Xml( - _In_ DWORD dwFlags, - _In_ EAP_METHOD_TYPE eapMethodType, - _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, - _In_ DWORD dwConnectionDataSize, - _Out_ IXMLDOMDocument2 **ppConfigDoc, - _Out_ EAP_ERROR **ppEapError) + DWORD dwFlags, + EAP_METHOD_TYPE eapMethodType, + const BYTE *pConnectionData, + DWORD dwConnectionDataSize, + IXMLDOMDocument2 **ppConfigDoc, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -181,67 +178,54 @@ DWORD WINAPI EapPeerConfigBlob2Xml( //Sleep(10000); #endif + // Initialize output parameters. + if (ppConfigDoc) + *ppConfigDoc = NULL; + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (eapMethodType.eapType.type != EAPMETHOD_TYPE || eapMethodType.dwAuthorId != 67532) + return dwResult = ERROR_NOT_SUPPORTED; + if (!pConnectionData && dwConnectionDataSize || !ppConfigDoc) return dwResult = ERROR_INVALID_PARAMETER; - assert(!*ppEapError); + HRESULT hr; - if (eapMethodType.eapType.type != EAPMETHOD_TYPE) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)eapMethodType.eapType.type, (int)EAPMETHOD_TYPE).c_str())); - else if (eapMethodType.dwAuthorId != 67532) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)eapMethodType.dwAuthorId, (int)67532).c_str())); - else if (!pConnectionData && dwConnectionDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConnectionData is NULL."))); - else if (!ppConfigDoc) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppConfigDoc is NULL."))); - else { - HRESULT hr; + // Create configuration XML document. + com_obj pConfigDoc; + if (FAILED(hr = pConfigDoc.create(CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER))) + return dwResult = g_peer.log_error(ppEapError, HRESULT_CODE(hr), _T(__FUNCTION__) _T(" Error creating XML document.")); - // Create configuration XML document. - com_obj pConfigDoc; - if (FAILED(hr = pConfigDoc.create(CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER))) { - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = HRESULT_CODE(hr), _T(__FUNCTION__) _T(" Error creating XML document."))); - return dwResult; - } + pConfigDoc->put_async(VARIANT_FALSE); - pConfigDoc->put_async(VARIANT_FALSE); + // Load empty XML configuration. + VARIANT_BOOL isSuccess = VARIANT_FALSE; + if (FAILED((hr = pConfigDoc->loadXML(L"", &isSuccess)))) + return dwResult = g_peer.log_error(ppEapError, HRESULT_CODE(hr), _T(__FUNCTION__) _T(" Error loading XML document template.")); + if (!isSuccess) + return dwResult = g_peer.log_error(ppEapError, ERROR_XML_PARSE_ERROR, _T(__FUNCTION__) _T(" Loading XML template failed.")); - // Load empty XML configuration. - VARIANT_BOOL isSuccess = VARIANT_FALSE; - if (FAILED((hr = pConfigDoc->loadXML(L"", &isSuccess)))) { - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = HRESULT_CODE(hr), _T(__FUNCTION__) _T(" Error loading XML document template."))); - return dwResult; - } - if (!isSuccess) { - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_XML_PARSE_ERROR, _T(__FUNCTION__) _T(" Loading XML template failed."))); - return dwResult; - } + // Configure XML selection namespaces used. + pConfigDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\" xmlns:eaphostconfig=\"http://www.microsoft.com/provisioning/EapHostConfig\"")); - // Configure XML selection namespaces used. - pConfigDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\" xmlns:eaphostconfig=\"http://www.microsoft.com/provisioning/EapHostConfig\"")); + // Select node. + com_obj pXmlElConfig; + if (FAILED(eapxml::select_node(pConfigDoc, bstr(L"eaphostconfig:Config"), pXmlElConfig))) + return dwResult = g_peer.log_error(ppEapError, ERROR_NOT_FOUND, _T(__FUNCTION__) _T(" Error selecting element.")); - // Select node. - com_obj pXmlElConfig; - if (FAILED(eapxml::select_node(pConfigDoc, bstr(L"eaphostconfig:Config"), pXmlElConfig))) { - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_FOUND, _T(__FUNCTION__) _T(" Error selecting element."))); - return dwResult; - } - - // Save configuration. - pConfigDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\"")); - try { - g_peer.config_blob2xml(dwFlags, pConnectionData, dwConnectionDataSize, pConfigDoc, pXmlElConfig); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - return dwResult = (*ppEapError)->dwWinError; - } catch (...) { - return dwResult = ERROR_INVALID_DATA; - } - - *ppConfigDoc = pConfigDoc.detach(); + // Save configuration. + pConfigDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\"")); + try { + g_peer.config_blob2xml(dwFlags, pConnectionData, dwConnectionDataSize, pConfigDoc, pXmlElConfig); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + return dwResult = ERROR_INVALID_DATA; } + *ppConfigDoc = pConfigDoc.detach(); + return dwResult; } @@ -251,15 +235,16 @@ DWORD WINAPI EapPeerConfigBlob2Xml( /// /// \sa [EapPeerInvokeConfigUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363614.aspx) /// +//_Use_decl_annotations_ DWORD WINAPI EapPeerInvokeConfigUI( - _In_ const EAP_METHOD_TYPE *pEapType, - _In_ HWND hwndParent, - _In_ DWORD dwFlags, - _In_ DWORD dwConnectionDataInSize, - _In_count_(dwConnectionDataInSize) const BYTE *pConnectionDataIn, - _Out_ DWORD *pdwConnectionDataOutSize, - _Out_ BYTE **ppConnectionDataOut, - _Out_ EAP_ERROR **ppEapError) + const EAP_METHOD_TYPE *pEapType, + HWND hwndParent, + DWORD dwFlags, + DWORD dwConnectionDataInSize, + const BYTE *pConnectionDataIn, + DWORD *pdwConnectionDataOutSize, + BYTE **ppConnectionDataOut, + EAP_ERROR **ppEapError) { UNREFERENCED_PARAMETER(dwFlags); DWORD dwResult = ERROR_SUCCESS; @@ -269,33 +254,26 @@ DWORD WINAPI EapPeerInvokeConfigUI( //Sleep(10000); #endif + // Initialize output parameters. + if (pdwConnectionDataOutSize) + *pdwConnectionDataOutSize = 0; + if (ppConnectionDataOut) + *ppConnectionDataOut = NULL; + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!pEapType || !pConnectionDataIn && dwConnectionDataInSize || !pdwConnectionDataOutSize || !ppConnectionDataOut) return dwResult = ERROR_INVALID_PARAMETER; + if (pEapType->eapType.type != EAPMETHOD_TYPE || pEapType->dwAuthorId != 67532) + return dwResult = ERROR_NOT_SUPPORTED; - assert(!*ppEapError); - - if (!pEapType) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapType is NULL."))); - else if (pEapType->eapType.type != EAPMETHOD_TYPE) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)pEapType->eapType.type, (int)EAPMETHOD_TYPE).c_str())); - else if (pEapType->dwAuthorId != 67532) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str())); - else if (!pConnectionDataIn && dwConnectionDataInSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConnectionDataIn is NULL."))); - else if (!pdwConnectionDataOutSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwConnectionDataOutSize is NULL."))); - else if (!ppConnectionDataOut) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppConnectionDataOut is NULL."))); - else { - try { - g_peer.invoke_config_ui(hwndParent, pConnectionDataIn, dwConnectionDataInSize, ppConnectionDataOut, pdwConnectionDataOutSize); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.invoke_config_ui(hwndParent, pConnectionDataIn, dwConnectionDataInSize, ppConnectionDataOut, pdwConnectionDataOutSize); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -307,18 +285,19 @@ DWORD WINAPI EapPeerInvokeConfigUI( /// /// \sa [EapPeerInvokeIdentityUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363615.aspx) /// +//_Use_decl_annotations_ DWORD WINAPI EapPeerInvokeIdentityUI( - _In_ const EAP_METHOD_TYPE *pEapType, - _In_ DWORD dwFlags, - _In_ HWND hwndParent, - _In_ DWORD dwConnectionDataSize, - _In_count_(dwConnectionDataSize) const BYTE *pConnectionData, - _In_ DWORD dwUserDataSize, - _In_count_(dwUserDataSize) const BYTE *pUserData, - _Out_ DWORD *pdwUserDataOutSize, - _Out_ BYTE **ppUserDataOut, - _Out_ LPWSTR *ppwszIdentity, - _Out_ EAP_ERROR **ppEapError) + const EAP_METHOD_TYPE *pEapType, + DWORD dwFlags, + HWND hwndParent, + DWORD dwConnectionDataSize, + const BYTE *pConnectionData, + DWORD dwUserDataSize, + const BYTE *pUserData, + DWORD *pdwUserDataOutSize, + BYTE **ppUserDataOut, + LPWSTR *ppwszIdentity, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -327,37 +306,28 @@ DWORD WINAPI EapPeerInvokeIdentityUI( //Sleep(10000); #endif + // Initialize output parameters. + if (pdwUserDataOutSize) + *pdwUserDataOutSize = 0; + if (ppUserDataOut) + *ppUserDataOut = NULL; + if (ppwszIdentity) + *ppwszIdentity = NULL; + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) - dwResult = ERROR_INVALID_PARAMETER; + if (!pEapType || !pConnectionData && dwConnectionDataSize || !pUserData && dwUserDataSize || !pdwUserDataOutSize || !ppUserDataOut || !ppwszIdentity) + return dwResult = ERROR_INVALID_PARAMETER; + if (pEapType->eapType.type != EAPMETHOD_TYPE || pEapType->dwAuthorId != 67532) + return dwResult = ERROR_NOT_SUPPORTED; - assert(!*ppEapError); - - if (!pEapType) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapType is NULL."))); - else if (pEapType->eapType.type != EAPMETHOD_TYPE) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)pEapType->eapType.type, (int)EAPMETHOD_TYPE).c_str())); - else if (pEapType->dwAuthorId != 67532) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str())); - else if (!pConnectionData && dwConnectionDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pConnectionData is NULL."))); - else if (!pUserData && dwUserDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUserData is NULL."))); - else if (!pdwUserDataOutSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwUserDataOutSize is NULL."))); - else if (!ppUserDataOut) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppUserDataOut is NULL."))); - else if (!ppwszIdentity) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppwszIdentity is NULL."))); - else { - try { - g_peer.invoke_identity_ui(hwndParent, dwFlags, pConnectionData, dwConnectionDataSize, pUserData, dwUserDataSize, ppUserDataOut, pdwUserDataOutSize, ppwszIdentity); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.invoke_identity_ui(hwndParent, dwFlags, pConnectionData, dwConnectionDataSize, pUserData, dwUserDataSize, ppUserDataOut, pdwUserDataOutSize, ppwszIdentity); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; @@ -369,14 +339,15 @@ DWORD WINAPI EapPeerInvokeIdentityUI( /// /// \sa [EapPeerInvokeInteractiveUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363616.aspx) /// +//_Use_decl_annotations_ DWORD WINAPI EapPeerInvokeInteractiveUI( - _In_ const EAP_METHOD_TYPE *pEapType, - _In_ HWND hwndParent, - _In_ DWORD dwUIContextDataSize, - _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, - _Out_ DWORD *pdwDataFromInteractiveUISize, - _Out_ BYTE **ppDataFromInteractiveUI, - _Out_ EAP_ERROR **ppEapError) + const EAP_METHOD_TYPE *pEapType, + HWND hwndParent, + DWORD dwUIContextDataSize, + const BYTE *pUIContextData, + DWORD *pdwDataFromInteractiveUISize, + BYTE **ppDataFromInteractiveUI, + EAP_ERROR **ppEapError) { DWORD dwResult = ERROR_SUCCESS; event_fn_auto_ret event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); @@ -385,33 +356,26 @@ DWORD WINAPI EapPeerInvokeInteractiveUI( //Sleep(10000); #endif + // Initialize output parameters. + if (pdwDataFromInteractiveUISize) + *pdwDataFromInteractiveUISize = 0; + if (ppDataFromInteractiveUI) + *ppDataFromInteractiveUI = NULL; + if (ppEapError) + *ppEapError = NULL; + // Parameter check - if (!ppEapError) + if (!pEapType || !pUIContextData && dwUIContextDataSize || !pdwDataFromInteractiveUISize || !ppDataFromInteractiveUI) return dwResult = ERROR_INVALID_PARAMETER; + if (pEapType->eapType.type != EAPMETHOD_TYPE || pEapType->dwAuthorId != 67532) + return dwResult = ERROR_NOT_SUPPORTED; - assert(!*ppEapError); - - if (!pEapType) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pEapType is NULL."))); - else if (pEapType->eapType.type != EAPMETHOD_TYPE) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)pEapType->eapType.type, (int)EAPMETHOD_TYPE).c_str())); - else if (pEapType->dwAuthorId != 67532) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str())); - else if (!pUIContextData && dwUIContextDataSize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pUIContextData is NULL."))); - else if (!pdwDataFromInteractiveUISize) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" pdwDataFromInteractiveUISize is NULL."))); - else if (!ppDataFromInteractiveUI) - g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppDataFromInteractiveUI is NULL."))); - else { - try { - g_peer.invoke_interactive_ui(hwndParent, pUIContextData, dwUIContextDataSize, ppDataFromInteractiveUI, pdwDataFromInteractiveUISize); - } catch (std::exception &err) { - g_peer.log_error(*ppEapError = g_peer.make_error(err)); - dwResult = (*ppEapError)->dwWinError; - } catch (...) { - dwResult = ERROR_INVALID_DATA; - } + try { + g_peer.invoke_interactive_ui(hwndParent, pUIContextData, dwUIContextDataSize, ppDataFromInteractiveUI, pdwDataFromInteractiveUISize); + } catch (std::exception &err) { + dwResult = g_peer.log_error(ppEapError, err); + } catch (...) { + dwResult = ERROR_INVALID_DATA; } return dwResult; diff --git a/EventMonitor/App.cpp b/EventMonitor/App.cpp index 29460a4..0f063b5 100644 --- a/EventMonitor/App.cpp +++ b/EventMonitor/App.cpp @@ -28,6 +28,7 @@ // wxEventMonitorApp ////////////////////////////////////////////////////////////////////////// +#pragma warning(suppress: 28251) wxIMPLEMENT_APP(wxEventMonitorApp); diff --git a/EventMonitor/ETWLog.cpp b/EventMonitor/ETWLog.cpp index fe8e74d..cea8939 100644 --- a/EventMonitor/ETWLog.cpp +++ b/EventMonitor/ETWLog.cpp @@ -132,11 +132,8 @@ VOID WINAPI wxEventTraceProcessorThread::EventRecordCallback(_In_ PEVENT_RECORD wxASSERT_MSG(pEvent->UserContext, wxT("thread is NULL")); wxEventTraceProcessorThread *_this = ((wxEventTraceProcessorThread*)pEvent->UserContext); - - if (_this->TestDestroy()) { - // Event processing is pending destruction. + if (!_this || _this->TestDestroy()) return; - } _this->m_parent->QueueEvent(new wxETWEvent(wxEVT_ETW_EVENT, *pEvent)); } @@ -178,7 +175,7 @@ wxETWListCtrl::wxETWListCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos m_col_format_width[0] = 26; m_col_format_width[1] = 5; m_col_format_width[2] = 5; - m_col_format_width[3] = std::max(std::max(_countof("EapHost"), _countof("Schannel")), _countof(PRODUCT_NAME_STR)) - 1; + m_col_format_width[3] = std::max(std::max(_countof("EapHost"), _countof("Schannel")), _countof(PRODUCT_NAME_STR)) - 1; m_col_format_width[4] = 0; // Prepare all possible item attributes. @@ -219,7 +216,11 @@ wxETWListCtrl::wxETWListCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos properties->Wnode.BufferSize = ulSize; properties->Wnode.Flags = WNODE_FLAG_TRACED_GUID; properties->Wnode.ClientContext = 1; //QPC clock resolution - CoCreateGuid(&(properties->Wnode.Guid)); + HRESULT hr = CoCreateGuid(&(properties->Wnode.Guid)); + if (FAILED(hr)) { + wxLogError(winstd::tstring_printf(wxT("error 0x%08x generating GUID"), hr).c_str()); + continue; + } properties->LogFileMode = /*EVENT_TRACE_FILE_MODE_SEQUENTIAL |*/ EVENT_TRACE_REAL_TIME_MODE; properties->MaximumFileSize = 1; // 1 MB properties->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES); @@ -776,13 +777,13 @@ static tstring MapToString(_In_ const EVENT_MAP_INFO *pMapInfo, _In_ ULONG ulDat ((pMapInfo->Flag & EVENTMAP_INFO_FLAG_WBEM_VALUEMAP ) && (pMapInfo->Flag & ~EVENTMAP_INFO_FLAG_WBEM_VALUEMAP) != EVENTMAP_INFO_FLAG_WBEM_FLAG)) { if ((pMapInfo->Flag & EVENTMAP_INFO_FLAG_WBEM_NO_MAP) == EVENTMAP_INFO_FLAG_WBEM_NO_MAP) - return tstring_printf(_T("%ls"), (PBYTE)pMapInfo + pMapInfo->MapEntryArray[ulData].OutputOffset); + return tstring_printf(_T("%ls"), (LPCWSTR)((PBYTE)pMapInfo + pMapInfo->MapEntryArray[ulData].OutputOffset)); else { for (ULONG i = 0; ; i++) { if (i >= pMapInfo->EntryCount) return tstring_printf(_T("%lu"), ulData); else if (pMapInfo->MapEntryArray[i].Value == ulData) - return tstring_printf(_T("%ls"), (PBYTE)pMapInfo + pMapInfo->MapEntryArray[i].OutputOffset); + return tstring_printf(_T("%ls"), (LPCWSTR)((PBYTE)pMapInfo + pMapInfo->MapEntryArray[i].OutputOffset)); } } } else if ( @@ -817,7 +818,7 @@ static tstring DataToString(_In_ USHORT InType, _In_ USHORT OutType, _In_count_( case TDH_INTYPE_UNICODESTRING: case TDH_INTYPE_NONNULLTERMINATEDSTRING: case TDH_INTYPE_UNICODECHAR: - return tstring_printf(_T("%.*ls"), nDataSize/sizeof(WCHAR), pData); + return tstring_printf(_T("%.*ls"), (unsigned int)(nDataSize/sizeof(WCHAR)), (LPCWSTR)pData); case TDH_INTYPE_ANSISTRING: case TDH_INTYPE_NONNULLTERMINATEDANSISTRING: @@ -918,6 +919,7 @@ static tstring DataToString(_In_ USHORT InType, _In_ USHORT OutType, _In_count_( case TDH_INTYPE_BINARY: switch (OutType) { case TDH_OUTTYPE_IPV6: { + #pragma warning(suppress: 6387) // ntdll.dll *must* exist. auto RtlIpv6AddressToString = (LPTSTR(NTAPI*)(const IN6_ADDR*, LPTSTR))GetProcAddress(GetModuleHandle(_T("ntdll.dll")), #ifdef _UNICODE "RtlIpv6AddressToStringW" @@ -945,8 +947,12 @@ static tstring DataToString(_In_ USHORT InType, _In_ USHORT OutType, _In_count_( case TDH_INTYPE_GUID: { assert(nDataSize >= sizeof(GUID)); WCHAR szGuid[39]; - StringFromGUID2(*(GUID*)pData, szGuid, _countof(szGuid)); - return tstring_printf(_T("%ls"), szGuid); + if (StringFromGUID2(*(GUID*)pData, szGuid, _countof(szGuid))) + return tstring_printf(_T("%ls"), szGuid); + else { + assert(0); + return _T("(GUID)"); + } } case TDH_INTYPE_POINTER: @@ -995,7 +1001,7 @@ static tstring DataToString(_In_ USHORT InType, _In_ USHORT OutType, _In_count_( // 32-bit computer and 16 bytes on a 64-bit computer. // Doubling the pointer size handles both cases. assert(nDataSize >= (SIZE_T)nPtrSize * 2); - return (PULONG)pData > 0 ? DataToString(TDH_INTYPE_SID, OutType, pData + nPtrSize * 2, nDataSize - nPtrSize * 2, pMapInfo, nPtrSize) : _T("(WBEM SID)"); + return (PULONG)pData > 0 ? DataToString(TDH_INTYPE_SID, OutType, pData + (SIZE_T)nPtrSize * 2, nDataSize - (SIZE_T)nPtrSize * 2, pMapInfo, nPtrSize) : _T("(WBEM SID)"); case TDH_INTYPE_SID: { assert(nDataSize >= sizeof(SID)); @@ -1027,7 +1033,7 @@ static ULONG GetArraySize(PEVENT_RECORD pEvent, PTRACE_EVENT_INFO pInfo, ULONG i ULONG ulResult; // Get array count property. - PROPERTY_DATA_DESCRIPTOR data_desc = { (ULONGLONG)(reinterpret_cast(pInfo) + pInfo->EventPropertyInfoArray[pInfo->EventPropertyInfoArray[i].countPropertyIndex].NameOffset), ULONG_MAX }; + PROPERTY_DATA_DESCRIPTOR data_desc = { (ULONGLONG)pInfo + pInfo->EventPropertyInfoArray[pInfo->EventPropertyInfoArray[i].countPropertyIndex].NameOffset, ULONG_MAX }; vector count; if ((ulResult = TdhGetProperty(pEvent, 0, NULL, 1, &data_desc, count)) != ERROR_SUCCESS) return ulResult; @@ -1067,7 +1073,7 @@ static tstring PropertyToString(PEVENT_RECORD pEvent, PTRACE_EVENT_INFO pInfo, U if (out_nonfirst) out += _T(", "); else out_nonfirst = true; out += _T('('); for (USHORT j = pInfo->EventPropertyInfoArray[ulPropIndex].structType.StructStartIndex, usLastMember = pInfo->EventPropertyInfoArray[ulPropIndex].structType.StructStartIndex + pInfo->EventPropertyInfoArray[ulPropIndex].structType.NumOfStructMembers; j < usLastMember; j++) { - out += tstring_printf(_T("%ls: "), reinterpret_cast(pInfo) + pInfo->EventPropertyInfoArray[j].NameOffset); + out += tstring_printf(_T("%ls: "), (LPCWSTR)(reinterpret_cast(pInfo) + pInfo->EventPropertyInfoArray[j].NameOffset)); out += PropertyToString(pEvent, pInfo, j, reinterpret_cast(reinterpret_cast(pInfo) + pInfo->EventPropertyInfoArray[ulPropIndex].NameOffset), k, nPtrSize); } out += _T(')'); @@ -1086,12 +1092,12 @@ static tstring PropertyToString(PEVENT_RECORD pEvent, PTRACE_EVENT_INFO pInfo, U // The first descriptor in the array identifies the name of the structure and the second // descriptor defines the member of the structure whose data you want to retrieve. PROPERTY_DATA_DESCRIPTOR data_desc[2] = { - { (ULONGLONG)pStructureName , ulStructIndex }, - { (ULONGLONG)(reinterpret_cast(pInfo) + pInfo->EventPropertyInfoArray[ulPropIndex].NameOffset), k } + { (ULONGLONG)pStructureName , ulStructIndex }, + { (ULONGLONG)pInfo + pInfo->EventPropertyInfoArray[ulPropIndex].NameOffset, k } }; ulResult = TdhGetProperty(pEvent, 0, NULL, _countof(data_desc), data_desc, data); } else { - PROPERTY_DATA_DESCRIPTOR data_desc = { (ULONGLONG)(reinterpret_cast(pInfo) + pInfo->EventPropertyInfoArray[ulPropIndex].NameOffset), k }; + PROPERTY_DATA_DESCRIPTOR data_desc = { (ULONGLONG)pInfo + pInfo->EventPropertyInfoArray[ulPropIndex].NameOffset, k }; ulResult = TdhGetProperty(pEvent, 0, NULL, 1, &data_desc, data); } if (ulResult == ERROR_EVT_INVALID_EVENT_DATA) { diff --git a/EventMonitor/ETWLog.h b/EventMonitor/ETWLog.h index 4d997ac..28ffb97 100644 --- a/EventMonitor/ETWLog.h +++ b/EventMonitor/ETWLog.h @@ -150,7 +150,7 @@ protected: private: /// \cond internal - static VOID WINAPI EventRecordCallback(PEVENT_RECORD pEvent); + static VOID WINAPI EventRecordCallback(_In_ PEVENT_RECORD pEvent); /// \endcond protected: diff --git a/EventMonitor/Frame.h b/EventMonitor/Frame.h index 1e751b3..a06bbda 100644 --- a/EventMonitor/Frame.h +++ b/EventMonitor/Frame.h @@ -34,6 +34,9 @@ class wxPersistentEventMonitorFrame; #include +#pragma warning(push) +#pragma warning(disable: 26444) + /// \addtogroup EventMonitor /// @{ @@ -173,3 +176,5 @@ inline wxPersistentObject *wxCreatePersistentObject(wxEventMonitorFrame *wnd) } /// @} + +#pragma warning(pop) diff --git a/MsiUseFeature/Main.cpp b/MsiUseFeature/Main.cpp index 77bc98a..ebdb05b 100644 --- a/MsiUseFeature/Main.cpp +++ b/MsiUseFeature/Main.cpp @@ -76,7 +76,8 @@ static int MsiUseFeature() } -int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) +_Use_decl_annotations_ +int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hInstance); UNREFERENCED_PARAMETER(hPrevInstance); diff --git a/WLANManager/Main.cpp b/WLANManager/Main.cpp index 3f7252a..894346d 100644 --- a/WLANManager/Main.cpp +++ b/WLANManager/Main.cpp @@ -130,6 +130,7 @@ static int WLANManager() // Launch WLAN profile config dialog. WLAN_REASON_CODE wlrc = L2_REASON_CODE_SUCCESS; + #pragma warning(suppress: 6387) // TODO: MSDN nor SAL annotation don't indicate NULL HWND are OK with WlanUIEditProfile(). DWORD dwResult = WlanUIEditProfile(WLAN_UI_API_VERSION, pwcArglist[2], &(interfaces->InterfaceInfo[i].InterfaceGuid), NULL, WLSecurityPage, NULL, &wlrc); if (dwResult != ERROR_SUCCESS) { // WlanUIEditProfile() displays own error dialog on failure. @@ -153,7 +154,8 @@ static int WLANManager() } -int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) +_Use_decl_annotations_ +int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hInstance); UNREFERENCED_PARAMETER(hPrevInstance); diff --git a/include/Common.props b/include/Common.props index b945d22..b358d18 100644 --- a/include/Common.props +++ b/include/Common.props @@ -29,6 +29,9 @@ $(WXWIN)\include\msvc;$(WXWIN)\include;$(IncludePath) $(WXWIN)\src\aui;$(WXWIN)\src\cocoa;$(WXWIN)\src\common;$(WXWIN)\src\dfb;$(WXWIN)\src\expat;$(WXWIN)\src\generic;$(WXWIN)\src\gtk;$(WXWIN)\src\gtk1;$(WXWIN)\src\html;$(WXWIN)\src\jpeg;$(WXWIN)\src\motif;$(WXWIN)\src\msdos;$(WXWIN)\src\msw;$(WXWIN)\src\os2;$(WXWIN)\src\osx;$(WXWIN)\src\png;$(WXWIN)\src\propgrid;$(WXWIN)\src\regex;$(WXWIN)\src\ribbon;$(WXWIN)\src\richtext;$(WXWIN)\src\stc;$(WXWIN)\src\tiff;$(WXWIN)\src\univ;$(WXWIN)\src\unix;$(WXWIN)\src\x11;$(WXWIN)\src\xml;$(WXWIN)\src\xrc;$(WXWIN)\src\zlib;$(SourcePath) false + NativeRecommendedRules.ruleset + true + $(WXWIN);$(CAExcludePath) @@ -38,6 +41,7 @@ StdAfx.h ProgramDatabase true + true true diff --git a/lib/EAPBase/include/Config.h b/lib/EAPBase/include/Config.h index deb509b..cad88c2 100644 --- a/lib/EAPBase/include/Config.h +++ b/lib/EAPBase/include/Config.h @@ -83,7 +83,7 @@ namespace eap /// /// \param[in] other Configuration to move from /// - config(_Inout_ config &&other); + config(_Inout_ config &&other) noexcept; /// /// Copies configuration @@ -101,7 +101,7 @@ namespace eap /// /// \returns Reference to this object /// - config& operator=(_Inout_ config &&other); + config& operator=(_Inout_ config &&other) noexcept; /// /// Clones this object @@ -187,7 +187,7 @@ namespace eap /// /// \param[in] other Configuration to move from /// - config_method(_Inout_ config_method &&other); + config_method(_Inout_ config_method &&other) noexcept; /// /// Copies configuration @@ -205,7 +205,7 @@ namespace eap /// /// \returns Reference to this object /// - config_method& operator=(_Inout_ config_method &&other); + config_method& operator=(_Inout_ config_method &&other) noexcept; /// \name XML management /// @{ @@ -271,7 +271,7 @@ namespace eap /// /// \param[in] other Configuration to move from /// - config_method_with_cred(_Inout_ config_method_with_cred &&other); + config_method_with_cred(_Inout_ config_method_with_cred &&other) noexcept; /// /// Copies configuration @@ -289,7 +289,7 @@ namespace eap /// /// \returns Reference to this object /// - config_method_with_cred& operator=(_Inout_ config_method_with_cred &&other); + config_method_with_cred& operator=(_Inout_ config_method_with_cred &&other) noexcept; /// \name XML management /// @{ @@ -335,7 +335,7 @@ namespace eap /// /// \param[in] other Configuration to move from /// - config_provider(_Inout_ config_provider &&other); + config_provider(_Inout_ config_provider &&other) noexcept; /// /// Copies configuration @@ -353,7 +353,7 @@ namespace eap /// /// \returns Reference to this object /// - config_provider& operator=(_Inout_ config_provider &&other); + config_provider& operator=(_Inout_ config_provider &&other) noexcept; virtual config* clone() const; @@ -431,7 +431,7 @@ namespace eap /// /// \param[in] other Configuration to move from /// - config_connection(_Inout_ config_connection &&other); + config_connection(_Inout_ config_connection &&other) noexcept; /// /// Copies configuration @@ -449,7 +449,7 @@ namespace eap /// /// \returns Reference to this object /// - config_connection& operator=(_Inout_ config_connection &&other); + config_connection& operator=(_Inout_ config_connection &&other) noexcept; virtual config* clone() const; diff --git a/lib/EAPBase/include/Credentials.h b/lib/EAPBase/include/Credentials.h index 7ba4a89..3e63446 100644 --- a/lib/EAPBase/include/Credentials.h +++ b/lib/EAPBase/include/Credentials.h @@ -86,7 +86,7 @@ namespace eap /// /// \param[in] other Credentials to move from /// - credentials(_Inout_ credentials &&other); + credentials(_Inout_ credentials &&other) noexcept; /// /// Copies credentials @@ -104,7 +104,7 @@ namespace eap /// /// \returns Reference to this object /// - credentials& operator=(_Inout_ credentials &&other); + credentials& operator=(_Inout_ credentials &&other) noexcept; /// /// Resets credentials @@ -216,7 +216,7 @@ namespace eap /// virtual source_t combine( _In_ DWORD dwFlags, - _In_ HANDLE hTokenImpersonateUser, + _In_opt_ HANDLE hTokenImpersonateUser, _In_opt_ const credentials *cred_cached, _In_ const config_method &cfg, _In_opt_z_ LPCTSTR pszTargetName) = 0; @@ -251,7 +251,7 @@ namespace eap /// /// \param[in] other Credentials to move from /// - credentials_identity(_Inout_ credentials_identity &&other); + credentials_identity(_Inout_ credentials_identity &&other) noexcept; /// /// Copies credentials @@ -269,7 +269,7 @@ namespace eap /// /// \returns Reference to this object /// - credentials_identity& operator=(_Inout_ credentials_identity &&other); + credentials_identity& operator=(_Inout_ credentials_identity &&other) noexcept; virtual config* clone() const; @@ -311,7 +311,7 @@ namespace eap /// virtual source_t combine( _In_ DWORD dwFlags, - _In_ HANDLE hTokenImpersonateUser, + _In_opt_ HANDLE hTokenImpersonateUser, _In_opt_ const credentials *cred_cached, _In_ const config_method &cfg, _In_opt_z_ LPCTSTR pszTargetName); @@ -354,7 +354,7 @@ namespace eap /// /// \param[in] other Credentials to move from /// - credentials_pass(_Inout_ credentials_pass &&other); + credentials_pass(_Inout_ credentials_pass &&other) noexcept; /// /// Copies credentials @@ -372,7 +372,7 @@ namespace eap /// /// \returns Reference to this object /// - credentials_pass& operator=(_Inout_ credentials_pass &&other); + credentials_pass& operator=(_Inout_ credentials_pass &&other) noexcept; virtual config* clone() const; virtual void clear(); @@ -423,7 +423,7 @@ namespace eap /// virtual source_t combine( _In_ DWORD dwFlags, - _In_ HANDLE hTokenImpersonateUser, + _In_opt_ HANDLE hTokenImpersonateUser, _In_opt_ const credentials *cred_cached, _In_ const config_method &cfg, _In_opt_z_ LPCTSTR pszTargetName); @@ -465,7 +465,7 @@ namespace eap /// /// \param[in] other Credentials to move from /// - credentials_connection(_Inout_ credentials_connection &&other); + credentials_connection(_Inout_ credentials_connection &&other) noexcept; /// /// Copies credentials @@ -483,7 +483,7 @@ namespace eap /// /// \returns Reference to this object /// - credentials_connection& operator=(_Inout_ credentials_connection &&other); + credentials_connection& operator=(_Inout_ credentials_connection &&other) noexcept; virtual config* clone() const; diff --git a/lib/EAPBase/include/EAP.h b/lib/EAPBase/include/EAP.h index df5ac81..cf745dd 100644 --- a/lib/EAPBase/include/EAP.h +++ b/lib/EAPBase/include/EAP.h @@ -551,7 +551,7 @@ inline unsigned __int64 htonll(unsigned __int64 val); /// \param[in ] val A 24-bit unsigned number in host byte order /// \param[out] out A 24-bit unsigned number in network byte order /// -inline void hton24(_In_ unsigned int val, _Out_ unsigned char out[3]); +inline void hton24(_In_ unsigned int val, _Out_writes_(3) unsigned char out[3]); /// /// Converts a 24-bit integer from TCP/IP network to host byte order. @@ -658,6 +658,9 @@ namespace eap /// /// Constructor /// + /// Note: This constructor does not initialize data. Use sanitizing_blob_zf class when zero-initialization is required. + /// + #pragma warning(suppress: 26495) inline sanitizing_blob_f() { } @@ -677,7 +680,7 @@ namespace eap /// /// \param[inout] other BLOB to move from /// - inline sanitizing_blob_f(_Inout_ sanitizing_blob_f &&other) + inline sanitizing_blob_f(_Inout_ sanitizing_blob_f &&other) noexcept { memcpy(data, other.data, N); } @@ -687,7 +690,7 @@ namespace eap /// /// \param[inout] other Zero-initialized BLOB to move from /// - inline sanitizing_blob_f(_Inout_ sanitizing_blob_zf &&other) + inline sanitizing_blob_f(_Inout_ sanitizing_blob_zf &&other) noexcept { memcpy(data, other.data, N); memset(other.data, 0, N); @@ -722,7 +725,7 @@ namespace eap /// /// \returns Reference to this object /// - inline sanitizing_blob_f& operator=(_Inout_ sanitizing_blob_f &&other) + inline sanitizing_blob_f& operator=(_Inout_ sanitizing_blob_f &&other) noexcept { if (this != std::addressof(other)) memcpy(data, other.data, N); @@ -736,7 +739,7 @@ namespace eap /// /// \returns Reference to this object /// - inline sanitizing_blob_f& operator=(_Inout_ sanitizing_blob_zf &&other) + inline sanitizing_blob_f& operator=(_Inout_ sanitizing_blob_zf &&other) noexcept { if (this != std::addressof(other)) { memcpy(data, other.data, N); @@ -827,7 +830,7 @@ namespace eap /// /// \param[inout] other Zero-initialized BLOB to move from /// - inline sanitizing_blob_zf(_Inout_ sanitizing_blob_zf &&other) : + inline sanitizing_blob_zf(_Inout_ sanitizing_blob_zf &&other) noexcept : sanitizing_blob_f(std::move(other)) { memset(other.data, 0, N); @@ -848,7 +851,7 @@ namespace eap /// /// \param[inout] other BLOB to move from /// - inline sanitizing_blob_zf(_Inout_ sanitizing_blob_f &&other) : + inline sanitizing_blob_zf(_Inout_ sanitizing_blob_f &&other) noexcept : sanitizing_blob_f(std::move(other)) { } @@ -874,7 +877,7 @@ namespace eap /// /// \returns Reference to this object /// - inline sanitizing_blob_zf& operator=(_Inout_ sanitizing_blob_zf &&other) + inline sanitizing_blob_zf& operator=(_Inout_ sanitizing_blob_zf &&other) noexcept { if (this != std::addressof(other)) { memcpy(data, other.data, N); @@ -904,7 +907,7 @@ namespace eap /// /// \returns Reference to this object /// - inline sanitizing_blob_zf& operator=(_Inout_ sanitizing_blob_f &&other) + inline sanitizing_blob_zf& operator=(_Inout_ sanitizing_blob_f &&other) noexcept { if (this != std::addressof(other)) memcpy(data, other.data, N); @@ -1110,7 +1113,7 @@ inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::basic_st template inline size_t pksizeof(_In_ const std::basic_string &val) { - return sizeof(char)*(WideCharToMultiByte(CP_UTF8, 0, val.c_str(), (int)val.length(), NULL, 0, NULL, NULL) + 1); + return sizeof(char)*(WideCharToMultiByte(CP_UTF8, 0, val.c_str(), (int)val.length(), NULL, 0, NULL, NULL)) + sizeof(char); } @@ -1407,7 +1410,7 @@ inline unsigned __int64 htonll(unsigned __int64 val) #endif -inline void hton24(_In_ unsigned int val, _Out_ unsigned char out[3]) +inline void hton24(_In_ unsigned int val, _Out_writes_(3) unsigned char out[3]) { assert(val <= 0xffffff); out[0] = (val >> 16) & 0xff; diff --git a/lib/EAPBase/include/EAPXML.h b/lib/EAPBase/include/EAPXML.h index 8c89e3b..3ea0abd 100644 --- a/lib/EAPBase/include/EAPXML.h +++ b/lib/EAPBase/include/EAPXML.h @@ -357,7 +357,7 @@ namespace eapxml /// - <0 if failed. /// Use `SUCCEEDED()` macro to test for first two cases (>=0) or `FAILED()` to test for failure. /// - inline HRESULT put_element_base64(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrElementName, _In_opt_z_ const BSTR bstrNamespace, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen, _Out_opt_ winstd::com_obj *ppXmlElement = NULL); + inline HRESULT put_element_base64(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrElementName, _In_opt_z_ const BSTR bstrNamespace, _In_bytecount_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen, _Out_opt_ winstd::com_obj *ppXmlElement = NULL); /// /// Creates a new child element with hexadecimal encoded text from BLOB @@ -376,7 +376,7 @@ namespace eapxml /// - <0 if failed. /// Use `SUCCEEDED()` macro to test for first two cases (>=0) or `FAILED()` to test for failure. /// - inline HRESULT put_element_hex(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrElementName, _In_opt_z_ const BSTR bstrNamespace, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen, _Out_opt_ winstd::com_obj *ppXmlElement = NULL); + inline HRESULT put_element_hex(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrElementName, _In_opt_z_ const BSTR bstrNamespace, _In_bytecount_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen, _Out_opt_ winstd::com_obj *ppXmlElement = NULL); /// /// Returns attribute text @@ -481,7 +481,7 @@ namespace eapxml /// - <0 if failed. /// Use `SUCCEEDED()` macro to test for first two cases (>=0) or `FAILED()` to test for failure. /// - inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_opt_z_ _In_z_ const BSTR bstrValue); + inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_z_ const BSTR bstrValue); /// /// Sets node attribute converted from number @@ -496,7 +496,7 @@ namespace eapxml /// - <0 if failed. /// Use `SUCCEEDED()` macro to test for first two cases (>=0) or `FAILED()` to test for failure. /// - inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_opt_z_ _In_ DWORD dwValue); + inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_ DWORD dwValue); /// /// Sets node attribute converted from boolean @@ -511,7 +511,7 @@ namespace eapxml /// - <0 if failed. /// Use `SUCCEEDED()` macro to test for first two cases (>=0) or `FAILED()` to test for failure. /// - inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_opt_z_ _In_ bool bValue); + inline HRESULT put_attrib_value(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_ bool bValue); /// /// Sets node attribute to Base64 encoded text from BLOB @@ -527,7 +527,7 @@ namespace eapxml /// - <0 if failed. /// Use `SUCCEEDED()` macro to test for first two cases (>=0) or `FAILED()` to test for failure. /// - inline HRESULT put_attrib_base64(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_opt_z_ _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen); + inline HRESULT put_attrib_base64(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_bytecount_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen); /// /// Sets node attribute to hexadecimal encoded text from BLOB /// @@ -542,7 +542,7 @@ namespace eapxml /// - <0 if failed. /// Use `SUCCEEDED()` macro to test for first two cases (>=0) or `FAILED()` to test for failure. /// - inline HRESULT put_attrib_hex(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen); + inline HRESULT put_attrib_hex(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_bytecount_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen); /// /// Builds XPath for a given node @@ -786,7 +786,7 @@ namespace eapxml pbstrValue = std::move(bstrEn); return S_OK; } else - return ERROR_NOT_FOUND; + return HRESULT_FROM_WIN32(ERROR_NOT_FOUND); } winstd::com_obj pXmlElLocalizedText; @@ -831,7 +831,6 @@ namespace eapxml { assert(pDoc); assert(pCurrentDOMNode); - assert(ppXmlElement); static const VARIANT varNodeTypeEl = { VT_I4, 0, 0, 0, { NODE_ELEMENT } }; HRESULT hr; @@ -878,7 +877,7 @@ namespace eapxml } - inline HRESULT put_element_base64(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrElementName, _In_opt_z_ const BSTR bstrNamespace, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen, _Out_opt_ winstd::com_obj *ppXmlElement) + inline HRESULT put_element_base64(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrElementName, _In_opt_z_ const BSTR bstrNamespace, _In_bytecount_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen, _Out_opt_ winstd::com_obj *ppXmlElement) { std::wstring sBase64; winstd::base64_enc enc; @@ -887,7 +886,7 @@ namespace eapxml } - inline HRESULT put_element_hex(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrElementName, _In_opt_z_ const BSTR bstrNamespace, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen, _Out_opt_ winstd::com_obj *ppXmlElement) + inline HRESULT put_element_hex(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrElementName, _In_opt_z_ const BSTR bstrNamespace, _In_bytecount_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen, _Out_opt_ winstd::com_obj *ppXmlElement) { std::wstring sHex; winstd::hex_enc enc; @@ -936,8 +935,6 @@ namespace eapxml inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ bool &pbValue) { - assert(pbValue); - winstd::bstr bstr; HRESULT hr = get_attrib_value(pXmlParent, bstrAttributeName, bstr); if (SUCCEEDED(hr)) { @@ -1012,7 +1009,7 @@ namespace eapxml } - inline HRESULT put_attrib_base64(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen) + inline HRESULT put_attrib_base64(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_bytecount_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen) { std::wstring sBase64; winstd::base64_enc enc; @@ -1021,7 +1018,7 @@ namespace eapxml } - inline HRESULT put_attrib_hex(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_count_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen) + inline HRESULT put_attrib_hex(_In_ IXMLDOMNode *pCurrentDOMNode, _In_z_ const BSTR bstrAttributeName, _In_bytecount_(nValueLen) LPCVOID pValue, _In_ SIZE_T nValueLen) { std::wstring sHex; winstd::hex_enc enc; diff --git a/lib/EAPBase/include/Method.h b/lib/EAPBase/include/Method.h index 3afea6e..967915c 100644 --- a/lib/EAPBase/include/Method.h +++ b/lib/EAPBase/include/Method.h @@ -69,7 +69,7 @@ namespace eap /// /// \param[in] other Method to move from /// - method(_Inout_ method &&other); + method(_Inout_ method &&other) noexcept; /// /// Moves a method @@ -78,7 +78,7 @@ namespace eap /// /// \returns Reference to this object /// - method& operator=(_Inout_ method &&other); + method& operator=(_Inout_ method &&other) noexcept; /// \name Session management /// @{ @@ -144,12 +144,12 @@ namespace eap /// /// \sa [EapPeerGetResult function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363611.aspx) /// - /// \param[in ] reason The reason code for the authentication result returned in \p pResult. - /// \param[out] pResult A pointer to a structure that contains the authentication results. + /// \param[in ] reason The reason code for the authentication result returned in \p pResult. + /// \param[inout] pResult A pointer to a structure that contains the authentication results. /// virtual void get_result( - _In_ EapPeerMethodResultReason reason, - _Out_ EapPeerMethodResult *pResult); + _In_ EapPeerMethodResultReason reason, + _Inout_ EapPeerMethodResult *pResult); /// \name User Interaction /// @{ @@ -236,7 +236,7 @@ namespace eap /// /// \param[in] other Method to move from /// - method_tunnel(_Inout_ method_tunnel &&other); + method_tunnel(_Inout_ method_tunnel &&other) noexcept; /// /// Moves a method @@ -245,7 +245,7 @@ namespace eap /// /// \returns Reference to this object /// - method_tunnel& operator=(_Inout_ method_tunnel &&other); + method_tunnel& operator=(_Inout_ method_tunnel &&other) noexcept; /// \name Session management /// @{ @@ -274,8 +274,8 @@ namespace eap /// @} virtual void get_result( - _In_ EapPeerMethodResultReason reason, - _Out_ EapPeerMethodResult *pResult); + _In_ EapPeerMethodResultReason reason, + _Inout_ EapPeerMethodResult *pResult); /// \name User Interaction /// @{ @@ -326,7 +326,7 @@ namespace eap /// /// \param[in] other Method to move from /// - method_eap(_Inout_ method_eap &&other); + method_eap(_Inout_ method_eap &&other) noexcept; /// /// Moves a method @@ -335,7 +335,7 @@ namespace eap /// /// \returns Reference to this object /// - method_eap& operator=(_Inout_ method_eap &&other); + method_eap& operator=(_Inout_ method_eap &&other) noexcept; /// \name Session management /// @{ diff --git a/lib/EAPBase/include/Module.h b/lib/EAPBase/include/Module.h index 9109e8a..3cd4f15 100644 --- a/lib/EAPBase/include/Module.h +++ b/lib/EAPBase/include/Module.h @@ -93,17 +93,17 @@ namespace eap /// /// Allocate BLOB /// - BYTE* alloc_memory(_In_ size_t size); + BYTE* alloc_memory(_In_ size_t size) const; /// /// Free BLOB allocated with this peer /// - void free_memory(_In_ BYTE *ptr); + void free_memory(_In_ BYTE *ptr) const; /// /// Free EAP_ERROR allocated with `make_error()` method /// - void free_error_memory(_In_ EAP_ERROR *err); + void free_error_memory(_In_ EAP_ERROR *err) const; /// /// Makes a new method configuration @@ -147,6 +147,35 @@ namespace eap /// void log_error(_In_ const EAP_ERROR *err) const; + /// + /// Logs error and optionally returns EAP_ERROR + /// + inline DWORD log_error(_Out_opt_ EAP_ERROR **eap_err, _In_ DWORD dwErrorCode, _In_opt_z_ LPCWSTR pszRootCauseString = NULL, _In_opt_z_ LPCWSTR pszRepairString = NULL, _In_opt_ DWORD dwReasonCode = 0, _In_opt_ LPCGUID pRootCauseGuid = NULL, _In_opt_ LPCGUID pRepairGuid = NULL, _In_opt_ LPCGUID pHelpLinkGuid = NULL) const + { + EAP_ERROR *e = make_error(dwErrorCode, pszRootCauseString, pszRepairString, dwReasonCode, pRootCauseGuid, pRepairGuid, pHelpLinkGuid); + log_error(e); + if (eap_err) + *eap_err = e; + else + free_error_memory(e); + return dwErrorCode; + } + + /// + /// Logs error and optionally returns EAP_ERROR + /// + inline DWORD log_error(_Out_opt_ EAP_ERROR **eap_err, _In_ std::exception &err) const + { + EAP_ERROR *e = make_error(err); + log_error(e); + DWORD dwWinError = e->dwWinError; + if (eap_err) + *eap_err = e; + else + free_error_memory(e); + return dwWinError; + } + /// /// Logs Unicode string config value /// @@ -288,7 +317,7 @@ namespace eap /// /// \returns Encrypted data /// - std::vector encrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_opt_ HCRYPTHASH hHash = NULL) const; + std::vector encrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _In_opt_ HCRYPTHASH hHash = NULL) const; /// @@ -301,7 +330,7 @@ namespace eap /// \returns Encrypted data /// template - std::vector encrypt(_In_ HCRYPTPROV hProv, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val, _Out_opt_ HCRYPTHASH hHash = NULL) const + std::vector encrypt(_In_ HCRYPTPROV hProv, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val, _In_opt_ HCRYPTHASH hHash = NULL) const { return encrypt(hProv, val.c_str(), val.length()*sizeof(_Elem), hHash); } @@ -317,7 +346,7 @@ namespace eap /// \returns Encrypted data /// template - std::vector encrypt(_In_ HCRYPTPROV hProv, _In_ const std::basic_string &val, _Out_opt_ HCRYPTHASH hHash = NULL) const + std::vector encrypt(_In_ HCRYPTPROV hProv, _In_ const std::basic_string &val, _In_opt_ HCRYPTHASH hHash = NULL) const { winstd::sanitizing_string val_utf8; WideCharToMultiByte(CP_UTF8, 0, val, val_utf8, NULL, NULL); @@ -380,13 +409,15 @@ namespace eap /// \returns Decrypted data /// template - std::vector<_Ty, _Ax> decrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_opt_ HCRYPTHASH hHash = NULL) const + std::vector<_Ty, _Ax> decrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _In_opt_ HCRYPTHASH hHash = NULL) const { // Import the private RSA key. HRSRC res = FindResource(m_instance, MAKEINTRESOURCE(IDR_EAP_KEY_PRIVATE), RT_RCDATA); - assert(res); + if (!res) + throw winstd::win_runtime_error(__FUNCTION__ " FindResource failed."); HGLOBAL res_handle = LoadResource(m_instance, res); - assert(res_handle); + if (!res_handle) + throw winstd::win_runtime_error(__FUNCTION__ " LoadResource failed."); winstd::crypt_key key_rsa; std::unique_ptr > keyinfo_data; DWORD keyinfo_size = 0; @@ -423,7 +454,7 @@ namespace eap /// \returns Decrypted string /// template - std::basic_string<_Elem, _Traits, _Ax> decrypt_str(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_opt_ HCRYPTHASH hHash = NULL) const + std::basic_string<_Elem, _Traits, _Ax> decrypt_str(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _In_opt_ HCRYPTHASH hHash = NULL) const { std::vector<_Elem, sanitizing_allocator<_Elem> > buf(std::move(decrypt(hProv, data, size, hHash))); return std::basic_string<_Elem, _Traits, _Ax>(buf.data(), buf.size()); @@ -441,7 +472,7 @@ namespace eap /// \returns Decrypted string /// template - std::basic_string decrypt_str(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_opt_ HCRYPTHASH hHash = NULL) const + std::basic_string decrypt_str(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _In_opt_ HCRYPTHASH hHash = NULL) const { winstd::sanitizing_string buf(std::move(decrypt_str(hProv, data, size, hHash))); std::basic_string dec; @@ -865,13 +896,13 @@ namespace eap /// \param[out] ppDataFromInteractiveUI A pointer that receives a credentials BLOB that can be used in authentication. The caller should free the inner pointers using the function \p EapPeerFreeMemory(), starting at the innermost pointer. If a non-NULL value is supplied for this parameter, meaning that an existing data BLOB is passed to it, the supplied data BLOB will be updated and returned in this parameter. /// virtual void query_ui_blob_from_interactive_ui_input_fields( - _In_ DWORD dwVersion, - _In_ DWORD dwFlags, - _In_ DWORD dwUIContextDataSize, - _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, - _In_ const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData, - _Out_ DWORD *pdwDataFromInteractiveUISize, - _Out_ BYTE **ppDataFromInteractiveUI) const; + _In_ DWORD dwVersion, + _In_ DWORD dwFlags, + _In_ DWORD dwUIContextDataSize, + _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, + _In_ const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData, + _Out_ DWORD *pdwDataFromInteractiveUISize, + _Outptr_result_buffer_(*pdwDataFromInteractiveUISize) BYTE **ppDataFromInteractiveUI) const; /// \name Session management /// @{ @@ -942,9 +973,9 @@ namespace eap /// \param[inout] pdwSendPacketSize A pointer to a value that contains the size in bytes of the buffer allocated for the response packet. On return, this parameter receives a pointer to the actual size in bytes of \p pSendPacket. /// virtual void get_response_packet( - _In_ EAP_SESSION_HANDLE hSession, - _Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket, - _Inout_ DWORD *pdwSendPacketSize) = 0; + _In_ EAP_SESSION_HANDLE hSession, + _Out_bytecapcount_(*pdwSendPacketSize) EapPacket *pSendPacket, + _Inout_ DWORD *pdwSendPacketSize) = 0; /// @} @@ -953,14 +984,14 @@ namespace eap /// /// \sa [EapPeerGetResult function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363611.aspx) /// - /// \param[in ] hSession A unique handle for this EAP authentication session on the EAPHost server. This handle is returned in the \p pSessionHandle parameter in a previous call to `EapPeerBeginSession()`. - /// \param[in ] reason The reason code for the authentication result returned in \p pResult. - /// \param[out] pResult A pointer to a structure that contains the authentication results. + /// \param[in ] hSession A unique handle for this EAP authentication session on the EAPHost server. This handle is returned in the \p pSessionHandle parameter in a previous call to `EapPeerBeginSession()`. + /// \param[in ] reason The reason code for the authentication result returned in \p pResult. + /// \param[inout] pResult A pointer to a structure that contains the authentication results. /// virtual void get_result( - _In_ EAP_SESSION_HANDLE hSession, - _In_ EapPeerMethodResultReason reason, - _Out_ EapPeerMethodResult *pResult) = 0; + _In_ EAP_SESSION_HANDLE hSession, + _In_ EapPeerMethodResultReason reason, + _Inout_ EapPeerMethodResult *pResult) = 0; /// \name User Interaction /// @{ diff --git a/lib/EAPBase/include/UIContext.h b/lib/EAPBase/include/UIContext.h index 2d3c34e..6035aec 100644 --- a/lib/EAPBase/include/UIContext.h +++ b/lib/EAPBase/include/UIContext.h @@ -66,7 +66,7 @@ namespace eap /// /// \param[in] other Credentials to move from /// - ui_context(_Inout_ ui_context &&other); + ui_context(_Inout_ ui_context &&other) noexcept; /// /// Copies context @@ -84,7 +84,7 @@ namespace eap /// /// \returns Reference to this object /// - ui_context& operator=(_Inout_ ui_context &&other); + ui_context& operator=(_Inout_ ui_context &&other) noexcept; /// \name BLOB management /// @{ diff --git a/lib/EAPBase/src/Config.cpp b/lib/EAPBase/src/Config.cpp index 1e87c3c..c50e1b8 100644 --- a/lib/EAPBase/src/Config.cpp +++ b/lib/EAPBase/src/Config.cpp @@ -40,7 +40,7 @@ eap::config::config(_In_ const config &other) : } -eap::config::config(_Inout_ config &&other) : +eap::config::config(_Inout_ config &&other) noexcept : m_module(other.m_module) { } @@ -55,7 +55,7 @@ eap::config& eap::config::operator=(_In_ const config &other) } -eap::config& eap::config::operator=(_Inout_ config &&other) +eap::config& eap::config::operator=(_Inout_ config &&other) noexcept { if (this != &other) assert(&m_module == &other.m_module); @@ -103,7 +103,7 @@ eap::config_method::config_method(_In_ const config_method &other) : } -eap::config_method::config_method(_Inout_ config_method &&other) : +eap::config_method::config_method(_Inout_ config_method &&other) noexcept : m_level (std::move(other.m_level )), m_allow_save (std::move(other.m_allow_save )), m_last_status(std::move(other.m_last_status)), @@ -127,7 +127,7 @@ eap::config_method& eap::config_method::operator=(_In_ const config_method &othe } -eap::config_method& eap::config_method::operator=(_Inout_ config_method &&other) +eap::config_method& eap::config_method::operator=(_Inout_ config_method &&other) noexcept { if (this != &other) { assert(m_level == other.m_level); // Allow move within same configuration level only. @@ -231,7 +231,7 @@ eap::config_method_with_cred::config_method_with_cred(_In_ const config_method_w } -eap::config_method_with_cred::config_method_with_cred(_Inout_ config_method_with_cred &&other) : +eap::config_method_with_cred::config_method_with_cred(_Inout_ config_method_with_cred &&other) noexcept : m_use_cred (std::move(other.m_use_cred)), m_cred (std::move(other.m_cred )), config_method(std::move(other )) @@ -251,7 +251,7 @@ eap::config_method_with_cred& eap::config_method_with_cred::operator=(_In_ const } -eap::config_method_with_cred& eap::config_method_with_cred::operator=(_Inout_ config_method_with_cred &&other) +eap::config_method_with_cred& eap::config_method_with_cred::operator=(_Inout_ config_method_with_cred &&other) noexcept { if (this != &other) { (config_method&)*this = std::move(other ); @@ -362,7 +362,7 @@ eap::config_provider::config_provider(_In_ const config_provider &other) : } -eap::config_provider::config_provider(_Inout_ config_provider &&other) : +eap::config_provider::config_provider(_Inout_ config_provider &&other) noexcept : m_namespace (std::move(other.m_namespace )), m_id (std::move(other.m_id )), m_read_only (std::move(other.m_read_only )), @@ -404,7 +404,7 @@ eap::config_provider& eap::config_provider::operator=(_In_ const config_provider } -eap::config_provider& eap::config_provider::operator=(_Inout_ config_provider &&other) +eap::config_provider& eap::config_provider::operator=(_Inout_ config_provider &&other) noexcept { if (this != &other) { (config&&)*this = std::move(other ); @@ -700,7 +700,7 @@ eap::config_connection::config_connection(_In_ const config_connection &other) : } -eap::config_connection::config_connection(_Inout_ config_connection &&other) : +eap::config_connection::config_connection(_Inout_ config_connection &&other) noexcept : m_providers(std::move(other.m_providers)), config (std::move(other )) { @@ -718,7 +718,7 @@ eap::config_connection& eap::config_connection::operator=(_In_ const config_conn } -eap::config_connection& eap::config_connection::operator=(_Inout_ config_connection &&other) +eap::config_connection& eap::config_connection::operator=(_Inout_ config_connection &&other) noexcept { if (this != &other) { (config&&)*this = std::move(other ); diff --git a/lib/EAPBase/src/Credentials.cpp b/lib/EAPBase/src/Credentials.cpp index ebf854b..cac82ac 100644 --- a/lib/EAPBase/src/Credentials.cpp +++ b/lib/EAPBase/src/Credentials.cpp @@ -53,7 +53,7 @@ eap::credentials::credentials(_In_ const credentials &other) : } -eap::credentials::credentials(_Inout_ credentials &&other) : +eap::credentials::credentials(_Inout_ credentials &&other) noexcept : m_identity(std::move(other.m_identity)), config(std::move(other)) { @@ -71,7 +71,7 @@ eap::credentials& eap::credentials::operator=(_In_ const credentials &other) } -eap::credentials& eap::credentials::operator=(_Inout_ credentials &&other) +eap::credentials& eap::credentials::operator=(_Inout_ credentials &&other) noexcept { if (this != &other) { (config&)*this = std::move(other); @@ -177,7 +177,7 @@ eap::credentials_identity::credentials_identity(_In_ const credentials_identity } -eap::credentials_identity::credentials_identity(_Inout_ credentials_identity &&other) : credentials(std::move(other)) +eap::credentials_identity::credentials_identity(_Inout_ credentials_identity &&other) noexcept : credentials(std::move(other)) { } @@ -191,7 +191,7 @@ eap::credentials_identity& eap::credentials_identity::operator=(_In_ const crede } -eap::credentials_identity& eap::credentials_identity::operator=(_Inout_ credentials_identity &&other) +eap::credentials_identity& eap::credentials_identity::operator=(_Inout_ credentials_identity &&other) noexcept { if (this != &other) (credentials&)*this = std::move(other); @@ -297,7 +297,7 @@ LPCTSTR eap::credentials_identity::target_suffix() const eap::credentials::source_t eap::credentials_identity::combine( _In_ DWORD dwFlags, - _In_ HANDLE hTokenImpersonateUser, + _In_opt_ HANDLE hTokenImpersonateUser, _In_opt_ const credentials *cred_cached, _In_ const config_method &cfg, _In_opt_z_ LPCTSTR pszTargetName) @@ -359,7 +359,7 @@ eap::credentials_pass::credentials_pass(_In_ const credentials_pass &other) : } -eap::credentials_pass::credentials_pass(_Inout_ credentials_pass &&other) : +eap::credentials_pass::credentials_pass(_Inout_ credentials_pass &&other) noexcept : m_password (std::move(other.m_password)), m_enc_alg (std::move(other.m_enc_alg )), credentials(std::move(other )) @@ -379,7 +379,7 @@ eap::credentials_pass& eap::credentials_pass::operator=(_In_ const credentials_p } -eap::credentials_pass& eap::credentials_pass::operator=(_Inout_ credentials_pass &&other) +eap::credentials_pass& eap::credentials_pass::operator=(_Inout_ credentials_pass &&other) noexcept { if (this != &other) { (credentials&)*this = std::move(other ); @@ -603,7 +603,7 @@ LPCTSTR eap::credentials_pass::target_suffix() const eap::credentials::source_t eap::credentials_pass::combine( _In_ DWORD dwFlags, - _In_ HANDLE hTokenImpersonateUser, + _In_opt_ HANDLE hTokenImpersonateUser, _In_opt_ const credentials *cred_cached, _In_ const config_method &cfg, _In_opt_z_ LPCTSTR pszTargetName) @@ -737,7 +737,7 @@ eap::credentials_connection::credentials_connection(_In_ const credentials_conne } -eap::credentials_connection::credentials_connection(_Inout_ credentials_connection &&other) : +eap::credentials_connection::credentials_connection(_Inout_ credentials_connection &&other) noexcept : m_cfg ( other.m_cfg ), m_namespace(std::move(other.m_namespace)), m_id (std::move(other.m_id )), @@ -760,7 +760,7 @@ eap::credentials_connection& eap::credentials_connection::operator=(_In_ const c } -eap::credentials_connection& eap::credentials_connection::operator=(_Inout_ credentials_connection &&other) +eap::credentials_connection& eap::credentials_connection::operator=(_Inout_ credentials_connection &&other) noexcept { if (this != &other) { (config&)*this = std::move(other ); @@ -948,7 +948,7 @@ template inline static basic_string<_Elem, _Traits, _Ax> kph_encrypt(_In_ HCRYPTPROV hProv, _In_z_ const char *src) { basic_string<_Elem, _Traits, _Ax> str; - unsigned short key[8]; + unsigned short key[8] = { 0 }; // Generate the key. if (!CryptGenRandom(hProv, sizeof(key), (BYTE*)key)) diff --git a/lib/EAPBase/src/Method.cpp b/lib/EAPBase/src/Method.cpp index a139a3b..91cfaec 100644 --- a/lib/EAPBase/src/Method.cpp +++ b/lib/EAPBase/src/Method.cpp @@ -34,13 +34,13 @@ eap::method::method(_In_ module &mod) : } -eap::method::method(_Inout_ method &&other) : +eap::method::method(_Inout_ method &&other) noexcept : m_module(other.m_module) { } -eap::method& eap::method::operator=(_Inout_ method &&other) +eap::method& eap::method::operator=(_Inout_ method &&other) noexcept { if (this != std::addressof(other)) { assert(std::addressof(m_module) == std::addressof(other.m_module)); // Move method within same module only! @@ -96,7 +96,7 @@ EapPeerMethodResponseAction eap::method::set_ui_context( } -void eap::method::get_response_attributes(_Inout_ EapAttributes *pAttribs) +void eap::method::get_response_attributes(_Out_ EapAttributes *pAttribs) { assert(pAttribs); @@ -126,14 +126,14 @@ eap::method_tunnel::method_tunnel(_In_ module &mod, _In_ method *inner) : } -eap::method_tunnel::method_tunnel(_Inout_ method_tunnel &&other) : +eap::method_tunnel::method_tunnel(_Inout_ method_tunnel &&other) noexcept : m_inner(std::move(other.m_inner)), method (std::move(other )) { } -eap::method_tunnel& eap::method_tunnel::operator=(_Inout_ method_tunnel &&other) +eap::method_tunnel& eap::method_tunnel::operator=(_Inout_ method_tunnel &&other) noexcept { if (this != std::addressof(other)) { (method&)*this = std::move(other ); @@ -213,7 +213,7 @@ EapPeerMethodResponseAction eap::method_tunnel::set_ui_context( } -void eap::method_tunnel::get_response_attributes(_Inout_ EapAttributes *pAttribs) +void eap::method_tunnel::get_response_attributes(_Out_ EapAttributes *pAttribs) { assert(m_inner); m_inner->get_response_attributes(pAttribs); @@ -240,7 +240,7 @@ eap::method_eap::method_eap(_In_ module &mod, _In_ winstd::eap_type_t eap_method } -eap::method_eap::method_eap(_Inout_ method_eap &&other) : +eap::method_eap::method_eap(_Inout_ method_eap &&other) noexcept : m_eap_method (std::move(other.m_eap_method)), m_id (std::move(other.m_id )), m_send_nak (std::move(other.m_send_nak )), @@ -249,7 +249,7 @@ eap::method_eap::method_eap(_Inout_ method_eap &&other) : } -eap::method_eap& eap::method_eap::operator=(_Inout_ method_eap &&other) +eap::method_eap& eap::method_eap::operator=(_Inout_ method_eap &&other) noexcept { if (this != std::addressof(other)) { assert(m_eap_method == other.m_eap_method); // Move method within same EAP method type only! @@ -274,7 +274,7 @@ void eap::method_eap::begin_session( // Inner method can generate packets of up to 64kB (less the EAP packet header). // Initialize inner method with appropriately less packet size maximum. if (dwMaxSendPacketSize < sizeof(EapPacket)) - throw invalid_argument(string_printf(__FUNCTION__ " Maximum packet size too small (minimum: %u, available: %u).", sizeof(EapPacket) + 1, dwMaxSendPacketSize)); + throw invalid_argument(string_printf(__FUNCTION__ " Maximum packet size too small (minimum: %zu, available: %u).", sizeof(EapPacket) + 1, dwMaxSendPacketSize)); assert(m_inner); m_inner->begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, std::min(dwMaxSendPacketSize, MAXWORD) - sizeof(EapPacket)); } @@ -337,7 +337,7 @@ void eap::method_eap::get_response_packet( // Check packet size. We will suggest one EAP method alone, so we need one byte for data. size_t size_packet = sizeof(EapPacket) + 1; if (size_packet > size_max) - throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %u, maximum: %u).", size_packet, size_max)); + throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %zu, maximum: %u).", size_packet, size_max)); packet.reserve(size_packet); // To avoid reallocation when inserting EAP packet header later. // Data of Legacy Nak packet is a list of supported EAP types: our method alone. diff --git a/lib/EAPBase/src/Module.cpp b/lib/EAPBase/src/Module.cpp index 21f9cc4..274c4f9 100644 --- a/lib/EAPBase/src/Module.cpp +++ b/lib/EAPBase/src/Module.cpp @@ -28,7 +28,7 @@ using namespace winstd; // eap::module ////////////////////////////////////////////////////////////////////// -eap::module::module(eap_type_t eap_method) : +eap::module::module(_In_ eap_type_t eap_method) : m_eap_method(eap_method), m_instance(NULL) { @@ -141,16 +141,16 @@ EAP_ERROR* eap::module::make_error(_In_ const EAP_ERROR *err) const } -BYTE* eap::module::alloc_memory(_In_ size_t size) +BYTE* eap::module::alloc_memory(_In_ size_t size) const { BYTE *p = (BYTE*)HeapAlloc(m_heap, 0, size); if (!p) - throw win_runtime_error(winstd::string_printf(__FUNCTION__ " Error allocating memory for BLOB (%uB).", size)); + throw win_runtime_error(winstd::string_printf(__FUNCTION__ " Error allocating memory for BLOB (%zuB).", size)); return p; } -void eap::module::free_memory(_In_ BYTE *ptr) +void eap::module::free_memory(_In_ BYTE *ptr) const { #if !EAP_ENCRYPT_BLOBS // Since we do security here and some of the BLOBs contain credentials, sanitize every memory block before freeing. @@ -160,7 +160,7 @@ void eap::module::free_memory(_In_ BYTE *ptr) } -void eap::module::free_error_memory(_In_ EAP_ERROR *err) +void eap::module::free_error_memory(_In_ EAP_ERROR *err) const { // pRootCauseString and pRepairString always trail the ppEapError to reduce number of (de)allocations. HeapFree(m_heap, 0, err); @@ -193,7 +193,7 @@ eap::config_method* eap::module::make_config_method() } -std::vector eap::module::encrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_opt_ HCRYPTHASH hHash) const +std::vector eap::module::encrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _In_opt_ HCRYPTHASH hHash) const { // Generate 256-bit AES session key. crypt_key key_aes; @@ -202,9 +202,11 @@ std::vector eap::module::encrypt(_In_ HCRYPTPROV hProv, _In_bytec // Import the public RSA key. HRSRC res = FindResource(m_instance, MAKEINTRESOURCE(IDR_EAP_KEY_PUBLIC), RT_RCDATA); - assert(res); + if (!res) + throw winstd::win_runtime_error(__FUNCTION__ " FindResource failed."); HGLOBAL res_handle = LoadResource(m_instance, res); - assert(res_handle); + if (!res_handle) + throw winstd::win_runtime_error(__FUNCTION__ " LoadResource failed."); crypt_key key_rsa; unique_ptr > keyinfo_data; DWORD keyinfo_size = 0; @@ -321,13 +323,13 @@ void eap::peer::query_interactive_ui_input_fields( void eap::peer::query_ui_blob_from_interactive_ui_input_fields( - _In_ DWORD dwVersion, - _In_ DWORD dwFlags, - _In_ DWORD dwUIContextDataSize, - _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, - _In_ const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData, - _Out_ DWORD *pdwDataFromInteractiveUISize, - _Out_ BYTE **ppDataFromInteractiveUI) const + _In_ DWORD dwVersion, + _In_ DWORD dwFlags, + _In_ DWORD dwUIContextDataSize, + _In_count_(dwUIContextDataSize) const BYTE *pUIContextData, + _In_ const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData, + _Out_ DWORD *pdwDataFromInteractiveUISize, + _Outptr_result_buffer_(*pdwDataFromInteractiveUISize) BYTE **ppDataFromInteractiveUI) const { UNREFERENCED_PARAMETER(dwVersion); UNREFERENCED_PARAMETER(dwFlags); diff --git a/lib/EAPBase/src/UIContext.cpp b/lib/EAPBase/src/UIContext.cpp index e2f1946..84ab069 100644 --- a/lib/EAPBase/src/UIContext.cpp +++ b/lib/EAPBase/src/UIContext.cpp @@ -43,7 +43,7 @@ eap::ui_context::ui_context(_In_ const ui_context &other) : } -eap::ui_context::ui_context(_Inout_ ui_context &&other) : +eap::ui_context::ui_context(_Inout_ ui_context &&other) noexcept : m_cfg ( other.m_cfg ), m_cred ( other.m_cred ), packable(std::move(other )) @@ -63,7 +63,7 @@ eap::ui_context& eap::ui_context::operator=(_In_ const ui_context &other) } -eap::ui_context& eap::ui_context::operator=(_Inout_ ui_context &&other) +eap::ui_context& eap::ui_context::operator=(_Inout_ ui_context &&other) noexcept { if (this != &other) { assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move context within same configuration only! diff --git a/lib/EAPBase_UI/include/EAP_UI.h b/lib/EAPBase_UI/include/EAP_UI.h index f167d46..2166ffd 100644 --- a/lib/EAPBase_UI/include/EAP_UI.h +++ b/lib/EAPBase_UI/include/EAP_UI.h @@ -108,8 +108,10 @@ inline void wxInitializeConfig(); #pragma once -#include // Fixes `CreateDialog` name collision +#pragma warning(push) +#pragma warning(disable: 26444) #include "../res/wxEAP_UI.h" +#pragma warning(pop) #include "../../EAPBase/include/Config.h" #include "../../EAPBase/include/Credentials.h" @@ -126,6 +128,10 @@ inline void wxInitializeConfig(); #include #include +#pragma warning(push) +#pragma warning(disable: 26444) + + /// \addtogroup EAPBaseGUI /// @{ @@ -195,7 +201,7 @@ public: m_providers), is_single ? wxEAPGetProviderName(provider->m_name) : - winstd::tstring_printf(_T("%s (%u)"), static_cast(wxEAPGetProviderName(provider->m_name)), count)); + winstd::tstring_printf(_T("%s (%zu)"), static_cast(wxEAPGetProviderName(provider->m_name)), count)); } } @@ -248,7 +254,11 @@ protected: // Create provider. eap::config_provider cfg_provider(m_cfg.m_module); GUID guid; - CoCreateGuid(&guid); + HRESULT hr = CoCreateGuid(&guid); + if (FAILED(hr)) { + wxLogError(winstd::tstring_printf(wxT("error 0x%08x generating GUID"), hr).c_str()); + return; + } cfg_provider.m_namespace = L"urn:uuid"; cfg_provider.m_id = winstd::wstring_guid(guid).substr(1, 36); cfg_provider.m_methods.push_back(std::move(cfg_method)); @@ -258,7 +268,7 @@ protected: eap::config_provider &cfg_provider2 = m_cfg.m_providers.back(); eap::config_method *cfg_method2 = cfg_provider2.m_methods.front().get(); _wxT *page = new _wxT(cfg_provider2, *cfg_method2, m_providers); - m_providers->InsertPage(m_providers->GetSelection() + 1, page, wxEAPGetProviderName(cfg_provider2.m_name), true); + m_providers->InsertPage((size_t)m_providers->GetSelection() + 1, page, wxEAPGetProviderName(cfg_provider2.m_name), true); this->Layout(); this->GetSizer()->Fit(this); @@ -1132,3 +1142,5 @@ inline void wxInitializeConfig() wxConfigBase *cfgPrev = wxConfigBase::Set(new wxConfig(wxT(PRODUCT_NAME_STR), wxT(VENDOR_NAME_STR))); if (cfgPrev) wxDELETE(cfgPrev); } + +#pragma warning(pop) diff --git a/lib/EapHost/include/Config.h b/lib/EapHost/include/Config.h index d78de00..b1fce2f 100644 --- a/lib/EapHost/include/Config.h +++ b/lib/EapHost/include/Config.h @@ -65,7 +65,7 @@ namespace eap /// /// \param[in] other Configuration to move from /// - config_method_eaphost(_Inout_ config_method_eaphost &&other); + config_method_eaphost(_Inout_ config_method_eaphost &&other) noexcept; /// /// Copies configuration @@ -83,7 +83,7 @@ namespace eap /// /// \returns Reference to this object /// - config_method_eaphost& operator=(_Inout_ config_method_eaphost &&other); + config_method_eaphost& operator=(_Inout_ config_method_eaphost &&other) noexcept; virtual config* clone() const; diff --git a/lib/EapHost/include/Credentials.h b/lib/EapHost/include/Credentials.h index e25dd15..ebe667c 100644 --- a/lib/EapHost/include/Credentials.h +++ b/lib/EapHost/include/Credentials.h @@ -67,7 +67,7 @@ namespace eap /// /// \param[in] other Credentials to move from /// - credentials_eaphost(_Inout_ credentials_eaphost &&other); + credentials_eaphost(_Inout_ credentials_eaphost &&other) noexcept; /// /// Copies credentials @@ -85,7 +85,7 @@ namespace eap /// /// \returns Reference to this object /// - credentials_eaphost& operator=(_Inout_ credentials_eaphost &&other); + credentials_eaphost& operator=(_Inout_ credentials_eaphost &&other) noexcept; virtual config* clone() const; virtual void clear(); @@ -136,7 +136,7 @@ namespace eap /// virtual source_t combine( _In_ DWORD dwFlags, - _In_ HANDLE hTokenImpersonateUser, + _In_opt_ HANDLE hTokenImpersonateUser, _In_opt_ const credentials *cred_cached, _In_ const config_method &cfg, _In_opt_z_ LPCTSTR pszTargetName); diff --git a/lib/EapHost/include/Method.h b/lib/EapHost/include/Method.h index f3a03e0..7fd4b2b 100644 --- a/lib/EapHost/include/Method.h +++ b/lib/EapHost/include/Method.h @@ -61,7 +61,7 @@ namespace eap /// /// \param[in] other EAP method to move from /// - method_eaphost(_Inout_ method_eaphost &&other); + method_eaphost(_Inout_ method_eaphost &&other) noexcept; /// /// Moves an EAP method @@ -70,7 +70,7 @@ namespace eap /// /// \returns Reference to this object /// - method_eaphost& operator=(_Inout_ method_eaphost &&other); + method_eaphost& operator=(_Inout_ method_eaphost &&other) noexcept; /// \name Session management /// @{ @@ -99,8 +99,8 @@ namespace eap /// @} virtual void get_result( - _In_ EapPeerMethodResultReason reason, - _Out_ EapPeerMethodResult *pResult); + _In_ EapPeerMethodResultReason reason, + _Inout_ EapPeerMethodResult *pResult); /// \name User Interaction /// @{ diff --git a/lib/EapHost/src/Config.cpp b/lib/EapHost/src/Config.cpp index 7c76eb0..ea558cd 100644 --- a/lib/EapHost/src/Config.cpp +++ b/lib/EapHost/src/Config.cpp @@ -45,7 +45,7 @@ eap::config_method_eaphost::config_method_eaphost(_In_ const config_method_eapho } -eap::config_method_eaphost::config_method_eaphost(_Inout_ config_method_eaphost &&other) : +eap::config_method_eaphost::config_method_eaphost(_Inout_ config_method_eaphost &&other) noexcept : m_type (std::move(other.m_type )), m_type_str (std::move(other.m_type_str)), m_cfg_blob (std::move(other.m_cfg_blob)), @@ -67,7 +67,7 @@ eap::config_method_eaphost& eap::config_method_eaphost::operator=(_In_ const con } -eap::config_method_eaphost& eap::config_method_eaphost::operator=(_Inout_ config_method_eaphost &&other) +eap::config_method_eaphost& eap::config_method_eaphost::operator=(_Inout_ config_method_eaphost &&other) noexcept { if (this != &other) { (config_method&&)*this = std::move(other ); diff --git a/lib/EapHost/src/Credentials.cpp b/lib/EapHost/src/Credentials.cpp index fa4f23a..35192b5 100644 --- a/lib/EapHost/src/Credentials.cpp +++ b/lib/EapHost/src/Credentials.cpp @@ -42,7 +42,7 @@ eap::credentials_eaphost::credentials_eaphost(_In_ const credentials_eaphost &ot } -eap::credentials_eaphost::credentials_eaphost(_Inout_ credentials_eaphost &&other) : +eap::credentials_eaphost::credentials_eaphost(_Inout_ credentials_eaphost &&other) noexcept : m_cred_blob(std::move(other.m_cred_blob)), credentials(std::move(other )) { @@ -60,7 +60,7 @@ eap::credentials_eaphost& eap::credentials_eaphost::operator=(_In_ const credent } -eap::credentials_eaphost& eap::credentials_eaphost::operator=(_Inout_ credentials_eaphost &&other) +eap::credentials_eaphost& eap::credentials_eaphost::operator=(_Inout_ credentials_eaphost &&other) noexcept { if (this != &other) { (credentials&)*this = std::move(other); @@ -220,7 +220,7 @@ LPCTSTR eap::credentials_eaphost::target_suffix() const eap::credentials::source_t eap::credentials_eaphost::combine( _In_ DWORD dwFlags, - _In_ HANDLE hTokenImpersonateUser, + _In_opt_ HANDLE hTokenImpersonateUser, _In_opt_ const credentials *cred_cached, _In_ const config_method &cfg, _In_opt_z_ LPCTSTR pszTargetName) diff --git a/lib/EapHost/src/Method.cpp b/lib/EapHost/src/Method.cpp index 8bc1bee..52e2170 100644 --- a/lib/EapHost/src/Method.cpp +++ b/lib/EapHost/src/Method.cpp @@ -37,7 +37,7 @@ eap::method_eaphost::method_eaphost(_In_ module &mod, _In_ config_method_eaphost } -eap::method_eaphost::method_eaphost(_Inout_ method_eaphost &&other) : +eap::method_eaphost::method_eaphost(_Inout_ method_eaphost &&other) noexcept : m_cfg ( other.m_cfg ), m_cred ( other.m_cred ), m_session_id(std::move(other.m_session_id)), @@ -46,7 +46,7 @@ eap::method_eaphost::method_eaphost(_Inout_ method_eaphost &&other) : } -eap::method_eaphost& eap::method_eaphost::operator=(_Inout_ method_eaphost &&other) +eap::method_eaphost& eap::method_eaphost::operator=(_Inout_ method_eaphost &&other) noexcept { if (this != std::addressof(other)) { assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move method within same configuration only! @@ -257,7 +257,7 @@ EapPeerMethodResponseAction eap::method_eaphost::set_ui_context( } -void eap::method_eaphost::get_response_attributes(_Inout_ EapAttributes *pAttribs) +void eap::method_eaphost::get_response_attributes(_Out_ EapAttributes *pAttribs) { // Get response attributes from EapHost peer. eap_error_runtime error; diff --git a/lib/GTC/include/Config.h b/lib/GTC/include/Config.h index adfd1c2..fe62234 100644 --- a/lib/GTC/include/Config.h +++ b/lib/GTC/include/Config.h @@ -74,7 +74,7 @@ namespace eap /// /// \param[in] other Configuration to move from /// - config_method_eapgtc(_Inout_ config_method_eapgtc &&other); + config_method_eapgtc(_Inout_ config_method_eapgtc &&other) noexcept; /// /// Copies configuration @@ -92,7 +92,7 @@ namespace eap /// /// \returns Reference to this object /// - config_method_eapgtc& operator=(_Inout_ config_method_eapgtc &&other); + config_method_eapgtc& operator=(_Inout_ config_method_eapgtc &&other) noexcept; virtual config* clone() const; diff --git a/lib/GTC/include/Method.h b/lib/GTC/include/Method.h index 673dd59..65efef1 100644 --- a/lib/GTC/include/Method.h +++ b/lib/GTC/include/Method.h @@ -57,7 +57,7 @@ namespace eap /// /// \param[in] other GTC method to move from /// - method_gtc(_Inout_ method_gtc &&other); + method_gtc(_Inout_ method_gtc &&other) noexcept; /// /// Moves a GTC method @@ -66,7 +66,7 @@ namespace eap /// /// \returns Reference to this object /// - method_gtc& operator=(_Inout_ method_gtc &&other); + method_gtc& operator=(_Inout_ method_gtc &&other) noexcept; /// \name Session management /// @{ @@ -93,8 +93,8 @@ namespace eap /// @} virtual void get_result( - _In_ EapPeerMethodResultReason reason, - _Out_ EapPeerMethodResult *pResult); + _In_ EapPeerMethodResultReason reason, + _Inout_ EapPeerMethodResult *pResult); /// \name User Interaction /// @{ diff --git a/lib/GTC/src/Config.cpp b/lib/GTC/src/Config.cpp index 025adce..c8be1ec 100644 --- a/lib/GTC/src/Config.cpp +++ b/lib/GTC/src/Config.cpp @@ -41,7 +41,7 @@ eap::config_method_eapgtc::config_method_eapgtc(_In_ const config_method_eapgtc } -eap::config_method_eapgtc::config_method_eapgtc(_Inout_ config_method_eapgtc &&other) : +eap::config_method_eapgtc::config_method_eapgtc(_Inout_ config_method_eapgtc &&other) noexcept : config_method_with_cred(std::move(other)) { } @@ -56,7 +56,7 @@ eap::config_method_eapgtc& eap::config_method_eapgtc::operator=(_In_ const confi } -eap::config_method_eapgtc& eap::config_method_eapgtc::operator=(_Inout_ config_method_eapgtc &&other) +eap::config_method_eapgtc& eap::config_method_eapgtc::operator=(_Inout_ config_method_eapgtc &&other) noexcept { if (this != &other) (config_method_with_cred&&)*this = std::move(other); diff --git a/lib/GTC/src/Method.cpp b/lib/GTC/src/Method.cpp index 3695b1e..d84ed46 100644 --- a/lib/GTC/src/Method.cpp +++ b/lib/GTC/src/Method.cpp @@ -36,7 +36,7 @@ eap::method_gtc::method_gtc(_In_ module &mod, _In_ config_method_eapgtc &cfg, _I } -eap::method_gtc::method_gtc(_Inout_ method_gtc &&other) : +eap::method_gtc::method_gtc(_Inout_ method_gtc &&other) noexcept : m_cfg ( other.m_cfg ), m_cred ( other.m_cred ), m_challenge(std::move(other.m_challenge)), @@ -46,7 +46,7 @@ eap::method_gtc::method_gtc(_Inout_ method_gtc &&other) : } -eap::method_gtc& eap::method_gtc::operator=(_Inout_ method_gtc &&other) +eap::method_gtc& eap::method_gtc::operator=(_Inout_ method_gtc &&other) noexcept { if (this != std::addressof(other)) { assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move method within same configuration only! @@ -113,7 +113,7 @@ void eap::method_gtc::get_response_packet( WideCharToMultiByte(CP_UTF8, 0, m_response, response_utf8, NULL, NULL); if (sizeof(sanitizing_string::value_type)*response_utf8.length() > size_max) - throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %u, maximum: %u).", sizeof(sanitizing_string::value_type)*response_utf8.length(), size_max)); + throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %zu, maximum: %u).", sizeof(sanitizing_string::value_type)*response_utf8.length(), size_max)); packet.assign(response_utf8.begin(), response_utf8.end()); } diff --git a/lib/GTC_UI/include/GTC_UI.h b/lib/GTC_UI/include/GTC_UI.h index 6ed9c71..a60cf99 100644 --- a/lib/GTC_UI/include/GTC_UI.h +++ b/lib/GTC_UI/include/GTC_UI.h @@ -56,6 +56,9 @@ typedef wxEAPCredentialsConfigPanel +#pragma warning(push) +#pragma warning(disable: 26444) + /// \addtogroup EAPBaseGUI /// @{ @@ -138,3 +141,5 @@ protected: }; /// @} + +#pragma warning(pop) diff --git a/lib/MSCHAPv2/include/Config.h b/lib/MSCHAPv2/include/Config.h index e9cd1bb..0ffb394 100644 --- a/lib/MSCHAPv2/include/Config.h +++ b/lib/MSCHAPv2/include/Config.h @@ -66,7 +66,7 @@ namespace eap /// /// \param[in] other Configuration to move from /// - config_method_mschapv2(_Inout_ config_method_mschapv2 &&other); + config_method_mschapv2(_Inout_ config_method_mschapv2 &&other) noexcept; /// /// Copies configuration @@ -84,7 +84,7 @@ namespace eap /// /// \returns Reference to this object /// - config_method_mschapv2& operator=(_Inout_ config_method_mschapv2 &&other); + config_method_mschapv2& operator=(_Inout_ config_method_mschapv2 &&other) noexcept; virtual config* clone() const; @@ -134,7 +134,7 @@ namespace eap /// /// \param[in] other Configuration to move from /// - config_method_eapmschapv2(_Inout_ config_method_eapmschapv2 &&other); + config_method_eapmschapv2(_Inout_ config_method_eapmschapv2 &&other) noexcept; /// /// Copies configuration @@ -152,7 +152,7 @@ namespace eap /// /// \returns Reference to this object /// - config_method_eapmschapv2& operator=(_Inout_ config_method_eapmschapv2 &&other); + config_method_eapmschapv2& operator=(_Inout_ config_method_eapmschapv2 &&other) noexcept; virtual config* clone() const; diff --git a/lib/MSCHAPv2/include/Method.h b/lib/MSCHAPv2/include/Method.h index 8450599..8491934 100644 --- a/lib/MSCHAPv2/include/Method.h +++ b/lib/MSCHAPv2/include/Method.h @@ -62,7 +62,7 @@ namespace eap /// /// \param[in] other MSCHAPv2 method to move from /// - method_mschapv2_base(_Inout_ method_mschapv2_base &&other); + method_mschapv2_base(_Inout_ method_mschapv2_base &&other) noexcept; /// /// Moves a MSCHAPv2 method @@ -71,7 +71,7 @@ namespace eap /// /// \returns Reference to this object /// - method_mschapv2_base& operator=(_Inout_ method_mschapv2_base &&other); + method_mschapv2_base& operator=(_Inout_ method_mschapv2_base &&other) noexcept; /// \name Session management /// @{ @@ -94,8 +94,8 @@ namespace eap /// @} virtual void get_result( - _In_ EapPeerMethodResultReason reason, - _Out_ EapPeerMethodResult *pResult); + _In_ EapPeerMethodResultReason reason, + _Inout_ EapPeerMethodResult *pResult); protected: /// @@ -162,7 +162,7 @@ namespace eap /// /// \param[in] other MSCHAPv2 method to move from /// - method_mschapv2(_Inout_ method_mschapv2 &&other); + method_mschapv2(_Inout_ method_mschapv2 &&other) noexcept; /// /// Moves a MSCHAPv2 method @@ -171,7 +171,7 @@ namespace eap /// /// \returns Reference to this object /// - method_mschapv2& operator=(_Inout_ method_mschapv2 &&other); + method_mschapv2& operator=(_Inout_ method_mschapv2 &&other) noexcept; /// \name Packet processing /// @{ @@ -208,7 +208,7 @@ namespace eap /// /// \param[in] other MSCHAPv2 method to move from /// - method_mschapv2_diameter(_Inout_ method_mschapv2_diameter &&other); + method_mschapv2_diameter(_Inout_ method_mschapv2_diameter &&other) noexcept; /// /// Moves a MSCHAPv2 method @@ -217,7 +217,7 @@ namespace eap /// /// \returns Reference to this object /// - method_mschapv2_diameter& operator=(_Inout_ method_mschapv2_diameter &&other); + method_mschapv2_diameter& operator=(_Inout_ method_mschapv2_diameter &&other) noexcept; /// \name Session management /// @{ diff --git a/lib/MSCHAPv2/src/Config.cpp b/lib/MSCHAPv2/src/Config.cpp index 39b3fbc..83fe648 100644 --- a/lib/MSCHAPv2/src/Config.cpp +++ b/lib/MSCHAPv2/src/Config.cpp @@ -40,7 +40,7 @@ eap::config_method_mschapv2::config_method_mschapv2(_In_ const config_method_msc } -eap::config_method_mschapv2::config_method_mschapv2(_Inout_ config_method_mschapv2 &&other) : +eap::config_method_mschapv2::config_method_mschapv2(_Inout_ config_method_mschapv2 &&other) noexcept : config_method_with_cred(std::move(other)) { } @@ -55,7 +55,7 @@ eap::config_method_mschapv2& eap::config_method_mschapv2::operator=(_In_ const c } -eap::config_method_mschapv2& eap::config_method_mschapv2::operator=(_Inout_ config_method_mschapv2 &&other) +eap::config_method_mschapv2& eap::config_method_mschapv2::operator=(_Inout_ config_method_mschapv2 &&other) noexcept { if (this != &other) (config_method_with_cred&&)*this = std::move(other); @@ -103,7 +103,7 @@ eap::config_method_eapmschapv2::config_method_eapmschapv2(_In_ const config_meth } -eap::config_method_eapmschapv2::config_method_eapmschapv2(_Inout_ config_method_eapmschapv2 &&other) : +eap::config_method_eapmschapv2::config_method_eapmschapv2(_Inout_ config_method_eapmschapv2 &&other) noexcept : config_method_mschapv2(std::move(other)) { } @@ -118,7 +118,7 @@ eap::config_method_eapmschapv2& eap::config_method_eapmschapv2::operator=(_In_ c } -eap::config_method_eapmschapv2& eap::config_method_eapmschapv2::operator=(_Inout_ config_method_eapmschapv2 &&other) +eap::config_method_eapmschapv2& eap::config_method_eapmschapv2::operator=(_Inout_ config_method_eapmschapv2 &&other) noexcept { if (this != &other) (config_method_mschapv2&&)*this = std::move(other); diff --git a/lib/MSCHAPv2/src/Method.cpp b/lib/MSCHAPv2/src/Method.cpp index 997d6b6..0e992ef 100644 --- a/lib/MSCHAPv2/src/Method.cpp +++ b/lib/MSCHAPv2/src/Method.cpp @@ -37,7 +37,7 @@ eap::method_mschapv2_base::method_mschapv2_base(_In_ module &mod, _In_ config_me } -eap::method_mschapv2_base::method_mschapv2_base(_Inout_ method_mschapv2_base &&other) : +eap::method_mschapv2_base::method_mschapv2_base(_Inout_ method_mschapv2_base &&other) noexcept : m_cfg ( other.m_cfg ), m_cred ( other.m_cred ), m_cp (std::move(other.m_cp )), @@ -51,7 +51,7 @@ eap::method_mschapv2_base::method_mschapv2_base(_Inout_ method_mschapv2_base &&o } -eap::method_mschapv2_base& eap::method_mschapv2_base::operator=(_Inout_ method_mschapv2_base &&other) +eap::method_mschapv2_base& eap::method_mschapv2_base::operator=(_Inout_ method_mschapv2_base &&other) noexcept { if (this != std::addressof(other)) { assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move method within same configuration only! @@ -93,7 +93,7 @@ void eap::method_mschapv2_base::get_response_packet( _In_opt_ DWORD size_max) { if (m_packet_res.size() > size_max) - throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %u, maximum: %u).", m_packet_res.size(), size_max)); + throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %zu, maximum: %u).", m_packet_res.size(), size_max)); packet.assign(m_packet_res.begin(), m_packet_res.end()); } @@ -211,13 +211,13 @@ eap::method_mschapv2::method_mschapv2(_In_ module &mod, _In_ config_method_mscha } -eap::method_mschapv2::method_mschapv2(_Inout_ method_mschapv2 &&other) : +eap::method_mschapv2::method_mschapv2(_Inout_ method_mschapv2 &&other) noexcept : method_mschapv2_base(std::move(other )) { } -eap::method_mschapv2& eap::method_mschapv2::operator=(_Inout_ method_mschapv2 &&other) +eap::method_mschapv2& eap::method_mschapv2::operator=(_Inout_ method_mschapv2 &&other) noexcept { if (this != std::addressof(other)) (method_mschapv2_base&)*this = std::move(other); @@ -328,14 +328,14 @@ eap::method_mschapv2_diameter::method_mschapv2_diameter(_In_ module &mod, _In_ c } -eap::method_mschapv2_diameter::method_mschapv2_diameter(_Inout_ method_mschapv2_diameter &&other) : +eap::method_mschapv2_diameter::method_mschapv2_diameter(_Inout_ method_mschapv2_diameter &&other) noexcept : m_phase (std::move(other.m_phase)), method_mschapv2_base(std::move(other )) { } -eap::method_mschapv2_diameter& eap::method_mschapv2_diameter::operator=(_Inout_ method_mschapv2_diameter &&other) +eap::method_mschapv2_diameter& eap::method_mschapv2_diameter::operator=(_Inout_ method_mschapv2_diameter &&other) noexcept { if (this != std::addressof(other)) { (method_mschapv2_base&)*this = std::move(other ); diff --git a/lib/PAP/include/Config.h b/lib/PAP/include/Config.h index 812249c..3b52418 100644 --- a/lib/PAP/include/Config.h +++ b/lib/PAP/include/Config.h @@ -65,7 +65,7 @@ namespace eap /// /// \param[in] other Configuration to move from /// - config_method_pap(_Inout_ config_method_pap &&other); + config_method_pap(_Inout_ config_method_pap &&other) noexcept; /// /// Copies configuration @@ -83,7 +83,7 @@ namespace eap /// /// \returns Reference to this object /// - config_method_pap& operator=(_Inout_ config_method_pap &&other); + config_method_pap& operator=(_Inout_ config_method_pap &&other) noexcept; virtual config* clone() const; diff --git a/lib/PAP/include/Method.h b/lib/PAP/include/Method.h index e85284d..45aadfe 100644 --- a/lib/PAP/include/Method.h +++ b/lib/PAP/include/Method.h @@ -58,7 +58,7 @@ namespace eap /// /// \param[in] other PAP method to move from /// - method_pap_diameter(_Inout_ method_pap_diameter &&other); + method_pap_diameter(_Inout_ method_pap_diameter &&other) noexcept; /// /// Moves a PAP method @@ -67,7 +67,7 @@ namespace eap /// /// \returns Reference to this object /// - method_pap_diameter& operator=(_Inout_ method_pap_diameter &&other); + method_pap_diameter& operator=(_Inout_ method_pap_diameter &&other) noexcept; /// \name Session management /// @{ @@ -94,8 +94,8 @@ namespace eap /// @} virtual void get_result( - _In_ EapPeerMethodResultReason reason, - _Out_ EapPeerMethodResult *pResult); + _In_ EapPeerMethodResultReason reason, + _Inout_ EapPeerMethodResult *pResult); protected: config_method_pap &m_cfg; ///< Method configuration diff --git a/lib/PAP/src/Config.cpp b/lib/PAP/src/Config.cpp index ceb01ee..9ee8c40 100644 --- a/lib/PAP/src/Config.cpp +++ b/lib/PAP/src/Config.cpp @@ -40,7 +40,7 @@ eap::config_method_pap::config_method_pap(_In_ const config_method_pap &other) : } -eap::config_method_pap::config_method_pap(_Inout_ config_method_pap &&other) : +eap::config_method_pap::config_method_pap(_Inout_ config_method_pap &&other) noexcept : config_method_with_cred(std::move(other)) { } @@ -55,7 +55,7 @@ eap::config_method_pap& eap::config_method_pap::operator=(_In_ const config_meth } -eap::config_method_pap& eap::config_method_pap::operator=(_Inout_ config_method_pap &&other) +eap::config_method_pap& eap::config_method_pap::operator=(_Inout_ config_method_pap &&other) noexcept { if (this != &other) (config_method_with_cred&&)*this = std::move(other); diff --git a/lib/PAP/src/Method.cpp b/lib/PAP/src/Method.cpp index 29febbc..3850c93 100644 --- a/lib/PAP/src/Method.cpp +++ b/lib/PAP/src/Method.cpp @@ -37,7 +37,7 @@ eap::method_pap_diameter::method_pap_diameter(_In_ module &mod, _In_ config_meth } -eap::method_pap_diameter::method_pap_diameter(_Inout_ method_pap_diameter &&other) : +eap::method_pap_diameter::method_pap_diameter(_Inout_ method_pap_diameter &&other) noexcept : m_cfg ( other.m_cfg ), m_cred ( other.m_cred ), m_phase (std::move(other.m_phase )), @@ -47,7 +47,7 @@ eap::method_pap_diameter::method_pap_diameter(_Inout_ method_pap_diameter &&othe } -eap::method_pap_diameter& eap::method_pap_diameter::operator=(_Inout_ method_pap_diameter &&other) +eap::method_pap_diameter& eap::method_pap_diameter::operator=(_Inout_ method_pap_diameter &&other) noexcept { if (this != std::addressof(other)) { assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move method within same configuration only! @@ -122,7 +122,7 @@ void eap::method_pap_diameter::get_response_packet( _In_opt_ DWORD size_max) { if (m_packet_res.size() > size_max) - throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %u, maximum: %u).", m_packet_res.size(), size_max)); + throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %zu, maximum: %u).", m_packet_res.size(), size_max)); packet.assign(m_packet_res.begin(), m_packet_res.end()); } diff --git a/lib/TLS/include/Config.h b/lib/TLS/include/Config.h index 9ba79a9..288fb24 100644 --- a/lib/TLS/include/Config.h +++ b/lib/TLS/include/Config.h @@ -89,7 +89,7 @@ namespace eap /// /// \param[in] other Configuration to move from /// - config_method_tls(_Inout_ config_method_tls &&other); + config_method_tls(_Inout_ config_method_tls &&other) noexcept; /// /// Copies configuration @@ -107,7 +107,7 @@ namespace eap /// /// \returns Reference to this object /// - config_method_tls& operator=(_Inout_ config_method_tls &&other); + config_method_tls& operator=(_Inout_ config_method_tls &&other) noexcept; virtual config* clone() const; diff --git a/lib/TLS/include/Credentials.h b/lib/TLS/include/Credentials.h index 7e2e98f..e7d8ca2 100644 --- a/lib/TLS/include/Credentials.h +++ b/lib/TLS/include/Credentials.h @@ -67,7 +67,7 @@ namespace eap /// /// \param[in] other Credentials to move from /// - credentials_tls(_Inout_ credentials_tls &&other); + credentials_tls(_Inout_ credentials_tls &&other) noexcept; /// /// Copies credentials @@ -85,7 +85,7 @@ namespace eap /// /// \returns Reference to this object /// - credentials_tls& operator=(_Inout_ credentials_tls &&other); + credentials_tls& operator=(_Inout_ credentials_tls &&other) noexcept; virtual config* clone() const; virtual void clear(); @@ -138,7 +138,7 @@ namespace eap /// virtual source_t combine( _In_ DWORD dwFlags, - _In_ HANDLE hTokenImpersonateUser, + _In_opt_ HANDLE hTokenImpersonateUser, _In_opt_ const credentials *cred_cached, _In_ const config_method &cfg, _In_opt_z_ LPCTSTR pszTargetName); diff --git a/lib/TLS/src/Config.cpp b/lib/TLS/src/Config.cpp index d80dd50..b423196 100644 --- a/lib/TLS/src/Config.cpp +++ b/lib/TLS/src/Config.cpp @@ -80,7 +80,7 @@ eap::config_method_tls::config_method_tls(_In_ const config_method_tls &other) : } -eap::config_method_tls::config_method_tls(_Inout_ config_method_tls &&other) : +eap::config_method_tls::config_method_tls(_Inout_ config_method_tls &&other) noexcept : m_trusted_root_ca(std::move(other.m_trusted_root_ca)), m_server_names(std::move(other.m_server_names)), config_method_with_cred(std::move(other)) @@ -100,7 +100,7 @@ eap::config_method_tls& eap::config_method_tls::operator=(_In_ const config_meth } -eap::config_method_tls& eap::config_method_tls::operator=(_Inout_ config_method_tls &&other) +eap::config_method_tls& eap::config_method_tls::operator=(_Inout_ config_method_tls &&other) noexcept { if (this != &other) { (config_method_with_cred&&)*this = std::move(other); diff --git a/lib/TLS/src/Credentials.cpp b/lib/TLS/src/Credentials.cpp index deea341..001b873 100644 --- a/lib/TLS/src/Credentials.cpp +++ b/lib/TLS/src/Credentials.cpp @@ -40,7 +40,7 @@ eap::credentials_tls::credentials_tls(_In_ const credentials_tls &other) : } -eap::credentials_tls::credentials_tls(_Inout_ credentials_tls &&other) : +eap::credentials_tls::credentials_tls(_Inout_ credentials_tls &&other) noexcept : m_cert(std::move(other.m_cert)), credentials(std::move(other)) { @@ -58,7 +58,7 @@ eap::credentials_tls& eap::credentials_tls::operator=(_In_ const credentials_tls } -eap::credentials_tls& eap::credentials_tls::operator=(_Inout_ credentials_tls &&other) +eap::credentials_tls& eap::credentials_tls::operator=(_Inout_ credentials_tls &&other) noexcept { if (this != &other) { (credentials&)*this = std::move(other); @@ -260,7 +260,7 @@ std::wstring eap::credentials_tls::get_identity() const unique_ptr > san_info; if (strcmp(m_cert->pCertInfo->rgExtension[idx_ext].pszObjId, szOID_SUBJECT_ALT_NAME2) == 0) { unsigned char *output = NULL; - DWORD size_output; + DWORD size_output = 0; if (!CryptDecodeObjectEx( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, szOID_SUBJECT_ALT_NAME2, @@ -272,7 +272,7 @@ std::wstring eap::credentials_tls::get_identity() const san_info.reset((CERT_ALT_NAME_INFO*)output); } else if (strcmp(m_cert->pCertInfo->rgExtension[idx_ext].pszObjId, szOID_SUBJECT_ALT_NAME) == 0) { unsigned char *output = NULL; - DWORD size_output; + DWORD size_output = 0; if (!CryptDecodeObjectEx( X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, szOID_SUBJECT_ALT_NAME, @@ -300,7 +300,7 @@ std::wstring eap::credentials_tls::get_identity() const eap::credentials::source_t eap::credentials_tls::combine( _In_ DWORD dwFlags, - _In_ HANDLE hTokenImpersonateUser, + _In_opt_ HANDLE hTokenImpersonateUser, _In_opt_ const credentials *cred_cached, _In_ const config_method &cfg, _In_opt_z_ LPCTSTR pszTargetName) diff --git a/lib/TLS_UI/src/TLS_UI.cpp b/lib/TLS_UI/src/TLS_UI.cpp index 81e25c1..7b22352 100644 --- a/lib/TLS_UI/src/TLS_UI.cpp +++ b/lib/TLS_UI/src/TLS_UI.cpp @@ -225,8 +225,10 @@ void wxTLSServerTrustPanel::OnRootCADClick(wxCommandEvent& event) wxTLSServerTrustPanelBase::OnRootCADClick(event); wxCertificateClientData *cert = dynamic_cast(event.GetClientObject()); - if (cert) + if (cert) { + #pragma warning(suppress: 6387) // The pvReserved parameter is annotated as _In_ CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, cert->m_cert, this->GetHWND(), NULL, 0, NULL); + } } @@ -237,6 +239,7 @@ void wxTLSServerTrustPanel::OnRootCAAddStore(wxCommandEvent& event) winstd::cert_store store; if (store.create(NULL, _T("ROOT"))) { winstd::cert_context cert; + #pragma warning(suppress: 6387) // The pvReserved parameter is annotated as _In_ cert.attach(CryptUIDlgSelectCertificateFromStore(store, this->GetHWND(), NULL, NULL, 0, 0, NULL)); if (cert) AddRootCA(cert); diff --git a/lib/TTLS/include/Config.h b/lib/TTLS/include/Config.h index b2aca7a..fc0bfca 100644 --- a/lib/TTLS/include/Config.h +++ b/lib/TTLS/include/Config.h @@ -69,7 +69,7 @@ namespace eap /// /// \param[in] other Configuration to move from /// - config_method_ttls(_Inout_ config_method_ttls &&other); + config_method_ttls(_Inout_ config_method_ttls &&other) noexcept; /// /// Copies configuration @@ -87,7 +87,7 @@ namespace eap /// /// \returns Reference to this object /// - config_method_ttls& operator=(_Inout_ config_method_ttls &&other); + config_method_ttls& operator=(_Inout_ config_method_ttls &&other) noexcept; virtual config* clone() const; diff --git a/lib/TTLS/include/Credentials.h b/lib/TTLS/include/Credentials.h index 2cdb184..f00e1b4 100644 --- a/lib/TTLS/include/Credentials.h +++ b/lib/TTLS/include/Credentials.h @@ -62,7 +62,7 @@ namespace eap /// /// \param[in] other Credentials to move from /// - credentials_ttls(_Inout_ credentials_ttls &&other); + credentials_ttls(_Inout_ credentials_ttls &&other) noexcept; /// /// Copies credentials @@ -80,7 +80,7 @@ namespace eap /// /// \returns Reference to this object /// - credentials_ttls& operator=(_Inout_ credentials_ttls &&other); + credentials_ttls& operator=(_Inout_ credentials_ttls &&other) noexcept; virtual config* clone() const; virtual void clear(); @@ -127,7 +127,7 @@ namespace eap /// virtual source_t combine( _In_ DWORD dwFlags, - _In_ HANDLE hTokenImpersonateUser, + _In_opt_ HANDLE hTokenImpersonateUser, _In_opt_ const credentials *cred_cached, _In_ const config_method &cfg, _In_opt_z_ LPCTSTR pszTargetName); diff --git a/lib/TTLS/include/Method.h b/lib/TTLS/include/Method.h index a309c6a..af4aa50 100644 --- a/lib/TTLS/include/Method.h +++ b/lib/TTLS/include/Method.h @@ -93,7 +93,7 @@ namespace eap /// /// \param[in] other Method to move from /// - method_defrag(_Inout_ method_defrag &&other); + method_defrag(_Inout_ method_defrag &&other) noexcept; /// /// Moves a method @@ -102,7 +102,7 @@ namespace eap /// /// \returns Reference to this object /// - method_defrag& operator=(_Inout_ method_defrag &&other); + method_defrag& operator=(_Inout_ method_defrag &&other) noexcept; /// \name Session management /// @{ @@ -129,7 +129,6 @@ namespace eap /// @} protected: - DWORD m_size_frag_max; ///< Maximum size of a fragment sanitizing_blob m_data_req; ///< Data in request sanitizing_blob m_data_res; ///< Data in response bool m_send_res; ///< Are we sending a response? @@ -156,7 +155,7 @@ namespace eap /// /// \param[in] other Method to move from /// - method_eapmsg(_Inout_ method_eapmsg &&other); + method_eapmsg(_Inout_ method_eapmsg &&other) noexcept; /// /// Moves a method @@ -165,7 +164,7 @@ namespace eap /// /// \returns Reference to this object /// - method_eapmsg& operator=(_Inout_ method_eapmsg &&other); + method_eapmsg& operator=(_Inout_ method_eapmsg &&other) noexcept; /// \name Session management /// @{ @@ -230,7 +229,7 @@ namespace eap /// /// \param[in] other TTLS method to move from /// - method_ttls(_Inout_ method_ttls &&other); + method_ttls(_Inout_ method_ttls &&other) noexcept; /// /// Moves a TTLS method @@ -239,7 +238,7 @@ namespace eap /// /// \returns Reference to this object /// - method_ttls& operator=(_Inout_ method_ttls &&other); + method_ttls& operator=(_Inout_ method_ttls &&other) noexcept; /// \name Session management /// @{ @@ -266,8 +265,8 @@ namespace eap /// @} virtual void get_result( - _In_ EapPeerMethodResultReason reason, - _Out_ EapPeerMethodResult *pResult); + _In_ EapPeerMethodResultReason reason, + _Inout_ EapPeerMethodResult *pResult); protected: #if EAP_TLS < EAP_TLS_SCHANNEL_FULL diff --git a/lib/TTLS/include/Module.h b/lib/TTLS/include/Module.h index 8e5b830..73ae483 100644 --- a/lib/TTLS/include/Module.h +++ b/lib/TTLS/include/Module.h @@ -115,16 +115,16 @@ namespace eap _Out_ EapPeerMethodOutput *pEapOutput); virtual void get_response_packet( - _In_ EAP_SESSION_HANDLE hSession, - _Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket, - _Inout_ DWORD *pdwSendPacketSize); + _In_ EAP_SESSION_HANDLE hSession, + _Out_bytecapcount_(*pdwSendPacketSize) EapPacket *pSendPacket, + _Inout_ DWORD *pdwSendPacketSize); /// @} virtual void get_result( - _In_ EAP_SESSION_HANDLE hSession, - _In_ EapPeerMethodResultReason reason, - _Out_ EapPeerMethodResult *pResult); + _In_ EAP_SESSION_HANDLE hSession, + _In_ EapPeerMethodResultReason reason, + _Inout_ EapPeerMethodResult *pResult); /// \name User Interaction /// @{ @@ -167,12 +167,12 @@ namespace eap /// /// Checks all configured providers and tries to combine credentials. /// - const config_method_ttls* combine_credentials( + _Success_(return != 0) const config_method_ttls* combine_credentials( _In_ DWORD dwFlags, _In_ const config_connection &cfg, _In_count_(dwUserDataSize) const BYTE *pUserData, _In_ DWORD dwUserDataSize, - _Out_ credentials_connection& cred_out, + _Inout_ credentials_connection& cred_out, _In_ HANDLE hTokenImpersonateUser); protected: @@ -223,7 +223,7 @@ namespace eap /// /// \param[in] other Thread to move from /// - crl_checker(_Inout_ crl_checker &&other); + crl_checker(_Inout_ crl_checker &&other) noexcept; /// /// Moves a thread @@ -232,7 +232,7 @@ namespace eap /// /// \returns Reference to this object /// - crl_checker& operator=(_Inout_ crl_checker &&other); + crl_checker& operator=(_Inout_ crl_checker &&other) noexcept; /// /// Verifies server's certificate if it has been revoked diff --git a/lib/TTLS/include/UIContext.h b/lib/TTLS/include/UIContext.h index 051363c..83c362b 100644 --- a/lib/TTLS/include/UIContext.h +++ b/lib/TTLS/include/UIContext.h @@ -61,7 +61,7 @@ namespace eap /// /// \param[in] other Credentials to move from /// - ui_context_ttls(_Inout_ ui_context_ttls &&other); + ui_context_ttls(_Inout_ ui_context_ttls &&other) noexcept; /// /// Copies context @@ -79,7 +79,7 @@ namespace eap /// /// \returns Reference to this object /// - ui_context_ttls& operator=(_Inout_ ui_context_ttls &&other); + ui_context_ttls& operator=(_Inout_ ui_context_ttls &&other) noexcept; /// \name BLOB management /// @{ diff --git a/lib/TTLS/src/Config.cpp b/lib/TTLS/src/Config.cpp index 2e3f048..6b9495a 100644 --- a/lib/TTLS/src/Config.cpp +++ b/lib/TTLS/src/Config.cpp @@ -45,7 +45,7 @@ eap::config_method_ttls::config_method_ttls(const _In_ config_method_ttls &other } -eap::config_method_ttls::config_method_ttls(_Inout_ config_method_ttls &&other) : +eap::config_method_ttls::config_method_ttls(_Inout_ config_method_ttls &&other) noexcept : m_inner(std::move(other.m_inner)), m_anonymous_identity(std::move(other.m_anonymous_identity)), config_method_tls(std::move(other)) @@ -65,7 +65,7 @@ eap::config_method_ttls& eap::config_method_ttls::operator=(const _In_ config_me } -eap::config_method_ttls& eap::config_method_ttls::operator=(_Inout_ config_method_ttls &&other) +eap::config_method_ttls& eap::config_method_ttls::operator=(_Inout_ config_method_ttls &&other) noexcept { if (this != &other) { (config_method_tls&&)*this = std::move(other); diff --git a/lib/TTLS/src/Credentials.cpp b/lib/TTLS/src/Credentials.cpp index 030c28e..2193d14 100644 --- a/lib/TTLS/src/Credentials.cpp +++ b/lib/TTLS/src/Credentials.cpp @@ -41,7 +41,7 @@ eap::credentials_ttls::credentials_ttls(_In_ const credentials_ttls &other) : } -eap::credentials_ttls::credentials_ttls(_Inout_ credentials_ttls &&other) : +eap::credentials_ttls::credentials_ttls(_Inout_ credentials_ttls &&other) noexcept : m_inner(std::move(other.m_inner)), credentials_tls(std::move(other)) { @@ -59,7 +59,7 @@ eap::credentials_ttls& eap::credentials_ttls::operator=(_In_ const credentials_t } -eap::credentials_ttls& eap::credentials_ttls::operator=(_Inout_ credentials_ttls &&other) +eap::credentials_ttls& eap::credentials_ttls::operator=(_Inout_ credentials_ttls &&other) noexcept { if (this != &other) { (credentials_tls&)*this = std::move(other); @@ -180,7 +180,7 @@ wstring eap::credentials_ttls::get_identity() const eap::credentials::source_t eap::credentials_ttls::combine( _In_ DWORD dwFlags, - _In_ HANDLE hTokenImpersonateUser, + _In_opt_ HANDLE hTokenImpersonateUser, _In_opt_ const credentials *cred_cached, _In_ const config_method &cfg, _In_opt_z_ LPCTSTR pszTargetName) diff --git a/lib/TTLS/src/Method.cpp b/lib/TTLS/src/Method.cpp index 4424c00..d5e5ee8 100644 --- a/lib/TTLS/src/Method.cpp +++ b/lib/TTLS/src/Method.cpp @@ -37,7 +37,7 @@ eap::method_defrag::method_defrag(_In_ module &mod, _In_ method *inner) : } -eap::method_defrag::method_defrag(_Inout_ method_defrag &&other) : +eap::method_defrag::method_defrag(_Inout_ method_defrag &&other) noexcept : m_data_req (std::move(other.m_data_req)), m_data_res (std::move(other.m_data_res)), m_send_res (std::move(other.m_send_res)), @@ -46,7 +46,7 @@ eap::method_defrag::method_defrag(_Inout_ method_defrag &&other) : } -eap::method_defrag& eap::method_defrag::operator=(_Inout_ method_defrag &&other) +eap::method_defrag& eap::method_defrag::operator=(_Inout_ method_defrag &&other) noexcept { if (this != std::addressof(other)) { (method_tunnel&)*this = std::move(other ); @@ -181,7 +181,7 @@ eap::method_eapmsg::method_eapmsg(_In_ module &mod, _In_ const wchar_t *identity } -eap::method_eapmsg::method_eapmsg(_Inout_ method_eapmsg &&other) : +eap::method_eapmsg::method_eapmsg(_Inout_ method_eapmsg &&other) noexcept : m_identity (std::move(other.m_identity )), m_phase (std::move(other.m_phase )), m_packet_res (std::move(other.m_packet_res)), @@ -190,7 +190,7 @@ eap::method_eapmsg::method_eapmsg(_Inout_ method_eapmsg &&other) : } -eap::method_eapmsg& eap::method_eapmsg::operator=(_Inout_ method_eapmsg &&other) +eap::method_eapmsg& eap::method_eapmsg::operator=(_Inout_ method_eapmsg &&other) noexcept { if (this != std::addressof(other)) { (method_tunnel&)*this = std::move(other ); @@ -215,7 +215,7 @@ void eap::method_eapmsg::begin_session( // Inner method can generate packets of up to 16MB (less the Diameter AVP header). // Initialize inner method with appropriately less packet size maximum. if (dwMaxSendPacketSize < sizeof(diameter_avp_header)) - throw invalid_argument(string_printf(__FUNCTION__ " Maximum packet size too small (minimum: %u, available: %u).", sizeof(diameter_avp_header) + 1, dwMaxSendPacketSize)); + throw invalid_argument(string_printf(__FUNCTION__ " Maximum packet size too small (minimum: %zu, available: %u).", sizeof(diameter_avp_header) + 1, dwMaxSendPacketSize)); assert(m_inner); m_inner->begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, std::min(dwMaxSendPacketSize, 0xffffff) - sizeof(diameter_avp_header)); @@ -325,7 +325,7 @@ void eap::method_eapmsg::get_response_packet( packet.insert(packet.end(), (unsigned int)((4 - size_packet) % 4), 0); } else { if (m_packet_res.size() > size_max) - throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %u, maximum: %u).", m_packet_res.size(), size_max)); + throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %zu, maximum: %u).", m_packet_res.size(), size_max)); packet.assign(m_packet_res.begin(), m_packet_res.end()); } @@ -344,10 +344,12 @@ eap::method_ttls::method_ttls(_In_ module &mod, _In_ config_method_ttls &cfg, _I m_packet_res_inner(false), method_tunnel(mod, inner) { + m_eap_attr_desc.dwNumberOfAttributes = 0; + m_eap_attr_desc.pAttribs = NULL; } -eap::method_ttls::method_ttls(_Inout_ method_ttls &&other) : +eap::method_ttls::method_ttls(_Inout_ method_ttls &&other) noexcept : m_cfg ( other.m_cfg ), m_cred ( other.m_cred ), m_user_ctx (std::move(other.m_user_ctx )), @@ -362,10 +364,12 @@ eap::method_ttls::method_ttls(_Inout_ method_ttls &&other) : m_eap_attr (std::move(other.m_eap_attr )), method_tunnel (std::move(other )) { + m_eap_attr_desc.dwNumberOfAttributes = (DWORD)m_eap_attr.size(); + m_eap_attr_desc.pAttribs = m_eap_attr.data(); } -eap::method_ttls& eap::method_ttls::operator=(_Inout_ method_ttls &&other) +eap::method_ttls& eap::method_ttls::operator=(_Inout_ method_ttls &&other) noexcept { if (this != std::addressof(other)) { assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move method within same configuration only! @@ -770,11 +774,11 @@ void eap::method_ttls::get_response_packet( if (FAILED(status)) throw sec_runtime_error(status, __FUNCTION__ " Error getting Schannel required encryption sizes."); if (m_packet_res.size() + sizes.cbHeader + sizes.cbTrailer > size_max) - throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %u, maximum: %u).", m_packet_res.size(), size_max)); + throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %zu, maximum: %u).", m_packet_res.size(), size_max)); sizes.cbMaximumMessage = std::min(sizes.cbMaximumMessage, size_max - (unsigned long)(m_packet_res.size() + sizes.cbHeader + sizes.cbTrailer)); // Get inner response packet. - packet.reserve(sizes.cbHeader + sizes.cbMaximumMessage + sizes.cbTrailer); + packet.reserve((size_t)sizes.cbHeader + sizes.cbMaximumMessage + sizes.cbTrailer); method_tunnel::get_response_packet(packet, sizes.cbMaximumMessage); if (!packet.empty()) { DWORD size_data = (DWORD)packet.size(); @@ -799,7 +803,7 @@ void eap::method_ttls::get_response_packet( m_packet_res.insert(m_packet_res.end(), reinterpret_cast(buf[0].pvBuffer), reinterpret_cast(buf[0].pvBuffer) + buf[0].cbBuffer + buf[1].cbBuffer + buf[2].cbBuffer); } } else if (m_packet_res.size() > size_max) - throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %u, maximum: %u).", m_packet_res.size(), size_max)); + throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %zu, maximum: %u).", m_packet_res.size(), size_max)); packet.assign(m_packet_res.begin(), m_packet_res.end()); } @@ -819,7 +823,7 @@ void eap::method_ttls::get_result( // Prepare EAP result attributes. if (pResult->pAttribArray) { - m_eap_attr.reserve(pResult->pAttribArray->dwNumberOfAttributes + 3); + m_eap_attr.reserve((size_t)pResult->pAttribArray->dwNumberOfAttributes + 3); m_eap_attr.clear(); // Copy all EAP attributes from inner method up to blank terminator. Exclude any MPPE-Recv-Key or MPPE-Send-Key if found. for (auto attr = pResult->pAttribArray->pAttribs, attr_end = pResult->pAttribArray->pAttribs + pResult->pAttribArray->dwNumberOfAttributes; attr != attr_end && attr->eaType; ++attr) { diff --git a/lib/TTLS/src/Module.cpp b/lib/TTLS/src/Module.cpp index 022a458..ea2e68f 100644 --- a/lib/TTLS/src/Module.cpp +++ b/lib/TTLS/src/Module.cpp @@ -92,6 +92,8 @@ void eap::peer_ttls::get_identity( _Out_ BOOL *pfInvokeUI, _Out_ WCHAR **ppwszIdentity) { + assert(ppUserDataOut); + assert(pdwUserDataOutSize); assert(pfInvokeUI); assert(ppwszIdentity); @@ -111,7 +113,10 @@ void eap::peer_ttls::get_identity( if ((dwFlags & EAP_FLAG_MACHINE_AUTH) == 0) { // Per-user authentication, request UI. log_event(&EAPMETHOD_TRACE_EVT_CRED_INVOKE_UI2, event_data::blank); + *ppUserDataOut = NULL; + *pdwUserDataOutSize = 0; *pfInvokeUI = TRUE; + *ppwszIdentity = NULL; return; } else { // Per-machine authentication, cannot use UI. @@ -308,9 +313,9 @@ void eap::peer_ttls::process_request_packet( void eap::peer_ttls::get_response_packet( - _In_ EAP_SESSION_HANDLE hSession, - _Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket, - _Inout_ DWORD *pdwSendPacketSize) + _In_ EAP_SESSION_HANDLE hSession, + _Out_bytecapcount_(*pdwSendPacketSize) EapPacket *pSendPacket, + _Inout_ DWORD *pdwSendPacketSize) { assert(pdwSendPacketSize); assert(pSendPacket || !*pdwSendPacketSize); @@ -393,8 +398,8 @@ void eap::peer_ttls::set_ui_context( void eap::peer_ttls::get_response_attributes( - _In_ EAP_SESSION_HANDLE hSession, - _Inout_ EapAttributes *pAttribs) + _In_ EAP_SESSION_HANDLE hSession, + _Out_ EapAttributes *pAttribs) { static_cast(hSession)->m_method->get_response_attributes(pAttribs); } @@ -422,12 +427,12 @@ void eap::peer_ttls::spawn_crl_check(_Inout_ winstd::cert_context &&cert) } -const eap::config_method_ttls* eap::peer_ttls::combine_credentials( +_Success_(return != 0) const eap::config_method_ttls* eap::peer_ttls::combine_credentials( _In_ DWORD dwFlags, _In_ const config_connection &cfg, _In_count_(dwUserDataSize) const BYTE *pUserData, _In_ DWORD dwUserDataSize, - _Out_ credentials_connection& cred_out, + _Inout_ credentials_connection& cred_out, _In_ HANDLE hTokenImpersonateUser) { #if EAP_USE_NATIVE_CREDENTIAL_CACHE @@ -560,7 +565,7 @@ eap::peer_ttls::crl_checker::crl_checker(_In_ module &mod, _Inout_ winstd::cert_ } -eap::peer_ttls::crl_checker::crl_checker(_Inout_ crl_checker &&other) : +eap::peer_ttls::crl_checker::crl_checker(_Inout_ crl_checker &&other) noexcept : m_module( other.m_module ), m_thread(std::move(other.m_thread)), m_abort (std::move(other.m_abort )), @@ -569,7 +574,7 @@ eap::peer_ttls::crl_checker::crl_checker(_Inout_ crl_checker &&other) : } -eap::peer_ttls::crl_checker& eap::peer_ttls::crl_checker::operator=(_Inout_ crl_checker &&other) +eap::peer_ttls::crl_checker& eap::peer_ttls::crl_checker::operator=(_Inout_ crl_checker &&other) noexcept { if (this != std::addressof(other)) { assert(std::addressof(m_module) == std::addressof(other.m_module)); // Move threads within same module only! @@ -627,7 +632,7 @@ DWORD WINAPI eap::peer_ttls::crl_checker::verify(_In_ crl_checker *obj) switch (status_rev.dwError) { case CRYPT_E_NO_REVOCATION_CHECK: // Revocation check could not be performed. - c += status_rev.dwIndex + 1; + c += (size_t)status_rev.dwIndex + 1; if (c == c_end) { // This "error" is expected for the root CA certificate. } else { @@ -663,7 +668,7 @@ DWORD WINAPI eap::peer_ttls::crl_checker::verify(_In_ crl_checker *obj) }} // Resume checking the rest of the chain. - c += status_rev.dwIndex + 1; + c += (size_t)status_rev.dwIndex + 1; break; case ERROR_SUCCESS: @@ -674,7 +679,7 @@ DWORD WINAPI eap::peer_ttls::crl_checker::verify(_In_ crl_checker *obj) default: // Checking one of the certificates in the chain for revocation failed. Resume checking the rest. obj->m_module.log_event(&EAPMETHOD_TLS_SERVER_CERT_REVOKE_FAILED, event_data((unsigned int)eap_type_ttls), event_data(subj), event_data(status_rev.dwError), event_data::blank); - c += status_rev.dwIndex + 1; + c += (size_t)status_rev.dwIndex + 1; } } else { // Revocation check finished. diff --git a/lib/TTLS/src/UIContext.cpp b/lib/TTLS/src/UIContext.cpp index 7b37ccf..64b838b 100644 --- a/lib/TTLS/src/UIContext.cpp +++ b/lib/TTLS/src/UIContext.cpp @@ -41,7 +41,7 @@ eap::ui_context_ttls::ui_context_ttls(_In_ const ui_context_ttls &other) : } -eap::ui_context_ttls::ui_context_ttls(_Inout_ ui_context_ttls &&other) : +eap::ui_context_ttls::ui_context_ttls(_Inout_ ui_context_ttls &&other) noexcept : m_data (std::move(other.m_data)), ui_context(std::move(other )) { @@ -59,7 +59,7 @@ eap::ui_context_ttls& eap::ui_context_ttls::operator=(_In_ const ui_context_ttls } -eap::ui_context_ttls& eap::ui_context_ttls::operator=(_Inout_ ui_context_ttls &&other) +eap::ui_context_ttls& eap::ui_context_ttls::operator=(_Inout_ ui_context_ttls &&other) noexcept { if (this != &other) { (ui_context&)*this = std::move(other ); diff --git a/lib/TTLS_UI/src/Module.cpp b/lib/TTLS_UI/src/Module.cpp index eb17957..d70bb49 100644 --- a/lib/TTLS_UI/src/Module.cpp +++ b/lib/TTLS_UI/src/Module.cpp @@ -323,8 +323,10 @@ void eap::peer_ttls_ui::invoke_identity_ui( wxLogError("Unsupported authentication mode."); break; } - default : wxLogError("Unsupported inner authentication method."); + default: wxLogError("Unsupported inner authentication method."); } + if (!panel) + throw invalid_argument("Invalid authentication mode"); panel->SetRemember(src_inner == eap::credentials::source_storage); dlg.AddContent(panel); diff --git a/lib/WinStd b/lib/WinStd index ddf3330..03522c0 160000 --- a/lib/WinStd +++ b/lib/WinStd @@ -1 +1 @@ -Subproject commit ddf3330545faa2365f43593bbce7445edb8ee519 +Subproject commit 03522c004709f2e54eda4b10f0ef8321b682f28c diff --git a/lib/wxExtend b/lib/wxExtend index bfa2377..23f8c36 160000 --- a/lib/wxExtend +++ b/lib/wxExtend @@ -1 +1 @@ -Subproject commit bfa23771d9532a479210d81c75420cd15a0b3c97 +Subproject commit 23f8c36900dffeb768d08d26414510b1be74c51c