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.

109 lines
4.4 KiB

  1. #pragma once
  2. //
  3. // Before calling DelayLoad( DL_MODULE), make sure DLOleInitialize() has been called.
  4. // DLOleTerminate() will also unload loaded modules.
  5. //
  6. BOOL DLOleInitialize();
  7. void DLOleTerminate();
  8. //
  9. // DelayLoad( DL_MODULE) loads a particular module in a thread-safe manner and
  10. //returns TRUE on current or past success. This is an efficient way to repeatedly ensure
  11. //a module is loaded.
  12. //
  13. //
  14. // DelayUnload() unloads the module, and should not be called until all threads are done with
  15. //the module. If any threads need to use the module after DelayUnload() is completed, DelayLoad()
  16. //should be called again.
  17. //
  18. typedef struct
  19. {
  20. LPCSTR szFunctionName;
  21. FARPROC * ppfuncAddress;
  22. } DL_FUNCTIONMAP;
  23. struct DL_MODULE
  24. {
  25. HMODULE _hDllHandle;
  26. const LPCSTR _szDllName;
  27. const DL_FUNCTIONMAP *const _pFunctionMap;
  28. const int _iFunctionMapSize;
  29. DL_MODULE( const LPCSTR szDllName, const DL_FUNCTIONMAP *const pFunctionMap, const int iFunctionMapSize);
  30. #if INET_DEBUG
  31. ~DL_MODULE();
  32. #endif
  33. private:
  34. // disabled dummy assignment operator to
  35. // eliminate /W4 compiler warning C4512
  36. DL_MODULE &operator=( DL_MODULE & ) {}
  37. };
  38. BOOL DelayLoad( DL_MODULE* pModule);
  39. BOOL DelayUnload( DL_MODULE* pModule);
  40. //
  41. // DL(Function) will wrap a call to function pointer g_pfnFunction.
  42. //
  43. #define DL(func) (* g_pfn ## func)
  44. //
  45. // Ole32 module and import information
  46. //
  47. extern DL_MODULE g_moduleOle32;
  48. // DelayLoad( &Ole32Functions) loads the following function pointers:
  49. extern LPVOID (__stdcall *g_pfnCoTaskMemAlloc)(IN SIZE_T cb);
  50. extern HRESULT (__stdcall *g_pfnCLSIDFromString)(IN LPOLESTR lpsz, OUT LPCLSID pclsid);
  51. extern HRESULT (__stdcall *g_pfnCoCreateInstance)(IN REFCLSID rclsid, IN LPUNKNOWN pUnkOuter, IN DWORD dwClsContext, IN REFIID riid, OUT LPVOID FAR* ppv);
  52. extern HRESULT (__stdcall *g_pfnGetHGlobalFromStream)(IStream *pstm,HGLOBAL *phglobal);
  53. extern HRESULT (__stdcall *g_pfnCreateStreamOnHGlobal)(HGLOBAL hGlobal,BOOL fDeleteOnRelease,LPSTREAM *ppstm);
  54. extern HRESULT (__stdcall *g_pfnCoInitializeEx)(IN LPVOID pvReserved, IN DWORD dwCoInit);
  55. extern void (__stdcall *g_pfnCoUninitialize)(void);
  56. //
  57. //
  58. // OleAut32.dll module and import information
  59. //
  60. //
  61. extern DL_MODULE g_moduleOleAut32;
  62. // From DelayLoad( &OleAut32.dll), the following function pointers are loaded:
  63. extern HRESULT (__stdcall *g_pfnRegisterTypeLib)(ITypeLib * ptlib, OLECHAR *szFullPath, OLECHAR *szHelpDir);
  64. extern HRESULT (__stdcall *g_pfnLoadTypeLib)(const OLECHAR *szFile, ITypeLib ** pptlib);
  65. extern HRESULT (__stdcall *g_pfnUnRegisterTypeLib)(REFGUID libID, WORD wVerMajor, WORD wVerMinor, LCID lcid, SYSKIND syskind);
  66. extern HRESULT (__stdcall *g_pfnDispGetParam)(DISPPARAMS * pdispparams, UINT position, VARTYPE vtTarg, VARIANT * pvarResult, UINT * puArgErr);
  67. extern void (__stdcall *g_pfnVariantInit)(VARIANTARG * pvarg);
  68. extern HRESULT (__stdcall *g_pfnVariantClear)(VARIANTARG * pvarg);
  69. extern HRESULT (__stdcall *g_pfnCreateErrorInfo)(ICreateErrorInfo ** pperrinfo);
  70. extern HRESULT (__stdcall *g_pfnSetErrorInfo)(ULONG dwReserved, IErrorInfo * perrinfo);
  71. extern HRESULT (__stdcall *g_pfnGetErrorInfo)(ULONG dwReserved, IErrorInfo ** pperrinfo);
  72. extern BSTR (__stdcall *g_pfnSysAllocString)(const OLECHAR* pch);
  73. extern BSTR (__stdcall *g_pfnSysAllocStringLen)(const OLECHAR * pch, UINT ui);
  74. extern void (__stdcall *g_pfnSysFreeString)(BSTR bstr);
  75. extern HRESULT (__stdcall *g_pfnVariantChangeType)(VARIANTARG * pvargDest, VARIANTARG * pvarSrc, USHORT wFlags, VARTYPE vt);
  76. extern HRESULT (__stdcall *g_pfnSafeArrayDestroy)(SAFEARRAY * psa);
  77. extern SAFEARRAY* (__stdcall *g_pfnSafeArrayCreateVector)(VARTYPE vt, LONG lLbound, ULONG cElements);
  78. extern HRESULT (__stdcall *g_pfnSafeArrayCopy)(SAFEARRAY * psa, SAFEARRAY ** ppsaOut);
  79. extern HRESULT (__stdcall *g_pfnSafeArrayUnaccessData)(SAFEARRAY * psa);
  80. extern HRESULT (__stdcall *g_pfnSafeArrayGetUBound)(SAFEARRAY * psa, UINT nDim, LONG * plUbound);
  81. extern HRESULT (__stdcall *g_pfnSafeArrayGetLBound)(SAFEARRAY * psa, UINT nDim, LONG * plLbound);
  82. extern UINT (__stdcall *g_pfnSafeArrayGetDim)(SAFEARRAY * psa);
  83. extern HRESULT (__stdcall *g_pfnSafeArrayAccessData)(SAFEARRAY * psa, void HUGEP** ppvData);
  84. extern HRESULT (__stdcall *g_pfnSafeArrayDestroyDescriptor)(SAFEARRAY * psa);
  85. extern HRESULT (__stdcall *g_pfnSafeArrayCopyData)(SAFEARRAY *psaSource, SAFEARRAY *psaTarget);