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.

2196 lines
54 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. print.c
  5. Abstract:
  6. This module contains the port
  7. specific WINFAX API functions.
  8. Author:
  9. Wesley Witt (wesw) 29-Nov-1996
  10. Revision History:
  11. --*/
  12. #include "faxapi.h"
  13. #pragma hdrstop
  14. int
  15. __cdecl
  16. PortPriorityCompare(
  17. const void *arg1,
  18. const void *arg2
  19. )
  20. {
  21. if (((PFAX_PORT_INFOW)arg1)->Priority < ((PFAX_PORT_INFOW)arg2)->Priority) {
  22. return -1;
  23. }
  24. if (((PFAX_PORT_INFOW)arg1)->Priority > ((PFAX_PORT_INFOW)arg2)->Priority) {
  25. return 1;
  26. }
  27. return 0;
  28. }
  29. BOOL
  30. WINAPI
  31. FaxEnumPortsW(
  32. IN HANDLE FaxHandle,
  33. OUT PFAX_PORT_INFOW *PortInfoBuffer,
  34. OUT LPDWORD PortsReturned
  35. )
  36. /*++
  37. Routine Description:
  38. Enumerates all of the FAX devices attached to the
  39. FAX server. The port state information is returned
  40. for each device.
  41. Arguments:
  42. FaxHandle - FAX handle obtained from FaxConnectFaxServer
  43. PortInfoBuffer - Buffer to hold the port information
  44. PortInfoBufferSize - Total size of the port info buffer
  45. PortsReturned - The number of ports in the buffer
  46. Return Value:
  47. TRUE - Success
  48. FALSE - Failure, call GetLastError() for more error information.
  49. --*/
  50. {
  51. error_status_t ec;
  52. DWORD i;
  53. PFAX_PORT_INFOW PortInfo;
  54. DWORD PortInfoBufferSize = 0;
  55. DEBUG_FUNCTION_NAME(TEXT("FaxEnumPortsW"));
  56. if (!ValidateFaxHandle(FaxHandle, FHT_SERVICE)) {
  57. SetLastError(ERROR_INVALID_HANDLE);
  58. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  59. return FALSE;
  60. }
  61. if (!PortInfoBuffer || !PortsReturned) {
  62. SetLastError(ERROR_INVALID_PARAMETER);
  63. DebugPrintEx(DEBUG_ERR, _T("!PortInfoBuffer || !PortsReturned."));
  64. return FALSE;
  65. }
  66. *PortInfoBuffer = NULL;
  67. __try
  68. {
  69. ec = FAX_EnumPorts(
  70. FH_FAX_HANDLE(FaxHandle),
  71. (LPBYTE*)PortInfoBuffer,
  72. &PortInfoBufferSize,
  73. PortsReturned
  74. );
  75. }
  76. __except (EXCEPTION_EXECUTE_HANDLER)
  77. {
  78. //
  79. // For some reason we crashed.
  80. //
  81. ec = GetExceptionCode();
  82. DebugPrintEx(
  83. DEBUG_ERR,
  84. TEXT("Exception on RPC call to FAX_EnumPorts. (ec: %ld)"),
  85. ec);
  86. }
  87. if (ec)
  88. {
  89. DumpRPCExtendedStatus ();
  90. SetLastError( ec );
  91. return FALSE;
  92. }
  93. PortInfo = (PFAX_PORT_INFOW) *PortInfoBuffer;
  94. for (i=0; i<*PortsReturned; i++) {
  95. FixupStringPtrW( PortInfoBuffer, PortInfo[i].DeviceName );
  96. FixupStringPtrW( PortInfoBuffer, PortInfo[i].Tsid );
  97. FixupStringPtrW( PortInfoBuffer, PortInfo[i].Csid );
  98. }
  99. //
  100. // sort the ports by priority
  101. //
  102. qsort(
  103. (PVOID) *PortInfoBuffer,
  104. (int) (*PortsReturned),
  105. sizeof(FAX_PORT_INFOW),
  106. PortPriorityCompare
  107. );
  108. return TRUE;
  109. }
  110. BOOL
  111. WINAPI
  112. FaxEnumPortsA(
  113. IN HANDLE FaxHandle,
  114. OUT PFAX_PORT_INFOA *PortInfoBuffer,
  115. OUT LPDWORD PortsReturned
  116. )
  117. /*++
  118. Routine Description:
  119. Enumerates all of the FAX devices attached to the
  120. FAX server. The port state information is returned
  121. for each device.
  122. Arguments:
  123. FaxHandle - FAX handle obtained from FaxConnectFaxServer
  124. PortInfoBuffer - Buffer to hold the port information
  125. PortInfoBufferSize - Total size of the port info buffer
  126. BytesNeeded - Total bytes needed for buffer
  127. PortsReturned - The number of ports in the buffer
  128. Return Value:
  129. TRUE - Success
  130. FALSE - Failure, call GetLastError() for more error information.
  131. --*/
  132. {
  133. DWORD i;
  134. PFAX_PORT_INFOW PortInfo;
  135. DEBUG_FUNCTION_NAME(TEXT("FaxEnumPortsA"));
  136. if (!FaxEnumPortsW(
  137. FaxHandle,
  138. (PFAX_PORT_INFOW *)PortInfoBuffer,
  139. PortsReturned
  140. ))
  141. {
  142. return FALSE;
  143. }
  144. //
  145. // convert the strings from unicode to ascii
  146. //
  147. PortInfo = (PFAX_PORT_INFOW) *PortInfoBuffer;
  148. for (i=0; i<*PortsReturned; i++)
  149. {
  150. if (!ConvertUnicodeStringInPlace( (LPWSTR) PortInfo[i].DeviceName ) ||
  151. !ConvertUnicodeStringInPlace( (LPWSTR) PortInfo[i].Tsid ) ||
  152. !ConvertUnicodeStringInPlace( (LPWSTR) PortInfo[i].Csid ))
  153. {
  154. DebugPrintEx(DEBUG_ERR, _T("ConvertUnicodeStringInPlace failed, ec = %ld."), GetLastError());
  155. MemFree (PortInfo);
  156. return FALSE;
  157. }
  158. }
  159. return TRUE;
  160. } // FaxEnumPortsA
  161. extern "C"
  162. DWORD
  163. WINAPI
  164. IsDeviceVirtual (
  165. IN HANDLE hFaxHandle,
  166. IN DWORD dwDeviceId,
  167. OUT LPBOOL lpbVirtual
  168. )
  169. /*++
  170. Routine name : IsDeviceVirtual
  171. Routine description:
  172. Checks if a given device is virtual
  173. Author:
  174. Eran Yariv (EranY), May, 2001
  175. Arguments:
  176. hFaxHandle [in] - Fax connection handle
  177. dwDeviceId [in] - Device id
  178. lpbVirtual [out] - Result flag
  179. Return Value:
  180. Standard Win32 error code
  181. --*/
  182. {
  183. PFAX_PORT_INFO pPortInfo = NULL;
  184. HANDLE hPort = NULL;
  185. DWORD dwRes = ERROR_SUCCESS;
  186. DEBUG_FUNCTION_NAME(TEXT("IsDeviceVirtual"));
  187. if (!ValidateFaxHandle(hFaxHandle, FHT_SERVICE))
  188. {
  189. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  190. return ERROR_INVALID_HANDLE;
  191. }
  192. if (!FaxOpenPort (hFaxHandle, dwDeviceId, PORT_OPEN_QUERY, &hPort))
  193. {
  194. dwRes = GetLastError ();
  195. DebugPrintEx(DEBUG_ERR, _T("FaxOpenPort() failed with %ld."), dwRes);
  196. return dwRes;
  197. }
  198. if (!FaxGetPort (hPort, &pPortInfo))
  199. {
  200. dwRes = GetLastError ();
  201. DebugPrintEx(DEBUG_ERR, _T("FaxGetPort() failed with %ld."), dwRes);
  202. goto exit;
  203. }
  204. *lpbVirtual = (pPortInfo->Flags & FPF_VIRTUAL) ? TRUE : FALSE;
  205. Assert (ERROR_SUCCESS == dwRes);
  206. exit:
  207. MemFree (pPortInfo);
  208. if (hPort)
  209. {
  210. FaxClose (hPort);
  211. }
  212. return dwRes;
  213. } // IsDeviceVirtual
  214. extern "C"
  215. BOOL
  216. WINAPI
  217. FaxGetPortW(
  218. IN HANDLE FaxPortHandle,
  219. OUT PFAX_PORT_INFOW *PortInfoBuffer
  220. )
  221. /*++
  222. Routine Description:
  223. Returns port status information for a requested port.
  224. The device id passed in should be optained from FAXEnumPorts.
  225. Arguments:
  226. FaxHandle - FAX handle obtained from FaxConnectFaxServer
  227. DeviceId - TAPI device id
  228. PortInfoBuffer - Buffer to hold the port information
  229. PortInfoBufferSize - Total size of the port info buffer
  230. Return Value:
  231. ERROR_SUCCESS for success, otherwise a WIN32 error code.
  232. --*/
  233. {
  234. error_status_t ec;
  235. PFAX_PORT_INFOW PortInfo;
  236. DWORD PortInfoBufferSize = 0;
  237. DEBUG_FUNCTION_NAME(TEXT("FaxGetPortW"));
  238. if (!ValidateFaxHandle(FaxPortHandle, FHT_PORT)) {
  239. SetLastError(ERROR_INVALID_HANDLE);
  240. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  241. return FALSE;
  242. }
  243. if (!PortInfoBuffer) {
  244. SetLastError(ERROR_INVALID_PARAMETER);
  245. DebugPrintEx(DEBUG_ERR, _T("PortInfoBuffer is NULL."));
  246. return FALSE;
  247. }
  248. *PortInfoBuffer = NULL;
  249. __try
  250. {
  251. ec = FAX_GetPort(
  252. FH_PORT_HANDLE(FaxPortHandle),
  253. (LPBYTE*)PortInfoBuffer,
  254. &PortInfoBufferSize
  255. );
  256. }
  257. __except (EXCEPTION_EXECUTE_HANDLER)
  258. {
  259. //
  260. // For some reason we got an exception.
  261. //
  262. ec = GetExceptionCode();
  263. DebugPrintEx(
  264. DEBUG_ERR,
  265. TEXT("Exception on RPC call to FAX_GetPort. (ec: %ld)"),
  266. ec);
  267. }
  268. if (ec)
  269. {
  270. DumpRPCExtendedStatus ();
  271. SetLastError( ec );
  272. return FALSE;
  273. }
  274. PortInfo = (PFAX_PORT_INFOW) *PortInfoBuffer;
  275. FixupStringPtrW( PortInfoBuffer, PortInfo->DeviceName );
  276. FixupStringPtrW( PortInfoBuffer, PortInfo->Tsid );
  277. FixupStringPtrW( PortInfoBuffer, PortInfo->Csid );
  278. return TRUE;
  279. }
  280. extern "C"
  281. BOOL
  282. WINAPI
  283. FaxGetPortA(
  284. IN HANDLE FaxPortHandle,
  285. OUT PFAX_PORT_INFOA *PortInfoBuffer
  286. )
  287. /*++
  288. Routine Description:
  289. Returns port status information for a requested port.
  290. The device id passed in should be optained from FAXEnumPorts.
  291. Arguments:
  292. FaxHandle - FAX handle obtained from FaxConnectFaxServer
  293. DeviceId - TAPI device id
  294. PortInfoBuffer - Buffer to hold the port information
  295. PortInfoBufferSize - Total size of the port info buffer
  296. BytesNeeded - Total bytes needed for buffer
  297. Return Value:
  298. ERROR_SUCCESS for success, otherwise a WIN32 error code.
  299. --*/
  300. {
  301. BOOL Rval = FALSE;
  302. PFAX_PORT_INFOW PortInfo;
  303. DEBUG_FUNCTION_NAME(TEXT("FaxGetPortA"));
  304. if (!FaxGetPortW( FaxPortHandle, (PFAX_PORT_INFOW *)PortInfoBuffer)) {
  305. goto exit;
  306. }
  307. PortInfo = (PFAX_PORT_INFOW) *PortInfoBuffer;
  308. if (!ConvertUnicodeStringInPlace( (LPWSTR)PortInfo->DeviceName ) ||
  309. !ConvertUnicodeStringInPlace( (LPWSTR)PortInfo->Tsid ) ||
  310. !ConvertUnicodeStringInPlace( (LPWSTR)PortInfo->Csid ))
  311. {
  312. DebugPrintEx(DEBUG_ERR, _T("ConvertUnicodeStringInPlace failed, ec = %ld."), GetLastError());
  313. MemFree (PortInfo);
  314. return FALSE;
  315. }
  316. (*PortInfoBuffer)->SizeOfStruct = sizeof(FAX_PORT_INFOA);
  317. Rval = TRUE;
  318. exit:
  319. return Rval;
  320. } // FaxGetPortA
  321. BOOL
  322. FaxSetPortW(
  323. IN HANDLE FaxPortHandle,
  324. IN const FAX_PORT_INFOW *PortInfoBuffer
  325. )
  326. /*++
  327. Routine Description:
  328. Changes the port capability mask. This allows the caller to
  329. enable or disable sending & receiving on a port basis.
  330. Arguments:
  331. FaxHandle - FAX handle obtained from FaxConnectFaxServer.
  332. PortInfo - PortInfo structure
  333. Return Value:
  334. ERROR_SUCCESS for success, otherwise a WIN32 error code.
  335. --*/
  336. {
  337. error_status_t ec;
  338. PHANDLE_ENTRY HandleEntry = (PHANDLE_ENTRY) FaxPortHandle;
  339. DEBUG_FUNCTION_NAME(TEXT("FaxSetPortW"));
  340. //
  341. // Validate Parameters
  342. //
  343. if (!ValidateFaxHandle(FaxPortHandle, FHT_PORT)) {
  344. SetLastError(ERROR_INVALID_HANDLE);
  345. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  346. return FALSE;
  347. }
  348. if (!PortInfoBuffer) {
  349. SetLastError(ERROR_INVALID_PARAMETER);
  350. DebugPrintEx(DEBUG_ERR, _T("PortInfoBuffer is NULL."));
  351. return FALSE;
  352. }
  353. if (PortInfoBuffer->SizeOfStruct != sizeof(FAX_PORT_INFOW)) {
  354. SetLastError(ERROR_INVALID_PARAMETER);
  355. DebugPrintEx(DEBUG_ERR, _T("PortInfoBuffer->SizeOfStruct != sizeof(FAX_PORT_INFOW)."));
  356. return FALSE;
  357. }
  358. if (!(HandleEntry->Flags & PORT_OPEN_MODIFY))
  359. {
  360. SetLastError(ERROR_ACCESS_DENIED);
  361. return FALSE;
  362. }
  363. __try
  364. {
  365. ec = FAX_SetPort(
  366. FH_PORT_HANDLE(FaxPortHandle),
  367. (PFAX_PORT_INFO)PortInfoBuffer
  368. );
  369. }
  370. __except (EXCEPTION_EXECUTE_HANDLER)
  371. {
  372. //
  373. // For some reason we got an exception.
  374. //
  375. ec = GetExceptionCode();
  376. DebugPrintEx(
  377. DEBUG_ERR,
  378. TEXT("Exception on RPC call to FAX_SetPort. (ec: %ld)"),
  379. ec);
  380. }
  381. if (ec)
  382. {
  383. DumpRPCExtendedStatus ();
  384. SetLastError( ec );
  385. return FALSE;
  386. }
  387. return TRUE;
  388. }
  389. BOOL
  390. FaxSetPortA(
  391. IN HANDLE FaxPortHandle,
  392. IN const FAX_PORT_INFOA *PortInfoBuffer
  393. )
  394. /*++
  395. Routine Description:
  396. Changes the port capability mask. This allows the caller to
  397. enable or disable sending & receiving on a port basis.
  398. Arguments:
  399. FaxHandle - FAX handle obtained from FaxConnectFaxServer.
  400. PortInfo - PortInfo structure
  401. Return Value:
  402. ERROR_SUCCESS for success, otherwise a WIN32 error code.
  403. --*/
  404. {
  405. DWORD ec = ERROR_SUCCESS;
  406. FAX_PORT_INFOW PortInfoW = {0};
  407. DEBUG_FUNCTION_NAME(_T("FaxSetPortA"));
  408. //
  409. // Validate Parameters
  410. //
  411. if (!ValidateFaxHandle(FaxPortHandle, FHT_PORT)) {
  412. SetLastError(ERROR_INVALID_HANDLE);
  413. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  414. return FALSE;
  415. }
  416. if (!PortInfoBuffer) {
  417. SetLastError(ERROR_INVALID_PARAMETER);
  418. DebugPrintEx(DEBUG_ERR, _T("PortInfoBuffer is NULL."));
  419. return FALSE;
  420. }
  421. if (PortInfoBuffer->SizeOfStruct != sizeof(FAX_PORT_INFOA)) {
  422. SetLastError(ERROR_INVALID_PARAMETER);
  423. DebugPrintEx(DEBUG_ERR, _T("(PortInfoBuffer->SizeOfStruct != sizeof(FAX_PORT_INFOA))."));
  424. return FALSE;
  425. }
  426. PortInfoW.SizeOfStruct = sizeof(FAX_PORT_INFOW);
  427. PortInfoW.DeviceId = PortInfoBuffer->DeviceId;
  428. PortInfoW.State = PortInfoBuffer->State;
  429. PortInfoW.Flags = PortInfoBuffer->Flags;
  430. PortInfoW.Rings = PortInfoBuffer->Rings;
  431. PortInfoW.Priority = PortInfoBuffer->Priority;
  432. PortInfoW.DeviceName = AnsiStringToUnicodeString( PortInfoBuffer->DeviceName );
  433. if (!PortInfoW.DeviceName && PortInfoBuffer->DeviceName)
  434. {
  435. ec = ERROR_OUTOFMEMORY;
  436. goto exit;
  437. }
  438. PortInfoW.Csid = AnsiStringToUnicodeString( PortInfoBuffer->Csid );
  439. if (!PortInfoW.Csid && PortInfoBuffer->Csid)
  440. {
  441. ec = ERROR_OUTOFMEMORY;
  442. goto exit;
  443. }
  444. PortInfoW.Tsid = AnsiStringToUnicodeString( PortInfoBuffer->Tsid );
  445. if (!PortInfoW.Tsid && PortInfoBuffer->Tsid)
  446. {
  447. ec = ERROR_OUTOFMEMORY;
  448. goto exit;
  449. }
  450. if (!FaxSetPortW( FaxPortHandle, &PortInfoW ))
  451. {
  452. ec = GetLastError();
  453. goto exit;
  454. }
  455. Assert (ERROR_SUCCESS == ec);
  456. exit:
  457. MemFree( (PBYTE) PortInfoW.DeviceName );
  458. MemFree( (PBYTE) PortInfoW.Csid );
  459. MemFree( (PBYTE) PortInfoW.Tsid );
  460. if (ERROR_SUCCESS != ec)
  461. {
  462. SetLastError(ec);
  463. return FALSE;
  464. }
  465. return TRUE;
  466. }
  467. BOOL
  468. WINAPI
  469. FaxOpenPort(
  470. IN HANDLE FaxHandle,
  471. IN DWORD DeviceId,
  472. IN DWORD Flags,
  473. OUT LPHANDLE FaxPortHandle
  474. )
  475. /*++
  476. Routine Description:
  477. Opens a fax port for subsequent use in other fax APIs.
  478. Arguments:
  479. FaxHandle - FAX handle obtained from FaxConnectFaxServer.
  480. DeviceId - Requested device id
  481. FaxPortHandle - The resulting FAX port handle.
  482. Return Value:
  483. TRUE - Success
  484. FALSE - Failure, call GetLastError() for more error information.
  485. --*/
  486. {
  487. error_status_t ec;
  488. PHANDLE_ENTRY HandleEntry;
  489. DEBUG_FUNCTION_NAME(TEXT("FaxOpenPort"));
  490. if (!ValidateFaxHandle(FaxHandle, FHT_SERVICE)) {
  491. SetLastError(ERROR_INVALID_HANDLE);
  492. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  493. return FALSE;
  494. }
  495. if ( !FaxPortHandle ||
  496. (!(Flags & (PORT_OPEN_QUERY | PORT_OPEN_MODIFY) ))) {
  497. SetLastError(ERROR_INVALID_PARAMETER);
  498. return FALSE;
  499. }
  500. __try
  501. {
  502. ec = FAX_OpenPort( FH_FAX_HANDLE(FaxHandle), DeviceId, Flags, FaxPortHandle );
  503. }
  504. __except (EXCEPTION_EXECUTE_HANDLER)
  505. {
  506. //
  507. // For some reason we crashed.
  508. //
  509. ec = GetExceptionCode();
  510. DebugPrintEx(
  511. DEBUG_ERR,
  512. TEXT("Exception on RPC call to FAX_OpenPort. (ec: %ld)"),
  513. ec);
  514. }
  515. if (ec)
  516. {
  517. DumpRPCExtendedStatus ();
  518. SetLastError( ec );
  519. return FALSE;
  520. }
  521. HandleEntry = CreateNewPortHandle( FH_DATA(FaxHandle), Flags, *FaxPortHandle );
  522. if (HandleEntry) {
  523. HandleEntry->DeviceId = DeviceId;
  524. }
  525. *FaxPortHandle = HandleEntry;
  526. return *FaxPortHandle != NULL;
  527. }
  528. BOOL
  529. WINAPI
  530. FaxEnumRoutingMethodsW(
  531. IN HANDLE FaxPortHandle,
  532. OUT PFAX_ROUTING_METHODW *RoutingInfoBuffer,
  533. OUT LPDWORD MethodsReturned
  534. )
  535. {
  536. PFAX_ROUTING_METHODW FaxRoutingMethod = NULL;
  537. error_status_t ec;
  538. DWORD i;
  539. DWORD RoutingInfoBufferSize = 0;
  540. DEBUG_FUNCTION_NAME(TEXT("FaxEnumRoutingMethodsW"));
  541. if (!ValidateFaxHandle(FaxPortHandle, FHT_PORT)) {
  542. SetLastError(ERROR_INVALID_HANDLE);
  543. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  544. return FALSE;
  545. }
  546. if (!RoutingInfoBuffer || !MethodsReturned) {
  547. SetLastError(ERROR_INVALID_PARAMETER);
  548. DebugPrintEx(DEBUG_ERR, _T("Some Params are NULL."));
  549. return FALSE;
  550. }
  551. *RoutingInfoBuffer = NULL;
  552. *MethodsReturned = 0;
  553. __try
  554. {
  555. ec = FAX_EnumRoutingMethods(
  556. FH_PORT_HANDLE(FaxPortHandle),
  557. (LPBYTE*)RoutingInfoBuffer,
  558. &RoutingInfoBufferSize,
  559. MethodsReturned
  560. );
  561. }
  562. __except (EXCEPTION_EXECUTE_HANDLER)
  563. {
  564. //
  565. // For some reason we crashed.
  566. //
  567. ec = GetExceptionCode();
  568. DebugPrintEx(
  569. DEBUG_ERR,
  570. TEXT("Exception on RPC call to FAX_EnumRoutingMethods. (ec: %ld)"),
  571. ec);
  572. }
  573. if (ec)
  574. {
  575. DumpRPCExtendedStatus ();
  576. SetLastError( ec );
  577. return FALSE;
  578. }
  579. FaxRoutingMethod = (PFAX_ROUTING_METHODW) *RoutingInfoBuffer;
  580. for (i=0; i<*MethodsReturned; i++) {
  581. FixupStringPtrW( RoutingInfoBuffer, FaxRoutingMethod[i].DeviceName );
  582. FixupStringPtrW( RoutingInfoBuffer, FaxRoutingMethod[i].Guid );
  583. FixupStringPtrW( RoutingInfoBuffer, FaxRoutingMethod[i].FunctionName );
  584. FixupStringPtrW( RoutingInfoBuffer, FaxRoutingMethod[i].FriendlyName );
  585. FixupStringPtrW( RoutingInfoBuffer, FaxRoutingMethod[i].ExtensionImageName );
  586. FixupStringPtrW( RoutingInfoBuffer, FaxRoutingMethod[i].ExtensionFriendlyName );
  587. }
  588. return TRUE;
  589. }
  590. BOOL
  591. WINAPI
  592. FaxEnumRoutingMethodsA(
  593. IN HANDLE FaxPortHandle,
  594. OUT PFAX_ROUTING_METHODA *RoutingInfoBuffer,
  595. OUT LPDWORD MethodsReturned
  596. )
  597. {
  598. PFAX_ROUTING_METHODW FaxRoutingMethod = NULL;
  599. DWORD i;
  600. DEBUG_FUNCTION_NAME(TEXT("FaxEnumRoutingMethodsA"));
  601. if (!FaxEnumRoutingMethodsW(
  602. FaxPortHandle,
  603. (PFAX_ROUTING_METHODW *)RoutingInfoBuffer,
  604. MethodsReturned
  605. ))
  606. {
  607. return FALSE;
  608. }
  609. FaxRoutingMethod = (PFAX_ROUTING_METHODW) *RoutingInfoBuffer;
  610. for (i=0; i<*MethodsReturned; i++)
  611. {
  612. if (!ConvertUnicodeStringInPlace( (LPWSTR)FaxRoutingMethod[i].DeviceName ) ||
  613. !ConvertUnicodeStringInPlace( (LPWSTR)FaxRoutingMethod[i].Guid ) ||
  614. !ConvertUnicodeStringInPlace( (LPWSTR)FaxRoutingMethod[i].FunctionName ) ||
  615. !ConvertUnicodeStringInPlace( (LPWSTR)FaxRoutingMethod[i].FriendlyName ) ||
  616. !ConvertUnicodeStringInPlace( (LPWSTR)FaxRoutingMethod[i].ExtensionImageName ) ||
  617. !ConvertUnicodeStringInPlace( (LPWSTR)FaxRoutingMethod[i].ExtensionFriendlyName ))
  618. {
  619. DebugPrintEx(DEBUG_ERR, _T("ConvertUnicodeStringInPlace failed, ec = %ld."), GetLastError());
  620. MemFree (FaxRoutingMethod);
  621. return FALSE;
  622. }
  623. }
  624. return TRUE;
  625. } // FaxEnumRoutingMethodsA
  626. BOOL
  627. WINAPI
  628. FaxEnableRoutingMethodW(
  629. IN HANDLE FaxPortHandle,
  630. IN LPCWSTR RoutingGuid,
  631. IN BOOL Enabled
  632. )
  633. {
  634. error_status_t ec;
  635. DEBUG_FUNCTION_NAME(TEXT("FaxEnableRoutingMethodW"));
  636. if (!ValidateFaxHandle(FaxPortHandle, FHT_PORT)) {
  637. SetLastError(ERROR_INVALID_HANDLE);
  638. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  639. return FALSE;
  640. }
  641. if (!RoutingGuid) {
  642. SetLastError(ERROR_INVALID_PARAMETER);
  643. DebugPrintEx(DEBUG_ERR, _T("RoutingGuid is NULL."));
  644. return FALSE;
  645. }
  646. __try
  647. {
  648. ec = FAX_EnableRoutingMethod( FH_PORT_HANDLE(FaxPortHandle), (LPWSTR)RoutingGuid, Enabled);
  649. }
  650. __except (EXCEPTION_EXECUTE_HANDLER)
  651. {
  652. //
  653. // For some reason we crashed.
  654. //
  655. ec = GetExceptionCode();
  656. DebugPrintEx(
  657. DEBUG_ERR,
  658. TEXT("Exception on RPC call to FAX_EnableRoutingMethod. (ec: %ld)"),
  659. ec);
  660. }
  661. if (ec)
  662. {
  663. DumpRPCExtendedStatus ();
  664. SetLastError( ec );
  665. return FALSE;
  666. }
  667. return TRUE;
  668. }
  669. BOOL
  670. WINAPI
  671. FaxEnableRoutingMethodA(
  672. IN HANDLE FaxPortHandle,
  673. IN LPCSTR RoutingGuid,
  674. IN BOOL Enabled
  675. )
  676. {
  677. BOOL Rval;
  678. LPWSTR RoutingGuidW = AnsiStringToUnicodeString( RoutingGuid );
  679. if (!RoutingGuidW) {
  680. SetLastError( ERROR_INVALID_PARAMETER );
  681. return FALSE;
  682. }
  683. Rval = FaxEnableRoutingMethodW( FaxPortHandle, RoutingGuidW, Enabled );
  684. MemFree( RoutingGuidW );
  685. return Rval;
  686. }
  687. BOOL
  688. WINAPI
  689. FaxGetRoutingInfoW(
  690. IN const HANDLE FaxPortHandle,
  691. IN LPCWSTR RoutingGuid,
  692. OUT LPBYTE *RoutingInfoBuffer,
  693. OUT LPDWORD RoutingInfoBufferSize
  694. )
  695. {
  696. error_status_t ec;
  697. DEBUG_FUNCTION_NAME(TEXT("FaxGetRoutingInfoW"));
  698. if (!ValidateFaxHandle(FaxPortHandle, FHT_PORT)) {
  699. SetLastError(ERROR_INVALID_HANDLE);
  700. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  701. return FALSE;
  702. }
  703. if (!RoutingGuid || !RoutingInfoBuffer || !RoutingInfoBufferSize) {
  704. SetLastError(ERROR_INVALID_PARAMETER);
  705. DebugPrintEx(DEBUG_ERR, _T("Some Params are NULL."));
  706. return FALSE;
  707. }
  708. *RoutingInfoBuffer = NULL;
  709. *RoutingInfoBufferSize = 0;
  710. __try
  711. {
  712. ec = FAX_GetRoutingInfo(
  713. FH_PORT_HANDLE(FaxPortHandle),
  714. (LPWSTR)RoutingGuid,
  715. RoutingInfoBuffer,
  716. RoutingInfoBufferSize
  717. );
  718. }
  719. __except (EXCEPTION_EXECUTE_HANDLER)
  720. {
  721. //
  722. // For some reason we crashed.
  723. //
  724. ec = GetExceptionCode();
  725. DebugPrintEx(
  726. DEBUG_ERR,
  727. TEXT("Exception on RPC call to FAX_GetRoutingInfo. (ec: %ld)"),
  728. ec);
  729. }
  730. if (ec)
  731. {
  732. DumpRPCExtendedStatus ();
  733. SetLastError( ec );
  734. return FALSE;
  735. }
  736. return TRUE;
  737. }
  738. BOOL
  739. WINAPI
  740. FaxGetRoutingInfoA(
  741. IN HANDLE FaxPortHandle,
  742. IN LPCSTR RoutingGuid,
  743. OUT LPBYTE *RoutingInfoBuffer,
  744. OUT LPDWORD RoutingInfoBufferSize
  745. )
  746. {
  747. BOOL Rval;
  748. LPWSTR RoutingGuidW = AnsiStringToUnicodeString( RoutingGuid );
  749. if (!RoutingGuidW) {
  750. SetLastError( ERROR_INVALID_PARAMETER );
  751. return FALSE;
  752. }
  753. Rval = FaxGetRoutingInfoW(
  754. FaxPortHandle,
  755. RoutingGuidW,
  756. RoutingInfoBuffer,
  757. RoutingInfoBufferSize
  758. );
  759. MemFree( RoutingGuidW );
  760. return Rval;
  761. }
  762. BOOL
  763. WINAPI
  764. FaxSetRoutingInfoW(
  765. IN HANDLE FaxPortHandle,
  766. IN LPCWSTR RoutingGuid,
  767. IN const BYTE *RoutingInfoBuffer,
  768. IN DWORD RoutingInfoBufferSize
  769. )
  770. {
  771. error_status_t ec;
  772. DEBUG_FUNCTION_NAME(TEXT("FaxSetRoutingInfoW"));
  773. if (!ValidateFaxHandle(FaxPortHandle, FHT_PORT)) {
  774. SetLastError(ERROR_INVALID_HANDLE);
  775. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  776. return FALSE;
  777. }
  778. if (!RoutingGuid || !RoutingInfoBuffer || !RoutingInfoBufferSize) {
  779. SetLastError(ERROR_INVALID_PARAMETER);
  780. DebugPrintEx(DEBUG_ERR, _T("Some Params are NULL."));
  781. return FALSE;
  782. }
  783. __try
  784. {
  785. ec = FAX_SetRoutingInfo(
  786. FH_PORT_HANDLE(FaxPortHandle),
  787. (LPWSTR)RoutingGuid,
  788. RoutingInfoBuffer,
  789. RoutingInfoBufferSize
  790. );
  791. }
  792. __except (EXCEPTION_EXECUTE_HANDLER)
  793. {
  794. //
  795. // For some reason we crashed.
  796. //
  797. ec = GetExceptionCode();
  798. DebugPrintEx(
  799. DEBUG_ERR,
  800. TEXT("Exception on RPC call to FAX_SetRoutingInfo. (ec: %ld)"),
  801. ec);
  802. }
  803. if (ec)
  804. {
  805. DumpRPCExtendedStatus ();
  806. SetLastError( ec );
  807. return FALSE;
  808. }
  809. return TRUE;
  810. }
  811. BOOL
  812. WINAPI
  813. FaxSetRoutingInfoA(
  814. IN HANDLE FaxPortHandle,
  815. IN LPCSTR RoutingGuid,
  816. IN const BYTE *RoutingInfoBuffer,
  817. IN DWORD RoutingInfoBufferSize
  818. )
  819. {
  820. BOOL Rval;
  821. LPWSTR RoutingGuidW = AnsiStringToUnicodeString( RoutingGuid );
  822. if (!RoutingGuidW) {
  823. SetLastError( ERROR_INVALID_PARAMETER );
  824. return FALSE;
  825. }
  826. Rval = FaxSetRoutingInfoW(
  827. FaxPortHandle,
  828. RoutingGuidW,
  829. RoutingInfoBuffer,
  830. RoutingInfoBufferSize
  831. );
  832. MemFree( RoutingGuidW );
  833. return Rval;
  834. }
  835. BOOL
  836. WINAPI
  837. FaxEnumerateProvidersA (
  838. IN HANDLE hFaxHandle,
  839. OUT PFAX_DEVICE_PROVIDER_INFOA *ppProviders,
  840. OUT LPDWORD lpdwNumProviders
  841. )
  842. /*++
  843. Routine name : FaxEnumerateProvidersA
  844. Routine description:
  845. Enumerates FSPs - ANSI version
  846. Author:
  847. Eran Yariv (EranY), Nov, 1999
  848. Arguments:
  849. hFaxHandle [in ] - Handle to fax server
  850. ppProviders [out] - Pointer to buffer to return array of providers.
  851. lpdwNumProviders [out] - Number of providers returned in the array.
  852. Return Value:
  853. TRUE - Success
  854. FALSE - Failure, call GetLastError() for more error information.
  855. --*/
  856. {
  857. PFAX_DEVICE_PROVIDER_INFOW pUnicodeProviders;
  858. DWORD dwNumProviders;
  859. DWORD dwCur;
  860. DEBUG_FUNCTION_NAME(TEXT("FaxEnumerateProvidersA"));
  861. if (!ppProviders || !lpdwNumProviders)
  862. {
  863. SetLastError(ERROR_INVALID_PARAMETER);
  864. DebugPrintEx(DEBUG_ERR, _T("Some Params are NULL."));
  865. return FALSE;
  866. }
  867. //
  868. // Call the UNICODE version first
  869. //
  870. if (!FaxEnumerateProvidersW (hFaxHandle, &pUnicodeProviders, &dwNumProviders))
  871. {
  872. return FALSE;
  873. }
  874. //
  875. // Convert returned value back into ANSI.
  876. // We keep the UNICODE structures and do a UNICODE to ANSI convert in place.
  877. //
  878. *lpdwNumProviders = dwNumProviders;
  879. *ppProviders = (PFAX_DEVICE_PROVIDER_INFOA) pUnicodeProviders;
  880. for (dwCur = 0; dwCur < dwNumProviders; dwCur++)
  881. {
  882. if (!ConvertUnicodeStringInPlace( pUnicodeProviders[dwCur].lpctstrFriendlyName ) ||
  883. !ConvertUnicodeStringInPlace( pUnicodeProviders[dwCur].lpctstrImageName ) ||
  884. !ConvertUnicodeStringInPlace( pUnicodeProviders[dwCur].lpctstrProviderName ) ||
  885. !ConvertUnicodeStringInPlace( pUnicodeProviders[dwCur].lpctstrGUID ))
  886. {
  887. DebugPrintEx(DEBUG_ERR, _T("ConvertUnicodeStringInPlace failed, ec = %ld."), GetLastError());
  888. MemFree (pUnicodeProviders);
  889. return FALSE;
  890. }
  891. }
  892. return TRUE;
  893. } // FaxEnumerateProvidersA
  894. BOOL
  895. WINAPI
  896. FaxEnumerateProvidersW (
  897. IN HANDLE hFaxHandle,
  898. OUT PFAX_DEVICE_PROVIDER_INFOW *ppProviders,
  899. OUT LPDWORD lpdwNumProviders
  900. )
  901. /*++
  902. Routine name : FaxEnumerateProvidersW
  903. Routine description:
  904. Enumerates FSPs - UNICODE version
  905. Author:
  906. Eran Yariv (EranY), Nov, 1999
  907. Arguments:
  908. hFaxHandle [in ] - Handle to fax server
  909. ppProviders [out] - Pointer to buffer to return array of providers.
  910. lpdwNumProviders [out] - Number of providers returned in the array.
  911. Return Value:
  912. TRUE - Success
  913. FALSE - Failure, call GetLastError() for more error information.
  914. --*/
  915. {
  916. DWORD ec = ERROR_SUCCESS;
  917. DWORD dwConfigSize;
  918. DWORD dwCur;
  919. DEBUG_FUNCTION_NAME(TEXT("FaxEnumerateProvidersW"));
  920. if (!ppProviders || !lpdwNumProviders)
  921. {
  922. SetLastError(ERROR_INVALID_PARAMETER);
  923. DebugPrintEx(DEBUG_ERR, _T("Some Params are NULL."));
  924. return FALSE;
  925. }
  926. if (!ValidateFaxHandle(hFaxHandle,FHT_SERVICE))
  927. {
  928. SetLastError(ERROR_INVALID_HANDLE);
  929. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  930. return FALSE;
  931. }
  932. *ppProviders = NULL;
  933. //
  934. // Call the RPC function
  935. //
  936. __try
  937. {
  938. ec = FAX_EnumerateProviders(
  939. FH_FAX_HANDLE(hFaxHandle),
  940. (LPBYTE*)ppProviders,
  941. &dwConfigSize,
  942. lpdwNumProviders
  943. );
  944. }
  945. __except (EXCEPTION_EXECUTE_HANDLER)
  946. {
  947. //
  948. // For some reason we got an exception.
  949. //
  950. ec = GetExceptionCode();
  951. DebugPrintEx(
  952. DEBUG_ERR,
  953. TEXT("Exception on RPC call to FAX_EnumerateProviders. (ec: %ld)"),
  954. ec);
  955. }
  956. if (ERROR_SUCCESS != ec)
  957. {
  958. DumpRPCExtendedStatus ();
  959. SetLastError(ec);
  960. return FALSE;
  961. }
  962. for (dwCur = 0; dwCur < (*lpdwNumProviders); dwCur++)
  963. {
  964. FixupStringPtrW( ppProviders, (*ppProviders)[dwCur].lpctstrFriendlyName );
  965. FixupStringPtrW( ppProviders, (*ppProviders)[dwCur].lpctstrImageName );
  966. FixupStringPtrW( ppProviders, (*ppProviders)[dwCur].lpctstrProviderName );
  967. FixupStringPtrW( ppProviders, (*ppProviders)[dwCur].lpctstrGUID );
  968. }
  969. return TRUE;
  970. } // FaxEnumerateProvidersW
  971. #ifndef UNICODE
  972. BOOL
  973. WINAPI
  974. FaxEnumerateProvidersX (
  975. IN HANDLE hFaxHandle,
  976. OUT PFAX_DEVICE_PROVIDER_INFOW *ppProviders,
  977. OUT LPDWORD lpdwNumProviders
  978. )
  979. {
  980. UNREFERENCED_PARAMETER (hFaxHandle);
  981. UNREFERENCED_PARAMETER (ppProviders);
  982. UNREFERENCED_PARAMETER (lpdwNumProviders);
  983. SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
  984. return FALSE;
  985. } // FaxEnumerateProvidersX
  986. #endif // #ifndef UNICODE
  987. //********************************************
  988. //* Extended ports
  989. //********************************************
  990. BOOL
  991. WINAPI
  992. FaxGetPortExA (
  993. IN HANDLE hFaxHandle,
  994. IN DWORD dwDeviceId,
  995. OUT PFAX_PORT_INFO_EXA *ppPortInfo
  996. )
  997. /*++
  998. Routine name : FaxGetPortExA
  999. Routine description:
  1000. Gets port (device) information - ANSI version
  1001. Author:
  1002. Eran Yariv (EranY), Nov, 1999
  1003. Arguments:
  1004. hFaxHandle [in ] - Fax server RPC handle
  1005. dwDeviceId [in ] - Unique device id
  1006. ppPortInfo [out] - Port information
  1007. Return Value:
  1008. TRUE - Success
  1009. FALSE - Failure, call GetLastError() for more error information.
  1010. --*/
  1011. {
  1012. PFAX_PORT_INFO_EXW pUnicodePort;
  1013. DEBUG_FUNCTION_NAME(TEXT("FaxGetPortExA"));
  1014. if (!ppPortInfo)
  1015. {
  1016. SetLastError(ERROR_INVALID_PARAMETER);
  1017. DebugPrintEx(DEBUG_ERR, _T("ppPortInfo is NULL."));
  1018. return FALSE;
  1019. }
  1020. //
  1021. // Call the UNICODE version first
  1022. //
  1023. if (!FaxGetPortExW (hFaxHandle, dwDeviceId, &pUnicodePort))
  1024. {
  1025. return FALSE;
  1026. }
  1027. //
  1028. // Convert returned value back into ANSI.
  1029. // We keep the UNICODE structures and do a UNICODE to ANSI convert in place.
  1030. //
  1031. *ppPortInfo = (PFAX_PORT_INFO_EXA) pUnicodePort;
  1032. if (!ConvertUnicodeStringInPlace( pUnicodePort->lpctstrDeviceName ) ||
  1033. !ConvertUnicodeStringInPlace( pUnicodePort->lptstrDescription ) ||
  1034. !ConvertUnicodeStringInPlace( pUnicodePort->lpctstrProviderName ) ||
  1035. !ConvertUnicodeStringInPlace( pUnicodePort->lpctstrProviderGUID ) ||
  1036. !ConvertUnicodeStringInPlace( pUnicodePort->lptstrCsid ) ||
  1037. !ConvertUnicodeStringInPlace( pUnicodePort->lptstrTsid ))
  1038. {
  1039. DebugPrintEx(DEBUG_ERR, _T("ConvertUnicodeStringInPlace failed, ec = %ld."), GetLastError());
  1040. MemFree (pUnicodePort);
  1041. return FALSE;
  1042. }
  1043. (*ppPortInfo)->dwSizeOfStruct = sizeof(FAX_PORT_INFO_EXA);
  1044. return TRUE;
  1045. } // FaxGetPortExA
  1046. BOOL
  1047. WINAPI
  1048. FaxGetPortExW (
  1049. IN HANDLE hFaxHandle,
  1050. IN DWORD dwDeviceId,
  1051. OUT PFAX_PORT_INFO_EXW *ppPortInfo
  1052. )
  1053. /*++
  1054. Routine name : FaxGetPortExW
  1055. Routine description:
  1056. Gets port (device) information - UNICODE version
  1057. Author:
  1058. Eran Yariv (EranY), Nov, 1999
  1059. Arguments:
  1060. hFaxHandle [in ] - Fax server RPC handle
  1061. dwDeviceId [in ] - Unique device id
  1062. ppPortInfo [out] - Port information
  1063. Return Value:
  1064. TRUE - Success
  1065. FALSE - Failure, call GetLastError() for more error information.
  1066. --*/
  1067. {
  1068. DWORD ec = ERROR_SUCCESS;
  1069. DWORD dwConfigSize;
  1070. DEBUG_FUNCTION_NAME(TEXT("FaxGetPortExW"));
  1071. if (!ppPortInfo || !dwDeviceId)
  1072. {
  1073. SetLastError(ERROR_INVALID_PARAMETER);
  1074. DebugPrintEx(DEBUG_ERR, _T("Some Params are NULL."));
  1075. return FALSE;
  1076. }
  1077. if (!ValidateFaxHandle(hFaxHandle,FHT_SERVICE))
  1078. {
  1079. SetLastError(ERROR_INVALID_HANDLE);
  1080. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  1081. return FALSE;
  1082. }
  1083. *ppPortInfo = NULL;
  1084. //
  1085. // Call the RPC function
  1086. //
  1087. __try
  1088. {
  1089. ec = FAX_GetPortEx(
  1090. FH_FAX_HANDLE(hFaxHandle),
  1091. dwDeviceId,
  1092. (LPBYTE*)ppPortInfo,
  1093. &dwConfigSize
  1094. );
  1095. }
  1096. __except (EXCEPTION_EXECUTE_HANDLER)
  1097. {
  1098. //
  1099. // For some reason we got an exception.
  1100. //
  1101. ec = GetExceptionCode();
  1102. DebugPrintEx(
  1103. DEBUG_ERR,
  1104. TEXT("Exception on RPC call to FAX_GetPortEx. (ec: %ld)"),
  1105. ec);
  1106. }
  1107. if (ERROR_SUCCESS != ec)
  1108. {
  1109. DumpRPCExtendedStatus ();
  1110. SetLastError(ec);
  1111. return FALSE;
  1112. }
  1113. FixupStringPtrW( ppPortInfo, (*ppPortInfo)->lpctstrDeviceName );
  1114. FixupStringPtrW( ppPortInfo, (*ppPortInfo)->lptstrDescription );
  1115. FixupStringPtrW( ppPortInfo, (*ppPortInfo)->lpctstrProviderName );
  1116. FixupStringPtrW( ppPortInfo, (*ppPortInfo)->lpctstrProviderGUID );
  1117. FixupStringPtrW( ppPortInfo, (*ppPortInfo)->lptstrCsid );
  1118. FixupStringPtrW( ppPortInfo, (*ppPortInfo)->lptstrTsid );
  1119. return TRUE;
  1120. } // FaxGetPortExW
  1121. #ifndef UNICODE
  1122. BOOL
  1123. WINAPI
  1124. FaxGetPortExX (
  1125. IN HANDLE hFaxHandle,
  1126. IN DWORD dwDeviceId,
  1127. OUT PFAX_PORT_INFO_EXW *ppPortInfo
  1128. )
  1129. {
  1130. UNREFERENCED_PARAMETER (hFaxHandle);
  1131. UNREFERENCED_PARAMETER (dwDeviceId);
  1132. UNREFERENCED_PARAMETER (ppPortInfo);
  1133. SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
  1134. return FALSE;
  1135. } // FaxGetPortExX
  1136. #endif // #ifndef UNICODE
  1137. BOOL
  1138. WINAPI
  1139. FaxSetPortExA (
  1140. IN HANDLE hFaxHandle,
  1141. IN DWORD dwDeviceId,
  1142. IN PFAX_PORT_INFO_EXA pPortInfo
  1143. )
  1144. /*++
  1145. Routine name : FaxSetPortExA
  1146. Routine description:
  1147. Sets port (device) information - ANSI version
  1148. Author:
  1149. Eran Yariv (EranY), Nov, 1999
  1150. Arguments:
  1151. hFaxHandle [in] - Fax server RPC handle
  1152. dwDeviceId [in] - Unique device id
  1153. pPortInfo [in] - New port information
  1154. Return Value:
  1155. TRUE - Success
  1156. FALSE - Failure, call GetLastError() for more error information.
  1157. --*/
  1158. {
  1159. FAX_PORT_INFO_EXW PortW;
  1160. BOOL bRes = FALSE;
  1161. DEBUG_FUNCTION_NAME(TEXT("FaxSetPortExA"));
  1162. //
  1163. // Validate Parameters
  1164. //
  1165. if (!ValidateFaxHandle(hFaxHandle, FHT_SERVICE))
  1166. {
  1167. SetLastError(ERROR_INVALID_HANDLE);
  1168. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  1169. return FALSE;
  1170. }
  1171. if (!pPortInfo || !dwDeviceId)
  1172. {
  1173. SetLastError(ERROR_INVALID_PARAMETER);
  1174. DebugPrintEx(DEBUG_ERR, _T("Some Params are NULL."));
  1175. return FALSE;
  1176. }
  1177. if (sizeof(FAX_PORT_INFO_EXA) != pPortInfo->dwSizeOfStruct)
  1178. {
  1179. SetLastError(ERROR_INVALID_PARAMETER);
  1180. DebugPrintEx(DEBUG_ERR, _T("(sizeof(FAX_PORT_INFO_EXA) != pPortInfo->dwSizeOfStruct)."));
  1181. return FALSE;
  1182. }
  1183. //
  1184. // Create a UNICODE structure and pass along to UNICODE function
  1185. // Ansi structure is same size as unicode structure, so we can just copy it, then
  1186. // cast the string pointers correctly
  1187. //
  1188. CopyMemory(&PortW, pPortInfo, sizeof(FAX_PORT_INFO_EXA));
  1189. //
  1190. // We're only setting the strings that get set in the service
  1191. //
  1192. PortW.lptstrCsid = NULL;
  1193. PortW.lptstrDescription = NULL;
  1194. PortW.lptstrTsid = NULL;
  1195. PortW.lpctstrDeviceName = NULL;
  1196. PortW.lpctstrProviderName = NULL;
  1197. PortW.lpctstrProviderGUID = NULL;
  1198. PortW.dwSizeOfStruct = sizeof (FAX_PORT_INFO_EXW);
  1199. if (pPortInfo->lptstrCsid)
  1200. {
  1201. if (NULL ==
  1202. (PortW.lptstrCsid = AnsiStringToUnicodeString(pPortInfo->lptstrCsid))
  1203. )
  1204. {
  1205. goto exit;
  1206. }
  1207. }
  1208. if (pPortInfo->lptstrDescription)
  1209. {
  1210. if (NULL ==
  1211. (PortW.lptstrDescription = AnsiStringToUnicodeString(pPortInfo->lptstrDescription))
  1212. )
  1213. {
  1214. goto exit;
  1215. }
  1216. }
  1217. if (pPortInfo->lptstrTsid)
  1218. {
  1219. if (NULL ==
  1220. (PortW.lptstrTsid = AnsiStringToUnicodeString(pPortInfo->lptstrTsid))
  1221. )
  1222. {
  1223. goto exit;
  1224. }
  1225. }
  1226. bRes = FaxSetPortExW (hFaxHandle, dwDeviceId, &PortW);
  1227. exit:
  1228. MemFree((PVOID)PortW.lptstrCsid);
  1229. MemFree((PVOID)PortW.lptstrDescription);
  1230. MemFree((PVOID)PortW.lptstrTsid);
  1231. return bRes;
  1232. } // FaxSetPortExA
  1233. BOOL
  1234. WINAPI
  1235. FaxSetPortExW (
  1236. IN HANDLE hFaxHandle,
  1237. IN DWORD dwDeviceId,
  1238. IN PFAX_PORT_INFO_EXW pPortInfo
  1239. )
  1240. /*++
  1241. Routine name : FaxSetPortExW
  1242. Routine description:
  1243. Sets port (device) information - UNICODE version
  1244. Author:
  1245. Eran Yariv (EranY), Nov, 1999
  1246. Arguments:
  1247. hFaxHandle [in] - Fax server RPC handle
  1248. dwDeviceId [in] - Unique device id
  1249. pPortInfo [in] - New port information
  1250. Return Value:
  1251. TRUE - Success
  1252. FALSE - Failure, call GetLastError() for more error information.
  1253. --*/
  1254. {
  1255. error_status_t ec;
  1256. DEBUG_FUNCTION_NAME(TEXT("FaxSetPortExW"));
  1257. //
  1258. // Validate Parameters
  1259. //
  1260. if (!ValidateFaxHandle(hFaxHandle, FHT_SERVICE))
  1261. {
  1262. SetLastError(ERROR_INVALID_HANDLE);
  1263. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  1264. return FALSE;
  1265. }
  1266. if (!dwDeviceId || !pPortInfo)
  1267. {
  1268. SetLastError(ERROR_INVALID_PARAMETER);
  1269. DebugPrintEx(DEBUG_ERR, _T("Some Params are NULL."));
  1270. return FALSE;
  1271. }
  1272. if (sizeof (FAX_PORT_INFO_EXW) != pPortInfo->dwSizeOfStruct)
  1273. {
  1274. SetLastError(ERROR_INVALID_PARAMETER);
  1275. return FALSE;
  1276. }
  1277. __try
  1278. {
  1279. ec = FAX_SetPortEx(
  1280. FH_FAX_HANDLE(hFaxHandle),
  1281. dwDeviceId,
  1282. pPortInfo );
  1283. }
  1284. __except (EXCEPTION_EXECUTE_HANDLER)
  1285. {
  1286. //
  1287. // For some reason we got an exception.
  1288. //
  1289. ec = GetExceptionCode();
  1290. DebugPrintEx(
  1291. DEBUG_ERR,
  1292. TEXT("Exception on RPC call to FAX_SetPortEx. (ec: %ld)"),
  1293. ec);
  1294. }
  1295. if (ERROR_SUCCESS != ec)
  1296. {
  1297. DumpRPCExtendedStatus ();
  1298. SetLastError(ec);
  1299. return FALSE;
  1300. }
  1301. return TRUE;
  1302. } // FaxSetPortExW
  1303. #ifndef UNICODE
  1304. BOOL
  1305. WINAPI
  1306. FaxSetPortExX (
  1307. IN HANDLE hFaxHandle,
  1308. IN DWORD dwDeviceId,
  1309. IN PFAX_PORT_INFO_EXW pPortInfo
  1310. )
  1311. {
  1312. UNREFERENCED_PARAMETER (hFaxHandle);
  1313. UNREFERENCED_PARAMETER (dwDeviceId);
  1314. UNREFERENCED_PARAMETER (pPortInfo);
  1315. SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
  1316. return FALSE;
  1317. } // FaxSetPortExX
  1318. #endif // #ifndef UNICODE
  1319. BOOL
  1320. WINAPI
  1321. FaxEnumPortsExA (
  1322. IN HANDLE hFaxHandle,
  1323. OUT PFAX_PORT_INFO_EXA *ppPorts,
  1324. OUT LPDWORD lpdwNumPorts
  1325. )
  1326. /*++
  1327. Routine name : FaxEnumPortsExA
  1328. Routine description:
  1329. Eumerate all the devices (ports) on the server - ANSI version
  1330. Author:
  1331. Eran Yariv (EranY), Nov, 1999
  1332. Arguments:
  1333. hFaxHandle [in ] - Fax server RPC handle
  1334. ppPorts [out] - Array of port information
  1335. lpdwNumPorts [out] - Size of the returned array
  1336. Return Value:
  1337. TRUE - Success
  1338. FALSE - Failure, call GetLastError() for more error information.
  1339. --*/
  1340. {
  1341. PFAX_PORT_INFO_EXW pUnicodePorts;
  1342. DWORD dwNumPorts;
  1343. DWORD dwCur;
  1344. DEBUG_FUNCTION_NAME(TEXT("FaxEnumPortsExA"));
  1345. if (!ppPorts || !lpdwNumPorts)
  1346. {
  1347. SetLastError(ERROR_INVALID_PARAMETER);
  1348. DebugPrintEx(DEBUG_ERR, _T("Some Params are NULL."));
  1349. return FALSE;
  1350. }
  1351. //
  1352. // Call the UNICODE version first
  1353. //
  1354. if (!FaxEnumPortsExW (hFaxHandle, &pUnicodePorts, &dwNumPorts))
  1355. {
  1356. DebugPrintEx(DEBUG_ERR, _T("FaxEnumPortsExW() is failed. ec = %ld."), GetLastError());
  1357. return FALSE;
  1358. }
  1359. //
  1360. // Convert returned value back into ANSI.
  1361. // We keep the UNICODE structures and do a UNICODE to ANSI convert in place.
  1362. //
  1363. *lpdwNumPorts = dwNumPorts;
  1364. *ppPorts = (PFAX_PORT_INFO_EXA) pUnicodePorts;
  1365. for (dwCur = 0; dwCur < dwNumPorts; dwCur++)
  1366. {
  1367. if (!ConvertUnicodeStringInPlace( pUnicodePorts[dwCur].lpctstrDeviceName ) ||
  1368. !ConvertUnicodeStringInPlace( pUnicodePorts[dwCur].lpctstrProviderGUID ) ||
  1369. !ConvertUnicodeStringInPlace( pUnicodePorts[dwCur].lpctstrProviderName ) ||
  1370. !ConvertUnicodeStringInPlace( pUnicodePorts[dwCur].lptstrCsid ) ||
  1371. !ConvertUnicodeStringInPlace( pUnicodePorts[dwCur].lptstrDescription ) ||
  1372. !ConvertUnicodeStringInPlace( pUnicodePorts[dwCur].lptstrTsid ))
  1373. {
  1374. DebugPrintEx(DEBUG_ERR, _T("ConvertUnicodeStringInPlace failed, ec = %ld."), GetLastError());
  1375. MemFree (pUnicodePorts);
  1376. return FALSE;
  1377. }
  1378. }
  1379. return TRUE;
  1380. } // FaxEnumPortsExA
  1381. BOOL
  1382. WINAPI
  1383. FaxEnumPortsExW (
  1384. IN HANDLE hFaxHandle,
  1385. OUT PFAX_PORT_INFO_EXW *ppPorts,
  1386. OUT LPDWORD lpdwNumPorts
  1387. )
  1388. /*++
  1389. Routine name : FaxEnumPortsExW
  1390. Routine description:
  1391. Eumerate all the devices (ports) on the server - UNICODE version
  1392. Author:
  1393. Eran Yariv (EranY), Nov, 1999
  1394. Arguments:
  1395. hFaxHandle [in ] - Fax server RPC handle
  1396. ppPorts [out] - Array of port information
  1397. lpdwNumPorts [out] - Size of the returned array
  1398. Return Value:
  1399. TRUE - Success
  1400. FALSE - Failure, call GetLastError() for more error information.
  1401. --*/
  1402. {
  1403. DWORD ec = ERROR_SUCCESS;
  1404. DWORD dwConfigSize;
  1405. DWORD dwCur;
  1406. DEBUG_FUNCTION_NAME(TEXT("FaxEnumPortsExW"));
  1407. if (!ppPorts || !lpdwNumPorts)
  1408. {
  1409. SetLastError(ERROR_INVALID_PARAMETER);
  1410. DebugPrintEx(DEBUG_ERR, _T("Some Params are NULL."));
  1411. return FALSE;
  1412. }
  1413. if (!ValidateFaxHandle(hFaxHandle, FHT_SERVICE))
  1414. {
  1415. SetLastError(ERROR_INVALID_HANDLE);
  1416. DebugPrintEx(DEBUG_ERR, _T("ValidateFaxHandle() is failed."));
  1417. return FALSE;
  1418. }
  1419. *ppPorts = NULL;
  1420. //
  1421. // Call the RPC function
  1422. //
  1423. __try
  1424. {
  1425. ec = FAX_EnumPortsEx(
  1426. FH_FAX_HANDLE(hFaxHandle),
  1427. (LPBYTE*)ppPorts,
  1428. &dwConfigSize,
  1429. lpdwNumPorts
  1430. );
  1431. }
  1432. __except (EXCEPTION_EXECUTE_HANDLER)
  1433. {
  1434. //
  1435. // For some reason we got an exception.
  1436. //
  1437. ec = GetExceptionCode();
  1438. DebugPrintEx(
  1439. DEBUG_ERR,
  1440. TEXT("Exception on RPC call to FAX_EnumPortsEx. (ec: %ld)"),
  1441. ec);
  1442. }
  1443. if (ERROR_SUCCESS != ec)
  1444. {
  1445. DumpRPCExtendedStatus ();
  1446. SetLastError(ec);
  1447. return FALSE;
  1448. }
  1449. for (dwCur = 0; dwCur < (*lpdwNumPorts); dwCur++)
  1450. {
  1451. FixupStringPtrW( ppPorts, (*ppPorts)[dwCur].lpctstrDeviceName );
  1452. FixupStringPtrW( ppPorts, (*ppPorts)[dwCur].lpctstrProviderGUID );
  1453. FixupStringPtrW( ppPorts, (*ppPorts)[dwCur].lpctstrProviderName );
  1454. FixupStringPtrW( ppPorts, (*ppPorts)[dwCur].lptstrCsid );
  1455. FixupStringPtrW( ppPorts, (*ppPorts)[dwCur].lptstrDescription );
  1456. FixupStringPtrW( ppPorts, (*ppPorts)[dwCur].lptstrTsid );
  1457. }
  1458. return TRUE;
  1459. } // FaxEnumPortsExW
  1460. #ifndef UNICODE
  1461. BOOL
  1462. WINAPI
  1463. FaxEnumPortsExX (
  1464. IN HANDLE hFaxHandle,
  1465. OUT PFAX_PORT_INFO_EXW *ppPorts,
  1466. OUT LPDWORD lpdwNumPorts
  1467. )
  1468. {
  1469. UNREFERENCED_PARAMETER (hFaxHandle);
  1470. UNREFERENCED_PARAMETER (ppPorts);
  1471. UNREFERENCED_PARAMETER (lpdwNumPorts);
  1472. SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
  1473. return FALSE;
  1474. } // FaxEnumPortsExX
  1475. #endif // #ifndef UNICODE
  1476. //********************************************
  1477. //* Extension data
  1478. //********************************************
  1479. BOOL
  1480. WINAPI
  1481. FaxGetExtensionDataA (
  1482. IN HANDLE hFaxHandle,
  1483. IN DWORD dwDeviceID,
  1484. IN LPCSTR lpctstrNameGUID,
  1485. OUT PVOID *ppData,
  1486. OUT LPDWORD lpdwDataSize
  1487. )
  1488. /*++
  1489. Routine name : FaxGetExtensionDataA
  1490. Routine description:
  1491. Read the extension's private data - ANSI version
  1492. Author:
  1493. Eran Yariv (EranY), Nov, 1999
  1494. Arguments:
  1495. hFaxHandle [in ] - Handle to fax server
  1496. dwDeviceId [in ] - Device identifier.
  1497. 0 = Unassociated data
  1498. lpctstrNameGUID [in ] - GUID of named data
  1499. ppData [out] - Pointer to data buffer
  1500. lpdwDataSize [out] - Returned size of data
  1501. Return Value:
  1502. TRUE - Success
  1503. FALSE - Failure, call GetLastError() for more error information.
  1504. --*/
  1505. {
  1506. LPWSTR lpwstrGUID;
  1507. BOOL bRes;
  1508. DEBUG_FUNCTION_NAME(TEXT("FaxGetExtensionDataA"));
  1509. if (!lpctstrNameGUID)
  1510. {
  1511. SetLastError(ERROR_INVALID_PARAMETER);
  1512. return FALSE;
  1513. }
  1514. lpwstrGUID = AnsiStringToUnicodeString (lpctstrNameGUID);
  1515. if (NULL == lpwstrGUID)
  1516. {
  1517. SetLastError(ERROR_NOT_ENOUGH_MEMORY);
  1518. return FALSE;
  1519. }
  1520. bRes = FaxGetExtensionDataW ( hFaxHandle,
  1521. dwDeviceID,
  1522. lpwstrGUID,
  1523. ppData,
  1524. lpdwDataSize
  1525. );
  1526. MemFree (lpwstrGUID);
  1527. return bRes;
  1528. } // FaxGetExtensionDataA
  1529. BOOL
  1530. WINAPI
  1531. FaxGetExtensionDataW (
  1532. IN HANDLE hFaxHandle,
  1533. IN DWORD dwDeviceID,
  1534. IN LPCWSTR lpctstrNameGUID,
  1535. OUT PVOID *ppData,
  1536. OUT LPDWORD lpdwDataSize
  1537. )
  1538. /*++
  1539. Routine name : FaxGetExtensionDataW
  1540. Routine description:
  1541. Read the extension's private data - UNICODE version
  1542. Author:
  1543. Eran Yariv (EranY), Nov, 1999
  1544. Arguments:
  1545. hFaxHandle [in ] - Handle to fax server
  1546. dwDeviceId [in ] - Device identifier.
  1547. 0 = Unassociated data
  1548. lpctstrNameGUID [in ] - GUID of named data
  1549. ppData [out] - Pointer to data buffer
  1550. lpdwDataSize [out] - Returned size of data
  1551. Return Value:
  1552. TRUE - Success
  1553. FALSE - Failure, call GetLastError() for more error information.
  1554. --*/
  1555. {
  1556. DWORD dwRes;
  1557. DEBUG_FUNCTION_NAME(TEXT("FaxGetExtensionDataW"));
  1558. if (!lpctstrNameGUID || !ppData || !lpdwDataSize)
  1559. {
  1560. SetLastError(ERROR_INVALID_PARAMETER);
  1561. return FALSE;
  1562. }
  1563. if (!ValidateFaxHandle(hFaxHandle, FHT_SERVICE))
  1564. {
  1565. SetLastError(ERROR_INVALID_HANDLE);
  1566. return FALSE;
  1567. }
  1568. dwRes = IsValidGUID (lpctstrNameGUID);
  1569. if (ERROR_SUCCESS != dwRes)
  1570. {
  1571. SetLastError(dwRes);
  1572. return FALSE;
  1573. }
  1574. *ppData = NULL;
  1575. //
  1576. // Call the RPC function
  1577. //
  1578. __try
  1579. {
  1580. dwRes = FAX_GetExtensionData(
  1581. FH_FAX_HANDLE (hFaxHandle),
  1582. dwDeviceID,
  1583. lpctstrNameGUID,
  1584. (LPBYTE*)ppData,
  1585. lpdwDataSize
  1586. );
  1587. }
  1588. __except (EXCEPTION_EXECUTE_HANDLER)
  1589. {
  1590. //
  1591. // For some reason we got an exception.
  1592. //
  1593. dwRes = GetExceptionCode();
  1594. DebugPrintEx(
  1595. DEBUG_ERR,
  1596. TEXT("Exception on RPC call to FAX_GetExtensionData. (ec: %ld)"),
  1597. dwRes);
  1598. }
  1599. if (ERROR_SUCCESS != dwRes)
  1600. {
  1601. DumpRPCExtendedStatus ();
  1602. SetLastError(dwRes);
  1603. return FALSE;
  1604. }
  1605. return TRUE;
  1606. } // FaxGetExtensionDataW
  1607. #ifndef UNICODE
  1608. BOOL
  1609. WINAPI
  1610. FaxGetExtensionDataX (
  1611. IN HANDLE hFaxHandle,
  1612. IN DWORD dwDeviceID,
  1613. IN LPCWSTR lpctstrNameGUID,
  1614. OUT PVOID *ppData,
  1615. OUT LPDWORD lpdwDataSize
  1616. )
  1617. {
  1618. UNREFERENCED_PARAMETER (hFaxHandle);
  1619. UNREFERENCED_PARAMETER (dwDeviceID);
  1620. UNREFERENCED_PARAMETER (lpctstrNameGUID);
  1621. UNREFERENCED_PARAMETER (ppData);
  1622. UNREFERENCED_PARAMETER (lpdwDataSize);
  1623. SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
  1624. return FALSE;
  1625. } // FaxGetExtensionDataX
  1626. #endif // #ifndef UNICODE
  1627. BOOL
  1628. WINAPI
  1629. FaxSetExtensionDataA (
  1630. IN HANDLE hFaxHandle,
  1631. IN DWORD dwDeviceID,
  1632. IN LPCSTR lpctstrNameGUID,
  1633. IN CONST PVOID pData,
  1634. IN CONST DWORD dwDataSize
  1635. )
  1636. /*++
  1637. Routine name : FaxSetExtensionDataA
  1638. Routine description:
  1639. Write the extension's private data - ANSI version
  1640. Author:
  1641. Eran Yariv (EranY), Nov, 1999
  1642. Arguments:
  1643. hFaxHandle [in ] - Handle to fax server
  1644. dwDeviceId [in ] - Device identifier.
  1645. 0 = Unassociated data
  1646. lpctstrNameGUID [in ] - GUID of named data
  1647. pData [in ] - Pointer to data
  1648. dwDataSize [in ] - Size of data
  1649. Return Value:
  1650. TRUE - Success
  1651. FALSE - Failure, call GetLastError() for more error information.
  1652. --*/
  1653. {
  1654. LPWSTR lpwstrGUID;
  1655. BOOL bRes;
  1656. DEBUG_FUNCTION_NAME(TEXT("FaxSetExtensionDataA"));
  1657. if (!lpctstrNameGUID)
  1658. {
  1659. SetLastError(ERROR_INVALID_PARAMETER);
  1660. return FALSE;
  1661. }
  1662. lpwstrGUID = AnsiStringToUnicodeString (lpctstrNameGUID);
  1663. if (NULL == lpwstrGUID)
  1664. {
  1665. SetLastError(ERROR_NOT_ENOUGH_MEMORY);
  1666. return FALSE;
  1667. }
  1668. bRes = FaxSetExtensionDataW ( hFaxHandle,
  1669. dwDeviceID,
  1670. lpwstrGUID,
  1671. pData,
  1672. dwDataSize
  1673. );
  1674. MemFree (lpwstrGUID);
  1675. return bRes;
  1676. } // FaxSetExtensionDataA
  1677. BOOL
  1678. WINAPI
  1679. FaxSetExtensionDataW (
  1680. IN HANDLE hFaxHandle,
  1681. IN DWORD dwDeviceID,
  1682. IN LPCWSTR lpctstrNameGUID,
  1683. IN CONST PVOID pData,
  1684. IN CONST DWORD dwDataSize
  1685. )
  1686. /*++
  1687. Routine name : FaxSetExtensionDataW
  1688. Routine description:
  1689. Write the extension's private data - UNICODE version
  1690. Author:
  1691. Eran Yariv (EranY), Nov, 1999
  1692. Arguments:
  1693. hFaxHandle [in ] - Handle to fax server
  1694. dwDeviceId [in ] - Device identifier.
  1695. 0 = Unassociated data
  1696. lpctstrNameGUID [in ] - GUID of named data
  1697. pData [in ] - Pointer to data
  1698. dwDataSize [in ] - Size of data
  1699. Return Value:
  1700. TRUE - Success
  1701. FALSE - Failure, call GetLastError() for more error information.
  1702. --*/
  1703. {
  1704. DWORD dwRes;
  1705. DWORD dwComputerNameSize;
  1706. WCHAR lpwstrComputerName[MAX_COMPUTERNAME_LENGTH + 1];
  1707. DEBUG_FUNCTION_NAME(TEXT("FaxSetExtensionDataW"));
  1708. if (!lpctstrNameGUID || !pData || !dwDataSize)
  1709. {
  1710. SetLastError(ERROR_INVALID_PARAMETER);
  1711. return FALSE;
  1712. }
  1713. if (!ValidateFaxHandle(hFaxHandle, FHT_SERVICE))
  1714. {
  1715. SetLastError(ERROR_INVALID_HANDLE);
  1716. return FALSE;
  1717. }
  1718. dwRes = IsValidGUID (lpctstrNameGUID);
  1719. if (ERROR_SUCCESS != dwRes)
  1720. {
  1721. SetLastError(dwRes);
  1722. return FALSE;
  1723. }
  1724. //
  1725. // Retrieve the name of the machine for this caller.
  1726. // The machine name will be used (together with the fax handle) to uniquely
  1727. // identify that:
  1728. // 1. The data was set remotely using an RPC call (and not by a local extension).
  1729. // 2. Uniquely identify the module (instance) that called the Set operation.
  1730. //
  1731. // We're doing this to block notifications in the server back to the module that
  1732. // did the data change (called the Set... function).
  1733. //
  1734. dwComputerNameSize = sizeof (lpwstrComputerName) / sizeof (lpwstrComputerName[0]);
  1735. if (!GetComputerNameW (lpwstrComputerName, &dwComputerNameSize))
  1736. {
  1737. dwRes = GetLastError ();
  1738. DebugPrintEx(
  1739. DEBUG_ERR,
  1740. TEXT("Error calling GetComputerNameW (ec: %ld)"),
  1741. dwRes);
  1742. SetLastError(dwRes);
  1743. return FALSE;
  1744. }
  1745. //
  1746. // Call the RPC function
  1747. //
  1748. __try
  1749. {
  1750. dwRes = FAX_SetExtensionData(
  1751. FH_FAX_HANDLE (hFaxHandle),
  1752. lpwstrComputerName,
  1753. dwDeviceID,
  1754. lpctstrNameGUID,
  1755. (LPBYTE)pData,
  1756. dwDataSize
  1757. );
  1758. }
  1759. __except (EXCEPTION_EXECUTE_HANDLER)
  1760. {
  1761. //
  1762. // For some reason we got an exception.
  1763. //
  1764. dwRes = GetExceptionCode();
  1765. DebugPrintEx(
  1766. DEBUG_ERR,
  1767. TEXT("Exception on RPC call to FAX_SetExtensionData. (ec: %ld)"),
  1768. dwRes);
  1769. }
  1770. if (ERROR_SUCCESS != dwRes)
  1771. {
  1772. DumpRPCExtendedStatus ();
  1773. SetLastError(dwRes);
  1774. return FALSE;
  1775. }
  1776. return TRUE;
  1777. } // FaxSetExtensionDataW
  1778. #ifndef UNICODE
  1779. BOOL
  1780. WINAPI
  1781. FaxSetExtensionDataX (
  1782. IN HANDLE hFaxHandle,
  1783. IN DWORD dwDeviceID,
  1784. IN LPCWSTR lpctstrNameGUID,
  1785. IN CONST PVOID pData,
  1786. IN CONST DWORD dwDataSize
  1787. )
  1788. {
  1789. UNREFERENCED_PARAMETER (hFaxHandle);
  1790. UNREFERENCED_PARAMETER (dwDeviceID);
  1791. UNREFERENCED_PARAMETER (lpctstrNameGUID);
  1792. UNREFERENCED_PARAMETER (pData);
  1793. UNREFERENCED_PARAMETER (dwDataSize);
  1794. SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
  1795. return FALSE;
  1796. } // FaxSetExtensionDataX
  1797. #endif // #ifndef UNICODE