diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..24b36b1
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "WTLHelper"]
+ path = WTLHelper
+ url = https://github.com/zodiacon/WTLHelper.git
diff --git a/WFPCore/WFPCore.cpp b/WFPCore/WFPCore.cpp
index ef88b41..b7627b4 100644
--- a/WFPCore/WFPCore.cpp
+++ b/WFPCore/WFPCore.cpp
@@ -3,3 +3,6 @@
#include "pch.h"
+#pragma comment(lib, "Fwpuclnt.lib")
+#pragma comment(lib, "Shlwapi.lib")
+
diff --git a/WFPCore/WFPCore.vcxproj b/WFPCore/WFPCore.vcxproj
index 898f378..f2eba94 100644
--- a/WFPCore/WFPCore.vcxproj
+++ b/WFPCore/WFPCore.vcxproj
@@ -78,6 +78,8 @@
true
Use
pch.h
+ MultiThreadedDebug
+ stdcpp20
@@ -95,6 +97,8 @@
true
Use
pch.h
+ MultiThreaded
+ stdcpp20
@@ -112,6 +116,8 @@
true
Use
pch.h
+ MultiThreadedDebug
+ stdcpp20
@@ -129,6 +135,8 @@
true
Use
pch.h
+ MultiThreaded
+ stdcpp20
diff --git a/WFPCore/WFPEngine.cpp b/WFPCore/WFPEngine.cpp
index 24d7f8a..1b63fb8 100644
--- a/WFPCore/WFPEngine.cpp
+++ b/WFPCore/WFPEngine.cpp
@@ -23,37 +23,6 @@ DWORD WFPEngine::LastError() const {
return m_LastError;
}
-std::vector WFPEngine::EnumSessions() const {
- HANDLE hEnum;
- std::vector info;
- m_LastError = FwpmSessionCreateEnumHandle(m_hEngine, nullptr, &hEnum);
- if (m_LastError != ERROR_SUCCESS)
- return info;
-
- UINT32 count;
- FWPM_SESSION** sessions;
- if ((m_LastError = FwpmSessionEnum(m_hEngine, hEnum, 128, &sessions, &count)) == ERROR_SUCCESS) {
- info.reserve(count);
- for (UINT32 i = 0; i < count; i++) {
- auto session = sessions[i];
- WFPSessionInfo si;
- si.Name = ParseMUIString(session->displayData.name);
- si.Desc = ParseMUIString(session->displayData.description);
- si.SessionKey = session->sessionKey;
- si.ProcessId = session->processId;
- si.UserName = session->username;
- si.Flags = session->flags;
- ::CopySid(sizeof(si.Sid), (PSID)si.Sid, session->sid);
- si.KernelMode = session->kernelMode;
- info.emplace_back(std::move(si));
- }
- FwpmFreeMemory((void**)&sessions);
- }
- m_LastError = FwpmSessionDestroyEnumHandle(m_hEngine, hEnum);
-
- return info;
-}
-
std::vector WFPEngine::EnumLayers() const {
HANDLE hEnum;
std::vector info;
@@ -89,6 +58,34 @@ std::vector WFPEngine::EnumLayers() const {
return info;
}
+std::vector WFPEngine::EnumSubLayers() const {
+ HANDLE hEnum;
+ std::vector info;
+ m_LastError = FwpmSubLayerCreateEnumHandle(m_hEngine, nullptr, &hEnum);
+ if (m_LastError)
+ return info;
+ FWPM_SUBLAYER** layers;
+ UINT32 count;
+ m_LastError = FwpmSubLayerEnum(m_hEngine, hEnum, 256, &layers, &count);
+ if (m_LastError == ERROR_SUCCESS) {
+ info.reserve(count);
+ for (UINT32 i = 0; i < count; i++) {
+ auto layer = layers[i];
+ WFPSubLayerInfo li;
+ li.Name = ParseMUIString(layer->displayData.name);
+ li.Desc = ParseMUIString(layer->displayData.description);
+ li.SubLayerKey = layer->subLayerKey;
+ li.Flags = layer->flags;
+ li.Weight = layer->weight;
+ li.ProviderKey = layer->providerKey ? *layer->providerKey : GUID_NULL;
+ li.ProviderData.resize(layer->providerData.size);
+ memcpy(li.ProviderData.data(), layer->providerData.data, layer->providerData.size);
+ info.emplace_back(std::move(li));
+ }
+ }
+ return info;
+}
+
std::vector WFPEngine::EnumProviders(bool includeData) const {
HANDLE hEnum;
std::vector info;
@@ -143,41 +140,6 @@ std::vector WFPEngine::EnumCallouts() const {
return info;
}
-std::vector WFPEngine::EnumFilters(bool includeConditions) const {
- HANDLE hEnum;
- std::vector info;
- m_LastError = FwpmFilterCreateEnumHandle(m_hEngine, nullptr, &hEnum);
- if (m_LastError)
- return info;
- FWPM_FILTER** filters;
- UINT32 count;
- m_LastError = FwpmFilterEnum(m_hEngine, hEnum, 4096, &filters, &count);
- if (m_LastError == ERROR_SUCCESS) {
- info.reserve(count);
- for (UINT32 i = 0; i < count; i++) {
- auto filter = filters[i];
- WFPFilterInfo fi;
- fi.FilterKey = filter->filterKey;
- fi.FilterId = filter->filterId;
- fi.ProviderKey = filter->providerKey ? *filter->providerKey : GUID_NULL;
- fi.Name = ParseMUIString(filter->displayData.name);
- fi.Desc = ParseMUIString(filter->displayData.description);
- fi.ConditionCount = filter->numFilterConditions;
- fi.EffectiveWeight = *(WFPValue*)&filter->effectiveWeight;
- fi.LayerKey = filter->layerKey;
- fi.SubLayerKey = filter->subLayerKey;
- fi.Weight = *(WFPValue*)&filter->weight;
- if (includeConditions) {
- // TODO
- }
- info.emplace_back(std::move(fi));
- }
- FwpmFreeMemory((void**)&filters);
- m_LastError = FwpmFilterDestroyEnumHandle(m_hEngine, hEnum);
- }
- return info;
-}
-
WFPProviderInfo WFPEngine::GetProviderByKey(GUID const& guid) const {
FWPM_PROVIDER* provider;
m_LastError = FwpmProviderGetByKey(m_hEngine, &guid, &provider);
@@ -202,7 +164,6 @@ WFPProviderInfo WFPEngine::InitProvider(FWPM_PROVIDER* p, bool includeData) {
return pi;
}
-
std::wstring WFPEngine::ParseMUIString(PCWSTR input) {
if (input == nullptr)
return L"";
diff --git a/WFPCore/WFPEngine.h b/WFPCore/WFPEngine.h
index fa1bf43..fed5f64 100644
--- a/WFPCore/WFPEngine.h
+++ b/WFPCore/WFPEngine.h
@@ -3,6 +3,8 @@
#include
#include
#include
+#include
+#include
struct WFPSessionInfo {
GUID SessionKey;
@@ -101,6 +103,16 @@ struct WFPLayerInfo {
UINT16 LayerId;
};
+struct WFPSubLayerInfo {
+ GUID SubLayerKey;
+ std::wstring Name;
+ std::wstring Desc;
+ UINT32 Flags;
+ GUID ProviderKey;
+ std::vector ProviderData;
+ UINT16 Weight;
+};
+
enum class WFPMatchType {
EQUAL,
GREATER,
@@ -195,11 +207,78 @@ public:
DWORD LastError() const;
//
- // enumrations
+ // enumerations
//
- std::vector EnumSessions() const;
- std::vector EnumFilters(bool includeConditions = false) const;
+
+ template requires std::is_base_of_v
+ std::vector EnumSessions() const {
+ HANDLE hEnum;
+ std::vector info;
+ m_LastError = FwpmSessionCreateEnumHandle(m_hEngine, nullptr, &hEnum);
+ if (m_LastError != ERROR_SUCCESS)
+ return info;
+
+ UINT32 count;
+ FWPM_SESSION** sessions;
+ if ((m_LastError = FwpmSessionEnum(m_hEngine, hEnum, 128, &sessions, &count)) == ERROR_SUCCESS) {
+ info.reserve(count);
+ for (UINT32 i = 0; i < count; i++) {
+ auto session = sessions[i];
+ TSession si;
+ si.Name = ParseMUIString(session->displayData.name);
+ si.Desc = ParseMUIString(session->displayData.description);
+ si.SessionKey = session->sessionKey;
+ si.ProcessId = session->processId;
+ si.UserName = session->username;
+ si.Flags = session->flags;
+ ::CopySid(sizeof(si.Sid), (PSID)si.Sid, session->sid);
+ si.KernelMode = session->kernelMode;
+ info.emplace_back(std::move(si));
+ }
+ FwpmFreeMemory((void**)&sessions);
+ }
+ m_LastError = FwpmSessionDestroyEnumHandle(m_hEngine, hEnum);
+
+ return info;
+ }
+
+ template requires std::is_base_of_v
+ std::vector EnumFilters(bool includeConditions = false) const {
+ HANDLE hEnum;
+ std::vector info;
+ m_LastError = FwpmFilterCreateEnumHandle(m_hEngine, nullptr, &hEnum);
+ if (m_LastError)
+ return info;
+ FWPM_FILTER** filters;
+ UINT32 count;
+ m_LastError = FwpmFilterEnum(m_hEngine, hEnum, 4096, &filters, &count);
+ if (m_LastError == ERROR_SUCCESS) {
+ info.reserve(count);
+ for (UINT32 i = 0; i < count; i++) {
+ auto filter = filters[i];
+ TFilter fi;
+ fi.FilterKey = filter->filterKey;
+ fi.FilterId = filter->filterId;
+ fi.ProviderKey = filter->providerKey ? *filter->providerKey : GUID_NULL;
+ fi.Name = ParseMUIString(filter->displayData.name);
+ fi.Desc = ParseMUIString(filter->displayData.description);
+ fi.ConditionCount = filter->numFilterConditions;
+ fi.EffectiveWeight = *(WFPValue*)&filter->effectiveWeight;
+ fi.LayerKey = filter->layerKey;
+ fi.SubLayerKey = filter->subLayerKey;
+ fi.Weight = *(WFPValue*)&filter->weight;
+ if (includeConditions) {
+ // TODO
+ }
+ info.emplace_back(std::move(fi));
+ }
+ FwpmFreeMemory((void**)&filters);
+ m_LastError = FwpmFilterDestroyEnumHandle(m_hEngine, hEnum);
+ }
+ return info;
+ }
std::vector EnumLayers() const;
+ std::vector EnumSubLayers() const;
std::vector EnumProviders(bool includeData = false) const;
std::vector EnumCallouts() const;
diff --git a/WFPCore/pch.h b/WFPCore/pch.h
index 8de3c08..208a333 100644
--- a/WFPCore/pch.h
+++ b/WFPCore/pch.h
@@ -14,5 +14,7 @@
#include
#include
#include
+#include
+#include
#endif //PCH_H
diff --git a/WFPExplorer.sln b/WFPExplorer.sln
index 9931261..bbcfcea 100644
--- a/WFPExplorer.sln
+++ b/WFPExplorer.sln
@@ -9,38 +9,66 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WFPExplorer", "WFPExplorer\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WFPCore", "WFPCore\WFPCore.vcxproj", "{1EC9C4CA-34FD-4BE0-9662-9D92C53B9A90}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WTLHelper", "WTLHelper\WTLHelper.vcxproj", "{AE53419F-A769-4548-8E15-E311904DF7DF}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
+ Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {838BF7A3-0019-47F4-9DA8-2DC1194BF8CB}.Debug|ARM64.ActiveCfg = Debug|x64
+ {838BF7A3-0019-47F4-9DA8-2DC1194BF8CB}.Debug|ARM64.Build.0 = Debug|x64
{838BF7A3-0019-47F4-9DA8-2DC1194BF8CB}.Debug|x64.ActiveCfg = Debug|x64
{838BF7A3-0019-47F4-9DA8-2DC1194BF8CB}.Debug|x64.Build.0 = Debug|x64
{838BF7A3-0019-47F4-9DA8-2DC1194BF8CB}.Debug|x86.ActiveCfg = Debug|Win32
{838BF7A3-0019-47F4-9DA8-2DC1194BF8CB}.Debug|x86.Build.0 = Debug|Win32
+ {838BF7A3-0019-47F4-9DA8-2DC1194BF8CB}.Release|ARM64.ActiveCfg = Release|x64
+ {838BF7A3-0019-47F4-9DA8-2DC1194BF8CB}.Release|ARM64.Build.0 = Release|x64
{838BF7A3-0019-47F4-9DA8-2DC1194BF8CB}.Release|x64.ActiveCfg = Release|x64
{838BF7A3-0019-47F4-9DA8-2DC1194BF8CB}.Release|x64.Build.0 = Release|x64
{838BF7A3-0019-47F4-9DA8-2DC1194BF8CB}.Release|x86.ActiveCfg = Release|Win32
{838BF7A3-0019-47F4-9DA8-2DC1194BF8CB}.Release|x86.Build.0 = Release|Win32
+ {67BC52CE-A4B4-4C3A-85B6-71B5C70BC2E0}.Debug|ARM64.ActiveCfg = Debug|x64
+ {67BC52CE-A4B4-4C3A-85B6-71B5C70BC2E0}.Debug|ARM64.Build.0 = Debug|x64
{67BC52CE-A4B4-4C3A-85B6-71B5C70BC2E0}.Debug|x64.ActiveCfg = Debug|x64
{67BC52CE-A4B4-4C3A-85B6-71B5C70BC2E0}.Debug|x64.Build.0 = Debug|x64
{67BC52CE-A4B4-4C3A-85B6-71B5C70BC2E0}.Debug|x86.ActiveCfg = Debug|Win32
{67BC52CE-A4B4-4C3A-85B6-71B5C70BC2E0}.Debug|x86.Build.0 = Debug|Win32
+ {67BC52CE-A4B4-4C3A-85B6-71B5C70BC2E0}.Release|ARM64.ActiveCfg = Release|x64
+ {67BC52CE-A4B4-4C3A-85B6-71B5C70BC2E0}.Release|ARM64.Build.0 = Release|x64
{67BC52CE-A4B4-4C3A-85B6-71B5C70BC2E0}.Release|x64.ActiveCfg = Release|x64
{67BC52CE-A4B4-4C3A-85B6-71B5C70BC2E0}.Release|x64.Build.0 = Release|x64
{67BC52CE-A4B4-4C3A-85B6-71B5C70BC2E0}.Release|x86.ActiveCfg = Release|Win32
{67BC52CE-A4B4-4C3A-85B6-71B5C70BC2E0}.Release|x86.Build.0 = Release|Win32
+ {1EC9C4CA-34FD-4BE0-9662-9D92C53B9A90}.Debug|ARM64.ActiveCfg = Debug|x64
+ {1EC9C4CA-34FD-4BE0-9662-9D92C53B9A90}.Debug|ARM64.Build.0 = Debug|x64
{1EC9C4CA-34FD-4BE0-9662-9D92C53B9A90}.Debug|x64.ActiveCfg = Debug|x64
{1EC9C4CA-34FD-4BE0-9662-9D92C53B9A90}.Debug|x64.Build.0 = Debug|x64
{1EC9C4CA-34FD-4BE0-9662-9D92C53B9A90}.Debug|x86.ActiveCfg = Debug|Win32
{1EC9C4CA-34FD-4BE0-9662-9D92C53B9A90}.Debug|x86.Build.0 = Debug|Win32
+ {1EC9C4CA-34FD-4BE0-9662-9D92C53B9A90}.Release|ARM64.ActiveCfg = Release|x64
+ {1EC9C4CA-34FD-4BE0-9662-9D92C53B9A90}.Release|ARM64.Build.0 = Release|x64
{1EC9C4CA-34FD-4BE0-9662-9D92C53B9A90}.Release|x64.ActiveCfg = Release|x64
{1EC9C4CA-34FD-4BE0-9662-9D92C53B9A90}.Release|x64.Build.0 = Release|x64
{1EC9C4CA-34FD-4BE0-9662-9D92C53B9A90}.Release|x86.ActiveCfg = Release|Win32
{1EC9C4CA-34FD-4BE0-9662-9D92C53B9A90}.Release|x86.Build.0 = Release|Win32
+ {AE53419F-A769-4548-8E15-E311904DF7DF}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {AE53419F-A769-4548-8E15-E311904DF7DF}.Debug|ARM64.Build.0 = Debug|ARM64
+ {AE53419F-A769-4548-8E15-E311904DF7DF}.Debug|x64.ActiveCfg = Debug|x64
+ {AE53419F-A769-4548-8E15-E311904DF7DF}.Debug|x64.Build.0 = Debug|x64
+ {AE53419F-A769-4548-8E15-E311904DF7DF}.Debug|x86.ActiveCfg = Debug|Win32
+ {AE53419F-A769-4548-8E15-E311904DF7DF}.Debug|x86.Build.0 = Debug|Win32
+ {AE53419F-A769-4548-8E15-E311904DF7DF}.Release|ARM64.ActiveCfg = Release|ARM64
+ {AE53419F-A769-4548-8E15-E311904DF7DF}.Release|ARM64.Build.0 = Release|ARM64
+ {AE53419F-A769-4548-8E15-E311904DF7DF}.Release|x64.ActiveCfg = Release|x64
+ {AE53419F-A769-4548-8E15-E311904DF7DF}.Release|x64.Build.0 = Release|x64
+ {AE53419F-A769-4548-8E15-E311904DF7DF}.Release|x86.ActiveCfg = Release|Win32
+ {AE53419F-A769-4548-8E15-E311904DF7DF}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/WFPExplorer/Interfaces.h b/WFPExplorer/Interfaces.h
new file mode 100644
index 0000000..58860f2
--- /dev/null
+++ b/WFPExplorer/Interfaces.h
@@ -0,0 +1,4 @@
+#pragma once
+
+struct IMainFrame abstract {
+};
diff --git a/WFPExplorer/MainFrm.cpp b/WFPExplorer/MainFrm.cpp
index 85e9d83..ff98d26 100644
--- a/WFPExplorer/MainFrm.cpp
+++ b/WFPExplorer/MainFrm.cpp
@@ -5,7 +5,7 @@
#include "pch.h"
#include "resource.h"
#include "AboutDlg.h"
-#include "View.h"
+#include "SessionsView.h"
#include "MainFrm.h"
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) {
@@ -20,10 +20,15 @@ BOOL CMainFrame::OnIdle() {
}
LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
+ if (!m_Engine.Open()) {
+ AtlMessageBox(nullptr, L"Failed to open WFP Engine", IDR_MAINFRAME, MB_ICONERROR);
+ return -1;
+ }
+
CreateSimpleStatusBar();
m_hWndClient = m_view.Create(m_hWnd, rcDefault, nullptr,
- WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
+ WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0);
UISetCheck(ID_VIEW_STATUS_BAR, 1);
CMessageLoop* pLoop = _Module.GetMessageLoop();
@@ -35,6 +40,9 @@ LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/
CMenuHandle menuMain = GetMenu();
m_view.SetWindowMenu(menuMain.GetSubMenu(WINDOW_MENU_POSITION));
+ if (!m_Engine.Open()) {
+ AtlMessageBox(nullptr, L"Failed to open WFP Engine", IDR_MAINFRAME, MB_ICONERROR);
+ }
return 0;
}
@@ -53,9 +61,9 @@ LRESULT CMainFrame::OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCt
}
LRESULT CMainFrame::OnFileNew(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
- CView* pView = new CView;
+ auto pView = new CSessionsView(this, m_Engine);
pView->Create(m_view, rcDefault, nullptr, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0);
- m_view.AddPage(pView->m_hWnd, _T("Document"));
+ m_view.AddPage(pView->m_hWnd, _T("Sessions"));
// TODO: add code to initialize document
diff --git a/WFPExplorer/MainFrm.h b/WFPExplorer/MainFrm.h
index e649b6e..323b878 100644
--- a/WFPExplorer/MainFrm.h
+++ b/WFPExplorer/MainFrm.h
@@ -1,15 +1,14 @@
-// MainFrm.h : interface of the CMainFrame class
-//
-/////////////////////////////////////////////////////////////////////////////
-
#pragma once
+#include
+#include "Interfaces.h"
+
class CMainFrame :
public CFrameWindowImpl,
public CAutoUpdateUI,
public CMessageFilter,
- public CIdleHandler
-{
+ public IMainFrame,
+ public CIdleHandler {
public:
DECLARE_FRAME_WND_CLASS(L"WFPExplorerMainWndClass", IDR_MAINFRAME)
@@ -46,4 +45,6 @@ public:
LRESULT OnWindowClose(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
LRESULT OnWindowCloseAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
LRESULT OnWindowActivate(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
+
+ WFPEngine m_Engine;
};
diff --git a/WFPExplorer/ProcessHelper.cpp b/WFPExplorer/ProcessHelper.cpp
new file mode 100644
index 0000000..80f6ba0
--- /dev/null
+++ b/WFPExplorer/ProcessHelper.cpp
@@ -0,0 +1,31 @@
+#include "pch.h"
+#include "ProcessHelper.h"
+
+CString ProcessHelper::GetProcessName(DWORD pid) {
+ static std::unordered_map processes;
+ CString name;
+ HANDLE hProcess = ::OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid);
+ if (hProcess) {
+ WCHAR path[MAX_PATH];
+ DWORD size = _countof(path);
+ if (::QueryFullProcessImageName(hProcess, 0, path, &size))
+ name = wcsrchr(path, L'\\') + 1;
+ ::CloseHandle(hProcess);
+ }
+ if(name.IsEmpty()) {
+ if (processes.empty()) {
+ auto hSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+ ATLASSERT(hSnap != INVALID_HANDLE_VALUE);
+ PROCESSENTRY32 pe;
+ pe.dwSize = sizeof(pe);
+ ::Process32First(hSnap, &pe);
+ while (::Process32Next(hSnap, &pe)) {
+ if (wcsrchr(pe.szExeFile, L'\\') == nullptr)
+ processes.insert({ pe.th32ProcessID, pe.szExeFile });
+ }
+ ::CloseHandle(hSnap);
+ }
+ name = processes.at(pid);
+ }
+ return name;
+}
diff --git a/WFPExplorer/ProcessHelper.h b/WFPExplorer/ProcessHelper.h
new file mode 100644
index 0000000..79695d2
--- /dev/null
+++ b/WFPExplorer/ProcessHelper.h
@@ -0,0 +1,6 @@
+#pragma once
+
+struct ProcessHelper abstract final {
+ static CString GetProcessName(DWORD pid);
+};
+
diff --git a/WFPExplorer/SessionsView.cpp b/WFPExplorer/SessionsView.cpp
new file mode 100644
index 0000000..a682be3
--- /dev/null
+++ b/WFPExplorer/SessionsView.cpp
@@ -0,0 +1,57 @@
+// View.cpp : implementation of the CSessionsView class
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "pch.h"
+#include "resource.h"
+#include "SessionsView.h"
+#include
+#include "StringHelper.h"
+#include "ProcessHelper.h"
+
+CSessionsView::CSessionsView(IMainFrame* frame, WFPEngine& engine) : CFrameView(frame), m_Engine(engine) {
+}
+
+BOOL CSessionsView::PreTranslateMessage(MSG* pMsg) {
+ pMsg;
+ return FALSE;
+}
+
+void CSessionsView::Refresh() {
+ m_Sessions = m_Engine.EnumSessions();
+ m_List.SetItemCountEx((int)m_Sessions.size(), LVSICF_NOSCROLL);
+}
+
+CString CSessionsView::GetColumnText(HWND, int row, int col) {
+ auto& session = m_Sessions[row];
+ switch (GetColumnManager(m_List)->GetColumnTag(col)) {
+ case ColumnType::Key: return StringHelper::GuidToString(session.SessionKey);
+ case ColumnType::Name: return session.Name.c_str();
+ case ColumnType::Desc: return session.Desc.c_str();
+ case ColumnType::ProcessId: return std::to_wstring(session.ProcessId).c_str();
+ case ColumnType::Flags: return std::to_wstring(session.Flags).c_str();
+ case ColumnType::ProcessName:
+ if (session.ProcessName.IsEmpty())
+ session.ProcessName = ProcessHelper::GetProcessName(session.ProcessId);
+ return session.ProcessName;
+ }
+ return CString();
+}
+
+LRESULT CSessionsView::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
+ m_hWndClient = m_List.Create(m_hWnd, rcDefault, nullptr,
+ WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | LVS_OWNERDATA | LVS_REPORT | LVS_SHOWSELALWAYS);
+ m_List.SetExtendedListViewStyle(LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
+
+ auto cm = GetColumnManager(m_List);
+ cm->AddColumn(L"Session Key", 0, 250, ColumnType::Key);
+ cm->AddColumn(L"PID", LVCFMT_RIGHT, 90, ColumnType::ProcessId);
+ cm->AddColumn(L"Process Name", LVCFMT_LEFT, 180, ColumnType::ProcessName);
+ cm->AddColumn(L"Flags", LVCFMT_RIGHT, 80, ColumnType::Flags);
+ cm->AddColumn(L"Session Name", 0, 180, ColumnType::Name);
+ cm->AddColumn(L"Description", 0, 180, ColumnType::Desc);
+
+ Refresh();
+
+ return 0;
+}
diff --git a/WFPExplorer/SessionsView.h b/WFPExplorer/SessionsView.h
new file mode 100644
index 0000000..57dbd28
--- /dev/null
+++ b/WFPExplorer/SessionsView.h
@@ -0,0 +1,48 @@
+#pragma once
+
+#include
+#include
+#include "Interfaces.h"
+#include
+
+class WFPEngine;
+
+class CSessionsView :
+ public CFrameView,
+ public CVirtualListView {
+public:
+ CSessionsView(IMainFrame* frame, WFPEngine& engine);
+
+ DECLARE_WND_CLASS(nullptr)
+
+ BOOL PreTranslateMessage(MSG* pMsg);
+ void Refresh();
+
+ CString GetColumnText(HWND, int row, int col);
+
+ BEGIN_MSG_MAP(CSessionsView)
+ MESSAGE_HANDLER(WM_CREATE, OnCreate)
+ CHAIN_MSG_MAP(CVirtualListView)
+ CHAIN_MSG_MAP(BaseFrame)
+ END_MSG_MAP()
+
+// Handler prototypes (uncomment arguments if needed):
+// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
+// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
+// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
+
+private:
+ enum class ColumnType {
+ Key, Name, Desc, Flags, ProcessId, ProcessName,
+ };
+ struct Session : WFPSessionInfo {
+ CString ProcessName;
+ };
+
+ LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
+
+ WFPEngine& m_Engine;
+
+ CListViewCtrl m_List;
+ std::vector m_Sessions;
+};
diff --git a/WFPExplorer/StringHelper.cpp b/WFPExplorer/StringHelper.cpp
new file mode 100644
index 0000000..2d68f4b
--- /dev/null
+++ b/WFPExplorer/StringHelper.cpp
@@ -0,0 +1,7 @@
+#include "pch.h"
+#include "StringHelper.h"
+
+CString StringHelper::GuidToString(GUID const& guid) {
+ WCHAR sguid[64];
+ return ::StringFromGUID2(guid, sguid, _countof(sguid)) ? sguid : L"";
+}
diff --git a/WFPExplorer/StringHelper.h b/WFPExplorer/StringHelper.h
new file mode 100644
index 0000000..9e6204b
--- /dev/null
+++ b/WFPExplorer/StringHelper.h
@@ -0,0 +1,6 @@
+#pragma once
+
+struct StringHelper abstract final {
+ static CString GuidToString(GUID const& guid);
+};
+
diff --git a/WFPExplorer/View.cpp b/WFPExplorer/View.cpp
deleted file mode 100644
index bb7f278..0000000
--- a/WFPExplorer/View.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-// View.cpp : implementation of the CView class
-//
-/////////////////////////////////////////////////////////////////////////////
-
-#include "pch.h"
-#include "resource.h"
-#include "View.h"
-
-BOOL CView::PreTranslateMessage(MSG* pMsg) {
- pMsg;
- return FALSE;
-}
-
-void CView::OnFinalMessage(HWND /*hWnd*/) {
- delete this;
-}
-
-LRESULT CView::OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
- CPaintDC dc(m_hWnd);
-
- //TODO: Add your drawing code here
-
- return 0;
-}
diff --git a/WFPExplorer/View.h b/WFPExplorer/View.h
deleted file mode 100644
index 46585eb..0000000
--- a/WFPExplorer/View.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// View.h : interface of the CView class
-//
-/////////////////////////////////////////////////////////////////////////////
-
-#pragma once
-
-class CView : public CWindowImpl
-{
-public:
- DECLARE_WND_CLASS(nullptr)
-
- BOOL PreTranslateMessage(MSG* pMsg);
-
- virtual void OnFinalMessage(HWND /*hWnd*/);
-
- BEGIN_MSG_MAP(CView)
- MESSAGE_HANDLER(WM_PAINT, OnPaint)
- END_MSG_MAP()
-
-// Handler prototypes (uncomment arguments if needed):
-// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
-// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
-// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
-
- LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
-};
diff --git a/WFPExplorer/WFPExplorer.cpp b/WFPExplorer/WFPExplorer.cpp
index 9af5f3a..e3a3b0a 100644
--- a/WFPExplorer/WFPExplorer.cpp
+++ b/WFPExplorer/WFPExplorer.cpp
@@ -4,6 +4,11 @@
#include "pch.h"
#include "resource.h"
#include "MainFrm.h"
+#include
+
+#pragma comment(lib, "Fwpuclnt.lib")
+#pragma comment(lib, "Shlwapi.lib")
+
CAppModule _Module;
@@ -26,7 +31,7 @@ int Run(LPTSTR /*lpstrCmdLine*/ = nullptr, int nCmdShow = SW_SHOWDEFAULT) {
return nRet;
}
-int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) {
+int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) {
HRESULT hRes = ::CoInitialize(nullptr);
ATLASSERT(SUCCEEDED(hRes));
@@ -35,6 +40,8 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lp
hRes = _Module.Init(nullptr, hInstance);
ATLASSERT(SUCCEEDED(hRes));
+ ThemeHelper::Init();
+
int nRet = Run(lpstrCmdLine, nCmdShow);
_Module.Term();
diff --git a/WFPExplorer/WFPExplorer.vcxproj b/WFPExplorer/WFPExplorer.vcxproj
index bc5b95c..00f5852 100644
--- a/WFPExplorer/WFPExplorer.vcxproj
+++ b/WFPExplorer/WFPExplorer.vcxproj
@@ -21,6 +21,7 @@
17.0
{67BC52CE-A4B4-4C3A-85B6-71B5C70BC2E0}
+ 10.0
@@ -87,6 +88,9 @@
Disabled
_WINDOWS;STRICT;_DEBUG;%(PreprocessorDefinitions)
pch.h
+ ..\WTLHelper;..\WFPCore
+ stdcpp20
+ false
Windows
@@ -119,6 +123,9 @@
Disabled
WIN32;_WINDOWS;STRICT;_DEBUG;%(PreprocessorDefinitions)
pch.h
+ ..\WTLHelper;..\WFPCore
+ stdcpp20
+ false
Windows
@@ -151,6 +158,9 @@
WIN32;_WINDOWS;STRICT;NDEBUG;%(PreprocessorDefinitions)
pch.h
+ ..\WTLHelper;..\WFPCore
+ stdcpp20
+ false
Windows
@@ -182,6 +192,9 @@
_WINDOWS;STRICT;NDEBUG;%(PreprocessorDefinitions)
pch.h
+ ..\WTLHelper;..\WFPCore
+ stdcpp20
+ false
Windows
@@ -212,15 +225,20 @@
Create
Create
-
+
+
+
+
+
-
+
+
@@ -242,15 +260,20 @@
{1ec9c4ca-34fd-4be0-9662-9d92c53b9a90}
+
+ {ae53419f-a769-4548-8e15-e311904df7df}
+
+
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
\ No newline at end of file
diff --git a/WFPExplorer/WFPExplorer.vcxproj.filters b/WFPExplorer/WFPExplorer.vcxproj.filters
index d43d2f1..3239d39 100644
--- a/WFPExplorer/WFPExplorer.vcxproj.filters
+++ b/WFPExplorer/WFPExplorer.vcxproj.filters
@@ -16,6 +16,12 @@
{dd3ee917-d543-4f76-9565-2c62be172421}
+
+ {badfa682-db92-4619-8c6c-b99b2a803286}
+
+
+ {f00a7e40-bce0-4e4b-98eb-144534e3639f}
+
@@ -27,10 +33,16 @@
Source Files
-
+
+ Dialogs
+
+
+ Views
+
+
Source Files
-
+
Source Files
@@ -41,13 +53,22 @@
Header Files
-
+
Header Files
+ Dialogs
+
+
+ Views
+
+
Header Files
-
+
+ Header Files
+
+
Header Files
diff --git a/WFPExplorer/packages.config b/WFPExplorer/packages.config
index 3b4929a..0f0aeea 100644
--- a/WFPExplorer/packages.config
+++ b/WFPExplorer/packages.config
@@ -1,4 +1,5 @@
+
\ No newline at end of file
diff --git a/WFPExplorer/pch.h b/WFPExplorer/pch.h
index e9d496e..a5f3ab5 100644
--- a/WFPExplorer/pch.h
+++ b/WFPExplorer/pch.h
@@ -1,13 +1,8 @@
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
#pragma once
// Change these values to use different versions
-#define WINVER 0x0601
-#define _WIN32_WINNT 0x0601
+#define WINVER 0x0603
+#define _WIN32_WINNT 0x0603
#define _WIN32_IE 0x0700
#define _RICHEDIT_VER 0x0500
@@ -18,15 +13,20 @@
extern CAppModule _Module;
#include
-
#include
#include
#include
#include
#include
+#include
#include
#include
+#include
#include
+#include
+#include
+#include
+#include
#if defined _M_IX86
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
diff --git a/WTLHelper b/WTLHelper
new file mode 160000
index 0000000..d5d71a8
--- /dev/null
+++ b/WTLHelper
@@ -0,0 +1 @@
+Subproject commit d5d71a8c1eab443027097bc2840507a3033d4626
diff --git a/wfpc/wfpc.vcxproj b/wfpc/wfpc.vcxproj
index bfe3f01..ca2ed32 100644
--- a/wfpc/wfpc.vcxproj
+++ b/wfpc/wfpc.vcxproj
@@ -78,6 +78,8 @@
true
Use
pch.h
+ MultiThreadedDebug
+ stdcpp20
Console
@@ -94,6 +96,8 @@
true
Use
pch.h
+ MultiThreaded
+ stdcpp20
Console
@@ -110,6 +114,8 @@
true
Use
pch.h
+ MultiThreadedDebug
+ stdcpp20
Console
@@ -126,6 +132,8 @@
true
Use
pch.h
+ MultiThreaded
+ stdcpp20
Console