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.

1411 lines
35 KiB

  1. /////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998 Active Voice Corporation. All Rights Reserved.
  4. //
  5. // Active Agent(r) and Unified Communications(tm) are trademarks of Active Voice Corporation.
  6. //
  7. // Other brand and product names used herein are trademarks of their respective owners.
  8. //
  9. // The entire program and user interface including the structure, sequence, selection,
  10. // and arrangement of the dialog, the exclusively "yes" and "no" choices represented
  11. // by "1" and "2," and each dialog message are protected by copyrights registered in
  12. // the United States and by international treaties.
  13. //
  14. // Protected by one or more of the following United States patents: 5,070,526, 5,488,650,
  15. // 5,434,906, 5,581,604, 5,533,102, 5,568,540, 5,625,676, 5,651,054.
  16. //
  17. // Active Voice Corporation
  18. // Seattle, Washington
  19. // USA
  20. //
  21. /////////////////////////////////////////////////////////////////////////////////////////
  22. ////
  23. // telthunk.c - tel thunk functions
  24. ////
  25. // This is a thunk layer to the telephone functions in tel.dll.
  26. // It's purpose is to allow an application to use tel.dll functions
  27. // only if they are available.
  28. //
  29. // To use this module, link TELTHUNK.OBJ with your application
  30. // rather than with TEL.LIB. Before calling any Tel or TelOut
  31. // functions, call TelThunkInit. Before exiting your application,
  32. // call TelThunkTerm.
  33. //
  34. #include "winlocal.h"
  35. #include <stdlib.h>
  36. #include "telthunk.h"
  37. #include "tel.h"
  38. #include "telcfg.h"
  39. #include "telwav.h"
  40. #include "telout.h"
  41. #include "telin.h"
  42. #include "file.h"
  43. #include "loadlib.h"
  44. #include "mem.h"
  45. #include "str.h"
  46. #include "trace.h"
  47. extern HINSTANCE g_hInstLib;
  48. ////
  49. // private definitions
  50. ////
  51. #ifdef _WIN32
  52. #define TELTHUNK_LIBNAME "tel32.dll"
  53. #define TELTHUNK_LIBNAME_TIU "tel32nt.dll"
  54. #else
  55. #define TELTHUNK_LIBNAME "tel.dll"
  56. #endif
  57. #ifdef TELTHUNK
  58. #undef TELTHUNK
  59. #endif
  60. extern HINSTANCE g_hInstLib;
  61. // telthunk control struct
  62. //
  63. typedef struct TELTHUNK
  64. {
  65. DWORD dwVersion;
  66. HINSTANCE hInst;
  67. HTASK hTask;
  68. HINSTANCE hInstLib;
  69. } TELTHUNK, FAR *LPTELTHUNK;
  70. // telthunk function struct
  71. //
  72. typedef struct TELTHUNKFN
  73. {
  74. int index;
  75. LPSTR lpszName;
  76. FARPROC lpfn;
  77. } TELTHUNKFN, FAR *LPTELTHUNKFN;
  78. enum
  79. {
  80. iTelInitDLL = 0,
  81. iTelTermDLL,
  82. iTelInit,
  83. iTelTerm,
  84. iTelIsConnected,
  85. iTelConnect,
  86. iTelDisconnect,
  87. iTelTransfer,
  88. iTelConnectIdleTimeoutReset,
  89. iTelOutGetDeviceCount,
  90. iTelOutDeviceIsOpen,
  91. iTelOutOpen,
  92. iTelOutClose,
  93. iTelOutPlay,
  94. iTelOutStop,
  95. iTelOutPause,
  96. iTelOutResume,
  97. iTelOutGetState,
  98. iTelOutGetPosition,
  99. iTelOutGetId,
  100. iTelOutGetName,
  101. iTelOutSupportsFormat,
  102. iTelOutFormatSuggest,
  103. iTelOutIsSynchronous,
  104. iTelOutSupportsVolume,
  105. iTelOutSupportsSpeed,
  106. iTelOutSupportsPitch,
  107. iTelOutGetVolume,
  108. iTelOutSetVolume,
  109. iTelOutGetSpeed,
  110. iTelOutSetSpeed,
  111. iTelOutGetPitch,
  112. iTelOutSetPitch,
  113. iTelOutTerm,
  114. iTelInGetDeviceCount,
  115. iTelInDeviceIsOpen,
  116. iTelInOpen,
  117. iTelInClose,
  118. iTelInRecord,
  119. iTelInStop,
  120. iTelInGetState,
  121. iTelInGetPosition,
  122. iTelInGetId,
  123. iTelInGetName,
  124. iTelInSupportsFormat,
  125. iTelInFormatSuggest,
  126. iTelInTerm,
  127. iTelCfgRead,
  128. iTelCfgWrite,
  129. iTelCfgDoDialog,
  130. iTelWavOpenEx,
  131. TELTHUNK_MAXFUNCTIONS
  132. };
  133. static TELTHUNKFN aTelThunkFn[] =
  134. {
  135. iTelInitDLL, "TelInitDLL", NULL,
  136. iTelTermDLL, "TelTermDLL", NULL,
  137. iTelInit, "TelInit", NULL,
  138. iTelTerm, "TelTerm", NULL,
  139. iTelIsConnected, "TelIsConnected", NULL,
  140. iTelConnect, "TelConnect", NULL,
  141. iTelDisconnect, "TelDisconnect", NULL,
  142. iTelTransfer, "TelTransfer", NULL,
  143. iTelConnectIdleTimeoutReset, "TelConnectIdleTimeoutReset", NULL,
  144. iTelOutGetDeviceCount, "TelOutGetDeviceCount", NULL,
  145. iTelOutDeviceIsOpen, "TelOutDeviceIsOpen", NULL,
  146. iTelOutOpen, "TelOutOpen", NULL,
  147. iTelOutClose, "TelOutClose", NULL,
  148. iTelOutPlay, "TelOutPlay", NULL,
  149. iTelOutStop, "TelOutStop", NULL,
  150. iTelOutPause, "TelOutPause", NULL,
  151. iTelOutResume, "TelOutResume", NULL,
  152. iTelOutGetState, "TelOutGetState", NULL,
  153. iTelOutGetPosition, "TelOutGetPosition", NULL,
  154. iTelOutGetId, "TelOutGetId", NULL,
  155. iTelOutGetName, "TelOutGetName", NULL,
  156. iTelOutSupportsFormat, "TelOutSupportsFormat", NULL,
  157. iTelOutFormatSuggest, "TelOutFormatSuggest", NULL,
  158. iTelOutIsSynchronous, "TelOutIsSynchronous", NULL,
  159. iTelOutSupportsVolume, "TelOutSupportsVolume", NULL,
  160. iTelOutSupportsSpeed, "TelOutSupportsSpeed", NULL,
  161. iTelOutSupportsPitch, "TelOutSupportsPitch", NULL,
  162. iTelOutGetVolume, "TelOutGetVolume", NULL,
  163. iTelOutSetVolume, "TelOutSetVolume", NULL,
  164. iTelOutGetSpeed, "TelOutGetSpeed", NULL,
  165. iTelOutSetSpeed, "TelOutSetSpeed", NULL,
  166. iTelOutGetPitch, "TelOutGetPitch", NULL,
  167. iTelOutSetPitch, "TelOutSetPitch", NULL,
  168. iTelOutTerm, "TelOutTerm", NULL,
  169. iTelInGetDeviceCount, "TelInGetDeviceCount", NULL,
  170. iTelInDeviceIsOpen, "TelInDeviceIsOpen", NULL,
  171. iTelInOpen, "TelInOpen", NULL,
  172. iTelInClose, "TelInClose", NULL,
  173. iTelInRecord, "TelInRecord", NULL,
  174. iTelInStop, "TelInStop", NULL,
  175. iTelInGetState, "TelInGetState", NULL,
  176. iTelInGetPosition, "TelInGetPosition", NULL,
  177. iTelInGetId, "TelInGetId", NULL,
  178. iTelInGetName, "TelInGetName", NULL,
  179. iTelInSupportsFormat, "TelInSupportsFormat", NULL,
  180. iTelInFormatSuggest, "TelInFormatSuggest", NULL,
  181. iTelInTerm, "TelInTerm", NULL,
  182. iTelCfgRead, "TelCfgRead", NULL,
  183. iTelCfgWrite, "TelCfgWrite", NULL,
  184. iTelCfgDoDialog, "TelCfgDoDialog", NULL,
  185. iTelWavOpenEx, "TelWavOpenEx", NULL
  186. };
  187. // helper functions
  188. //
  189. static LPTELTHUNK TelThunkGetPtr(HTELTHUNK hTelThunk);
  190. static HTELTHUNK TelThunkGetHandle(LPTELTHUNK lpTelThunk);
  191. ////
  192. // public functions
  193. ////
  194. // TelThunkInit - initialize telthunk engine
  195. // <dwVersion> (i) must be TELTHUNK_VERSION
  196. // <hInst> (i) instance handle of calling module
  197. // return handle (NULL if error)
  198. //
  199. HTELTHUNK DLLEXPORT WINAPI TelThunkInit(DWORD dwVersion, HINSTANCE hInst)
  200. {
  201. BOOL fSuccess = TRUE;
  202. LPTELTHUNK lpTelThunk = NULL;
  203. if (dwVersion != TELTHUNK_VERSION)
  204. fSuccess = TraceFALSE(NULL);
  205. else if (hInst == NULL)
  206. fSuccess = TraceFALSE(NULL);
  207. else if ((lpTelThunk = (LPTELTHUNK) MemAlloc(NULL, sizeof(TELTHUNK), 0)) == NULL)
  208. fSuccess = TraceFALSE(NULL);
  209. else
  210. {
  211. int i;
  212. TCHAR szLibName[_MAX_PATH];
  213. LPTSTR lpszBackSlash = NULL;
  214. lpTelThunk->dwVersion = dwVersion;
  215. lpTelThunk->hInst = hInst;
  216. lpTelThunk->hTask = GetCurrentTask();
  217. lpTelThunk->hInstLib = NULL;
  218. // Determine which DLL to use
  219. //
  220. #ifdef _WIN32
  221. MemSet(szLibName, 0, sizeof(szLibName));
  222. GetModuleFileName(g_hInstLib, szLibName, SIZEOFARRAY(szLibName));
  223. if ((lpszBackSlash = StrRChr(szLibName, '\\')) != NULL)
  224. StrCpy(lpszBackSlash + 1, TEXT("TiuClient.dll"));
  225. if (FileExists(szLibName))
  226. StrNCpy(szLibName, TELTHUNK_LIBNAME_TIU, SIZEOFARRAY(szLibName));
  227. else
  228. #endif
  229. StrNCpy(szLibName, TELTHUNK_LIBNAME, SIZEOFARRAY(szLibName));
  230. TracePrintf_1(NULL, 5,
  231. TEXT("TelThunkInit: Loading DLL=%s\n"),
  232. (LPTSTR) szLibName);
  233. // load the library if possible
  234. //
  235. if ((lpTelThunk->hInstLib = LoadLibraryPath(szLibName, g_hInstLib, 0)) == NULL)
  236. fSuccess = TraceFALSE(NULL);
  237. // get the address of each function in library
  238. //
  239. else for (i = 0; i < MAG(aTelThunkFn); ++i)
  240. {
  241. if (aTelThunkFn[i].index != i)
  242. fSuccess = TraceFALSE(NULL);
  243. else if ((aTelThunkFn[i].lpfn = GetProcAddress(lpTelThunk->hInstLib,
  244. aTelThunkFn[i].lpszName)) == NULL)
  245. {
  246. TracePrintf_1(NULL, 6,
  247. TEXT("GetProcAddress failed\n fn=%s\n"),
  248. (LPTSTR) aTelThunkFn[i].lpszName);
  249. fSuccess = TraceFALSE(NULL);
  250. }
  251. }
  252. }
  253. if (!fSuccess)
  254. {
  255. TelThunkTerm(TelThunkGetHandle(lpTelThunk));
  256. lpTelThunk = NULL;
  257. }
  258. else
  259. {
  260. __int16 (WINAPI *lpfnTelInitDLL)(void);
  261. if (((FARPROC) lpfnTelInitDLL = aTelThunkFn[iTelInitDLL].lpfn) != NULL)
  262. (*lpfnTelInitDLL)();
  263. }
  264. return fSuccess ? TelThunkGetHandle(lpTelThunk) : NULL;
  265. }
  266. // TelThunkTerm - shut down telthunk engine
  267. // <hTelThunk> (i) handle returned from TelThunkInit
  268. // return 0 if success
  269. //
  270. int DLLEXPORT WINAPI TelThunkTerm(HTELTHUNK hTelThunk)
  271. {
  272. BOOL fSuccess = TRUE;
  273. LPTELTHUNK lpTelThunk;
  274. if ((lpTelThunk = TelThunkGetPtr(hTelThunk)) == NULL)
  275. fSuccess = TraceFALSE(NULL);
  276. else
  277. {
  278. __int16 (WINAPI *lpfnTelTermDLL)(void);
  279. if (((FARPROC) lpfnTelTermDLL = aTelThunkFn[iTelTermDLL].lpfn) != NULL)
  280. (*lpfnTelTermDLL)();
  281. // library no longer needed
  282. //
  283. FreeLibrary(lpTelThunk->hInstLib);
  284. if ((lpTelThunk = MemFree(NULL, lpTelThunk)) != NULL)
  285. fSuccess = TraceFALSE(NULL);
  286. }
  287. return fSuccess ? 0 : -1;
  288. }
  289. // Tel thunk functions
  290. //
  291. HTEL DLLEXPORT WINAPI TelInit(DWORD dwVersion, HINSTANCE hInst,
  292. LPCTSTR lpszServerParams, HWND hwndNotify, WORD wFlags)
  293. {
  294. BOOL fSuccess = TRUE;
  295. HTEL (WINAPI *lpfnTelInit)(DWORD dwVersion, HINSTANCE hInst,
  296. LPCTSTR lpszServerParams, HWND hwndNotify, WORD wFlags);
  297. HTEL hTel;
  298. if (aTelThunkFn[iTelInit].index != iTelInit)
  299. fSuccess = TraceFALSE(NULL);
  300. else if (((FARPROC) lpfnTelInit = aTelThunkFn[iTelInit].lpfn) == NULL)
  301. fSuccess = TraceFALSE(NULL);
  302. else
  303. {
  304. hTel = (*lpfnTelInit)(dwVersion, hInst,
  305. lpszServerParams, hwndNotify, wFlags);
  306. }
  307. return fSuccess ? hTel : NULL;
  308. }
  309. int DLLEXPORT WINAPI TelTerm(HTEL hTel)
  310. {
  311. BOOL fSuccess = TRUE;
  312. int (WINAPI *lpfnTelTerm)(HTEL hTel);
  313. int iRet;
  314. if (aTelThunkFn[iTelTerm].index != iTelTerm)
  315. fSuccess = TraceFALSE(NULL);
  316. else if (((FARPROC) lpfnTelTerm = aTelThunkFn[iTelTerm].lpfn) == NULL)
  317. fSuccess = TraceFALSE(NULL);
  318. else
  319. {
  320. iRet = (*lpfnTelTerm)(hTel);
  321. }
  322. return fSuccess ? iRet : -1;
  323. }
  324. DWORD DLLEXPORT WINAPI TelIsConnected(HTEL hTel)
  325. {
  326. BOOL fSuccess = TRUE;
  327. DWORD (WINAPI *lpfnTelIsConnected)(HTEL hTel);
  328. DWORD dwRet;
  329. if (aTelThunkFn[iTelIsConnected].index != iTelIsConnected)
  330. fSuccess = TraceFALSE(NULL);
  331. else if (((FARPROC) lpfnTelIsConnected = aTelThunkFn[iTelIsConnected].lpfn) == NULL)
  332. fSuccess = TraceFALSE(NULL);
  333. else
  334. {
  335. dwRet = (*lpfnTelIsConnected)(hTel);
  336. }
  337. return fSuccess ? dwRet : 0;
  338. }
  339. int DLLEXPORT WINAPI TelConnect(HTEL hTel, LPCTSTR lpszPhoneConnect,
  340. HNBOX hNBoxConnect, DWORD dwTimeoutConnect, DWORD dwTimeoutIdle,
  341. HNBOX hNBoxDisconnect, DWORD dwTimeoutDisconnect, DWORD dwFlags)
  342. {
  343. BOOL fSuccess = TRUE;
  344. int (WINAPI *lpfnTelConnect)(HTEL hTel, LPCTSTR lpszPhoneConnect,
  345. HNBOX hNBoxConnect, DWORD dwTimeoutConnect, DWORD dwTimeoutIdle,
  346. HNBOX hNBoxDisconnect, DWORD dwTimeoutDisconnect, DWORD dwFlags);
  347. int iRet;
  348. if (aTelThunkFn[iTelConnect].index != iTelConnect)
  349. fSuccess = TraceFALSE(NULL);
  350. else if (((FARPROC) lpfnTelConnect = aTelThunkFn[iTelConnect].lpfn) == NULL)
  351. fSuccess = TraceFALSE(NULL);
  352. else
  353. {
  354. iRet = (*lpfnTelConnect)(hTel, lpszPhoneConnect,
  355. hNBoxConnect, dwTimeoutConnect, dwTimeoutIdle,
  356. hNBoxDisconnect, dwTimeoutDisconnect, dwFlags);
  357. }
  358. return fSuccess ? iRet : -1;
  359. }
  360. int DLLEXPORT WINAPI TelDisconnect(HTEL hTel, DWORD dwFlags)
  361. {
  362. BOOL fSuccess = TRUE;
  363. int (WINAPI *lpfnTelDisconnect)(HTEL hTel, DWORD dwFlags);
  364. int iRet;
  365. if (aTelThunkFn[iTelDisconnect].index != iTelDisconnect)
  366. fSuccess = TraceFALSE(NULL);
  367. else if (((FARPROC) lpfnTelDisconnect = aTelThunkFn[iTelDisconnect].lpfn) == NULL)
  368. fSuccess = TraceFALSE(NULL);
  369. else
  370. {
  371. iRet = (*lpfnTelDisconnect)(hTel, dwFlags);
  372. }
  373. return fSuccess ? iRet : -1;
  374. }
  375. int DLLEXPORT WINAPI TelTransfer(HTEL hTel, LPCTSTR lpszPhoneTransfer,
  376. HNBOX hNBoxTransfer, DWORD dwTimeoutTransfer, DWORD dwFlags)
  377. {
  378. BOOL fSuccess = TRUE;
  379. int (WINAPI *lpfnTelTransfer)(HTEL hTel, LPCTSTR lpszPhoneTransfer,
  380. HNBOX hNBoxTransfer, DWORD dwTimeoutTransfer, DWORD dwFlags);
  381. int iRet;
  382. if (aTelThunkFn[iTelTransfer].index != iTelTransfer)
  383. fSuccess = TraceFALSE(NULL);
  384. else if (((FARPROC) lpfnTelTransfer = aTelThunkFn[iTelTransfer].lpfn) == NULL)
  385. fSuccess = TraceFALSE(NULL);
  386. else
  387. {
  388. iRet = (*lpfnTelTransfer)(hTel, lpszPhoneTransfer,
  389. hNBoxTransfer, dwTimeoutTransfer, dwFlags);
  390. }
  391. return fSuccess ? iRet : -1;
  392. }
  393. int DLLEXPORT WINAPI TelConnectIdleTimeoutReset(HTEL hTel, BOOL fReset)
  394. {
  395. BOOL fSuccess = TRUE;
  396. int (WINAPI *lpfnTelConnectIdleTimeoutReset)(HTEL hTel, BOOL fReset);
  397. int iRet;
  398. if (aTelThunkFn[iTelConnectIdleTimeoutReset].index != iTelConnectIdleTimeoutReset)
  399. fSuccess = TraceFALSE(NULL);
  400. else if (((FARPROC) lpfnTelConnectIdleTimeoutReset = aTelThunkFn[iTelConnectIdleTimeoutReset].lpfn) == NULL)
  401. fSuccess = TraceFALSE(NULL);
  402. else
  403. {
  404. iRet = (*lpfnTelConnectIdleTimeoutReset)(hTel, fReset);
  405. }
  406. return fSuccess ? iRet : -1;
  407. }
  408. // TelOut thunk functions
  409. //
  410. int DLLEXPORT WINAPI TelOutGetDeviceCount(void)
  411. {
  412. BOOL fSuccess = TRUE;
  413. int (WINAPI *lpfnTelOutGetDeviceCount)(void);
  414. int iRet;
  415. if (aTelThunkFn[iTelOutGetDeviceCount].index != iTelOutGetDeviceCount)
  416. fSuccess = TraceFALSE(NULL);
  417. else if (((FARPROC) lpfnTelOutGetDeviceCount = aTelThunkFn[iTelOutGetDeviceCount].lpfn) == NULL)
  418. fSuccess = TraceFALSE(NULL);
  419. else
  420. {
  421. iRet = (*lpfnTelOutGetDeviceCount)();
  422. }
  423. return fSuccess ? iRet : -1;
  424. }
  425. BOOL DLLEXPORT WINAPI TelOutDeviceIsOpen(int idDev)
  426. {
  427. BOOL fSuccess = TRUE;
  428. BOOL (WINAPI *lpfnTelOutDeviceIsOpen)(int idDev);
  429. BOOL fRet;
  430. if (aTelThunkFn[iTelOutDeviceIsOpen].index != iTelOutDeviceIsOpen)
  431. fSuccess = TraceFALSE(NULL);
  432. else if (((FARPROC) lpfnTelOutDeviceIsOpen = aTelThunkFn[iTelOutDeviceIsOpen].lpfn) == NULL)
  433. fSuccess = TraceFALSE(NULL);
  434. else
  435. {
  436. fRet = (*lpfnTelOutDeviceIsOpen)(idDev);
  437. }
  438. return fSuccess ? fRet : -1;
  439. }
  440. HTELOUT DLLEXPORT WINAPI TelOutOpen(DWORD dwVersion, HINSTANCE hInst,
  441. int idDev, LPWAVEFORMATEX lpwfx, HWND hwndNotify,
  442. DWORD msTimeoutOpen, DWORD msTimeoutRetry, DWORD dwFlags)
  443. {
  444. BOOL fSuccess = TRUE;
  445. HTELOUT (WINAPI *lpfnTelOutOpen)(DWORD dwVersion, HINSTANCE hInst,
  446. int idDev, LPWAVEFORMATEX lpwfx, HWND hwndNotify,
  447. DWORD msTimeoutOpen, DWORD msTimeoutRetry, DWORD dwFlags);
  448. HTELOUT hTelOut;
  449. if (aTelThunkFn[iTelOutOpen].index != iTelOutOpen)
  450. fSuccess = TraceFALSE(NULL);
  451. else if (((FARPROC) lpfnTelOutOpen = aTelThunkFn[iTelOutOpen].lpfn) == NULL)
  452. fSuccess = TraceFALSE(NULL);
  453. else
  454. {
  455. hTelOut = (*lpfnTelOutOpen)(dwVersion, hInst, idDev, lpwfx,
  456. hwndNotify, msTimeoutOpen, msTimeoutRetry, dwFlags);
  457. }
  458. return fSuccess ? hTelOut : NULL;
  459. }
  460. int DLLEXPORT WINAPI TelOutClose(HTELOUT hTelOut, DWORD msTimeoutClose)
  461. {
  462. BOOL fSuccess = TRUE;
  463. int (WINAPI *lpfnTelOutClose)(HTELOUT hTelOut, DWORD msTimeoutClose);
  464. int iRet;
  465. if (aTelThunkFn[iTelOutClose].index != iTelOutClose)
  466. fSuccess = TraceFALSE(NULL);
  467. else if (((FARPROC) lpfnTelOutClose = aTelThunkFn[iTelOutClose].lpfn) == NULL)
  468. fSuccess = TraceFALSE(NULL);
  469. else
  470. {
  471. iRet = (*lpfnTelOutClose)(hTelOut, msTimeoutClose);
  472. }
  473. return fSuccess ? iRet : -1;
  474. }
  475. int DLLEXPORT WINAPI TelOutPlay(HTELOUT hTelOut, LPVOID lpBuf, long sizBuf, long hrfile)
  476. {
  477. BOOL fSuccess = TRUE;
  478. int (WINAPI *lpfnTelOutPlay)(HTELOUT hTelOut, LPVOID lpBuf, long sizBuf, long hrfile);
  479. int iRet;
  480. if (aTelThunkFn[iTelOutPlay].index != iTelOutPlay)
  481. fSuccess = TraceFALSE(NULL);
  482. else if (((FARPROC) lpfnTelOutPlay = aTelThunkFn[iTelOutPlay].lpfn) == NULL)
  483. fSuccess = TraceFALSE(NULL);
  484. else
  485. {
  486. iRet = (*lpfnTelOutPlay)(hTelOut, lpBuf, sizBuf, hrfile);
  487. }
  488. return fSuccess ? iRet : -1;
  489. }
  490. int DLLEXPORT WINAPI TelOutStop(HTELOUT hTelOut, DWORD msTimeoutStop)
  491. {
  492. BOOL fSuccess = TRUE;
  493. int (WINAPI *lpfnTelOutStop)(HTELOUT hTelOut, DWORD msTimeoutStop);
  494. int iRet;
  495. if (aTelThunkFn[iTelOutStop].index != iTelOutStop)
  496. fSuccess = TraceFALSE(NULL);
  497. else if (((FARPROC) lpfnTelOutStop = aTelThunkFn[iTelOutStop].lpfn) == NULL)
  498. fSuccess = TraceFALSE(NULL);
  499. else
  500. {
  501. iRet = (*lpfnTelOutStop)(hTelOut, msTimeoutStop);
  502. }
  503. return fSuccess ? iRet : -1;
  504. }
  505. int DLLEXPORT WINAPI TelOutPause(HTELOUT hTelOut)
  506. {
  507. BOOL fSuccess = TRUE;
  508. int (WINAPI *lpfnTelOutPause)(HTELOUT hTelOut);
  509. int iRet;
  510. if (aTelThunkFn[iTelOutPause].index != iTelOutPause)
  511. fSuccess = TraceFALSE(NULL);
  512. else if (((FARPROC) lpfnTelOutPause = aTelThunkFn[iTelOutPause].lpfn) == NULL)
  513. fSuccess = TraceFALSE(NULL);
  514. else
  515. {
  516. iRet = (*lpfnTelOutPause)(hTelOut);
  517. }
  518. return fSuccess ? iRet : -1;
  519. }
  520. int DLLEXPORT WINAPI TelOutResume(HTELOUT hTelOut)
  521. {
  522. BOOL fSuccess = TRUE;
  523. int (WINAPI *lpfnTelOutResume)(HTELOUT hTelOut);
  524. int iRet;
  525. if (aTelThunkFn[iTelOutResume].index != iTelOutResume)
  526. fSuccess = TraceFALSE(NULL);
  527. else if (((FARPROC) lpfnTelOutResume = aTelThunkFn[iTelOutResume].lpfn) == NULL)
  528. fSuccess = TraceFALSE(NULL);
  529. else
  530. {
  531. iRet = (*lpfnTelOutResume)(hTelOut);
  532. }
  533. return fSuccess ? iRet : -1;
  534. }
  535. WORD DLLEXPORT WINAPI TelOutGetState(HTELOUT hTelOut)
  536. {
  537. BOOL fSuccess = TRUE;
  538. WORD (WINAPI *lpfnTelOutGetState)(HTELOUT hTelOut);
  539. WORD wRet;
  540. if (aTelThunkFn[iTelOutGetState].index != iTelOutGetState)
  541. fSuccess = TraceFALSE(NULL);
  542. else if (((FARPROC) lpfnTelOutGetState = aTelThunkFn[iTelOutGetState].lpfn) == NULL)
  543. fSuccess = TraceFALSE(NULL);
  544. else
  545. {
  546. wRet = (*lpfnTelOutGetState)(hTelOut);
  547. }
  548. return fSuccess ? wRet : 0;
  549. }
  550. long DLLEXPORT WINAPI TelOutGetPosition(HTELOUT hTelOut)
  551. {
  552. BOOL fSuccess = TRUE;
  553. long (WINAPI *lpfnTelOutGetPosition)(HTELOUT hTelOut);
  554. long lRet;
  555. if (aTelThunkFn[iTelOutGetPosition].index != iTelOutGetPosition)
  556. fSuccess = TraceFALSE(NULL);
  557. else if (((FARPROC) lpfnTelOutGetPosition = aTelThunkFn[iTelOutGetPosition].lpfn) == NULL)
  558. fSuccess = TraceFALSE(NULL);
  559. else
  560. {
  561. lRet = (*lpfnTelOutGetPosition)(hTelOut);
  562. }
  563. return fSuccess ? lRet : -1;
  564. }
  565. int DLLEXPORT WINAPI TelOutGetId(HTELOUT hTelOut)
  566. {
  567. BOOL fSuccess = TRUE;
  568. int (WINAPI *lpfnTelOutGetId)(HTELOUT hTelOut);
  569. int iRet;
  570. if (aTelThunkFn[iTelOutGetId].index != iTelOutGetId)
  571. fSuccess = TraceFALSE(NULL);
  572. else if (((FARPROC) lpfnTelOutGetId = aTelThunkFn[iTelOutGetId].lpfn) == NULL)
  573. fSuccess = TraceFALSE(NULL);
  574. else
  575. {
  576. iRet = (*lpfnTelOutGetId)(hTelOut);
  577. }
  578. return fSuccess ? iRet : -1;
  579. }
  580. int DLLEXPORT WINAPI TelOutGetName(HTELOUT hTelOut, int idDev, LPTSTR lpszName, int sizName)
  581. {
  582. BOOL fSuccess = TRUE;
  583. int (WINAPI *lpfnTelOutGetName)(HTELOUT hTelOut, int idDev, LPTSTR lpszName, int sizName);
  584. int iRet;
  585. if (aTelThunkFn[iTelOutGetName].index != iTelOutGetName)
  586. fSuccess = TraceFALSE(NULL);
  587. else if (((FARPROC) lpfnTelOutGetName = aTelThunkFn[iTelOutGetName].lpfn) == NULL)
  588. fSuccess = TraceFALSE(NULL);
  589. else
  590. {
  591. iRet = (*lpfnTelOutGetName)(hTelOut, idDev, lpszName, sizName);
  592. }
  593. return fSuccess ? iRet : -1;
  594. }
  595. BOOL DLLEXPORT WINAPI TelOutSupportsFormat(HTELOUT hTelOut, int idDev,
  596. LPWAVEFORMATEX lpwfx)
  597. {
  598. BOOL fSuccess = TRUE;
  599. BOOL (WINAPI *lpfnTelOutSupportsFormat)(HTELOUT hTelOut, int idDev,
  600. LPWAVEFORMATEX lpwfx);
  601. BOOL fRet;
  602. if (aTelThunkFn[iTelOutSupportsFormat].index != iTelOutSupportsFormat)
  603. fSuccess = TraceFALSE(NULL);
  604. else if (((FARPROC) lpfnTelOutSupportsFormat = aTelThunkFn[iTelOutSupportsFormat].lpfn) == NULL)
  605. fSuccess = TraceFALSE(NULL);
  606. else
  607. {
  608. fRet = (*lpfnTelOutSupportsFormat)(hTelOut, idDev, lpwfx);
  609. }
  610. return fSuccess ? fRet : FALSE;
  611. }
  612. LPWAVEFORMATEX DLLEXPORT WINAPI TelOutFormatSuggest(HTELOUT hTelOut,
  613. int idDev, LPWAVEFORMATEX lpwfxSrc, DWORD dwFlags)
  614. {
  615. BOOL fSuccess = TRUE;
  616. LPWAVEFORMATEX (WINAPI *lpfnTelOutFormatSuggest)(HTELOUT hTelOut,
  617. int idDev, LPWAVEFORMATEX lpwfxSrc, DWORD dwFlags);
  618. LPWAVEFORMATEX lpwfx;
  619. if (aTelThunkFn[iTelOutFormatSuggest].index != iTelOutFormatSuggest)
  620. fSuccess = TraceFALSE(NULL);
  621. else if (((FARPROC) lpfnTelOutFormatSuggest = aTelThunkFn[iTelOutFormatSuggest].lpfn) == NULL)
  622. fSuccess = TraceFALSE(NULL);
  623. else
  624. {
  625. lpwfx = (*lpfnTelOutFormatSuggest)(hTelOut, idDev, lpwfxSrc, dwFlags);
  626. }
  627. return fSuccess ? lpwfx : NULL;
  628. }
  629. BOOL DLLEXPORT WINAPI TelOutIsSynchronous(HTELOUT hTelOut, int idDev)
  630. {
  631. BOOL fSuccess = TRUE;
  632. BOOL (WINAPI *lpfnTelOutIsSynchronous)(HTELOUT hTelOut, int idDev);
  633. BOOL fRet;
  634. if (aTelThunkFn[iTelOutIsSynchronous].index != iTelOutIsSynchronous)
  635. fSuccess = TraceFALSE(NULL);
  636. else if (((FARPROC) lpfnTelOutIsSynchronous = aTelThunkFn[iTelOutIsSynchronous].lpfn) == NULL)
  637. fSuccess = TraceFALSE(NULL);
  638. else
  639. {
  640. fRet = (*lpfnTelOutIsSynchronous)(hTelOut, idDev);
  641. }
  642. return fSuccess ? fRet : FALSE;
  643. }
  644. BOOL DLLEXPORT WINAPI TelOutSupportsVolume(HTELOUT hTelOut, int idDev)
  645. {
  646. BOOL fSuccess = TRUE;
  647. BOOL (WINAPI *lpfnTelOutSupportsVolume)(HTELOUT hTelOut, int idDev);
  648. BOOL fRet;
  649. if (aTelThunkFn[iTelOutSupportsVolume].index != iTelOutSupportsVolume)
  650. fSuccess = TraceFALSE(NULL);
  651. else if (((FARPROC) lpfnTelOutSupportsVolume = aTelThunkFn[iTelOutSupportsVolume].lpfn) == NULL)
  652. fSuccess = TraceFALSE(NULL);
  653. else
  654. {
  655. fRet = (*lpfnTelOutSupportsVolume)(hTelOut, idDev);
  656. }
  657. return fSuccess ? fRet : FALSE;
  658. }
  659. BOOL DLLEXPORT WINAPI TelOutSupportsSpeed(HTELOUT hTelOut, int idDev)
  660. {
  661. BOOL fSuccess = TRUE;
  662. BOOL (WINAPI *lpfnTelOutSupportsSpeed)(HTELOUT hTelOut, int idDev);
  663. BOOL fRet;
  664. if (aTelThunkFn[iTelOutSupportsSpeed].index != iTelOutSupportsSpeed)
  665. fSuccess = TraceFALSE(NULL);
  666. else if (((FARPROC) lpfnTelOutSupportsSpeed = aTelThunkFn[iTelOutSupportsSpeed].lpfn) == NULL)
  667. fSuccess = TraceFALSE(NULL);
  668. else
  669. {
  670. fRet = (*lpfnTelOutSupportsSpeed)(hTelOut, idDev);
  671. }
  672. return fSuccess ? fRet : FALSE;
  673. }
  674. BOOL DLLEXPORT WINAPI TelOutSupportsPitch(HTELOUT hTelOut, int idDev)
  675. {
  676. BOOL fSuccess = TRUE;
  677. BOOL (WINAPI *lpfnTelOutSupportsPitch)(HTELOUT hTelOut, int idDev);
  678. BOOL fRet;
  679. if (aTelThunkFn[iTelOutSupportsPitch].index != iTelOutSupportsPitch)
  680. fSuccess = TraceFALSE(NULL);
  681. else if (((FARPROC) lpfnTelOutSupportsPitch = aTelThunkFn[iTelOutSupportsPitch].lpfn) == NULL)
  682. fSuccess = TraceFALSE(NULL);
  683. else
  684. {
  685. fRet = (*lpfnTelOutSupportsPitch)(hTelOut, idDev);
  686. }
  687. return fSuccess ? fRet : FALSE;
  688. }
  689. int DLLEXPORT WINAPI TelOutGetVolume(HTELOUT hTelOut)
  690. {
  691. BOOL fSuccess = TRUE;
  692. int (WINAPI *lpfnTelOutGetVolume)(HTELOUT hTelOut);
  693. int iRet;
  694. if (aTelThunkFn[iTelOutGetVolume].index != iTelOutGetVolume)
  695. fSuccess = TraceFALSE(NULL);
  696. else if (((FARPROC) lpfnTelOutGetVolume = aTelThunkFn[iTelOutGetVolume].lpfn) == NULL)
  697. fSuccess = TraceFALSE(NULL);
  698. else
  699. {
  700. iRet = (*lpfnTelOutGetVolume)(hTelOut);
  701. }
  702. return fSuccess ? iRet : -1;
  703. }
  704. int DLLEXPORT WINAPI TelOutSetVolume(HTELOUT hTelOut, int nLevel)
  705. {
  706. BOOL fSuccess = TRUE;
  707. int (WINAPI *lpfnTelOutSetVolume)(HTELOUT hTelOut, int nLevel);
  708. int iRet;
  709. if (aTelThunkFn[iTelOutSetVolume].index != iTelOutSetVolume)
  710. fSuccess = TraceFALSE(NULL);
  711. else if (((FARPROC) lpfnTelOutSetVolume = aTelThunkFn[iTelOutSetVolume].lpfn) == NULL)
  712. fSuccess = TraceFALSE(NULL);
  713. else
  714. {
  715. iRet = (*lpfnTelOutSetVolume)(hTelOut, nLevel);
  716. }
  717. return fSuccess ? iRet : -1;
  718. }
  719. int DLLEXPORT WINAPI TelOutGetSpeed(HTELOUT hTelOut)
  720. {
  721. BOOL fSuccess = TRUE;
  722. int (WINAPI *lpfnTelOutGetSpeed)(HTELOUT hTelOut);
  723. int iRet;
  724. if (aTelThunkFn[iTelOutGetSpeed].index != iTelOutGetSpeed)
  725. fSuccess = TraceFALSE(NULL);
  726. else if (((FARPROC) lpfnTelOutGetSpeed = aTelThunkFn[iTelOutGetSpeed].lpfn) == NULL)
  727. fSuccess = TraceFALSE(NULL);
  728. else
  729. {
  730. iRet = (*lpfnTelOutGetSpeed)(hTelOut);
  731. }
  732. return fSuccess ? iRet : -1;
  733. }
  734. int DLLEXPORT WINAPI TelOutSetSpeed(HTELOUT hTelOut, int nLevel)
  735. {
  736. BOOL fSuccess = TRUE;
  737. int (WINAPI *lpfnTelOutSetSpeed)(HTELOUT hTelOut, int nLevel);
  738. int iRet;
  739. if (aTelThunkFn[iTelOutSetSpeed].index != iTelOutSetSpeed)
  740. fSuccess = TraceFALSE(NULL);
  741. else if (((FARPROC) lpfnTelOutSetSpeed = aTelThunkFn[iTelOutSetSpeed].lpfn) == NULL)
  742. fSuccess = TraceFALSE(NULL);
  743. else
  744. {
  745. iRet = (*lpfnTelOutSetSpeed)(hTelOut, nLevel);
  746. }
  747. return fSuccess ? iRet : -1;
  748. }
  749. int DLLEXPORT WINAPI TelOutGetPitch(HTELOUT hTelOut)
  750. {
  751. BOOL fSuccess = TRUE;
  752. int (WINAPI *lpfnTelOutGetPitch)(HTELOUT hTelOut);
  753. int iRet;
  754. if (aTelThunkFn[iTelOutGetPitch].index != iTelOutGetPitch)
  755. fSuccess = TraceFALSE(NULL);
  756. else if (((FARPROC) lpfnTelOutGetPitch = aTelThunkFn[iTelOutGetPitch].lpfn) == NULL)
  757. fSuccess = TraceFALSE(NULL);
  758. else
  759. {
  760. iRet = (*lpfnTelOutGetPitch)(hTelOut);
  761. }
  762. return fSuccess ? iRet : -1;
  763. }
  764. int DLLEXPORT WINAPI TelOutSetPitch(HTELOUT hTelOut, int nLevel)
  765. {
  766. BOOL fSuccess = TRUE;
  767. int (WINAPI *lpfnTelOutSetPitch)(HTELOUT hTelOut, int nLevel);
  768. int iRet;
  769. if (aTelThunkFn[iTelOutSetPitch].index != iTelOutSetPitch)
  770. fSuccess = TraceFALSE(NULL);
  771. else if (((FARPROC) lpfnTelOutSetPitch = aTelThunkFn[iTelOutSetPitch].lpfn) == NULL)
  772. fSuccess = TraceFALSE(NULL);
  773. else
  774. {
  775. iRet = (*lpfnTelOutSetPitch)(hTelOut, nLevel);
  776. }
  777. return fSuccess ? iRet : -1;
  778. }
  779. int DLLEXPORT WINAPI TelOutTerm(HINSTANCE hInst, DWORD dwFlags)
  780. {
  781. BOOL fSuccess = TRUE;
  782. int (WINAPI *lpfnTelOutTerm)(HINSTANCE hInst, DWORD dwFlags);
  783. int iRet;
  784. if (aTelThunkFn[iTelOutTerm].index != iTelOutTerm)
  785. fSuccess = TraceFALSE(NULL);
  786. else if (((FARPROC) lpfnTelOutTerm = aTelThunkFn[iTelOutTerm].lpfn) == NULL)
  787. fSuccess = TraceFALSE(NULL);
  788. else
  789. {
  790. iRet = (*lpfnTelOutTerm)(hInst, dwFlags);
  791. }
  792. return fSuccess ? iRet : -1;
  793. }
  794. // TelIn thunk functions
  795. //
  796. int DLLEXPORT WINAPI TelInGetDeviceCount(void)
  797. {
  798. BOOL fSuccess = TRUE;
  799. int (WINAPI *lpfnTelInGetDeviceCount)(void);
  800. int iRet;
  801. if (aTelThunkFn[iTelInGetDeviceCount].index != iTelInGetDeviceCount)
  802. fSuccess = TraceFALSE(NULL);
  803. else if (((FARPROC) lpfnTelInGetDeviceCount = aTelThunkFn[iTelInGetDeviceCount].lpfn) == NULL)
  804. fSuccess = TraceFALSE(NULL);
  805. else
  806. {
  807. iRet = (*lpfnTelInGetDeviceCount)();
  808. }
  809. return fSuccess ? iRet : -1;
  810. }
  811. BOOL DLLEXPORT WINAPI TelInDeviceIsOpen(int idDev)
  812. {
  813. BOOL fSuccess = TRUE;
  814. BOOL (WINAPI *lpfnTelInDeviceIsOpen)(int idDev);
  815. BOOL fRet;
  816. if (aTelThunkFn[iTelInDeviceIsOpen].index != iTelInDeviceIsOpen)
  817. fSuccess = TraceFALSE(NULL);
  818. else if (((FARPROC) lpfnTelInDeviceIsOpen = aTelThunkFn[iTelInDeviceIsOpen].lpfn) == NULL)
  819. fSuccess = TraceFALSE(NULL);
  820. else
  821. {
  822. fRet = (*lpfnTelInDeviceIsOpen)(idDev);
  823. }
  824. return fSuccess ? fRet : -1;
  825. }
  826. HTELIN DLLEXPORT WINAPI TelInOpen(DWORD dwVersion, HINSTANCE hInst,
  827. int idDev, LPWAVEFORMATEX lpwfx, HWND hwndNotify,
  828. DWORD msTimeoutOpen, DWORD msTimeoutRetry, DWORD dwFlags)
  829. {
  830. BOOL fSuccess = TRUE;
  831. HTELIN (WINAPI *lpfnTelInOpen)(DWORD dwVersion, HINSTANCE hInst,
  832. int idDev, LPWAVEFORMATEX lpwfx, HWND hwndNotify,
  833. DWORD msTimeoutOpen, DWORD msTimeoutRetry, DWORD dwFlags);
  834. HTELIN hTelIn;
  835. if (aTelThunkFn[iTelInOpen].index != iTelInOpen)
  836. fSuccess = TraceFALSE(NULL);
  837. else if (((FARPROC) lpfnTelInOpen = aTelThunkFn[iTelInOpen].lpfn) == NULL)
  838. fSuccess = TraceFALSE(NULL);
  839. else
  840. {
  841. hTelIn = (*lpfnTelInOpen)(dwVersion, hInst, idDev, lpwfx,
  842. hwndNotify, msTimeoutOpen, msTimeoutRetry, dwFlags);
  843. }
  844. return fSuccess ? hTelIn : NULL;
  845. }
  846. int DLLEXPORT WINAPI TelInClose(HTELIN hTelIn, DWORD msTimeoutClose)
  847. {
  848. BOOL fSuccess = TRUE;
  849. int (WINAPI *lpfnTelInClose)(HTELIN hTelIn, DWORD msTimeoutClose);
  850. int iRet;
  851. if (aTelThunkFn[iTelInClose].index != iTelInClose)
  852. fSuccess = TraceFALSE(NULL);
  853. else if (((FARPROC) lpfnTelInClose = aTelThunkFn[iTelInClose].lpfn) == NULL)
  854. fSuccess = TraceFALSE(NULL);
  855. else
  856. {
  857. iRet = (*lpfnTelInClose)(hTelIn, msTimeoutClose);
  858. }
  859. return fSuccess ? iRet : -1;
  860. }
  861. int DLLEXPORT WINAPI TelInRecord(HTELIN hTelIn, LPVOID lpBuf, long sizBuf, long hrfile)
  862. {
  863. BOOL fSuccess = TRUE;
  864. int (WINAPI *lpfnTelInRecord)(HTELIN hTelIn, LPVOID lpBuf, long sizBuf, long hrfile);
  865. int iRet;
  866. if (aTelThunkFn[iTelInRecord].index != iTelInRecord)
  867. fSuccess = TraceFALSE(NULL);
  868. else if (((FARPROC) lpfnTelInRecord = aTelThunkFn[iTelInRecord].lpfn) == NULL)
  869. fSuccess = TraceFALSE(NULL);
  870. else
  871. {
  872. iRet = (*lpfnTelInRecord)(hTelIn, lpBuf, sizBuf, hrfile);
  873. }
  874. return fSuccess ? iRet : -1;
  875. }
  876. int DLLEXPORT WINAPI TelInStop(HTELIN hTelIn, DWORD msTimeoutStop)
  877. {
  878. BOOL fSuccess = TRUE;
  879. int (WINAPI *lpfnTelInStop)(HTELIN hTelIn, DWORD msTimeoutStop);
  880. int iRet;
  881. if (aTelThunkFn[iTelInStop].index != iTelInStop)
  882. fSuccess = TraceFALSE(NULL);
  883. else if (((FARPROC) lpfnTelInStop = aTelThunkFn[iTelInStop].lpfn) == NULL)
  884. fSuccess = TraceFALSE(NULL);
  885. else
  886. {
  887. iRet = (*lpfnTelInStop)(hTelIn, msTimeoutStop);
  888. }
  889. return fSuccess ? iRet : -1;
  890. }
  891. WORD DLLEXPORT WINAPI TelInGetState(HTELIN hTelIn)
  892. {
  893. BOOL fSuccess = TRUE;
  894. WORD (WINAPI *lpfnTelInGetState)(HTELIN hTelIn);
  895. WORD wRet;
  896. if (aTelThunkFn[iTelInGetState].index != iTelInGetState)
  897. fSuccess = TraceFALSE(NULL);
  898. else if (((FARPROC) lpfnTelInGetState = aTelThunkFn[iTelInGetState].lpfn) == NULL)
  899. fSuccess = TraceFALSE(NULL);
  900. else
  901. {
  902. wRet = (*lpfnTelInGetState)(hTelIn);
  903. }
  904. return fSuccess ? wRet : 0;
  905. }
  906. long DLLEXPORT WINAPI TelInGetPosition(HTELIN hTelIn)
  907. {
  908. BOOL fSuccess = TRUE;
  909. long (WINAPI *lpfnTelInGetPosition)(HTELIN hTelIn);
  910. long lRet;
  911. if (aTelThunkFn[iTelInGetPosition].index != iTelInGetPosition)
  912. fSuccess = TraceFALSE(NULL);
  913. else if (((FARPROC) lpfnTelInGetPosition = aTelThunkFn[iTelInGetPosition].lpfn) == NULL)
  914. fSuccess = TraceFALSE(NULL);
  915. else
  916. {
  917. lRet = (*lpfnTelInGetPosition)(hTelIn);
  918. }
  919. return fSuccess ? lRet : -1;
  920. }
  921. int DLLEXPORT WINAPI TelInGetId(HTELIN hTelIn)
  922. {
  923. BOOL fSuccess = TRUE;
  924. int (WINAPI *lpfnTelInGetId)(HTELIN hTelIn);
  925. int iRet;
  926. if (aTelThunkFn[iTelInGetId].index != iTelInGetId)
  927. fSuccess = TraceFALSE(NULL);
  928. else if (((FARPROC) lpfnTelInGetId = aTelThunkFn[iTelInGetId].lpfn) == NULL)
  929. fSuccess = TraceFALSE(NULL);
  930. else
  931. {
  932. iRet = (*lpfnTelInGetId)(hTelIn);
  933. }
  934. return fSuccess ? iRet : -1;
  935. }
  936. int DLLEXPORT WINAPI TelInGetName(HTELIN hTelIn, int idDev, LPTSTR lpszName, int sizName)
  937. {
  938. BOOL fSuccess = TRUE;
  939. int (WINAPI *lpfnTelInGetName)(HTELIN hTelIn, int idDev, LPTSTR lpszName, int sizName);
  940. int iRet;
  941. if (aTelThunkFn[iTelInGetName].index != iTelInGetName)
  942. fSuccess = TraceFALSE(NULL);
  943. else if (((FARPROC) lpfnTelInGetName = aTelThunkFn[iTelInGetName].lpfn) == NULL)
  944. fSuccess = TraceFALSE(NULL);
  945. else
  946. {
  947. iRet = (*lpfnTelInGetName)(hTelIn, idDev, lpszName, sizName);
  948. }
  949. return fSuccess ? iRet : -1;
  950. }
  951. BOOL DLLEXPORT WINAPI TelInSupportsFormat(HTELIN hTelIn, int idDev,
  952. LPWAVEFORMATEX lpwfx)
  953. {
  954. BOOL fSuccess = TRUE;
  955. BOOL (WINAPI *lpfnTelInSupportsFormat)(HTELIN hTelIn, int idDev,
  956. LPWAVEFORMATEX lpwfx);
  957. BOOL fRet;
  958. if (aTelThunkFn[iTelInSupportsFormat].index != iTelInSupportsFormat)
  959. fSuccess = TraceFALSE(NULL);
  960. else if (((FARPROC) lpfnTelInSupportsFormat = aTelThunkFn[iTelInSupportsFormat].lpfn) == NULL)
  961. fSuccess = TraceFALSE(NULL);
  962. else
  963. {
  964. fRet = (*lpfnTelInSupportsFormat)(hTelIn, idDev, lpwfx);
  965. }
  966. return fSuccess ? fRet : FALSE;
  967. }
  968. LPWAVEFORMATEX DLLEXPORT WINAPI TelInFormatSuggest(HTELIN hTelIn,
  969. int idDev, LPWAVEFORMATEX lpwfxSrc, DWORD dwFlags)
  970. {
  971. BOOL fSuccess = TRUE;
  972. LPWAVEFORMATEX (WINAPI *lpfnTelInFormatSuggest)(HTELIN hTelIn,
  973. int idDev, LPWAVEFORMATEX lpwfxSrc, DWORD dwFlags);
  974. LPWAVEFORMATEX lpwfx;
  975. if (aTelThunkFn[iTelInFormatSuggest].index != iTelInFormatSuggest)
  976. fSuccess = TraceFALSE(NULL);
  977. else if (((FARPROC) lpfnTelInFormatSuggest = aTelThunkFn[iTelInFormatSuggest].lpfn) == NULL)
  978. fSuccess = TraceFALSE(NULL);
  979. else
  980. {
  981. lpwfx = (*lpfnTelInFormatSuggest)(hTelIn, idDev, lpwfxSrc, dwFlags);
  982. }
  983. return fSuccess ? lpwfx : NULL;
  984. }
  985. int DLLEXPORT WINAPI TelInTerm(HINSTANCE hInst, DWORD dwFlags)
  986. {
  987. BOOL fSuccess = TRUE;
  988. int (WINAPI *lpfnTelInTerm)(HINSTANCE hInst, DWORD dwFlags);
  989. int iRet;
  990. if (aTelThunkFn[iTelInTerm].index != iTelInTerm)
  991. fSuccess = TraceFALSE(NULL);
  992. else if (((FARPROC) lpfnTelInTerm = aTelThunkFn[iTelInTerm].lpfn) == NULL)
  993. fSuccess = TraceFALSE(NULL);
  994. else
  995. {
  996. iRet = (*lpfnTelInTerm)(hInst, dwFlags);
  997. }
  998. return fSuccess ? iRet : -1;
  999. }
  1000. int DLLEXPORT WINAPI TelCfgRead(DWORD dwVersion, HINSTANCE hInst,
  1001. LPTELCFG lpTelCfg, LPARAM lParam, DWORD dwFlags)
  1002. {
  1003. BOOL fSuccess = TRUE;
  1004. int (WINAPI *lpfnTelCfgRead)(DWORD dwVersion, HINSTANCE hInst,
  1005. LPTELCFG lpTelCfg, LPARAM lParam, DWORD dwFlags);
  1006. int iRet;
  1007. if (aTelThunkFn[iTelCfgRead].index != iTelCfgRead)
  1008. fSuccess = TraceFALSE(NULL);
  1009. else if (((FARPROC) lpfnTelCfgRead = aTelThunkFn[iTelCfgRead].lpfn) == NULL)
  1010. fSuccess = TraceFALSE(NULL);
  1011. else
  1012. {
  1013. iRet = (*lpfnTelCfgRead)(dwVersion, hInst, lpTelCfg, lParam, dwFlags);
  1014. }
  1015. return fSuccess ? iRet : -1;
  1016. }
  1017. int DLLEXPORT WINAPI TelCfgWrite(DWORD dwVersion, HINSTANCE hInst,
  1018. LPTELCFG lpTelCfg, LPARAM lParam, DWORD dwFlags)
  1019. {
  1020. BOOL fSuccess = TRUE;
  1021. int (WINAPI *lpfnTelCfgWrite)(DWORD dwVersion, HINSTANCE hInst,
  1022. LPTELCFG lpTelCfg, LPARAM lParam, DWORD dwFlags);
  1023. int iRet;
  1024. if (aTelThunkFn[iTelCfgWrite].index != iTelCfgWrite)
  1025. fSuccess = TraceFALSE(NULL);
  1026. else if (((FARPROC) lpfnTelCfgWrite = aTelThunkFn[iTelCfgWrite].lpfn) == NULL)
  1027. fSuccess = TraceFALSE(NULL);
  1028. else
  1029. {
  1030. iRet = (*lpfnTelCfgWrite)(dwVersion, hInst, lpTelCfg, lParam, dwFlags);
  1031. }
  1032. return fSuccess ? iRet : -1;
  1033. }
  1034. int DLLEXPORT WINAPI TelCfgDoDialog(HINSTANCE hInst,
  1035. HWND hwndOwner, LPARAM lParam)
  1036. {
  1037. BOOL fSuccess = TRUE;
  1038. int (WINAPI *lpfnTelCfgDoDialog)(HINSTANCE hInst,
  1039. HWND hwndOwner, LPARAM lParam);
  1040. int iRet;
  1041. if (aTelThunkFn[iTelCfgDoDialog].index != iTelCfgDoDialog)
  1042. fSuccess = TraceFALSE(NULL);
  1043. else if (((FARPROC) lpfnTelCfgDoDialog = aTelThunkFn[iTelCfgDoDialog].lpfn) == NULL)
  1044. fSuccess = TraceFALSE(NULL);
  1045. else
  1046. {
  1047. iRet = (*lpfnTelCfgDoDialog)(hInst, hwndOwner, lParam);
  1048. }
  1049. return fSuccess ? iRet : -1;
  1050. }
  1051. HWAV DLLEXPORT WINAPI TelWavOpenEx(DWORD dwVersion, HINSTANCE hInst,
  1052. LPTSTR lpszFileName, DWORD dwReserved, DWORD dwFlagsOpen, DWORD dwFlagsEx)
  1053. {
  1054. BOOL fSuccess = TRUE;
  1055. HWAV (WINAPI *lpfnTelWavOpenEx)(DWORD dwVersion, HINSTANCE hInst,
  1056. LPTSTR lpszFileName, DWORD dwReserved, DWORD dwFlagsOpen, DWORD dwFlagsEx);
  1057. HWAV hWav;
  1058. if (aTelThunkFn[iTelWavOpenEx].index != iTelWavOpenEx)
  1059. fSuccess = TraceFALSE(NULL);
  1060. else if (((FARPROC) lpfnTelWavOpenEx = aTelThunkFn[iTelWavOpenEx].lpfn) == NULL)
  1061. fSuccess = TraceFALSE(NULL);
  1062. else
  1063. {
  1064. hWav = (*lpfnTelWavOpenEx)(dwVersion, hInst,
  1065. lpszFileName, dwReserved, dwFlagsOpen, dwFlagsEx);
  1066. }
  1067. return fSuccess ? hWav : NULL;
  1068. }
  1069. ////
  1070. // helper functions
  1071. ////
  1072. // TelThunkGetPtr - verify that telthunk handle is valid,
  1073. // <hTelThunk> (i) handle returned from TelThunkInit
  1074. // return corresponding telthunk pointer (NULL if error)
  1075. //
  1076. static LPTELTHUNK TelThunkGetPtr(HTELTHUNK hTelThunk)
  1077. {
  1078. BOOL fSuccess = TRUE;
  1079. LPTELTHUNK lpTelThunk;
  1080. if ((lpTelThunk = (LPTELTHUNK) hTelThunk) == NULL)
  1081. fSuccess = TraceFALSE(NULL);
  1082. else if (IsBadWritePtr(lpTelThunk, sizeof(TELTHUNK)))
  1083. fSuccess = TraceFALSE(NULL);
  1084. #ifdef CHECKTASK
  1085. // make sure current task owns the telthunk handle
  1086. //
  1087. else if (lpTelThunk->hTask != GetCurrentTask())
  1088. fSuccess = TraceFALSE(NULL);
  1089. #endif
  1090. return fSuccess ? lpTelThunk : NULL;
  1091. }
  1092. // TelThunkGetHandle - verify that telthunk pointer is valid,
  1093. // <lpTelThunk> (i) pointer to TELTHUNK struct
  1094. // return corresponding telthunk handle (NULL if error)
  1095. //
  1096. static HTELTHUNK TelThunkGetHandle(LPTELTHUNK lpTelThunk)
  1097. {
  1098. BOOL fSuccess = TRUE;
  1099. HTELTHUNK hTelThunk;
  1100. if ((hTelThunk = (HTELTHUNK) lpTelThunk) == NULL)
  1101. fSuccess = TraceFALSE(NULL);
  1102. return fSuccess ? hTelThunk : NULL;
  1103. }