From 5188c7d41f63a1c7939e5b5f7643dfd886df4d18 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 25 Nov 2020 20:06:43 -0800 Subject: [PATCH] com & com security already initialized by here --- osdep/EthernetTap.cpp | 3 ++- osdep/WindowsEthernetTap.cpp | 8 +------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/osdep/EthernetTap.cpp b/osdep/EthernetTap.cpp index 4f3d20f40..ab3f7acfc 100644 --- a/osdep/EthernetTap.cpp +++ b/osdep/EthernetTap.cpp @@ -112,7 +112,7 @@ std::shared_ptr EthernetTap::newInstance( -1, NULL, NULL, - RPC_C_AUTHN_LEVEL_DEFAULT, + RPC_C_AUTHN_LEVEL_PKT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, @@ -120,6 +120,7 @@ std::shared_ptr EthernetTap::newInstance( ); if (FAILED(hres)) { CoUninitialize(); + fprintf(stderr, "WinEthernetTap: Failed to initialize security"); throw std::runtime_error("WinEthernetTap: Failed to initialize security"); } _comInit = true; diff --git a/osdep/WindowsEthernetTap.cpp b/osdep/WindowsEthernetTap.cpp index 71c7c503d..ab6ea6194 100644 --- a/osdep/WindowsEthernetTap.cpp +++ b/osdep/WindowsEthernetTap.cpp @@ -816,13 +816,7 @@ void WindowsEthernetTap::setFriendlyName(const char *dn) RegCloseKey(ifp); } - HRESULT hr = CoInitialize(nullptr); - if (hr != S_OK) return; - CoInitializeSecurity(NULL, -1, NULL, NULL, - RPC_C_AUTHN_LEVEL_PKT, - RPC_C_IMP_LEVEL_IMPERSONATE, - NULL, EOAC_NONE, NULL); - if (hr != S_OK) return; + HRESULT hr = S_OK; INetSharingManager *nsm; hr = CoCreateInstance(__uuidof(NetSharingManager), NULL, CLSCTX_ALL, __uuidof(INetSharingManager), (void**)&nsm);