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.

94 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 2001, Microsoft Corporation
  3. Module Name:
  4. delay.cpp
  5. Abstract:
  6. This file implements the delay load.
  7. Author:
  8. Revision History:
  9. Notes:
  10. --*/
  11. #include "private.h"
  12. #include "delay.h"
  13. FARPROC GetFn(HINSTANCE *phInst, WCHAR *pchLib, char *pchFunc, BOOL fLoad)
  14. {
  15. if (*phInst == NULL)
  16. {
  17. if (fLoad)
  18. *phInst = LoadSystemLibraryW(pchLib);
  19. if (*phInst == NULL)
  20. {
  21. #ifdef DEBUG
  22. if (fLoad)
  23. {
  24. Assert(0);
  25. }
  26. #endif
  27. return NULL;
  28. }
  29. }
  30. return GetProcAddress(*phInst, pchFunc);
  31. }
  32. #define DELAYLOAD(_hInst, _DllName, _CallConv, _FuncName, _Args1, _Args2, _RetType, _ErrVal, _fLoad) \
  33. _RetType _CallConv _FuncName _Args1 \
  34. { \
  35. static FARPROC pfn = NULL; \
  36. \
  37. if (pfn == NULL || _hInst == NULL) \
  38. { \
  39. pfn = GetFn(&_hInst, L#_DllName, #_FuncName, _fLoad); \
  40. \
  41. if (pfn == NULL) \
  42. { \
  43. if (_fLoad) \
  44. { \
  45. Assert(0); \
  46. } \
  47. return (_RetType) _ErrVal; \
  48. } \
  49. } \
  50. \
  51. return ((_RetType (_CallConv *)_Args1) (pfn)) _Args2; \
  52. }
  53. HINSTANCE g_hOle32 = NULL;
  54. HRESULT Internal_CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID* ppv)
  55. {
  56. static FARPROC pfn = NULL;
  57. if (pfn == NULL || g_hOle32 == NULL) {
  58. pfn = GetFn(&g_hOle32, L"ole32.dll", "CoCreateInstance", TRUE);
  59. if (pfn == NULL) {
  60. Assert(0);
  61. return E_FAIL;
  62. }
  63. }
  64. return ((HRESULT (WINAPI *)(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID* ppv))(pfn))(rclsid, pUnkOuter, dwClsContext, riid, ppv);
  65. }
  66. HINSTANCE g_hMsimtf = NULL;
  67. DELAYLOAD(g_hMsimtf, Msimtf.dll, WINAPI, MsimtfIsWindowFiltered, (HWND hwnd), (hwnd), BOOL, FALSE, TRUE)
  68. DELAYLOAD(g_hMsimtf, Msimtf.dll, WINAPI, MsimtfIsGuidMapEnable, (HIMC himc,BOOL *pbGuidMap), (himc, pbGuidMap), BOOL, FALSE, TRUE)
  69. HINSTANCE g_hMsctf = NULL;
  70. DELAYLOAD(g_hMsctf, Msctf.dll, WINAPI, TF_CreateThreadMgr, (ITfThreadMgr **pptim), (pptim), HRESULT, E_FAIL, TRUE)
  71. DELAYLOAD(g_hMsctf, Msctf.dll, WINAPI, TF_GetThreadMgr, (ITfThreadMgr **pptim), (pptim), HRESULT, E_FAIL, TRUE)
  72. DELAYLOAD(g_hMsctf, Msctf.dll, WINAPI, TF_CreateInputProcessorProfiles, (ITfInputProcessorProfiles **ppipp), (ppipp), HRESULT, E_FAIL, TRUE)
  73. DELAYLOAD(g_hMsctf, Msctf.dll, WINAPI, TF_DllDetachInOther, (void), (), BOOL, FALSE, FALSE)