Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.6 KiB

  1. // Panic.h : Declaration of the CPanic
  2. #ifndef __PANIC_H_
  3. #define __PANIC_H_
  4. #include "resource.h" // main symbols
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CPanic
  7. #define EventName "{26ED148B-1050-461d-9999-3A5002D0103D}"
  8. LRESULT CALLBACK KeyboardProc(int code,WPARAM wParam,LPARAM lParam);
  9. class CHookHnd
  10. {
  11. public:
  12. HHOOK m_hHook;
  13. CHookHnd()
  14. {
  15. m_hHook = NULL;
  16. }
  17. ~CHookHnd()
  18. {
  19. if (m_hHook)
  20. UnhookWindowsHookEx(m_hHook);
  21. }
  22. HHOOK SetHook()
  23. {
  24. if (!m_hHook)
  25. {
  26. m_hHook = SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,_Module.GetModuleInstance(),NULL);
  27. }
  28. return m_hHook;
  29. }
  30. BOOL UnHook()
  31. {
  32. BOOL bRetVal = TRUE;
  33. if (m_hHook)
  34. {
  35. bRetVal = UnhookWindowsHookEx(m_hHook);
  36. if (bRetVal == TRUE)
  37. m_hHook = NULL;
  38. }
  39. return bRetVal;
  40. }
  41. };
  42. class ATL_NO_VTABLE CPanic :
  43. public CComObjectRootEx<CComSingleThreadModel>,
  44. public CComCoClass<CPanic, &CLSID_Panic>,
  45. public IDispatchImpl<IPanic, &IID_IPanic, &LIBID_SAFRCFILEDLGLib>
  46. {
  47. public:
  48. CPanic()
  49. {
  50. m_hEvent = NULL;
  51. }
  52. ~CPanic();
  53. DECLARE_REGISTRY_RESOURCEID(IDR_PANIC)
  54. DECLARE_NOT_AGGREGATABLE(CPanic)
  55. DECLARE_PROTECT_FINAL_CONSTRUCT()
  56. BEGIN_COM_MAP(CPanic)
  57. COM_INTERFACE_ENTRY(IPanic)
  58. COM_INTERFACE_ENTRY(IDispatch)
  59. END_COM_MAP()
  60. CComPtr<IDispatch> m_ptrScriptFncPtr;
  61. HANDLE m_hEvent;
  62. static CHookHnd m_Hook;
  63. static HANDLE m_hPanicThread;
  64. static DWORD WINAPI PanicThread(LPVOID lpParameter);
  65. // IPanic
  66. public:
  67. STDMETHOD(ClearPanicHook)();
  68. STDMETHOD(SetPanicHook)(/*[in]*/ IDispatch *iDisp);
  69. };
  70. #endif //__PANIC_H_