Source code of Windows XP (NT5)
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.

81 lines
3.0 KiB

  1. #if !defined(_FUSION_INC_FUSIONMODULE_H_INCLUDED_)
  2. #define _FUSION_INC_FUSIONMODULE_H_INCLUDED_
  3. #pragma once
  4. #include "oleaut_d.h"
  5. #include "debmacro.h"
  6. #include "FusionBuffer.h"
  7. #define FUSION_OA_API(_fn, _args, _nargs) void _fn _args { ASSERT(m_fFusionModuleInitialized); m_OleAut._fn _nargs; }
  8. #define FUSION_OA_API_(_rett, _fn, _args, _nargs) _rett _fn _args { ASSERT(m_fFusionModuleInitialized); return m_OleAut._fn _nargs; }
  9. #define FUSION_MODULE_UNUSED(x) (x)
  10. class CFusionModule
  11. {
  12. public:
  13. CFusionModule() : m_fFusionModuleInitialized(false), m_hInstDLL(NULL), m_dwEnumLocaleTLS(0)
  14. #if DBG
  15. , m_dwTraceContextTLS(0)
  16. #endif
  17. { }
  18. ~CFusionModule() { }
  19. // Pass all DllMain() activations through here for attach and detach time work.
  20. BOOL ModuleDllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID pvReserved);
  21. HRESULT Initialize();
  22. FUSION_OA_API_(HRESULT, VariantClear, (VARIANTARG *pvarg), (pvarg))
  23. FUSION_OA_API_(HRESULT, VariantInit, (VARIANTARG *pvarg), (pvarg))
  24. FUSION_OA_API_(HRESULT, VariantCopy, (VARIANTARG *pvargDest, const VARIANTARG *pvargSrc), (pvargDest, const_cast<VARIANTARG *>(pvargSrc)))
  25. FUSION_OA_API_(HRESULT, VariantChangeType, (VARIANTARG *pvargDest, const VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt),
  26. (pvargDest, const_cast<VARIANTARG *>(pvargSrc), wFlags, vt))
  27. FUSION_OA_API_(BSTR, SysAllocString, (LPCOLESTR sz), (sz))
  28. FUSION_OA_API(SysFreeString, (BSTR bstr), (bstr))
  29. typedef BOOL (CALLBACK * LOCALE_ENUMPROCEXW)(LPWSTR pszLCID, LPVOID pvContext);
  30. typedef BOOL (CALLBACK * LOCALE_ENUMPROCEXA)(LPSTR pszLCID, LPVOID pvContext);
  31. BOOL EnumSystemLocalesExA(LOCALE_ENUMPROCEXA lpLocaleEnumProc, DWORD dwFlags, LPVOID pvContext);
  32. BOOL EnumSystemLocalesExW(LOCALE_ENUMPROCEXW lpLocaleEnumProc, DWORD dwFlags, LPVOID pvContext);
  33. #if DBG
  34. template <typename T> void GetFunctionTraceContext(T *&rpt)
  35. {
  36. rpt = reinterpret_cast<T *>(::TlsGetValue(m_dwTraceContextTLS));
  37. }
  38. template <typename T> void SetFunctionTraceContext(T *pt)
  39. {
  40. ::TlsSetValue(m_dwTraceContextTLS, pt);
  41. }
  42. #endif
  43. protected:
  44. bool m_fFusionModuleInitialized;
  45. DWORD m_dwEnumLocaleTLS; // TLS key used in wrapped calls to EnumSystemLocales
  46. #if DBG
  47. DWORD m_dwTraceContextTLS; // TLS key used to manage active trace contexts
  48. #endif
  49. COleAutDll m_OleAut;
  50. HINSTANCE m_hInstDLL;
  51. typedef struct tagENUMSYSTEMLOCALESEXCONTEXTA
  52. {
  53. LPVOID pvContext; // user specified context
  54. LOCALE_ENUMPROCEXA lpLocaleEnumProc; // user specified enumeration function
  55. } ENUMSYSTEMLOCALESEXCONTEXTA, *LPENUMSYSTEMLOCALESEXCONTEXTA;
  56. typedef struct tagENUMSYSTEMLOCALESEXCONTEXTW
  57. {
  58. LPVOID pvContext; // user specified context
  59. LOCALE_ENUMPROCEXW lpLocaleEnumProc; // user specified enumeration function
  60. } ENUMSYSTEMLOCALESEXCONTEXTW, *LPENUMSYSTEMLOCALESEXCONTEXTW;
  61. static BOOL CALLBACK EnumLocalesProcA(LPSTR pszLCID);
  62. static BOOL CALLBACK EnumLocalesProcW(LPWSTR pszLCID);
  63. };
  64. #undef FUSION_MODULE_UNUSED
  65. #endif