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.

442 lines
17 KiB

  1. //
  2. // delay.cpp
  3. //
  4. // Delay load imported functions for perf.
  5. //
  6. #include "private.h"
  7. #include "ciccs.h"
  8. extern CCicCriticalSectionStatic g_cs;
  9. FARPROC GetFn(HINSTANCE *phInst, LPCTSTR pchLib, LPCSTR pchFunc)
  10. {
  11. if (*phInst == 0)
  12. {
  13. EnterCriticalSection(g_cs);
  14. if (*phInst == 0)
  15. {
  16. *phInst = LoadSystemLibrary(pchLib);
  17. }
  18. LeaveCriticalSection(g_cs);
  19. if (*phInst == 0)
  20. {
  21. Assert(0);
  22. return NULL;
  23. }
  24. }
  25. return GetProcAddress(*phInst, pchFunc);
  26. }
  27. #define DELAYLOAD(_hInst, _DllName, _CallConv, _FuncName, _Args1, _Args2, _RetType, _ErrVal) \
  28. _RetType _CallConv _FuncName _Args1 \
  29. { \
  30. static FARPROC pfn = NULL; \
  31. \
  32. if (pfn == NULL || _hInst == NULL) \
  33. { \
  34. pfn = GetFn(&_hInst, _DllName, #_FuncName); \
  35. \
  36. if (pfn == NULL) \
  37. { \
  38. Assert(0); \
  39. return (_RetType) _ErrVal; \
  40. } \
  41. } \
  42. \
  43. return ((_RetType (_CallConv *)_Args1) (pfn)) _Args2; \
  44. }
  45. //
  46. // imm32.dll
  47. //
  48. namespace imm32 {
  49. const TCHAR module_imm32[] = TEXT("imm32.dll");
  50. #define IMM32LOAD(_FuncName, _Args1, _Args2, _RetType, _ErrVal) \
  51. DELAYLOAD(g_hImm32, module_imm32, WINAPI, _FuncName, _Args1, _Args2, _RetType, _ErrVal)
  52. HINSTANCE g_hImm32 = 0;
  53. BOOL FreeLibrary()
  54. {
  55. BOOL ret = FALSE;
  56. if (g_hImm32 != NULL)
  57. {
  58. ret = ::FreeLibrary(g_hImm32);
  59. g_hImm32 = NULL;
  60. }
  61. return ret;
  62. }
  63. /*
  64. * IMM32 Input Context (hIMC) API Interface.
  65. */
  66. IMM32LOAD(ImmCreateContext, (void), (), HIMC, 0)
  67. IMM32LOAD(ImmDestroyContext, (HIMC hIMC), (hIMC), BOOL, FALSE)
  68. IMM32LOAD(ImmAssociateContext, (HWND hWnd, HIMC hIMC), (hWnd, hIMC), HIMC, 0)
  69. IMM32LOAD(ImmAssociateContextEx, (HWND hWnd, HIMC hIMC, DWORD dwFlags), (hWnd, hIMC, dwFlags), BOOL, FALSE)
  70. IMM32LOAD(ImmGetContext, (HWND hWnd), (hWnd), HIMC, 0)
  71. IMM32LOAD(ImmReleaseContext, (HWND hWnd, HIMC hIMC), (hWnd, hIMC), BOOL, FALSE)
  72. IMM32LOAD(ImmGetIMCLockCount, (HIMC hIMC), (hIMC), DWORD, 0)
  73. IMM32LOAD(ImmUnlockIMC, (HIMC hIMC), (hIMC), BOOL, FALSE)
  74. IMM32LOAD(ImmLockIMC, (HIMC hIMC), (hIMC), LPINPUTCONTEXT, NULL)
  75. /*
  76. * IMM32 Input Context Components (hIMCC) API Interface.
  77. */
  78. IMM32LOAD(ImmCreateIMCC, (DWORD dw), (dw), HIMCC, FALSE)
  79. IMM32LOAD(ImmDestroyIMCC, (HIMCC hIMCC), (hIMCC), HIMCC, hIMCC)
  80. IMM32LOAD(ImmGetIMCCSize, (HIMCC hIMCC), (hIMCC), DWORD, 0)
  81. IMM32LOAD(ImmReSizeIMCC, (HIMCC hIMCC, DWORD dw), (hIMCC, dw), HIMCC, 0)
  82. IMM32LOAD(ImmGetIMCCLockCount, (HIMCC hIMCC), (hIMCC), DWORD, 0)
  83. IMM32LOAD(ImmUnlockIMCC, (HIMCC hIMCC), (hIMCC), BOOL, FALSE)
  84. IMM32LOAD(ImmLockIMCC, (HIMCC hIMCC), (hIMCC), LPVOID, NULL)
  85. /*
  86. * IMM32 Composition String API Interface
  87. */
  88. IMM32LOAD(ImmGetCompositionStringA, (HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen), (hIMC, dwIndex, lpBuf, dwBufLen), LONG, 0);
  89. IMM32LOAD(ImmGetCompositionStringW, (HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen), (hIMC, dwIndex, lpBuf, dwBufLen), LONG, 0);
  90. IMM32LOAD(ImmSetCompositionStringA, (HIMC hIMC, DWORD dwIndex, LPVOID lpComp, DWORD dwCompLen, LPVOID lpRead, DWORD dwReadLen), (hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen), BOOL, FALSE);
  91. IMM32LOAD(ImmSetCompositionStringW, (HIMC hIMC, DWORD dwIndex, LPVOID lpComp, DWORD dwCompLen, LPVOID lpRead, DWORD dwReadLen), (hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen), BOOL, FALSE);
  92. /*
  93. * IMM32 Composition Font API Interface
  94. */
  95. IMM32LOAD(ImmGetCompositionFontA, (HIMC hIMC, LPLOGFONTA lplf), (hIMC, lplf), BOOL, FALSE);
  96. IMM32LOAD(ImmGetCompositionFontW, (HIMC hIMC, LPLOGFONTW lplf), (hIMC, lplf), BOOL, FALSE);
  97. IMM32LOAD(ImmSetCompositionFontA, (HIMC hIMC, LPLOGFONTA lplf), (hIMC, lplf), BOOL, FALSE);
  98. IMM32LOAD(ImmSetCompositionFontW, (HIMC hIMC, LPLOGFONTW lplf), (hIMC, lplf), BOOL, FALSE);
  99. /*
  100. * IMM32 Open Status API Interface
  101. */
  102. IMM32LOAD(ImmGetOpenStatus, (HIMC hIMC), (hIMC), BOOL, FALSE)
  103. IMM32LOAD(ImmSetOpenStatus, (HIMC hIMC, BOOL f), (hIMC, f), BOOL, FALSE)
  104. /*
  105. * IMM32 Conversion Status API Interface
  106. */
  107. IMM32LOAD(ImmGetConversionStatus, (HIMC hIMC, LPDWORD pdw1, LPDWORD pdw2), (hIMC, pdw1, pdw2), BOOL, FALSE)
  108. IMM32LOAD(ImmSetConversionStatus, (HIMC hIMC, DWORD dw1, DWORD dw2), (hIMC, dw1, dw2), BOOL, FALSE)
  109. /*
  110. * IMM32 Status Window Pos API Interface
  111. */
  112. IMM32LOAD(ImmGetStatusWindowPos, (HIMC hIMC, LPPOINT lpptPos), (hIMC, lpptPos), BOOL, FALSE)
  113. IMM32LOAD(ImmSetStatusWindowPos, (HIMC hIMC, LPPOINT lpptPos), (hIMC, lpptPos), BOOL, FALSE)
  114. /*
  115. * IMM32 Composition Window API Interface
  116. */
  117. IMM32LOAD(ImmGetCompositionWindow, (HIMC hIMC, LPCOMPOSITIONFORM lpCompForm), (hIMC, lpCompForm), BOOL, FALSE)
  118. IMM32LOAD(ImmSetCompositionWindow, (HIMC hIMC, LPCOMPOSITIONFORM lpCompForm), (hIMC, lpCompForm), BOOL, FALSE);
  119. /*
  120. * IMM32 Candidate Window API Interface
  121. */
  122. IMM32LOAD(ImmGetCandidateWindow, (HIMC hIMC, DWORD dw, LPCANDIDATEFORM pCF), (hIMC, dw, pCF), BOOL, FALSE)
  123. IMM32LOAD(ImmSetCandidateWindow, (HIMC hIMC, LPCANDIDATEFORM pCF), (hIMC, pCF), BOOL, FALSE)
  124. IMM32LOAD(ImmGetCandidateListA, (HIMC hIMC, DWORD dwIndex, LPCANDIDATELIST lpCandList, DWORD dwBufLen), (hIMC, dwIndex, lpCandList, dwBufLen), DWORD, 0);
  125. IMM32LOAD(ImmGetCandidateListW, (HIMC hIMC, DWORD dwIndex, LPCANDIDATELIST lpCandList, DWORD dwBufLen), (hIMC, dwIndex, lpCandList, dwBufLen), DWORD, 0);
  126. IMM32LOAD(ImmGetCandidateListCountA, (HIMC hIMC, LPDWORD lpdwListCount), (hIMC, lpdwListCount), DWORD, 0);
  127. IMM32LOAD(ImmGetCandidateListCountW, (HIMC hIMC, LPDWORD lpdwListCount), (hIMC, lpdwListCount), DWORD, 0);
  128. /*
  129. * IMM32 Generate Message API Interface
  130. */
  131. IMM32LOAD(ImmGenerateMessage, (HIMC hIMC), (hIMC), BOOL, FALSE);
  132. /*
  133. * IMM32 Notify IME API Interface
  134. */
  135. IMM32LOAD(ImmNotifyIME, (HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue), (hIMC, dwAction, dwIndex, dwValue), BOOL, FALSE)
  136. /*
  137. * IMM32 Guide Line IME API Interface
  138. */
  139. IMM32LOAD(ImmGetGuideLineA, (HIMC hIMC, DWORD dwIndex, LPSTR lpBuf, DWORD dwBufLen), (hIMC, dwIndex, lpBuf, dwBufLen), DWORD, 0);
  140. IMM32LOAD(ImmGetGuideLineW, (HIMC hIMC, DWORD dwIndex, LPWSTR lpBuf, DWORD dwBufLen), (hIMC, dwIndex, lpBuf, dwBufLen), DWORD, 0);
  141. /*
  142. * IMM32 Menu items API Interface
  143. */
  144. IMM32LOAD(ImmGetImeMenuItemsA, (HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOA lpImeParentMenu, LPIMEMENUITEMINFOA lpImeMenu, DWORD dwSize), (hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, dwSize), DWORD, 0);
  145. IMM32LOAD(ImmGetImeMenuItemsW, (HIMC hIMC, DWORD dwFlags, DWORD dwType, LPIMEMENUITEMINFOW lpImeParentMenu, LPIMEMENUITEMINFOW lpImeMenu, DWORD dwSize), (hIMC, dwFlags, dwType, lpImeParentMenu, lpImeMenu, dwSize), DWORD, 0);
  146. /*
  147. * IMM32 Default IME Window API Interface
  148. */
  149. IMM32LOAD(ImmGetDefaultIMEWnd, (HWND hWnd), (hWnd), HWND, 0);
  150. IMM32LOAD(ImmGetVirtualKey, (HWND hWnd), (hWnd), UINT, VK_PROCESSKEY);
  151. /*
  152. * IMM32 UI message API Interface
  153. */
  154. IMM32LOAD(ImmIsUIMessageA, (HWND hWnd, UINT u, WPARAM wParam, LPARAM lParam), (hWnd, u, wParam, lParam), BOOL, FALSE);
  155. IMM32LOAD(ImmIsUIMessageW, (HWND hWnd, UINT u, WPARAM wParam, LPARAM lParam), (hWnd, u, wParam, lParam), BOOL, FALSE);
  156. /*
  157. * IMM32 Simulate hotkey API Interface
  158. */
  159. IMM32LOAD(ImmSimulateHotKey, (HWND hWnd, DWORD dwHotKeyID), (hWnd, dwHotKeyID), BOOL, FALSE);
  160. IMM32LOAD(ImmGetHotKey, (DWORD dwHotKeyId, LPUINT lpuModifiers, LPUINT lpuVKey, LPHKL lphKL), (dwHotKeyId, lpuModifiers, lpuVKey, lphKL), BOOL, FALSE);
  161. IMM32LOAD(ImmSetHotKey, (DWORD dwHotKeyId, UINT uModifiers, UINT uVKey, HKL hKL), (dwHotKeyId, uModifiers, uVKey, hKL), BOOL, FALSE);
  162. /*
  163. * IMM32 Property API Interface
  164. */
  165. IMM32LOAD(ImmGetProperty, (HKL hKL, DWORD dw), (hKL, dw), DWORD, 0);
  166. /*
  167. * IMM32 Description API Interface
  168. */
  169. IMM32LOAD(ImmGetDescriptionA, (HKL hKL, LPSTR lpszDescription, UINT uBufLen), (hKL, lpszDescription, uBufLen), UINT, 0);
  170. IMM32LOAD(ImmGetDescriptionW, (HKL hKL, LPWSTR lpszDescription, UINT uBufLen), (hKL, lpszDescription, uBufLen), UINT, 0);
  171. IMM32LOAD(ImmGetIMEFileNameA, (HKL hKL, LPSTR lpszFileName, UINT uBufLen), (hKL, lpszFileName, uBufLen), UINT, 0);
  172. IMM32LOAD(ImmGetIMEFileNameW, (HKL hKL, LPWSTR lpszFileName, UINT uBufLen), (hKL, lpszFileName, uBufLen), UINT, 0);
  173. /*
  174. * IMM32 Conversion List API Interface
  175. */
  176. IMM32LOAD(ImmGetConversionListA, (HKL hKL, HIMC hIMC, LPCSTR psz, LPCANDIDATELIST pCL, DWORD dwBufLen, UINT uFlag), (hKL, hIMC, psz, pCL, dwBufLen, uFlag), DWORD, 0);
  177. IMM32LOAD(ImmGetConversionListW, (HKL hKL, HIMC hIMC, LPCWSTR psz, LPCANDIDATELIST pCL, DWORD dwBufLen, UINT uFlag), (hKL, hIMC, psz, pCL, dwBufLen, uFlag), DWORD, 0);
  178. /*
  179. * IMM32 IsIME API Interface
  180. */
  181. IMM32LOAD(ImmIsIME, (HKL hKL), (hKL), BOOL, FALSE);
  182. /*
  183. * IMM32 Escape API Interface
  184. */
  185. IMM32LOAD(ImmEscapeA, (HKL hKL, HIMC hIMC, UINT u, LPVOID pv), (hKL, hIMC, u, pv), LRESULT, 0);
  186. IMM32LOAD(ImmEscapeW, (HKL hKL, HIMC hIMC, UINT u, LPVOID pv), (hKL, hIMC, u, pv), LRESULT, 0);
  187. /*
  188. * IMM32 Configure IME Interface
  189. */
  190. IMM32LOAD(ImmConfigureIMEA, (HKL hKL, HWND hWnd, DWORD dw, LPVOID pv), (hKL, hWnd, dw, pv), BOOL, FALSE);
  191. IMM32LOAD(ImmConfigureIMEW, (HKL hKL, HWND hWnd, DWORD dw, LPVOID pv), (hKL, hWnd, dw, pv), BOOL, FALSE);
  192. /*
  193. * IMM32 Register Word IME Interface
  194. */
  195. IMM32LOAD(ImmRegisterWordA, (HKL hKL, LPCSTR lpszReading, DWORD dw, LPCSTR lpszRegister), (hKL, lpszReading, dw, lpszRegister), BOOL, FALSE);
  196. IMM32LOAD(ImmRegisterWordW, (HKL hKL, LPCWSTR lpszReading, DWORD dw, LPCWSTR lpszRegister), (hKL, lpszReading, dw, lpszRegister), BOOL, FALSE);
  197. IMM32LOAD(ImmUnregisterWordA, (HKL hKL, LPCSTR lpszReading, DWORD dw, LPCSTR lpszUnregister), (hKL, lpszReading, dw, lpszUnregister), BOOL, FALSE);
  198. IMM32LOAD(ImmUnregisterWordW, (HKL hKL, LPCWSTR lpszReading, DWORD dw, LPCWSTR lpszUnregister), (hKL, lpszReading, dw, lpszUnregister), BOOL, FALSE);
  199. IMM32LOAD(ImmGetRegisterWordStyleA, (HKL hKL, UINT nItem, LPSTYLEBUFA lpStyleBuf), (hKL, nItem, lpStyleBuf), UINT, 0);
  200. IMM32LOAD(ImmGetRegisterWordStyleW, (HKL hKL, UINT nItem, LPSTYLEBUFW lpStyleBuf), (hKL, nItem, lpStyleBuf), UINT, 0);
  201. /*
  202. * IMM32 soft kbd API
  203. */
  204. IMM32LOAD(ImmCreateSoftKeyboard, (UINT uType, HWND hOwner, int x, int y), (uType, hOwner, x, y), HWND, NULL);
  205. IMM32LOAD(ImmDestroySoftKeyboard, (HWND hSoftKbdWnd), (hSoftKbdWnd), BOOL, FALSE);
  206. IMM32LOAD(ImmShowSoftKeyboard, (HWND hSoftKbdWnd, int nCmdShow), (hSoftKbdWnd, nCmdShow), BOOL, FALSE);
  207. /*
  208. * IMM32 Enumurate Input Context API
  209. */
  210. IMM32LOAD(ImmEnumInputContext, (DWORD idThread, IMCENUMPROC lpfn, LPARAM lParam), (idThread, lpfn, lParam), BOOL, FALSE);
  211. /*
  212. * IMM32 win98/nt5 apis
  213. */
  214. IMM32LOAD(ImmDisableIME, (DWORD dwId), (dwId), BOOL, FALSE);
  215. IMM32LOAD(ImmRequestMessageA, (HIMC hIMC, WPARAM wParam, LPARAM lParam), (hIMC, wParam, lParam), LRESULT, 0);
  216. IMM32LOAD(ImmRequestMessageW, (HIMC hIMC, WPARAM wParam, LPARAM lParam), (hIMC, wParam, lParam), LRESULT, 0);
  217. IMM32LOAD(ImmInstallIMEA, (LPCSTR lpszIMEFileName, LPCSTR lpszLayoutText), (lpszIMEFileName, lpszLayoutText), HKL, 0);
  218. IMM32LOAD(ImmInstallIMEW, (LPCWSTR lpszIMEFileName, LPCWSTR lpszLayoutText), (lpszIMEFileName, lpszLayoutText), HKL, 0);
  219. }
  220. //
  221. // imm32.dll
  222. //
  223. namespace imm32prev {
  224. const TCHAR module_imm32[] = TEXT("imm32.dll");
  225. #define IMM32LOAD(_FuncName, _Args1, _Args2, _RetType, _ErrVal) \
  226. DELAYLOAD(g_hImm32, module_imm32, WINAPI, _FuncName, _Args1, _Args2, _RetType, _ErrVal)
  227. HINSTANCE g_hImm32 = 0;
  228. BOOL FreeLibrary()
  229. {
  230. BOOL ret = FALSE;
  231. if (g_hImm32 != NULL)
  232. {
  233. ret = ::FreeLibrary(g_hImm32);
  234. g_hImm32 = NULL;
  235. }
  236. return ret;
  237. }
  238. IMM32LOAD(CtfImmGetGuidAtom, (HIMC hIMC, BYTE bAttr, DWORD* pGuidAtom), (hIMC, bAttr, pGuidAtom), HRESULT, S_OK);
  239. IMM32LOAD(CtfImmIsGuidMapEnable, (HIMC hIMC), (hIMC), BOOL, FALSE);
  240. IMM32LOAD(CtfImmIsCiceroEnabled, (VOID), (), BOOL, FALSE);
  241. IMM32LOAD(CtfImmIsCiceroStartedInThread, (VOID), (), BOOL, FALSE);
  242. IMM32LOAD(CtfImmSetCiceroStartInThread, (BOOL fSet), (fSet), HRESULT, S_OK);
  243. IMM32LOAD(GetKeyboardLayoutCP, (HKL hKL), (hKL), UINT, 0);
  244. IMM32LOAD(ImmGetAppCompatFlags, (HIMC hIMC), (hIMC), DWORD, 0);
  245. IMM32LOAD(CtfImmSetAppCompatFlags, (DWORD dwFlag), (dwFlag), VOID, NULL);
  246. IMM32LOAD(CtfAImmActivate, (HMODULE* phMod), (phMod), HRESULT, E_FAIL);
  247. IMM32LOAD(CtfAImmDeactivate, (HMODULE hMod), (hMod), HRESULT, E_FAIL);
  248. IMM32LOAD(CtfAImmIsIME, (HKL hkl), (hkl), BOOL, FALSE);
  249. }
  250. //
  251. // version.dll
  252. //
  253. const TCHAR module_version[] = TEXT("version.dll");
  254. HINSTANCE g_hVersion = 0;
  255. DELAYLOAD(g_hVersion, module_version, WINAPI, GetFileVersionInfoSizeA, (LPTSTR pszFileName, LPDWORD pdwHandle), (pszFileName, pdwHandle), DWORD, 0);
  256. DELAYLOAD(g_hVersion, module_version, WINAPI, GetFileVersionInfoA, (LPTSTR lptstrFilename, DWORD dwHandle, DWORD dwLen, LPVOID lpData), (lptstrFilename, dwHandle, dwLen, lpData), BOOL, FALSE);
  257. DELAYLOAD(g_hVersion, module_version, WINAPI, VerQueryValueA, (const LPVOID pBlock, LPTSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen), (pBlock, lpSubBlock, lplpBuffer, puLen), BOOL, FALSE);
  258. //
  259. // msctf.dll
  260. //
  261. const TCHAR module_msctf[] = TEXT("msctf.dll");
  262. HINSTANCE g_hCTF = 0;
  263. DELAYLOAD(g_hCTF, module_msctf, WINAPI, TF_CreateLangBarMgr, (ITfLangBarMgr **pplbm), (pplbm), HRESULT, E_FAIL);
  264. //
  265. // ole32.dll
  266. //
  267. HINSTANCE g_hOle32 = 0;
  268. HRESULT STDAPICALLTYPE Internal_CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID* ppv)
  269. {
  270. static FARPROC pfn = NULL;
  271. if (pfn == NULL || g_hOle32 == NULL)
  272. {
  273. pfn = GetFn(&g_hOle32, TEXT("ole32.dll"), "CoCreateInstance");
  274. if (pfn == NULL)
  275. {
  276. Assert(0);
  277. if (ppv != NULL)
  278. {
  279. *ppv = NULL;
  280. }
  281. return E_FAIL;
  282. }
  283. }
  284. return ((HRESULT (STDAPICALLTYPE *)(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID* ppv))(pfn))(rclsid, pUnkOuter, dwClsContext, riid, ppv);
  285. }
  286. LPVOID STDAPICALLTYPE Internal_CoTaskMemAlloc(ULONG cb)
  287. {
  288. static FARPROC pfn = NULL;
  289. if (pfn == NULL || g_hOle32 == NULL)
  290. {
  291. pfn = GetFn(&g_hOle32, TEXT("ole32.dll"), "CoTaskMemAlloc");
  292. if (pfn == NULL)
  293. {
  294. Assert(0);
  295. return NULL;
  296. }
  297. }
  298. return ((LPVOID (STDAPICALLTYPE *)(ULONG cb))(pfn))(cb);
  299. }
  300. LPVOID STDAPICALLTYPE Internal_CoTaskMemRealloc(LPVOID pv, ULONG cb)
  301. {
  302. static FARPROC pfn = NULL;
  303. if (pfn == NULL || g_hOle32 == NULL)
  304. {
  305. pfn = GetFn(&g_hOle32, TEXT("ole32.dll"), "CoTaskMemRealloc");
  306. if (pfn == NULL)
  307. {
  308. Assert(0);
  309. return NULL;
  310. }
  311. }
  312. return ((LPVOID (STDAPICALLTYPE *)(LPVOID pv, ULONG cb))(pfn))(pv, cb);
  313. }
  314. void STDAPICALLTYPE Internal_CoTaskMemFree(void* pv)
  315. {
  316. static FARPROC pfn = NULL;
  317. if (pfn == NULL || g_hOle32 == NULL)
  318. {
  319. pfn = GetFn(&g_hOle32, TEXT("ole32.dll"), "CoTaskMemFree");
  320. if (pfn == NULL)
  321. {
  322. Assert(0);
  323. return;
  324. }
  325. }
  326. ((void (STDAPICALLTYPE *)(void* pv))(pfn))(pv);
  327. }
  328. //
  329. // cleanup -- called from process detach
  330. //
  331. void UninitDelayLoadLibraries()
  332. {
  333. EnterCriticalSection(g_cs);
  334. imm32::FreeLibrary();
  335. imm32prev::FreeLibrary();
  336. if (g_hVersion != 0)
  337. {
  338. FreeLibrary(g_hVersion);
  339. g_hVersion = NULL;
  340. }
  341. if (g_hCTF != 0)
  342. {
  343. FreeLibrary(g_hCTF);
  344. g_hCTF = NULL;
  345. }
  346. if (g_hOle32 != 0)
  347. {
  348. FreeLibrary(g_hOle32);
  349. g_hOle32 = NULL;
  350. }
  351. LeaveCriticalSection(g_cs);
  352. }