1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #ifndef CWINDOWSFIREWALL_H
- #define CWINDOWSFIREWALL_H
- #include <windows.h>
- #include <netfw.h>
- #include <QString>
- #include <vector>
- #include <thread>
- class CProcessData
- {
- public:
- DWORD pid = 0;
- std::wstring sExeName = L"";
- std::wstring sExePath = L"";
- bool bDisabled = false;
- };
- class CWindowsFireWall
- {
- public:
- CWindowsFireWall()=delete;
- CWindowsFireWall(DWORD pid, bool bcheck = true);
- ~CWindowsFireWall();
- void removeLastRules();
- private:
- bool init();
- bool setWallOn();
- bool disableAllApp();
- void cleanup();
- bool getAllAppNameList(std::vector<CProcessData> &vAppList);
- HRESULT WFCOMInitialize(INetFwPolicy2** ppNetFwPolicy2);
- void setAllRulesEnabled(VARIANT_BOOL bEnable);
- void threadProc();
- void checkInprogressFireWall();
- void uploadAppLog(std::vector<CProcessData> &vAppList);
- void checkRulesIsEnabled();
- std::thread *m_pThrd;
- DWORD m_wthreadID;
- bool m_bIsRun = true;
- HRESULT m_comInit = E_FAIL;
- INetFwPolicy2 *m_pNetFwPolicy2 = NULL;
- QString m_sErrMsg;
- std::vector<std::wstring> m_vDisableRuleNames;
- VARIANT_BOOL m_fw_profile2_domain_enabled = VARIANT_TRUE;
- VARIANT_BOOL m_fw_profile2_private_enabled = VARIANT_TRUE;
- VARIANT_BOOL m_fw_profile2_public_enabled = VARIANT_TRUE;
- bool m_bModifyFireWall = false;
- DWORD m_pid = 0;
- const int m_inprogressCheckSeconds = 60*5;
- bool m_bcheck = true;
- };
- extern std::shared_ptr<CWindowsFireWall> g_windowsFireWallPtr;
- #endif // CWINDOWSFIREWALL_H
|