Compare commits

...

14 Commits

Author SHA1 Message Date
ecf3048b78 Update external URL
Fixes: #2
Reported by: Peder B. Sundt <pbsds@hotmail.com>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-06-30 09:30:56 +02:00
403caa2d36 Update samples
The EAP-TTLS sample was broken and was replaced by a working one.

Reported-by: Tomasz Wolniewicz <twoln@umk.pl>
Signed-off-by: Simon Rozman <simon@rozman.si>
2020-02-26 15:38:48 +01:00
de3744189e Bump WinStd
Signed-off-by: Simon Rozman <simon@rozman.si>
2019-11-28 15:51:43 +01:00
549621dbbd Extend examples section
Signed-off-by: Simon Rozman <simon@rozman.si>
2019-06-17 11:01:21 +02:00
6bcb33af41 Bump WinStd
Signed-off-by: Simon Rozman <simon@rozman.si>
2019-06-14 17:51:19 +02:00
60fe9f4d1a Add /i switch to display error messages
Signed-off-by: Simon Rozman <simon@rozman.si>
2019-06-14 17:44:00 +02:00
e94fa3fa26 Switch to WinStd library
Signed-off-by: Simon Rozman <simon@rozman.si>
2019-06-14 15:41:00 +02:00
f35a0f4bf4 Add README.md to solution file
Signed-off-by: Simon Rozman <simon@rozman.si>
2019-06-14 15:32:53 +02:00
3ed2c48724 Add ARM64 support
Signed-off-by: Simon Rozman <simon@rozman.si>
2019-06-14 15:31:31 +02:00
b0284a70d2 Gather all remaining common settings in property files
+ Change intermediate and output paths

Signed-off-by: Simon Rozman <simon@rozman.si>
2019-06-14 15:27:06 +02:00
af4b898688 Enable code analysis and resolve reported warnings
Signed-off-by: Simon Rozman <simon@rozman.si>
2019-06-14 15:26:49 +02:00
c1ce01ddad Upgrade to Visual Studio 2019
+ Reset all non-vital compiler and linker options to defaults
+ Unify intermediate and output paths

Signed-off-by: Simon Rozman <simon@rozman.si>
2019-06-14 15:25:23 +02:00
873c01d9c4 Preset version to 1.1 and update version year to 2019
Signed-off-by: Simon Rozman <simon@rozman.si>
2019-06-14 13:13:04 +02:00
df336e545f Update documentation 2018-05-09 18:17:00 +02:00
19 changed files with 370 additions and 392 deletions

8
.gitignore vendored
View File

@ -1,7 +1 @@
/*.sdf
/*.suo
/Debug
/ipch
/Release
/x64
/*.opensdf
/.vs

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "lib/WinStd"]
path = lib/WinStd
url = https://github.com/Amebis/WinStd.git

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<EapHostUserCredentials xmlns="http://www.microsoft.com/provisioning/EapHostUserCredentials"
xmlns:eapCommon="http://www.microsoft.com/provisioning/EapCommon"
xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapMethodUserCredentials">
<EapMethod>
<eapCommon:Type>21</eapCommon:Type>
<eapCommon:AuthorId>311</eapCommon:AuthorId>
</EapMethod>
<Credentials xmlns="http://www.microsoft.com/provisioning/EapHostUserCredentials">
<EapTtls xmlns="http://www.microsoft.com/provisioning/EapTtlsUserPropertiesV1">
<Username>user03</Username>
<Password>user_0303</Password>
</EapTtls>
</Credentials>
</EapHostUserCredentials>

View File

@ -1,30 +1,37 @@
# WLANSetEAPUserData
Windows helper utility to set user data for a given WLAN profile
Binary downloads and change-logs can be found on the [project's release page](https://github.com/rozmansi/WLANSetEAPUserData/releases).
##Usage
```
WLANSetEAPUserData <profile> <flags> <user data URI>
```
Parameter | Explanation
----------------|------------
`profile` | The name of the network profile (not neccessarely the same as SSID)
`flags` | Flags to pass to `WlanSetProfileEapXmlUserData()` function call (decimal number: 0=Current User, 1=All Users)
`user data URI` | User data XML URI. Can be a path to an XML file, web URL where user data XML can be loaded from, etc. The XML schema varies according to the configured EAP method provider used by `profile`. For example: Microsoft's EAP-TLS requires the schema described in [EAP-TLS User Properties](https://msdn.microsoft.com/en-us/library/windows/desktop/bb204662.aspx).
##Return codes
Value | Meaning
------|--------
0 | Success (on at least one WLAN interface)
100 | CommandLineToArgvW() failed
101 | Not enough arguments
200 | CoInitialize() failed
300 | CoCreateInstance(CLSID_DOMDocument2) failed
301 | IXMLDOMDocument::load() failed
302 | IXMLDOMDocument::load() reported an error in the XML document
304 | IXMLDOMDocument::get_xml() failed
400 | WlanOpenHandle() failed
401 | WlanEnumInterfaces() failed
402 | WlanSetProfileEapXmlUserData() failed on all WLAN interfaces for the given profile
403 | No ready WLAN interfaces found
## Usage
```
WLANSetEAPUserData <profile> <flags> <user data URI> [/i]
```
| Parameter | Explanation |
| --------------- | ----------- |
| `profile` | The name of the network profile (typically same as SSID) |
| `flags` | Flags to pass to `WlanSetProfileEapXmlUserData()` function call (decimal number: 0=Current User, 1=All Users) |
| `user data URI` | User data XML URI. Can be a path to an XML file, web URL where user data XML can be loaded from, etc. The XML schema varies according to the configured EAP method provider used by `profile`. For example: Microsoft's EAP-TLS requires the schema described in [EAP-TLS User Properties](https://docs.microsoft.com/en-us/windows/win32/eaphost/eap-tls-user-properties). |
| /i | Interactive: Pop-up a message dialog in case of error |
## Return codes
| Value | Meaning |
| -----:| ------------------------------------------------------------------------------------ |
| 0 | Success (on at least one WLAN interface) |
| 100 | `CommandLineToArgvW()` failed |
| 101 | Not enough arguments |
| 200 | `CoInitialize()` failed |
| 300 | `CoCreateInstance(CLSID_DOMDocument2)` failed |
| 301 | `IXMLDOMDocument::load()` failed |
| 302 | `IXMLDOMDocument::load()` reported an error in the XML document |
| 304 | `IXMLDOMDocument::get_xml()` failed |
| 400 | `WlanOpenHandle()` failed |
| 401 | `WlanEnumInterfaces()` failed |
| 402 | `WlanSetProfileEapXmlUserData()` failed on all WLAN interfaces for the given profile |
| 403 | No ready WLAN interfaces found |

View File

@ -1,26 +1,61 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29009.5
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WLANSetEAPUserData", "WLANSetEAPUserData\WLANSetEAPUserData.vcxproj", "{EC3084A5-CA18-498B-A962-5321AE37789B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{08F04160-9ED5-4351-A4BB-E29162C133D1}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{943F6F19-535F-4DD8-A5BA-5033B4E2EFF5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinStd", "lib\WinStd\build\WinStd-16.0.vcxproj", "{47399D91-7EB9-41DE-B521-514BA5DB0C43}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|ARM64 = Release|ARM64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EC3084A5-CA18-498B-A962-5321AE37789B}.Debug|ARM64.ActiveCfg = Debug|ARM64
{EC3084A5-CA18-498B-A962-5321AE37789B}.Debug|ARM64.Build.0 = Debug|ARM64
{EC3084A5-CA18-498B-A962-5321AE37789B}.Debug|Win32.ActiveCfg = Debug|Win32
{EC3084A5-CA18-498B-A962-5321AE37789B}.Debug|Win32.Build.0 = Debug|Win32
{EC3084A5-CA18-498B-A962-5321AE37789B}.Debug|x64.ActiveCfg = Debug|x64
{EC3084A5-CA18-498B-A962-5321AE37789B}.Debug|x64.Build.0 = Debug|x64
{EC3084A5-CA18-498B-A962-5321AE37789B}.Release|ARM64.ActiveCfg = Release|ARM64
{EC3084A5-CA18-498B-A962-5321AE37789B}.Release|ARM64.Build.0 = Release|ARM64
{EC3084A5-CA18-498B-A962-5321AE37789B}.Release|Win32.ActiveCfg = Release|Win32
{EC3084A5-CA18-498B-A962-5321AE37789B}.Release|Win32.Build.0 = Release|Win32
{EC3084A5-CA18-498B-A962-5321AE37789B}.Release|x64.ActiveCfg = Release|x64
{EC3084A5-CA18-498B-A962-5321AE37789B}.Release|x64.Build.0 = Release|x64
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Debug|ARM64.ActiveCfg = Debug|ARM64
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Debug|ARM64.Build.0 = Debug|ARM64
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Debug|Win32.ActiveCfg = Debug|Win32
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Debug|Win32.Build.0 = Debug|Win32
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Debug|x64.ActiveCfg = Debug|x64
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Debug|x64.Build.0 = Debug|x64
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Release|ARM64.ActiveCfg = Release|ARM64
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Release|ARM64.Build.0 = Release|ARM64
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Release|Win32.ActiveCfg = Release|Win32
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Release|Win32.Build.0 = Release|Win32
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Release|x64.ActiveCfg = Release|x64
{47399D91-7EB9-41DE-B521-514BA5DB0C43}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{47399D91-7EB9-41DE-B521-514BA5DB0C43} = {943F6F19-535F-4DD8-A5BA-5033B4E2EFF5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1B6BEEAC-F963-4C30-A460-9EE887768FC3}
EndGlobalSection
EndGlobal

View File

@ -1,5 +1,3 @@
/*.user
/Debug
/Release
/x64
/*.aps
/temp
/WLANSetEAPUserData.aps

View File

@ -1,5 +1,5 @@
/*
Copyright 2016 Simon Rozman
Copyright 2016-2019 Simon Rozman
This file is part of WLANSetEAPUserData.
@ -17,7 +17,9 @@
along with WLANSetEAPUserData. If not, see <http://www.gnu.org/licenses/>.
*/
#include "WLANSetEAPUserData.h"
#include <WinStd\Com.h>
#include <WinStd\Common.h>
#include <WinStd\WLAN.h>
#include <comip.h>
#include <comutil.h>
#include <msxml6.h>
@ -33,125 +35,142 @@
#pragma comment(lib, "Wlanapi.lib")
using namespace std;
using namespace winstd;
///
/// Main program body
///
int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
)
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hInstance );
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine );
UNREFERENCED_PARAMETER(nCmdShow );
// Get command line arguments. (As Unicode, please.)
int nArgs;
unique_ptr<LPWSTR[], LocalFree_delete<LPWSTR[]> > pwcArglist(CommandLineToArgvW(GetCommandLineW(), &nArgs));
if (!pwcArglist) {
//_ftprintf(stderr, _T("CommandLineToArgvW() failed (error %u).\n"), GetLastError());
return 100;
}
if (nArgs <= 3) {
//_ftprintf(stderr, _T("Not enough arguments.\n"));
return 101;
}
int result = -1;
bool interactive = false;
// Initialize COM.
com_initializer com_init(NULL);
if (FAILED(com_init.status())) {
//_ftprintf(stderr, _T("CoInitialize() failed (error 0x%08x).\n"), com_init.status());
return 200;
}
// Load user data XML into memory.
// Use MSXML6 IXMLDOMDocument to load XML to offload charset detection.
_bstr_t user_data;
{
// Create XML document.
_com_ptr_t<_com_IIID<IXMLDOMDocument, &__uuidof(IXMLDOMDocument)> > doc;
HRESULT hr = doc.CreateInstance(CLSID_DOMDocument60, NULL, CLSCTX_ALL);
if (FAILED(hr)) {
//_ftprintf(stderr, _T("CoCreateInstance(CLSID_DOMDocument2) failed (error 0x%08x).\n"), hr);
return 300;
try {
// Get command line arguments. (As Unicode, please.)
int nArgs;
unique_ptr<LPWSTR[], LocalFree_delete<LPWSTR[]> > pwcArglist(CommandLineToArgvW(GetCommandLineW(), &nArgs));
if (!pwcArglist) {
result = 100;
throw win_runtime_error("CommandLineToArgvW() failed");
}
doc->put_async(VARIANT_FALSE);
doc->put_validateOnParse(VARIANT_FALSE);
// Load XML from user data file.
VARIANT_BOOL succeeded = VARIANT_FALSE;
hr = doc->load(_variant_t(pwcArglist[3]), &succeeded);
if (FAILED(hr)) {
//_ftprintf(stderr, _T("IXMLDOMDocument::load(%ls) failed (error 0x%08x).\n"), pwcArglist[3], hr);
return 301;
} else if (!succeeded) {
//_ftprintf(stderr, _T("IXMLDOMDocument::load(%ls) failed.\n"), pwcArglist[3]);
return 302;
if (nArgs < 4) {
result = 101;
throw invalid_argument("Not enough arguments.");
}
// Get document XML.
BSTR bstr;
hr = doc->get_xml(&bstr);
if (FAILED(hr)) {
//_ftprintf(stderr, _T("IXMLDOMDocument::get_xml() failed (error 0x%08x).\n"), hr);
return 304;
for (int i = 4; i < nArgs; i++)
if (_wcsicmp(pwcArglist[i], L"/I") == 0) interactive = true;
// Initialize COM.
com_initializer com_init(NULL);
if (FAILED(com_init.status())) {
result = 200;
throw com_runtime_error(com_init.status(), "CoInitialize() failed");
}
user_data.Attach(bstr);
// Load user data XML into memory.
// Use MSXML6 IXMLDOMDocument to load XML to offload charset detection.
_bstr_t user_data;
{
// Create XML document.
_com_ptr_t<_com_IIID<IXMLDOMDocument, &__uuidof(IXMLDOMDocument)> > doc;
HRESULT hr = doc.CreateInstance(CLSID_DOMDocument60, NULL, CLSCTX_ALL);
if (FAILED(hr)) {
result = 300;
throw com_runtime_error(hr, "CoCreateInstance(CLSID_DOMDocument2) failed");
}
doc->put_async(VARIANT_FALSE);
doc->put_validateOnParse(VARIANT_FALSE);
// Load XML from user data file.
VARIANT_BOOL succeeded = VARIANT_FALSE;
hr = doc->load(_variant_t(pwcArglist[3]), &succeeded);
if (FAILED(hr)) {
result = 301;
throw com_runtime_error(hr, string_printf("IXMLDOMDocument::load(%ls) failed", pwcArglist[3]));
} else if (!succeeded) {
result = 302;
throw runtime_error(string_printf("IXMLDOMDocument::load(%ls) failed", pwcArglist[3]));
}
// Get document XML.
BSTR bstr;
hr = doc->get_xml(&bstr);
if (FAILED(hr)) {
result = 304;
throw com_runtime_error(hr, "IXMLDOMDocument::get_xml() failed");
}
user_data.Attach(bstr);
}
// Open WLAN handle.
DWORD dwNegotiatedVersion;
wlan_handle wlan;
if (!wlan.open(WLAN_API_MAKE_VERSION(2, 0), &dwNegotiatedVersion)) {
result = 400;
throw win_runtime_error("WlanOpenHandle() failed");
}
// Get a list of WLAN interfaces.
unique_ptr<WLAN_INTERFACE_INFO_LIST, WlanFreeMemory_delete<WLAN_INTERFACE_INFO_LIST> > interfaces;
{
WLAN_INTERFACE_INFO_LIST *pInterfaceList;
DWORD dwResult = WlanEnumInterfaces(wlan, NULL, &pInterfaceList);
if (dwResult != ERROR_SUCCESS) {
result = 401;
throw win_runtime_error(dwResult, "WlanEnumInterfaces() failed");
}
interfaces.reset(pInterfaceList);
}
if (!interfaces->dwNumberOfItems) {
result = 403;
throw runtime_error("No ready WLAN interfaces found");
}
// Iterate over all WLAN interfaces.
bool success = false;
for (DWORD i = 0; i < interfaces->dwNumberOfItems; i++) {
if (interfaces->InterfaceInfo[i].isState == wlan_interface_state_not_ready) {
// This interface is not ready.
continue;
}
// Set user data.
DWORD dwResult = WlanSetProfileEapXmlUserData(
wlan,
&(interfaces->InterfaceInfo[i].InterfaceGuid),
pwcArglist[1],
wcstoul(pwcArglist[2], NULL, 10),
user_data,
NULL);
if (dwResult == ERROR_SUCCESS) {
// At least one interface/profile succeeded.
success = true;
} else if (interactive)
MessageBox(NULL, tstring_printf(_T("WlanSetProfileEapXmlUserData() failed: %s"), win_runtime_error(dwResult).msg().c_str()).c_str(), NULL, MB_ICONWARNING | MB_OK);
}
return success ? 0 : 402;
} catch (com_runtime_error err) {
if (interactive)
MessageBox(NULL, tstring_printf(_T("%hs: 0x%08x"), err.what(), err.number()).c_str(), NULL, MB_ICONERROR | MB_OK);
} catch (win_runtime_error err) {
if (interactive)
MessageBox(NULL, tstring_printf(_T("%hs: %s"), err.what(), err.msg().c_str()).c_str(), NULL, MB_ICONERROR | MB_OK);
} catch (exception err) {
if (interactive)
MessageBoxA(NULL, err.what(), NULL, MB_ICONERROR | MB_OK);
}
// Open WLAN handle.
DWORD dwNegotiatedVersion;
unique_ptr<void, WlanCloseHandle_delete> wlan;
{
HANDLE hWlan;
DWORD dwResult = WlanOpenHandle(WLAN_API_MAKE_VERSION(2, 0), NULL, &dwNegotiatedVersion, &hWlan);
if (dwResult != ERROR_SUCCESS) {
//_ftprintf(stderr, _T("WlanOpenHandle() failed (error %u).\n"), dwResult);
return 400;
}
wlan.reset(hWlan);
}
// Get a list of WLAN interfaces.
unique_ptr<WLAN_INTERFACE_INFO_LIST, WlanFreeMemory_delete<WLAN_INTERFACE_INFO_LIST> > interfaces;
{
WLAN_INTERFACE_INFO_LIST *pInterfaceList;
DWORD dwResult = WlanEnumInterfaces(wlan.get(), NULL, &pInterfaceList);
if (dwResult != ERROR_SUCCESS) {
//_ftprintf(stderr, _T("WlanEnumInterfaces() failed (error %u).\n"), dwResult);
return 401;
}
interfaces.reset(pInterfaceList);
}
// Iterate over all WLAN interfaces.
bool success = false;
for (DWORD i = 0; i < interfaces->dwNumberOfItems; i++) {
if (interfaces->InterfaceInfo[i].isState == wlan_interface_state_not_ready) {
// This interface is not ready.
continue;
}
// Set user data.
DWORD dwResult = WlanSetProfileEapXmlUserData(
wlan.get(),
&(interfaces->InterfaceInfo[i].InterfaceGuid),
pwcArglist[1],
wcstoul(pwcArglist[2], NULL, 10),
user_data,
NULL);
if (dwResult == ERROR_SUCCESS) {
// At least one interface/profile succeeded.
success = true;
} else {
//_ftprintf(stderr, _T("WlanSetProfileEapXmlUserData() failed (error %u).\n"), dwResult);
}
}
return success ? 0 : interfaces->dwNumberOfItems ? 402 : 403;
return result;
}

View File

@ -1,161 +0,0 @@
/*
Copyright 2016 Simon Rozman
This file is part of WLANSetEAPUserData.
WLANSetEAPUserData is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
WLANSetEAPUserData is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with WLANSetEAPUserData. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <Windows.h>
///
/// Deleter for unique_ptr using LocalFree
///
template <class _Ty>
struct LocalFree_delete
{
///
/// Frees memory
///
/// \sa [LocalFree function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa366730.aspx)
///
inline void operator()(_Ty *_Ptr) const
{
LocalFree(_Ptr);
}
};
///
/// Deleter for unique_ptr to array of unknown size using LocalFree
///
template <class _Ty>
struct LocalFree_delete<_Ty[]>
{
///
/// Frees memory
///
inline void operator()(_Ty *_Ptr) const
{
LocalFree(_Ptr);
}
///
/// Frees memory
///
/// \sa [LocalFree function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa366730.aspx)
///
template<class _Other>
inline void operator()(_Other *) const
{
LocalFree(_Ptr);
}
};
#include <ObjBase.h>
///
/// Context scope automatic COM (un)initialization
///
class com_initializer
{
public:
///
/// Initializes the COM library on the current thread and identifies the concurrency model as single-thread apartment (STA).
///
/// \sa [CoInitialize function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms678543.aspx)
///
inline com_initializer(_In_opt_ LPVOID pvReserved)
{
m_result = CoInitialize(pvReserved);
}
///
/// Initializes the COM library for use by the calling thread, sets the thread's concurrency model, and creates a new apartment for the thread if one is required.
///
/// \sa [CoInitializeEx function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms695279.aspx)
///
inline com_initializer(_In_opt_ LPVOID pvReserved, _In_ DWORD dwCoInit)
{
m_result = CoInitializeEx(pvReserved, dwCoInit);
}
///
/// Uninitializes COM.
///
/// \sa [CoUninitialize function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms688715.aspx)
///
virtual ~com_initializer()
{
if (SUCCEEDED(m_result))
CoUninitialize();
}
///
/// Return result of `CoInitialize()` call.
///
/// \sa [CoInitialize function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms678543.aspx)
///
inline HRESULT status() const
{
return m_result;
}
protected:
HRESULT m_result; ///< Result of CoInitialize call
};
#include <wlanapi.h>
///
/// Deleter for unique_ptr using WlanCloseHandle
///
struct WlanCloseHandle_delete
{
///
/// Closes the WLAN handle
///
/// \sa [WlanCloseHandle function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms706610.aspx)
///
inline void operator()(void *_Ptr) const
{
WlanCloseHandle(_Ptr, NULL);
}
};
///
/// Deleter for unique_ptr using WlanFreeMemory
///
template <class _Ty>
struct WlanFreeMemory_delete
{
///
/// Frees memory
///
/// \sa [WlanFreeMemory function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms706722.aspx)
///
void operator()(_Ty *_Ptr) const
{
WlanFreeMemory(_Ptr);
}
};

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<OutDir>..\output\$(Platform).$(Configuration)\</OutDir>
<IncludePath>..\lib\WinStd\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup>
<Link>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View File

@ -1,6 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
@ -9,6 +13,10 @@
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
@ -22,150 +30,130 @@
<ProjectGuid>{EC3084A5-CA18-498B-A962-5321AE37789B}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>WLANSetEAPUserData</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\include\Debug.props" />
<Import Project="WLANSetEAPUserData.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\include\Debug.props" />
<Import Project="WLANSetEAPUserData.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\include\Debug.props" />
<Import Project="WLANSetEAPUserData.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\include\Release.props" />
<Import Project="WLANSetEAPUserData.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\include\Release.props" />
<Import Project="WLANSetEAPUserData.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\include\Release.props" />
<Import Project="WLANSetEAPUserData.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<CodeAnalysisRuleSet>NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<CodeAnalysisRuleSet>NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<CodeAnalysisRuleSet>NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<CodeAnalysisRuleSet>NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<CodeAnalysisRuleSet>NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<SmallerTypeCheck>true</SmallerTypeCheck>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<StringPooling>true</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<SmallerTypeCheck>true</SmallerTypeCheck>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<StringPooling>true</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>Full</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<WholeProgramOptimization>true</WholeProgramOptimization>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<StringPooling>true</StringPooling>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>Full</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<WholeProgramOptimization>true</WholeProgramOptimization>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<StringPooling>true</StringPooling>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<CodeAnalysisRuleSet>NativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" />
<ItemGroup>
<ClCompile Include="WLANSetEAPUserData.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h" />
<ClInclude Include="WLANSetEAPUserData.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="WLANSetEAPUserData.rc" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\lib\WinStd\build\WinStd-16.0.vcxproj">
<Project>{47399d91-7eb9-41de-b521-514ba5db0c43}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Xml Include="..\Examples\Microsoft EAP-TLS Userdata.xml" />
<Xml Include="..\Examples\Microsoft EAP-TTLS Userdata %28inner non-EAP%29.xml" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -13,6 +13,9 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Examples">
<UniqueIdentifier>{fe2655f9-bce6-47e8-84d5-6d78ca6006b6}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="WLANSetEAPUserData.cpp">
@ -20,9 +23,6 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="WLANSetEAPUserData.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -32,4 +32,12 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Xml Include="..\Examples\Microsoft EAP-TLS Userdata.xml">
<Filter>Examples</Filter>
</Xml>
<Xml Include="..\Examples\Microsoft EAP-TTLS Userdata %28inner non-EAP%29.xml">
<Filter>Examples</Filter>
</Xml>
</ItemGroup>
</Project>

16
include/Common.props Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<IntDir>temp\$(MSBuildProjectName).$(Platform).$(Configuration).$(PlatformToolset)\</IntDir>
<OutDir>temp\$(MSBuildProjectName).$(Platform).$(Configuration).$(PlatformToolset)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<EnablePREfast>true</EnablePREfast>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

15
include/Debug.props Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets">
<Import Project="Common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

19
include/Release.props Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets">
<Import Project="Common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

1
lib/WinStd Submodule

@ -0,0 +1 @@
Subproject commit f9e65c8a75d96ecd08e0ca3cc171cade5e756da7

6
output/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
/ARM64.Debug
/ARM64.Release
/Win32.Debug
/Win32.Release
/x64.Debug
/x64.Release