SymModule.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef __SymModule_h__
  2. #define __SymModule_h__
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif // _MSC_VER > 1000
  6. /////////////////////////////////////////////////////////////////////////////
  7. // SymModule.h: Definition of the SymModule class
  8. //
  9. #include <SymGuard.h>
  10. #include "resource.h"
  11. /////////////////////////////////////////////////////////////////////////////
  12. // Forward Declarations
  13. class CSymGuardApp;
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CSymModule
  16. //
  17. class CSymModule :
  18. public IDispatchImpl<ISymModule, &IID_ISymModule, &LIBID_SymGuardLib>,
  19. public ISupportErrorInfo,
  20. public CComObjectRootEx<CComMultiThreadModel>,
  21. public CComCoClass<CSymModule, &CLSID_SymModule>
  22. {
  23. // Declarations
  24. public:
  25. DECLARE_REGISTRY_RESOURCEID(IDR_SymModule)
  26. DECLARE_PROTECT_FINAL_CONSTRUCT()
  27. DECLARE_GET_CONTROLLING_UNKNOWN()
  28. // Category Map
  29. public:
  30. BEGIN_CATEGORY_MAP(CSymModule)
  31. IMPLEMENTED_CATEGORY(CATID_SymGuard)
  32. IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
  33. IMPLEMENTED_CATEGORY(CATID_SafeForInitializing)
  34. END_CATEGORY_MAP()
  35. // Interface Map
  36. public:
  37. BEGIN_COM_MAP(CSymModule)
  38. COM_INTERFACE_ENTRY(IDispatch)
  39. COM_INTERFACE_ENTRY(ISymModule)
  40. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  41. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_spUnkMarshaler.p)
  42. END_COM_MAP()
  43. // Construction / Destruction
  44. public:
  45. CSymModule();
  46. HRESULT FinalConstruct();
  47. void FinalRelease();
  48. HRESULT Init(BSTR bstrSymbolPath, BSTR bstrModuleName,
  49. VARIANT* pvarImageBase, VARIANT* pvarImageSize, CSymGuardApp* pApp,
  50. const ZString& strCacheKey);
  51. void UnloadModule();
  52. // Attributes
  53. public:
  54. static HRESULT GetCacheKey(BSTR bstrSymbolPath, BSTR bstrModuleName,
  55. VARIANT* pvarImageBase, VARIANT* pvarImageSize, ZString& strKey);
  56. // Implementation
  57. protected:
  58. HANDLE GetSymHandle() const;
  59. static HRESULT VariantHexToDWORD(VARIANT* pvar, DWORD* pdw);
  60. // ISupportErrorInfo Interface Methods
  61. public:
  62. STDMETHODIMP InterfaceSupportsErrorInfo(REFIID riid);
  63. // ISymModule Interface Methods
  64. public:
  65. STDMETHODIMP GetSymbolFromAddress(VARIANT* pvarAddress,
  66. ISymInfo** ppSymInfo);
  67. STDMETHODIMP FlushModuleFromCache();
  68. STDMETHODIMP put_Timeout(long nMinutes);
  69. STDMETHODIMP get_Timeout(long* pnMinutes);
  70. STDMETHODIMP put_BuildPathBase(BSTR bstr);
  71. STDMETHODIMP get_BuildPathBase(BSTR* pbstr);
  72. STDMETHODIMP put_SourcePathBase(BSTR bstr);
  73. STDMETHODIMP get_SourcePathBase(BSTR* pbstr);
  74. STDMETHODIMP get_SymbolPath(BSTR* pbstr);
  75. STDMETHODIMP get_ModuleName(BSTR* pbstr);
  76. STDMETHODIMP get_ImageBase(VARIANT* pvar);
  77. STDMETHODIMP get_ImageSize(VARIANT* pvar);
  78. STDMETHODIMP get_TimeDateStamp(DATE* pd);
  79. STDMETHODIMP get_CheckSum(VARIANT* pvar);
  80. STDMETHODIMP get_SymbolCount(long* pc);
  81. STDMETHODIMP get_SymbolType(BSTR* pbstr);
  82. STDMETHODIMP get_ImageName(BSTR* pbstr);
  83. STDMETHODIMP get_LoadedImageName(BSTR* pbstr);
  84. // Types
  85. protected:
  86. typedef TCObjectLock<CSymModule> XLock;
  87. // Data Members
  88. public:
  89. CComPtr<IUnknown> m_spUnkMarshaler;
  90. protected:
  91. CComBSTR m_bstrBuildPathBase;
  92. CComBSTR m_bstrSourcePathBase;
  93. IMAGEHLP_MODULE m_im;
  94. long m_nMinutes;
  95. DWORD m_dwImageBase;
  96. ZString m_strCacheKey;
  97. CSymGuardApp* m_pApp;
  98. };
  99. /////////////////////////////////////////////////////////////////////////////
  100. #endif // !__SymModule_h__