EAPTTLS split to EAP Method itself and UI

This commit is contained in:
Simon Rozman 2016-05-20 01:33:24 +02:00
parent 61fa67a415
commit f5d647e81f
19 changed files with 796 additions and 204 deletions

View File

@ -35,6 +35,7 @@ Property Signature_
s$(MSIBUILD_LENGTH_ID) s$(MSIBUILD_LENGTH_ID)
AppSearch Property Signature_
OLD$(MSIBUILD_PRODUCT_NAME_UC)DIR clEAPTTLS.dll.$(PLAT)
OLD$(MSIBUILD_PRODUCT_NAME_UC)DIR clEAPTTLSUI.dll.$(PLAT)
OLD$(MSIBUILD_PRODUCT_NAME_UC)DIR clEAPMethodEvents.dll.$(PLAT)
<<NOKEEP
@ -58,9 +59,11 @@ clEAPMethodEvents.dll.x64 {594109D7-8FA0-43DF-8CA6-FE1562AAC1C1} 1
!ENDIF
!IF "$(PLAT)" == "Win32"
clEAPTTLS.dll.Win32 {A4A62D2F-DA90-4765-BD8C-D59EA2C01DFE} 1
clEAPTTLSUI.dll.Win32 {1EBA30DA-69D1-4EB5-B353-65F9BD8164EF} 1
!ENDIF
!IF "$(PLAT)" == "x64"
clEAPTTLS.dll.x64 {A1F62401-03F1-4D4E-A1FA-0FD4858D90B6} 1
clEAPTTLSUI.dll.x64 {01C9F45C-9B29-4C1A-9FF2-856F8799C2D0} 1
!ENDIF
<<NOKEEP
@ -85,11 +88,16 @@ compEAPMethodEvents.dll.x64 {594109D7-8FA0-43DF-8CA6-FE1562AAC1C1} $(MSIBUILD_PR
compEAPHostAuthor {086E042A-6741-459D-92F0-F5CCFA4E34D4} $(MSIBUILD_PRODUCT_NAME_UC)BINDIR $(MSIBUILD_COMPONENT_ATTRIB_REGISTRY) regEAPHostAuthor
!IF "$(PLAT)" == "Win32"
compEAPTTLS.dll.Win32 {A4A62D2F-DA90-4765-BD8C-D59EA2C01DFE} $(MSIBUILD_PRODUCT_NAME_UC)BINDIR 0 fileEAPTTLS.dll.Win32
compEAPTTLSUI.dll.Win32 {1EBA30DA-69D1-4EB5-B353-65F9BD8164EF} $(MSIBUILD_PRODUCT_NAME_UC)BINDIR 0 fileEAPTTLSUI.dll.Win32
!ENDIF
!IF "$(PLAT)" == "x64"
compEAPTTLS.dll.x64 {A1F62401-03F1-4D4E-A1FA-0FD4858D90B6} $(MSIBUILD_PRODUCT_NAME_UC)BINDIR 256 fileEAPTTLS.dll.x64
compEAPTTLSUI.dll.x64 {01C9F45C-9B29-4C1A-9FF2-856F8799C2D0} $(MSIBUILD_PRODUCT_NAME_UC)BINDIR 256 fileEAPTTLSUI.dll.x64
!ENDIF
compEAPTTLSPeerDllPath {29FD2FDC-9289-47F0-96A3-C21AEE587B5B} $(MSIBUILD_PRODUCT_NAME_UC)BINDIR $(MSIBUILD_COMPONENT_ATTRIB_REGISTRY) regEAPTTLSPeerDllPath
compEAPTTLSPeerConfigUIPath {2516BB92-0C14-4157-A136-3A713D459D08} $(MSIBUILD_PRODUCT_NAME_UC)BINDIR $(MSIBUILD_COMPONENT_ATTRIB_REGISTRY) regEAPTTLSPeerConfigUIPath
compEAPTTLSPeerIdentityPath {3E1F0068-863C-4CFB-8D95-A66995443D19} $(MSIBUILD_PRODUCT_NAME_UC)BINDIR $(MSIBUILD_COMPONENT_ATTRIB_REGISTRY) regEAPTTLSPeerIdentityPath
compEAPTTLSPeerInteractiveUIPath {256F1256-C085-4EA3-8D7E-FF4BBCCC3C7D} $(MSIBUILD_PRODUCT_NAME_UC)BINDIR $(MSIBUILD_COMPONENT_ATTRIB_REGISTRY) regEAPTTLSPeerInteractiveUIPath
compEAPTTLSPeerFriendlyName {E3250ECE-E59F-4693-B290-925B80929EAE} $(MSIBUILD_PRODUCT_NAME_UC)BINDIR $(MSIBUILD_COMPONENT_ATTRIB_REGISTRY) regEAPTTLSPeerFriendlyName
compEAPTTLSPeerInvokePasswordDialog {9A426E96-6E79-4BA9-83DD-7A205CA43810} $(MSIBUILD_PRODUCT_NAME_UC)BINDIR $(MSIBUILD_COMPONENT_ATTRIB_REGISTRY) regEAPTTLSPeerInvokePasswordDialog
compEAPTTLSPeerInvokeUsernameDialog {92E9B700-3D91-4C6F-BBD8-99888D7A2387} $(MSIBUILD_PRODUCT_NAME_UC)BINDIR $(MSIBUILD_COMPONENT_ATTRIB_REGISTRY) regEAPTTLSPeerInvokeUsernameDialog
@ -130,7 +138,11 @@ FeatureComponents Feature_ Component_
featEAPTTLS compEAPMethodEvents.dll.$(PLAT)
featEAPTTLS compEAPHostAuthor
featEAPTTLS compEAPTTLS.dll.$(PLAT)
featEAPTTLS compEAPTTLSUI.dll.$(PLAT)
featEAPTTLS compEAPTTLSPeerDllPath
featEAPTTLS compEAPTTLSPeerConfigUIPath
featEAPTTLS compEAPTTLSPeerIdentityPath
featEAPTTLS compEAPTTLSPeerInteractiveUIPath
featEAPTTLS compEAPTTLSPeerFriendlyName
featEAPTTLS compEAPTTLSPeerInvokePasswordDialog
featEAPTTLS compEAPTTLSPeerInvokeUsernameDialog
@ -151,6 +163,7 @@ s$(MSIBUILD_LENGTH_ID) s$(MSIBUILD_LENGTH_ID) l255 i4 S$(MSIBUILD_LENGTH_ID) S20
File File
fileEAPMethodEvents.dll.$(PLAT) compEAPMethodEvents.dll.$(PLAT) EAPMET~1.DLL|EAPMethodEvents.dll 0 0 1536 1
fileEAPTTLS.dll.$(PLAT) compEAPTTLS.dll.$(PLAT) EAPTTLS.dll 0 0 1536 1
fileEAPTTLSUI.dll.$(PLAT) compEAPTTLSUI.dll.$(PLAT) EAPTTL~1.DLL|EAPTTLSUI.dll 0 0 1536 1
<<NOKEEP
@ -167,6 +180,9 @@ s$(MSIBUILD_LENGTH_ID) i2 l255 L255 L0 s$(MSIBUILD_LENGTH_ID)
Registry Registry
regEAPHostAuthor 2 SYSTEM\CurrentControlSet\services\EapHost\Methods\67532 $(MSIBUILD_PRODUCT_NAME) compEAPHostAuthor
regEAPTTLSPeerDllPath 2 SYSTEM\CurrentControlSet\services\EapHost\Methods\67532\21 PeerDllPath [#fileEAPTTLS.dll.$(PLAT)] compEAPTTLSPeerDllPath
regEAPTTLSPeerConfigUIPath 2 SYSTEM\CurrentControlSet\services\EapHost\Methods\67532\21 PeerConfigUIPath [#fileEAPTTLSUI.dll.$(PLAT)] compEAPTTLSPeerConfigUIPath
regEAPTTLSPeerIdentityPath 2 SYSTEM\CurrentControlSet\services\EapHost\Methods\67532\21 PeerIdentityPath [#fileEAPTTLSUI.dll.$(PLAT)] compEAPTTLSPeerIdentityPath
regEAPTTLSPeerInteractiveUIPath 2 SYSTEM\CurrentControlSet\services\EapHost\Methods\67532\21 PeerInteractiveUIPath [#fileEAPTTLSUI.dll.$(PLAT)] compEAPTTLSPeerInteractiveUIPath
regEAPTTLSPeerFriendlyName 2 SYSTEM\CurrentControlSet\services\EapHost\Methods\67532\21 PeerFriendlyName @[#fileEAPTTLS.dll.$(PLAT)],-1 compEAPTTLSPeerFriendlyName
regEAPTTLSPeerInvokePasswordDialog 2 SYSTEM\CurrentControlSet\services\EapHost\Methods\67532\21 PeerInvokePasswordDialog #0 compEAPTTLSPeerInvokePasswordDialog
regEAPTTLSPeerInvokeUsernameDialog 2 SYSTEM\CurrentControlSet\services\EapHost\Methods\67532\21 PeerInvokeUsernameDialog #0 compEAPTTLSPeerInvokeUsernameDialog

View File

@ -0,0 +1,32 @@
;
; Copyright 2015-2016 Amebis
; Copyright 2016 GÉANT
;
; This file is part of GEANTLink.
;
; GEANTLink 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.
;
; GEANTLink 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 GEANTLink. If not, see <http://www.gnu.org/licenses/>.
;
EXPORTS
EapPeerFreeMemory
EapPeerFreeErrorMemory
EapPeerGetInfo
; EapPeerConfigXml2Blob
; EapPeerConfigBlob2Xml
; EapPeerGetMethodProperties
; EapPeerCredentialsXml2Blob
; EapPeerQueryCredentialInputFields
; EapPeerQueryUserBlobFromCredentialInputFields
; EapPeerQueryInteractiveUIInputFields
; EapPeerQueryUIBlobFromInteractiveUIInputFields

View File

@ -0,0 +1,26 @@
;
; Copyright 2015-2016 Amebis
; Copyright 2016 GÉANT
;
; This file is part of GEANTLink.
;
; GEANTLink 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.
;
; GEANTLink 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 GEANTLink. If not, see <http://www.gnu.org/licenses/>.
;
EXPORTS
EapPeerFreeMemory
EapPeerFreeErrorMemory
EapPeerInvokeConfigUI
EapPeerInvokeIdentityUI
EapPeerInvokeInteractiveUI

View File

@ -9,6 +9,9 @@
<ClCompile>
<PreprocessorDefinitions>EAPMETHOD_TYPE=21;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<ModuleDefinitionFile>EAPMethod.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View File

@ -105,6 +105,9 @@
<Project>{d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="EAPMethod.def" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -44,4 +44,9 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="EAPMethod.def">
<Filter>Source Files</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,17 @@
<?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>EAPMETHOD_TYPE=21;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<ModuleDefinitionFile>EAPMethodUI.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

Binary file not shown.

View File

@ -0,0 +1,114 @@
<?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|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{DD7A97CA-F18E-43B7-95C4-D06E6A291624}</ProjectGuid>
<RootNamespace>EAPTTLSUI</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</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\Win32.props" />
<Import Project="..\..\include\Debug.props" />
<Import Project="EAPTTLSUI.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\x64.props" />
<Import Project="..\..\include\Debug.props" />
<Import Project="EAPTTLSUI.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\Win32.props" />
<Import Project="..\..\include\Release.props" />
<Import Project="EAPTTLSUI.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\x64.props" />
<Import Project="..\..\include\Release.props" />
<Import Project="EAPTTLSUI.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<ItemGroup>
<ClInclude Include="..\include\EAPMethods.h" />
<ClInclude Include="..\include\EAPTTLS.h" />
<ClInclude Include="..\include\StdAfx.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\EAPMethods.cpp" />
<ClCompile Include="..\src\EAPTTLS.cpp" />
<ClCompile Include="..\src\MainUI.cpp" />
<ClCompile Include="..\src\StdAfx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EAPTTLSUI.rc" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\lib\WinStd\build\WinStd.vcxproj">
<Project>{47399d91-7eb9-41de-b521-514ba5db0c43}</Project>
</ProjectReference>
<ProjectReference Include="EAPMethodEvents.vcxproj">
<Project>{d63f24bd-92a0-4d6b-8b69-ed947e4d2b1b}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="EAPMethodUI.def" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<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>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\StdAfx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\EAPMethods.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\EAPTTLS.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\StdAfx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\MainUI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\EAPMethods.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\EAPTTLS.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EAPTTLSUI.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="EAPMethodUI.def">
<Filter>Source Files</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -34,7 +34,9 @@ extern "C" {
namespace eap
{
class session_base;
class eap_module_base;
template<class Ts> class peer;
class peer_ui_base;
};
#pragma once
@ -132,10 +134,9 @@ namespace eap
///
/// EAP peer base class
/// EAP module base class
///
template<class Ts>
class peer
class eap_module_base
{
public:
inline DWORD create()
@ -150,57 +151,12 @@ namespace eap
}
virtual ~peer()
virtual ~eap_module_base()
{
m_ep.write(&EAPMETHOD_TRACE_EVT_MODULE_UNLOAD, winstd::event_data((BYTE)EAPMETHOD_TYPE), winstd::event_data::blank);
}
///
/// Obtains a set of function pointers for an implementation of the EAP peer method currently loaded on the EAPHost service
///
/// \sa [EapPeerGetInfo function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363608.aspx)
///
inline void get_info(_Out_ EAP_PEER_METHOD_ROUTINES *pEapPeerMethodRoutines) const
{
ETW_FN_VOID;
assert(pEapPeerMethodRoutines);
pEapPeerMethodRoutines->dwVersion = PRODUCT_VERSION;
pEapPeerMethodRoutines->pEapType = NULL;
pEapPeerMethodRoutines->EapPeerInitialize = initialize;
pEapPeerMethodRoutines->EapPeerShutdown = shutdown;
pEapPeerMethodRoutines->EapPeerBeginSession = begin_session;
pEapPeerMethodRoutines->EapPeerEndSession = end_session;
pEapPeerMethodRoutines->EapPeerSetCredentials = NULL; // Always NULL unless we want to use generic credential UI
pEapPeerMethodRoutines->EapPeerGetIdentity = get_identity;
pEapPeerMethodRoutines->EapPeerProcessRequestPacket = process_request_packet;
pEapPeerMethodRoutines->EapPeerGetResponsePacket = get_response_packet;
pEapPeerMethodRoutines->EapPeerGetResult = get_result;
pEapPeerMethodRoutines->EapPeerGetUIContext = get_ui_context;
pEapPeerMethodRoutines->EapPeerSetUIContext = set_ui_context;
pEapPeerMethodRoutines->EapPeerGetResponseAttributes = get_response_attributes;
pEapPeerMethodRoutines->EapPeerSetResponseAttributes = set_response_attributes;
}
///
/// Free BLOB allocated with this peer
///
inline void free_memory(_In_ void *ptr)
{
ETW_FN_VOID;
if (ptr) {
// Since we do security here and some of the BLOBs contain credentials, sanitize every memory block before freeing.
SecureZeroMemory(ptr, HeapSize(m_heap, 0, ptr));
HeapFree(m_heap, 0, ptr);
}
}
///
/// Allocate a EAP_ERROR and fill it according to dwErrorCode
///
@ -257,6 +213,21 @@ namespace eap
}
///
/// Free BLOB allocated with this peer
///
inline void free_memory(_In_ void *ptr)
{
ETW_FN_VOID;
if (ptr) {
// Since we do security here and some of the BLOBs contain credentials, sanitize every memory block before freeing.
SecureZeroMemory(ptr, HeapSize(m_heap, 0, ptr));
HeapFree(m_heap, 0, ptr);
}
}
///
/// Free EAP_ERROR allocated with `make_error()` method
///
@ -270,6 +241,49 @@ namespace eap
}
}
protected:
winstd::heap m_heap; ///< Heap
mutable winstd::event_provider m_ep; ///< Event Provider
};
///
/// EAP peer base class
///
template<class Ts>
class peer : public eap_module_base
{
public:
///
/// Obtains a set of function pointers for an implementation of the EAP peer method currently loaded on the EAPHost service
///
/// \sa [EapPeerGetInfo function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363608.aspx)
///
inline void get_info(_Out_ EAP_PEER_METHOD_ROUTINES *pEapPeerMethodRoutines) const
{
ETW_FN_VOID;
assert(pEapPeerMethodRoutines);
pEapPeerMethodRoutines->dwVersion = PRODUCT_VERSION;
pEapPeerMethodRoutines->pEapType = NULL;
pEapPeerMethodRoutines->EapPeerInitialize = initialize;
pEapPeerMethodRoutines->EapPeerShutdown = shutdown;
pEapPeerMethodRoutines->EapPeerBeginSession = begin_session;
pEapPeerMethodRoutines->EapPeerEndSession = end_session;
pEapPeerMethodRoutines->EapPeerSetCredentials = NULL; // Always NULL unless we want to use generic credential UI
pEapPeerMethodRoutines->EapPeerGetIdentity = get_identity;
pEapPeerMethodRoutines->EapPeerProcessRequestPacket = process_request_packet;
pEapPeerMethodRoutines->EapPeerGetResponsePacket = get_response_packet;
pEapPeerMethodRoutines->EapPeerGetResult = get_result;
pEapPeerMethodRoutines->EapPeerGetUIContext = get_ui_context;
pEapPeerMethodRoutines->EapPeerSetUIContext = set_ui_context;
pEapPeerMethodRoutines->EapPeerGetResponseAttributes = get_response_attributes;
pEapPeerMethodRoutines->EapPeerSetResponseAttributes = set_response_attributes;
}
protected:
///
/// Initializes an EAP peer method for EAPHost.
@ -446,9 +460,65 @@ namespace eap
assert(hSession);
return static_cast<Ts*>(hSession)->set_response_attributes(pAttribs, pEapOutput, ppEapError);
}
};
protected:
winstd::heap m_heap; ///< Heap
mutable winstd::event_provider m_ep; ///< Event Provider
///
/// EAP peer UI base class
///
class peer_ui_base : public eap_module_base
{
public:
///
/// Constructor
///
peer_ui_base();
///
/// Raises the EAP method's specific connection configuration user interface dialog on the client.
///
/// \sa [EapPeerInvokeConfigUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363614.aspx)
///
virtual DWORD invoke_config_ui(
_In_ const EAP_METHOD_TYPE *pEapType,
_In_ HWND hwndParent,
_In_ DWORD dwFlags,
_In_ DWORD dwSizeOfConnectionDataIn,
_In_count_(dwSizeOfConnectionDataIn) const BYTE *pConnectionDataIn,
_Out_ DWORD *pdwSizeOfConnectionDataOut,
_Out_ BYTE **ppConnectionDataOut,
_Out_ EAP_ERROR **ppEapError) = 0;
///
/// Raises a custom interactive user interface dialog to obtain user identity information for the EAP method on the client.
///
/// \sa [EapPeerInvokeIdentityUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363615.aspx)
///
virtual DWORD invoke_identity_ui(
_In_ const EAP_METHOD_TYPE *pEapType,
_In_ DWORD dwFlags,
_In_ HWND hwndParent,
_In_ DWORD dwSizeOfConnectionData,
_In_count_(dwSizeOfConnectionData) const BYTE *pConnectionData,
_In_ DWORD dwSizeOfUserData,
_In_count_(dwSizeOfUserData) const BYTE *pUserData,
_Out_ DWORD *pdwSizeOfUserDataOut,
_Out_ BYTE **ppUserDataOut,
_Out_ LPWSTR *ppwszIdentity,
_Out_ EAP_ERROR **ppEapError) = 0;
///
/// Raises a custom interactive user interface dialog for the EAP method on the client.
///
/// \sa [EapPeerInvokeInteractiveUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363616.aspx)
///
virtual DWORD invoke_interactive_ui(
_In_ const EAP_METHOD_TYPE *pEapType,
_In_ HWND hwndParent,
_In_ DWORD dwSizeofUIContextData,
_In_count_(dwSizeofUIContextData) const BYTE *pUIContextData,
_Out_ DWORD *pdwSizeOfDataFromInteractiveUI,
_Out_ BYTE **ppDataFromInteractiveUI,
_Out_ EAP_ERROR **ppEapError) = 0;
};
};

View File

@ -24,6 +24,7 @@ namespace eap
{
class session_ttls;
class peer_ttls;
class peer_ttls_ui;
}
#pragma once
@ -44,4 +45,61 @@ namespace eap
class peer_ttls : public peer<session_ttls>
{
};
class peer_ttls_ui : public peer_ui_base
{
public:
///
/// Constructor
///
peer_ttls_ui();
///
/// Raises the EAP method's specific connection configuration user interface dialog on the client.
///
/// \sa [EapPeerInvokeConfigUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363614.aspx)
///
virtual DWORD invoke_config_ui(
_In_ const EAP_METHOD_TYPE *pEapType,
_In_ HWND hwndParent,
_In_ DWORD dwFlags,
_In_ DWORD dwSizeOfConnectionDataIn,
_In_count_(dwSizeOfConnectionDataIn) const BYTE *pConnectionDataIn,
_Out_ DWORD *pdwSizeOfConnectionDataOut,
_Out_ BYTE **ppConnectionDataOut,
_Out_ EAP_ERROR **ppEapError);
///
/// Raises a custom interactive user interface dialog to obtain user identity information for the EAP method on the client.
///
/// \sa [EapPeerInvokeIdentityUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363615.aspx)
///
virtual DWORD invoke_identity_ui(
_In_ const EAP_METHOD_TYPE *pEapType,
_In_ DWORD dwFlags,
_In_ HWND hwndParent,
_In_ DWORD dwSizeOfConnectionData,
_In_count_(dwSizeOfConnectionData) const BYTE *pConnectionData,
_In_ DWORD dwSizeOfUserData,
_In_count_(dwSizeOfUserData) const BYTE *pUserData,
_Out_ DWORD *pdwSizeOfUserDataOut,
_Out_ BYTE **ppUserDataOut,
_Out_ LPWSTR *ppwszIdentity,
_Out_ EAP_ERROR **ppEapError);
///
/// Raises a custom interactive user interface dialog for the EAP method on the client.
///
/// \sa [EapPeerInvokeInteractiveUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363616.aspx)
///
virtual DWORD invoke_interactive_ui(
_In_ const EAP_METHOD_TYPE *pEapType,
_In_ HWND hwndParent,
_In_ DWORD dwSizeofUIContextData,
_In_count_(dwSizeofUIContextData) const BYTE *pUIContextData,
_Out_ DWORD *pdwSizeOfDataFromInteractiveUI,
_Out_ BYTE **ppDataFromInteractiveUI,
_Out_ EAP_ERROR **ppEapError);
};
}

View File

@ -28,9 +28,7 @@
#include <WinStd/Win.h>
#include <eaptypes.h>
extern "C" {
#include <eapmethodpeerapis.h>
}
#include <Commctrl.h>
#include <tchar.h>

View File

@ -130,3 +130,12 @@ DWORD eap::session_base::set_response_attributes(_In_ EapAttributes *pAttribs, _
return ERROR_SUCCESS;
}
//////////////////////////////////////////////////////////////////////
// eap::peer_ui_base
//////////////////////////////////////////////////////////////////////
eap::peer_ui_base::peer_ui_base() : eap_module_base()
{
}

View File

@ -20,6 +20,8 @@
#include <StdAfx.h>
#pragma comment(lib, "Comctl32.lib")
//////////////////////////////////////////////////////////////////////
// eap::session_ttls
@ -28,3 +30,91 @@
eap::session_ttls::session_ttls() : session_base()
{
}
//////////////////////////////////////////////////////////////////////
// eap::peer_ui_base
//////////////////////////////////////////////////////////////////////
eap::peer_ttls_ui::peer_ttls_ui() : peer_ui_base()
{
}
DWORD eap::peer_ttls_ui::invoke_config_ui(
_In_ const EAP_METHOD_TYPE *pEapType,
_In_ HWND hwndParent,
_In_ DWORD dwFlags,
_In_ DWORD dwSizeOfConnectionDataIn,
_In_count_(dwSizeOfConnectionDataIn) const BYTE *pConnectionDataIn,
_Out_ DWORD *pdwSizeOfConnectionDataOut,
_Out_ BYTE **ppConnectionDataOut,
_Out_ EAP_ERROR **ppEapError)
{
UNREFERENCED_PARAMETER(pEapType);
UNREFERENCED_PARAMETER(dwFlags);
UNREFERENCED_PARAMETER(dwSizeOfConnectionDataIn);
UNREFERENCED_PARAMETER(pConnectionDataIn);
UNREFERENCED_PARAMETER(pdwSizeOfConnectionDataOut);
UNREFERENCED_PARAMETER(ppConnectionDataOut);
UNREFERENCED_PARAMETER(ppEapError);
InitCommonControls();
MessageBox(hwndParent, _T(PRODUCT_NAME_STR) _T(" configuration goes here!"), _T(PRODUCT_NAME_STR) _T(" Settings"), MB_OK);
return ERROR_SUCCESS;
}
DWORD eap::peer_ttls_ui::invoke_identity_ui(
_In_ const EAP_METHOD_TYPE *pEapType,
_In_ DWORD dwFlags,
_In_ HWND hwndParent,
_In_ DWORD dwSizeOfConnectionData,
_In_count_(dwSizeOfConnectionData) const BYTE *pConnectionData,
_In_ DWORD dwSizeOfUserData,
_In_count_(dwSizeOfUserData) const BYTE *pUserData,
_Out_ DWORD *pdwSizeOfUserDataOut,
_Out_ BYTE **ppUserDataOut,
_Out_ LPWSTR *ppwszIdentity,
_Out_ EAP_ERROR **ppEapError)
{
UNREFERENCED_PARAMETER(pEapType);
UNREFERENCED_PARAMETER(dwFlags);
UNREFERENCED_PARAMETER(dwSizeOfConnectionData);
UNREFERENCED_PARAMETER(pConnectionData);
UNREFERENCED_PARAMETER(dwSizeOfUserData);
UNREFERENCED_PARAMETER(pUserData);
UNREFERENCED_PARAMETER(pdwSizeOfUserDataOut);
UNREFERENCED_PARAMETER(ppUserDataOut);
UNREFERENCED_PARAMETER(ppwszIdentity);
UNREFERENCED_PARAMETER(ppEapError);
InitCommonControls();
MessageBox(hwndParent, _T(PRODUCT_NAME_STR) _T(" credential prompt goes here!"), _T(PRODUCT_NAME_STR) _T(" Credentials"), MB_OK);
return ERROR_SUCCESS;
}
DWORD eap::peer_ttls_ui::invoke_interactive_ui(
_In_ const EAP_METHOD_TYPE *pEapType,
_In_ HWND hwndParent,
_In_ DWORD dwSizeofUIContextData,
_In_count_(dwSizeofUIContextData) const BYTE *pUIContextData,
_Out_ DWORD *pdwSizeOfDataFromInteractiveUI,
_Out_ BYTE **ppDataFromInteractiveUI,
_Out_ EAP_ERROR **ppEapError)
{
UNREFERENCED_PARAMETER(pEapType);
UNREFERENCED_PARAMETER(dwSizeofUIContextData);
UNREFERENCED_PARAMETER(pUIContextData);
UNREFERENCED_PARAMETER(pdwSizeOfDataFromInteractiveUI);
UNREFERENCED_PARAMETER(ppDataFromInteractiveUI);
UNREFERENCED_PARAMETER(ppEapError);
InitCommonControls();
MessageBox(hwndParent, _T(PRODUCT_NAME_STR) _T(" interactive UI goes here!"), _T(PRODUCT_NAME_STR) _T(" Prompt"), MB_OK);
return ERROR_SUCCESS;
}

View File

@ -20,8 +20,6 @@
#include <StdAfx.h>
#pragma comment(lib, "Comctl32.lib")
#pragma comment(lib, "Shlwapi.lib")
#if EAPMETHOD_TYPE==21
#define _EAPMETHOD_PEER eap::peer_ttls
@ -43,19 +41,13 @@ BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID l
UNREFERENCED_PARAMETER(lpvReserved);
if (fdwReason == DLL_PROCESS_ATTACH) {
//// Load EAPMethodEvents.dll
//tstring path;
//GetModuleFileName(hinstDLL, path);
//LPTSTR pszFilename = PathFindFileName(path.c_str());
//path.resize(pszFilename ? (size_t)(pszFilename - (LPCTSTR)path.c_str()) : 0);
//path += _T("EAPMethodEvents.dll");
//g_EAPMethodEvents.load(path.c_str(), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE);
if (!g_peer.create())
#ifdef _DEBUG
//Sleep(10000);
#endif
if (g_peer.create() != ERROR_SUCCESS)
return FALSE;
} else if (fdwReason == DLL_PROCESS_DETACH) {
} else if (fdwReason == DLL_PROCESS_DETACH)
assert(!_CrtDumpMemoryLeaks());
}
return TRUE;
}
@ -71,8 +63,6 @@ VOID WINAPI EapPeerFreeMemory(_In_ void *pUIContextData)
g_peer.free_memory(pUIContextData);
}
#pragma comment(linker, "/EXPORT:EapPeerFreeMemory")
///
/// Releases error-specific memory allocated by the EAP peer method.
@ -84,8 +74,6 @@ VOID WINAPI EapPeerFreeErrorMemory(_In_ EAP_ERROR *ppEapError)
g_peer.free_error_memory(ppEapError);
}
#pragma comment(linker, "/EXPORT:EapPeerFreeErrorMemory")
///
/// Obtains a set of function pointers for an implementation of the EAP peer method currently loaded on the EAPHost service.
@ -100,144 +88,16 @@ DWORD WINAPI EapPeerGetInfo(_In_ EAP_TYPE* pEapType, _Out_ EAP_PEER_METHOD_ROUTI
#endif
// Parameter check
if (!ppEapError) {
if (!ppEapError)
dwResult = ERROR_INVALID_PARAMETER;
} else if (!pEapType) {
else if (!pEapType)
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapType is NULL."), NULL);
} else if (pEapType->type != EAPMETHOD_TYPE) {
else if (pEapType->type != EAPMETHOD_TYPE)
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" Input EAP type (%d) does not match the supported EAP type (%d)."), (int)pEapType->type, (int)EAPMETHOD_TYPE).c_str(), NULL);
} else if (!pEapPeerMethodRoutines) {
else if (!pEapPeerMethodRoutines)
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapPeerMethodRoutines is NULL."), NULL);
} else
else
g_peer.get_info(pEapPeerMethodRoutines);
return dwResult;
}
#pragma comment(linker, "/EXPORT:EapPeerGetInfo")
///
/// Raises the EAP method's specific connection configuration user interface dialog on the client.
///
/// \sa [EapPeerInvokeConfigUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363614.aspx)
///
DWORD WINAPI EapPeerInvokeConfigUI(_In_ EAP_METHOD_TYPE *pEapType, _In_ HWND hwndParent, _In_ DWORD dwFlags, _In_ DWORD dwSizeOfConnectionDataIn, _In_ BYTE *pConnectionDataIn, _Out_ DWORD *pdwSizeOfConnectionDataOut, _Out_ BYTE **ppConnectionDataOut, _Out_ EAP_ERROR **ppEapError)
{
DWORD dwResult = NO_ERROR;
#ifdef _DEBUG
//MessageBox(NULL, _T("Attach debugger!"), _T(__FUNCTION__), MB_OK);
#endif
// Parameter check
if (!ppEapError) {
dwResult = ERROR_INVALID_PARAMETER;
} else if (!pEapType) {
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapType is NULL."), NULL);
} else if (pEapType->eapType.type != EAPMETHOD_TYPE) {
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::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(), NULL);
} else if (pEapType->dwAuthorId != 67532) {
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str(), NULL);
} else if (!pdwSizeOfConnectionDataOut) {
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwSizeOfConnectionDataOut is NULL."), NULL);
} else if (!ppConnectionDataOut) {
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppConnectionDataOut is NULL."), NULL);
} else {
UNREFERENCED_PARAMETER(dwFlags);
UNREFERENCED_PARAMETER(dwSizeOfConnectionDataIn);
UNREFERENCED_PARAMETER(pConnectionDataIn);
InitCommonControls();
MessageBox(hwndParent, _T(PRODUCT_NAME_STR) _T(" configuration goes here!"), _T(PRODUCT_NAME_STR) _T(" Settings"), MB_OK);
}
return dwResult;
}
#pragma comment(linker, "/EXPORT:EapPeerInvokeConfigUI")
///
/// Raises a custom interactive user interface dialog to obtain user identity information for the EAP method on the client.
///
/// \sa [EapPeerInvokeIdentityUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363615.aspx)
///
DWORD WINAPI EapPeerInvokeIdentityUI(_In_ EAP_METHOD_TYPE *pEapType, _In_ DWORD dwFlags, _In_ HWND hwndParent, _In_ DWORD dwSizeOfConnectionData, _In_ const BYTE *pConnectionData, _Out_ DWORD dwSizeOfUserData, _In_ const BYTE *pUserData, _Out_ DWORD *pdwSizeOfUserDataOut, _Out_ BYTE **ppUserDataOut, _Out_ LPWSTR *ppwszIdentity, _Out_ EAP_ERROR **ppEapError)
{
DWORD dwResult = NO_ERROR;
#ifdef _DEBUG
//MessageBox(NULL, _T("Attach debugger!"), _T(__FUNCTION__), MB_OK);
#endif
// Parameter check
if (!ppEapError) {
dwResult = ERROR_INVALID_PARAMETER;
} else if (!pEapType) {
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapType is NULL."), NULL);
} else if (pEapType->eapType.type != EAPMETHOD_TYPE) {
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::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(), NULL);
} else if (pEapType->dwAuthorId != 67532) {
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str(), NULL);
} else if (!pdwSizeOfUserDataOut) {
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwSizeOfUserDataOut is NULL."), NULL);
} else if (!ppUserDataOut) {
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppUserDataOut is NULL."), NULL);
} else if (!ppwszIdentity) {
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppwszIdentity is NULL."), NULL);
} else {
UNREFERENCED_PARAMETER(dwFlags);
UNREFERENCED_PARAMETER(pUserData);
UNREFERENCED_PARAMETER(dwSizeOfUserData);
UNREFERENCED_PARAMETER(pConnectionData);
UNREFERENCED_PARAMETER(dwSizeOfConnectionData);
InitCommonControls();
MessageBox(hwndParent, _T(PRODUCT_NAME_STR) _T(" credential prompt goes here!"), _T(PRODUCT_NAME_STR) _T(" Credentials"), MB_OK);
}
return dwResult;
}
#pragma comment(linker, "/EXPORT:EapPeerInvokeIdentityUI")
///
/// Raises a custom interactive user interface dialog for the EAP method on the client.
///
/// \sa [EapPeerInvokeInteractiveUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363616.aspx)
///
DWORD WINAPI EapPeerInvokeInteractiveUI(_In_ EAP_METHOD_TYPE *pEapType, _In_ HWND hwndParent, _In_ DWORD dwSizeofUIContextData, _In_ BYTE *pUIContextData, _Out_ DWORD *pdwSizeOfDataFromInteractiveUI, _Out_ BYTE **ppDataFromInteractiveUI, _Out_ EAP_ERROR **ppEapError)
{
DWORD dwResult = NO_ERROR;
#ifdef _DEBUG
//MessageBox(NULL, _T("Attach debugger!"), _T(__FUNCTION__), MB_OK);
#endif
// Parameter check
if (!ppEapError) {
dwResult = ERROR_INVALID_PARAMETER;
} else if (!pEapType) {
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapType is NULL."), NULL);
} else if (pEapType->eapType.type != EAPMETHOD_TYPE) {
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::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(), NULL);
} else if (pEapType->dwAuthorId != 67532) {
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str(), NULL);
} else if (!pdwSizeOfDataFromInteractiveUI) {
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwSizeOfDataFromInteractiveUI is NULL."), NULL);
} else if (!ppDataFromInteractiveUI) {
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppDataFromInteractiveUI is NULL."), NULL);
} else {
UNREFERENCED_PARAMETER(dwSizeofUIContextData);
UNREFERENCED_PARAMETER(pUIContextData);
InitCommonControls();
MessageBox(hwndParent, _T(PRODUCT_NAME_STR) _T(" interactive UI goes here!"), _T(PRODUCT_NAME_STR) _T(" Prompt"), MB_OK);
}
return dwResult;
}
#pragma comment(linker, "/EXPORT:EapPeerInvokeInteractiveUI")

225
EAPMethods/src/MainUI.cpp Normal file
View File

@ -0,0 +1,225 @@
/*
Copyright 2015-2016 Amebis
Copyright 2016 GÉANT
This file is part of GEANTLink.
GEANTLink 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.
GEANTLink 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 GEANTLink. If not, see <http://www.gnu.org/licenses/>.
*/
#include <StdAfx.h>
#if EAPMETHOD_TYPE==21
#define _EAPMETHOD_PEER_UI eap::peer_ttls_ui
#else
#error Unknown EAP Method type.
#endif
_EAPMETHOD_PEER_UI g_peer;
///
/// DLL main entry point
///
/// \sa [DllMain entry point](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682583.aspx)
///
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved)
{
UNREFERENCED_PARAMETER(hinstDLL);
UNREFERENCED_PARAMETER(lpvReserved);
if (fdwReason == DLL_PROCESS_ATTACH) {
#ifdef _DEBUG
//MessageBox(NULL, _T("Attach debugger!"), _T(__FUNCTION__), MB_OK);
#endif
if (g_peer.create() != ERROR_SUCCESS)
return FALSE;
} else if (fdwReason == DLL_PROCESS_DETACH)
assert(!_CrtDumpMemoryLeaks());
return TRUE;
}
///
/// Releases all memory associated with an opaque user interface context data buffer.
///
/// \sa [EapPeerFreeMemory function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363606.aspx)
///
VOID WINAPI EapPeerFreeMemory(_In_ void *pUIContextData)
{
g_peer.free_memory(pUIContextData);
}
///
/// Releases error-specific memory allocated by the EAP peer method.
///
/// \sa [EapPeerFreeErrorMemory function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363605.aspx)
///
VOID WINAPI EapPeerFreeErrorMemory(_In_ EAP_ERROR *ppEapError)
{
g_peer.free_error_memory(ppEapError);
}
///
/// Raises the EAP method's specific connection configuration user interface dialog on the client.
///
/// \sa [EapPeerInvokeConfigUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363614.aspx)
///
DWORD WINAPI EapPeerInvokeConfigUI(
_In_ /*const*/ EAP_METHOD_TYPE *pEapType,
_In_ HWND hwndParent,
_In_ DWORD dwFlags,
_In_ DWORD dwSizeOfConnectionDataIn,
_In_count_(dwSizeOfConnectionDataIn) /*const*/ BYTE *pConnectionDataIn,
_Out_ DWORD *pdwSizeOfConnectionDataOut,
_Out_ BYTE **ppConnectionDataOut,
_Out_ EAP_ERROR **ppEapError)
{
DWORD dwResult = NO_ERROR;
#ifdef _DEBUG
//MessageBox(NULL, _T("Attach debugger!"), _T(__FUNCTION__), MB_OK);
#endif
// Parameter check
if (!ppEapError)
dwResult = ERROR_INVALID_PARAMETER;
else if (!pEapType)
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapType is NULL."), NULL);
else if (pEapType->eapType.type != EAPMETHOD_TYPE)
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::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(), NULL);
else if (pEapType->dwAuthorId != 67532)
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str(), NULL);
else if (!pdwSizeOfConnectionDataOut)
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwSizeOfConnectionDataOut is NULL."), NULL);
else if (!ppConnectionDataOut)
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppConnectionDataOut is NULL."), NULL);
else
dwResult = g_peer.invoke_config_ui(
pEapType,
hwndParent,
dwFlags,
dwSizeOfConnectionDataIn,
pConnectionDataIn,
pdwSizeOfConnectionDataOut,
ppConnectionDataOut,
ppEapError);
return dwResult;
}
///
/// Raises a custom interactive user interface dialog to obtain user identity information for the EAP method on the client.
///
/// \sa [EapPeerInvokeIdentityUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363615.aspx)
///
DWORD WINAPI EapPeerInvokeIdentityUI(
_In_ /*const*/ EAP_METHOD_TYPE *pEapType,
_In_ DWORD dwFlags,
_In_ HWND hwndParent,
_In_ DWORD dwSizeOfConnectionData,
_In_count_(dwSizeOfConnectionData) const BYTE *pConnectionData,
_In_ DWORD dwSizeOfUserData,
_In_count_(dwSizeOfUserData) const BYTE *pUserData,
_Out_ DWORD *pdwSizeOfUserDataOut,
_Out_ BYTE **ppUserDataOut,
_Out_ LPWSTR *ppwszIdentity,
_Out_ EAP_ERROR **ppEapError)
{
DWORD dwResult = NO_ERROR;
#ifdef _DEBUG
//MessageBox(NULL, _T("Attach debugger!"), _T(__FUNCTION__), MB_OK);
#endif
// Parameter check
if (!ppEapError)
dwResult = ERROR_INVALID_PARAMETER;
else if (!pEapType)
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapType is NULL."), NULL);
else if (pEapType->eapType.type != EAPMETHOD_TYPE)
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::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(), NULL);
else if (pEapType->dwAuthorId != 67532)
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str(), NULL);
else if (!pdwSizeOfUserDataOut)
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwSizeOfUserDataOut is NULL."), NULL);
else if (!ppUserDataOut)
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppUserDataOut is NULL."), NULL);
else if (!ppwszIdentity)
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppwszIdentity is NULL."), NULL);
else
dwResult = g_peer.invoke_identity_ui(
pEapType,
dwFlags,
hwndParent,
dwSizeOfConnectionData,
pConnectionData,
dwSizeOfUserData,
pUserData,
pdwSizeOfUserDataOut,
ppUserDataOut,
ppwszIdentity,
ppEapError);
return dwResult;
}
///
/// Raises a custom interactive user interface dialog for the EAP method on the client.
///
/// \sa [EapPeerInvokeInteractiveUI function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363616.aspx)
///
DWORD WINAPI EapPeerInvokeInteractiveUI(
_In_ /*const*/ EAP_METHOD_TYPE *pEapType,
_In_ HWND hwndParent,
_In_ DWORD dwSizeofUIContextData,
_In_count_(dwSizeofUIContextData) /*const*/ BYTE *pUIContextData,
_Out_ DWORD *pdwSizeOfDataFromInteractiveUI,
_Out_ BYTE **ppDataFromInteractiveUI,
_Out_ EAP_ERROR **ppEapError)
{
DWORD dwResult = NO_ERROR;
#ifdef _DEBUG
//MessageBox(NULL, _T("Attach debugger!"), _T(__FUNCTION__), MB_OK);
#endif
// Parameter check
if (!ppEapError)
dwResult = ERROR_INVALID_PARAMETER;
else if (!pEapType)
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pEapType is NULL."), NULL);
else if (pEapType->eapType.type != EAPMETHOD_TYPE)
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::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(), NULL);
else if (pEapType->dwAuthorId != 67532)
*ppEapError = g_peer.make_error(dwResult = ERROR_NOT_SUPPORTED, 0, NULL, NULL, NULL, winstd::wstring_printf(_T(__FUNCTION__) _T(" EAP author (%d) does not match the supported author (%d)."), (int)pEapType->dwAuthorId, (int)67532).c_str(), NULL);
else if (!pdwSizeOfDataFromInteractiveUI)
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" pdwSizeOfDataFromInteractiveUI is NULL."), NULL);
else if (!ppDataFromInteractiveUI)
*ppEapError = g_peer.make_error(dwResult = ERROR_INVALID_PARAMETER, 0, NULL, NULL, NULL, _T(__FUNCTION__) _T(" ppDataFromInteractiveUI is NULL."), NULL);
else
dwResult = g_peer.invoke_interactive_ui(
pEapType,
hwndParent,
dwSizeofUIContextData,
pUIContextData,
pdwSizeOfDataFromInteractiveUI,
ppDataFromInteractiveUI,
ppEapError);
return dwResult;
}

View File

@ -188,6 +188,9 @@ RegisterDLLs :: \
"$(OUTPUT_DIR)\$(PLAT).Debug\EAPTTLS.dll"
reg.exe add "HKLM\SYSTEM\CurrentControlSet\services\EapHost\Methods\67532" /ve /t REG_SZ /d "$(PRODUCT_NAME)" /f > NUL
reg.exe add "HKLM\SYSTEM\CurrentControlSet\services\EapHost\Methods\67532\21" /v "PeerDllPath" /t REG_SZ /d "$(MAKEDIR)\$(OUTPUT_DIR)\$(PLAT).Debug\EAPTTLS.dll" /f > NUL
reg.exe add "HKLM\SYSTEM\CurrentControlSet\services\EapHost\Methods\67532\21" /v "PeerConfigUIPath" /t REG_SZ /d "$(MAKEDIR)\$(OUTPUT_DIR)\$(PLAT).Debug\EAPTTLSUI.dll" /f > NUL
reg.exe add "HKLM\SYSTEM\CurrentControlSet\services\EapHost\Methods\67532\21" /v "PeerIdentityPath" /t REG_SZ /d "$(MAKEDIR)\$(OUTPUT_DIR)\$(PLAT).Debug\EAPTTLSUI.dll" /f > NUL
reg.exe add "HKLM\SYSTEM\CurrentControlSet\services\EapHost\Methods\67532\21" /v "PeerInteractiveUIPath" /t REG_SZ /d "$(MAKEDIR)\$(OUTPUT_DIR)\$(PLAT).Debug\EAPTTLSUI.dll" /f > NUL
reg.exe add "HKLM\SYSTEM\CurrentControlSet\services\EapHost\Methods\67532\21" /v "PeerFriendlyName" /t REG_SZ /d "@$(MAKEDIR)\$(OUTPUT_DIR)\$(PLAT).Debug\EAPTTLS.dll,-1" /f > NUL
reg.exe add "HKLM\SYSTEM\CurrentControlSet\services\EapHost\Methods\67532\21" /v "PeerInvokePasswordDialog" /t REG_DWORD /d 0 /f > NUL
reg.exe add "HKLM\SYSTEM\CurrentControlSet\services\EapHost\Methods\67532\21" /v "PeerInvokeUsernameDialog" /t REG_DWORD /d 0 /f > NUL

View File

@ -20,6 +20,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CredWrite", "CredWrite\Cred
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EAPMethodEvents", "EAPMethods\build\EAPMethodEvents.vcxproj", "{D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EAPTTLSUI", "EAPMethods\build\EAPTTLSUI.vcxproj", "{DD7A97CA-F18E-43B7-95C4-D06E6A291624}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -60,6 +62,14 @@ Global
{D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B}.Release|Win32.Build.0 = Release|Win32
{D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B}.Release|x64.ActiveCfg = Release|x64
{D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B}.Release|x64.Build.0 = Release|x64
{DD7A97CA-F18E-43B7-95C4-D06E6A291624}.Debug|Win32.ActiveCfg = Debug|Win32
{DD7A97CA-F18E-43B7-95C4-D06E6A291624}.Debug|Win32.Build.0 = Debug|Win32
{DD7A97CA-F18E-43B7-95C4-D06E6A291624}.Debug|x64.ActiveCfg = Debug|x64
{DD7A97CA-F18E-43B7-95C4-D06E6A291624}.Debug|x64.Build.0 = Debug|x64
{DD7A97CA-F18E-43B7-95C4-D06E6A291624}.Release|Win32.ActiveCfg = Release|Win32
{DD7A97CA-F18E-43B7-95C4-D06E6A291624}.Release|Win32.Build.0 = Release|Win32
{DD7A97CA-F18E-43B7-95C4-D06E6A291624}.Release|x64.ActiveCfg = Release|x64
{DD7A97CA-F18E-43B7-95C4-D06E6A291624}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -67,6 +77,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{331B6077-E3E2-4867-B93E-9D3F57280DE7} = {60BAAC3D-DC98-4C19-BC40-1A86963DE86C}
{D63F24BD-92A0-4D6B-8B69-ED947E4D2B1B} = {60BAAC3D-DC98-4C19-BC40-1A86963DE86C}
{DD7A97CA-F18E-43B7-95C4-D06E6A291624} = {60BAAC3D-DC98-4C19-BC40-1A86963DE86C}
{47399D91-7EB9-41DE-B521-514BA5DB0C43} = {E66A3FE1-4EE4-401F-8EAD-BE518B230393}
{2D3CE079-7EB1-4F47-B79E-F0310671ECCB} = {7B5EC9B7-208C-426A-941D-DAF9271BD4A4}
EndGlobalSection