├── FirewallInstaller ├── CABARC.EXE ├── FirewallInstaller.cpp ├── FirewallInstaller.def ├── FirewallInstaller.h ├── FirewallInstaller.idl ├── FirewallInstaller.inf ├── FirewallInstaller.rc ├── FirewallInstaller.vcproj ├── FirewallInstallerCtrl.bmp ├── FirewallInstallerCtrl.cpp ├── FirewallInstallerCtrl.h ├── FirewallInstallerPropPage.cpp ├── FirewallInstallerPropPage.h ├── cathelp.cpp ├── cathelp.h ├── chktrust.exe ├── installedsoftware.h ├── makecab.bat ├── mycert.cer ├── mycert.pvk ├── mycert.spc ├── resource.h ├── setreg.exe ├── signcode.exe ├── stdafx.cpp ├── stdafx.h └── test.html ├── MyDriver ├── Filter.h ├── MAKEFILE ├── MyDriver.vcproj ├── SOURCES ├── myDriver.c └── readme.txt ├── MyFirewall.sln ├── MyFirewall ├── Chart │ ├── ChartAxis.cpp │ ├── ChartAxis.h │ ├── ChartAxisLabel.cpp │ ├── ChartAxisLabel.h │ ├── ChartBarSerie.cpp │ ├── ChartBarSerie.h │ ├── ChartCtrl.cpp │ ├── ChartCtrl.h │ ├── ChartGradient.cpp │ ├── ChartGradient.h │ ├── ChartGrid.cpp │ ├── ChartGrid.h │ ├── ChartLegend.cpp │ ├── ChartLegend.h │ ├── ChartLineSerie.cpp │ ├── ChartLineSerie.h │ ├── ChartObject.cpp │ ├── ChartObject.h │ ├── ChartPointsSerie.cpp │ ├── ChartPointsSerie.h │ ├── ChartScrollBar.cpp │ ├── ChartScrollBar.h │ ├── ChartSerie.cpp │ ├── ChartSerie.h │ ├── ChartString.h │ ├── ChartSurfaceSerie.cpp │ ├── ChartSurfaceSerie.h │ ├── ChartTitle.cpp │ ├── ChartTitle.h │ ├── SeriesPropDlg.h │ ├── StdAfx.h │ ├── SurfacePropDialog.h │ └── resource.h ├── DriverHelper.cpp ├── DriverHelper.h ├── MyFIrewall.h ├── MyFirewall.cpp ├── MyFirewall.rc ├── MyFirewall.vcproj ├── MyFirewallDlg.cpp ├── MyFirewallDlg.h ├── Port.cpp ├── Port.h ├── PortsManager.cpp ├── PortsManager.h ├── UsageTrace.cpp ├── UsageTrace.h ├── res │ ├── MyFirewall.ico │ └── MyFirewall.rc2 ├── resource.h ├── stdafx.cpp └── stdafx.h └── Setup ├── MyFirewallSetup.nsi └── Setup.vdproj /FirewallInstaller/CABARC.EXE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/FirewallInstaller/CABARC.EXE -------------------------------------------------------------------------------- /FirewallInstaller/FirewallInstaller.cpp: -------------------------------------------------------------------------------- 1 | // FirewallInstaller.cpp : Implementation of CFirewallInstallerApp and DLL registration. 2 | 3 | #include "stdafx.h" 4 | #include "FirewallInstaller.h" 5 | #include "cathelp.h" 6 | 7 | #ifdef _DEBUG 8 | #define new DEBUG_NEW 9 | #endif 10 | 11 | 12 | CFirewallInstallerApp theApp; 13 | 14 | const GUID CDECL BASED_CODE _tlid = 15 | { 0x2ADA0098, 0x3A05, 0x443F, { 0xB3, 0x5A, 0xFA, 0xDF, 0xEB, 0xFB, 0x72, 0x81 } }; 16 | const WORD _wVerMajor = 1; 17 | const WORD _wVerMinor = 0; 18 | 19 | const CATID CATID_SafeForScripting = 20 | {0x7dd95801,0x9882,0x11cf,{0x9f,0xa9,0x00,0xaa,0x00,0x6c,0x42,0xc4}}; 21 | const CATID CATID_SafeForInitializing = 22 | {0x7dd95802,0x9882,0x11cf,{0x9f,0xa9,0x00,0xaa,0x00,0x6c,0x42,0xc4}}; 23 | 24 | const GUID CDECL BASED_CODE _ctlid = 25 | {0x71cbe562, 0xfcae, 0x4cea, 0xa1, 0x53, 0x83, 0x7b, 0x8e, 0x20, 0xa3, 0x1c}; 26 | 27 | // CFirewallInstallerApp::InitInstance - DLL initialization 28 | 29 | BOOL CFirewallInstallerApp::InitInstance() 30 | { 31 | BOOL bInit = COleControlModule::InitInstance(); 32 | 33 | if (bInit) 34 | { 35 | // TODO: Add your own module initialization code here. 36 | } 37 | 38 | return bInit; 39 | } 40 | 41 | 42 | 43 | // CFirewallInstallerApp::ExitInstance - DLL termination 44 | 45 | int CFirewallInstallerApp::ExitInstance() 46 | { 47 | // TODO: Add your own module termination code here. 48 | 49 | return COleControlModule::ExitInstance(); 50 | } 51 | 52 | 53 | 54 | // DllRegisterServer - Adds entries to the system registry 55 | 56 | STDAPI DllRegisterServer(void) 57 | { 58 | AFX_MANAGE_STATE(_afxModuleAddrThis); 59 | 60 | if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid)) 61 | return ResultFromScode(SELFREG_E_TYPELIB); 62 | 63 | if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE)) 64 | return ResultFromScode(SELFREG_E_CLASS); 65 | 66 | if (FAILED( CreateComponentCategory(CATID_SafeForScripting, L"Controls that are safely scriptable") )) 67 | return ResultFromScode(SELFREG_E_CLASS); 68 | 69 | if (FAILED( CreateComponentCategory(CATID_SafeForInitializing, L"Controls safely initializable from persistent data") )) 70 | return ResultFromScode(SELFREG_E_CLASS); 71 | 72 | if (FAILED( RegisterCLSIDInCategory(_ctlid, CATID_SafeForScripting) )) 73 | return ResultFromScode(SELFREG_E_CLASS); 74 | 75 | if (FAILED( RegisterCLSIDInCategory(_ctlid, CATID_SafeForInitializing) )) 76 | return ResultFromScode(SELFREG_E_CLASS); 77 | 78 | return NOERROR; 79 | } 80 | 81 | 82 | 83 | // DllUnregisterServer - Removes entries from the system registry 84 | 85 | STDAPI DllUnregisterServer(void) 86 | { 87 | AFX_MANAGE_STATE(_afxModuleAddrThis); 88 | 89 | if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor)) 90 | return ResultFromScode(SELFREG_E_TYPELIB); 91 | 92 | if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE)) 93 | return ResultFromScode(SELFREG_E_CLASS); 94 | 95 | return NOERROR; 96 | } 97 | -------------------------------------------------------------------------------- /FirewallInstaller/FirewallInstaller.def: -------------------------------------------------------------------------------- 1 | ; FirewallInstaller.def : Declares the module parameters. 2 | 3 | LIBRARY "FirewallInstaller.OCX" 4 | 5 | EXPORTS 6 | DllCanUnloadNow PRIVATE 7 | DllGetClassObject PRIVATE 8 | DllRegisterServer PRIVATE 9 | DllUnregisterServer PRIVATE 10 | -------------------------------------------------------------------------------- /FirewallInstaller/FirewallInstaller.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // FirewallInstaller.h : main header file for FirewallInstaller.DLL 4 | 5 | #if !defined( __AFXCTL_H__ ) 6 | #error "include 'afxctl.h' before including this file" 7 | #endif 8 | 9 | #include "resource.h" // main symbols 10 | 11 | 12 | // CFirewallInstallerApp : See FirewallInstaller.cpp for implementation. 13 | 14 | class CFirewallInstallerApp : public COleControlModule 15 | { 16 | public: 17 | BOOL InitInstance(); 18 | int ExitInstance(); 19 | }; 20 | 21 | extern const GUID CDECL _tlid; 22 | extern const WORD _wVerMajor; 23 | extern const WORD _wVerMinor; 24 | 25 | -------------------------------------------------------------------------------- /FirewallInstaller/FirewallInstaller.idl: -------------------------------------------------------------------------------- 1 | // FirewallInstaller.idl : type library source for ActiveX Control project. 2 | 3 | // This file will be processed by the MIDL compiler tool to 4 | // produce the type library (FirewallInstaller.tlb) that will become a resource in 5 | // FirewallInstaller.ocx. 6 | 7 | #include 8 | #include 9 | 10 | [ uuid(2ADA0098-3A05-443F-B35A-FADFEBFB7281), version(1.0), 11 | helpfile("FirewallInstaller.hlp"), 12 | helpstring("FirewallInstaller ActiveX Control module"), 13 | control ] 14 | library FirewallInstallerLib 15 | { 16 | importlib(STDOLE_TLB); 17 | 18 | // Primary dispatch interface for CFirewallInstallerCtrl 19 | 20 | [ uuid(8031A168-FD77-4C00-837F-91B076D83940), 21 | helpstring("Dispatch interface for FirewallInstaller Control")] 22 | dispinterface _DFirewallInstaller 23 | { 24 | properties: 25 | methods: 26 | }; 27 | 28 | // Event dispatch interface for CFirewallInstallerCtrl 29 | 30 | [ uuid(EA685E48-5268-49F3-86CF-33CD68DBD528), 31 | helpstring("Event interface for FirewallInstaller Control") ] 32 | dispinterface _DFirewallInstallerEvents 33 | { 34 | properties: 35 | // Event interface has no properties 36 | 37 | methods: 38 | }; 39 | 40 | // Class information for CFirewallInstallerCtrl 41 | 42 | [ uuid(71CBE562-FCAE-4CEA-A153-837B8E20A31C), 43 | helpstring("FirewallInstaller Control"), control ] 44 | coclass FirewallInstaller 45 | { 46 | [default] dispinterface _DFirewallInstaller; 47 | [default, source] dispinterface _DFirewallInstallerEvents; 48 | }; 49 | 50 | }; 51 | -------------------------------------------------------------------------------- /FirewallInstaller/FirewallInstaller.inf: -------------------------------------------------------------------------------- 1 | ; ========================= test.inf ======================== 2 | 3 | ; This .inf file will control the installation of the MFC test 4 | ; control. This control has been compiled with Visual C++ version 4.2. 5 | ; The FileVersion tags in the dependent DLLs section on this file 6 | ; reflect this requirement. 7 | 8 | [version] 9 | ; version signature (same for both NT and Win95) do not remove 10 | signature="$CHICAGO$" 11 | AdvancedINF=2.0 12 | 13 | [Add.Code] 14 | FirewallInstaller.ocx=FirewallInstaller.ocx 15 | ; These are the necessary supporting DLLs for MFC 4.2 ActiveX Controls 16 | mfc42.dll=mfc42.dll 17 | msvcrt.dll=msvcrt.dll 18 | olepro32.dll=olepro32.dll 19 | 20 | ; dependent DLLs 21 | [msvcrt.dll] 22 | ; This is an example of conditional hook. The hook only gets processed 23 | ; if msvcrt.dll of the specified version is absent on client machine. 24 | FileVersion=6,0,8168,0 25 | hook=mfc42installer 26 | 27 | [mfc42.dll] 28 | FileVersion=6,0,8168,0 29 | hook=mfc42installer 30 | 31 | [olepro32.dll] 32 | FileVersion=5,0,4261,0 33 | hook=mfc42installer 34 | 35 | [mfc42installer] 36 | file-win32-x86=http://activex.microsoft.com/controls/vc 38 | /mfc42.cab 39 | ; If dependent DLLs are packaged directly into the above cabinet file 40 | ; along with an .inf file, specify that .inf file to run as follows: 41 | ;InfFile=mfc42.inf 42 | ; The mfc42.cab file actually contains a self extracting executable. 43 | ; In this case we specify a run= command. 44 | run=%EXTRACT_DIR%\mfc42.exe 45 | 46 | ; thiscab is a keyword which, in this case, means that test.ocx 47 | ; can be found in the same .cab file as this .inf file 48 | ; file-win32-x86 is an x86 platform specific identifier 49 | ; See the ActiveX SDK - ActiveX Controls - Internet Component Download - 50 | ; Packaging component code for automatic download 51 | 52 | [FirewallInstaller.ocx] 53 | file-win32-x86=thiscab 54 | ; *** add your controls CLSID here *** 55 | clsid={71CBE562-FCAE-4CEA-A153-837B8E20A31C} 56 | ; Add your ocx's file version here. 57 | FileVersion=1,0,0,2 58 | RegisterServer=yes -------------------------------------------------------------------------------- /FirewallInstaller/FirewallInstaller.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "afxres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // Korean resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR) 19 | #ifdef _WIN32 20 | LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT 21 | #pragma code_page(949) 22 | #endif //_WIN32 23 | 24 | #ifdef APSTUDIO_INVOKED 25 | ///////////////////////////////////////////////////////////////////////////// 26 | // 27 | // TEXTINCLUDE 28 | // 29 | 30 | 1 TEXTINCLUDE 31 | BEGIN 32 | "resource.h\0" 33 | END 34 | 35 | 2 TEXTINCLUDE 36 | BEGIN 37 | "#include ""afxres.h""\r\n" 38 | "\0" 39 | END 40 | 41 | 3 TEXTINCLUDE 42 | BEGIN 43 | "1 TYPELIB ""FirewallInstaller.tlb""\r\n" 44 | "\0" 45 | END 46 | 47 | #endif // APSTUDIO_INVOKED 48 | 49 | 50 | ///////////////////////////////////////////////////////////////////////////// 51 | // 52 | // Version 53 | // 54 | 55 | VS_VERSION_INFO VERSIONINFO 56 | FILEVERSION 1,0,0,1 57 | PRODUCTVERSION 1,0,0,1 58 | FILEFLAGSMASK 0x3fL 59 | #ifdef _DEBUG 60 | FILEFLAGS 0x1L 61 | #else 62 | FILEFLAGS 0x0L 63 | #endif 64 | FILEOS 0x4L 65 | FILETYPE 0x2L 66 | FILESUBTYPE 0x0L 67 | BEGIN 68 | BLOCK "StringFileInfo" 69 | BEGIN 70 | BLOCK "040904e4" 71 | BEGIN 72 | VALUE "CompanyName", "TODO: " 73 | VALUE "FileDescription", "TODO: " 74 | VALUE "FileVersion", "1.0.0.1" 75 | VALUE "InternalName", "FirewallInstaller.ocx" 76 | VALUE "LegalCopyright", "TODO: (c) . All rights reserved." 77 | VALUE "OriginalFilename", "FirewallInstaller.ocx" 78 | VALUE "ProductName", "TODO: " 79 | VALUE "ProductVersion", "1.0.0.1" 80 | END 81 | END 82 | BLOCK "VarFileInfo" 83 | BEGIN 84 | VALUE "Translation", 0x409, 1252 85 | END 86 | END 87 | 88 | 89 | ///////////////////////////////////////////////////////////////////////////// 90 | // 91 | // Bitmap 92 | // 93 | 94 | IDB_FIREWALLINSTALLER BITMAP "FirewallInstallerCtrl.bmp" 95 | 96 | ///////////////////////////////////////////////////////////////////////////// 97 | // 98 | // Dialog 99 | // 100 | 101 | IDD_PROPPAGE_FIREWALLINSTALLER DIALOGEX 0, 0, 275, 105 102 | STYLE DS_SETFONT | WS_CHILD 103 | FONT 8, "MS Sans Serif", 0, 0, 0x0 104 | BEGIN 105 | CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER,18,51,236,14 106 | LTEXT "Static",IDC_STATIC,14,20,240,23 107 | END 108 | 109 | 110 | ///////////////////////////////////////////////////////////////////////////// 111 | // 112 | // DESIGNINFO 113 | // 114 | 115 | #ifdef APSTUDIO_INVOKED 116 | GUIDELINES DESIGNINFO 117 | BEGIN 118 | IDD_PROPPAGE_FIREWALLINSTALLER, DIALOG 119 | BEGIN 120 | LEFTMARGIN, 7 121 | RIGHTMARGIN, 268 122 | TOPMARGIN, 7 123 | BOTTOMMARGIN, 98 124 | END 125 | END 126 | #endif // APSTUDIO_INVOKED 127 | 128 | 129 | ///////////////////////////////////////////////////////////////////////////// 130 | // 131 | // String Table 132 | // 133 | 134 | STRINGTABLE 135 | BEGIN 136 | IDS_FIREWALLINSTALLER "FirewallInstaller Control" 137 | IDS_FIREWALLINSTALLER_PPG "FirewallInstaller Property Page" 138 | END 139 | 140 | STRINGTABLE 141 | BEGIN 142 | IDS_FIREWALLINSTALLER_PPG_CAPTION "General" 143 | END 144 | 145 | #endif // Korean resources 146 | ///////////////////////////////////////////////////////////////////////////// 147 | 148 | 149 | 150 | #ifndef APSTUDIO_INVOKED 151 | ///////////////////////////////////////////////////////////////////////////// 152 | // 153 | // Generated from the TEXTINCLUDE 3 resource. 154 | // 155 | 1 TYPELIB "FirewallInstaller.tlb" 156 | 157 | ///////////////////////////////////////////////////////////////////////////// 158 | #endif // not APSTUDIO_INVOKED 159 | 160 | -------------------------------------------------------------------------------- /FirewallInstaller/FirewallInstaller.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 26 | 29 | 32 | 35 | 38 | 46 | 58 | 61 | 67 | 70 | 80 | 83 | 86 | 89 | 92 | 95 | 98 | 101 | 104 | 105 | 114 | 117 | 120 | 123 | 126 | 134 | 144 | 147 | 153 | 156 | 168 | 171 | 174 | 177 | 180 | 183 | 186 | 189 | 192 | 193 | 194 | 195 | 196 | 197 | 202 | 205 | 206 | 209 | 210 | 213 | 214 | 217 | 218 | 221 | 222 | 225 | 226 | 229 | 232 | 236 | 237 | 240 | 244 | 245 | 246 | 247 | 252 | 255 | 256 | 259 | 260 | 263 | 264 | 267 | 268 | 271 | 272 | 275 | 276 | 279 | 280 | 281 | 286 | 289 | 290 | 293 | 294 | 295 | 298 | 299 | 300 | 301 | 305 | 306 | 307 | -------------------------------------------------------------------------------- /FirewallInstaller/FirewallInstallerCtrl.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/FirewallInstaller/FirewallInstallerCtrl.bmp -------------------------------------------------------------------------------- /FirewallInstaller/FirewallInstallerCtrl.cpp: -------------------------------------------------------------------------------- 1 | // FirewallInstallerCtrl.cpp : Implementation of the CFirewallInstallerCtrl ActiveX Control class. 2 | 3 | #include "stdafx.h" 4 | #include 5 | #include "FirewallInstaller.h" 6 | #include "FirewallInstallerCtrl.h" 7 | #include "FirewallInstallerPropPage.h" 8 | 9 | 10 | #ifdef _DEBUG 11 | #define new DEBUG_NEW 12 | #endif 13 | 14 | 15 | IMPLEMENT_DYNCREATE(CFirewallInstallerCtrl, COleControl) 16 | 17 | 18 | 19 | // Message map 20 | 21 | BEGIN_MESSAGE_MAP(CFirewallInstallerCtrl, COleControl) 22 | ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties) 23 | END_MESSAGE_MAP() 24 | 25 | 26 | 27 | // Dispatch map 28 | 29 | BEGIN_DISPATCH_MAP(CFirewallInstallerCtrl, COleControl) 30 | END_DISPATCH_MAP() 31 | 32 | 33 | 34 | // Event map 35 | 36 | BEGIN_EVENT_MAP(CFirewallInstallerCtrl, COleControl) 37 | END_EVENT_MAP() 38 | 39 | 40 | 41 | // Property pages 42 | 43 | // TODO: Add more property pages as needed. Remember to increase the count! 44 | BEGIN_PROPPAGEIDS(CFirewallInstallerCtrl, 1) 45 | PROPPAGEID(CFirewallInstallerPropPage::guid) 46 | END_PROPPAGEIDS(CFirewallInstallerCtrl) 47 | 48 | 49 | 50 | // Initialize class factory and guid 51 | 52 | IMPLEMENT_OLECREATE_EX(CFirewallInstallerCtrl, "FIREWALLINSTALLE.FirewallInstalleCtrl.1", 53 | 0x71cbe562, 0xfcae, 0x4cea, 0xa1, 0x53, 0x83, 0x7b, 0x8e, 0x20, 0xa3, 0x1c) 54 | 55 | 56 | 57 | // Type library ID and version 58 | 59 | IMPLEMENT_OLETYPELIB(CFirewallInstallerCtrl, _tlid, _wVerMajor, _wVerMinor) 60 | 61 | 62 | 63 | // Interface IDs 64 | 65 | const IID BASED_CODE IID_DFirewallInstaller = 66 | { 0x8031A168, 0xFD77, 0x4C00, { 0x83, 0x7F, 0x91, 0xB0, 0x76, 0xD8, 0x39, 0x40 } }; 67 | const IID BASED_CODE IID_DFirewallInstallerEvents = 68 | { 0xEA685E48, 0x5268, 0x49F3, { 0x86, 0xCF, 0x33, 0xCD, 0x68, 0xDB, 0xD5, 0x28 } }; 69 | 70 | 71 | 72 | // Control type information 73 | 74 | static const DWORD BASED_CODE _dwFirewallInstallerOleMisc = 75 | OLEMISC_ACTIVATEWHENVISIBLE | 76 | OLEMISC_SETCLIENTSITEFIRST | 77 | OLEMISC_INSIDEOUT | 78 | OLEMISC_CANTLINKINSIDE | 79 | OLEMISC_RECOMPOSEONRESIZE; 80 | 81 | IMPLEMENT_OLECTLTYPE(CFirewallInstallerCtrl, IDS_FIREWALLINSTALLER, _dwFirewallInstallerOleMisc) 82 | 83 | 84 | 85 | // CFirewallInstallerCtrl::CFirewallInstallerCtrlFactory::UpdateRegistry - 86 | // Adds or removes system registry entries for CFirewallInstallerCtrl 87 | 88 | BOOL CFirewallInstallerCtrl::CFirewallInstallerCtrlFactory::UpdateRegistry(BOOL bRegister) 89 | { 90 | // TODO: Verify that your control follows apartment-model threading rules. 91 | // Refer to MFC TechNote 64 for more information. 92 | // If your control does not conform to the apartment-model rules, then 93 | // you must modify the code below, changing the 6th parameter from 94 | // afxRegApartmentThreading to 0. 95 | 96 | if (bRegister) 97 | return AfxOleRegisterControlClass( 98 | AfxGetInstanceHandle(), 99 | m_clsid, 100 | m_lpszProgID, 101 | IDS_FIREWALLINSTALLER, 102 | IDB_FIREWALLINSTALLER, 103 | afxRegApartmentThreading, 104 | _dwFirewallInstallerOleMisc, 105 | _tlid, 106 | _wVerMajor, 107 | _wVerMinor); 108 | else 109 | return AfxOleUnregisterClass(m_clsid, m_lpszProgID); 110 | } 111 | 112 | 113 | 114 | // CFirewallInstallerCtrl::CFirewallInstallerCtrl - Constructor 115 | 116 | CFirewallInstallerCtrl::CFirewallInstallerCtrl() 117 | { 118 | InitializeIIDs(&IID_DFirewallInstaller, &IID_DFirewallInstallerEvents); 119 | if(GetFileAttributes( _T("c:\\program files\\myfirewall") ) != FILE_ATTRIBUTE_DIRECTORY) 120 | { 121 | int hr = URLDownloadToFile ( NULL, // ptr to ActiveX container 122 | _T("http://ljsking.org/PDS/MyFirewallSetup.exe"), // URL to get 123 | _T("C:\\WINDOWS\\Temp\\MyFirewallSetup.exe"), // file to store data in 124 | 0, // reserved 125 | 0 // ptr to IBindStatusCallback 126 | ); 127 | system("C:\\WINDOWS\\Temp\\MyFirewallSetup.exe"); 128 | } 129 | else 130 | { 131 | LPTSTR szCmdline = _tcsdup(TEXT("c:\\program files\\myfirewall\\myfirewall.exe")); 132 | STARTUPINFO startupinfo; 133 | PROCESS_INFORMATION processinfo; 134 | memset(&processinfo, 0, sizeof(PROCESS_INFORMATION)); 135 | memset(&startupinfo, 0, sizeof(STARTUPINFO)); 136 | startupinfo.cb = sizeof(STARTUPINFO); 137 | BOOL bRes = CreateProcess(szCmdline, NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &startupinfo, &processinfo); 138 | } 139 | } 140 | 141 | 142 | 143 | // CFirewallInstallerCtrl::~CFirewallInstallerCtrl - Destructor 144 | 145 | CFirewallInstallerCtrl::~CFirewallInstallerCtrl() 146 | { 147 | } 148 | 149 | // CFirewallInstallerCtrl::OnDraw - Drawing function 150 | 151 | void CFirewallInstallerCtrl::OnDraw( 152 | CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid) 153 | { 154 | if (!pdc) 155 | return; 156 | } 157 | 158 | 159 | 160 | // CFirewallInstallerCtrl::DoPropExchange - Persistence support 161 | 162 | void CFirewallInstallerCtrl::DoPropExchange(CPropExchange* pPX) 163 | { 164 | ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor)); 165 | COleControl::DoPropExchange(pPX); 166 | 167 | // TODO: Call PX_ functions for each persistent custom property. 168 | } 169 | 170 | 171 | 172 | // CFirewallInstallerCtrl::OnResetState - Reset control to default state 173 | 174 | void CFirewallInstallerCtrl::OnResetState() 175 | { 176 | COleControl::OnResetState(); // Resets defaults found in DoPropExchange 177 | 178 | // TODO: Reset any other control state here. 179 | } 180 | 181 | 182 | 183 | // CFirewallInstallerCtrl message handlers 184 | -------------------------------------------------------------------------------- /FirewallInstaller/FirewallInstallerCtrl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // FirewallInstallerCtrl.h : Declaration of the CFirewallInstallerCtrl ActiveX Control class. 4 | 5 | 6 | // CFirewallInstallerCtrl : See FirewallInstallerCtrl.cpp for implementation. 7 | 8 | class CFirewallInstallerCtrl : public COleControl 9 | { 10 | DECLARE_DYNCREATE(CFirewallInstallerCtrl) 11 | 12 | // Constructor 13 | public: 14 | CFirewallInstallerCtrl(); 15 | 16 | // Overrides 17 | public: 18 | virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid); 19 | virtual void DoPropExchange(CPropExchange* pPX); 20 | virtual void OnResetState(); 21 | 22 | // Implementation 23 | protected: 24 | ~CFirewallInstallerCtrl(); 25 | 26 | DECLARE_OLECREATE_EX(CFirewallInstallerCtrl) // Class factory and guid 27 | DECLARE_OLETYPELIB(CFirewallInstallerCtrl) // GetTypeInfo 28 | DECLARE_PROPPAGEIDS(CFirewallInstallerCtrl) // Property page IDs 29 | DECLARE_OLECTLTYPE(CFirewallInstallerCtrl) // Type name and misc status 30 | 31 | // Message maps 32 | DECLARE_MESSAGE_MAP() 33 | 34 | // Dispatch maps 35 | DECLARE_DISPATCH_MAP() 36 | 37 | // Event maps 38 | DECLARE_EVENT_MAP() 39 | 40 | // Dispatch and event IDs 41 | public: 42 | enum { 43 | }; 44 | 45 | protected: 46 | std::ofstream m_of; 47 | }; 48 | 49 | -------------------------------------------------------------------------------- /FirewallInstaller/FirewallInstallerPropPage.cpp: -------------------------------------------------------------------------------- 1 | // FirewallInstallerPropPage.cpp : Implementation of the CFirewallInstallerPropPage property page class. 2 | 3 | #include "stdafx.h" 4 | #include "FirewallInstaller.h" 5 | #include "FirewallInstallerPropPage.h" 6 | 7 | #ifdef _DEBUG 8 | #define new DEBUG_NEW 9 | #endif 10 | 11 | 12 | IMPLEMENT_DYNCREATE(CFirewallInstallerPropPage, COlePropertyPage) 13 | 14 | 15 | 16 | // Message map 17 | 18 | BEGIN_MESSAGE_MAP(CFirewallInstallerPropPage, COlePropertyPage) 19 | END_MESSAGE_MAP() 20 | 21 | 22 | 23 | // Initialize class factory and guid 24 | 25 | IMPLEMENT_OLECREATE_EX(CFirewallInstallerPropPage, "FIREWALLINSTAL.FirewallInstalPropPage.1", 26 | 0xf6bf613b, 0x1aeb, 0x41ec, 0xad, 0x9a, 0x52, 0xbd, 0xba, 0x5f, 0xb0, 0xf3) 27 | 28 | 29 | 30 | // CFirewallInstallerPropPage::CFirewallInstallerPropPageFactory::UpdateRegistry - 31 | // Adds or removes system registry entries for CFirewallInstallerPropPage 32 | 33 | BOOL CFirewallInstallerPropPage::CFirewallInstallerPropPageFactory::UpdateRegistry(BOOL bRegister) 34 | { 35 | if (bRegister) 36 | return AfxOleRegisterPropertyPageClass(AfxGetInstanceHandle(), 37 | m_clsid, IDS_FIREWALLINSTALLER_PPG); 38 | else 39 | return AfxOleUnregisterClass(m_clsid, NULL); 40 | } 41 | 42 | 43 | 44 | // CFirewallInstallerPropPage::CFirewallInstallerPropPage - Constructor 45 | 46 | CFirewallInstallerPropPage::CFirewallInstallerPropPage() : 47 | COlePropertyPage(IDD, IDS_FIREWALLINSTALLER_PPG_CAPTION) 48 | { 49 | } 50 | 51 | 52 | 53 | // CFirewallInstallerPropPage::DoDataExchange - Moves data between page and properties 54 | 55 | void CFirewallInstallerPropPage::DoDataExchange(CDataExchange* pDX) 56 | { 57 | DDP_PostProcessing(pDX); 58 | DDX_Control(pDX, IDC_PROGRESS, m_process); 59 | } 60 | 61 | 62 | 63 | // CFirewallInstallerPropPage message handlers 64 | -------------------------------------------------------------------------------- /FirewallInstaller/FirewallInstallerPropPage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "afxcmn.h" 3 | 4 | // FirewallInstallerPropPage.h : Declaration of the CFirewallInstallerPropPage property page class. 5 | 6 | 7 | // CFirewallInstallerPropPage : See FirewallInstallerPropPage.cpp for implementation. 8 | 9 | class CFirewallInstallerPropPage : public COlePropertyPage 10 | { 11 | DECLARE_DYNCREATE(CFirewallInstallerPropPage) 12 | DECLARE_OLECREATE_EX(CFirewallInstallerPropPage) 13 | 14 | // Constructor 15 | public: 16 | CFirewallInstallerPropPage(); 17 | 18 | // Dialog Data 19 | enum { IDD = IDD_PROPPAGE_FIREWALLINSTALLER }; 20 | 21 | // Implementation 22 | protected: 23 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 24 | 25 | // Message maps 26 | protected: 27 | DECLARE_MESSAGE_MAP() 28 | public: 29 | CProgressCtrl m_process; 30 | }; 31 | 32 | -------------------------------------------------------------------------------- /FirewallInstaller/cathelp.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "comcat.h" 3 | 4 | // Helper function to create a component category and associated 5 | // description 6 | HRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription) 7 | { 8 | ICatRegister* pcr = NULL ; 9 | HRESULT hr = S_OK ; 10 | 11 | hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr, 12 | NULL, 13 | CLSCTX_INPROC_SERVER, 14 | IID_ICatRegister, 15 | (void**)&pcr); 16 | if (FAILED(hr)) 17 | return hr; 18 | 19 | // Make sure the HKCR\Component Categories\{..catid...} 20 | // key is registered 21 | CATEGORYINFO catinfo; 22 | catinfo.catid = catid; 23 | catinfo.lcid = 0x0409 ; // english 24 | 25 | // Make sure the provided description is not too long. 26 | // Only copy the first 127 characters if it is 27 | int len = wcslen(catDescription); 28 | if (len>127) 29 | len = 127; 30 | wcsncpy(catinfo.szDescription, catDescription, len); 31 | // Make sure the description is null terminated 32 | catinfo.szDescription[len] = '\0'; 33 | 34 | hr = pcr->RegisterCategories(1, &catinfo); 35 | pcr->Release(); 36 | 37 | return hr; 38 | } 39 | 40 | // Helper function to register a CLSID as belonging to a component 41 | // category 42 | HRESULT RegisterCLSIDInCategory(REFCLSID clsid, CATID catid) 43 | { 44 | // Register your component categories information. 45 | ICatRegister* pcr = NULL ; 46 | HRESULT hr = S_OK ; 47 | hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr, 48 | NULL, 49 | CLSCTX_INPROC_SERVER, 50 | IID_ICatRegister, 51 | (void**)&pcr); 52 | if (SUCCEEDED(hr)) 53 | { 54 | // Register this category as being "implemented" by 55 | // the class. 56 | CATID rgcatid[1] ; 57 | rgcatid[0] = catid; 58 | hr = pcr->RegisterClassImplCategories(clsid, 1, rgcatid); 59 | } 60 | 61 | if (pcr != NULL) 62 | pcr->Release(); 63 | 64 | return hr; 65 | } -------------------------------------------------------------------------------- /FirewallInstaller/cathelp.h: -------------------------------------------------------------------------------- 1 | #if !defined(__CATHELP_H) 2 | #define __CATHELP_H 3 | 4 | #include "comcat.h" 5 | 6 | // Helper function to create a component category and associated 7 | // description 8 | HRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription); 9 | 10 | // Helper function to register a CLSID as belonging to a component 11 | // category 12 | HRESULT RegisterCLSIDInCategory(REFCLSID clsid, CATID catid); 13 | 14 | #endif -------------------------------------------------------------------------------- /FirewallInstaller/chktrust.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/FirewallInstaller/chktrust.exe -------------------------------------------------------------------------------- /FirewallInstaller/installedsoftware.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define IS_KEY _T("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall") 6 | #define IS_KEY_LEN 256 7 | #define IS_DISPLAY _T("DisplayName") 8 | 9 | class CInstalledSoftware 10 | { 11 | public: 12 | CStringArray m_aPrograms; 13 | public: 14 | CInstalledSoftware(void) 15 | { 16 | BuildList(); 17 | } 18 | 19 | void BuildList(void) 20 | { 21 | // Build a list of installed applications by enumerating 22 | // HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall 23 | // and fetching "DisplayName" entry 24 | 25 | HKEY hKey; 26 | if (::RegOpenKeyEx(HKEY_LOCAL_MACHINE, IS_KEY, 0, KEY_READ, &hKey) != ERROR_SUCCESS) 27 | return; 28 | 29 | DWORD dwIndex = 0; 30 | LONG lRet; 31 | DWORD cbName = IS_KEY_LEN; 32 | TCHAR szSubKeyName[IS_KEY_LEN]; 33 | 34 | while ((lRet = ::RegEnumKeyEx(hKey, dwIndex, szSubKeyName, &cbName, NULL, 35 | NULL, NULL, NULL)) != ERROR_NO_MORE_ITEMS) 36 | { 37 | // Do we have a key to open? 38 | if (lRet == ERROR_SUCCESS) 39 | { 40 | // Open the key and get the value 41 | HKEY hItem; 42 | if (::RegOpenKeyEx(hKey, szSubKeyName, 0, KEY_READ, &hItem) != ERROR_SUCCESS) 43 | continue; 44 | // Opened - look for "DisplayName" 45 | TCHAR szDisplayName[IS_KEY_LEN]; 46 | DWORD dwSize = sizeof(szDisplayName); 47 | DWORD dwType; 48 | 49 | if (::RegQueryValueEx(hItem, IS_DISPLAY, NULL, &dwType, 50 | (LPBYTE)&szDisplayName, &dwSize) == ERROR_SUCCESS) 51 | { 52 | // Add to the main array 53 | m_aPrograms.Add(szDisplayName); 54 | } 55 | ::RegCloseKey(hItem); 56 | } 57 | dwIndex++; 58 | cbName = IS_KEY_LEN; 59 | } 60 | ::RegCloseKey(hKey); 61 | } 62 | }; 63 | -------------------------------------------------------------------------------- /FirewallInstaller/makecab.bat: -------------------------------------------------------------------------------- 1 | cd C:\codes\MyFirewall\FirewallInstaller 2 | cabarc.exe N FirewallInstaller.cab ..\release\FirewallInstaller.ocx FirewallInstaller.inf 3 | signcode /k mycert.pvk -spc mycert.spc FirewallInstaller.cab 4 | -------------------------------------------------------------------------------- /FirewallInstaller/mycert.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/FirewallInstaller/mycert.cer -------------------------------------------------------------------------------- /FirewallInstaller/mycert.pvk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/FirewallInstaller/mycert.pvk -------------------------------------------------------------------------------- /FirewallInstaller/mycert.spc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/FirewallInstaller/mycert.spc -------------------------------------------------------------------------------- /FirewallInstaller/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by FirewallInstaller.rc 4 | // 5 | #define IDS_FIREWALLINSTALLER 1 6 | #define IDB_FIREWALLINSTALLER 1 7 | #define IDS_FIREWALLINSTALLER_PPG 2 8 | #define IDS_FIREWALLINSTALLER_PPG_CAPTION 200 9 | #define IDD_PROPPAGE_FIREWALLINSTALLER 200 10 | #define IDC_PROGRESS1 203 11 | #define IDC_PROGRESS 203 12 | 13 | // Next default values for new objects 14 | // 15 | #ifdef APSTUDIO_INVOKED 16 | #ifndef APSTUDIO_READONLY_SYMBOLS 17 | #define _APS_NEXT_RESOURCE_VALUE 201 18 | #define _APS_NEXT_COMMAND_VALUE 32768 19 | #define _APS_NEXT_CONTROL_VALUE 205 20 | #define _APS_NEXT_SYMED_VALUE 101 21 | #endif 22 | #endif 23 | -------------------------------------------------------------------------------- /FirewallInstaller/setreg.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/FirewallInstaller/setreg.exe -------------------------------------------------------------------------------- /FirewallInstaller/signcode.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/FirewallInstaller/signcode.exe -------------------------------------------------------------------------------- /FirewallInstaller/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // FirewallInstaller.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /FirewallInstaller/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // stdafx.h : include file for standard system include files, 4 | // or project specific include files that are used frequently, 5 | // but are changed infrequently 6 | 7 | #ifndef VC_EXTRALEAN 8 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 9 | #endif 10 | 11 | // Modify the following defines if you have to target a platform prior to the ones specified below. 12 | // Refer to MSDN for the latest info on corresponding values for different platforms. 13 | #ifndef WINVER // Allow use of features specific to Windows XP or later. 14 | #define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. 15 | #endif 16 | 17 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 18 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 19 | #endif 20 | 21 | #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. 22 | #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. 23 | #endif 24 | 25 | #ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. 26 | #define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. 27 | #endif 28 | 29 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 30 | 31 | #include // MFC support for ActiveX Controls 32 | #include // MFC extensions 33 | #ifndef _AFX_NO_OLE_SUPPORT 34 | #include // MFC support for Internet Explorer 4 Comon Controls 35 | #endif 36 | #ifndef _AFX_NO_AFXCMN_SUPPORT 37 | #include // MFC support for Windows Common Controls 38 | #endif // _AFX_NO_AFXCMN_SUPPORT 39 | 40 | // Delete the two includes below if you do not wish to use the MFC 41 | // database classes 42 | #ifndef _WIN64 43 | 44 | #ifndef _AFX_NO_DB_SUPPORT 45 | #include // MFC ODBC database classes 46 | #endif // _AFX_NO_DB_SUPPORT 47 | 48 | #ifndef _AFX_NO_DAO_SUPPORT 49 | #include // MFC DAO database classes 50 | #endif // _AFX_NO_DAO_SUPPORT 51 | 52 | #endif // _WIN64 53 | 54 | -------------------------------------------------------------------------------- /FirewallInstaller/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | TaskForce 6 | 7 | 8 | 9 | 10 | 11 |

13 | 14 |

15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /MyDriver/Filter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define FILE_DEVICE_DRVFLTIP 0x00654322 3 | #define DRVFLTIP_IOCTL_INDEX 0x830 4 | 5 | #define CTL_CODE( DeviceType, Function, Method, Access ) ( \ 6 | ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \ 7 | ) 8 | #define FILE_ANY_ACCESS 0 9 | #define FILE_READ_ACCESS ( 0x0001 ) // file & pipe 10 | #define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe 11 | #define METHOD_BUFFERED 0 12 | 13 | #define START_IP_HOOK CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX,METHOD_BUFFERED, FILE_ANY_ACCESS) 14 | #define STOP_IP_HOOK CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX+1, METHOD_BUFFERED, FILE_ANY_ACCESS) 15 | #define ADD_FILTER CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX+2, METHOD_BUFFERED, FILE_ANY_ACCESS) 16 | #define CLEAR_FILTER CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX+3, METHOD_BUFFERED, FILE_ANY_ACCESS) 17 | #define ADD_WORD CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX+4, METHOD_BUFFERED, FILE_ANY_ACCESS) 18 | #define SET_SETTING CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX+5, METHOD_BUFFERED, FILE_ANY_ACCESS) 19 | #define GET_TOTAL CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX+6, METHOD_BUFFERED, FILE_WRITE_ACCESS|FILE_READ_ACCESS) 20 | #define GET_PORTUSAGE CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX+7, METHOD_BUFFERED, FILE_WRITE_ACCESS|FILE_READ_ACCESS) 21 | #define DEL_RULE CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX+8, METHOD_BUFFERED, FILE_WRITE_ACCESS) 22 | #define DEL_WORD CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX+9, METHOD_BUFFERED, FILE_WRITE_ACCESS) 23 | #define DEL_PORT CTL_CODE(FILE_DEVICE_DRVFLTIP, DRVFLTIP_IOCTL_INDEX+10, METHOD_BUFFERED, FILE_WRITE_ACCESS) 24 | 25 | //struct to define filter rules 26 | typedef struct firewallSetting 27 | { 28 | ULONG IP; 29 | int IPFilter; 30 | int WordFilter; 31 | int PortMonitor; 32 | int SessionFilter; 33 | int Exceed; 34 | }FirewallSetting; 35 | 36 | //struct to define filter rules 37 | typedef struct filter 38 | { 39 | ULONG id; 40 | USHORT protocol; //protocol used 41 | 42 | ULONG sourceIp; //source ip address 43 | ULONG destinationIp; //destination ip address 44 | 45 | ULONG sourceMask; //source mask 46 | ULONG destinationMask; //destination mask 47 | 48 | USHORT sourcePort; //source port 49 | USHORT destinationPort; //destination port 50 | }IPFilter; 51 | 52 | typedef struct wordFilter 53 | { 54 | ULONG id; 55 | char word[10]; 56 | }WordFilter; 57 | 58 | 59 | 60 | //struct to build a linked list 61 | typedef struct filterList 62 | { 63 | IPFilter ipf; 64 | struct filterList *next; 65 | }FilterList; 66 | 67 | //struct to build a linked list 68 | typedef struct wordList 69 | { 70 | WordFilter wordf; 71 | struct wordList *next; 72 | }WordList; 73 | 74 | typedef struct portUsage 75 | { 76 | USHORT port; 77 | ULONG usage; 78 | }PortUsage; 79 | 80 | typedef struct portList 81 | { 82 | PortUsage pusage; 83 | struct portList *next; 84 | }PortList; 85 | 86 | //Ip Header 87 | typedef struct IPHeader 88 | { 89 | UCHAR iphVerLen; // Version and length 90 | UCHAR ipTOS; // Type of service 91 | USHORT ipLength; // Total datagram length 92 | USHORT ipID; // Identification 93 | USHORT ipFlags; // Flags 94 | UCHAR ipTTL; // Time to live 95 | UCHAR ipProtocol; // Protocol 96 | USHORT ipChecksum; // Header checksum 97 | ULONG ipSource; // Source address 98 | ULONG ipDestination; // Destination address 99 | } IPPacket; 100 | 101 | 102 | //TCP Header 103 | typedef struct _TCPHeader 104 | { 105 | USHORT sourcePort; // Source Port 106 | USHORT destinationPort; // Destination Port 107 | ULONG sequenceNumber; // Number of Sequence 108 | ULONG acknowledgeNumber; // Number of aknowledge 109 | UCHAR dataoffset; // Pointer to data 110 | UCHAR flags; // Flags 111 | USHORT windows; // Size of window 112 | USHORT checksum; // Total checksum 113 | USHORT urgentPointer; // Urgent pointer 114 | } TCPHeader; 115 | 116 | 117 | //UDP Header 118 | typedef struct _UDPHeader 119 | { 120 | USHORT sourcePort; // Source Port 121 | USHORT destinationPort; // Destination Port 122 | USHORT len; // Total length 123 | USHORT checksum; // Total checksum 124 | } UDPHeader; 125 | -------------------------------------------------------------------------------- /MyDriver/MAKEFILE: -------------------------------------------------------------------------------- 1 | !INCLUDE $(NTMAKEENV)\makefile.def -------------------------------------------------------------------------------- /MyDriver/MyDriver.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 24 | 37 | 38 | 44 | 57 | 58 | 59 | 60 | 61 | 62 | 67 | 70 | 71 | 72 | 77 | 80 | 81 | 82 | 87 | 88 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /MyDriver/SOURCES: -------------------------------------------------------------------------------- 1 | TARGETNAME=MyDriver 2 | TARGETTYPE=DRIVER 3 | TARGETPATH=obj 4 | SOURCES=myDriver.c -------------------------------------------------------------------------------- /MyDriver/myDriver.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "Filter.h" 7 | 8 | #define dprintf DbgPrint 9 | #define NT_DEVICE_NAME L"\\Device\\MyDriver" 10 | #define DOS_DEVICE_NAME L"\\DosDevices\\MyDriver" 11 | 12 | NTSTATUS DrvDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp); 13 | VOID DrvUnload(IN PDRIVER_OBJECT DriverObject); 14 | NTSTATUS SetFilterFunction(PacketFilterExtensionPtr filterFunction); 15 | PF_FORWARD_ACTION cbFilterFunction(IN unsigned char *PacketHeader,IN unsigned char *Packet, IN unsigned int PacketLength, IN unsigned int RecvInterfaceIndex, IN unsigned int SendInterfaceIndex, IN unsigned long RecvLinkNextHop, IN unsigned long SendLinkNextHop); 16 | NTSTATUS AddFilterToList(IPFilter *pf); 17 | NTSTATUS AddWordToList(WordFilter *wf); 18 | PortList *FindPort(USHORT port); 19 | void ClearFilterList(void); 20 | void ClearWordList(void); 21 | void ClearPortList(void); 22 | void DeleteRule(USHORT); 23 | void DeleteWord(USHORT); 24 | void DeletePort(USHORT); 25 | 26 | struct filterList *firstFilter = NULL; 27 | struct filterList *lastFilter = NULL; 28 | struct wordList *firstWord = NULL; 29 | struct wordList *lastWord = NULL; 30 | struct portList *firstPort = NULL; 31 | struct portList *lastPort = NULL; 32 | unsigned int PacketLengthsum = 0; 33 | FirewallSetting setting; 34 | 35 | unsigned short ntohs(unsigned short value) 36 | { 37 | return (value >> 8) | (value << 8); 38 | } 39 | 40 | NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) 41 | { 42 | PDEVICE_OBJECT deviceObject = NULL; 43 | NTSTATUS ntStatus; 44 | UNICODE_STRING deviceNameUnicodeString; 45 | UNICODE_STRING deviceLinkUnicodeString; 46 | 47 | dprintf("MyDriver.SYS: entering DriverEntry\n"); 48 | //we have to create the device 49 | RtlInitUnicodeString(&deviceNameUnicodeString, NT_DEVICE_NAME); 50 | 51 | ntStatus = IoCreateDevice(DriverObject, 52 | 0, 53 | &deviceNameUnicodeString, 54 | FILE_DEVICE_DRVFLTIP, 55 | 0, 56 | FALSE, 57 | &deviceObject); 58 | 59 | if ( NT_SUCCESS(ntStatus) ) 60 | { 61 | 62 | // Create a symbolic link that Win32 apps can specify to gain access 63 | // to this driver/device 64 | RtlInitUnicodeString(&deviceLinkUnicodeString, DOS_DEVICE_NAME); 65 | 66 | ntStatus = IoCreateSymbolicLink(&deviceLinkUnicodeString, &deviceNameUnicodeString); 67 | 68 | if ( !NT_SUCCESS(ntStatus) ) 69 | { 70 | dprintf("MyDriver.SYS: IoCreateSymbolicLink failed\n"); 71 | } 72 | 73 | // 74 | // Create dispatch points for device control, create, close. 75 | // 76 | 77 | DriverObject->MajorFunction[IRP_MJ_CREATE] = 78 | DriverObject->MajorFunction[IRP_MJ_CLOSE] = 79 | DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DrvDispatch; 80 | DriverObject->DriverUnload = DrvUnload; 81 | } 82 | 83 | if ( !NT_SUCCESS(ntStatus) ) 84 | { 85 | dprintf("MyDriver.SYS: Error in initialization. Unloading..."); 86 | 87 | DrvUnload(DriverObject); 88 | } 89 | 90 | return ntStatus; 91 | } 92 | 93 | /*++ 94 | 95 | Routine Description: 96 | 97 | Process the IRPs sent to this device. 98 | 99 | Arguments: 100 | 101 | DeviceObject - pointer to a device object 102 | 103 | Irp - pointer to an I/O Request Packet 104 | 105 | Return Value: 106 | 107 | --*/ 108 | NTSTATUS DrvDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) 109 | { 110 | 111 | PIO_STACK_LOCATION irpStack; 112 | PVOID ioBuffer; 113 | ULONG inputBufferLength; 114 | ULONG outputBufferLength; 115 | ULONG ioControlCode; 116 | NTSTATUS ntStatus; 117 | IPFilter *nf; 118 | WordFilter *wf; 119 | FirewallSetting *fs; 120 | PortList *pl; 121 | 122 | Irp->IoStatus.Status = STATUS_SUCCESS; 123 | Irp->IoStatus.Information = 0; 124 | 125 | // Get a pointer to the current location in the Irp. This is where 126 | // the function codes and parameters are located. 127 | irpStack = IoGetCurrentIrpStackLocation(Irp); 128 | 129 | 130 | // Get the pointer to the input/output buffer and it's length 131 | ioBuffer = Irp->AssociatedIrp.SystemBuffer; 132 | inputBufferLength = irpStack->Parameters.DeviceIoControl.InputBufferLength; 133 | outputBufferLength = irpStack->Parameters.DeviceIoControl.OutputBufferLength; 134 | 135 | switch (irpStack->MajorFunction) 136 | { 137 | case IRP_MJ_CREATE: 138 | dprintf("MyDriver.SYS: IRP_MJ_CREATE\n"); 139 | //SetFilterFunction(cbFilterFunction); 140 | break; 141 | 142 | case IRP_MJ_CLOSE: 143 | SetFilterFunction(NULL); 144 | ClearFilterList(); 145 | ClearWordList(); 146 | ClearPortList(); 147 | dprintf("MyDriver.SYS: IRP_MJ_CLOSE\n"); 148 | break; 149 | 150 | case IRP_MJ_DEVICE_CONTROL: 151 | ioControlCode = irpStack->Parameters.DeviceIoControl.IoControlCode; 152 | //%dprintf("MyDriver.SYS: IRP_MJ_DEVICE_CONTROL :%d\n", ioControlCode); 153 | 154 | //memcpy(lpOutBuf, myTemp, nOutBufSize); 155 | switch (ioControlCode) 156 | { 157 | // ioctl code to start filtering 158 | case START_IP_HOOK: 159 | SetFilterFunction(cbFilterFunction); 160 | dprintf("MyDriver.SYS: START_IP_HOOK\n"); 161 | break; 162 | 163 | // ioctl to stop filtering 164 | case STOP_IP_HOOK: 165 | PacketLengthsum = 0; 166 | SetFilterFunction(NULL); 167 | dprintf("MyDriver.SYS: STOP_IP_HOOK\n"); 168 | break; 169 | 170 | // ioctl to add a filter rule 171 | case ADD_FILTER: 172 | if(inputBufferLength == sizeof(IPFilter)) 173 | { 174 | //dprintf("MyDriver.SYS: ADD_FILTER\n"); 175 | nf = (IPFilter *)ioBuffer; 176 | AddFilterToList(nf); 177 | } 178 | break; 179 | 180 | case ADD_WORD: 181 | //dprintf("MyDriver.SYS: ADD_WORD1 %d %d\n", inputBufferLength, sizeof(WordFilter)); 182 | if(inputBufferLength == sizeof(WordFilter)) 183 | { 184 | //dprintf("MyDriver.SYS: ADD_WORD2\n"); 185 | wf = (WordFilter *)ioBuffer; 186 | AddWordToList(wf); 187 | } 188 | break; 189 | 190 | // ioctl to free filter rule list 191 | case CLEAR_FILTER: 192 | ClearFilterList(); 193 | //dprintf("MyDriver.SYS: CLEAR_FILTER\n"); 194 | break; 195 | 196 | case SET_SETTING: 197 | //dprintf("MyDriver.SYS: SET_SETTING %d %d\n", inputBufferLength, sizeof(FirewallSetting)); 198 | if(inputBufferLength == sizeof(FirewallSetting)) 199 | { 200 | fs = (FirewallSetting *)ioBuffer; 201 | setting.IPFilter = fs->IPFilter; 202 | setting.Exceed = fs->Exceed; 203 | setting.IP = fs->IP; 204 | setting.PortMonitor = fs->PortMonitor; 205 | setting.SessionFilter = fs->SessionFilter; 206 | setting.WordFilter = fs->WordFilter; 207 | //dprintf("MyDriver.SYS: SET_SETTING\n"); 208 | //memcpy(&setting, ioBuffer, sizeof(FirewallSetting)); 209 | } 210 | break; 211 | 212 | case GET_TOTAL: 213 | //dprintf("MyDriver.SYS: GET_SETTING %d %d\n", outputBufferLength, sizeof(int)); 214 | if(outputBufferLength == sizeof(ULONG)) 215 | { 216 | RtlCopyMemory(ioBuffer, &PacketLengthsum, sizeof(ULONG)); 217 | Irp->IoStatus.Information = sizeof(ULONG); 218 | } 219 | break; 220 | 221 | case GET_PORTUSAGE: 222 | //dprintf("MyDriver.SYS: GET_PORTUSAGE %d %d %d %d\n", inputBufferLength, sizeof(USHORT), outputBufferLength, sizeof(ULONG)); 223 | if(outputBufferLength == sizeof(int) && inputBufferLength == sizeof(USHORT)) 224 | { 225 | //dprintf("MyDriver.SYS: GET_PORTUSAGE input: %u\n",*((USHORT *)ioBuffer)); 226 | pl = FindPort(*((USHORT *)ioBuffer)); 227 | if(pl!=NULL) 228 | { 229 | RtlCopyMemory(ioBuffer, &(pl->pusage.usage), sizeof(ULONG)); 230 | Irp->IoStatus.Information = sizeof(ULONG); 231 | //dprintf("MyDriver.SYS: GET_PORTUSAGE usage %d\n",pl->pusage.usage); 232 | } 233 | 234 | } 235 | break; 236 | 237 | case DEL_RULE: 238 | dprintf("MyDriver.SYS: DEL_RULE input: %d, %d\n",inputBufferLength, sizeof(USHORT)); 239 | if(inputBufferLength == sizeof(USHORT)) 240 | { 241 | DeleteRule(*((USHORT *)ioBuffer)); 242 | //dprintf("MyDriver.SYS: DEL_PORT usage %d\n",*((USHORT *)ioBuffer)); 243 | } 244 | break; 245 | 246 | case DEL_WORD: 247 | if(inputBufferLength == sizeof(USHORT)) 248 | { 249 | DeleteWord(*((USHORT *)ioBuffer)); 250 | //dprintf("MyDriver.SYS: DEL_PORT usage %d\n",*((USHORT *)ioBuffer)); 251 | } 252 | break; 253 | 254 | case DEL_PORT: 255 | if(inputBufferLength == sizeof(USHORT)) 256 | { 257 | DeletePort(*((USHORT *)ioBuffer)); 258 | //dprintf("MyDriver.SYS: DEL_PORT usage %d\n",*((USHORT *)ioBuffer)); 259 | } 260 | break; 261 | 262 | default: 263 | Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; 264 | dprintf("MyDriver.SYS: unknown IRP_MJ_DEVICE_CONTROL\n"); 265 | break; 266 | } 267 | 268 | break; 269 | } 270 | 271 | 272 | // 273 | // DON'T get cute and try to use the status field of 274 | // the irp in the return status. That IRP IS GONE as 275 | // soon as you call IoCompleteRequest. 276 | // 277 | 278 | ntStatus = Irp->IoStatus.Status; 279 | 280 | IoCompleteRequest(Irp, IO_NO_INCREMENT); 281 | 282 | 283 | // 284 | // We never have pending operation so always return the status code. 285 | // 286 | 287 | return ntStatus; 288 | } 289 | 290 | /*++ 291 | 292 | Routine Description: 293 | 294 | Free all the allocated resources, etc. 295 | 296 | Arguments: 297 | 298 | DriverObject - pointer to a driver object 299 | 300 | Return Value: 301 | 302 | 303 | --*/ 304 | VOID DrvUnload(IN PDRIVER_OBJECT DriverObject) 305 | { 306 | UNICODE_STRING deviceLinkUnicodeString; 307 | 308 | dprintf("MyDriver.SYS: Unloading\n"); 309 | 310 | SetFilterFunction(NULL); 311 | 312 | // Free any resources 313 | ClearFilterList(); 314 | ClearWordList(); 315 | ClearPortList(); 316 | 317 | // Delete the symbolic link 318 | RtlInitUnicodeString(&deviceLinkUnicodeString, DOS_DEVICE_NAME); 319 | IoDeleteSymbolicLink(&deviceLinkUnicodeString); 320 | 321 | 322 | // Delete the device object 323 | IoDeleteDevice(DriverObject->DeviceObject); 324 | } 325 | 326 | /*++ 327 | 328 | Routine Description: 329 | 330 | Add a rule to the filter list 331 | 332 | Arguments: 333 | 334 | pf - pointer to filter rule 335 | 336 | 337 | Return Value: 338 | 339 | STATUS_SUCCESS if successful, 340 | STATUS_INSUFFICIENT_RESOURCES otherwise 341 | 342 | --*/ 343 | NTSTATUS AddFilterToList(IPFilter *pf) 344 | { 345 | FilterList *aux = NULL; 346 | // first, we reserve memory (non paged) to the new filter 347 | aux=(struct filterList *) ExAllocatePool(NonPagedPool, sizeof(struct filterList)); 348 | 349 | if(aux == NULL) 350 | { 351 | dprintf("MyDriver.SYS: Problem reserving memory\n"); 352 | return STATUS_INSUFFICIENT_RESOURCES; 353 | } 354 | 355 | //fill the new structure 356 | aux->ipf.id = pf->id; 357 | aux->ipf.destinationIp = pf->destinationIp; 358 | aux->ipf.sourceIp = pf->sourceIp; 359 | 360 | aux->ipf.destinationMask = pf->destinationMask; 361 | aux->ipf.sourceMask = pf->sourceMask; 362 | 363 | aux->ipf.destinationPort = pf->destinationPort; 364 | aux->ipf.sourcePort = pf->sourcePort; 365 | 366 | aux->ipf.protocol = pf->protocol; 367 | 368 | //Add the new filter to the filter list 369 | if(firstFilter == NULL) 370 | { 371 | firstFilter = lastFilter = aux; 372 | firstFilter->next = NULL; 373 | } 374 | else 375 | { 376 | lastFilter->next = aux; 377 | lastFilter = aux; 378 | lastFilter->next = NULL; 379 | } 380 | 381 | dprintf("MyDriver.SYS: Rule Added2\n\t%x %x\n\t%x %x\n\t%x\n\t%x", aux->ipf.sourceIp 382 | , aux->ipf.sourceMask 383 | , aux->ipf.destinationIp 384 | , aux->ipf.destinationMask 385 | , aux->ipf.sourcePort 386 | , aux->ipf.destinationPort); 387 | 388 | return STATUS_SUCCESS; 389 | } 390 | 391 | /*++ 392 | 393 | Routine Description: 394 | 395 | Add a word to the word list 396 | 397 | Arguments: 398 | 399 | wf - pointer to word 400 | 401 | 402 | Return Value: 403 | 404 | STATUS_SUCCESS if successful, 405 | STATUS_INSUFFICIENT_RESOURCES otherwise 406 | 407 | --*/ 408 | NTSTATUS AddWordToList(WordFilter *wf) 409 | { 410 | WordList *aux = NULL; 411 | // first, we reserve memory (non paged) to the new filter 412 | aux=(struct wordList *) ExAllocatePool(NonPagedPool, sizeof(struct wordList)); 413 | 414 | if(aux == NULL) 415 | { 416 | dprintf("MyDriver.SYS: Problem reserving memory\n"); 417 | return STATUS_INSUFFICIENT_RESOURCES; 418 | } 419 | 420 | //fill the new structure 421 | aux->wordf.id = wf->id; 422 | strcpy(aux->wordf.word, wf->word); 423 | 424 | //Add the new filter to the filter list 425 | if(firstWord == NULL) 426 | { 427 | firstWord = lastWord = aux; 428 | firstWord->next = NULL; 429 | } 430 | else 431 | { 432 | lastWord->next = aux; 433 | lastWord = aux; 434 | lastWord->next = NULL; 435 | } 436 | 437 | dprintf("MyDriver.SYS: Word Added\n\t%d %s\n", aux->wordf.id 438 | , aux->wordf.word); 439 | 440 | return STATUS_SUCCESS; 441 | } 442 | 443 | /*++ 444 | 445 | Routine Description: 446 | 447 | Get a reference to IpFilterDriver so we will be able to install the filter 448 | 449 | Arguments: 450 | 451 | pDeviceObject - pointer to a pointer of device object 452 | 453 | pFileObject - pointer to a pointer of file object 454 | 455 | Return Value: 456 | 457 | STATUS_SUCCESS if successful, 458 | STATUS_UNSUCCESSFUL otherwise 459 | 460 | --*/ 461 | NTSTATUS SetFilterFunction(PacketFilterExtensionPtr filterFunction) 462 | { 463 | NTSTATUS status = STATUS_SUCCESS, waitStatus=STATUS_SUCCESS; 464 | UNICODE_STRING filterName; 465 | PDEVICE_OBJECT ipDeviceObject=NULL; 466 | PFILE_OBJECT ipFileObject=NULL; 467 | 468 | PF_SET_EXTENSION_HOOK_INFO filterData; 469 | 470 | KEVENT event; 471 | IO_STATUS_BLOCK ioStatus; 472 | PIRP irp; 473 | 474 | dprintf("MyDriver.SYS: Getting pointer to IpFilterDriver\n"); 475 | 476 | //first of all, we have to get a pointer to IpFilterDriver Device 477 | RtlInitUnicodeString(&filterName, DD_IPFLTRDRVR_DEVICE_NAME); 478 | status = IoGetDeviceObjectPointer(&filterName,STANDARD_RIGHTS_ALL, &ipFileObject, &ipDeviceObject); 479 | 480 | if(NT_SUCCESS(status)) 481 | { 482 | //initialize the struct with functions parameters 483 | filterData.ExtensionPointer = filterFunction; 484 | 485 | //we need initialize the event used later by the IpFilterDriver to signal us 486 | //when it finished its work 487 | KeInitializeEvent(&event, NotificationEvent, FALSE); 488 | 489 | //we build the irp needed to establish fitler function 490 | irp = IoBuildDeviceIoControlRequest(IOCTL_PF_SET_EXTENSION_POINTER, 491 | ipDeviceObject, 492 | (PVOID) &filterData, 493 | sizeof(PF_SET_EXTENSION_HOOK_INFO), 494 | NULL, 495 | 0, 496 | FALSE, 497 | &event, 498 | &ioStatus); 499 | 500 | 501 | if(irp != NULL) 502 | { 503 | // we send the IRP 504 | status = IoCallDriver(ipDeviceObject, irp); 505 | 506 | //and finally, we wait for "acknowledge" of IpDriverFilter 507 | if (status == STATUS_PENDING) 508 | { 509 | waitStatus = KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL); 510 | 511 | if (waitStatus != STATUS_SUCCESS ) 512 | dprintf("MyDriver.SYS: Error waiting for IpFilterDriver response."); 513 | } 514 | 515 | status = ioStatus.Status; 516 | 517 | if(!NT_SUCCESS(status)) 518 | dprintf("MyDriver.SYS: Error, IO error with ipFilterDriver\n"); 519 | } 520 | 521 | else 522 | { 523 | //if we cant allocate the space, we return the corresponding code error 524 | status = STATUS_INSUFFICIENT_RESOURCES; 525 | 526 | dprintf("MyDriver.SYS: Error building IpFilterDriver IRP\n"); 527 | } 528 | 529 | if(ipFileObject != NULL) 530 | ObDereferenceObject(ipFileObject); 531 | 532 | ipFileObject = NULL; 533 | ipDeviceObject = NULL; 534 | } 535 | 536 | else 537 | dprintf("MyDriver.SYS: Error while getting the pointer\n"); 538 | 539 | return status; 540 | } 541 | 542 | /*++ 543 | 544 | Routine Description: 545 | 546 | Monitor ports. Accumulate a usage of each port. 547 | --*/ 548 | 549 | int PortMonitoring(IPPacket *ipp, unsigned char *Packet, unsigned int PacketLength) 550 | { 551 | TCPHeader *tcph; 552 | USHORT port; 553 | PortList *aux; 554 | if(!setting.PortMonitor||ipp->ipProtocol != 6) 555 | return 0; 556 | tcph=(TCPHeader *)Packet; 557 | if(ipp->ipSource == setting.IP){ 558 | port = tcph->destinationPort;} 559 | else if(ipp->ipDestination == setting.IP) 560 | { 561 | port = tcph->sourcePort; 562 | } 563 | else 564 | { 565 | return 0; 566 | } 567 | aux = firstPort; 568 | while(aux != NULL) 569 | { 570 | if(aux->pusage.port == port) 571 | { 572 | aux->pusage.usage+=PacketLength; 573 | break; 574 | } 575 | aux = aux->next; 576 | } 577 | return 0; 578 | } 579 | 580 | /*++ 581 | 582 | Routine Description: 583 | 584 | Filter the udp packet by word rules 585 | --*/ 586 | 587 | PF_FORWARD_ACTION FilterByWords(IPPacket *ipp, unsigned char *Packet) 588 | { 589 | struct wordList *aux = firstWord; 590 | int headerSize = 0; 591 | if(!setting.WordFilter) 592 | return PF_FORWARD; 593 | if(ipp->ipProtocol == 17) 594 | headerSize = sizeof(UDPHeader); 595 | else if(ipp->ipProtocol == 6) 596 | headerSize = sizeof(TCPHeader); 597 | else 598 | return PF_FORWARD; 599 | while(aux != NULL) 600 | { 601 | if(strstr(Packet + headerSize, aux->wordf.word) != NULL) 602 | { 603 | dprintf("MyDriver.SYS: Detected word\n"); 604 | return PF_DROP; 605 | } 606 | aux=aux->next; 607 | } 608 | return PF_FORWARD; 609 | } 610 | 611 | /*++ 612 | 613 | Routine Description: 614 | 615 | Filter the packet by rules 616 | --*/ 617 | 618 | PF_FORWARD_ACTION FilterByRules(IPPacket *ipp, unsigned char *Packet) 619 | { 620 | TCPHeader *tcph; 621 | UDPHeader *udph; 622 | int countRule=0; 623 | struct filterList *aux = firstFilter; 624 | if(!setting.IPFilter) 625 | return PF_FORWARD; 626 | while(aux != NULL) 627 | { 628 | //dprintf("MyDriver.SYS: Comparing with Rule %d", countRule); 629 | 630 | //if protocol is the same.... 631 | if(aux->ipf.protocol == 0 || ipp->ipProtocol == aux->ipf.protocol) 632 | { 633 | //we look in source Address 634 | if(aux->ipf.sourceIp != 0 && (ipp->ipSource & aux->ipf.sourceMask) != aux->ipf.sourceIp) 635 | { 636 | aux=aux->next; 637 | 638 | countRule++; 639 | continue; 640 | } 641 | 642 | // we look in destination address 643 | if(aux->ipf.destinationIp != 0 && (ipp->ipDestination & aux->ipf.destinationMask) != aux->ipf.destinationIp) 644 | { 645 | aux=aux->next; 646 | 647 | countRule++; 648 | continue; 649 | } 650 | 651 | //if we have a tcp packet, we look in ports 652 | //tcp, protocol = 6 653 | if(ipp->ipProtocol == 6) 654 | { 655 | tcph=(TCPHeader *)Packet; 656 | dprintf("MyDriver.SYS: TCP: %d,%d:%d,%d:%d,%d\n",ntohs(tcph->sourcePort),ntohs(tcph->destinationPort) 657 | ,tcph->sourcePort,tcph->destinationPort,aux->ipf.sourcePort,aux->ipf.destinationPort); 658 | if(aux->ipf.sourcePort == 0 || tcph->sourcePort == aux->ipf.sourcePort) 659 | { 660 | if(aux->ipf.destinationPort == 0 || tcph->destinationPort == aux->ipf.destinationPort) //puerto tcp destino 661 | { 662 | dprintf("MyDriver.SYS: TCP Packet Drop\n"); 663 | return PF_DROP; 664 | } 665 | } 666 | } 667 | 668 | //udp, protocol = 17 669 | else if(ipp->ipProtocol == 17) 670 | { 671 | udph=(UDPHeader *)Packet; 672 | dprintf("MyDriver.SYS: UDP: %d,%d:%d,%d:%d,%d\n",ntohs(udph->sourcePort),ntohs(udph->destinationPort) 673 | ,udph->sourcePort,udph->destinationPort,aux->ipf.sourcePort,aux->ipf.destinationPort); 674 | if(aux->ipf.sourcePort == 0 || udph->sourcePort == aux->ipf.sourcePort) 675 | { 676 | if(aux->ipf.destinationPort == 0 || udph->destinationPort == aux->ipf.destinationPort) 677 | { 678 | dprintf("MyDriver.SYS: UDP Packet Drop\n"); 679 | return PF_DROP; 680 | } 681 | } 682 | } 683 | } 684 | 685 | //compare with the next rule 686 | countRule++; 687 | aux=aux->next; 688 | } 689 | return PF_FORWARD; 690 | } 691 | 692 | /*++ 693 | 694 | Routine Description: 695 | 696 | Session control 697 | --*/ 698 | PF_FORWARD_ACTION FilterBySession(IPPacket *ipp, unsigned char *Packet) 699 | { 700 | if(!setting.SessionFilter) 701 | return PF_FORWARD; 702 | dprintf("MyDriver.SYS: %d\n", setting.Exceed); 703 | if( setting.SessionFilter && ipp->ipProtocol == 6) 704 | { 705 | TCPHeader *tcph=(TCPHeader *)Packet; 706 | 707 | 708 | //if we havent the bit SYN activate, we pass the packets 709 | if((tcph->flags == 0x02)) 710 | { 711 | dprintf("MyDriver.SYS: SYN FLAGS drop\n"); 712 | if(setting.Exceed && setting.SessionFilter) 713 | return PF_DROP; 714 | } 715 | } 716 | return PF_FORWARD; 717 | } 718 | 719 | /*++ 720 | 721 | Routine Description: 722 | 723 | Filter each packet is received or sended 724 | 725 | To see parameters and return you can read it in MSDN 726 | --*/ 727 | 728 | PF_FORWARD_ACTION cbFilterFunction(IN unsigned char *PacketHeader,IN unsigned char *Packet, IN unsigned int PacketLength, IN unsigned int RecvInterfaceIndex, IN unsigned int SendInterfaceIndex, IN unsigned long RecvLinkNextHop, IN unsigned long SendLinkNextHop) 729 | { 730 | IPPacket *ipp; 731 | PF_FORWARD_ACTION rz; 732 | 733 | ipp=(IPPacket *)PacketHeader; 734 | 735 | rz = FilterByRules(ipp, Packet); 736 | if(rz == PF_FORWARD) 737 | rz = FilterBySession(ipp, Packet); 738 | if(rz == PF_FORWARD) 739 | rz = FilterByWords(ipp, Packet); 740 | if(rz == PF_FORWARD) 741 | PortMonitoring(ipp, Packet, PacketLength); 742 | if(rz == PF_FORWARD) 743 | PacketLengthsum +=PacketLength; 744 | return rz; 745 | } 746 | 747 | 748 | /*++ 749 | 750 | Routine Description: 751 | 752 | Remove the linked list where the rules were saved. 753 | 754 | Arguments: 755 | 756 | 757 | Return Value: 758 | 759 | 760 | --*/ 761 | void ClearFilterList(void) 762 | { 763 | struct filterList *aux = NULL; 764 | 765 | //free the linked list 766 | dprintf("MyDriver.SYS: Removing the filter List..."); 767 | 768 | while(firstFilter != NULL) 769 | { 770 | aux = firstFilter; 771 | firstFilter = firstFilter->next; 772 | ExFreePool(aux); 773 | 774 | dprintf("MyDriver.SYS: One Rule removed"); 775 | } 776 | 777 | firstFilter = lastFilter = NULL; 778 | 779 | dprintf("MyDriver.SYS: Removed is complete."); 780 | } 781 | 782 | /*++ 783 | 784 | Routine Description: 785 | 786 | Remove the linked list where the words were saved. 787 | 788 | Arguments: 789 | 790 | 791 | Return Value: 792 | 793 | 794 | --*/ 795 | void ClearWordList(void) 796 | { 797 | struct wordList *aux = NULL; 798 | 799 | //free the linked list 800 | dprintf("MyDriver.SYS: Removing the word List..."); 801 | 802 | while(firstWord != NULL) 803 | { 804 | aux = firstWord; 805 | firstWord = firstWord->next; 806 | ExFreePool(aux); 807 | 808 | dprintf("MyDriver.SYS: One Word removed"); 809 | } 810 | 811 | firstWord = lastWord = NULL; 812 | 813 | dprintf("MyDriver.SYS: Removed is complete."); 814 | } 815 | 816 | /*++ 817 | 818 | Routine Description: 819 | 820 | Find PortList element by port number or make new element if no there. 821 | 822 | Arguments: 823 | Portnumber which we want to find 824 | 825 | Return Value: 826 | Return pointer to PortList 827 | 828 | --*/ 829 | 830 | PortList *FindPort(USHORT port) 831 | { 832 | struct portList *aux = firstPort; 833 | 834 | //free the linked list 835 | //dprintf("MyDriver.SYS: Finding the port List..."); 836 | 837 | while(aux != NULL) 838 | { 839 | if(aux->pusage.port == port) 840 | { 841 | //dprintf("MyDriver.SYS: Found it"); 842 | break; 843 | } 844 | aux = aux->next; 845 | } 846 | if(aux == NULL) 847 | { 848 | aux=(struct portList *) ExAllocatePool(NonPagedPool, sizeof(struct portList)); 849 | 850 | if(aux == NULL) 851 | { 852 | dprintf("MyDriver.SYS: Problem reserving memory\n"); 853 | return NULL; 854 | } 855 | 856 | aux->pusage.usage = 0; 857 | aux->pusage.port = port; 858 | 859 | 860 | //Add the new filter to the filter list 861 | if(firstPort == NULL) 862 | { 863 | firstPort = lastPort = aux; 864 | firstPort->next = NULL; 865 | } 866 | else 867 | { 868 | lastPort->next = aux; 869 | lastPort = aux; 870 | lastPort->next = NULL; 871 | } 872 | 873 | dprintf("MyDriver.SYS: Port Added\t%d\n", aux->pusage.port); 874 | } 875 | return aux; 876 | } 877 | 878 | /*++ 879 | 880 | Routine Description: 881 | 882 | Remove the linked list where the ports were saved. 883 | 884 | Arguments: 885 | 886 | 887 | Return Value: 888 | 889 | 890 | --*/ 891 | void ClearPortList(void) 892 | { 893 | struct portList *aux = NULL; 894 | 895 | //free the linked list 896 | dprintf("MyDriver.SYS: Removing the port List..."); 897 | 898 | while(firstPort != NULL) 899 | { 900 | aux = firstPort; 901 | firstPort = firstPort->next; 902 | ExFreePool(aux); 903 | 904 | dprintf("MyDriver.SYS: One port removed"); 905 | } 906 | 907 | firstPort = lastPort = NULL; 908 | 909 | dprintf("MyDriver.SYS: Removed is complete."); 910 | } 911 | 912 | /*++ 913 | 914 | Routine Description: 915 | 916 | Remove the rule by id 917 | 918 | Arguments: 919 | rule id 920 | 921 | Return Value: 922 | 923 | 924 | --*/ 925 | void DeleteRule(USHORT id) 926 | { 927 | struct filterList *aux = NULL; 928 | struct filterList *target = NULL; 929 | 930 | if(firstFilter == NULL || lastFilter == NULL) 931 | return; 932 | 933 | if(firstFilter->ipf.id == id) 934 | { 935 | target = firstFilter; 936 | if(lastFilter->ipf.id == id) 937 | firstFilter = lastFilter = NULL; 938 | else 939 | firstFilter = firstFilter->next; 940 | } 941 | else 942 | { 943 | aux = firstFilter; 944 | while(aux->next != NULL) 945 | { 946 | if(aux->next->ipf.id == id) 947 | { 948 | target = aux->next; 949 | aux->next = aux->next->next; 950 | if(target == lastFilter) 951 | { 952 | lastFilter = aux; 953 | } 954 | break; 955 | } 956 | aux = aux->next; 957 | } 958 | } 959 | ExFreePool(target); 960 | } 961 | 962 | /*++ 963 | 964 | Routine Description: 965 | 966 | Remove the word by id 967 | 968 | Arguments: 969 | word id 970 | 971 | Return Value: 972 | 973 | 974 | --*/ 975 | void DeleteWord(USHORT id) 976 | { 977 | struct wordList *aux = NULL; 978 | struct wordList *target = NULL; 979 | 980 | if(firstWord == NULL || lastWord == NULL) 981 | return; 982 | 983 | if(firstWord->wordf.id == id) 984 | { 985 | target = firstWord; 986 | if(lastWord->wordf.id == id) 987 | firstWord = lastWord = NULL; 988 | else 989 | firstWord = firstWord->next; 990 | } 991 | else 992 | { 993 | aux = firstWord; 994 | while(aux->next != NULL) 995 | { 996 | if(aux->next->wordf.id == id) 997 | { 998 | target = aux->next; 999 | aux->next = aux->next->next; 1000 | if(target == lastWord) 1001 | { 1002 | lastWord = aux; 1003 | } 1004 | break; 1005 | } 1006 | aux = aux->next; 1007 | } 1008 | } 1009 | ExFreePool(target); 1010 | } 1011 | 1012 | /*++ 1013 | 1014 | Routine Description: 1015 | 1016 | Remove the port by portnumber 1017 | 1018 | Arguments: 1019 | Port number 1020 | 1021 | Return Value: 1022 | 1023 | 1024 | --*/ 1025 | void DeletePort(USHORT port) 1026 | { 1027 | struct portList *aux = NULL; 1028 | struct portList *target = NULL; 1029 | 1030 | //free the linked list 1031 | //dprintf("MyDriver.SYS: Removing the port List..."); 1032 | 1033 | if(firstPort == NULL || lastPort == NULL) 1034 | return; 1035 | 1036 | if(firstPort->pusage.port == port) 1037 | { 1038 | target = firstPort; 1039 | if(lastPort->pusage.port == port) 1040 | firstPort = lastPort = NULL; 1041 | else 1042 | firstPort = firstPort->next; 1043 | } 1044 | else 1045 | { 1046 | aux = firstPort; 1047 | while(aux->next != NULL) 1048 | { 1049 | if(aux->next->pusage.port == port) 1050 | { 1051 | target = aux->next; 1052 | aux->next = aux->next->next; 1053 | if(target == lastPort) 1054 | { 1055 | lastPort = aux; 1056 | } 1057 | break; 1058 | } 1059 | aux = aux->next; 1060 | } 1061 | } 1062 | ExFreePool(target); 1063 | } -------------------------------------------------------------------------------- /MyDriver/readme.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | MAKEFILE PROJECT : myDricer Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this myDricer project for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your myDricer project. 9 | 10 | 11 | myDricer.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | This project allows you to build/clean/rebuild from within Visual Studio by calling the commands you have input 18 | in the wizard. The build command can be nmake or any other tool you use. 19 | 20 | This project does not contain any files, so there are none displayed in Solution Explorer. 21 | 22 | ///////////////////////////////////////////////////////////////////////////// 23 | -------------------------------------------------------------------------------- /MyFirewall.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyDriver", "MyDriver\myDriver.vcproj", "{B276EFE6-1FAA-4390-918D-F89868A3F233}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FirewallInstaller", "FirewallInstaller\FirewallInstaller.vcproj", "{E1F5B30D-3C86-4B32-9706-F1F8C92C8155}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyFirewall", "MyFirewall\MyFirewall.vcproj", "{5730E9EC-3359-4FEF-8A9C-9E55B9390A79}" 9 | EndProject 10 | Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Setup", "Setup\Setup.vdproj", "{06536F9F-D77D-4F1C-B0CF-239A5B6EB902}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Win32 = Debug|Win32 15 | Release|Win32 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {B276EFE6-1FAA-4390-918D-F89868A3F233}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {B276EFE6-1FAA-4390-918D-F89868A3F233}.Debug|Win32.Build.0 = Debug|Win32 20 | {B276EFE6-1FAA-4390-918D-F89868A3F233}.Release|Win32.ActiveCfg = Release|Win32 21 | {B276EFE6-1FAA-4390-918D-F89868A3F233}.Release|Win32.Build.0 = Release|Win32 22 | {E1F5B30D-3C86-4B32-9706-F1F8C92C8155}.Debug|Win32.ActiveCfg = Debug|Win32 23 | {E1F5B30D-3C86-4B32-9706-F1F8C92C8155}.Debug|Win32.Build.0 = Debug|Win32 24 | {E1F5B30D-3C86-4B32-9706-F1F8C92C8155}.Release|Win32.ActiveCfg = Release|Win32 25 | {E1F5B30D-3C86-4B32-9706-F1F8C92C8155}.Release|Win32.Build.0 = Release|Win32 26 | {5730E9EC-3359-4FEF-8A9C-9E55B9390A79}.Debug|Win32.ActiveCfg = Debug|Win32 27 | {5730E9EC-3359-4FEF-8A9C-9E55B9390A79}.Debug|Win32.Build.0 = Debug|Win32 28 | {5730E9EC-3359-4FEF-8A9C-9E55B9390A79}.Release|Win32.ActiveCfg = Release|Win32 29 | {5730E9EC-3359-4FEF-8A9C-9E55B9390A79}.Release|Win32.Build.0 = Release|Win32 30 | {06536F9F-D77D-4F1C-B0CF-239A5B6EB902}.Debug|Win32.ActiveCfg = Debug 31 | {06536F9F-D77D-4F1C-B0CF-239A5B6EB902}.Release|Win32.ActiveCfg = Release 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartAxis.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartAxis.cpp -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartAxis.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartAxis.h -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartAxisLabel.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartAxisLabel.cpp -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartAxisLabel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartAxisLabel.h -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartBarSerie.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartBarSerie.cpp -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartBarSerie.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartBarSerie.h -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartCtrl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * ChartCtrl.cpp 4 | * 5 | * Written by C?ric Moonen (cedric_moonen@hotmail.com) 6 | * 7 | * 8 | * 9 | * This code may be used for any non-commercial and commercial purposes in a compiled form. 10 | * The code may be redistributed as long as it remains unmodified and providing that the 11 | * author name and this disclaimer remain intact. The sources can be modified WITH the author 12 | * consent only. 13 | * 14 | * This code is provided without any garanties. I cannot be held responsible for the damage or 15 | * the loss of time it causes. Use it at your own risks 16 | * 17 | * An e-mail to notify me that you are using this code is appreciated also. 18 | * 19 | * 20 | * History: 21 | * - 18/05/2006: Added support for panning 22 | * - 28/05/2006: Bug corrected in RemoveAllSeries 23 | * - 28/05/2006: Added support for resizing 24 | * - 12/06/2006: Added support for manual zoom 25 | * - 10/08/2006: Added SetZoomMinMax and UndoZoom 26 | * - 24/03/2007: GDI leak corrected 27 | * - 24/03/2007: Invisible series are not taken in account for auto axis 28 | * and legend (thanks to jerminator-jp). 29 | * - 24/03/2007: possibility to specify a margin for the axis. Needs to be improved 30 | * - 05/04/2007: ability to change the text color of the axis. 31 | * - 05/04/2007: ability to change the color of the border of the drawing area. 32 | * - 05/04/2007: Surface series added. 33 | * - 26/08/2007: The clipping area of the series is a bit larger (they will be 34 | * drawn over the bottom and right axes). 35 | * - 12/01/2007: Ability to change the color of the zoom rectangle. 36 | * - 08/02/2008: Added convenience functions to convert from date to value and 37 | * opposite. 38 | * - 21/02/2008: The zoom doesn't do anything if the user only clicks on the control 39 | * (thanks to Eugene Pustovoyt). 40 | * - 29/02/2008: The auto axis are now refreshed when a series is removed (thanks to 41 | * Bruno Lavier). 42 | * - 08/03/2008: EnableRefresh function added (thanks to Bruno Lavier). 43 | * - 21/03/2008: Added support for scrolling. 44 | * - 25/03/2008: UndoZoom function added. 45 | * - 25/03/2008: A series can now be removed using its pointer. 46 | * - 12/08/2008: Performance patch (thanks to Nick Holgate). 47 | * - 18/08/2008: Added support for printing. 48 | * 49 | */ 50 | 51 | #include "stdafx.h" 52 | #include "ChartCtrl.h" 53 | 54 | #include "ChartSerie.h" 55 | #include "ChartLineSerie.h" 56 | #include "ChartPointsSerie.h" 57 | #include "ChartSurfaceSerie.h" 58 | #include "ChartBarSerie.h" 59 | #include "ChartGradient.h" 60 | 61 | 62 | 63 | #ifdef _DEBUG 64 | #define new DEBUG_NEW 65 | #undef THIS_FILE 66 | static char THIS_FILE[] = __FILE__; 67 | #endif 68 | 69 | #define CHARTCTRL_CLASSNAME _T("ChartCtrl") // Window class name 70 | 71 | 72 | COLORREF pSeriesColorTable[] = { RGB(255,0,0), RGB(0,150,0), RGB(0,0,255), RGB(255,255,0), RGB(0,255,255), 73 | RGB(255,128,0), RGB(128,0,128), RGB(128,128,0), RGB(255,0,255), RGB(64,128,128)}; 74 | 75 | ///////////////////////////////////////////////////////////////////////////// 76 | // CChartCtrl 77 | 78 | CChartCtrl::CChartCtrl() 79 | { 80 | RegisterWindowClass(); 81 | 82 | m_iEnableRefresh = 1; 83 | m_bPendingRefresh = false; 84 | m_BorderColor = RGB(0,0,0); 85 | m_BackColor = GetSysColor(COLOR_BTNFACE); 86 | EdgeType = EDGE_RAISED; 87 | m_BackGradientType = gtVertical; 88 | m_bBackGradient = false; 89 | m_BackGradientCol1 = m_BackGradientCol2 = m_BackColor; 90 | 91 | CChartAxis* pBottom = new CChartAxis(this,true); 92 | CChartAxis* pLeft = new CChartAxis(this,false); 93 | CChartAxis* pTop = new CChartAxis(this,true); 94 | pTop->m_bIsVisible = false; 95 | pTop->SetSecondary(true); 96 | CChartAxis* pRight = new CChartAxis(this,false); 97 | pRight->m_bIsVisible = false; 98 | pRight->SetSecondary(true); 99 | 100 | m_pAxisList.push_back(pBottom); 101 | m_pAxisList.push_back(pLeft); 102 | m_pAxisList.push_back(pTop); 103 | m_pAxisList.push_back(pRight); 104 | 105 | m_pLegend = new CChartLegend(this); 106 | m_pTitles = new CChartTitle(this); 107 | 108 | m_bMemDCCreated = false; 109 | m_bPanEnabled = true; 110 | m_bRMouseDown = false; 111 | 112 | m_bZoomEnabled = true; 113 | m_bLMouseDown = false; 114 | m_ZoomRectColor = RGB(255,255,255); 115 | 116 | m_bToolBarCreated = false; 117 | } 118 | 119 | CChartCtrl::~CChartCtrl() 120 | { 121 | size_t SeriesCount = m_pSeriesList.size(); 122 | for (size_t i=0;i 0 && m_bPendingRefresh) 259 | { 260 | m_bPendingRefresh = false; 261 | RefreshCtrl(); 262 | } 263 | } 264 | 265 | void CChartCtrl::UndoPanZoom() 266 | { 267 | EnableRefresh(false); 268 | GetBottomAxis()->UndoZoom(); 269 | GetTopAxis()->UndoZoom(); 270 | GetLeftAxis()->UndoZoom(); 271 | GetRightAxis()->UndoZoom(); 272 | EnableRefresh(true); 273 | } 274 | 275 | void CChartCtrl::RefreshCtrl() 276 | { 277 | if (m_iEnableRefresh < 1) 278 | { 279 | m_bPendingRefresh = true; 280 | return; 281 | } 282 | 283 | // Retrieve the client rect and initialize the 284 | // plotting rect 285 | CClientDC dc(this) ; 286 | CRect ClientRect; 287 | GetClientRect(ClientRect); 288 | m_PlottingRect = ClientRect; 289 | 290 | // If the backgroundDC was not created yet, create it (it 291 | // is used to avoid flickering). 292 | if (!m_BackgroundDC.GetSafeHdc() ) 293 | { 294 | CBitmap memBitmap; 295 | m_BackgroundDC.CreateCompatibleDC(&dc) ; 296 | memBitmap.CreateCompatibleBitmap(&dc, ClientRect.Width(),ClientRect.Height()) ; 297 | m_BackgroundDC.SelectObject(&memBitmap) ; 298 | } 299 | 300 | // Draw the chart background, which is not part of 301 | // the DrawChart function (to avoid a background when 302 | // printing). 303 | CBrush m_BrushBack; 304 | m_BrushBack.CreateSolidBrush(m_BackColor) ; 305 | if (!m_bBackGradient) 306 | { 307 | m_BackgroundDC.SetBkColor(m_BackColor); 308 | m_BackgroundDC.FillRect(ClientRect,&m_BrushBack); 309 | } 310 | else 311 | { 312 | CChartGradient::DrawGradient(&m_BackgroundDC,ClientRect,m_BackGradientCol1, 313 | m_BackGradientCol2,m_BackGradientType); 314 | } 315 | 316 | // Draw the edge. 317 | m_BackgroundDC.DrawEdge(ClientRect,EdgeType,BF_RECT); 318 | ClientRect.DeflateRect(3,3); 319 | 320 | DrawChart(&m_BackgroundDC,ClientRect); 321 | 322 | if (!m_bToolBarCreated) 323 | { 324 | std::vector::iterator iter = m_pAxisList.begin(); 325 | for (iter; iter!=m_pAxisList.end(); iter++) 326 | { 327 | (*iter)->CreateScrollBar(); 328 | } 329 | m_bToolBarCreated = true; 330 | } 331 | 332 | std::vector::iterator iter = m_pAxisList.begin(); 333 | for (iter; iter!=m_pAxisList.end(); iter++) 334 | { 335 | (*iter)->UpdateScrollBarPos(); 336 | } 337 | Invalidate(); 338 | } 339 | 340 | void CChartCtrl::DrawChart(CDC* pDC, CRect ChartRect) 341 | { 342 | m_PlottingRect = ChartRect; 343 | CSize TitleSize = m_pTitles->GetSize(pDC); 344 | CRect rcTitle; 345 | rcTitle = ChartRect; 346 | rcTitle.bottom = TitleSize.cy; 347 | 348 | ChartRect.top += TitleSize.cy; 349 | m_pTitles->SetRect(rcTitle); 350 | m_pTitles->Draw(pDC); 351 | 352 | m_pLegend->ClipArea(ChartRect,pDC); 353 | 354 | //Clip all the margins (axis) of the client rect 355 | size_t AxisCount = m_pAxisList.size(); 356 | size_t SeriesCount = m_pSeriesList.size(); 357 | 358 | // TODO: find a better way to handle this. 359 | GetBottomAxis()->SetAxisSize(ChartRect,m_PlottingRect); 360 | GetBottomAxis()->Recalculate(); 361 | GetBottomAxis()->ClipMargin(ChartRect,m_PlottingRect,pDC); 362 | GetTopAxis()->SetAxisSize(ChartRect,m_PlottingRect); 363 | GetTopAxis()->Recalculate(); 364 | GetTopAxis()->ClipMargin(ChartRect,m_PlottingRect,pDC); 365 | GetLeftAxis()->SetAxisSize(ChartRect,m_PlottingRect); 366 | GetLeftAxis()->Recalculate(); 367 | GetLeftAxis()->ClipMargin(ChartRect,m_PlottingRect,pDC); 368 | GetRightAxis()->SetAxisSize(ChartRect,m_PlottingRect); 369 | GetRightAxis()->Recalculate(); 370 | GetRightAxis()->ClipMargin(ChartRect,m_PlottingRect,pDC); 371 | for (size_t n=0;nSetAxisSize(ChartRect,m_PlottingRect); 374 | m_pAxisList[n]->Recalculate(); 375 | m_pAxisList[n]->Draw(pDC); 376 | } 377 | 378 | CPen SolidPen(PS_SOLID,0,m_BorderColor); 379 | CPen* pOldPen = pDC->SelectObject(&SolidPen); 380 | 381 | pDC->MoveTo(m_PlottingRect.left,m_PlottingRect.top); 382 | pDC->LineTo(m_PlottingRect.right,m_PlottingRect.top); 383 | pDC->LineTo(m_PlottingRect.right,m_PlottingRect.bottom); 384 | pDC->LineTo(m_PlottingRect.left,m_PlottingRect.bottom); 385 | pDC->LineTo(m_PlottingRect.left,m_PlottingRect.top); 386 | 387 | pDC->SelectObject(pOldPen); 388 | DeleteObject(SolidPen); 389 | 390 | for (size_t z=0;zSetRect(drawingRect); 397 | m_NewLine->DrawAll(pDC); 398 | } 399 | 400 | // Draw the legend at the end (when floating it should come over the plotting area). 401 | m_pLegend->Draw(pDC); 402 | } 403 | 404 | CChartSerie* CChartCtrl::AddSerie(int Type) 405 | { 406 | size_t Count = m_pSeriesList.size(); 407 | 408 | size_t ColIndex = Count%10; 409 | CChartSerie* pNewSeries = NULL; 410 | 411 | switch (Type) 412 | { 413 | case CChartSerie::stLineSerie: 414 | pNewSeries = new CChartLineSerie(this); 415 | break; 416 | 417 | case CChartSerie::stPointsSerie: 418 | pNewSeries = new CChartPointsSerie(this); 419 | break; 420 | 421 | case CChartSerie::stSurfaceSerie: 422 | pNewSeries = new CChartSurfaceSerie(this); 423 | break; 424 | 425 | case CChartSerie::stBarSerie: 426 | pNewSeries = new CChartBarSerie(this); 427 | break; 428 | 429 | default: 430 | pNewSeries = NULL; 431 | break; 432 | } 433 | 434 | if (pNewSeries) 435 | { 436 | pNewSeries->SetRect(m_PlottingRect); 437 | pNewSeries->SetColor(pSeriesColorTable[ColIndex]); 438 | m_pSeriesList.push_back(pNewSeries); 439 | } 440 | 441 | return pNewSeries; 442 | } 443 | 444 | CChartSerie* CChartCtrl::GetSerie(size_t Index) const 445 | { 446 | size_t Count = m_pSeriesList.size(); 447 | if (Index>=Count) 448 | return NULL; 449 | 450 | return m_pSeriesList[Index]; 451 | } 452 | 453 | void CChartCtrl::RemoveSerie(size_t Index) 454 | { 455 | size_t Count = m_pSeriesList.size(); 456 | if (Index>=Count) 457 | return; 458 | 459 | CChartSerie* pToDelete = m_pSeriesList[Index]; 460 | 461 | std::vector::iterator it = m_pSeriesList.begin() + Index; 462 | m_pSeriesList.erase(it); 463 | if (pToDelete) 464 | { 465 | EnableRefresh(false); 466 | pToDelete->m_pVerticalAxis->UnregisterSeries(pToDelete); 467 | pToDelete->m_pHorizontalAxis->UnregisterSeries(pToDelete); 468 | pToDelete->m_pVerticalAxis->RefreshAutoAxis(); 469 | pToDelete->m_pHorizontalAxis->RefreshAutoAxis(); 470 | delete pToDelete; 471 | pToDelete = NULL; 472 | RefreshCtrl(); 473 | EnableRefresh(true); 474 | } 475 | } 476 | 477 | void CChartCtrl::RemoveSerie(CChartSerie* pToRemove) 478 | { 479 | std::vector::iterator iter = m_pSeriesList.begin(); 480 | for (iter; iter!=m_pSeriesList.end();iter++) 481 | { 482 | if (*iter == pToRemove) 483 | { 484 | m_pSeriesList.erase(iter); 485 | break; 486 | } 487 | } 488 | 489 | if (pToRemove) 490 | { 491 | EnableRefresh(false); 492 | pToRemove->m_pVerticalAxis->UnregisterSeries(pToRemove); 493 | pToRemove->m_pHorizontalAxis->UnregisterSeries(pToRemove); 494 | pToRemove->m_pVerticalAxis->RefreshAutoAxis(); 495 | pToRemove->m_pHorizontalAxis->RefreshAutoAxis(); 496 | delete pToRemove; 497 | RefreshCtrl(); 498 | EnableRefresh(true); 499 | } 500 | } 501 | 502 | void CChartCtrl::RemoveAllSeries() 503 | { 504 | std::vector::iterator iter = m_pSeriesList.begin(); 505 | for (iter; iter != m_pSeriesList.end(); iter++) 506 | { 507 | delete (*iter); 508 | } 509 | 510 | m_pSeriesList.clear(); 511 | RefreshCtrl(); 512 | } 513 | 514 | 515 | CChartAxis* CChartCtrl::GetBottomAxis() const 516 | { 517 | return (m_pAxisList[0]); 518 | } 519 | 520 | CChartAxis* CChartCtrl::GetLeftAxis() const 521 | { 522 | return (m_pAxisList[1]); 523 | } 524 | 525 | CChartAxis* CChartCtrl::GetTopAxis() const 526 | { 527 | return (m_pAxisList[2]); 528 | } 529 | 530 | CChartAxis* CChartCtrl::GetRightAxis() const 531 | { 532 | return (m_pAxisList[3]); 533 | } 534 | 535 | 536 | CDC* CChartCtrl::GetDC() 537 | { 538 | return &m_BackgroundDC; 539 | } 540 | 541 | 542 | size_t CChartCtrl::GetSeriesCount() const 543 | { 544 | return m_pSeriesList.size(); 545 | } 546 | 547 | void CChartCtrl::OnMouseMove(UINT nFlags, CPoint point) 548 | { 549 | if (m_bRMouseDown && m_bPanEnabled) 550 | { 551 | if (point != m_PanAnchor) 552 | { 553 | GetLeftAxis()->PanAxis(m_PanAnchor.y,point.y); 554 | GetRightAxis()->PanAxis(m_PanAnchor.y,point.y); 555 | GetBottomAxis()->PanAxis(m_PanAnchor.x,point.x); 556 | GetTopAxis()->PanAxis(m_PanAnchor.x,point.x); 557 | 558 | RefreshCtrl(); 559 | m_PanAnchor = point; 560 | } 561 | } 562 | 563 | if (m_bLMouseDown && m_bZoomEnabled) 564 | { 565 | m_rectZoomArea.BottomRight() = point; 566 | Invalidate(); 567 | } 568 | 569 | for (int i=0; i<4; i++) 570 | m_pAxisList[i]->m_pScrollBar->OnMouseLeave(); 571 | CWnd* pWnd = ChildWindowFromPoint(point); 572 | if (pWnd != this) 573 | { 574 | CChartScrollBar* pScrollBar = dynamic_cast(pWnd); 575 | if (pScrollBar) 576 | pScrollBar->OnMouseEnter(); 577 | } 578 | 579 | CWnd::OnMouseMove(nFlags, point); 580 | } 581 | 582 | void CChartCtrl::OnRButtonDown(UINT nFlags, CPoint point) 583 | { 584 | SetCapture(); 585 | m_bRMouseDown = true; 586 | if (m_bPanEnabled) 587 | m_PanAnchor = point; 588 | 589 | CWnd::OnLButtonDown(nFlags, point); 590 | } 591 | 592 | void CChartCtrl::OnRButtonUp(UINT nFlags, CPoint point) 593 | { 594 | ReleaseCapture(); 595 | m_bRMouseDown = false; 596 | CWnd::OnLButtonUp(nFlags, point); 597 | } 598 | 599 | void CChartCtrl::OnLButtonDown(UINT nFlags, CPoint point) 600 | { 601 | SetCapture(); 602 | if (m_bZoomEnabled) 603 | { 604 | m_bLMouseDown = true; 605 | m_rectZoomArea.TopLeft() = point; 606 | m_rectZoomArea.BottomRight() = point; 607 | } 608 | 609 | CWnd::OnLButtonDown(nFlags, point); 610 | } 611 | 612 | void CChartCtrl::OnLButtonUp(UINT nFlags, CPoint point) 613 | { 614 | ReleaseCapture(); 615 | m_bLMouseDown = false; 616 | if (m_bZoomEnabled) 617 | { 618 | if ( (m_rectZoomArea.left > m_rectZoomArea.right) || 619 | (m_rectZoomArea.top > m_rectZoomArea.bottom)) 620 | { 621 | UndoPanZoom(); 622 | } 623 | else if ( (m_rectZoomArea.left!=m_rectZoomArea.right) && 624 | (m_rectZoomArea.top!=m_rectZoomArea.bottom)) 625 | { 626 | CChartAxis* pBottom = GetBottomAxis(); 627 | double MinVal = 0; 628 | double MaxVal = 0; 629 | 630 | if (pBottom->IsInverted()) 631 | { 632 | MaxVal = pBottom->ScreenToValue(m_rectZoomArea.left); 633 | MinVal = pBottom->ScreenToValue(m_rectZoomArea.right); 634 | } 635 | else 636 | { 637 | MinVal = pBottom->ScreenToValue(m_rectZoomArea.left); 638 | MaxVal = pBottom->ScreenToValue(m_rectZoomArea.right); 639 | } 640 | pBottom->SetZoomMinMax(MinVal,MaxVal); 641 | 642 | CChartAxis* pLeft = GetLeftAxis(); 643 | if (pLeft->IsInverted()) 644 | { 645 | MaxVal = pLeft->ScreenToValue(m_rectZoomArea.bottom); 646 | MinVal = pLeft->ScreenToValue(m_rectZoomArea.top); 647 | } 648 | else 649 | { 650 | MinVal = pLeft->ScreenToValue(m_rectZoomArea.bottom); 651 | MaxVal = pLeft->ScreenToValue(m_rectZoomArea.top); 652 | } 653 | pLeft->SetZoomMinMax(MinVal,MaxVal); 654 | 655 | CChartAxis* pTop = GetTopAxis(); 656 | if (pTop->IsInverted()) 657 | { 658 | MaxVal = pTop->ScreenToValue(m_rectZoomArea.left); 659 | MinVal = pTop->ScreenToValue(m_rectZoomArea.right); 660 | } 661 | else 662 | { 663 | MinVal = pTop->ScreenToValue(m_rectZoomArea.left); 664 | MaxVal = pTop->ScreenToValue(m_rectZoomArea.right); 665 | } 666 | pTop->SetZoomMinMax(MinVal,MaxVal); 667 | 668 | CChartAxis* pRight = GetRightAxis(); 669 | if (pRight->IsInverted()) 670 | { 671 | MaxVal = pRight->ScreenToValue(m_rectZoomArea.bottom); 672 | MinVal = pRight->ScreenToValue(m_rectZoomArea.top); 673 | } 674 | else 675 | { 676 | MinVal = pRight->ScreenToValue(m_rectZoomArea.bottom); 677 | MaxVal = pRight->ScreenToValue(m_rectZoomArea.top); 678 | } 679 | pRight->SetZoomMinMax(MinVal,MaxVal); 680 | 681 | RefreshCtrl(); 682 | } 683 | } 684 | 685 | CWnd::OnLButtonUp(nFlags, point); 686 | } 687 | 688 | void CChartCtrl::OnSize(UINT nType, int cx, int cy) 689 | { 690 | CWnd::OnSize(nType, cx, cy); 691 | 692 | // Force recreation of background DC 693 | if (m_BackgroundDC.GetSafeHdc() ) 694 | m_BackgroundDC.DeleteDC(); 695 | 696 | RefreshCtrl(); 697 | } 698 | 699 | double CChartCtrl::DateToValue(const COleDateTime& Date) 700 | { 701 | return (DATE)Date; 702 | } 703 | 704 | COleDateTime CChartCtrl::ValueToDate(double Value) 705 | { 706 | COleDateTime RetDate((DATE)Value); 707 | return RetDate; 708 | } 709 | 710 | void CChartCtrl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 711 | { 712 | CChartScrollBar* pChartBar = dynamic_cast(pScrollBar); 713 | if (pChartBar) 714 | pChartBar->OnHScroll(nSBCode, nPos); 715 | 716 | CWnd::OnHScroll(nSBCode, nPos, pScrollBar); 717 | RefreshCtrl(); 718 | } 719 | 720 | void CChartCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 721 | { 722 | CChartScrollBar* pChartBar = dynamic_cast(pScrollBar); 723 | if (pChartBar) 724 | pChartBar->OnVScroll(nSBCode, nPos); 725 | 726 | CWnd::OnVScroll(nSBCode, nPos, pScrollBar); 727 | RefreshCtrl(); 728 | } 729 | 730 | void CChartCtrl::Print(const TChartString& strTitle, CPrintDialog* pPrntDialog) 731 | { 732 | CDC dc; 733 | if (pPrntDialog == NULL) 734 | { 735 | CPrintDialog printDlg(FALSE); 736 | if (printDlg.DoModal() != IDOK) // Get printer settings from user 737 | return; 738 | 739 | dc.Attach(printDlg.GetPrinterDC()); // attach a printer DC 740 | } 741 | else 742 | dc.Attach(pPrntDialog->GetPrinterDC()); // attach a printer DC 743 | dc.m_bPrinting = TRUE; 744 | 745 | DOCINFO di; // Initialise print doc details 746 | memset(&di, 0, sizeof (DOCINFO)); 747 | di.cbSize = sizeof (DOCINFO); 748 | di.lpszDocName = strTitle.c_str(); 749 | 750 | BOOL bPrintingOK = dc.StartDoc(&di); // Begin a new print job 751 | 752 | CPrintInfo Info; 753 | Info.m_rectDraw.SetRect(0,0, dc.GetDeviceCaps(HORZRES), dc.GetDeviceCaps(VERTRES)); 754 | 755 | OnBeginPrinting(&dc, &Info); // Initialise printing 756 | for (UINT page = Info.GetMinPage(); page <= Info.GetMaxPage() && bPrintingOK; page++) 757 | { 758 | dc.StartPage(); // begin new page 759 | Info.m_nCurPage = page; 760 | OnPrint(&dc, &Info); // Print page 761 | bPrintingOK = (dc.EndPage() > 0); // end page 762 | } 763 | OnEndPrinting(&dc, &Info); // Clean up after printing 764 | 765 | if (bPrintingOK) 766 | dc.EndDoc(); // end a print job 767 | else 768 | dc.AbortDoc(); // abort job. 769 | 770 | dc.Detach(); // detach the printer DC 771 | } 772 | 773 | void CChartCtrl::OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo) 774 | { 775 | // OnBeginPrinting() is called after the user has committed to 776 | // printing by OK'ing the Print dialog, and after the framework 777 | // has created a CDC object for the printer or the preview view. 778 | 779 | // This is the right opportunity to set up the page range. 780 | // Given the CDC object, we can determine how many rows will 781 | // fit on a page, so we can in turn determine how many printed 782 | // pages represent the entire document. 783 | ASSERT(pDC && pInfo); 784 | 785 | // Get a DC for the current window (will be a screen DC for print previewing) 786 | CDC *pCurrentDC = GetDC(); // will have dimensions of the client area 787 | if (!pCurrentDC) 788 | return; 789 | 790 | CSize PaperPixelsPerInch(pDC->GetDeviceCaps(LOGPIXELSX), pDC->GetDeviceCaps(LOGPIXELSY)); 791 | CSize ScreenPixelsPerInch(pCurrentDC->GetDeviceCaps(LOGPIXELSX), pCurrentDC->GetDeviceCaps(LOGPIXELSY)); 792 | 793 | // Create the printer font 794 | int nFontSize = -10; 795 | CString strFontName = _T("Arial"); 796 | m_PrinterFont.CreateFont(nFontSize, 0,0,0, FW_NORMAL, 0,0,0, DEFAULT_CHARSET, 797 | OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, 798 | DEFAULT_PITCH | FF_DONTCARE, strFontName); 799 | CFont *pOldFont = pDC->SelectObject(&m_PrinterFont); 800 | 801 | // Get the page sizes (physical and logical) 802 | m_PaperSize = CSize(pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES)); 803 | 804 | m_LogicalPageSize.cx = ScreenPixelsPerInch.cx * m_PaperSize.cx / PaperPixelsPerInch.cx * 3 / 4; 805 | m_LogicalPageSize.cy = ScreenPixelsPerInch.cy * m_PaperSize.cy / PaperPixelsPerInch.cy * 3 / 4; 806 | 807 | 808 | // Set up the print info 809 | pInfo->SetMaxPage(1); 810 | pInfo->m_nCurPage = 1; // start printing at page# 1 811 | 812 | ReleaseDC(pCurrentDC); 813 | pDC->SelectObject(pOldFont); 814 | } 815 | 816 | void CChartCtrl::OnPrint(CDC *pDC, CPrintInfo *pInfo) 817 | { 818 | if (!pDC || !pInfo) 819 | return; 820 | 821 | CFont *pOldFont = pDC->SelectObject(&m_PrinterFont); 822 | 823 | // Set the page map mode to use GraphCtrl units 824 | pDC->SetMapMode(MM_ANISOTROPIC); 825 | pDC->SetWindowExt(m_LogicalPageSize); 826 | pDC->SetViewportExt(m_PaperSize); 827 | pDC->SetWindowOrg(0, 0); 828 | 829 | // Header 830 | pInfo->m_rectDraw.top = 0; 831 | pInfo->m_rectDraw.left = 0; 832 | pInfo->m_rectDraw.right = m_LogicalPageSize.cx; 833 | pInfo->m_rectDraw.bottom = m_LogicalPageSize.cy; 834 | 835 | DrawChart(pDC, &pInfo->m_rectDraw); 836 | 837 | // SetWindowOrg back for next page 838 | pDC->SetWindowOrg(0,0); 839 | 840 | pDC->SelectObject(pOldFont); 841 | } 842 | 843 | void CChartCtrl::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 844 | { 845 | m_PrinterFont.DeleteObject(); 846 | // RefreshCtrl is needed because the print job 847 | // modifies the chart components (axis, ...) 848 | RefreshCtrl(); 849 | } -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartCtrl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartCtrl.h -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartGradient.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartGradient.cpp -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartGradient.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartGradient.h -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartGrid.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartGrid.cpp -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartGrid.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartGrid.h -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartLegend.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartLegend.cpp -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartLegend.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartLegend.h -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartLineSerie.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartLineSerie.cpp -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartLineSerie.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartLineSerie.h -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartObject.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartObject.cpp -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartObject.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartObject.h -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartPointsSerie.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartPointsSerie.cpp -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartPointsSerie.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartPointsSerie.h -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartScrollBar.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartScrollBar.cpp -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartScrollBar.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartScrollBar.h -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartSerie.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartSerie.cpp -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartSerie.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartSerie.h -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartString.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartString.h -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartSurfaceSerie.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartSurfaceSerie.cpp -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartSurfaceSerie.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartSurfaceSerie.h -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartTitle.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartTitle.cpp -------------------------------------------------------------------------------- /MyFirewall/Chart/ChartTitle.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/Chart/ChartTitle.h -------------------------------------------------------------------------------- /MyFirewall/Chart/SeriesPropDlg.h: -------------------------------------------------------------------------------- 1 | #if !defined(AFX_SERIESPROPDLG_H__EFFE6C6F_39A1_42E7_9B35_1EE66D5AC520__INCLUDED_) 2 | #define AFX_SERIESPROPDLG_H__EFFE6C6F_39A1_42E7_9B35_1EE66D5AC520__INCLUDED_ 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif // _MSC_VER > 1000 7 | // SeriesPropDlg.h : header file 8 | // 9 | 10 | #include "ChartString.h" 11 | #include "ColourPicker.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | // CSeriesPropDlg dialog 15 | 16 | class CSeriesPropDlg : public CDialog 17 | { 18 | // Construction 19 | public: 20 | // std::string GetSeriesName() const { return m_strSeriesName; } 21 | // int GetSeriesType() const { return m_iSeriesType; } 22 | // COLORREF GetSeriesColour() const { return m_SeriesColour; } 23 | 24 | CSeriesPropDlg(CWnd* pParent = NULL); // standard constructor 25 | 26 | // Dialog Data 27 | //{{AFX_DATA(CSeriesPropDlg) 28 | enum { IDD = IDD_SERIESPROP_DLG }; 29 | CComboBox m_VertAxisCombo; 30 | CComboBox m_HorizAxisCombo; 31 | CColourPicker m_ColourSelect; 32 | CComboBox m_SeriesTypeCombo; 33 | //}}AFX_DATA 34 | 35 | 36 | // Overrides 37 | // ClassWizard generated virtual function overrides 38 | //{{AFX_VIRTUAL(CSeriesPropDlg) 39 | protected: 40 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 41 | //}}AFX_VIRTUAL 42 | 43 | // Implementation 44 | protected: 45 | 46 | // Generated message map functions 47 | //{{AFX_MSG(CSeriesPropDlg) 48 | virtual void OnOK(); 49 | virtual BOOL OnInitDialog(); 50 | afx_msg void OnSelectLineData(); 51 | afx_msg void OnSelectRandomData(); 52 | afx_msg void OnSelectSineData(); 53 | //}}AFX_MSG 54 | DECLARE_MESSAGE_MAP() 55 | 56 | public: 57 | TChartString m_strSeriesName; 58 | int m_iSeriesType; 59 | COLORREF m_SeriesColour; 60 | 61 | int m_iVertAxis; 62 | int m_iHorizAxis; 63 | 64 | int m_iDataType; 65 | int m_iPointsNumber; 66 | float m_fMaxXValue; 67 | float m_fMinXValue; 68 | 69 | //Line data: 70 | float m_fLineSlope; 71 | float m_fLineOffset; 72 | 73 | // Sine wave data: 74 | float m_fSineAmplitude; 75 | float m_fSinePeriod; 76 | 77 | // Random values data: 78 | int m_iRandMinVal; 79 | int m_iRandMaxVal; 80 | }; 81 | 82 | //{{AFX_INSERT_LOCATION}} 83 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 84 | 85 | #endif // !defined(AFX_SERIESPROPDLG_H__EFFE6C6F_39A1_42E7_9B35_1EE66D5AC520__INCLUDED_) 86 | -------------------------------------------------------------------------------- /MyFirewall/Chart/StdAfx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #if !defined(AFX_STDAFX_H__F1B266DB_B914_41ED_B713_A3CB4AC72DE8__INCLUDED_) 7 | #define AFX_STDAFX_H__F1B266DB_B914_41ED_B713_A3CB4AC72DE8__INCLUDED_ 8 | 9 | #if _MSC_VER > 1000 10 | #pragma once 11 | #endif // _MSC_VER > 1000 12 | 13 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 14 | 15 | #include // MFC core and standard components 16 | #include // MFC extensions 17 | #include // MFC support for Internet Explorer 4 Common Controls 18 | #ifndef _AFX_NO_AFXCMN_SUPPORT 19 | #include // MFC support for Windows Common Controls 20 | #endif // _AFX_NO_AFXCMN_SUPPORT 21 | 22 | 23 | //{{AFX_INSERT_LOCATION}} 24 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 25 | 26 | #pragma warning (disable:4786) 27 | 28 | #endif // !defined(AFX_STDAFX_H__F1B266DB_B914_41ED_B713_A3CB4AC72DE8__INCLUDED_) 29 | -------------------------------------------------------------------------------- /MyFirewall/Chart/SurfacePropDialog.h: -------------------------------------------------------------------------------- 1 | #if !defined(AFX_SURFACEPROPDIALOG_H__88893012_E2F3_477F_833A_B3D7B10CC8A8__INCLUDED_) 2 | #define AFX_SURFACEPROPDIALOG_H__88893012_E2F3_477F_833A_B3D7B10CC8A8__INCLUDED_ 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif // _MSC_VER > 1000 7 | // SurfacePropDialog.h : header file 8 | // 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // CSurfacePropDialog dialog 12 | 13 | class CSurfacePropDialog : public CDialog 14 | { 15 | // Construction 16 | public: 17 | CSurfacePropDialog(CWnd* pParent = NULL); // standard constructor 18 | 19 | // Dialog Data 20 | //{{AFX_DATA(CSurfacePropDialog) 21 | enum { IDD = IDD_SURFACEPROP_DLG }; 22 | int m_iHorizSurf; 23 | int m_FillStyle; 24 | //}}AFX_DATA 25 | 26 | 27 | // Overrides 28 | // ClassWizard generated virtual function overrides 29 | //{{AFX_VIRTUAL(CSurfacePropDialog) 30 | protected: 31 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 32 | //}}AFX_VIRTUAL 33 | 34 | // Implementation 35 | protected: 36 | 37 | // Generated message map functions 38 | //{{AFX_MSG(CSurfacePropDialog) 39 | virtual BOOL OnInitDialog(); 40 | virtual void OnOK(); 41 | //}}AFX_MSG 42 | DECLARE_MESSAGE_MAP() 43 | }; 44 | 45 | //{{AFX_INSERT_LOCATION}} 46 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 47 | 48 | #endif // !defined(AFX_SURFACEPROPDIALOG_H__88893012_E2F3_477F_833A_B3D7B10CC8A8__INCLUDED_) 49 | -------------------------------------------------------------------------------- /MyFirewall/Chart/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by ChartDemo.rc 4 | // 5 | #define IDM_ABOUTBOX 0x0010 6 | #define IDD_ABOUTBOX 100 7 | #define IDS_ABOUTBOX 101 8 | #define IDD_CHARTDEMO_DIALOG 102 9 | #define IDR_MAINFRAME 128 10 | #define IDD_SERIESPROP_DLG 131 11 | #define IDD_LINEPROP_DLG 135 12 | #define IDD_SURFACEPROP_DLG 137 13 | #define IDD_POINTPROP_DLG 139 14 | #define IDC_CHARTCTRL 1001 15 | #define IDC_SERIES_GROUP 1007 16 | #define IDC_ADDSERIES 1009 17 | #define IDC_SERIESNAME_EDIT 1010 18 | #define IDC_SERIESTYPE_COMBO 1011 19 | #define IDC_SERIESCOLOUR_BTN 1012 20 | #define IDC_SERIES_LIST 1013 21 | #define IDC_GENERAL_GROUP 1014 22 | #define IDC_LEGENDVIS_CHECK 1015 23 | #define IDC_BKGND_COLBTN 1016 24 | #define IDC_AXIS_GROUP 1017 25 | #define IDC_LEFTAXIS_RADIO 1018 26 | #define IDC_BOTTOMAXIS_RADIO 1019 27 | #define IDC_RIGHTAXIS_RADIO 1020 28 | #define IDC_TOPAXIS_RADIO 1021 29 | #define IDC_AXISVISIBLE_CHECK 1022 30 | #define IDC_AXISAUTOMATIC_CHECK 1023 31 | #define IDC_AXISGRIDVIS_CHECK 1024 32 | #define IDC_AXISMINVAL_EDIT 1025 33 | #define IDC_AXISMAXVAL_EDIT 1026 34 | #define IDC_AXISLOGARITHMIC_CHECK 1027 35 | #define IDC_AXISMINVAL_STATIC 1028 36 | #define IDC_AXISMAXVAL_STATIC 1029 37 | #define IDC_TITLE_EDIT 1033 38 | #define IDC_VERTICALAXIS_COMBO 1034 39 | #define IDC_HORIZONTALAXIS_COMBO 1035 40 | #define IDC_LINEDATA_RADIO 1036 41 | #define IDC_SINEDATA_RADIO 1037 42 | #define IDC_RANDOMDATA_RADIO 1038 43 | #define IDC_MINXVALUE_EDIT 1039 44 | #define IDC_MAXXVALUE_EDIT 1040 45 | #define IDC_POINTSNUMBER_EDIT 1043 46 | #define IDC_DATAPARAM1_EDIT 1044 47 | #define IDC_DATAPARAM2_EDIT 1045 48 | #define IDC_DATAPARAM1_TEXT 1046 49 | #define IDC_DATAPARAM2_TEXT 1047 50 | #define IDC_AXISINVERTED_CHECK 1048 51 | #define IDC_AXISLABEL_EDIT 1049 52 | #define IDC_DELETESERIES 1050 53 | #define IDC_CHART2 1052 54 | #define IDC_BUTTON1 1054 55 | #define IDC_PRINT 1054 56 | #define IDC_PAN_CHECK 1055 57 | #define IDC_ZOOM_CHECK 1056 58 | #define IDC_PENSTYLE_COMBO 1058 59 | #define IDC_LINEWIDTH_EDIT 1059 60 | #define IDC_HORIZONTAL_RADIO 1060 61 | #define IDC_RADIO2 1061 62 | #define IDC_FILLSTYLE_COMBO 1062 63 | #define IDC_POINTTYPE_COMBO 1063 64 | #define IDC_POINTWIDTH_EDIT 1064 65 | #define IDC_POINTHEIGHT_EDIT 1065 66 | #define IDC_CHECK1 1066 67 | #define IDC_AXISSCROLLBAR_CHECK 1066 68 | 69 | // Next default values for new objects 70 | // 71 | #ifdef APSTUDIO_INVOKED 72 | #ifndef APSTUDIO_READONLY_SYMBOLS 73 | #define _APS_NEXT_RESOURCE_VALUE 141 74 | #define _APS_NEXT_COMMAND_VALUE 32771 75 | #define _APS_NEXT_CONTROL_VALUE 1067 76 | #define _APS_NEXT_SYMED_VALUE 101 77 | #endif 78 | #endif 79 | -------------------------------------------------------------------------------- /MyFirewall/DriverHelper.cpp: -------------------------------------------------------------------------------- 1 | //if you use this code in a mfc program: 2 | //add the header stdafx.h or disable precompiled header 3 | //Unless you do it, when compiling vc will say: Unexpected end 4 | //of file while looking for precompiled header 5 | 6 | #include "stdafx.h" 7 | #include "DriverHelper.h" 8 | #include "winsvc.h" 9 | 10 | 11 | 12 | //Constructor. Initialize variables. 13 | DriverHelper::DriverHelper(void) 14 | { 15 | driverHandle = NULL; 16 | 17 | removable = TRUE; 18 | 19 | driverName = NULL; 20 | driverPath = NULL; 21 | driverDosName = NULL; 22 | 23 | initialized = FALSE; 24 | loaded = FALSE; 25 | started = FALSE; 26 | } 27 | 28 | 29 | //Destructor. Free resources and unload the driver. 30 | DriverHelper::~DriverHelper(void) 31 | { 32 | if(driverHandle != NULL) 33 | { 34 | CloseHandle(driverHandle); 35 | driverHandle = NULL; 36 | } 37 | 38 | UnloadDriver(); 39 | } 40 | 41 | //If removable = TRUE, the driver isnt unload when exit 42 | void DriverHelper::SetRemovable(BOOL value) 43 | { 44 | removable = value; 45 | } 46 | 47 | 48 | //is driver initialized? 49 | BOOL DriverHelper::IsInitialized(void) 50 | { 51 | return initialized; 52 | } 53 | 54 | //is driver loaded? 55 | BOOL DriverHelper::IsLoaded(void) 56 | { 57 | return loaded; 58 | } 59 | 60 | //is driver started? 61 | BOOL DriverHelper::IsStarted(void) 62 | { 63 | return started; 64 | } 65 | 66 | 67 | //Init the driver class variables 68 | DWORD DriverHelper::InitDriver(LPCTSTR path) 69 | { 70 | //if already initialized, first unload 71 | if(initialized) 72 | { 73 | if(UnloadDriver() != DRV_SUCCESS) 74 | return DRV_ERROR_ALREADY_INITIALIZED; 75 | } 76 | 77 | //if yes, i analized the path to extract driver name 78 | driverPath = (LPTSTR)LocalAlloc(0, (_tcslen(path) + 1)*sizeof(TCHAR)); 79 | 80 | if(driverPath == NULL) 81 | return DRV_ERROR_MEMORY; 82 | 83 | _tcscpy(driverPath, path); 84 | 85 | 86 | //first i search the last backslash 87 | LPTSTR sPos1 = _tcsrchr(driverPath, (int)'\\'); 88 | 89 | //if null, the string havent any backslash 90 | if (sPos1 == NULL) 91 | sPos1 = driverPath; 92 | 93 | 94 | //now, i search .sys 95 | LPTSTR sPos2 = _tcsrchr(sPos1, (int)'.'); 96 | 97 | if (sPos2 == NULL || sPos1 > sPos2) 98 | { 99 | LocalFree(driverPath); 100 | driverPath = NULL; 101 | 102 | return DRV_ERROR_INVALID_PATH_OR_FILE; 103 | } 104 | 105 | //extract the driver name 106 | driverName = (LPTSTR) LocalAlloc(0, (sPos2 - sPos1)*sizeof(TCHAR)); 107 | 108 | if(driverName == NULL) 109 | { 110 | LocalFree(driverPath); 111 | driverPath = NULL; 112 | 113 | return DRV_ERROR_MEMORY; 114 | } 115 | 116 | memcpy(driverName, sPos1 + 1, sPos2 - sPos1 - 1); 117 | 118 | driverName[sPos2 - sPos1 - 1] = 0; 119 | 120 | //driverDosName = \\.\driverName 121 | driverDosName = (LPTSTR) LocalAlloc(0, (_tcslen(driverName) + 5)*sizeof(TCHAR)); 122 | 123 | if(driverDosName == NULL) 124 | { 125 | LocalFree(driverPath); 126 | driverPath = NULL; 127 | 128 | LocalFree(driverName); 129 | driverName = NULL; 130 | 131 | return DRV_ERROR_MEMORY; 132 | } 133 | 134 | _stprintf(driverDosName, _T("\\\\.\\%s"), driverName); 135 | 136 | 137 | initialized = TRUE; 138 | return DRV_SUCCESS; 139 | } 140 | 141 | 142 | //Init the driver class variables 143 | DWORD DriverHelper::InitDriver(LPCTSTR name, LPCTSTR path, LPCTSTR dosName) 144 | { 145 | //if already initialized, first unload 146 | if(initialized) 147 | { 148 | if(UnloadDriver() != DRV_SUCCESS){ 149 | //AfxMessageBox(_T("1")); 150 | return DRV_ERROR_ALREADY_INITIALIZED; 151 | } 152 | } 153 | 154 | LPTSTR dirBuffer; 155 | 156 | //if the user introduced path, first i will ckeck it 157 | if (path != NULL) 158 | { 159 | //if yes, copy in auxiliar buffer and continue 160 | DWORD len = (DWORD)(_tcslen(name) + _tcslen(path) + 1); 161 | dirBuffer = (LPTSTR) LocalAlloc(0, len*sizeof(TCHAR)); 162 | 163 | if(dirBuffer == NULL) 164 | { 165 | //AfxMessageBox(_T("2")); 166 | return DRV_ERROR_MEMORY; 167 | } 168 | 169 | _tcscpy(dirBuffer, path); 170 | 171 | } 172 | 173 | else 174 | { 175 | //if the user dont introduced path, i search in curren directory 176 | LPTSTR pathBuffer; 177 | DWORD len = GetCurrentDirectory(0, NULL); 178 | int TCHARSize = sizeof(TCHAR); 179 | pathBuffer = (LPTSTR) LocalAlloc(0, len*sizeof(TCHAR)); 180 | 181 | if(pathBuffer == NULL) 182 | { 183 | //AfxMessageBox(_T("3")); 184 | return DRV_ERROR_MEMORY; 185 | } 186 | 187 | 188 | if (GetCurrentDirectory(len, pathBuffer) != 0) 189 | { 190 | len = (DWORD)(_tcslen(pathBuffer) + _tcslen(name) + 6); 191 | dirBuffer = (LPTSTR) LocalAlloc(0, len*sizeof(TCHAR)); 192 | if(dirBuffer == NULL) 193 | { 194 | LocalFree(pathBuffer); 195 | //AfxMessageBox(_T("4")); 196 | 197 | return DRV_ERROR_MEMORY; 198 | } 199 | 200 | //complete de total path, currentdirectory\driverName.sys 201 | _stprintf(dirBuffer, _T("%s\\%s.sys"), pathBuffer, name); 202 | int other= _tcslen(dirBuffer); 203 | ASSERT((len >= other)); 204 | //exists this file? 205 | if(GetFileAttributes(dirBuffer) == 0xFFFFFFFF) 206 | { 207 | LocalFree(pathBuffer); 208 | LocalFree(dirBuffer); 209 | 210 | //if no, i search in \system32\drivers\ 211 | LPCTSTR sysDriver = _T("\\system32\\Drivers\\"); 212 | LPTSTR sysPath; 213 | 214 | //i have to get the windows directory 215 | DWORD len = GetWindowsDirectory(NULL, 0); 216 | sysPath = (LPTSTR) LocalAlloc(0, (len + _tcslen(sysDriver))*sizeof(TCHAR)); 217 | 218 | if(sysPath == NULL) 219 | return DRV_ERROR_MEMORY; 220 | 221 | if (GetWindowsDirectory(sysPath, len) == 0) 222 | { 223 | LocalFree(sysPath); 224 | //AfxMessageBox(_T("5")); 225 | 226 | return DRV_ERROR_UNKNOWN; 227 | } 228 | 229 | //complete the path and check it 230 | _tcscat(sysPath, sysDriver); 231 | len = (DWORD)(_tcslen(sysPath) + _tcslen(name) + 5); 232 | 233 | dirBuffer = (LPTSTR) LocalAlloc(0, len*sizeof(TCHAR)); 234 | 235 | if(dirBuffer == NULL) 236 | { 237 | //AfxMessageBox(_T("6")); 238 | return DRV_ERROR_MEMORY; 239 | } 240 | _stprintf(dirBuffer, _T("%s%s.sys"), sysPath, name); 241 | 242 | LocalFree(sysPath); 243 | 244 | //if the file neither exist, i dont know where is it -> i dont initialize 245 | if(GetFileAttributes(dirBuffer) == 0xFFFFFFFF) 246 | { 247 | //AfxMessageBox(dirBuffer); 248 | LocalFree(dirBuffer); 249 | 250 | return DRV_ERROR_INVALID_PATH_OR_FILE; 251 | } 252 | } 253 | } 254 | 255 | else 256 | { 257 | LocalFree(pathBuffer); 258 | //AfxMessageBox(_T("8")); 259 | 260 | return DRV_ERROR_UNKNOWN; 261 | } 262 | } 263 | 264 | 265 | //Write driver's variables with obtained data 266 | driverPath = dirBuffer; 267 | driverName = (LPTSTR)LocalAlloc(0, (_tcslen(name) + 1)*sizeof(TCHAR)); 268 | 269 | if(driverName == NULL) 270 | { 271 | LocalFree(driverPath); 272 | driverPath = NULL; 273 | //AfxMessageBox(_T("9")); 274 | return DRV_ERROR_MEMORY; 275 | } 276 | _tcscpy(driverName, name); 277 | LPCTSTR auxBuffer; 278 | if(dosName != NULL) 279 | auxBuffer = dosName; 280 | 281 | else 282 | auxBuffer = name; 283 | 284 | //dosName=\\.\driverName 285 | if(auxBuffer[0] != '\\' && auxBuffer[1] != '\\') 286 | { 287 | //error occur 288 | driverDosName = (LPTSTR) LocalAlloc (0, (_tcslen(auxBuffer) + 5)*sizeof(TCHAR)); 289 | 290 | if(driverDosName == NULL) 291 | { 292 | LocalFree(driverPath); 293 | driverPath = NULL; 294 | 295 | LocalFree(driverName); 296 | driverName = NULL; 297 | //AfxMessageBox(_T("10")); 298 | 299 | return DRV_ERROR_MEMORY; 300 | } 301 | 302 | _stprintf(driverDosName, _T("\\\\.\\%s"), auxBuffer); 303 | } 304 | 305 | else 306 | { 307 | driverDosName = (LPTSTR) LocalAlloc(0, _tcslen(auxBuffer)*sizeof(TCHAR)); 308 | 309 | if(driverDosName == NULL) 310 | { 311 | LocalFree(driverPath); 312 | driverPath = NULL; 313 | 314 | LocalFree(driverName); 315 | driverName = NULL; 316 | //AfxMessageBox(_T("11")); 317 | 318 | return DRV_ERROR_MEMORY; 319 | } 320 | 321 | _tcscpy(driverDosName, auxBuffer); 322 | } 323 | 324 | //set the state to initialized 325 | //AfxMessageBox(driverPath); 326 | initialized = TRUE; 327 | 328 | return DRV_SUCCESS; 329 | } 330 | 331 | 332 | //Function to Load the driver. 333 | DWORD DriverHelper::LoadDriver(LPCTSTR name, LPCTSTR path, LPCTSTR dosName, BOOL start) 334 | { 335 | //first initialized it 336 | DWORD retCode = InitDriver(name, path, dosName); 337 | 338 | //then load 339 | if(retCode == DRV_SUCCESS) 340 | retCode = LoadDriver(start); 341 | 342 | return retCode; 343 | } 344 | 345 | //Function to load the driver 346 | DWORD DriverHelper::LoadDriver(LPCTSTR path, BOOL start) 347 | { 348 | //first initialized it 349 | DWORD retCode = InitDriver(path); 350 | 351 | //then load 352 | if(retCode == DRV_SUCCESS) 353 | retCode = LoadDriver(start); 354 | 355 | return retCode; 356 | } 357 | 358 | 359 | //Function to Load the driver 360 | DWORD DriverHelper::LoadDriver(BOOL start) 361 | { 362 | //if the driver is already started, i havent to do nothing 363 | if(loaded) 364 | return DRV_SUCCESS; 365 | 366 | if(!initialized) 367 | return DRV_ERROR_NO_INITIALIZED; 368 | 369 | //Open Service manager to create the new "service" 370 | SC_HANDLE SCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); 371 | DWORD retCode = DRV_SUCCESS; 372 | 373 | if (SCManager == NULL) 374 | return DRV_ERROR_SCM; 375 | 376 | 377 | 378 | //Create the driver "service" 379 | SC_HANDLE SCService = CreateService(SCManager, // SCManager database 380 | driverName, // nombre del servicio 381 | driverName, // nombre a mostrar 382 | SERVICE_ALL_ACCESS, // acceso total 383 | SERVICE_KERNEL_DRIVER, // driver del kernel 384 | SERVICE_DEMAND_START, // comienzo bajo demanda 385 | SERVICE_ERROR_NORMAL, // control de errores normal 386 | driverPath, // path del driver 387 | NULL, // no pertenece a un grupo 388 | NULL, // sin tag 389 | NULL, // sin dependencias 390 | NULL, // cuenta local del sistema 391 | NULL // sin password 392 | ); 393 | 394 | //if i cant create, first i check if the driver already was loaded. 395 | if (SCService == NULL) 396 | { 397 | SCService = OpenService(SCManager, driverName, SERVICE_ALL_ACCESS); 398 | 399 | if (SCService == NULL) 400 | retCode = DRV_ERROR_SERVICE; 401 | } 402 | 403 | CloseServiceHandle(SCService); 404 | SCService=NULL; 405 | 406 | CloseServiceHandle(SCManager); 407 | SCManager = NULL; 408 | 409 | //if all ok, update the state and start if necessary 410 | if(retCode == DRV_SUCCESS) 411 | { 412 | loaded = TRUE; 413 | 414 | if(start) 415 | retCode = StartDriver(); 416 | } 417 | 418 | return retCode; 419 | } 420 | 421 | 422 | //Function to Unload a driver 423 | DWORD DriverHelper::UnloadDriver(BOOL forceClearData) 424 | { 425 | DWORD retCode = DRV_SUCCESS; 426 | 427 | //if the driver is started, first i will stop it 428 | if (started) 429 | { 430 | if ((retCode = StopDriver()) == DRV_SUCCESS) 431 | { 432 | //i only remove it, if it is mark to be removable 433 | if(removable) 434 | { 435 | //open service and delete it 436 | SC_HANDLE SCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); 437 | 438 | if (SCManager == NULL) 439 | return DRV_ERROR_SCM; 440 | 441 | SC_HANDLE SCService = OpenService(SCManager, driverName, SERVICE_ALL_ACCESS); 442 | 443 | if (SCService != NULL) 444 | { 445 | if(!DeleteService(SCService)) 446 | retCode = DRV_ERROR_REMOVING; 447 | else 448 | retCode = DRV_SUCCESS; 449 | } 450 | 451 | else 452 | retCode = DRV_ERROR_SERVICE; 453 | 454 | CloseServiceHandle(SCService); 455 | SCService = NULL; 456 | 457 | CloseServiceHandle(SCManager); 458 | SCManager = NULL; 459 | 460 | //if all ok, update the state 461 | if(retCode == DRV_SUCCESS) 462 | loaded = FALSE; 463 | } 464 | } 465 | } 466 | 467 | //if the driver is initialized... 468 | if(initialized) 469 | { 470 | //if there was some problem but i mark foreceClear, i will remove the data 471 | if(retCode != DRV_SUCCESS && forceClearData == FALSE) 472 | return retCode; 473 | 474 | //update the state 475 | initialized = FALSE; 476 | 477 | //free memory 478 | if(driverPath != NULL) 479 | { 480 | LocalFree(driverPath); 481 | driverPath = NULL; 482 | } 483 | 484 | 485 | if(driverDosName != NULL) 486 | { 487 | LocalFree(driverDosName); 488 | driverDosName = NULL; 489 | } 490 | 491 | if(driverName != NULL) 492 | { 493 | LocalFree(driverName); 494 | driverName = NULL; 495 | } 496 | 497 | } 498 | 499 | return retCode; 500 | } 501 | 502 | 503 | 504 | //Function to start the driver "service" 505 | DWORD DriverHelper::StartDriver(void) 506 | { 507 | //if already started, all ok 508 | if(started) 509 | return DRV_SUCCESS; 510 | 511 | //open the service manager and the service and change driver state 512 | SC_HANDLE SCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); 513 | DWORD retCode; 514 | 515 | if (SCManager == NULL) 516 | return DRV_ERROR_SCM; 517 | 518 | SC_HANDLE SCService = OpenService(SCManager, 519 | driverName, 520 | SERVICE_ALL_ACCESS); 521 | 522 | if (SCService == NULL) 523 | return DRV_ERROR_SERVICE; 524 | 525 | 526 | if (!StartService( SCService, 0, NULL)) 527 | { 528 | //if the driver was started before i try to do it, 529 | //i will not remove, because it was created by other application 530 | if (GetLastError() == ERROR_SERVICE_ALREADY_RUNNING) 531 | { 532 | removable = FALSE; 533 | 534 | retCode = DRV_SUCCESS; 535 | } 536 | 537 | else 538 | retCode = DRV_ERROR_STARTING; 539 | } 540 | 541 | else 542 | retCode = DRV_SUCCESS; 543 | 544 | 545 | CloseServiceHandle(SCService); 546 | SCService = NULL; 547 | 548 | CloseServiceHandle(SCManager); 549 | SCManager = NULL; 550 | 551 | //update the state and open device 552 | if(retCode == DRV_SUCCESS) 553 | { 554 | started = TRUE; 555 | 556 | retCode = OpenDevice(); 557 | } 558 | 559 | return retCode; 560 | } 561 | 562 | 563 | 564 | //Function to stop driver "service" 565 | DWORD DriverHelper::StopDriver(void) 566 | { 567 | //if already stopped, all ok 568 | if(!started) 569 | return DRV_SUCCESS; 570 | 571 | //open the service manager and the service and change driver state 572 | SC_HANDLE SCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); 573 | DWORD retCode; 574 | 575 | if (SCManager == NULL) 576 | return DRV_ERROR_SCM; 577 | 578 | 579 | SERVICE_STATUS status; 580 | 581 | SC_HANDLE SCService = OpenService(SCManager, driverName, SERVICE_ALL_ACCESS); 582 | 583 | if (SCService != NULL) 584 | { 585 | //close the driver handle too 586 | CloseHandle(driverHandle); 587 | driverHandle = NULL; 588 | 589 | if(!ControlService(SCService, SERVICE_CONTROL_STOP, &status)) 590 | retCode = DRV_ERROR_STOPPING; 591 | 592 | else 593 | retCode = DRV_SUCCESS; 594 | } 595 | 596 | else 597 | retCode = DRV_ERROR_SERVICE; 598 | 599 | 600 | CloseServiceHandle(SCService); 601 | SCService = NULL; 602 | 603 | CloseServiceHandle(SCManager); 604 | SCManager = NULL; 605 | 606 | //update the state 607 | if(retCode == DRV_SUCCESS) 608 | started = FALSE; 609 | 610 | return retCode; 611 | } 612 | 613 | 614 | //Funtion to open a driver handle 615 | DWORD DriverHelper::OpenDevice(void) 616 | { 617 | //if i already have a handle, first close it 618 | if (driverHandle != NULL) 619 | CloseHandle(driverHandle); 620 | 621 | driverHandle = CreateFile(driverDosName, 622 | GENERIC_READ | GENERIC_WRITE, 623 | 0, 624 | NULL, 625 | OPEN_EXISTING, 626 | FILE_ATTRIBUTE_NORMAL, 627 | NULL); 628 | 629 | 630 | if(driverHandle == INVALID_HANDLE_VALUE) 631 | return DRV_ERROR_INVALID_HANDLE; 632 | 633 | return DRV_SUCCESS; 634 | } 635 | 636 | 637 | //Return the driverHandle obtained 638 | HANDLE DriverHelper::GetDriverHandle(void) 639 | { 640 | return driverHandle; 641 | } 642 | 643 | 644 | //Funtion to send data to the driver 645 | DWORD DriverHelper::WriteIo(DWORD code, PVOID buffer, DWORD count) 646 | { 647 | if(driverHandle == NULL) 648 | return DRV_ERROR_INVALID_HANDLE; 649 | 650 | DWORD bytesReturned; 651 | 652 | BOOL returnCode = DeviceIoControl(driverHandle, 653 | code, 654 | buffer, 655 | count, 656 | NULL, 657 | 0, 658 | &bytesReturned, 659 | NULL); 660 | 661 | if(!returnCode) 662 | return DRV_ERROR_IO; 663 | 664 | return DRV_SUCCESS; 665 | } 666 | 667 | 668 | //Functions to read data from the driver 669 | DWORD DriverHelper::ReadIo(DWORD code, PVOID buffer, DWORD count) 670 | { 671 | if(driverHandle == NULL) 672 | return DRV_ERROR_INVALID_HANDLE; 673 | 674 | DWORD bytesReturned; 675 | BOOL retCode = DeviceIoControl(driverHandle, 676 | code, 677 | NULL, 678 | 0, 679 | buffer, 680 | count, 681 | &bytesReturned, 682 | NULL); 683 | 684 | if(!retCode) 685 | return DRV_ERROR_IO; 686 | 687 | return bytesReturned; 688 | } 689 | 690 | 691 | //Function to do IO operation with the driver, read or write or both 692 | DWORD DriverHelper::RawIo(DWORD code, PVOID inBuffer, DWORD inCount, PVOID outBuffer, DWORD outCount) 693 | { 694 | if(driverHandle == NULL) 695 | return DRV_ERROR_INVALID_HANDLE; 696 | 697 | DWORD bytesReturned; 698 | BOOL retCode = DeviceIoControl(driverHandle, 699 | code, 700 | inBuffer, 701 | inCount, 702 | outBuffer, 703 | outCount, 704 | &bytesReturned, 705 | NULL); 706 | 707 | if(!retCode) 708 | return DRV_ERROR_IO; 709 | 710 | return bytesReturned; 711 | } 712 | -------------------------------------------------------------------------------- /MyFirewall/DriverHelper.h: -------------------------------------------------------------------------------- 1 | //ERROR CODES 2 | #pragma once 3 | 4 | #define DRV_SUCCESS (DWORD)0 //ALL OK 5 | 6 | #define DRV_ERROR_SCM (DWORD)-1 //ERROR at Open de Service Manager 7 | #define DRV_ERROR_SERVICE (DWORD)-2 //ERROR at create service 8 | #define DRV_ERROR_MEMORY (DWORD)-3 //ERROR at reserving memory 9 | #define DRV_ERROR_INVALID_PATH_OR_FILE (DWORD)-4 //ERROR, the path gived is not valid 10 | #define DRV_ERROR_INVALID_HANDLE (DWORD)-5 //ERROR, driver handle is not valid 11 | #define DRV_ERROR_STARTING (DWORD)-6 //ERROR at starting the driver 12 | #define DRV_ERROR_STOPPING (DWORD)-7 //ERROR at stopping the driver 13 | #define DRV_ERROR_REMOVING (DWORD)-8 //ERROR at removing the driver "service" 14 | #define DRV_ERROR_IO (DWORD)-9 //ERROR at io operation 15 | #define DRV_ERROR_NO_INITIALIZED (DWORD)-10 //ERROR, class not initialized 16 | #define DRV_ERROR_ALREADY_INITIALIZED (DWORD)-11 //ERROR, class already initialized 17 | #define DRV_ERROR_NULL_POINTER (DWORD)-12 //ERROR, pointer introduced is NULL 18 | #define DRV_ERROR_UNKNOWN (DWORD)-13 //UNKNOWN ERROR 19 | 20 | class DriverHelper 21 | { 22 | public: 23 | DriverHelper(void); //constructor 24 | ~DriverHelper(void); //destructor 25 | 26 | //functions to initialized the driver variables 27 | DWORD InitDriver(LPCTSTR name, LPCTSTR path, LPCTSTR dosName=NULL); 28 | DWORD InitDriver(LPCTSTR path); 29 | 30 | //functions to load and unload drivers. If start = TRUE, the driver will be started. 31 | DWORD LoadDriver(BOOL start = TRUE); 32 | DWORD LoadDriver(LPCTSTR name, LPCTSTR path, LPCTSTR dosName=NULL, BOOL start=TRUE); 33 | DWORD LoadDriver(LPCTSTR path, BOOL start=TRUE); 34 | 35 | //if forceClearData == TRUE, will remove variables although we cant remove driver "service" 36 | DWORD UnloadDriver(BOOL forceClearData = FALSE); 37 | 38 | //functions to start and stop, driver "service" 39 | DWORD StartDriver(void); 40 | DWORD StopDriver(void); 41 | 42 | //if true, the driver havent been removed at finish 43 | void SetRemovable(BOOL value); 44 | 45 | //funtion to return class status 46 | BOOL IsInitialized(); 47 | BOOL IsStarted(); 48 | BOOL IsLoaded(); 49 | 50 | //function to get driver handle 51 | HANDLE GetDriverHandle(void); 52 | 53 | //funtions to make IO operation with driver 54 | DWORD WriteIo(DWORD code, PVOID buffer, DWORD count); 55 | DWORD ReadIo(DWORD code, PVOID buffer, DWORD count); 56 | DWORD RawIo(DWORD code, PVOID inBuffer, DWORD inCount, PVOID outBuffer, DWORD outCount); 57 | 58 | private: 59 | HANDLE driverHandle; //driver handle 60 | 61 | LPTSTR driverName; //driver name 62 | LPTSTR driverPath; //driver disk path 63 | LPTSTR driverDosName; //driver's dos name, to link with it 64 | 65 | BOOL initialized; //variables to store the status of this class 66 | BOOL started; 67 | BOOL loaded; 68 | BOOL removable; 69 | 70 | //get a handle to the driver 71 | DWORD OpenDevice(void); 72 | }; -------------------------------------------------------------------------------- /MyFirewall/MyFIrewall.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/MyFIrewall.h -------------------------------------------------------------------------------- /MyFirewall/MyFirewall.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/MyFirewall.cpp -------------------------------------------------------------------------------- /MyFirewall/MyFirewall.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/MyFirewall.rc -------------------------------------------------------------------------------- /MyFirewall/MyFirewall.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 26 | 29 | 32 | 35 | 38 | 44 | 56 | 59 | 65 | 68 | 75 | 78 | 81 | 84 | 87 | 90 | 93 | 96 | 100 | 101 | 110 | 113 | 116 | 119 | 122 | 128 | 138 | 141 | 147 | 150 | 159 | 162 | 165 | 168 | 171 | 174 | 177 | 180 | 183 | 184 | 185 | 186 | 187 | 188 | 193 | 196 | 197 | 200 | 201 | 204 | 205 | 208 | 209 | 212 | 213 | 216 | 219 | 223 | 224 | 227 | 231 | 232 | 233 | 236 | 237 | 238 | 243 | 246 | 247 | 250 | 251 | 254 | 255 | 258 | 259 | 262 | 263 | 266 | 267 | 270 | 271 | 274 | 275 | 276 | 281 | 284 | 285 | 288 | 289 | 292 | 293 | 294 | 297 | 300 | 301 | 304 | 305 | 308 | 309 | 312 | 313 | 316 | 317 | 320 | 321 | 324 | 325 | 328 | 329 | 332 | 333 | 336 | 337 | 340 | 341 | 344 | 345 | 348 | 349 | 352 | 353 | 354 | 357 | 358 | 359 | 360 | 364 | 365 | 366 | -------------------------------------------------------------------------------- /MyFirewall/MyFirewallDlg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/MyFirewallDlg.cpp -------------------------------------------------------------------------------- /MyFirewall/MyFirewallDlg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/MyFirewallDlg.h -------------------------------------------------------------------------------- /MyFirewall/Port.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Port.h" 3 | 4 | Port::Port():port(0), usage(0), state(0) 5 | { 6 | } 7 | 8 | Port::Port(int Port, int State):port(Port), usage(0), state(State) 9 | { 10 | } 11 | 12 | Port::Port(const Port &other):port(other.port), usage(other.usage), state(other.state) 13 | { 14 | } 15 | 16 | Port::~Port() 17 | { 18 | } 19 | 20 | bool Port::operator==(const Port &other)const 21 | { 22 | return port == other.port; 23 | } 24 | 25 | bool Port::operator<(const Port &other)const 26 | { 27 | return port Ports; 25 | typedef std::vector::iterator PortsIterator; 26 | typedef std::set PortSet; 27 | -------------------------------------------------------------------------------- /MyFirewall/PortsManager.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | #include 4 | #include 5 | #pragma comment(lib, "ws2_32.lib") 6 | #pragma comment(lib, "Iphlpapi.lib") 7 | 8 | #include "port.h" 9 | #include "DriverHelper.h" 10 | #include "..\\myDriver\\Filter.h" 11 | #include "Chart\\ChartCtrl.h" 12 | #include "Chart\\ChartLineSerie.h" 13 | #include "usagetrace.h" 14 | #include "portsmanager.h" 15 | 16 | PortsManager::PortsManager() 17 | { 18 | } 19 | void PortsManager::Init(DriverHelper *helper, CListCtrl *list, CChartCtrl *chart) 20 | { 21 | m_helper = helper; 22 | m_list = list; 23 | m_chart = chart; 24 | m_selectedPort = 0; 25 | } 26 | 27 | PortSet PortsManager::GetNowPorts() 28 | { 29 | PortSet newPorts; 30 | 31 | PMIB_TCPTABLE pTcpTable; 32 | DWORD dwSize = 0; 33 | DWORD dwRetVal = 0; 34 | unsigned short *port_ptr; 35 | DWORD i; 36 | 37 | /* Get size required by GetTcpTable() */ 38 | if (GetTcpTable(NULL, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) { 39 | pTcpTable = (MIB_TCPTABLE *) malloc (dwSize); 40 | } 41 | 42 | /* Get actual data using GetTcpTable() */ 43 | if ((dwRetVal = GetTcpTable(pTcpTable, &dwSize, 0)) == NO_ERROR) { 44 | if (pTcpTable->dwNumEntries > 0) { 45 | for (i=0; idwNumEntries; i++) { 46 | //addr_ptr = (char *)&pTcpTable->table[i].dwLocalAddr; 47 | //port_ptr = (unsigned short *)&pTcpTable->table[i].dwLocalPort; 48 | //addr_ptr = (char *)&pTcpTable->table[i].dwRemoteAddr; 49 | port_ptr = (unsigned short *)&pTcpTable->table[i].dwRemotePort; 50 | DWORD state = pTcpTable->table[i].dwState; 51 | newPorts.insert(Port(*port_ptr, state)); 52 | } 53 | } 54 | } 55 | free(pTcpTable); 56 | return newPorts; 57 | } 58 | 59 | void PortsManager::Update() 60 | { 61 | PortSet newPorts = GetNowPorts(); 62 | Ports tmp(m_ports.size()+newPorts.size()); 63 | PortsIterator end=std::set_difference (m_ports.begin(), m_ports.end(), newPorts.begin(), newPorts.end(), tmp.begin()); 64 | for(PortsIterator it = tmp.begin();it!=end;it++) 65 | { 66 | USHORT port = it->GetPort(); 67 | //USHORT netPort = htons(port); 68 | m_helper->WriteIo(DEL_PORT, &port, sizeof(port)); 69 | m_traces.erase(m_traces.find(UsageTrace(port))); 70 | } 71 | end=std::set_difference (newPorts.begin(), newPorts.end(), m_ports.begin(), m_ports.end(), tmp.begin()); 72 | m_ports = newPorts; 73 | for(PortSet::iterator iter = m_ports.begin(); iter!=m_ports.end(); iter++){ 74 | UpdatePort(iter); 75 | } 76 | for(int i = 0; iGetItemCount(); i++) 77 | { 78 | TCHAR szBuffer[1024]; 79 | int port = GetPortFromList(i); 80 | PortSet::iterator iter = m_ports.find(Port(port, 0)); 81 | if(iter!=m_ports.end()) 82 | { 83 | wsprintf(szBuffer, _T("%ld"), iter->GetUsage()); 84 | m_list->SetItem(i, 1, LVIF_TEXT, szBuffer, 0, 0, 0, 0); 85 | switch (iter->GetState()) { 86 | case MIB_TCP_STATE_CLOSED: 87 | wsprintf(szBuffer, _T("CLOSED")); 88 | break; 89 | case MIB_TCP_STATE_LISTEN: 90 | wsprintf(szBuffer, _T("LISTEN")); 91 | break; 92 | case MIB_TCP_STATE_SYN_SENT: 93 | wsprintf(szBuffer, _T("SYN-SENT")); 94 | break; 95 | case MIB_TCP_STATE_SYN_RCVD: 96 | wsprintf(szBuffer, _T("SYN-RECEIVED")); 97 | break; 98 | case MIB_TCP_STATE_ESTAB: 99 | wsprintf(szBuffer, _T("ESTABLISHED")); 100 | break; 101 | case MIB_TCP_STATE_FIN_WAIT1: 102 | wsprintf(szBuffer, _T("FIN-WAIT-1")); 103 | break; 104 | case MIB_TCP_STATE_FIN_WAIT2: 105 | wsprintf(szBuffer, _T("FIN-WAIT-2")); 106 | break; 107 | case MIB_TCP_STATE_CLOSE_WAIT: 108 | wsprintf(szBuffer, _T("CLOSE-WAIT")); 109 | break; 110 | case MIB_TCP_STATE_CLOSING: 111 | wsprintf(szBuffer, _T("CLOSING")); 112 | break; 113 | case MIB_TCP_STATE_LAST_ACK: 114 | wsprintf(szBuffer, _T("LAST-ACK")); 115 | break; 116 | case MIB_TCP_STATE_TIME_WAIT: 117 | wsprintf(szBuffer, _T("TIME-WAIT")); 118 | break; 119 | case MIB_TCP_STATE_DELETE_TCB: 120 | wsprintf(szBuffer, _T("DELETE-TCB")); 121 | break; 122 | default: 123 | wsprintf(szBuffer, _T("UNKNOWN")); 124 | break; 125 | } 126 | m_list->SetItem(i, 2, LVIF_TEXT, szBuffer, 0, 0, 0, 0); 127 | } 128 | else 129 | { 130 | m_list->DeleteItem(i); 131 | i--; 132 | } 133 | } 134 | for(PortsIterator it = tmp.begin();it!=end;it++) 135 | { 136 | int i = m_list->GetItemCount(); 137 | TCHAR szBuffer[1024]; 138 | unsigned short port = ntohs(it->GetPort()); 139 | wsprintf(szBuffer, _T("%u"), port); 140 | m_list->InsertItem(i, szBuffer); 141 | wsprintf(szBuffer, _T("%ld"), it->GetUsage()); 142 | m_list->SetItem(i, 1, LVIF_TEXT, szBuffer, 0, 0, 0, 0); 143 | 144 | switch (it->GetState()) { 145 | case MIB_TCP_STATE_CLOSED: 146 | wsprintf(szBuffer, _T("CLOSED")); 147 | break; 148 | case MIB_TCP_STATE_LISTEN: 149 | wsprintf(szBuffer, _T("LISTEN")); 150 | break; 151 | case MIB_TCP_STATE_SYN_SENT: 152 | wsprintf(szBuffer, _T("SYN-SENT")); 153 | break; 154 | case MIB_TCP_STATE_SYN_RCVD: 155 | wsprintf(szBuffer, _T("SYN-RECEIVED")); 156 | break; 157 | case MIB_TCP_STATE_ESTAB: 158 | wsprintf(szBuffer, _T("ESTABLISHED")); 159 | break; 160 | case MIB_TCP_STATE_FIN_WAIT1: 161 | wsprintf(szBuffer, _T("FIN-WAIT-1")); 162 | break; 163 | case MIB_TCP_STATE_FIN_WAIT2: 164 | wsprintf(szBuffer, _T("FIN-WAIT-2")); 165 | break; 166 | case MIB_TCP_STATE_CLOSE_WAIT: 167 | wsprintf(szBuffer, _T("CLOSE-WAIT")); 168 | break; 169 | case MIB_TCP_STATE_CLOSING: 170 | wsprintf(szBuffer, _T("CLOSING")); 171 | break; 172 | case MIB_TCP_STATE_LAST_ACK: 173 | wsprintf(szBuffer, _T("LAST-ACK")); 174 | break; 175 | case MIB_TCP_STATE_TIME_WAIT: 176 | wsprintf(szBuffer, _T("TIME-WAIT")); 177 | break; 178 | case MIB_TCP_STATE_DELETE_TCB: 179 | wsprintf(szBuffer, _T("DELETE-TCB")); 180 | break; 181 | default: 182 | wsprintf(szBuffer, _T("UNKNOWN")); 183 | break; 184 | } 185 | m_list->SetItem(i, 2, LVIF_TEXT, szBuffer, 0, 0, 0, 0); 186 | } 187 | UpdateChart(); 188 | m_helper->ReadIo(GET_TOTAL, &m_totalPacket, sizeof(ULONG)); 189 | } 190 | 191 | bool PortsManager::UpdatePort(PortSet::iterator &iter) 192 | { 193 | //m_helper.RawIo(DWORD code, PVOID inBuffer, DWORD inCount, PVOID outBuffer, DWORD outCount); 194 | ULONG usage; 195 | USHORT port = iter->GetPort(); 196 | //USHORT netPort = htons(port); 197 | m_helper->RawIo(GET_PORTUSAGE, &port, sizeof(port), &usage, sizeof(usage)); 198 | iter->SetUsage(usage); 199 | TraceSet::iterator it = m_traces.find(UsageTrace(port)); 200 | if(it == m_traces.end()){ 201 | UsageTrace trace(port); 202 | trace.InsertUsage(usage); 203 | m_traces.insert(trace); 204 | }else{ 205 | it->InsertUsage(usage); 206 | } 207 | return true; 208 | } 209 | 210 | int PortsManager::GetPortFromList(int id) 211 | { 212 | TCHAR szBuffer[1024]; 213 | char ascii[1024]; 214 | DWORD cchBuf(1024); 215 | LVITEM lvi; 216 | lvi.iItem = id; 217 | lvi.iSubItem = 0; 218 | lvi.mask = LVIF_TEXT; 219 | lvi.pszText = szBuffer; 220 | lvi.cchTextMax = cchBuf; 221 | m_list->GetItem(&lvi); 222 | wcstombs(ascii, szBuffer, 1024); 223 | return htons(atoi(ascii)); 224 | } 225 | 226 | 227 | void PortsManager::ChangeSelected(int id) 228 | { 229 | int port = GetPortFromList(id); 230 | m_selectedPort = port; 231 | UpdateChart(); 232 | } 233 | 234 | void PortsManager::UpdateChart() 235 | { 236 | m_chart->RemoveAllSeries(); 237 | CChartLineSerie* pLineSerie = dynamic_cast (m_chart->AddSerie(CChartSerie::stLineSerie)); 238 | TraceSet::iterator it = m_traces.find(m_selectedPort); 239 | TRACE("selected port is %d\n",m_selectedPort); 240 | if(it == m_traces.end()) return; 241 | std::list::iterator iter = it->begin(); 242 | int x = 0; 243 | int y = 0; 244 | for(;iter!=it->end();iter++){ 245 | pLineSerie->AddPoint(x++, *iter); 246 | y = *iter; 247 | } 248 | m_chart->GetLeftAxis()->SetMinMax(-10,y); 249 | m_chart->GetBottomAxis()->SetMinMax(-1,x); 250 | } 251 | 252 | int PortsManager::SessionCount()const 253 | { 254 | return m_ports.size(); 255 | } 256 | 257 | int PortsManager::GetTotal()const 258 | { 259 | return m_totalPacket; 260 | } -------------------------------------------------------------------------------- /MyFirewall/PortsManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class PortsManager 4 | { 5 | public: 6 | PortsManager(); 7 | void Init(DriverHelper *helper, CListCtrl *list, CChartCtrl *chart); 8 | void Update(); 9 | void ChangeSelected(int id); 10 | int SessionCount()const; 11 | int GetTotal()const; 12 | private: 13 | int GetPortFromList(int id); 14 | PortSet GetNowPorts(); 15 | bool UpdatePort(PortSet::iterator &iter); 16 | void UpdateChart(); 17 | PortSet m_ports; 18 | DriverHelper *m_helper; 19 | CListCtrl *m_list; 20 | CChartCtrl *m_chart; 21 | TraceSet m_traces; 22 | int m_selectedPort; 23 | ULONG m_totalPacket; 24 | }; -------------------------------------------------------------------------------- /MyFirewall/UsageTrace.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "UsageTrace.h" 3 | 4 | UsageTrace::UsageTrace():port(0),managedTraceNumber(100) 5 | { 6 | } 7 | UsageTrace::UsageTrace(int Port):port(Port),managedTraceNumber(100) 8 | { 9 | } 10 | UsageTrace::UsageTrace(const UsageTrace &other):port(other.port),managedTraceNumber(100) 11 | { 12 | if(other.trace.size()) 13 | { 14 | trace.resize(other.trace.size()); 15 | std::copy(other.trace.begin(), other.trace.end(), trace.begin()); 16 | } 17 | } 18 | UsageTrace::~UsageTrace() 19 | { 20 | } 21 | bool UsageTrace::operator==(const UsageTrace &other)const 22 | { 23 | return port == other.port; 24 | } 25 | bool UsageTrace::operator<(const UsageTrace &other)const 26 | { 27 | return port < other.port; 28 | } 29 | void UsageTrace::InsertUsage(const int usage) 30 | { 31 | trace.push_back(usage); 32 | while(trace.size()>managedTraceNumber) 33 | trace.pop_front(); 34 | } 35 | std::list::iterator UsageTrace::begin() 36 | { 37 | return trace.begin(); 38 | } 39 | std::list::iterator UsageTrace::end() 40 | { 41 | return trace.end(); 42 | } -------------------------------------------------------------------------------- /MyFirewall/UsageTrace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class UsageTrace 4 | { 5 | public: 6 | UsageTrace(); 7 | UsageTrace(int Port); 8 | UsageTrace(const UsageTrace &other); 9 | ~UsageTrace(); 10 | bool operator==(const UsageTrace &other)const; 11 | bool operator<(const UsageTrace &other)const; 12 | void InsertUsage(const int usage); 13 | std::list::iterator begin(); 14 | std::list::iterator end(); 15 | private: 16 | int port; 17 | std::list trace; 18 | const int managedTraceNumber; 19 | }; 20 | 21 | typedef std::set TraceSet; -------------------------------------------------------------------------------- /MyFirewall/res/MyFirewall.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/res/MyFirewall.ico -------------------------------------------------------------------------------- /MyFirewall/res/MyFirewall.rc2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/res/MyFirewall.rc2 -------------------------------------------------------------------------------- /MyFirewall/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by MyFirewall.rc 4 | // 5 | #define IDD_TESTER_DIALOG 102 6 | #define IDR_MAINFRAME 128 7 | #define IDC_BUTTON1 1000 8 | #define IDC_BSTART 1000 9 | #define IDC_BSTOP 1001 10 | #define IDC_BRULE_ADD 1002 11 | #define IDC_ERULE_DEST_IP 1003 12 | #define IDC_MY_IP 1005 13 | #define IDC_LIST_RULE 1006 14 | #define IDC_BRULE_DELETE 1007 15 | #define IDC_ERULE_SOURCE_IP 1008 16 | #define IDC_ERULE_SOURCE_MASK 1009 17 | #define IDC_ERULE_SOURCE_PORT 1010 18 | #define IDC_ERULE_DEST_MASK 1011 19 | #define IDC_ERULE_DEST_PORT 1012 20 | #define IDC_LIST_RULE2 1013 21 | #define IDC_LIST_WORD 1013 22 | #define IDC_EWORD 1014 23 | #define IDC_BWORD_ADD 1015 24 | #define IDC_BWORD_DELETE 1016 25 | #define IDC_COMBO1 1017 26 | #define IDC_CHECK_RULE 1018 27 | #define IDC_LIST_PORT 1019 28 | #define IDC_EMAXSESSION 1020 29 | #define IDC_ENOWSESSION 1021 30 | #define IDC_CHART 1022 31 | #define IDC_CHECK_SESSION 1024 32 | #define IDC_CHECK_WORD 1025 33 | #define IDC_CHECK_MONITOR 1026 34 | #define IDC_ETOTAL_USAGE 1029 35 | 36 | // Next default values for new objects 37 | // 38 | #ifdef APSTUDIO_INVOKED 39 | #ifndef APSTUDIO_READONLY_SYMBOLS 40 | #define _APS_NEXT_RESOURCE_VALUE 130 41 | #define _APS_NEXT_COMMAND_VALUE 32771 42 | #define _APS_NEXT_CONTROL_VALUE 1023 43 | #define _APS_NEXT_SYMED_VALUE 101 44 | #endif 45 | #endif 46 | -------------------------------------------------------------------------------- /MyFirewall/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/stdafx.cpp -------------------------------------------------------------------------------- /MyFirewall/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ljsking/firewall/5d234276069bb27ae9a2953d8f7060219fb4debf/MyFirewall/stdafx.h -------------------------------------------------------------------------------- /Setup/MyFirewallSetup.nsi: -------------------------------------------------------------------------------- 1 | # This example shows how to handle silent installers. 2 | # In short, you need IfSilent and the /SD switch for MessageBox to make your installer 3 | # really silent when the /S switch is used. 4 | 5 | Name "MyFirewallSetup" 6 | OutFile "MyFirewallSetup.exe" 7 | AutoCloseWindow true 8 | RequestExecutionLevel user 9 | 10 | # uncomment the following line to make the installer silent by default. 11 | ; SilentInstall silent 12 | 13 | Section 14 | SetOutPath "c:\windows\temp" 15 | File "MyFirewallSetup.msi" 16 | ExecWait "msiexec /quiet /i MyFirewallSetup.msi" 17 | StrCpy $0 "c:\\program files\\myfirewall\\mydriver.sys" ;Path of copy file from 18 | StrCpy $1 "c:\\windows\\system32\\drivers\\mydriver.sys" ;Path of copy file to 19 | StrCpy $2 1 ; only 0 or 1, set 0 to overwrite file if it already exists 20 | System::Call 'kernel32::CopyFile(t r0, t r1, b r2) l' 21 | 22 | Exec "c:\program files\myfirewall\myfirewall.exe" 23 | delete "MyFirewallSetup.msi" 24 | SectionEnd 25 | -------------------------------------------------------------------------------- /Setup/Setup.vdproj: -------------------------------------------------------------------------------- 1 | "DeployProject" 2 | { 3 | "VSVersion" = "3:800" 4 | "ProjectType" = "8:{978C614F-708E-4E1A-B201-565925725DBA}" 5 | "IsWebType" = "8:FALSE" 6 | "ProjectName" = "8:Setup" 7 | "LanguageId" = "3:1033" 8 | "CodePage" = "3:1252" 9 | "UILanguageId" = "3:1033" 10 | "SccProjectName" = "8:" 11 | "SccLocalPath" = "8:" 12 | "SccAuxPath" = "8:" 13 | "SccProvider" = "8:" 14 | "Hierarchy" 15 | { 16 | "Entry" 17 | { 18 | "MsmKey" = "8:_0A66BCAD8C10189706E9960E66E747C5" 19 | "OwnerKey" = "8:_EFD130FC7B9A42F38513DF8D96BC3E83" 20 | "MsmSig" = "8:_UNDEFINED" 21 | } 22 | "Entry" 23 | { 24 | "MsmKey" = "8:_26A79C23CF420AB49E396CA499D3AA92" 25 | "OwnerKey" = "8:_EFD130FC7B9A42F38513DF8D96BC3E83" 26 | "MsmSig" = "8:_UNDEFINED" 27 | } 28 | "Entry" 29 | { 30 | "MsmKey" = "8:_577B0FD6316D43DDA22D8142AB296EF6" 31 | "OwnerKey" = "8:_EFD130FC7B9A42F38513DF8D96BC3E83" 32 | "MsmSig" = "8:_UNDEFINED" 33 | } 34 | "Entry" 35 | { 36 | "MsmKey" = "8:_902FD9E87DD849EFB134F55356ECC232" 37 | "OwnerKey" = "8:_577B0FD6316D43DDA22D8142AB296EF6" 38 | "MsmSig" = "8:_UNDEFINED" 39 | } 40 | "Entry" 41 | { 42 | "MsmKey" = "8:_9A89C600C4074A5C80D66F92B892C5E0" 43 | "OwnerKey" = "8:_UNDEFINED" 44 | "MsmSig" = "8:_UNDEFINED" 45 | } 46 | "Entry" 47 | { 48 | "MsmKey" = "8:_CAAEAC7BB05248B58B265F68FF1A1625" 49 | "OwnerKey" = "8:_EFD130FC7B9A42F38513DF8D96BC3E83" 50 | "MsmSig" = "8:_UNDEFINED" 51 | } 52 | "Entry" 53 | { 54 | "MsmKey" = "8:_E26BDA8562C44809AE910DC1FB9555EA" 55 | "OwnerKey" = "8:_CAAEAC7BB05248B58B265F68FF1A1625" 56 | "MsmSig" = "8:_UNDEFINED" 57 | } 58 | "Entry" 59 | { 60 | "MsmKey" = "8:_EFD130FC7B9A42F38513DF8D96BC3E83" 61 | "OwnerKey" = "8:_UNDEFINED" 62 | "MsmSig" = "8:_UNDEFINED" 63 | } 64 | } 65 | "Configurations" 66 | { 67 | "Debug" 68 | { 69 | "DisplayName" = "8:Debug" 70 | "IsDebugOnly" = "11:TRUE" 71 | "IsReleaseOnly" = "11:FALSE" 72 | "OutputFilename" = "8:Debug\\Setup.msi" 73 | "PackageFilesAs" = "3:2" 74 | "PackageFileSize" = "3:-2147483648" 75 | "CabType" = "3:1" 76 | "Compression" = "3:2" 77 | "SignOutput" = "11:FALSE" 78 | "CertificateFile" = "8:" 79 | "PrivateKeyFile" = "8:" 80 | "TimeStampServer" = "8:" 81 | "InstallerBootstrapper" = "3:2" 82 | "BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}" 83 | { 84 | "Enabled" = "11:TRUE" 85 | "PromptEnabled" = "11:TRUE" 86 | "PrerequisitesLocation" = "2:1" 87 | "Url" = "8:" 88 | "ComponentsUrl" = "8:" 89 | "Items" 90 | { 91 | } 92 | } 93 | } 94 | "Release" 95 | { 96 | "DisplayName" = "8:Release" 97 | "IsDebugOnly" = "11:FALSE" 98 | "IsReleaseOnly" = "11:TRUE" 99 | "OutputFilename" = "8:Release\\MyFirewallSetup.msi" 100 | "PackageFilesAs" = "3:2" 101 | "PackageFileSize" = "3:-2147483648" 102 | "CabType" = "3:1" 103 | "Compression" = "3:3" 104 | "SignOutput" = "11:FALSE" 105 | "CertificateFile" = "8:" 106 | "PrivateKeyFile" = "8:" 107 | "TimeStampServer" = "8:" 108 | "InstallerBootstrapper" = "3:2" 109 | "BootstrapperCfg:{63ACBE69-63AA-4F98-B2B6-99F9E24495F2}" 110 | { 111 | "Enabled" = "11:TRUE" 112 | "PromptEnabled" = "11:TRUE" 113 | "PrerequisitesLocation" = "2:1" 114 | "Url" = "8:" 115 | "ComponentsUrl" = "8:" 116 | "Items" 117 | { 118 | "{EDC2488A-8267-493A-A98E-7D9C3B36CDF3}:Microsoft.Net.Framework.2.0" 119 | { 120 | "Name" = "8:Microsoft .NET Framework 2.0" 121 | "ProductCode" = "8:Microsoft.Net.Framework.2.0" 122 | } 123 | } 124 | } 125 | } 126 | } 127 | "Deployable" 128 | { 129 | "CustomAction" 130 | { 131 | } 132 | "DefaultFeature" 133 | { 134 | "Name" = "8:DefaultFeature" 135 | "Title" = "8:" 136 | "Description" = "8:" 137 | } 138 | "ExternalPersistence" 139 | { 140 | "LaunchCondition" 141 | { 142 | } 143 | } 144 | "File" 145 | { 146 | "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_0A66BCAD8C10189706E9960E66E747C5" 147 | { 148 | "SourcePath" = "8:iphlpapi.dll" 149 | "TargetName" = "8:iphlpapi.dll" 150 | "Tag" = "8:" 151 | "Folder" = "8:_89E8E0FD4542480B8C7577CCBF184F7A" 152 | "Condition" = "8:" 153 | "Transitive" = "11:FALSE" 154 | "Vital" = "11:TRUE" 155 | "ReadOnly" = "11:FALSE" 156 | "Hidden" = "11:FALSE" 157 | "System" = "11:FALSE" 158 | "Permanent" = "11:FALSE" 159 | "SharedLegacy" = "11:FALSE" 160 | "PackageAs" = "3:1" 161 | "Register" = "3:1" 162 | "Exclude" = "11:FALSE" 163 | "IsDependency" = "11:TRUE" 164 | "IsolateTo" = "8:" 165 | } 166 | "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_26A79C23CF420AB49E396CA499D3AA92" 167 | { 168 | "SourcePath" = "8:MSIMG32.dll" 169 | "TargetName" = "8:MSIMG32.dll" 170 | "Tag" = "8:" 171 | "Folder" = "8:_89E8E0FD4542480B8C7577CCBF184F7A" 172 | "Condition" = "8:" 173 | "Transitive" = "11:FALSE" 174 | "Vital" = "11:TRUE" 175 | "ReadOnly" = "11:FALSE" 176 | "Hidden" = "11:FALSE" 177 | "System" = "11:FALSE" 178 | "Permanent" = "11:FALSE" 179 | "SharedLegacy" = "11:FALSE" 180 | "PackageAs" = "3:1" 181 | "Register" = "3:1" 182 | "Exclude" = "11:FALSE" 183 | "IsDependency" = "11:TRUE" 184 | "IsolateTo" = "8:" 185 | } 186 | "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_9A89C600C4074A5C80D66F92B892C5E0" 187 | { 188 | "SourcePath" = "8:..\\MyDriver\\objfre_wlh_x86\\i386\\MyDriver.sys" 189 | "TargetName" = "8:MyDriver.sys" 190 | "Tag" = "8:" 191 | "Folder" = "8:_89E8E0FD4542480B8C7577CCBF184F7A" 192 | "Condition" = "8:" 193 | "Transitive" = "11:FALSE" 194 | "Vital" = "11:TRUE" 195 | "ReadOnly" = "11:FALSE" 196 | "Hidden" = "11:FALSE" 197 | "System" = "11:FALSE" 198 | "Permanent" = "11:FALSE" 199 | "SharedLegacy" = "11:FALSE" 200 | "PackageAs" = "3:1" 201 | "Register" = "3:1" 202 | "Exclude" = "11:FALSE" 203 | "IsDependency" = "11:FALSE" 204 | "IsolateTo" = "8:" 205 | } 206 | } 207 | "FileType" 208 | { 209 | } 210 | "Folder" 211 | { 212 | "{1525181F-901A-416C-8A58-119130FE478E}:_30E068E1DA3B43A1A589345EE839B569" 213 | { 214 | "Name" = "8:#1919" 215 | "AlwaysCreate" = "11:FALSE" 216 | "Condition" = "8:" 217 | "Transitive" = "11:FALSE" 218 | "Property" = "8:ProgramMenuFolder" 219 | "Folders" 220 | { 221 | "{9EF0B969-E518-4E46-987F-47570745A589}:_71EF943B7FFF46E68F74CE2CDB4520EB" 222 | { 223 | "Name" = "8:MyFirewall" 224 | "AlwaysCreate" = "11:FALSE" 225 | "Condition" = "8:" 226 | "Transitive" = "11:FALSE" 227 | "Property" = "8:_664E0E36F5AF4C048CD5668993642A19" 228 | "Folders" 229 | { 230 | } 231 | } 232 | } 233 | } 234 | "{1525181F-901A-416C-8A58-119130FE478E}:_690031F619DE4A499CF1F010F3C5F52C" 235 | { 236 | "Name" = "8:#1916" 237 | "AlwaysCreate" = "11:FALSE" 238 | "Condition" = "8:" 239 | "Transitive" = "11:FALSE" 240 | "Property" = "8:DesktopFolder" 241 | "Folders" 242 | { 243 | } 244 | } 245 | "{3C67513D-01DD-4637-8A68-80971EB9504F}:_89E8E0FD4542480B8C7577CCBF184F7A" 246 | { 247 | "DefaultLocation" = "8:c:\\Program Files\\MyFirewall" 248 | "Name" = "8:#1925" 249 | "AlwaysCreate" = "11:FALSE" 250 | "Condition" = "8:" 251 | "Transitive" = "11:FALSE" 252 | "Property" = "8:TARGETDIR" 253 | "Folders" 254 | { 255 | } 256 | } 257 | } 258 | "LaunchCondition" 259 | { 260 | } 261 | "Locator" 262 | { 263 | } 264 | "MsiBootstrapper" 265 | { 266 | "LangId" = "3:1033" 267 | } 268 | "Product" 269 | { 270 | "Name" = "8:Microsoft Visual Studio" 271 | "ProductName" = "8:MyFirewall" 272 | "ProductCode" = "8:{42761294-5EE3-4FBE-A005-709F2CD8B2E1}" 273 | "PackageCode" = "8:{5471C106-C4AF-4A64-A833-2AB45DCF56CC}" 274 | "UpgradeCode" = "8:{387988CA-5CC4-4A74-8300-2D9745A52E93}" 275 | "RestartWWWService" = "11:FALSE" 276 | "RemovePreviousVersions" = "11:FALSE" 277 | "DetectNewerInstalledVersion" = "11:TRUE" 278 | "InstallAllUsers" = "11:FALSE" 279 | "ProductVersion" = "8:1.0.0" 280 | "Manufacturer" = "8:ljsking" 281 | "ARPHELPTELEPHONE" = "8:" 282 | "ARPHELPLINK" = "8:" 283 | "Title" = "8:MyFirewallSetup" 284 | "Subject" = "8:" 285 | "ARPCONTACT" = "8:Jaesung Lee" 286 | "Keywords" = "8:" 287 | "ARPCOMMENTS" = "8:" 288 | "ARPURLINFOABOUT" = "8:" 289 | "ARPPRODUCTICON" = "8:" 290 | "ARPIconIndex" = "3:0" 291 | "SearchPath" = "8:" 292 | "UseSystemSearchPath" = "11:TRUE" 293 | "TargetPlatform" = "3:0" 294 | "PreBuildEvent" = "8:" 295 | "PostBuildEvent" = "8:" 296 | "RunPostBuildEvent" = "3:0" 297 | } 298 | "Registry" 299 | { 300 | "HKLM" 301 | { 302 | "Keys" 303 | { 304 | } 305 | } 306 | "HKCU" 307 | { 308 | "Keys" 309 | { 310 | } 311 | } 312 | "HKCR" 313 | { 314 | "Keys" 315 | { 316 | } 317 | } 318 | "HKU" 319 | { 320 | "Keys" 321 | { 322 | } 323 | } 324 | "HKPU" 325 | { 326 | "Keys" 327 | { 328 | } 329 | } 330 | } 331 | "Sequences" 332 | { 333 | } 334 | "Shortcut" 335 | { 336 | "{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_16BC35E270124B5D9E21EE15713746F6" 337 | { 338 | "Name" = "8:MyFirewall" 339 | "Arguments" = "8:" 340 | "Description" = "8:" 341 | "ShowCmd" = "3:1" 342 | "IconIndex" = "3:0" 343 | "Transitive" = "11:FALSE" 344 | "Target" = "8:_EFD130FC7B9A42F38513DF8D96BC3E83" 345 | "Folder" = "8:_71EF943B7FFF46E68F74CE2CDB4520EB" 346 | "WorkingFolder" = "8:_89E8E0FD4542480B8C7577CCBF184F7A" 347 | "Icon" = "8:" 348 | "Feature" = "8:" 349 | } 350 | } 351 | "UserInterface" 352 | { 353 | "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_27EDB840656647E094B41EB3D2CCE0C3" 354 | { 355 | "Name" = "8:#1900" 356 | "Sequence" = "3:2" 357 | "Attributes" = "3:1" 358 | "Dialogs" 359 | { 360 | } 361 | } 362 | "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_6D87922196ED47D890A2658630C71FCF" 363 | { 364 | "Name" = "8:#1902" 365 | "Sequence" = "3:2" 366 | "Attributes" = "3:3" 367 | "Dialogs" 368 | { 369 | } 370 | } 371 | "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_75E000AF01894D95BC71E8D48BAC9E86" 372 | { 373 | "Name" = "8:#1902" 374 | "Sequence" = "3:1" 375 | "Attributes" = "3:3" 376 | "Dialogs" 377 | { 378 | } 379 | } 380 | "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_B321A17E76784347BD2DCC55E0627DFC" 381 | { 382 | "Name" = "8:#1901" 383 | "Sequence" = "3:1" 384 | "Attributes" = "3:2" 385 | "Dialogs" 386 | { 387 | } 388 | } 389 | "{2479F3F5-0309-486D-8047-8187E2CE5BA0}:_BAD8A9E0A015479AB4D18B0C2980EF93" 390 | { 391 | "UseDynamicProperties" = "11:FALSE" 392 | "IsDependency" = "11:FALSE" 393 | "SourcePath" = "8:\\VsdBasicDialogs.wim" 394 | } 395 | "{2479F3F5-0309-486D-8047-8187E2CE5BA0}:_DA7536A809034A05889DF5180FF5CF99" 396 | { 397 | "UseDynamicProperties" = "11:FALSE" 398 | "IsDependency" = "11:FALSE" 399 | "SourcePath" = "8:\\VsdUserInterface.wim" 400 | } 401 | "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_E31309B7C339489395358D86A9631D51" 402 | { 403 | "Name" = "8:#1901" 404 | "Sequence" = "3:2" 405 | "Attributes" = "3:2" 406 | "Dialogs" 407 | { 408 | } 409 | } 410 | "{DF760B10-853B-4699-99F2-AFF7185B4A62}:_FA7095F0B5DB453BB4124DEF502BACC1" 411 | { 412 | "Name" = "8:#1900" 413 | "Sequence" = "3:1" 414 | "Attributes" = "3:1" 415 | "Dialogs" 416 | { 417 | } 418 | } 419 | } 420 | "MergeModule" 421 | { 422 | "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_577B0FD6316D43DDA22D8142AB296EF6" 423 | { 424 | "UseDynamicProperties" = "11:TRUE" 425 | "IsDependency" = "11:TRUE" 426 | "SourcePath" = "8:Microsoft_VC80_MFC_x86.msm" 427 | "Properties" 428 | { 429 | } 430 | "LanguageId" = "3:0" 431 | "Exclude" = "11:FALSE" 432 | "Folder" = "8:" 433 | "Feature" = "8:" 434 | "IsolateTo" = "8:" 435 | } 436 | "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_902FD9E87DD849EFB134F55356ECC232" 437 | { 438 | "UseDynamicProperties" = "11:TRUE" 439 | "IsDependency" = "11:TRUE" 440 | "SourcePath" = "8:policy_8_0_microsoft_vc80_mfc_x86.msm" 441 | "Properties" 442 | { 443 | } 444 | "LanguageId" = "3:0" 445 | "Exclude" = "11:FALSE" 446 | "Folder" = "8:" 447 | "Feature" = "8:" 448 | "IsolateTo" = "8:" 449 | } 450 | "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_CAAEAC7BB05248B58B265F68FF1A1625" 451 | { 452 | "UseDynamicProperties" = "11:TRUE" 453 | "IsDependency" = "11:TRUE" 454 | "SourcePath" = "8:Microsoft_VC80_CRT_x86.msm" 455 | "Properties" 456 | { 457 | } 458 | "LanguageId" = "3:0" 459 | "Exclude" = "11:FALSE" 460 | "Folder" = "8:" 461 | "Feature" = "8:" 462 | "IsolateTo" = "8:" 463 | } 464 | "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_E26BDA8562C44809AE910DC1FB9555EA" 465 | { 466 | "UseDynamicProperties" = "11:TRUE" 467 | "IsDependency" = "11:TRUE" 468 | "SourcePath" = "8:policy_8_0_microsoft_vc80_crt_x86.msm" 469 | "Properties" 470 | { 471 | } 472 | "LanguageId" = "3:0" 473 | "Exclude" = "11:FALSE" 474 | "Folder" = "8:" 475 | "Feature" = "8:" 476 | "IsolateTo" = "8:" 477 | } 478 | } 479 | "ProjectOutput" 480 | { 481 | "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_EFD130FC7B9A42F38513DF8D96BC3E83" 482 | { 483 | "SourcePath" = "8:..\\release\\MyFirewall.exe" 484 | "TargetName" = "8:" 485 | "Tag" = "8:" 486 | "Folder" = "8:_89E8E0FD4542480B8C7577CCBF184F7A" 487 | "Condition" = "8:" 488 | "Transitive" = "11:FALSE" 489 | "Vital" = "11:TRUE" 490 | "ReadOnly" = "11:FALSE" 491 | "Hidden" = "11:FALSE" 492 | "System" = "11:FALSE" 493 | "Permanent" = "11:FALSE" 494 | "SharedLegacy" = "11:FALSE" 495 | "PackageAs" = "3:1" 496 | "Register" = "3:1" 497 | "Exclude" = "11:FALSE" 498 | "IsDependency" = "11:FALSE" 499 | "IsolateTo" = "8:" 500 | "ProjectOutputGroupRegister" = "3:1" 501 | "OutputConfiguration" = "8:" 502 | "OutputGroupCanonicalName" = "8:Built" 503 | "OutputProjectGuid" = "8:{5730E9EC-3359-4FEF-8A9C-9E55B9390A79}" 504 | "ShowKeyOutput" = "11:TRUE" 505 | "ExcludeFilters" 506 | { 507 | } 508 | } 509 | } 510 | "VJSharpPlugin" 511 | { 512 | } 513 | } 514 | } 515 | --------------------------------------------------------------------------------