IpMonitor.cpp
上传用户:ykzxjx
上传日期:2022-04-03
资源大小:1175k
文件大小:6k
开发平台:

Visual C++

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright 1999 - 2000 Mark Roddy
  4. // All Rights Reserved
  5. //
  6. // Hollis Technology Solutions
  7. // 94 Dow Road
  8. // Hollis, NH 03049
  9. // info@hollistech.com
  10. //
  11. // Synopsis: 
  12. // 
  13. //
  14. // Version Information:
  15. //
  16. // $Header: /iphook/usr/IpMonitor/IpMonitor.cpp 3     4/16/00 8:54p Markr $ 
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. // IpMonitor.cpp : Defines the class behaviors for the application.
  20. //
  21. #include "stdafx.h"
  22. #include "IpMonitor.h"
  23. #include "MainFrm.h"
  24. #include "IpMonitorDoc.h"
  25. #include "IpMonitorView.h"
  26. #include "Terms.h"
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CIpMonitorApp
  34. BEGIN_MESSAGE_MAP(CIpMonitorApp, CWinApp)
  35. //{{AFX_MSG_MAP(CIpMonitorApp)
  36. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  37. // NOTE - the ClassWizard will add and remove mapping macros here.
  38. //    DO NOT EDIT what you see in these blocks of generated code!
  39. //}}AFX_MSG_MAP
  40. // Standard file based document commands
  41. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  42. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  43. // Standard print setup command
  44. ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  45. END_MESSAGE_MAP()
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CIpMonitorApp construction
  48. CIpMonitorApp::CIpMonitorApp()
  49. {
  50. m_theView = NULL;
  51. m_theDoc = NULL;
  52. }
  53. /////////////////////////////////////////////////////////////////////////////
  54. // The one and only CIpMonitorApp object
  55. CIpMonitorApp theApp;
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CIpMonitorApp initialization
  58. BOOL CIpMonitorApp::InitInstance()
  59. {
  60. //
  61. // load the filter driver - it should already be installed!
  62. //
  63. filterDriver.init(_T("IpFilterDriver"), FILE_ATTRIBUTE_NORMAL, _T("System32\Drivers\IpFltDrv.sys"));
  64. if (filterDriver.getError() != NO_ERROR) {
  65. AfxErrorMessageBox(CString(_T("Can't load IpFilter")), filterDriver.getError());
  66. ExitInstance();
  67. }
  68. hookDriver.ChangeConfig(TRUE);
  69. hookDriver.RemoveDriverOnExit(TRUE);
  70. hookDriver.init(IPHOOK_NAME, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED);
  71. if (hookDriver.getError() != NO_ERROR) {
  72. AfxErrorMessageBox(CString(_T("Can't load IpHook")), hookDriver.getError());
  73. ExitInstance();
  74. }
  75. AfxEnableControlContainer();
  76. // Standard initialization
  77. // If you are not using these features and wish to reduce the size
  78. //  of your final executable, you should remove from the following
  79. //  the specific initialization routines you do not need.
  80. #ifdef _AFXDLL
  81. Enable3dControls(); // Call this when using MFC in a shared DLL
  82. #else
  83. Enable3dControlsStatic(); // Call this when linking to MFC statically
  84. #endif
  85. // Change the registry key under which our settings are stored.
  86. // TODO: You should modify this string to be something appropriate
  87. // such as the name of your company or organization.
  88. SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  89. LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  90. // Register the application's document templates.  Document templates
  91. //  serve as the connection between documents, frame windows and views.
  92. CSingleDocTemplate* pDocTemplate;
  93. pDocTemplate = new CSingleDocTemplate(
  94. IDR_MAINFRAME,
  95. RUNTIME_CLASS(CIpMonitorDoc),
  96. RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  97. RUNTIME_CLASS(CIpMonitorView));
  98. AddDocTemplate(pDocTemplate);
  99. // Parse command line for standard shell commands, DDE, file open
  100. CCommandLineInfo cmdInfo;
  101. ParseCommandLine(cmdInfo);
  102. // Dispatch commands specified on the command line
  103. if (!ProcessShellCommand(cmdInfo))
  104. return FALSE;
  105. // The one and only window has been initialized, so show and update it.
  106. m_pMainWnd->ShowWindow(SW_SHOW);
  107. m_pMainWnd->UpdateWindow();
  108. return TRUE;
  109. }
  110. /////////////////////////////////////////////////////////////////////////////
  111. // CAboutDlg dialog used for App About
  112. class CAboutDlg : public CDialog
  113. {
  114. public:
  115. CAboutDlg();
  116. // Dialog Data
  117. //{{AFX_DATA(CAboutDlg)
  118. enum { IDD = IDD_ABOUTBOX };
  119. //}}AFX_DATA
  120. // ClassWizard generated virtual function overrides
  121. //{{AFX_VIRTUAL(CAboutDlg)
  122. protected:
  123. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  124. //}}AFX_VIRTUAL
  125. // Implementation
  126. protected:
  127. //{{AFX_MSG(CAboutDlg)
  128. afx_msg void OnTerms();
  129. virtual BOOL OnInitDialog();
  130. afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
  131. //}}AFX_MSG
  132. DECLARE_MESSAGE_MAP()
  133. };
  134. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  135. {
  136. //{{AFX_DATA_INIT(CAboutDlg)
  137. //}}AFX_DATA_INIT
  138. }
  139. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  140. {
  141. CDialog::DoDataExchange(pDX);
  142. //{{AFX_DATA_MAP(CAboutDlg)
  143. //}}AFX_DATA_MAP
  144. }
  145. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  146. //{{AFX_MSG_MAP(CAboutDlg)
  147. ON_BN_CLICKED(IDOK2, OnTerms)
  148. ON_WM_CTLCOLOR()
  149. //}}AFX_MSG_MAP
  150. END_MESSAGE_MAP()
  151. // App command to run the dialog
  152. void CIpMonitorApp::OnAppAbout()
  153. {
  154. CAboutDlg aboutDlg;
  155. aboutDlg.DoModal();
  156. }
  157. /////////////////////////////////////////////////////////////////////////////
  158. // CIpMonitorApp message handlers
  159. ///////////////////////////////////////////////////////////////////////////////
  160. // 
  161. // Change History Log
  162. //
  163. // $Log: /iphook/usr/IpMonitor/IpMonitor.cpp $
  164. // 
  165. // 3     4/16/00 8:54p Markr
  166. // 
  167. // 2     1/27/00 10:35p Markr
  168. // Prepare to release!
  169. //
  170. ///////////////////////////////////////////////////////////////////////////////
  171. void CAboutDlg::OnTerms() 
  172. {
  173. Terms terms;
  174. terms.DoModal();
  175. }
  176. BOOL CAboutDlg::OnInitDialog() 
  177. {
  178. CDialog::OnInitDialog();
  179. return TRUE;  // return TRUE unless you set the focus to a control
  180.               // EXCEPTION: OCX Property Pages should return FALSE
  181. }
  182. HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
  183. {
  184. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  185. // TODO: Change any attributes of the DC here
  186. // TODO: Return a different brush if the default is not desired
  187. return hbr;
  188.     
  189. }