SymModuleImpl.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef __SymModuleImpl_h__
  2. #define __SymModuleImpl_h__
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif // _MSC_VER > 1000
  6. /////////////////////////////////////////////////////////////////////////////
  7. // SymModuleImpl.h: Definition of the CSymModuleImpl class
  8. //
  9. #include <SymGuard.h>
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CSymModuleImpl
  12. //
  13. class CSymModuleImpl :
  14. public ISymModule,
  15. public CComObjectRootEx<CComMultiThreadModel>
  16. {
  17. // Declarations
  18. public:
  19. DECLARE_PROTECT_FINAL_CONSTRUCT()
  20. // Interface Map
  21. public:
  22. BEGIN_COM_MAP(CSymModuleImpl)
  23. COM_INTERFACE_ENTRY(ISymModule)
  24. END_COM_MAP()
  25. // Construction / Destruction
  26. public:
  27. CSymModuleImpl();
  28. HRESULT FinalConstruct();
  29. void FinalRelease();
  30. protected:
  31. HRESULT Init(BSTR bstrSymbolPath, BSTR bstrModuleName,
  32. DWORD dwImageBase, DWORD dwImageSize, const ZString& strCacheKey);
  33. void UnloadModule();
  34. // Operations
  35. public:
  36. static HRESULT CreateModule(BSTR bstrSymbolPath, BSTR bstrModuleName,
  37. VARIANT* pvarImageBase, VARIANT* pvarImageSize, ISymModule** ppSymModule);
  38. static HRESULT VariantHexToDWORD(VARIANT* pvar, DWORD* pdw);
  39. // Overrides
  40. public:
  41. // CComObjectRootEx Overrides
  42. ULONG InternalRelease();
  43. // Implementation
  44. protected:
  45. HANDLE GetSymHandle() const;
  46. // IDispatch Interface Methods
  47. public:
  48. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
  49. STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo);
  50. STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames,
  51. LCID lcid, DISPID* rgDispId);
  52. STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
  53. WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult,
  54. EXCEPINFO* pExcepInfo, UINT* puArgErr);
  55. // ISymModule Interface Methods
  56. public:
  57. STDMETHODIMP GetSymbolFromAddress(VARIANT* pvarAddress,
  58. ISymInfo** ppSymInfo);
  59. STDMETHODIMP FlushModuleFromCache();
  60. STDMETHODIMP put_Timeout(long nMinutes);
  61. STDMETHODIMP get_Timeout(long* pnMinutes);
  62. STDMETHODIMP put_BuildPathBase(BSTR bstr);
  63. STDMETHODIMP get_BuildPathBase(BSTR* pbstr);
  64. STDMETHODIMP put_SourcePathBase(BSTR bstr);
  65. STDMETHODIMP get_SourcePathBase(BSTR* pbstr);
  66. STDMETHODIMP get_SymbolPath(BSTR* pbstr);
  67. STDMETHODIMP get_ModuleName(BSTR* pbstr);
  68. STDMETHODIMP get_ImageBase(VARIANT* pvar);
  69. STDMETHODIMP get_ImageSize(VARIANT* pvar);
  70. STDMETHODIMP get_TimeDateStamp(DATE* pd);
  71. STDMETHODIMP get_CheckSum(VARIANT* pvar);
  72. STDMETHODIMP get_SymbolCount(long* pc);
  73. STDMETHODIMP get_SymbolType(BSTR* pbstr);
  74. STDMETHODIMP get_ImageName(BSTR* pbstr);
  75. STDMETHODIMP get_LoadedImageName(BSTR* pbstr);
  76. // Types
  77. protected:
  78. typedef TCObjectLock<CSymModuleImpl> XLock;
  79. typedef TCObjectLock<TCAutoCriticalSection> XStaticLock;
  80. typedef std::map<ZString, ISymModule*> XModules;
  81. typedef XModules::iterator XModuleIt;
  82. // Data Members
  83. protected:
  84. IMAGEHLP_MODULE m_im;
  85. long m_nMinutes;
  86. DWORD m_dwImageBase;
  87. ZString m_strCacheKey;
  88. bool m_bInDestructionLock;
  89. protected:
  90. static TCAutoCriticalSection s_cs;
  91. static XModules s_ModuleCache;
  92. };
  93. /////////////////////////////////////////////////////////////////////////////
  94. #endif // !__SymModuleImpl_h__