HookSrv.cpp
上传用户:jstlsd
上传日期:2007-01-13
资源大小:186k
文件大小:5k
源码类别:

钩子与API截获

开发平台:

Visual C++

  1. //---------------------------------------------------------------------------
  2. //
  3. // HookSrv.cpp
  4. //
  5. // SUBSYSTEM:   Hook system
  6. //
  7. // MODULE:      Hook server
  8. //
  9. // DESCRIPTION: Defines the class behaviors for the application.
  10. //             
  11. // AUTHOR: Ivo Ivanov (ivopi@hotmail.com)
  12. // DATE: 2001 December v1.00
  13. //
  14. //---------------------------------------------------------------------------
  15. #include "stdafx.h"
  16. #include "HookSrv.h"
  17. #include "MainFrm.h"
  18. #include "LimitSingleInstance.h"
  19. //---------------------------------------------------------------------------
  20. //
  21. // class CHookSrvApp
  22. //
  23. //---------------------------------------------------------------------------
  24. BEGIN_MESSAGE_MAP(CHookSrvApp, CWinApp)
  25. //{{AFX_MSG_MAP(CHookSrvApp)
  26. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  27. // NOTE - the ClassWizard will add and remove mapping macros here.
  28. //    DO NOT EDIT what you see in these blocks of generated code!
  29. //}}AFX_MSG_MAP
  30. END_MESSAGE_MAP()
  31. //---------------------------------------------------------------------------
  32. //
  33. // CHookSrvApp construction
  34. //
  35. //---------------------------------------------------------------------------
  36. CHookSrvApp::CHookSrvApp()
  37. {
  38. // TODO: add construction code here,
  39. // Place all significant initialization in InitInstance
  40. }
  41. //---------------------------------------------------------------------------
  42. //
  43. // Singletons
  44. //
  45. //---------------------------------------------------------------------------
  46. // Application object
  47. CHookSrvApp theApp;
  48. // The one and only CLimitSingleInstance object
  49. CLimitSingleInstance g_SingleInstanceObj("{05CA3573-B449-4e0b-83F5-7FD612E378E9}");
  50. //---------------------------------------------------------------------------
  51. //
  52. // CHookSrvApp initialization
  53. //
  54. //---------------------------------------------------------------------------
  55. BOOL CHookSrvApp::InitInstance()
  56. {
  57. BOOL bIsAnotherInstanceRunning = 
  58. g_SingleInstanceObj.IsAnotherInstanceRunning();
  59. if (!bIsAnotherInstanceRunning)
  60. {
  61. #ifdef _AFXDLL
  62. Enable3dControls(); // Call this when using MFC in a shared DLL
  63. #else
  64. Enable3dControlsStatic(); // Call this when linking to MFC statically
  65. #endif
  66. // To create the main window, this code creates a new frame window
  67. // object and then sets it as the application's main window object.
  68. CMainFrame* pFrame = new CMainFrame;
  69. m_pMainWnd = pFrame;
  70. // create and load the frame with its resources
  71. pFrame->LoadFrame(
  72. IDR_MAINFRAME,
  73. WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, 
  74. NULL,
  75. NULL
  76. );
  77. // The one and only window has been initialized, so show and update it.
  78. pFrame->ShowWindow(SW_HIDE);
  79. pFrame->UpdateWindow();
  80. } // if
  81. return (!bIsAnotherInstanceRunning);
  82. }
  83. //---------------------------------------------------------------------------
  84. //
  85. // class CAboutDlg dialog used for App About
  86. //
  87. //---------------------------------------------------------------------------
  88. class CAboutDlg : public CDialog
  89. {
  90. public:
  91. CAboutDlg();
  92. // Dialog Data
  93. //{{AFX_DATA(CAboutDlg)
  94. enum { IDD = IDD_ABOUTBOX };
  95. //}}AFX_DATA
  96. // ClassWizard generated virtual function overrides
  97. //{{AFX_VIRTUAL(CAboutDlg)
  98. protected:
  99. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  100. //}}AFX_VIRTUAL
  101. // Implementation
  102. protected:
  103. //{{AFX_MSG(CAboutDlg)
  104. // No message handlers
  105. //}}AFX_MSG
  106. DECLARE_MESSAGE_MAP()
  107. };
  108. //---------------------------------------------------------------------------
  109. //
  110. // CAboutDlg constructor 
  111. //
  112. //---------------------------------------------------------------------------
  113. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  114. {
  115. //{{AFX_DATA_INIT(CAboutDlg)
  116. //}}AFX_DATA_INIT
  117. }
  118. //---------------------------------------------------------------------------
  119. //
  120. // DoDataExchange
  121. //
  122. //---------------------------------------------------------------------------
  123. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  124. {
  125. CDialog::DoDataExchange(pDX);
  126. //{{AFX_DATA_MAP(CAboutDlg)
  127. //}}AFX_DATA_MAP
  128. }
  129. //---------------------------------------------------------------------------
  130. //
  131. // the message map
  132. //
  133. //---------------------------------------------------------------------------
  134. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  135. //{{AFX_MSG_MAP(CAboutDlg)
  136. // No message handlers
  137. //}}AFX_MSG_MAP
  138. END_MESSAGE_MAP()
  139. //---------------------------------------------------------------------------
  140. // OnAppAbout
  141. //
  142. // App command to run the dialog
  143. //---------------------------------------------------------------------------
  144. void CHookSrvApp::OnAppAbout()
  145. {
  146. CAboutDlg aboutDlg;
  147. aboutDlg.DoModal();
  148. }
  149. //----------------------------End of the file -------------------------------