Address code analysis warnings

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2019-08-22 20:44:38 +02:00
parent a459823beb
commit 6fb5cb88d2
60 changed files with 935 additions and 960 deletions

View File

@ -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(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine); UNREFERENCED_PARAMETER(lpCmdLine);

File diff suppressed because it is too large Load Diff

View File

@ -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) /// \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__)); 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) /// \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__)); 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) /// \sa [EapPeerConfigXml2Blob function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363602.aspx)
/// ///
_Use_decl_annotations_
DWORD WINAPI EapPeerConfigXml2Blob( DWORD WINAPI EapPeerConfigXml2Blob(
_In_ DWORD dwFlags, DWORD dwFlags,
_In_ EAP_METHOD_TYPE eapMethodType, EAP_METHOD_TYPE eapMethodType,
_In_ IXMLDOMDocument2 *pConfigDoc, IXMLDOMDocument2 *pConfigDoc,
_Out_ BYTE **pConnectionDataOut, BYTE **pConnectionDataOut,
_Out_ DWORD *pdwConnectionDataOutSize, DWORD *pdwConnectionDataOutSize,
_Out_ EAP_ERROR **ppEapError) EAP_ERROR **ppEapError)
{ {
DWORD dwResult = ERROR_SUCCESS; DWORD dwResult = ERROR_SUCCESS;
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
@ -118,43 +121,36 @@ DWORD WINAPI EapPeerConfigXml2Blob(
//Sleep(10000); //Sleep(10000);
#endif #endif
// Initialize output parameters.
if (pConnectionDataOut)
*pConnectionDataOut = NULL;
if (pdwConnectionDataOutSize)
*pdwConnectionDataOutSize = 0;
if (ppEapError)
*ppEapError = NULL;
// Parameter check // 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; 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 (!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. // 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\"")); 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\""));
// <Config> // <Config>
com_obj<IXMLDOMElement> pXmlElConfig; com_obj<IXMLDOMElement> pXmlElConfig;
if (FAILED(eapxml::select_element(pConfigDoc, bstr(L"//eaphostconfig:Config"), 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 <Config> element."))); return dwResult = g_peer.log_error(ppEapError, ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" Error reading <Config> element."));
return dwResult;
}
// Load configuration. // Load configuration.
try { try {
g_peer.config_xml2blob(dwFlags, pXmlElConfig, pConnectionDataOut, pdwConnectionDataOutSize); g_peer.config_xml2blob(dwFlags, pXmlElConfig, pConnectionDataOut, pdwConnectionDataOutSize);
} catch (std::exception &err) { } catch (std::exception &err) {
g_peer.log_error(*ppEapError = g_peer.make_error(err)); dwResult = g_peer.log_error(ppEapError, err);
dwResult = (*ppEapError)->dwWinError;
} catch (...) { } catch (...) {
dwResult = ERROR_INVALID_DATA; dwResult = ERROR_INVALID_DATA;
} }
}
return dwResult; return dwResult;
} }
@ -167,13 +163,14 @@ DWORD WINAPI EapPeerConfigXml2Blob(
/// ///
/// \sa [EapPeerConfigBlob2Xml function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363601.aspx) /// \sa [EapPeerConfigBlob2Xml function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363601.aspx)
/// ///
_Use_decl_annotations_
DWORD WINAPI EapPeerConfigBlob2Xml( DWORD WINAPI EapPeerConfigBlob2Xml(
_In_ DWORD dwFlags, DWORD dwFlags,
_In_ EAP_METHOD_TYPE eapMethodType, EAP_METHOD_TYPE eapMethodType,
_In_count_(dwConnectionDataSize) const BYTE *pConnectionData, const BYTE *pConnectionData,
_In_ DWORD dwConnectionDataSize, DWORD dwConnectionDataSize,
_Out_ IXMLDOMDocument2 **ppConfigDoc, IXMLDOMDocument2 **ppConfigDoc,
_Out_ EAP_ERROR **ppEapError) EAP_ERROR **ppEapError)
{ {
DWORD dwResult = ERROR_SUCCESS; DWORD dwResult = ERROR_SUCCESS;
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
@ -181,66 +178,53 @@ DWORD WINAPI EapPeerConfigBlob2Xml(
//Sleep(10000); //Sleep(10000);
#endif #endif
// Initialize output parameters.
if (ppConfigDoc)
*ppConfigDoc = NULL;
if (ppEapError)
*ppEapError = NULL;
// Parameter check // 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; 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 (!ppConfigDoc)
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, _T(__FUNCTION__) _T(" ppConfigDoc is NULL.")));
else {
HRESULT hr; HRESULT hr;
// Create configuration XML document. // Create configuration XML document.
com_obj<IXMLDOMDocument2> pConfigDoc; com_obj<IXMLDOMDocument2> pConfigDoc;
if (FAILED(hr = pConfigDoc.create(CLSID_DOMDocument60, NULL, CLSCTX_INPROC_SERVER))) { 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 = g_peer.log_error(ppEapError, 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. // Load empty XML configuration.
VARIANT_BOOL isSuccess = VARIANT_FALSE; VARIANT_BOOL isSuccess = VARIANT_FALSE;
if (FAILED((hr = pConfigDoc->loadXML(L"<Config xmlns=\"http://www.microsoft.com/provisioning/EapHostConfig\"></Config>", &isSuccess)))) { if (FAILED((hr = pConfigDoc->loadXML(L"<Config xmlns=\"http://www.microsoft.com/provisioning/EapHostConfig\"></Config>", &isSuccess))))
g_peer.log_error(*ppEapError = g_peer.make_error(dwResult = HRESULT_CODE(hr), _T(__FUNCTION__) _T(" Error loading XML document template."))); return dwResult = g_peer.log_error(ppEapError, HRESULT_CODE(hr), _T(__FUNCTION__) _T(" Error loading XML document template."));
return dwResult; if (!isSuccess)
} return dwResult = g_peer.log_error(ppEapError, ERROR_XML_PARSE_ERROR, _T(__FUNCTION__) _T(" Loading XML template failed."));
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. // 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\"")); 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 <Config> node. // Select <Config> node.
com_obj<IXMLDOMNode> pXmlElConfig; com_obj<IXMLDOMNode> pXmlElConfig;
if (FAILED(eapxml::select_node(pConfigDoc, bstr(L"eaphostconfig:Config"), 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 <Config> element."))); return dwResult = g_peer.log_error(ppEapError, ERROR_NOT_FOUND, _T(__FUNCTION__) _T(" Error selecting <Config> element."));
return dwResult;
}
// Save configuration. // Save configuration.
pConfigDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\"")); pConfigDoc->setProperty(bstr(L"SelectionNamespaces"), variant(L"xmlns:eap-metadata=\"urn:ietf:params:xml:ns:yang:ietf-eap-metadata\""));
try { try {
g_peer.config_blob2xml(dwFlags, pConnectionData, dwConnectionDataSize, pConfigDoc, pXmlElConfig); g_peer.config_blob2xml(dwFlags, pConnectionData, dwConnectionDataSize, pConfigDoc, pXmlElConfig);
} catch (std::exception &err) { } catch (std::exception &err) {
g_peer.log_error(*ppEapError = g_peer.make_error(err)); dwResult = g_peer.log_error(ppEapError, err);
return dwResult = (*ppEapError)->dwWinError;
} catch (...) { } catch (...) {
return dwResult = ERROR_INVALID_DATA; return dwResult = ERROR_INVALID_DATA;
} }
*ppConfigDoc = pConfigDoc.detach(); *ppConfigDoc = pConfigDoc.detach();
}
return dwResult; return dwResult;
} }
@ -251,15 +235,16 @@ DWORD WINAPI EapPeerConfigBlob2Xml(
/// ///
/// \sa [EapPeerInvokeConfigUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363614.aspx) /// \sa [EapPeerInvokeConfigUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363614.aspx)
/// ///
//_Use_decl_annotations_
DWORD WINAPI EapPeerInvokeConfigUI( DWORD WINAPI EapPeerInvokeConfigUI(
_In_ const EAP_METHOD_TYPE *pEapType, const EAP_METHOD_TYPE *pEapType,
_In_ HWND hwndParent, HWND hwndParent,
_In_ DWORD dwFlags, DWORD dwFlags,
_In_ DWORD dwConnectionDataInSize, DWORD dwConnectionDataInSize,
_In_count_(dwConnectionDataInSize) const BYTE *pConnectionDataIn, const BYTE *pConnectionDataIn,
_Out_ DWORD *pdwConnectionDataOutSize, DWORD *pdwConnectionDataOutSize,
_Out_ BYTE **ppConnectionDataOut, BYTE **ppConnectionDataOut,
_Out_ EAP_ERROR **ppEapError) EAP_ERROR **ppEapError)
{ {
UNREFERENCED_PARAMETER(dwFlags); UNREFERENCED_PARAMETER(dwFlags);
DWORD dwResult = ERROR_SUCCESS; DWORD dwResult = ERROR_SUCCESS;
@ -269,34 +254,27 @@ DWORD WINAPI EapPeerInvokeConfigUI(
//Sleep(10000); //Sleep(10000);
#endif #endif
// Initialize output parameters.
if (pdwConnectionDataOutSize)
*pdwConnectionDataOutSize = 0;
if (ppConnectionDataOut)
*ppConnectionDataOut = NULL;
if (ppEapError)
*ppEapError = NULL;
// Parameter check // Parameter check
if (!ppEapError) if (!pEapType || !pConnectionDataIn && dwConnectionDataInSize || !pdwConnectionDataOutSize || !ppConnectionDataOut)
return dwResult = ERROR_INVALID_PARAMETER; 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 { try {
g_peer.invoke_config_ui(hwndParent, pConnectionDataIn, dwConnectionDataInSize, ppConnectionDataOut, pdwConnectionDataOutSize); g_peer.invoke_config_ui(hwndParent, pConnectionDataIn, dwConnectionDataInSize, ppConnectionDataOut, pdwConnectionDataOutSize);
} catch (std::exception &err) { } catch (std::exception &err) {
g_peer.log_error(*ppEapError = g_peer.make_error(err)); dwResult = g_peer.log_error(ppEapError, err);
dwResult = (*ppEapError)->dwWinError;
} catch (...) { } catch (...) {
dwResult = ERROR_INVALID_DATA; dwResult = ERROR_INVALID_DATA;
} }
}
return dwResult; return dwResult;
} }
@ -307,18 +285,19 @@ DWORD WINAPI EapPeerInvokeConfigUI(
/// ///
/// \sa [EapPeerInvokeIdentityUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363615.aspx) /// \sa [EapPeerInvokeIdentityUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363615.aspx)
/// ///
//_Use_decl_annotations_
DWORD WINAPI EapPeerInvokeIdentityUI( DWORD WINAPI EapPeerInvokeIdentityUI(
_In_ const EAP_METHOD_TYPE *pEapType, const EAP_METHOD_TYPE *pEapType,
_In_ DWORD dwFlags, DWORD dwFlags,
_In_ HWND hwndParent, HWND hwndParent,
_In_ DWORD dwConnectionDataSize, DWORD dwConnectionDataSize,
_In_count_(dwConnectionDataSize) const BYTE *pConnectionData, const BYTE *pConnectionData,
_In_ DWORD dwUserDataSize, DWORD dwUserDataSize,
_In_count_(dwUserDataSize) const BYTE *pUserData, const BYTE *pUserData,
_Out_ DWORD *pdwUserDataOutSize, DWORD *pdwUserDataOutSize,
_Out_ BYTE **ppUserDataOut, BYTE **ppUserDataOut,
_Out_ LPWSTR *ppwszIdentity, LPWSTR *ppwszIdentity,
_Out_ EAP_ERROR **ppEapError) EAP_ERROR **ppEapError)
{ {
DWORD dwResult = ERROR_SUCCESS; DWORD dwResult = ERROR_SUCCESS;
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
@ -327,38 +306,29 @@ DWORD WINAPI EapPeerInvokeIdentityUI(
//Sleep(10000); //Sleep(10000);
#endif #endif
// Initialize output parameters.
if (pdwUserDataOutSize)
*pdwUserDataOutSize = 0;
if (ppUserDataOut)
*ppUserDataOut = NULL;
if (ppwszIdentity)
*ppwszIdentity = NULL;
if (ppEapError)
*ppEapError = NULL;
// Parameter check // Parameter check
if (!ppEapError) if (!pEapType || !pConnectionData && dwConnectionDataSize || !pUserData && dwUserDataSize || !pdwUserDataOutSize || !ppUserDataOut || !ppwszIdentity)
dwResult = ERROR_INVALID_PARAMETER; 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 { try {
g_peer.invoke_identity_ui(hwndParent, dwFlags, pConnectionData, dwConnectionDataSize, pUserData, dwUserDataSize, ppUserDataOut, pdwUserDataOutSize, ppwszIdentity); g_peer.invoke_identity_ui(hwndParent, dwFlags, pConnectionData, dwConnectionDataSize, pUserData, dwUserDataSize, ppUserDataOut, pdwUserDataOutSize, ppwszIdentity);
} catch (std::exception &err) { } catch (std::exception &err) {
g_peer.log_error(*ppEapError = g_peer.make_error(err)); dwResult = g_peer.log_error(ppEapError, err);
dwResult = (*ppEapError)->dwWinError;
} catch (...) { } catch (...) {
dwResult = ERROR_INVALID_DATA; dwResult = ERROR_INVALID_DATA;
} }
}
return dwResult; return dwResult;
} }
@ -369,14 +339,15 @@ DWORD WINAPI EapPeerInvokeIdentityUI(
/// ///
/// \sa [EapPeerInvokeInteractiveUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363616.aspx) /// \sa [EapPeerInvokeInteractiveUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363616.aspx)
/// ///
//_Use_decl_annotations_
DWORD WINAPI EapPeerInvokeInteractiveUI( DWORD WINAPI EapPeerInvokeInteractiveUI(
_In_ const EAP_METHOD_TYPE *pEapType, const EAP_METHOD_TYPE *pEapType,
_In_ HWND hwndParent, HWND hwndParent,
_In_ DWORD dwUIContextDataSize, DWORD dwUIContextDataSize,
_In_count_(dwUIContextDataSize) const BYTE *pUIContextData, const BYTE *pUIContextData,
_Out_ DWORD *pdwDataFromInteractiveUISize, DWORD *pdwDataFromInteractiveUISize,
_Out_ BYTE **ppDataFromInteractiveUI, BYTE **ppDataFromInteractiveUI,
_Out_ EAP_ERROR **ppEapError) EAP_ERROR **ppEapError)
{ {
DWORD dwResult = ERROR_SUCCESS; DWORD dwResult = ERROR_SUCCESS;
event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult)); event_fn_auto_ret<DWORD> event_auto(g_peer.get_event_fn_auto(__FUNCTION__, dwResult));
@ -385,34 +356,27 @@ DWORD WINAPI EapPeerInvokeInteractiveUI(
//Sleep(10000); //Sleep(10000);
#endif #endif
// Initialize output parameters.
if (pdwDataFromInteractiveUISize)
*pdwDataFromInteractiveUISize = 0;
if (ppDataFromInteractiveUI)
*ppDataFromInteractiveUI = NULL;
if (ppEapError)
*ppEapError = NULL;
// Parameter check // Parameter check
if (!ppEapError) if (!pEapType || !pUIContextData && dwUIContextDataSize || !pdwDataFromInteractiveUISize || !ppDataFromInteractiveUI)
return dwResult = ERROR_INVALID_PARAMETER; 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 { try {
g_peer.invoke_interactive_ui(hwndParent, pUIContextData, dwUIContextDataSize, ppDataFromInteractiveUI, pdwDataFromInteractiveUISize); g_peer.invoke_interactive_ui(hwndParent, pUIContextData, dwUIContextDataSize, ppDataFromInteractiveUI, pdwDataFromInteractiveUISize);
} catch (std::exception &err) { } catch (std::exception &err) {
g_peer.log_error(*ppEapError = g_peer.make_error(err)); dwResult = g_peer.log_error(ppEapError, err);
dwResult = (*ppEapError)->dwWinError;
} catch (...) { } catch (...) {
dwResult = ERROR_INVALID_DATA; dwResult = ERROR_INVALID_DATA;
} }
}
return dwResult; return dwResult;
} }

View File

@ -28,6 +28,7 @@
// wxEventMonitorApp // wxEventMonitorApp
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#pragma warning(suppress: 28251)
wxIMPLEMENT_APP(wxEventMonitorApp); wxIMPLEMENT_APP(wxEventMonitorApp);

View File

@ -132,11 +132,8 @@ VOID WINAPI wxEventTraceProcessorThread::EventRecordCallback(_In_ PEVENT_RECORD
wxASSERT_MSG(pEvent->UserContext, wxT("thread is NULL")); wxASSERT_MSG(pEvent->UserContext, wxT("thread is NULL"));
wxEventTraceProcessorThread *_this = ((wxEventTraceProcessorThread*)pEvent->UserContext); wxEventTraceProcessorThread *_this = ((wxEventTraceProcessorThread*)pEvent->UserContext);
if (!_this || _this->TestDestroy())
if (_this->TestDestroy()) {
// Event processing is pending destruction.
return; return;
}
_this->m_parent->QueueEvent(new wxETWEvent(wxEVT_ETW_EVENT, *pEvent)); _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[0] = 26;
m_col_format_width[1] = 5; m_col_format_width[1] = 5;
m_col_format_width[2] = 5; m_col_format_width[2] = 5;
m_col_format_width[3] = std::max<int>(std::max<int>(_countof("EapHost"), _countof("Schannel")), _countof(PRODUCT_NAME_STR)) - 1; m_col_format_width[3] = std::max<size_t>(std::max<size_t>(_countof("EapHost"), _countof("Schannel")), _countof(PRODUCT_NAME_STR)) - 1;
m_col_format_width[4] = 0; m_col_format_width[4] = 0;
// Prepare all possible item attributes. // Prepare all possible item attributes.
@ -219,7 +216,11 @@ wxETWListCtrl::wxETWListCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos
properties->Wnode.BufferSize = ulSize; properties->Wnode.BufferSize = ulSize;
properties->Wnode.Flags = WNODE_FLAG_TRACED_GUID; properties->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
properties->Wnode.ClientContext = 1; //QPC clock resolution 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->LogFileMode = /*EVENT_TRACE_FILE_MODE_SEQUENTIAL |*/ EVENT_TRACE_REAL_TIME_MODE;
properties->MaximumFileSize = 1; // 1 MB properties->MaximumFileSize = 1; // 1 MB
properties->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES); 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)) ((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) 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 { else {
for (ULONG i = 0; ; i++) { for (ULONG i = 0; ; i++) {
if (i >= pMapInfo->EntryCount) if (i >= pMapInfo->EntryCount)
return tstring_printf(_T("%lu"), ulData); return tstring_printf(_T("%lu"), ulData);
else if (pMapInfo->MapEntryArray[i].Value == 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 ( } else if (
@ -817,7 +818,7 @@ static tstring DataToString(_In_ USHORT InType, _In_ USHORT OutType, _In_count_(
case TDH_INTYPE_UNICODESTRING: case TDH_INTYPE_UNICODESTRING:
case TDH_INTYPE_NONNULLTERMINATEDSTRING: case TDH_INTYPE_NONNULLTERMINATEDSTRING:
case TDH_INTYPE_UNICODECHAR: 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_ANSISTRING:
case TDH_INTYPE_NONNULLTERMINATEDANSISTRING: case TDH_INTYPE_NONNULLTERMINATEDANSISTRING:
@ -918,6 +919,7 @@ static tstring DataToString(_In_ USHORT InType, _In_ USHORT OutType, _In_count_(
case TDH_INTYPE_BINARY: case TDH_INTYPE_BINARY:
switch (OutType) { switch (OutType) {
case TDH_OUTTYPE_IPV6: { 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")), auto RtlIpv6AddressToString = (LPTSTR(NTAPI*)(const IN6_ADDR*, LPTSTR))GetProcAddress(GetModuleHandle(_T("ntdll.dll")),
#ifdef _UNICODE #ifdef _UNICODE
"RtlIpv6AddressToStringW" "RtlIpv6AddressToStringW"
@ -945,8 +947,12 @@ static tstring DataToString(_In_ USHORT InType, _In_ USHORT OutType, _In_count_(
case TDH_INTYPE_GUID: { case TDH_INTYPE_GUID: {
assert(nDataSize >= sizeof(GUID)); assert(nDataSize >= sizeof(GUID));
WCHAR szGuid[39]; WCHAR szGuid[39];
StringFromGUID2(*(GUID*)pData, szGuid, _countof(szGuid)); if (StringFromGUID2(*(GUID*)pData, szGuid, _countof(szGuid)))
return tstring_printf(_T("%ls"), szGuid); return tstring_printf(_T("%ls"), szGuid);
else {
assert(0);
return _T("(GUID)");
}
} }
case TDH_INTYPE_POINTER: 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. // 32-bit computer and 16 bytes on a 64-bit computer.
// Doubling the pointer size handles both cases. // Doubling the pointer size handles both cases.
assert(nDataSize >= (SIZE_T)nPtrSize * 2); 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: { case TDH_INTYPE_SID: {
assert(nDataSize >= sizeof(SID)); assert(nDataSize >= sizeof(SID));
@ -1027,7 +1033,7 @@ static ULONG GetArraySize(PEVENT_RECORD pEvent, PTRACE_EVENT_INFO pInfo, ULONG i
ULONG ulResult; ULONG ulResult;
// Get array count property. // Get array count property.
PROPERTY_DATA_DESCRIPTOR data_desc = { (ULONGLONG)(reinterpret_cast<LPBYTE>(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<unsigned char> count; vector<unsigned char> count;
if ((ulResult = TdhGetProperty(pEvent, 0, NULL, 1, &data_desc, count)) != ERROR_SUCCESS) if ((ulResult = TdhGetProperty(pEvent, 0, NULL, 1, &data_desc, count)) != ERROR_SUCCESS)
return ulResult; 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; if (out_nonfirst) out += _T(", "); else out_nonfirst = true;
out += _T('('); out += _T('(');
for (USHORT j = pInfo->EventPropertyInfoArray[ulPropIndex].structType.StructStartIndex, usLastMember = pInfo->EventPropertyInfoArray[ulPropIndex].structType.StructStartIndex + pInfo->EventPropertyInfoArray[ulPropIndex].structType.NumOfStructMembers; j < usLastMember; j++) { 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<LPBYTE>(pInfo) + pInfo->EventPropertyInfoArray[j].NameOffset); out += tstring_printf(_T("%ls: "), (LPCWSTR)(reinterpret_cast<LPBYTE>(pInfo) + pInfo->EventPropertyInfoArray[j].NameOffset));
out += PropertyToString(pEvent, pInfo, j, reinterpret_cast<LPWSTR>(reinterpret_cast<LPBYTE>(pInfo) + pInfo->EventPropertyInfoArray[ulPropIndex].NameOffset), k, nPtrSize); out += PropertyToString(pEvent, pInfo, j, reinterpret_cast<LPWSTR>(reinterpret_cast<LPBYTE>(pInfo) + pInfo->EventPropertyInfoArray[ulPropIndex].NameOffset), k, nPtrSize);
} }
out += _T(')'); out += _T(')');
@ -1087,11 +1093,11 @@ static tstring PropertyToString(PEVENT_RECORD pEvent, PTRACE_EVENT_INFO pInfo, U
// descriptor defines the member of the structure whose data you want to retrieve. // descriptor defines the member of the structure whose data you want to retrieve.
PROPERTY_DATA_DESCRIPTOR data_desc[2] = { PROPERTY_DATA_DESCRIPTOR data_desc[2] = {
{ (ULONGLONG)pStructureName , ulStructIndex }, { (ULONGLONG)pStructureName , ulStructIndex },
{ (ULONGLONG)(reinterpret_cast<LPBYTE>(pInfo) + pInfo->EventPropertyInfoArray[ulPropIndex].NameOffset), k } { (ULONGLONG)pInfo + pInfo->EventPropertyInfoArray[ulPropIndex].NameOffset, k }
}; };
ulResult = TdhGetProperty(pEvent, 0, NULL, _countof(data_desc), data_desc, data); ulResult = TdhGetProperty(pEvent, 0, NULL, _countof(data_desc), data_desc, data);
} else { } else {
PROPERTY_DATA_DESCRIPTOR data_desc = { (ULONGLONG)(reinterpret_cast<LPBYTE>(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); ulResult = TdhGetProperty(pEvent, 0, NULL, 1, &data_desc, data);
} }
if (ulResult == ERROR_EVT_INVALID_EVENT_DATA) { if (ulResult == ERROR_EVT_INVALID_EVENT_DATA) {

View File

@ -150,7 +150,7 @@ protected:
private: private:
/// \cond internal /// \cond internal
static VOID WINAPI EventRecordCallback(PEVENT_RECORD pEvent); static VOID WINAPI EventRecordCallback(_In_ PEVENT_RECORD pEvent);
/// \endcond /// \endcond
protected: protected:

View File

@ -34,6 +34,9 @@ class wxPersistentEventMonitorFrame;
#include <WinStd/Win.h> #include <WinStd/Win.h>
#pragma warning(push)
#pragma warning(disable: 26444)
/// \addtogroup EventMonitor /// \addtogroup EventMonitor
/// @{ /// @{
@ -173,3 +176,5 @@ inline wxPersistentObject *wxCreatePersistentObject(wxEventMonitorFrame *wnd)
} }
/// @} /// @}
#pragma warning(pop)

View File

@ -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(hInstance);
UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(hPrevInstance);

View File

@ -130,6 +130,7 @@ static int WLANManager()
// Launch WLAN profile config dialog. // Launch WLAN profile config dialog.
WLAN_REASON_CODE wlrc = L2_REASON_CODE_SUCCESS; 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); DWORD dwResult = WlanUIEditProfile(WLAN_UI_API_VERSION, pwcArglist[2], &(interfaces->InterfaceInfo[i].InterfaceGuid), NULL, WLSecurityPage, NULL, &wlrc);
if (dwResult != ERROR_SUCCESS) { if (dwResult != ERROR_SUCCESS) {
// WlanUIEditProfile() displays own error dialog on failure. // 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(hInstance);
UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(hPrevInstance);

View File

@ -29,6 +29,9 @@
<IncludePath>$(WXWIN)\include\msvc;$(WXWIN)\include;$(IncludePath)</IncludePath> <IncludePath>$(WXWIN)\include\msvc;$(WXWIN)\include;$(IncludePath)</IncludePath>
<SourcePath>$(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)</SourcePath> <SourcePath>$(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)</SourcePath>
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<CodeAnalysisRuleSet>NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CAExcludePath>$(WXWIN);$(CAExcludePath)</CAExcludePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup> <ItemDefinitionGroup>
<ClCompile> <ClCompile>
@ -38,6 +41,7 @@
<PrecompiledHeaderFile>StdAfx.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>StdAfx.h</PrecompiledHeaderFile>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<StringPooling>true</StringPooling> <StringPooling>true</StringPooling>
<EnablePREfast>true</EnablePREfast>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>

View File

@ -83,7 +83,7 @@ namespace eap
/// ///
/// \param[in] other Configuration to move from /// \param[in] other Configuration to move from
/// ///
config(_Inout_ config &&other); config(_Inout_ config &&other) noexcept;
/// ///
/// Copies configuration /// Copies configuration
@ -101,7 +101,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
config& operator=(_Inout_ config &&other); config& operator=(_Inout_ config &&other) noexcept;
/// ///
/// Clones this object /// Clones this object
@ -187,7 +187,7 @@ namespace eap
/// ///
/// \param[in] other Configuration to move from /// \param[in] other Configuration to move from
/// ///
config_method(_Inout_ config_method &&other); config_method(_Inout_ config_method &&other) noexcept;
/// ///
/// Copies configuration /// Copies configuration
@ -205,7 +205,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
config_method& operator=(_Inout_ config_method &&other); config_method& operator=(_Inout_ config_method &&other) noexcept;
/// \name XML management /// \name XML management
/// @{ /// @{
@ -271,7 +271,7 @@ namespace eap
/// ///
/// \param[in] other Configuration to move from /// \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 /// Copies configuration
@ -289,7 +289,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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 /// \name XML management
/// @{ /// @{
@ -335,7 +335,7 @@ namespace eap
/// ///
/// \param[in] other Configuration to move from /// \param[in] other Configuration to move from
/// ///
config_provider(_Inout_ config_provider &&other); config_provider(_Inout_ config_provider &&other) noexcept;
/// ///
/// Copies configuration /// Copies configuration
@ -353,7 +353,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
config_provider& operator=(_Inout_ config_provider &&other); config_provider& operator=(_Inout_ config_provider &&other) noexcept;
virtual config* clone() const; virtual config* clone() const;
@ -431,7 +431,7 @@ namespace eap
/// ///
/// \param[in] other Configuration to move from /// \param[in] other Configuration to move from
/// ///
config_connection(_Inout_ config_connection &&other); config_connection(_Inout_ config_connection &&other) noexcept;
/// ///
/// Copies configuration /// Copies configuration
@ -449,7 +449,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
config_connection& operator=(_Inout_ config_connection &&other); config_connection& operator=(_Inout_ config_connection &&other) noexcept;
virtual config* clone() const; virtual config* clone() const;

View File

@ -86,7 +86,7 @@ namespace eap
/// ///
/// \param[in] other Credentials to move from /// \param[in] other Credentials to move from
/// ///
credentials(_Inout_ credentials &&other); credentials(_Inout_ credentials &&other) noexcept;
/// ///
/// Copies credentials /// Copies credentials
@ -104,7 +104,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
credentials& operator=(_Inout_ credentials &&other); credentials& operator=(_Inout_ credentials &&other) noexcept;
/// ///
/// Resets credentials /// Resets credentials
@ -216,7 +216,7 @@ namespace eap
/// ///
virtual source_t combine( virtual source_t combine(
_In_ DWORD dwFlags, _In_ DWORD dwFlags,
_In_ HANDLE hTokenImpersonateUser, _In_opt_ HANDLE hTokenImpersonateUser,
_In_opt_ const credentials *cred_cached, _In_opt_ const credentials *cred_cached,
_In_ const config_method &cfg, _In_ const config_method &cfg,
_In_opt_z_ LPCTSTR pszTargetName) = 0; _In_opt_z_ LPCTSTR pszTargetName) = 0;
@ -251,7 +251,7 @@ namespace eap
/// ///
/// \param[in] other Credentials to move from /// \param[in] other Credentials to move from
/// ///
credentials_identity(_Inout_ credentials_identity &&other); credentials_identity(_Inout_ credentials_identity &&other) noexcept;
/// ///
/// Copies credentials /// Copies credentials
@ -269,7 +269,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
credentials_identity& operator=(_Inout_ credentials_identity &&other); credentials_identity& operator=(_Inout_ credentials_identity &&other) noexcept;
virtual config* clone() const; virtual config* clone() const;
@ -311,7 +311,7 @@ namespace eap
/// ///
virtual source_t combine( virtual source_t combine(
_In_ DWORD dwFlags, _In_ DWORD dwFlags,
_In_ HANDLE hTokenImpersonateUser, _In_opt_ HANDLE hTokenImpersonateUser,
_In_opt_ const credentials *cred_cached, _In_opt_ const credentials *cred_cached,
_In_ const config_method &cfg, _In_ const config_method &cfg,
_In_opt_z_ LPCTSTR pszTargetName); _In_opt_z_ LPCTSTR pszTargetName);
@ -354,7 +354,7 @@ namespace eap
/// ///
/// \param[in] other Credentials to move from /// \param[in] other Credentials to move from
/// ///
credentials_pass(_Inout_ credentials_pass &&other); credentials_pass(_Inout_ credentials_pass &&other) noexcept;
/// ///
/// Copies credentials /// Copies credentials
@ -372,7 +372,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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 config* clone() const;
virtual void clear(); virtual void clear();
@ -423,7 +423,7 @@ namespace eap
/// ///
virtual source_t combine( virtual source_t combine(
_In_ DWORD dwFlags, _In_ DWORD dwFlags,
_In_ HANDLE hTokenImpersonateUser, _In_opt_ HANDLE hTokenImpersonateUser,
_In_opt_ const credentials *cred_cached, _In_opt_ const credentials *cred_cached,
_In_ const config_method &cfg, _In_ const config_method &cfg,
_In_opt_z_ LPCTSTR pszTargetName); _In_opt_z_ LPCTSTR pszTargetName);
@ -465,7 +465,7 @@ namespace eap
/// ///
/// \param[in] other Credentials to move from /// \param[in] other Credentials to move from
/// ///
credentials_connection(_Inout_ credentials_connection &&other); credentials_connection(_Inout_ credentials_connection &&other) noexcept;
/// ///
/// Copies credentials /// Copies credentials
@ -483,7 +483,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
credentials_connection& operator=(_Inout_ credentials_connection &&other); credentials_connection& operator=(_Inout_ credentials_connection &&other) noexcept;
virtual config* clone() const; virtual config* clone() const;

View File

@ -551,7 +551,7 @@ inline unsigned __int64 htonll(unsigned __int64 val);
/// \param[in ] val A 24-bit unsigned number in host byte order /// \param[in ] val A 24-bit unsigned number in host byte order
/// \param[out] out A 24-bit unsigned number in network 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. /// Converts a 24-bit integer from TCP/IP network to host byte order.
@ -658,6 +658,9 @@ namespace eap
/// ///
/// Constructor /// 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() inline sanitizing_blob_f()
{ {
} }
@ -677,7 +680,7 @@ namespace eap
/// ///
/// \param[inout] other BLOB to move from /// \param[inout] other BLOB to move from
/// ///
inline sanitizing_blob_f(_Inout_ sanitizing_blob_f<N> &&other) inline sanitizing_blob_f(_Inout_ sanitizing_blob_f<N> &&other) noexcept
{ {
memcpy(data, other.data, N); memcpy(data, other.data, N);
} }
@ -687,7 +690,7 @@ namespace eap
/// ///
/// \param[inout] other Zero-initialized BLOB to move from /// \param[inout] other Zero-initialized BLOB to move from
/// ///
inline sanitizing_blob_f(_Inout_ sanitizing_blob_zf<N> &&other) inline sanitizing_blob_f(_Inout_ sanitizing_blob_zf<N> &&other) noexcept
{ {
memcpy(data, other.data, N); memcpy(data, other.data, N);
memset(other.data, 0, N); memset(other.data, 0, N);
@ -722,7 +725,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
inline sanitizing_blob_f& operator=(_Inout_ sanitizing_blob_f<N> &&other) inline sanitizing_blob_f& operator=(_Inout_ sanitizing_blob_f<N> &&other) noexcept
{ {
if (this != std::addressof(other)) if (this != std::addressof(other))
memcpy(data, other.data, N); memcpy(data, other.data, N);
@ -736,7 +739,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
inline sanitizing_blob_f& operator=(_Inout_ sanitizing_blob_zf<N> &&other) inline sanitizing_blob_f& operator=(_Inout_ sanitizing_blob_zf<N> &&other) noexcept
{ {
if (this != std::addressof(other)) { if (this != std::addressof(other)) {
memcpy(data, other.data, N); memcpy(data, other.data, N);
@ -827,7 +830,7 @@ namespace eap
/// ///
/// \param[inout] other Zero-initialized BLOB to move from /// \param[inout] other Zero-initialized BLOB to move from
/// ///
inline sanitizing_blob_zf(_Inout_ sanitizing_blob_zf<N> &&other) : inline sanitizing_blob_zf(_Inout_ sanitizing_blob_zf<N> &&other) noexcept :
sanitizing_blob_f<N>(std::move(other)) sanitizing_blob_f<N>(std::move(other))
{ {
memset(other.data, 0, N); memset(other.data, 0, N);
@ -848,7 +851,7 @@ namespace eap
/// ///
/// \param[inout] other BLOB to move from /// \param[inout] other BLOB to move from
/// ///
inline sanitizing_blob_zf(_Inout_ sanitizing_blob_f<N> &&other) : inline sanitizing_blob_zf(_Inout_ sanitizing_blob_f<N> &&other) noexcept :
sanitizing_blob_f<N>(std::move(other)) sanitizing_blob_f<N>(std::move(other))
{ {
} }
@ -874,7 +877,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
inline sanitizing_blob_zf& operator=(_Inout_ sanitizing_blob_zf<N> &&other) inline sanitizing_blob_zf& operator=(_Inout_ sanitizing_blob_zf<N> &&other) noexcept
{ {
if (this != std::addressof(other)) { if (this != std::addressof(other)) {
memcpy(data, other.data, N); memcpy(data, other.data, N);
@ -904,7 +907,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
inline sanitizing_blob_zf& operator=(_Inout_ sanitizing_blob_f<N> &&other) inline sanitizing_blob_zf& operator=(_Inout_ sanitizing_blob_f<N> &&other) noexcept
{ {
if (this != std::addressof(other)) if (this != std::addressof(other))
memcpy(data, other.data, N); memcpy(data, other.data, N);
@ -1110,7 +1113,7 @@ inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::basic_st
template<class _Traits, class _Ax> template<class _Traits, class _Ax>
inline size_t pksizeof(_In_ const std::basic_string<wchar_t, _Traits, _Ax> &val) inline size_t pksizeof(_In_ const std::basic_string<wchar_t, _Traits, _Ax> &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 #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); assert(val <= 0xffffff);
out[0] = (val >> 16) & 0xff; out[0] = (val >> 16) & 0xff;

View File

@ -357,7 +357,7 @@ namespace eapxml
/// - <0 if failed. /// - <0 if failed.
/// Use `SUCCEEDED()` macro to test for first two cases (>=0) or `FAILED()` to test for failure. /// 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<IXMLDOMElement> *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<IXMLDOMElement> *ppXmlElement = NULL);
/// ///
/// Creates a new child element with hexadecimal encoded text from BLOB /// Creates a new child element with hexadecimal encoded text from BLOB
@ -376,7 +376,7 @@ namespace eapxml
/// - <0 if failed. /// - <0 if failed.
/// Use `SUCCEEDED()` macro to test for first two cases (>=0) or `FAILED()` to test for failure. /// 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<IXMLDOMElement> *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<IXMLDOMElement> *ppXmlElement = NULL);
/// ///
/// Returns attribute text /// Returns attribute text
@ -481,7 +481,7 @@ namespace eapxml
/// - <0 if failed. /// - <0 if failed.
/// Use `SUCCEEDED()` macro to test for first two cases (>=0) or `FAILED()` to test for failure. /// 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 /// Sets node attribute converted from number
@ -496,7 +496,7 @@ namespace eapxml
/// - <0 if failed. /// - <0 if failed.
/// Use `SUCCEEDED()` macro to test for first two cases (>=0) or `FAILED()` to test for failure. /// 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 /// Sets node attribute converted from boolean
@ -511,7 +511,7 @@ namespace eapxml
/// - <0 if failed. /// - <0 if failed.
/// Use `SUCCEEDED()` macro to test for first two cases (>=0) or `FAILED()` to test for failure. /// 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 /// Sets node attribute to Base64 encoded text from BLOB
@ -527,7 +527,7 @@ namespace eapxml
/// - <0 if failed. /// - <0 if failed.
/// Use `SUCCEEDED()` macro to test for first two cases (>=0) or `FAILED()` to test for failure. /// 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 /// Sets node attribute to hexadecimal encoded text from BLOB
/// ///
@ -542,7 +542,7 @@ namespace eapxml
/// - <0 if failed. /// - <0 if failed.
/// Use `SUCCEEDED()` macro to test for first two cases (>=0) or `FAILED()` to test for failure. /// 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 /// Builds XPath for a given node
@ -786,7 +786,7 @@ namespace eapxml
pbstrValue = std::move(bstrEn); pbstrValue = std::move(bstrEn);
return S_OK; return S_OK;
} else } else
return ERROR_NOT_FOUND; return HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
} }
winstd::com_obj<IXMLDOMNode> pXmlElLocalizedText; winstd::com_obj<IXMLDOMNode> pXmlElLocalizedText;
@ -831,7 +831,6 @@ namespace eapxml
{ {
assert(pDoc); assert(pDoc);
assert(pCurrentDOMNode); assert(pCurrentDOMNode);
assert(ppXmlElement);
static const VARIANT varNodeTypeEl = { VT_I4, 0, 0, 0, { NODE_ELEMENT } }; static const VARIANT varNodeTypeEl = { VT_I4, 0, 0, 0, { NODE_ELEMENT } };
HRESULT hr; 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<IXMLDOMElement> *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<IXMLDOMElement> *ppXmlElement)
{ {
std::wstring sBase64; std::wstring sBase64;
winstd::base64_enc enc; 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<IXMLDOMElement> *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<IXMLDOMElement> *ppXmlElement)
{ {
std::wstring sHex; std::wstring sHex;
winstd::hex_enc enc; 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) inline HRESULT get_attrib_value(_In_ IXMLDOMNode *pXmlParent, _In_z_ const BSTR bstrAttributeName, _Out_ bool &pbValue)
{ {
assert(pbValue);
winstd::bstr bstr; winstd::bstr bstr;
HRESULT hr = get_attrib_value(pXmlParent, bstrAttributeName, bstr); HRESULT hr = get_attrib_value(pXmlParent, bstrAttributeName, bstr);
if (SUCCEEDED(hr)) { 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; std::wstring sBase64;
winstd::base64_enc enc; 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; std::wstring sHex;
winstd::hex_enc enc; winstd::hex_enc enc;

View File

@ -69,7 +69,7 @@ namespace eap
/// ///
/// \param[in] other Method to move from /// \param[in] other Method to move from
/// ///
method(_Inout_ method &&other); method(_Inout_ method &&other) noexcept;
/// ///
/// Moves a method /// Moves a method
@ -78,7 +78,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
method& operator=(_Inout_ method &&other); method& operator=(_Inout_ method &&other) noexcept;
/// \name Session management /// \name Session management
/// @{ /// @{
@ -145,11 +145,11 @@ namespace eap
/// \sa [EapPeerGetResult function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363611.aspx) /// \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[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[inout] pResult A pointer to a structure that contains the authentication results.
/// ///
virtual void get_result( virtual void get_result(
_In_ EapPeerMethodResultReason reason, _In_ EapPeerMethodResultReason reason,
_Out_ EapPeerMethodResult *pResult); _Inout_ EapPeerMethodResult *pResult);
/// \name User Interaction /// \name User Interaction
/// @{ /// @{
@ -236,7 +236,7 @@ namespace eap
/// ///
/// \param[in] other Method to move from /// \param[in] other Method to move from
/// ///
method_tunnel(_Inout_ method_tunnel &&other); method_tunnel(_Inout_ method_tunnel &&other) noexcept;
/// ///
/// Moves a method /// Moves a method
@ -245,7 +245,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
method_tunnel& operator=(_Inout_ method_tunnel &&other); method_tunnel& operator=(_Inout_ method_tunnel &&other) noexcept;
/// \name Session management /// \name Session management
/// @{ /// @{
@ -275,7 +275,7 @@ namespace eap
virtual void get_result( virtual void get_result(
_In_ EapPeerMethodResultReason reason, _In_ EapPeerMethodResultReason reason,
_Out_ EapPeerMethodResult *pResult); _Inout_ EapPeerMethodResult *pResult);
/// \name User Interaction /// \name User Interaction
/// @{ /// @{
@ -326,7 +326,7 @@ namespace eap
/// ///
/// \param[in] other Method to move from /// \param[in] other Method to move from
/// ///
method_eap(_Inout_ method_eap &&other); method_eap(_Inout_ method_eap &&other) noexcept;
/// ///
/// Moves a method /// Moves a method
@ -335,7 +335,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
method_eap& operator=(_Inout_ method_eap &&other); method_eap& operator=(_Inout_ method_eap &&other) noexcept;
/// \name Session management /// \name Session management
/// @{ /// @{

View File

@ -93,17 +93,17 @@ namespace eap
/// ///
/// Allocate BLOB /// Allocate BLOB
/// ///
BYTE* alloc_memory(_In_ size_t size); BYTE* alloc_memory(_In_ size_t size) const;
/// ///
/// Free BLOB allocated with this peer /// 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 /// 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 /// Makes a new method configuration
@ -147,6 +147,35 @@ namespace eap
/// ///
void log_error(_In_ const EAP_ERROR *err) const; 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 /// Logs Unicode string config value
/// ///
@ -288,7 +317,7 @@ namespace eap
/// ///
/// \returns Encrypted data /// \returns Encrypted data
/// ///
std::vector<unsigned char> encrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_opt_ HCRYPTHASH hHash = NULL) const; std::vector<unsigned char> 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 /// \returns Encrypted data
/// ///
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
std::vector<unsigned char> encrypt(_In_ HCRYPTPROV hProv, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val, _Out_opt_ HCRYPTHASH hHash = NULL) const std::vector<unsigned char> 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); return encrypt(hProv, val.c_str(), val.length()*sizeof(_Elem), hHash);
} }
@ -317,7 +346,7 @@ namespace eap
/// \returns Encrypted data /// \returns Encrypted data
/// ///
template<class _Traits, class _Ax> template<class _Traits, class _Ax>
std::vector<unsigned char> encrypt(_In_ HCRYPTPROV hProv, _In_ const std::basic_string<wchar_t, _Traits, _Ax> &val, _Out_opt_ HCRYPTHASH hHash = NULL) const std::vector<unsigned char> encrypt(_In_ HCRYPTPROV hProv, _In_ const std::basic_string<wchar_t, _Traits, _Ax> &val, _In_opt_ HCRYPTHASH hHash = NULL) const
{ {
winstd::sanitizing_string val_utf8; winstd::sanitizing_string val_utf8;
WideCharToMultiByte(CP_UTF8, 0, val, val_utf8, NULL, NULL); WideCharToMultiByte(CP_UTF8, 0, val, val_utf8, NULL, NULL);
@ -380,13 +409,15 @@ namespace eap
/// \returns Decrypted data /// \returns Decrypted data
/// ///
template<class _Ty, class _Ax> template<class _Ty, class _Ax>
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. // Import the private RSA key.
HRSRC res = FindResource(m_instance, MAKEINTRESOURCE(IDR_EAP_KEY_PRIVATE), RT_RCDATA); 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); 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; winstd::crypt_key key_rsa;
std::unique_ptr<unsigned char[], winstd::LocalFree_delete<unsigned char[]> > keyinfo_data; std::unique_ptr<unsigned char[], winstd::LocalFree_delete<unsigned char[]> > keyinfo_data;
DWORD keyinfo_size = 0; DWORD keyinfo_size = 0;
@ -423,7 +454,7 @@ namespace eap
/// \returns Decrypted string /// \returns Decrypted string
/// ///
template<class _Elem, class _Traits, class _Ax> template<class _Elem, class _Traits, class _Ax>
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))); 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()); return std::basic_string<_Elem, _Traits, _Ax>(buf.data(), buf.size());
@ -441,7 +472,7 @@ namespace eap
/// \returns Decrypted string /// \returns Decrypted string
/// ///
template<class _Traits, class _Ax> template<class _Traits, class _Ax>
std::basic_string<wchar_t, _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<wchar_t, _Traits, _Ax> 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))); winstd::sanitizing_string buf(std::move(decrypt_str(hProv, data, size, hHash)));
std::basic_string<wchar_t, _Traits, _Ax> dec; std::basic_string<wchar_t, _Traits, _Ax> dec;
@ -871,7 +902,7 @@ namespace eap
_In_count_(dwUIContextDataSize) const BYTE *pUIContextData, _In_count_(dwUIContextDataSize) const BYTE *pUIContextData,
_In_ const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData, _In_ const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData,
_Out_ DWORD *pdwDataFromInteractiveUISize, _Out_ DWORD *pdwDataFromInteractiveUISize,
_Out_ BYTE **ppDataFromInteractiveUI) const; _Outptr_result_buffer_(*pdwDataFromInteractiveUISize) BYTE **ppDataFromInteractiveUI) const;
/// \name Session management /// \name Session management
/// @{ /// @{
@ -943,7 +974,7 @@ namespace eap
/// ///
virtual void get_response_packet( virtual void get_response_packet(
_In_ EAP_SESSION_HANDLE hSession, _In_ EAP_SESSION_HANDLE hSession,
_Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket, _Out_bytecapcount_(*pdwSendPacketSize) EapPacket *pSendPacket,
_Inout_ DWORD *pdwSendPacketSize) = 0; _Inout_ DWORD *pdwSendPacketSize) = 0;
/// @} /// @}
@ -955,12 +986,12 @@ namespace eap
/// ///
/// \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 ] 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[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[inout] pResult A pointer to a structure that contains the authentication results.
/// ///
virtual void get_result( virtual void get_result(
_In_ EAP_SESSION_HANDLE hSession, _In_ EAP_SESSION_HANDLE hSession,
_In_ EapPeerMethodResultReason reason, _In_ EapPeerMethodResultReason reason,
_Out_ EapPeerMethodResult *pResult) = 0; _Inout_ EapPeerMethodResult *pResult) = 0;
/// \name User Interaction /// \name User Interaction
/// @{ /// @{

View File

@ -66,7 +66,7 @@ namespace eap
/// ///
/// \param[in] other Credentials to move from /// \param[in] other Credentials to move from
/// ///
ui_context(_Inout_ ui_context &&other); ui_context(_Inout_ ui_context &&other) noexcept;
/// ///
/// Copies context /// Copies context
@ -84,7 +84,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
ui_context& operator=(_Inout_ ui_context &&other); ui_context& operator=(_Inout_ ui_context &&other) noexcept;
/// \name BLOB management /// \name BLOB management
/// @{ /// @{

View File

@ -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) 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) if (this != &other)
assert(&m_module == &other.m_module); 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_level (std::move(other.m_level )),
m_allow_save (std::move(other.m_allow_save )), m_allow_save (std::move(other.m_allow_save )),
m_last_status(std::move(other.m_last_status)), 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) { if (this != &other) {
assert(m_level == other.m_level); // Allow move within same configuration level only. 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_use_cred (std::move(other.m_use_cred)),
m_cred (std::move(other.m_cred )), m_cred (std::move(other.m_cred )),
config_method(std::move(other )) 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) { if (this != &other) {
(config_method&)*this = std::move(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_namespace (std::move(other.m_namespace )),
m_id (std::move(other.m_id )), m_id (std::move(other.m_id )),
m_read_only (std::move(other.m_read_only )), 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) { if (this != &other) {
(config&&)*this = std::move(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)), m_providers(std::move(other.m_providers)),
config (std::move(other )) 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) { if (this != &other) {
(config&&)*this = std::move(other ); (config&&)*this = std::move(other );

View File

@ -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)), m_identity(std::move(other.m_identity)),
config(std::move(other)) 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) { if (this != &other) {
(config&)*this = std::move(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) if (this != &other)
(credentials&)*this = std::move(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( eap::credentials::source_t eap::credentials_identity::combine(
_In_ DWORD dwFlags, _In_ DWORD dwFlags,
_In_ HANDLE hTokenImpersonateUser, _In_opt_ HANDLE hTokenImpersonateUser,
_In_opt_ const credentials *cred_cached, _In_opt_ const credentials *cred_cached,
_In_ const config_method &cfg, _In_ const config_method &cfg,
_In_opt_z_ LPCTSTR pszTargetName) _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_password (std::move(other.m_password)),
m_enc_alg (std::move(other.m_enc_alg )), m_enc_alg (std::move(other.m_enc_alg )),
credentials(std::move(other )) 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) { if (this != &other) {
(credentials&)*this = std::move(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( eap::credentials::source_t eap::credentials_pass::combine(
_In_ DWORD dwFlags, _In_ DWORD dwFlags,
_In_ HANDLE hTokenImpersonateUser, _In_opt_ HANDLE hTokenImpersonateUser,
_In_opt_ const credentials *cred_cached, _In_opt_ const credentials *cred_cached,
_In_ const config_method &cfg, _In_ const config_method &cfg,
_In_opt_z_ LPCTSTR pszTargetName) _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_cfg ( other.m_cfg ),
m_namespace(std::move(other.m_namespace)), m_namespace(std::move(other.m_namespace)),
m_id (std::move(other.m_id )), 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) { if (this != &other) {
(config&)*this = std::move(other ); (config&)*this = std::move(other );
@ -948,7 +948,7 @@ template<class _Elem, class _Traits, class _Ax>
inline static basic_string<_Elem, _Traits, _Ax> kph_encrypt(_In_ HCRYPTPROV hProv, _In_z_ const char *src) inline static basic_string<_Elem, _Traits, _Ax> kph_encrypt(_In_ HCRYPTPROV hProv, _In_z_ const char *src)
{ {
basic_string<_Elem, _Traits, _Ax> str; basic_string<_Elem, _Traits, _Ax> str;
unsigned short key[8]; unsigned short key[8] = { 0 };
// Generate the key. // Generate the key.
if (!CryptGenRandom(hProv, sizeof(key), (BYTE*)key)) if (!CryptGenRandom(hProv, sizeof(key), (BYTE*)key))

View File

@ -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) 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)) { if (this != std::addressof(other)) {
assert(std::addressof(m_module) == std::addressof(other.m_module)); // Move method within same module only! 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); 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)), m_inner(std::move(other.m_inner)),
method (std::move(other )) 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)) { if (this != std::addressof(other)) {
(method&)*this = std::move(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); assert(m_inner);
m_inner->get_response_attributes(pAttribs); 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_eap_method (std::move(other.m_eap_method)),
m_id (std::move(other.m_id )), m_id (std::move(other.m_id )),
m_send_nak (std::move(other.m_send_nak )), 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)) { if (this != std::addressof(other)) {
assert(m_eap_method == other.m_eap_method); // Move method within same EAP method type only! 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). // Inner method can generate packets of up to 64kB (less the EAP packet header).
// Initialize inner method with appropriately less packet size maximum. // Initialize inner method with appropriately less packet size maximum.
if (dwMaxSendPacketSize < sizeof(EapPacket)) 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); assert(m_inner);
m_inner->begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, std::min<DWORD>(dwMaxSendPacketSize, MAXWORD) - sizeof(EapPacket)); m_inner->begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, std::min<DWORD>(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. // Check packet size. We will suggest one EAP method alone, so we need one byte for data.
size_t size_packet = sizeof(EapPacket) + 1; size_t size_packet = sizeof(EapPacket) + 1;
if (size_packet > size_max) 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. 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. // Data of Legacy Nak packet is a list of supported EAP types: our method alone.

View File

@ -28,7 +28,7 @@ using namespace winstd;
// eap::module // 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_eap_method(eap_method),
m_instance(NULL) 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); BYTE *p = (BYTE*)HeapAlloc(m_heap, 0, size);
if (!p) 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; return p;
} }
void eap::module::free_memory(_In_ BYTE *ptr) void eap::module::free_memory(_In_ BYTE *ptr) const
{ {
#if !EAP_ENCRYPT_BLOBS #if !EAP_ENCRYPT_BLOBS
// Since we do security here and some of the BLOBs contain credentials, sanitize every memory block before freeing. // 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. // pRootCauseString and pRepairString always trail the ppEapError to reduce number of (de)allocations.
HeapFree(m_heap, 0, err); HeapFree(m_heap, 0, err);
@ -193,7 +193,7 @@ eap::config_method* eap::module::make_config_method()
} }
std::vector<unsigned char> eap::module::encrypt(_In_ HCRYPTPROV hProv, _In_bytecount_(size) const void *data, _In_ size_t size, _Out_opt_ HCRYPTHASH hHash) const std::vector<unsigned char> 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. // Generate 256-bit AES session key.
crypt_key key_aes; crypt_key key_aes;
@ -202,9 +202,11 @@ std::vector<unsigned char> eap::module::encrypt(_In_ HCRYPTPROV hProv, _In_bytec
// Import the public RSA key. // Import the public RSA key.
HRSRC res = FindResource(m_instance, MAKEINTRESOURCE(IDR_EAP_KEY_PUBLIC), RT_RCDATA); 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); 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; crypt_key key_rsa;
unique_ptr<CERT_PUBLIC_KEY_INFO, LocalFree_delete<CERT_PUBLIC_KEY_INFO> > keyinfo_data; unique_ptr<CERT_PUBLIC_KEY_INFO, LocalFree_delete<CERT_PUBLIC_KEY_INFO> > keyinfo_data;
DWORD keyinfo_size = 0; DWORD keyinfo_size = 0;
@ -327,7 +329,7 @@ void eap::peer::query_ui_blob_from_interactive_ui_input_fields(
_In_count_(dwUIContextDataSize) const BYTE *pUIContextData, _In_count_(dwUIContextDataSize) const BYTE *pUIContextData,
_In_ const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData, _In_ const EAP_INTERACTIVE_UI_DATA *pEapInteractiveUIData,
_Out_ DWORD *pdwDataFromInteractiveUISize, _Out_ DWORD *pdwDataFromInteractiveUISize,
_Out_ BYTE **ppDataFromInteractiveUI) const _Outptr_result_buffer_(*pdwDataFromInteractiveUISize) BYTE **ppDataFromInteractiveUI) const
{ {
UNREFERENCED_PARAMETER(dwVersion); UNREFERENCED_PARAMETER(dwVersion);
UNREFERENCED_PARAMETER(dwFlags); UNREFERENCED_PARAMETER(dwFlags);

View File

@ -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_cfg ( other.m_cfg ),
m_cred ( other.m_cred ), m_cred ( other.m_cred ),
packable(std::move(other )) 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) { if (this != &other) {
assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move context within same configuration only! assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move context within same configuration only!

View File

@ -108,8 +108,10 @@ inline void wxInitializeConfig();
#pragma once #pragma once
#include <wx/msw/winundef.h> // Fixes `CreateDialog` name collision #pragma warning(push)
#pragma warning(disable: 26444)
#include "../res/wxEAP_UI.h" #include "../res/wxEAP_UI.h"
#pragma warning(pop)
#include "../../EAPBase/include/Config.h" #include "../../EAPBase/include/Config.h"
#include "../../EAPBase/include/Credentials.h" #include "../../EAPBase/include/Credentials.h"
@ -126,6 +128,10 @@ inline void wxInitializeConfig();
#include <list> #include <list>
#include <memory> #include <memory>
#pragma warning(push)
#pragma warning(disable: 26444)
/// \addtogroup EAPBaseGUI /// \addtogroup EAPBaseGUI
/// @{ /// @{
@ -195,7 +201,7 @@ public:
m_providers), m_providers),
is_single ? is_single ?
wxEAPGetProviderName(provider->m_name) : wxEAPGetProviderName(provider->m_name) :
winstd::tstring_printf(_T("%s (%u)"), static_cast<LPCTSTR>(wxEAPGetProviderName(provider->m_name)), count)); winstd::tstring_printf(_T("%s (%zu)"), static_cast<LPCTSTR>(wxEAPGetProviderName(provider->m_name)), count));
} }
} }
@ -248,7 +254,11 @@ protected:
// Create provider. // Create provider.
eap::config_provider cfg_provider(m_cfg.m_module); eap::config_provider cfg_provider(m_cfg.m_module);
GUID guid; 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_namespace = L"urn:uuid";
cfg_provider.m_id = winstd::wstring_guid(guid).substr(1, 36); cfg_provider.m_id = winstd::wstring_guid(guid).substr(1, 36);
cfg_provider.m_methods.push_back(std::move(cfg_method)); 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_provider &cfg_provider2 = m_cfg.m_providers.back();
eap::config_method *cfg_method2 = cfg_provider2.m_methods.front().get(); eap::config_method *cfg_method2 = cfg_provider2.m_methods.front().get();
_wxT *page = new _wxT(cfg_provider2, *cfg_method2, m_providers); _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->Layout();
this->GetSizer()->Fit(this); 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))); wxConfigBase *cfgPrev = wxConfigBase::Set(new wxConfig(wxT(PRODUCT_NAME_STR), wxT(VENDOR_NAME_STR)));
if (cfgPrev) wxDELETE(cfgPrev); if (cfgPrev) wxDELETE(cfgPrev);
} }
#pragma warning(pop)

View File

@ -65,7 +65,7 @@ namespace eap
/// ///
/// \param[in] other Configuration to move from /// \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 /// Copies configuration
@ -83,7 +83,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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; virtual config* clone() const;

View File

@ -67,7 +67,7 @@ namespace eap
/// ///
/// \param[in] other Credentials to move from /// \param[in] other Credentials to move from
/// ///
credentials_eaphost(_Inout_ credentials_eaphost &&other); credentials_eaphost(_Inout_ credentials_eaphost &&other) noexcept;
/// ///
/// Copies credentials /// Copies credentials
@ -85,7 +85,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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 config* clone() const;
virtual void clear(); virtual void clear();
@ -136,7 +136,7 @@ namespace eap
/// ///
virtual source_t combine( virtual source_t combine(
_In_ DWORD dwFlags, _In_ DWORD dwFlags,
_In_ HANDLE hTokenImpersonateUser, _In_opt_ HANDLE hTokenImpersonateUser,
_In_opt_ const credentials *cred_cached, _In_opt_ const credentials *cred_cached,
_In_ const config_method &cfg, _In_ const config_method &cfg,
_In_opt_z_ LPCTSTR pszTargetName); _In_opt_z_ LPCTSTR pszTargetName);

View File

@ -61,7 +61,7 @@ namespace eap
/// ///
/// \param[in] other EAP method to move from /// \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 /// Moves an EAP method
@ -70,7 +70,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
method_eaphost& operator=(_Inout_ method_eaphost &&other); method_eaphost& operator=(_Inout_ method_eaphost &&other) noexcept;
/// \name Session management /// \name Session management
/// @{ /// @{
@ -100,7 +100,7 @@ namespace eap
virtual void get_result( virtual void get_result(
_In_ EapPeerMethodResultReason reason, _In_ EapPeerMethodResultReason reason,
_Out_ EapPeerMethodResult *pResult); _Inout_ EapPeerMethodResult *pResult);
/// \name User Interaction /// \name User Interaction
/// @{ /// @{

View File

@ -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 (std::move(other.m_type )),
m_type_str (std::move(other.m_type_str)), m_type_str (std::move(other.m_type_str)),
m_cfg_blob (std::move(other.m_cfg_blob)), 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) { if (this != &other) {
(config_method&&)*this = std::move(other ); (config_method&&)*this = std::move(other );

View File

@ -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)), m_cred_blob(std::move(other.m_cred_blob)),
credentials(std::move(other )) 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) { if (this != &other) {
(credentials&)*this = std::move(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( eap::credentials::source_t eap::credentials_eaphost::combine(
_In_ DWORD dwFlags, _In_ DWORD dwFlags,
_In_ HANDLE hTokenImpersonateUser, _In_opt_ HANDLE hTokenImpersonateUser,
_In_opt_ const credentials *cred_cached, _In_opt_ const credentials *cred_cached,
_In_ const config_method &cfg, _In_ const config_method &cfg,
_In_opt_z_ LPCTSTR pszTargetName) _In_opt_z_ LPCTSTR pszTargetName)

View File

@ -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_cfg ( other.m_cfg ),
m_cred ( other.m_cred ), m_cred ( other.m_cred ),
m_session_id(std::move(other.m_session_id)), 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)) { if (this != std::addressof(other)) {
assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move method within same configuration only! 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. // Get response attributes from EapHost peer.
eap_error_runtime error; eap_error_runtime error;

View File

@ -74,7 +74,7 @@ namespace eap
/// ///
/// \param[in] other Configuration to move from /// \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 /// Copies configuration
@ -92,7 +92,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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; virtual config* clone() const;

View File

@ -57,7 +57,7 @@ namespace eap
/// ///
/// \param[in] other GTC method to move from /// \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 /// Moves a GTC method
@ -66,7 +66,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
method_gtc& operator=(_Inout_ method_gtc &&other); method_gtc& operator=(_Inout_ method_gtc &&other) noexcept;
/// \name Session management /// \name Session management
/// @{ /// @{
@ -94,7 +94,7 @@ namespace eap
virtual void get_result( virtual void get_result(
_In_ EapPeerMethodResultReason reason, _In_ EapPeerMethodResultReason reason,
_Out_ EapPeerMethodResult *pResult); _Inout_ EapPeerMethodResult *pResult);
/// \name User Interaction /// \name User Interaction
/// @{ /// @{

View File

@ -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)) 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) if (this != &other)
(config_method_with_cred&&)*this = std::move(other); (config_method_with_cred&&)*this = std::move(other);

View File

@ -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_cfg ( other.m_cfg ),
m_cred ( other.m_cred ), m_cred ( other.m_cred ),
m_challenge(std::move(other.m_challenge)), 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)) { if (this != std::addressof(other)) {
assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move method within same configuration only! 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); WideCharToMultiByte(CP_UTF8, 0, m_response, response_utf8, NULL, NULL);
if (sizeof(sanitizing_string::value_type)*response_utf8.length() > size_max) 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()); packet.assign(response_utf8.begin(), response_utf8.end());
} }

View File

@ -56,6 +56,9 @@ typedef wxEAPCredentialsConfigPanel<eap::credentials_pass, wxGTCPasswordCredenti
#include <Windows.h> #include <Windows.h>
#pragma warning(push)
#pragma warning(disable: 26444)
/// \addtogroup EAPBaseGUI /// \addtogroup EAPBaseGUI
/// @{ /// @{
@ -138,3 +141,5 @@ protected:
}; };
/// @} /// @}
#pragma warning(pop)

View File

@ -66,7 +66,7 @@ namespace eap
/// ///
/// \param[in] other Configuration to move from /// \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 /// Copies configuration
@ -84,7 +84,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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; virtual config* clone() const;
@ -134,7 +134,7 @@ namespace eap
/// ///
/// \param[in] other Configuration to move from /// \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 /// Copies configuration
@ -152,7 +152,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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; virtual config* clone() const;

View File

@ -62,7 +62,7 @@ namespace eap
/// ///
/// \param[in] other MSCHAPv2 method to move from /// \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 /// Moves a MSCHAPv2 method
@ -71,7 +71,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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 /// \name Session management
/// @{ /// @{
@ -95,7 +95,7 @@ namespace eap
virtual void get_result( virtual void get_result(
_In_ EapPeerMethodResultReason reason, _In_ EapPeerMethodResultReason reason,
_Out_ EapPeerMethodResult *pResult); _Inout_ EapPeerMethodResult *pResult);
protected: protected:
/// ///
@ -162,7 +162,7 @@ namespace eap
/// ///
/// \param[in] other MSCHAPv2 method to move from /// \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 /// Moves a MSCHAPv2 method
@ -171,7 +171,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
method_mschapv2& operator=(_Inout_ method_mschapv2 &&other); method_mschapv2& operator=(_Inout_ method_mschapv2 &&other) noexcept;
/// \name Packet processing /// \name Packet processing
/// @{ /// @{
@ -208,7 +208,7 @@ namespace eap
/// ///
/// \param[in] other MSCHAPv2 method to move from /// \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 /// Moves a MSCHAPv2 method
@ -217,7 +217,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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 /// \name Session management
/// @{ /// @{

View File

@ -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)) 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) if (this != &other)
(config_method_with_cred&&)*this = std::move(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)) 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) if (this != &other)
(config_method_mschapv2&&)*this = std::move(other); (config_method_mschapv2&&)*this = std::move(other);

View File

@ -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_cfg ( other.m_cfg ),
m_cred ( other.m_cred ), m_cred ( other.m_cred ),
m_cp (std::move(other.m_cp )), 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)) { if (this != std::addressof(other)) {
assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move method within same configuration only! 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) _In_opt_ DWORD size_max)
{ {
if (m_packet_res.size() > 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()); 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 )) 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)) if (this != std::addressof(other))
(method_mschapv2_base&)*this = std::move(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)), m_phase (std::move(other.m_phase)),
method_mschapv2_base(std::move(other )) 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)) { if (this != std::addressof(other)) {
(method_mschapv2_base&)*this = std::move(other ); (method_mschapv2_base&)*this = std::move(other );

View File

@ -65,7 +65,7 @@ namespace eap
/// ///
/// \param[in] other Configuration to move from /// \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 /// Copies configuration
@ -83,7 +83,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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; virtual config* clone() const;

View File

@ -58,7 +58,7 @@ namespace eap
/// ///
/// \param[in] other PAP method to move from /// \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 /// Moves a PAP method
@ -67,7 +67,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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 /// \name Session management
/// @{ /// @{
@ -95,7 +95,7 @@ namespace eap
virtual void get_result( virtual void get_result(
_In_ EapPeerMethodResultReason reason, _In_ EapPeerMethodResultReason reason,
_Out_ EapPeerMethodResult *pResult); _Inout_ EapPeerMethodResult *pResult);
protected: protected:
config_method_pap &m_cfg; ///< Method configuration config_method_pap &m_cfg; ///< Method configuration

View File

@ -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)) 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) if (this != &other)
(config_method_with_cred&&)*this = std::move(other); (config_method_with_cred&&)*this = std::move(other);

View File

@ -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_cfg ( other.m_cfg ),
m_cred ( other.m_cred ), m_cred ( other.m_cred ),
m_phase (std::move(other.m_phase )), 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)) { if (this != std::addressof(other)) {
assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move method within same configuration only! 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) _In_opt_ DWORD size_max)
{ {
if (m_packet_res.size() > 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()); packet.assign(m_packet_res.begin(), m_packet_res.end());
} }

View File

@ -89,7 +89,7 @@ namespace eap
/// ///
/// \param[in] other Configuration to move from /// \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 /// Copies configuration
@ -107,7 +107,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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; virtual config* clone() const;

View File

@ -67,7 +67,7 @@ namespace eap
/// ///
/// \param[in] other Credentials to move from /// \param[in] other Credentials to move from
/// ///
credentials_tls(_Inout_ credentials_tls &&other); credentials_tls(_Inout_ credentials_tls &&other) noexcept;
/// ///
/// Copies credentials /// Copies credentials
@ -85,7 +85,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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 config* clone() const;
virtual void clear(); virtual void clear();
@ -138,7 +138,7 @@ namespace eap
/// ///
virtual source_t combine( virtual source_t combine(
_In_ DWORD dwFlags, _In_ DWORD dwFlags,
_In_ HANDLE hTokenImpersonateUser, _In_opt_ HANDLE hTokenImpersonateUser,
_In_opt_ const credentials *cred_cached, _In_opt_ const credentials *cred_cached,
_In_ const config_method &cfg, _In_ const config_method &cfg,
_In_opt_z_ LPCTSTR pszTargetName); _In_opt_z_ LPCTSTR pszTargetName);

View File

@ -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_trusted_root_ca(std::move(other.m_trusted_root_ca)),
m_server_names(std::move(other.m_server_names)), m_server_names(std::move(other.m_server_names)),
config_method_with_cred(std::move(other)) 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) { if (this != &other) {
(config_method_with_cred&&)*this = std::move(other); (config_method_with_cred&&)*this = std::move(other);

View File

@ -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)), m_cert(std::move(other.m_cert)),
credentials(std::move(other)) 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) { if (this != &other) {
(credentials&)*this = std::move(other); (credentials&)*this = std::move(other);
@ -260,7 +260,7 @@ std::wstring eap::credentials_tls::get_identity() const
unique_ptr<CERT_ALT_NAME_INFO, LocalFree_delete<CERT_ALT_NAME_INFO> > san_info; unique_ptr<CERT_ALT_NAME_INFO, LocalFree_delete<CERT_ALT_NAME_INFO> > san_info;
if (strcmp(m_cert->pCertInfo->rgExtension[idx_ext].pszObjId, szOID_SUBJECT_ALT_NAME2) == 0) { if (strcmp(m_cert->pCertInfo->rgExtension[idx_ext].pszObjId, szOID_SUBJECT_ALT_NAME2) == 0) {
unsigned char *output = NULL; unsigned char *output = NULL;
DWORD size_output; DWORD size_output = 0;
if (!CryptDecodeObjectEx( if (!CryptDecodeObjectEx(
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
szOID_SUBJECT_ALT_NAME2, szOID_SUBJECT_ALT_NAME2,
@ -272,7 +272,7 @@ std::wstring eap::credentials_tls::get_identity() const
san_info.reset((CERT_ALT_NAME_INFO*)output); san_info.reset((CERT_ALT_NAME_INFO*)output);
} else if (strcmp(m_cert->pCertInfo->rgExtension[idx_ext].pszObjId, szOID_SUBJECT_ALT_NAME) == 0) { } else if (strcmp(m_cert->pCertInfo->rgExtension[idx_ext].pszObjId, szOID_SUBJECT_ALT_NAME) == 0) {
unsigned char *output = NULL; unsigned char *output = NULL;
DWORD size_output; DWORD size_output = 0;
if (!CryptDecodeObjectEx( if (!CryptDecodeObjectEx(
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
szOID_SUBJECT_ALT_NAME, szOID_SUBJECT_ALT_NAME,
@ -300,7 +300,7 @@ std::wstring eap::credentials_tls::get_identity() const
eap::credentials::source_t eap::credentials_tls::combine( eap::credentials::source_t eap::credentials_tls::combine(
_In_ DWORD dwFlags, _In_ DWORD dwFlags,
_In_ HANDLE hTokenImpersonateUser, _In_opt_ HANDLE hTokenImpersonateUser,
_In_opt_ const credentials *cred_cached, _In_opt_ const credentials *cred_cached,
_In_ const config_method &cfg, _In_ const config_method &cfg,
_In_opt_z_ LPCTSTR pszTargetName) _In_opt_z_ LPCTSTR pszTargetName)

View File

@ -225,8 +225,10 @@ void wxTLSServerTrustPanel::OnRootCADClick(wxCommandEvent& event)
wxTLSServerTrustPanelBase::OnRootCADClick(event); wxTLSServerTrustPanelBase::OnRootCADClick(event);
wxCertificateClientData *cert = dynamic_cast<wxCertificateClientData*>(event.GetClientObject()); wxCertificateClientData *cert = dynamic_cast<wxCertificateClientData*>(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); 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; winstd::cert_store store;
if (store.create(NULL, _T("ROOT"))) { if (store.create(NULL, _T("ROOT"))) {
winstd::cert_context cert; 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)); cert.attach(CryptUIDlgSelectCertificateFromStore(store, this->GetHWND(), NULL, NULL, 0, 0, NULL));
if (cert) if (cert)
AddRootCA(cert); AddRootCA(cert);

View File

@ -69,7 +69,7 @@ namespace eap
/// ///
/// \param[in] other Configuration to move from /// \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 /// Copies configuration
@ -87,7 +87,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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; virtual config* clone() const;

View File

@ -62,7 +62,7 @@ namespace eap
/// ///
/// \param[in] other Credentials to move from /// \param[in] other Credentials to move from
/// ///
credentials_ttls(_Inout_ credentials_ttls &&other); credentials_ttls(_Inout_ credentials_ttls &&other) noexcept;
/// ///
/// Copies credentials /// Copies credentials
@ -80,7 +80,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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 config* clone() const;
virtual void clear(); virtual void clear();
@ -127,7 +127,7 @@ namespace eap
/// ///
virtual source_t combine( virtual source_t combine(
_In_ DWORD dwFlags, _In_ DWORD dwFlags,
_In_ HANDLE hTokenImpersonateUser, _In_opt_ HANDLE hTokenImpersonateUser,
_In_opt_ const credentials *cred_cached, _In_opt_ const credentials *cred_cached,
_In_ const config_method &cfg, _In_ const config_method &cfg,
_In_opt_z_ LPCTSTR pszTargetName); _In_opt_z_ LPCTSTR pszTargetName);

View File

@ -93,7 +93,7 @@ namespace eap
/// ///
/// \param[in] other Method to move from /// \param[in] other Method to move from
/// ///
method_defrag(_Inout_ method_defrag &&other); method_defrag(_Inout_ method_defrag &&other) noexcept;
/// ///
/// Moves a method /// Moves a method
@ -102,7 +102,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
method_defrag& operator=(_Inout_ method_defrag &&other); method_defrag& operator=(_Inout_ method_defrag &&other) noexcept;
/// \name Session management /// \name Session management
/// @{ /// @{
@ -129,7 +129,6 @@ namespace eap
/// @} /// @}
protected: protected:
DWORD m_size_frag_max; ///< Maximum size of a fragment
sanitizing_blob m_data_req; ///< Data in request sanitizing_blob m_data_req; ///< Data in request
sanitizing_blob m_data_res; ///< Data in response sanitizing_blob m_data_res; ///< Data in response
bool m_send_res; ///< Are we sending a response? bool m_send_res; ///< Are we sending a response?
@ -156,7 +155,7 @@ namespace eap
/// ///
/// \param[in] other Method to move from /// \param[in] other Method to move from
/// ///
method_eapmsg(_Inout_ method_eapmsg &&other); method_eapmsg(_Inout_ method_eapmsg &&other) noexcept;
/// ///
/// Moves a method /// Moves a method
@ -165,7 +164,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
method_eapmsg& operator=(_Inout_ method_eapmsg &&other); method_eapmsg& operator=(_Inout_ method_eapmsg &&other) noexcept;
/// \name Session management /// \name Session management
/// @{ /// @{
@ -230,7 +229,7 @@ namespace eap
/// ///
/// \param[in] other TTLS method to move from /// \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 /// Moves a TTLS method
@ -239,7 +238,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \returns Reference to this object
/// ///
method_ttls& operator=(_Inout_ method_ttls &&other); method_ttls& operator=(_Inout_ method_ttls &&other) noexcept;
/// \name Session management /// \name Session management
/// @{ /// @{
@ -267,7 +266,7 @@ namespace eap
virtual void get_result( virtual void get_result(
_In_ EapPeerMethodResultReason reason, _In_ EapPeerMethodResultReason reason,
_Out_ EapPeerMethodResult *pResult); _Inout_ EapPeerMethodResult *pResult);
protected: protected:
#if EAP_TLS < EAP_TLS_SCHANNEL_FULL #if EAP_TLS < EAP_TLS_SCHANNEL_FULL

View File

@ -116,7 +116,7 @@ namespace eap
virtual void get_response_packet( virtual void get_response_packet(
_In_ EAP_SESSION_HANDLE hSession, _In_ EAP_SESSION_HANDLE hSession,
_Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket, _Out_bytecapcount_(*pdwSendPacketSize) EapPacket *pSendPacket,
_Inout_ DWORD *pdwSendPacketSize); _Inout_ DWORD *pdwSendPacketSize);
/// @} /// @}
@ -124,7 +124,7 @@ namespace eap
virtual void get_result( virtual void get_result(
_In_ EAP_SESSION_HANDLE hSession, _In_ EAP_SESSION_HANDLE hSession,
_In_ EapPeerMethodResultReason reason, _In_ EapPeerMethodResultReason reason,
_Out_ EapPeerMethodResult *pResult); _Inout_ EapPeerMethodResult *pResult);
/// \name User Interaction /// \name User Interaction
/// @{ /// @{
@ -167,12 +167,12 @@ namespace eap
/// ///
/// Checks all configured providers and tries to combine credentials. /// 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_ DWORD dwFlags,
_In_ const config_connection &cfg, _In_ const config_connection &cfg,
_In_count_(dwUserDataSize) const BYTE *pUserData, _In_count_(dwUserDataSize) const BYTE *pUserData,
_In_ DWORD dwUserDataSize, _In_ DWORD dwUserDataSize,
_Out_ credentials_connection& cred_out, _Inout_ credentials_connection& cred_out,
_In_ HANDLE hTokenImpersonateUser); _In_ HANDLE hTokenImpersonateUser);
protected: protected:
@ -223,7 +223,7 @@ namespace eap
/// ///
/// \param[in] other Thread to move from /// \param[in] other Thread to move from
/// ///
crl_checker(_Inout_ crl_checker &&other); crl_checker(_Inout_ crl_checker &&other) noexcept;
/// ///
/// Moves a thread /// Moves a thread
@ -232,7 +232,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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 /// Verifies server's certificate if it has been revoked

View File

@ -61,7 +61,7 @@ namespace eap
/// ///
/// \param[in] other Credentials to move from /// \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 /// Copies context
@ -79,7 +79,7 @@ namespace eap
/// ///
/// \returns Reference to this object /// \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 /// \name BLOB management
/// @{ /// @{

View File

@ -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_inner(std::move(other.m_inner)),
m_anonymous_identity(std::move(other.m_anonymous_identity)), m_anonymous_identity(std::move(other.m_anonymous_identity)),
config_method_tls(std::move(other)) 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) { if (this != &other) {
(config_method_tls&&)*this = std::move(other); (config_method_tls&&)*this = std::move(other);

View File

@ -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)), m_inner(std::move(other.m_inner)),
credentials_tls(std::move(other)) 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) { if (this != &other) {
(credentials_tls&)*this = std::move(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( eap::credentials::source_t eap::credentials_ttls::combine(
_In_ DWORD dwFlags, _In_ DWORD dwFlags,
_In_ HANDLE hTokenImpersonateUser, _In_opt_ HANDLE hTokenImpersonateUser,
_In_opt_ const credentials *cred_cached, _In_opt_ const credentials *cred_cached,
_In_ const config_method &cfg, _In_ const config_method &cfg,
_In_opt_z_ LPCTSTR pszTargetName) _In_opt_z_ LPCTSTR pszTargetName)

View File

@ -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_req (std::move(other.m_data_req)),
m_data_res (std::move(other.m_data_res)), m_data_res (std::move(other.m_data_res)),
m_send_res (std::move(other.m_send_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)) { if (this != std::addressof(other)) {
(method_tunnel&)*this = std::move(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_identity (std::move(other.m_identity )),
m_phase (std::move(other.m_phase )), m_phase (std::move(other.m_phase )),
m_packet_res (std::move(other.m_packet_res)), 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)) { if (this != std::addressof(other)) {
(method_tunnel&)*this = std::move(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). // Inner method can generate packets of up to 16MB (less the Diameter AVP header).
// Initialize inner method with appropriately less packet size maximum. // Initialize inner method with appropriately less packet size maximum.
if (dwMaxSendPacketSize < sizeof(diameter_avp_header)) 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); assert(m_inner);
m_inner->begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, std::min<DWORD>(dwMaxSendPacketSize, 0xffffff) - sizeof(diameter_avp_header)); m_inner->begin_session(dwFlags, pAttributeArray, hTokenImpersonateUser, std::min<DWORD>(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); packet.insert(packet.end(), (unsigned int)((4 - size_packet) % 4), 0);
} else { } else {
if (m_packet_res.size() > 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()); 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), m_packet_res_inner(false),
method_tunnel(mod, inner) 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_cfg ( other.m_cfg ),
m_cred ( other.m_cred ), m_cred ( other.m_cred ),
m_user_ctx (std::move(other.m_user_ctx )), 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 )), m_eap_attr (std::move(other.m_eap_attr )),
method_tunnel (std::move(other )) 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)) { if (this != std::addressof(other)) {
assert(std::addressof(m_cfg ) == std::addressof(other.m_cfg )); // Move method within same configuration only! 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)) if (FAILED(status))
throw sec_runtime_error(status, __FUNCTION__ " Error getting Schannel required encryption sizes."); throw sec_runtime_error(status, __FUNCTION__ " Error getting Schannel required encryption sizes.");
if (m_packet_res.size() + sizes.cbHeader + sizes.cbTrailer > size_max) 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<unsigned long>(sizes.cbMaximumMessage, size_max - (unsigned long)(m_packet_res.size() + sizes.cbHeader + sizes.cbTrailer)); sizes.cbMaximumMessage = std::min<unsigned long>(sizes.cbMaximumMessage, size_max - (unsigned long)(m_packet_res.size() + sizes.cbHeader + sizes.cbTrailer));
// Get inner response packet. // 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); method_tunnel::get_response_packet(packet, sizes.cbMaximumMessage);
if (!packet.empty()) { if (!packet.empty()) {
DWORD size_data = (DWORD)packet.size(); 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<const unsigned char*>(buf[0].pvBuffer), reinterpret_cast<const unsigned char*>(buf[0].pvBuffer) + buf[0].cbBuffer + buf[1].cbBuffer + buf[2].cbBuffer); m_packet_res.insert(m_packet_res.end(), reinterpret_cast<const unsigned char*>(buf[0].pvBuffer), reinterpret_cast<const unsigned char*>(buf[0].pvBuffer) + buf[0].cbBuffer + buf[1].cbBuffer + buf[2].cbBuffer);
} }
} else if (m_packet_res.size() > size_max) } 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()); packet.assign(m_packet_res.begin(), m_packet_res.end());
} }
@ -819,7 +823,7 @@ void eap::method_ttls::get_result(
// Prepare EAP result attributes. // Prepare EAP result attributes.
if (pResult->pAttribArray) { 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(); 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. // 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) { for (auto attr = pResult->pAttribArray->pAttribs, attr_end = pResult->pAttribArray->pAttribs + pResult->pAttribArray->dwNumberOfAttributes; attr != attr_end && attr->eaType; ++attr) {

View File

@ -92,6 +92,8 @@ void eap::peer_ttls::get_identity(
_Out_ BOOL *pfInvokeUI, _Out_ BOOL *pfInvokeUI,
_Out_ WCHAR **ppwszIdentity) _Out_ WCHAR **ppwszIdentity)
{ {
assert(ppUserDataOut);
assert(pdwUserDataOutSize);
assert(pfInvokeUI); assert(pfInvokeUI);
assert(ppwszIdentity); assert(ppwszIdentity);
@ -111,7 +113,10 @@ void eap::peer_ttls::get_identity(
if ((dwFlags & EAP_FLAG_MACHINE_AUTH) == 0) { if ((dwFlags & EAP_FLAG_MACHINE_AUTH) == 0) {
// Per-user authentication, request UI. // Per-user authentication, request UI.
log_event(&EAPMETHOD_TRACE_EVT_CRED_INVOKE_UI2, event_data::blank); log_event(&EAPMETHOD_TRACE_EVT_CRED_INVOKE_UI2, event_data::blank);
*ppUserDataOut = NULL;
*pdwUserDataOutSize = 0;
*pfInvokeUI = TRUE; *pfInvokeUI = TRUE;
*ppwszIdentity = NULL;
return; return;
} else { } else {
// Per-machine authentication, cannot use UI. // Per-machine authentication, cannot use UI.
@ -309,7 +314,7 @@ void eap::peer_ttls::process_request_packet(
void eap::peer_ttls::get_response_packet( void eap::peer_ttls::get_response_packet(
_In_ EAP_SESSION_HANDLE hSession, _In_ EAP_SESSION_HANDLE hSession,
_Inout_bytecap_(*dwSendPacketSize) EapPacket *pSendPacket, _Out_bytecapcount_(*pdwSendPacketSize) EapPacket *pSendPacket,
_Inout_ DWORD *pdwSendPacketSize) _Inout_ DWORD *pdwSendPacketSize)
{ {
assert(pdwSendPacketSize); assert(pdwSendPacketSize);
@ -394,7 +399,7 @@ void eap::peer_ttls::set_ui_context(
void eap::peer_ttls::get_response_attributes( void eap::peer_ttls::get_response_attributes(
_In_ EAP_SESSION_HANDLE hSession, _In_ EAP_SESSION_HANDLE hSession,
_Inout_ EapAttributes *pAttribs) _Out_ EapAttributes *pAttribs)
{ {
static_cast<session*>(hSession)->m_method->get_response_attributes(pAttribs); static_cast<session*>(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_ DWORD dwFlags,
_In_ const config_connection &cfg, _In_ const config_connection &cfg,
_In_count_(dwUserDataSize) const BYTE *pUserData, _In_count_(dwUserDataSize) const BYTE *pUserData,
_In_ DWORD dwUserDataSize, _In_ DWORD dwUserDataSize,
_Out_ credentials_connection& cred_out, _Inout_ credentials_connection& cred_out,
_In_ HANDLE hTokenImpersonateUser) _In_ HANDLE hTokenImpersonateUser)
{ {
#if EAP_USE_NATIVE_CREDENTIAL_CACHE #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_module( other.m_module ),
m_thread(std::move(other.m_thread)), m_thread(std::move(other.m_thread)),
m_abort (std::move(other.m_abort )), 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)) { if (this != std::addressof(other)) {
assert(std::addressof(m_module) == std::addressof(other.m_module)); // Move threads within same module only! 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) { switch (status_rev.dwError) {
case CRYPT_E_NO_REVOCATION_CHECK: case CRYPT_E_NO_REVOCATION_CHECK:
// Revocation check could not be performed. // Revocation check could not be performed.
c += status_rev.dwIndex + 1; c += (size_t)status_rev.dwIndex + 1;
if (c == c_end) { if (c == c_end) {
// This "error" is expected for the root CA certificate. // This "error" is expected for the root CA certificate.
} else { } else {
@ -663,7 +668,7 @@ DWORD WINAPI eap::peer_ttls::crl_checker::verify(_In_ crl_checker *obj)
}} }}
// Resume checking the rest of the chain. // Resume checking the rest of the chain.
c += status_rev.dwIndex + 1; c += (size_t)status_rev.dwIndex + 1;
break; break;
case ERROR_SUCCESS: case ERROR_SUCCESS:
@ -674,7 +679,7 @@ DWORD WINAPI eap::peer_ttls::crl_checker::verify(_In_ crl_checker *obj)
default: default:
// Checking one of the certificates in the chain for revocation failed. Resume checking the rest. // 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); 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 { } else {
// Revocation check finished. // Revocation check finished.

View File

@ -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)), m_data (std::move(other.m_data)),
ui_context(std::move(other )) 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) { if (this != &other) {
(ui_context&)*this = std::move(other ); (ui_context&)*this = std::move(other );

View File

@ -323,8 +323,10 @@ void eap::peer_ttls_ui::invoke_identity_ui(
wxLogError("Unsupported authentication mode."); wxLogError("Unsupported authentication mode.");
break; 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); panel->SetRemember(src_inner == eap::credentials::source_storage);
dlg.AddContent(panel); dlg.AddContent(panel);

@ -1 +1 @@
Subproject commit ddf3330545faa2365f43593bbce7445edb8ee519 Subproject commit 03522c004709f2e54eda4b10f0ef8321b682f28c

@ -1 +1 @@
Subproject commit bfa23771d9532a479210d81c75420cd15a0b3c97 Subproject commit 23f8c36900dffeb768d08d26414510b1be74c51c