diff --git a/EAPMethods/EAP-TTLS.vcxproj.filters b/EAPMethods/EAP-TTLS.vcxproj.filters index ebf0b23..5a3cd0e 100644 --- a/EAPMethods/EAP-TTLS.vcxproj.filters +++ b/EAPMethods/EAP-TTLS.vcxproj.filters @@ -26,6 +26,9 @@ Source Files + + Source Files + diff --git a/EAPMethods/EAP-TTLS_UI.vcxproj.filters b/EAPMethods/EAP-TTLS_UI.vcxproj.filters index cd27167..d4de84b 100644 --- a/EAPMethods/EAP-TTLS_UI.vcxproj.filters +++ b/EAPMethods/EAP-TTLS_UI.vcxproj.filters @@ -30,6 +30,9 @@ Source Files + + Source Files + diff --git a/EAPMethods/EAPMethod.def b/EAPMethods/EAPMethod.def index 4fb97d7..7d259eb 100644 Binary files a/EAPMethods/EAPMethod.def and b/EAPMethods/EAPMethod.def differ diff --git a/EAPMethods/EAPMethod.props b/EAPMethods/EAPMethod.props index f6d48bd..73b26b3 100644 --- a/EAPMethods/EAPMethod.props +++ b/EAPMethods/EAPMethod.props @@ -18,6 +18,7 @@ Create + diff --git a/EAPMethods/EAPMethod_UI.def b/EAPMethods/EAPMethod_UI.def index 84d60a9..eef9b7a 100644 Binary files a/EAPMethods/EAPMethod_UI.def and b/EAPMethods/EAPMethod_UI.def differ diff --git a/EAPMethods/EAPMethod_UI.props b/EAPMethods/EAPMethod_UI.props index a38a2db..d5d6974 100644 --- a/EAPMethods/EAPMethod_UI.props +++ b/EAPMethods/EAPMethod_UI.props @@ -21,6 +21,7 @@ Create + diff --git a/EAPMethods/PCH.h b/EAPMethods/PCH.h index d3db77c..08b82fd 100644 --- a/EAPMethods/PCH.h +++ b/EAPMethods/PCH.h @@ -27,3 +27,5 @@ #else #error Unknown EAP Method type. #endif + +extern EAPMETHOD_PEER g_peer; diff --git a/EAPMethods/PCH_UI.h b/EAPMethods/PCH_UI.h index 820e989..e179c00 100644 --- a/EAPMethods/PCH_UI.h +++ b/EAPMethods/PCH_UI.h @@ -29,3 +29,5 @@ #else #error Unknown EAP Method type. #endif + +extern EAPMETHOD_PEER_UI g_peer; diff --git a/EAPMethods/Register.cpp b/EAPMethods/Register.cpp new file mode 100644 index 0000000..11f3033 --- /dev/null +++ b/EAPMethods/Register.cpp @@ -0,0 +1,99 @@ +/* + Copyright 2020-2020 Amebis + Copyright 2016 GÉANT + + This file is part of GÉANTLink. + + GÉANTLink 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. + + GÉANTLink 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 GÉANTLink. If not, see . +*/ + +#include "PCH.h" + +using namespace std; +using namespace winstd; + + +static void set_value(_In_ HKEY hKey, _In_opt_z_ LPCTSTR lpValueName, _In_ LPCTSTR sValue) +{ + LSTATUS s = RegSetValueEx(hKey, lpValueName, 0, REG_SZ, reinterpret_cast(sValue), (DWORD)((_tcslen(sValue) + 1) * sizeof(tstring::value_type))); + if (s != ERROR_SUCCESS) + throw win_runtime_error(s, "RegSetValueEx failed."); +} + + +static void set_value(_In_ HKEY hKey, _In_opt_z_ LPCTSTR lpValueName, _In_ const tstring &sValue) +{ + LSTATUS s = RegSetValueEx(hKey, lpValueName, 0, REG_SZ, reinterpret_cast(sValue.c_str()), (DWORD)((sValue.length() + 1) * sizeof(tstring::value_type))); + if (s != ERROR_SUCCESS) + throw win_runtime_error(s, "RegSetValueEx failed."); +} + + +static void set_value(_In_ HKEY hKey, _In_opt_z_ LPCTSTR lpValueName, _In_ DWORD dwValue) +{ + LSTATUS s = RegSetValueEx(hKey, lpValueName, 0, REG_DWORD, reinterpret_cast(&dwValue), sizeof(dwValue)); + if (s != ERROR_SUCCESS) + throw win_runtime_error(s, "RegSetValueEx failed."); +} + + +/// +/// Registers method in EapHost registry +/// +/// \returns S_OK if successful; E_FAIL otherwise +/// +STDAPI DllRegisterServer() +{ + try { + tstring sz, sz2; + reg_key key_methods, key_author, key_method; + if (!key_methods.open(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\services\\EapHost\\Methods"), 0, KEY_CREATE_SUB_KEY)) throw win_runtime_error(); + sprintf(sz, _T("%u"), EAPMETHOD_AUTHOR_ID); + if (!key_author.create(key_methods, sz.c_str(), NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE)) throw win_runtime_error(); + set_value(key_author, NULL, _T(PRODUCT_NAME_STR)); + sprintf(sz, _T("%u"), EAPMETHOD_TYPE); + if (!key_method.create(key_author, sz.c_str(), NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE)) throw win_runtime_error(); + if (!GetModuleFileName(g_peer.m_instance, sz)) throw win_runtime_error("GetModuleFileName failed."); + sprintf(sz2, _T("@%s,-1"), sz.c_str()); + set_value(key_method, _T("PeerDllPath") , sz); + set_value(key_method, _T("PeerFriendlyName"), sz2); + set_value(key_method, _T("Properties") , (DWORD)389871807); + + return S_OK; + } catch(win_runtime_error &err) { + OutputDebugStr(_T("%hs (error %u)\n"), err.what(), err.number()); + return E_FAIL; + } catch(...) { + OutputDebugStr(_T("Registering DLL failed.\n")); + return E_FAIL; + } +} + + +/// +/// Unregisters method from EapHost registry +/// +/// \returns Always S_OK +/// +STDAPI DllUnregisterServer() +{ + try { + tstring sz; + reg_key key_methods; + if (!key_methods.open(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\services\\EapHost\\Methods"), 0, KEY_READ)) throw win_runtime_error(); + sprintf(sz, _T("%u\\%u"), EAPMETHOD_AUTHOR_ID, EAPMETHOD_TYPE); + if (!key_methods.delete_subkey(sz.c_str())) throw win_runtime_error(); + } catch(...) {} + return S_OK; +} diff --git a/EAPMethods/Register_UI.cpp b/EAPMethods/Register_UI.cpp new file mode 100644 index 0000000..59abc1e --- /dev/null +++ b/EAPMethods/Register_UI.cpp @@ -0,0 +1,100 @@ +/* + Copyright 2020-2020 Amebis + Copyright 2016 GÉANT + + This file is part of GÉANTLink. + + GÉANTLink 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. + + GÉANTLink 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 GÉANTLink. If not, see . +*/ + +#include "PCH_UI.h" + +using namespace std; +using namespace winstd; + + +static void set_value(_In_ HKEY hKey, _In_opt_z_ LPCTSTR lpValueName, _In_ LPCTSTR sValue) +{ + LSTATUS s = RegSetValueEx(hKey, lpValueName, 0, REG_SZ, reinterpret_cast(sValue), (DWORD)((_tcslen(sValue) + 1) * sizeof(tstring::value_type))); + if (s != ERROR_SUCCESS) + throw win_runtime_error(s, "RegSetValueEx failed."); +} + + +static void set_value(_In_ HKEY hKey, _In_opt_z_ LPCTSTR lpValueName, _In_ const tstring &sValue) +{ + LSTATUS s = RegSetValueEx(hKey, lpValueName, 0, REG_SZ, reinterpret_cast(sValue.c_str()), (DWORD)((sValue.length() + 1) * sizeof(tstring::value_type))); + if (s != ERROR_SUCCESS) + throw win_runtime_error(s, "RegSetValueEx failed."); +} + + +static void set_value(_In_ HKEY hKey, _In_opt_z_ LPCTSTR lpValueName, _In_ DWORD dwValue) +{ + LSTATUS s = RegSetValueEx(hKey, lpValueName, 0, REG_DWORD, reinterpret_cast(&dwValue), sizeof(dwValue)); + if (s != ERROR_SUCCESS) + throw win_runtime_error(s, "RegSetValueEx failed."); +} + + +/// +/// Registers method UI in EapHost registry +/// +/// \returns S_OK if successful; E_FAIL otherwise +/// +STDAPI DllRegisterServer() +{ + try { + tstring sz; + reg_key key_methods, key_author, key_method; + if (!key_methods.open(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\services\\EapHost\\Methods"), 0, KEY_CREATE_SUB_KEY)) throw win_runtime_error(); + sprintf(sz, _T("%u"), EAPMETHOD_AUTHOR_ID); + if (!key_author.create(key_methods, sz.c_str(), NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE)) throw win_runtime_error(); + set_value(key_author, NULL, _T(PRODUCT_NAME_STR)); + sprintf(sz, _T("%u"), EAPMETHOD_TYPE); + if (!key_method.create(key_author, sz.c_str(), NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE)) throw win_runtime_error(); + if (!GetModuleFileName(g_peer.m_instance, sz)) throw win_runtime_error("GetModuleFileName failed."); + set_value(key_method, _T("PeerConfigUIPath") , sz); + set_value(key_method, _T("PeerIdentityPath") , sz); + set_value(key_method, _T("PeerInteractiveUIPath") , sz); + set_value(key_method, _T("PeerInvokePasswordDialog"), (DWORD)0); + set_value(key_method, _T("PeerInvokeUsernameDialog"), (DWORD)0); + + return S_OK; + } catch(win_runtime_error &err) { + OutputDebugStr(_T("%hs (error %u)\n"), err.what(), err.number()); + return E_FAIL; + } catch(...) { + OutputDebugStr(_T("Registering DLL failed.\n")); + return E_FAIL; + } +} + + +/// +/// Unregisters method UI from EapHost registry +/// +/// \returns Always S_OK +/// +STDAPI DllUnregisterServer() +{ + try { + tstring sz; + reg_key key_methods; + if (!key_methods.open(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\services\\EapHost\\Methods"), 0, KEY_READ)) throw win_runtime_error(); + sprintf(sz, _T("%u\\%u"), EAPMETHOD_AUTHOR_ID, EAPMETHOD_TYPE); + key_methods.delete_subkey(sz.c_str()); + } catch(...) {} + return S_OK; +} diff --git a/Makefile b/Makefile index 1af10ae..920aef3 100644 Binary files a/Makefile and b/Makefile differ diff --git a/MakefileEAPMethod.mak b/MakefileEAPMethod.mak index 42fece9..7c5586b 100644 Binary files a/MakefileEAPMethod.mak and b/MakefileEAPMethod.mak differ diff --git a/include/ResourceDLL.props b/include/ResourceDLL.props deleted file mode 100644 index 9db83be..0000000 --- a/include/ResourceDLL.props +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - true - - - - Windows - true - Default - - - false - - - AFX_RESOURCE_DLL;%(PreprocessorDefinitions) - - - - diff --git a/lib/Events/build/Events.vcxproj b/lib/Events/build/Events.vcxproj index e1fdc9a..2f8ea46 100644 --- a/lib/Events/build/Events.vcxproj +++ b/lib/Events/build/Events.vcxproj @@ -81,7 +81,6 @@ - @@ -96,15 +95,57 @@ temp\Events.$(Platform).$(Configuration).$(PlatformToolset);%(AdditionalIncludeDirectories) - AFX_TARG_NEU;AFX_TARG_ENU;%(PreprocessorDefinitions) + AFX_TARG_NEU;AFX_TARG_ENU;AFX_RESOURCE_DLL;%(PreprocessorDefinitions) - - - - - - + + + $(IntDir);..\..\WinStd\include;%(AdditionalIncludeDirectories) + + + ..\src\Events.def + + + + + $(IntDir);..\..\WinStd\include;%(AdditionalIncludeDirectories) + + + ..\src\Events.def + + + + + $(IntDir);..\..\WinStd\include;%(AdditionalIncludeDirectories) + + + ..\src\Events.def + + + + + $(IntDir);..\..\WinStd\include;%(AdditionalIncludeDirectories) + + + ..\src\Events.def + + + + + $(IntDir);..\..\WinStd\include;%(AdditionalIncludeDirectories) + + + ..\src\Events.def + + + + + $(IntDir);..\..\WinStd\include;%(AdditionalIncludeDirectories) + + + ..\src\Events.def + + Document @@ -117,6 +158,23 @@ + + + Create + + + + + + + + + {47399d91-7eb9-41de-b521-514ba5db0c43} + + + + + diff --git a/lib/Events/build/Events.vcxproj.filters b/lib/Events/build/Events.vcxproj.filters index 7aad60d..46aef80 100644 --- a/lib/Events/build/Events.vcxproj.filters +++ b/lib/Events/build/Events.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -24,4 +24,22 @@ Resource Files + + + Source Files + + + Source Files + + + + + Header Files + + + + + Source Files + + \ No newline at end of file diff --git a/lib/Events/src/Events.def b/lib/Events/src/Events.def new file mode 100644 index 0000000..340550b Binary files /dev/null and b/lib/Events/src/Events.def differ diff --git a/lib/Events/src/PCH.cpp b/lib/Events/src/PCH.cpp new file mode 100644 index 0000000..7a973cc --- /dev/null +++ b/lib/Events/src/PCH.cpp @@ -0,0 +1,21 @@ +/* + Copyright 2020-2020 Amebis + Copyright 2016 GÉANT + + This file is part of GÉANTLink. + + GÉANTLink 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. + + GÉANTLink 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 GÉANTLink. If not, see . +*/ + +#include "PCH.h" diff --git a/lib/Events/src/PCH.h b/lib/Events/src/PCH.h new file mode 100644 index 0000000..b42ce38 --- /dev/null +++ b/lib/Events/src/PCH.h @@ -0,0 +1,31 @@ +/* + Copyright 2020-2020 Amebis + Copyright 2016 GÉANT + + This file is part of GÉANTLink. + + GÉANTLink 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. + + GÉANTLink 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 GÉANTLink. If not, see . +*/ + +#pragma once + +#include "../../../include/Version.h" + +#include +#include +#include + +#include + +#include diff --git a/lib/Events/src/Register.cpp b/lib/Events/src/Register.cpp new file mode 100644 index 0000000..3143c03 --- /dev/null +++ b/lib/Events/src/Register.cpp @@ -0,0 +1,164 @@ +/* + Copyright 2020-2020 Amebis + Copyright 2016 GÉANT + + This file is part of GÉANTLink. + + GÉANTLink 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. + + GÉANTLink 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 GÉANTLink. If not, see . +*/ + +#include "PCH.h" + +using namespace std; +using namespace winstd; + +HINSTANCE g_hInstance; + + +static void set_value(_In_ HKEY hKey, _In_opt_z_ LPCTSTR lpValueName, _In_ LPCTSTR sValue) +{ + LSTATUS s = RegSetValueEx(hKey, lpValueName, 0, REG_SZ, reinterpret_cast(sValue), (DWORD)((_tcslen(sValue) + 1) * sizeof(tstring::value_type))); + if (s != ERROR_SUCCESS) + throw win_runtime_error(s, "RegSetValueEx failed."); +} + + +static void set_value(_In_ HKEY hKey, _In_opt_z_ LPCTSTR lpValueName, _In_ const tstring &sValue) +{ + LSTATUS s = RegSetValueEx(hKey, lpValueName, 0, REG_SZ, reinterpret_cast(sValue.c_str()), (DWORD)((sValue.length() + 1) * sizeof(tstring::value_type))); + if (s != ERROR_SUCCESS) + throw win_runtime_error(s, "RegSetValueEx failed."); +} + + +static void set_value(_In_ HKEY hKey, _In_opt_z_ LPCTSTR lpValueName, _In_ DWORD dwValue) +{ + LSTATUS s = RegSetValueEx(hKey, lpValueName, 0, REG_DWORD, reinterpret_cast(&dwValue), sizeof(dwValue)); + if (s != ERROR_SUCCESS) + throw win_runtime_error(s, "RegSetValueEx failed."); +} + + +BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved) +{ + UNREFERENCED_PARAMETER(lpvReserved); + + if (fdwReason == DLL_PROCESS_ATTACH) { +#ifdef _DEBUG + //Sleep(10000); +#endif + g_hInstance = hinstDLL; + } else if (fdwReason == DLL_PROCESS_DETACH) + assert(!_CrtDumpMemoryLeaks()); + + return TRUE; +} + + +/// +/// Registers event source in Windows registry +/// +/// \returns S_OK if successful; E_FAIL otherwise +/// +STDAPI DllRegisterServer() +{ + try { + tstring sz, event_provider_name(_T(VENDOR_NAME_STR) _T("-") _T(PRODUCT_NAME_STR) _T("-EAPMethod")); + tstring_guid event_provider_guid(EAPMETHOD_TRACE_EVENT_PROVIDER); + + // Register event channels. + reg_key key_channels, key_channels_operational, key_channels_analytic; + if (!key_channels.open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WINEVT\\Channels"), 0, KEY_CREATE_SUB_KEY)) throw win_runtime_error(); + sprintf(sz, _T("%s/Operational"), event_provider_name.c_str()); + if (!key_channels_operational.create(key_channels, sz.c_str(), NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE)) throw win_runtime_error(); + set_value(key_channels_operational, _T("OwningPublisher") , event_provider_guid); + set_value(key_channels_operational, _T("Enabled") , (DWORD)0); + set_value(key_channels_operational, _T("Isolation") , (DWORD)0); + set_value(key_channels_operational, _T("ChannelAccess") , _T("O:BAG:SYD:(A;;0xf0007;;;SY)(A;;0x7;;;BA)(A;;0x7;;;SO)(A;;0x3;;;IU)(A;;0x3;;;SU)(A;;0x3;;;S-1-5-3)(A;;0x3;;;S-1-5-33)(A;;0x1;;;S-1-5-32-573)")); + set_value(key_channels_operational, _T("MaxSize") , (DWORD)1048576); + set_value(key_channels_operational, _T("MaxSizeUpper") , (DWORD)0); + set_value(key_channels_operational, _T("Retention") , (DWORD)0); + set_value(key_channels_operational, _T("AutoBackupLogFiles"), (DWORD)0); + set_value(key_channels_operational, _T("Type") , (DWORD)1); + sprintf(sz, _T("%s/Analytic"), event_provider_name.c_str()); + if (!key_channels_analytic.create(key_channels, sz.c_str(), NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE)) throw win_runtime_error(); + set_value(key_channels_analytic, _T("OwningPublisher"), event_provider_guid); + set_value(key_channels_analytic, _T("Enabled") , (DWORD)0); + set_value(key_channels_analytic, _T("Isolation") , (DWORD)0); + set_value(key_channels_analytic, _T("ChannelAccess") , _T("O:BAG:SYD:(A;;0xf0007;;;SY)(A;;0x7;;;BA)(A;;0x7;;;SO)(A;;0x3;;;IU)(A;;0x3;;;SU)(A;;0x3;;;S-1-5-3)(A;;0x3;;;S-1-5-33)(A;;0x1;;;S-1-5-32-573)")); + set_value(key_channels_analytic, _T("MaxSize") , (DWORD)1048576); + set_value(key_channels_analytic, _T("MaxSizeUpper") , (DWORD)0); + set_value(key_channels_analytic, _T("Retention") , (DWORD)4294967295); + set_value(key_channels_analytic, _T("Type") , (DWORD)2); + + // Register event publishers. + reg_key key_publishers, key_event_source; + if (!key_publishers.open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WINEVT\\Publishers"), 0, KEY_CREATE_SUB_KEY)) throw win_runtime_error(); + if (!key_event_source.create(key_publishers, event_provider_guid.c_str(), NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE)) throw win_runtime_error(); + set_value(key_event_source, NULL , event_provider_name); + if (!GetModuleFileName(g_hInstance, sz)) throw win_runtime_error("GetModuleFileName failed."); + set_value(key_event_source, _T("MessageFileName") , sz); + set_value(key_event_source, _T("ResourceFileName"), sz); + set_value(key_event_source, _T("Enabled") , (DWORD)1); + + // Bind channels and publishers. + reg_key key_channel_refs, key_channel_refs_operational, key_channel_refs_analytic; + if (!key_channel_refs.create(key_event_source, _T("ChannelReferences"), NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE)) throw win_runtime_error(); + if (!key_channel_refs_operational.create(key_channel_refs, _T("0"), NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE)) throw win_runtime_error(); + sprintf(sz, _T("%s/Operational"), event_provider_name.c_str()); + set_value(key_channel_refs_operational, NULL , sz); + set_value(key_channel_refs_operational, _T("Id") , (DWORD)16); + set_value(key_channel_refs_operational, _T("Flags"), (DWORD)0); + if (!key_channel_refs_analytic.create(key_channel_refs, _T("1"), NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE)) throw win_runtime_error(); + sprintf(sz, _T("%s/Analytic"), event_provider_name.c_str()); + set_value(key_channel_refs_analytic, NULL , sz); + set_value(key_channel_refs_analytic, _T("Id") , (DWORD)17); + set_value(key_channel_refs_analytic, _T("Flags"), (DWORD)0); + set_value(key_channel_refs, _T("Count"), (DWORD)2); + + return S_OK; + } catch(win_runtime_error &err) { + OutputDebugStr(_T("%hs (error %u)\n"), err.what(), err.number()); + return E_FAIL; + } catch(...) { + OutputDebugStr(_T("Registering DLL failed.\n")); + return E_FAIL; + } +} + + +/// +/// Unregisters event source from Windows registry +/// +/// \returns Always S_OK +/// +STDAPI DllUnregisterServer() +{ + // Unregister event publishers. + try { + reg_key key_publishers; + if (!key_publishers.open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WINEVT\\Publishers"), 0, KEY_READ)) throw win_runtime_error(); + key_publishers.delete_subkey(tstring_guid(EAPMETHOD_TRACE_EVENT_PROVIDER).c_str()); + } catch(...) {} + + // Unregister event channels. + try { + reg_key key_channels; + if (!key_channels.open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WINEVT\\Channels"), 0, KEY_READ)) throw win_runtime_error(); + key_channels.delete_subkey(_T(VENDOR_NAME_STR) _T("-") _T(PRODUCT_NAME_STR) _T("-EAPMethod/Operational")); + key_channels.delete_subkey(_T(VENDOR_NAME_STR) _T("-") _T(PRODUCT_NAME_STR) _T("-EAPMethod/Analytic")); + } catch(...) {} + + return S_OK; +} diff --git a/lib/WinStd b/lib/WinStd index 7c5f20d..85075cd 160000 --- a/lib/WinStd +++ b/lib/WinStd @@ -1 +1 @@ -Subproject commit 7c5f20d7563a6ab966164c0cdb48f8e1f64c4742 +Subproject commit 85075cd419df9488e13f5ebc8aaaf1d65c72ed66