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.

1665 lines
36 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. faxutil.h
  5. Abstract:
  6. This file defines the debugging interfaces
  7. available to the FAX compoments.
  8. Author:
  9. Wesley Witt (wesw) 22-Dec-1995
  10. Environment:
  11. User Mode
  12. --*/
  13. #ifndef _FAXUTIL_
  14. #define _FAXUTIL_
  15. #include <windows.h>
  16. #include <crtdbg.h>
  17. #include <malloc.h>
  18. #include <WinSpool.h>
  19. #include <rpc.h>
  20. #ifndef _FAXAPI_
  21. //
  22. // WinFax.h is not already included
  23. //
  24. #include <fxsapip.h>
  25. #else
  26. //
  27. // WinFax.h is already included
  28. // This happens by the W2K COM only.
  29. //
  30. typedef LPVOID *PFAX_VERSION;
  31. #endif // !defined _FAXAPI_
  32. #include <FaxDebug.h>
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. #define ARR_SIZE(x) (sizeof(x)/sizeof((x)[0]))
  37. //
  38. // Nul terminator for a character string
  39. //
  40. #define NUL 0
  41. #define IsEmptyString(p) ((p)[0] == NUL)
  42. #define SizeOfString(p) ((_tcslen(p) + 1) * sizeof(TCHAR))
  43. #define IsNulChar(c) ((c) == NUL)
  44. #define OffsetToString( Offset, Buffer ) ((Offset) ? (LPTSTR) ((Buffer) + ((ULONG_PTR) Offset)) : NULL)
  45. #define StringSize(_s) (( _s ) ? (_tcslen( _s ) + 1) * sizeof(TCHAR) : 0)
  46. #define StringSizeW(_s) (( _s ) ? (wcslen( _s ) + 1) * sizeof(WCHAR) : 0)
  47. #define MultiStringSize(_s) ( ( _s ) ? MultiStringLength((_s)) * sizeof(TCHAR) : 0 )
  48. #define MAX_GUID_STRING_LEN 39 // 38 chars + terminator null
  49. #define FAXBITS 1728
  50. #define FAXBYTES (FAXBITS/BYTEBITS)
  51. #define MAXHORZBITS FAXBITS
  52. #define MAXVERTBITS 3000 // 14inches plus
  53. #define MINUTES_PER_HOUR 60
  54. #define MINUTES_PER_DAY (24 * 60)
  55. #define SECONDS_PER_MINUTE 60
  56. #define SECONDS_PER_HOUR (SECONDS_PER_MINUTE * MINUTES_PER_HOUR)
  57. #define SECONDS_PER_DAY (MINUTES_PER_DAY * SECONDS_PER_MINUTE)
  58. #define FILETIMETICKS_PER_SECOND 10000000 // 100 nanoseconds / second
  59. #define FILETIMETICKS_PER_DAY ((LONGLONG) FILETIMETICKS_PER_SECOND * (LONGLONG) SECONDS_PER_DAY)
  60. #define MILLISECONDS_PER_SECOND 1000
  61. #ifndef MAKELONGLONG
  62. #define MAKELONGLONG(low,high) ((LONGLONG)(((DWORD)(low)) | ((LONGLONG)((DWORD)(high))) << 32))
  63. #endif
  64. #define HideWindow(_hwnd) SetWindowLong((_hwnd),GWL_STYLE,GetWindowLong((_hwnd),GWL_STYLE)&~WS_VISIBLE)
  65. #define UnHideWindow(_hwnd) SetWindowLong((_hwnd),GWL_STYLE,GetWindowLong((_hwnd),GWL_STYLE)|WS_VISIBLE)
  66. #define DWord2FaxTime(pFaxTime, dwValue) (pFaxTime)->hour = LOWORD(dwValue), (pFaxTime)->minute = HIWORD(dwValue)
  67. #define FaxTime2DWord(pFaxTime) MAKELONG((pFaxTime)->hour, (pFaxTime)->minute)
  68. #define EMPTY_STRING TEXT("")
  69. typedef GUID *PGUID;
  70. typedef enum {
  71. DEBUG_VER_MSG =0x00000001,
  72. DEBUG_WRN_MSG =0x00000002,
  73. DEBUG_ERR_MSG =0x00000004,
  74. DEBUG_FAX_TAPI_MSG =0x00000008
  75. } DEBUG_MESSAGE_TYPE;
  76. #define DEBUG_ALL_MSG DEBUG_VER_MSG | DEBUG_WRN_MSG | DEBUG_ERR_MSG | DEBUG_FAX_TAPI_MSG
  77. //
  78. // Tags used to pass information about fax jobs
  79. //
  80. typedef struct {
  81. LPTSTR lptstrTagName;
  82. LPTSTR lptstrValue;
  83. } FAX_TAG_MAP_ENTRY;
  84. void
  85. ParamTagsToString(
  86. FAX_TAG_MAP_ENTRY * lpTagMap,
  87. DWORD dwTagCount,
  88. LPTSTR lpTargetBuf,
  89. LPDWORD dwSize);
  90. //
  91. // debugging information
  92. //
  93. #ifndef FAXUTIL_DEBUG
  94. #ifdef ENABLE_FRE_LOGGING
  95. #define ENABLE_LOGGING
  96. #endif // ENABLE_FRE_LOGGING
  97. #ifdef DEBUG
  98. #define ENABLE_LOGGING
  99. #endif // DEBUG
  100. #ifdef DBG
  101. #define ENABLE_LOGGING
  102. #endif // DBG
  103. #ifdef ENABLE_LOGGING
  104. #define Assert(exp) if(!(exp)) {AssertError(TEXT(#exp),TEXT(__FILE__),__LINE__);}
  105. #define DebugPrint(_x_) fax_dprintf _x_
  106. #define DebugStop(_x_) {\
  107. fax_dprintf _x_;\
  108. fax_dprintf(TEXT("Stopping at %s @ %d"),TEXT(__FILE__),__LINE__);\
  109. __try {\
  110. DebugBreak();\
  111. } __except (UnhandledExceptionFilter(GetExceptionInformation())) {\
  112. }\
  113. }
  114. #define ASSERT_FALSE \
  115. { \
  116. int bAssertCondition = TRUE; \
  117. Assert(bAssertCondition == FALSE); \
  118. } \
  119. #ifdef USE_DEBUG_CONTEXT
  120. #define DEBUG_WRN USE_DEBUG_CONTEXT,DEBUG_WRN_MSG,faxDbgFunction,TEXT(__FILE__),__LINE__
  121. #define DEBUG_ERR USE_DEBUG_CONTEXT,DEBUG_ERR_MSG,faxDbgFunction,TEXT(__FILE__),__LINE__
  122. #define DEBUG_MSG USE_DEBUG_CONTEXT,DEBUG_VER_MSG,faxDbgFunction,TEXT(__FILE__),__LINE__
  123. #define DEBUG_TAPI USE_DEBUG_CONTEXT,DEBUG_FAX_TAPI_MSG,faxDbgFunction,TEXT(__FILE__),__LINE__
  124. #else
  125. #define DEBUG_WRN DEBUG_CONTEXT_ALL,DEBUG_WRN_MSG,faxDbgFunction,TEXT(__FILE__),__LINE__
  126. #define DEBUG_ERR DEBUG_CONTEXT_ALL,DEBUG_ERR_MSG,faxDbgFunction,TEXT(__FILE__),__LINE__
  127. #define DEBUG_MSG DEBUG_CONTEXT_ALL,DEBUG_VER_MSG,faxDbgFunction,TEXT(__FILE__),__LINE__
  128. #define DEBUG_TAPI DEBUG_CONTEXT_ALL,DEBUG_FAX_TAPI_MSG,faxDbgFunction,TEXT(__FILE__),__LINE__
  129. #endif
  130. #define DebugPrintEx dprintfex
  131. #define DebugError
  132. #define DebugPrintEx0(Format) \
  133. dprintfex(DEBUG_VER_MSG,faxDbgFunction,TEXT(__FILE__),__LINE__,Format);
  134. #define DebugPrintEx1(Format,Param1) \
  135. dprintfex(DEBUG_VER_MSG,faxDbgFunction,TEXT(__FILE__),__LINE__,Format,Param1);
  136. #define DebugPrintEx2(Format,Param1,Param2) \
  137. dprintfex(DEBUG_VER_MSG,faxDbgFunction,TEXT(__FILE__),__LINE__,Format,Param1,Param2);
  138. #define DebugPrintEx3(Format,Param1,Param2,Param3) \
  139. dprintfex(DEBUG_VER_MSG,faxDbgFunction,TEXT(__FILE__),__LINE__,Format,Param1,Param2,Param3);
  140. #define DEBUG_TRACE_ENTER DebugPrintEx(DEBUG_MSG,TEXT("Entering: %s"),faxDbgFunction);
  141. #define DEBUG_TRACE_LEAVE DebugPrintEx(DEBUG_MSG,TEXT("Leaving: %s"),faxDbgFunction);
  142. #define DEBUG_FUNCTION_NAME(_x_) LPCTSTR faxDbgFunction=_x_; \
  143. DEBUG_TRACE_ENTER;
  144. #define OPEN_DEBUG_FILE(f) debugOpenLogFile(f, -1)
  145. #define OPEN_DEBUG_FILE_SIZE(f,s) debugOpenLogFile(f, s)
  146. #define CLOSE_DEBUG_FILE debugCloseLogFile()
  147. #define SET_DEBUG_PROPERTIES(level,format,context) debugSetProperties(level,format,context)
  148. #else // ENABLE_LOGGING
  149. #define ASSERT_FALSE
  150. #define Assert(exp)
  151. #define DebugPrint(_x_)
  152. #define DebugStop(_x_)
  153. #define DebugPrintEx 1 ? (void)0 : dprintfex
  154. #define DebugPrintEx0(Format)
  155. #define DebugPrintEx1(Format,Param1)
  156. #define DebugPrintEx2(Format,Param1,Param2)
  157. #define DebugPrintEx3(Format,Param1,Param2,Param3)
  158. #define DEBUG_FUNCTION_NAME(_x_)
  159. #define DEBUG_TRACE_ENTER
  160. #define DEBUG_TRACE_LEAVE
  161. #define DEBUG_WRN DEBUG_CONTEXT_ALL,DEBUG_WRN_MSG,TEXT(""),TEXT(__FILE__),__LINE__
  162. #define DEBUG_ERR DEBUG_CONTEXT_ALL,DEBUG_ERR_MSG,TEXT(""),TEXT(__FILE__),__LINE__
  163. #define DEBUG_MSG DEBUG_CONTEXT_ALL,DEBUG_VER_MSG,TEXT(""),TEXT(__FILE__),__LINE__
  164. #define DEBUG_TAPI DEBUG_CONTEXT_ALL,DEBUG_FAX_TAPI_MSG,TEXT(""),TEXT(__FILE__),__LINE__
  165. #define OPEN_DEBUG_FILE(f)
  166. #define OPEN_DEBUG_FILE_SIZE(f,s)
  167. #define CLOSE_DEBUG_FILE
  168. #define SET_DEBUG_PROPERTIES(level,format,context)
  169. #endif // ENABLE_LOGGING
  170. extern BOOL ConsoleDebugOutput;
  171. void
  172. dprintfex(
  173. DEBUG_MESSAGE_CONTEXT nMessageContext,
  174. DEBUG_MESSAGE_TYPE nMessageType,
  175. LPCTSTR lpctstrDbgFunction,
  176. LPCTSTR lpctstrFile,
  177. DWORD dwLine,
  178. LPCTSTR lpctstrFormat,
  179. ...
  180. );
  181. void
  182. fax_dprintf(
  183. LPCTSTR Format,
  184. ...
  185. );
  186. VOID
  187. AssertError(
  188. LPCTSTR Expression,
  189. LPCTSTR File,
  190. ULONG LineNumber
  191. );
  192. BOOL debugOpenLogFile(LPCTSTR lpctstrFilename, DWORD dwMaxSize);
  193. void debugCloseLogFile();
  194. void debugSetProperties(DWORD dwLevel,DWORD dwFormat,DWORD dwContext);
  195. BOOL debugIsRegistrySession();
  196. #endif
  197. //
  198. // list management
  199. //
  200. #ifndef NO_FAX_LIST
  201. #define InitializeListHead(ListHead) {\
  202. (ListHead)->Flink = (ListHead)->Blink = (ListHead);\
  203. Assert((ListHead)->Flink && (ListHead)->Blink);\
  204. }
  205. #define IsListEmpty(ListHead) \
  206. ((ListHead)->Flink == (ListHead))
  207. #define InsertHeadList(ListHead,Entry) {\
  208. PLIST_ENTRY _EX_Flink;\
  209. PLIST_ENTRY _EX_ListHead;\
  210. Assert ( !((Entry)->Flink) && !((Entry)->Blink) );\
  211. _EX_ListHead = (ListHead);\
  212. _EX_Flink = _EX_ListHead->Flink;\
  213. (Entry)->Flink = _EX_Flink;\
  214. (Entry)->Blink = _EX_ListHead;\
  215. _EX_Flink->Blink = (Entry);\
  216. _EX_ListHead->Flink = (Entry);\
  217. Assert((ListHead)->Flink && (ListHead)->Blink && (Entry)->Blink && (Entry)->Flink);\
  218. }
  219. #define InsertTailList(ListHead,Entry) {\
  220. PLIST_ENTRY _EX_Blink;\
  221. PLIST_ENTRY _EX_ListHead;\
  222. Assert ( !((Entry)->Flink) && !((Entry)->Blink) );\
  223. _EX_ListHead = (ListHead);\
  224. _EX_Blink = _EX_ListHead->Blink;\
  225. (Entry)->Flink = _EX_ListHead;\
  226. (Entry)->Blink = _EX_Blink;\
  227. _EX_Blink->Flink = (Entry);\
  228. _EX_ListHead->Blink = (Entry);\
  229. Assert((ListHead)->Flink && (ListHead)->Blink && (Entry)->Blink && (Entry)->Flink);\
  230. }
  231. #define RemoveEntryList(Entry) {\
  232. PLIST_ENTRY _EX_Blink;\
  233. PLIST_ENTRY _EX_Flink;\
  234. Assert((Entry)->Blink && (Entry)->Flink);\
  235. _EX_Flink = (Entry)->Flink;\
  236. _EX_Blink = (Entry)->Blink;\
  237. _EX_Blink->Flink = _EX_Flink;\
  238. _EX_Flink->Blink = _EX_Blink;\
  239. (Entry)->Flink = NULL;\
  240. (Entry)->Blink = NULL;\
  241. }
  242. #define RemoveHeadList(ListHead) \
  243. Assert((ListHead)->Flink);\
  244. (ListHead)->Flink;\
  245. {RemoveEntryList((ListHead)->Flink)}
  246. #endif
  247. //
  248. // memory allocation
  249. //
  250. #ifndef FAXUTIL_MEM
  251. #define HEAP_SIZE (1024*1024)
  252. #ifdef FAX_HEAP_DEBUG
  253. #define HEAP_SIG 0x69696969
  254. typedef struct _HEAP_BLOCK {
  255. LIST_ENTRY ListEntry;
  256. ULONG Signature;
  257. SIZE_T Size;
  258. ULONG Line;
  259. #ifdef UNICODE
  260. WCHAR File[MAX_PATH];
  261. #else
  262. CHAR File[MAX_PATH];
  263. #endif
  264. } HEAP_BLOCK, *PHEAP_BLOCK;
  265. #define MemAlloc(s) pMemAlloc(s,__LINE__,__FILE__)
  266. #define MemReAlloc(d,s) pMemReAlloc(d,s,__LINE__,__FILE__)
  267. #define MemFree(p) pMemFree(p,__LINE__,__FILE__)
  268. #define MemFreeForHeap(h,p) pMemFreeForHeap(h,p,__LINE__,__FILE__)
  269. #define CheckHeap(p) pCheckHeap(p,__LINE__,__FILE__)
  270. #else
  271. #define MemAlloc(s) pMemAlloc(s)
  272. #define MemReAlloc(d,s) pMemReAlloc(d,s)
  273. #define MemFree(p) pMemFree(p)
  274. #define MemFreeForHeap(h,p) pMemFreeForHeap(h,p)
  275. #define CheckHeap(p) (TRUE)
  276. #endif
  277. typedef LPVOID (WINAPI *PMEMALLOC) (SIZE_T);
  278. typedef LPVOID (WINAPI *PMEMREALLOC) (LPVOID,SIZE_T);
  279. typedef VOID (WINAPI *PMEMFREE) (LPVOID);
  280. int GetY2KCompliantDate (
  281. LCID Locale,
  282. DWORD dwFlags,
  283. CONST SYSTEMTIME *lpDate,
  284. LPTSTR lpDateStr,
  285. int cchDate
  286. );
  287. long
  288. StatusNoMemoryExceptionFilter (DWORD dwExceptionCode);
  289. HRESULT
  290. SafeInitializeCriticalSection (LPCRITICAL_SECTION lpCriticalSection);
  291. HANDLE
  292. HeapInitialize(
  293. HANDLE hHeap,
  294. PMEMALLOC pMemAlloc,
  295. PMEMFREE pMemFree,
  296. PMEMREALLOC pMemReAlloc
  297. );
  298. BOOL
  299. HeapExistingInitialize(
  300. HANDLE hExistHeap
  301. );
  302. BOOL
  303. HeapCleanup(
  304. VOID
  305. );
  306. #ifdef FAX_HEAP_DEBUG
  307. BOOL
  308. pCheckHeap(
  309. PVOID MemPtr,
  310. ULONG Line,
  311. LPSTR File
  312. );
  313. VOID
  314. PrintAllocations(
  315. VOID
  316. );
  317. #else
  318. #define PrintAllocations()
  319. #endif
  320. PVOID
  321. pMemAlloc(
  322. SIZE_T AllocSize
  323. #ifdef FAX_HEAP_DEBUG
  324. ,ULONG Line
  325. ,LPSTR File
  326. #endif
  327. );
  328. PVOID
  329. pMemReAlloc(
  330. PVOID dest,
  331. ULONG AllocSize
  332. #ifdef FAX_HEAP_DEBUG
  333. ,ULONG Line
  334. ,LPSTR File
  335. #endif
  336. );
  337. VOID
  338. pMemFree(
  339. PVOID MemPtr
  340. #ifdef FAX_HEAP_DEBUG
  341. ,ULONG Line
  342. ,LPSTR File
  343. #endif
  344. );
  345. VOID
  346. pMemFreeForHeap(
  347. HANDLE hHeap,
  348. PVOID MemPtr
  349. #ifdef FAX_HEAP_DEBUG
  350. ,ULONG Line
  351. ,LPSTR File
  352. #endif
  353. );
  354. #endif
  355. //
  356. // Server/Registry Activity logging structure
  357. //
  358. typedef struct _FAX_SERVER_ACTIVITY_LOGGING_CONFIG
  359. {
  360. DWORD dwSizeOfStruct;
  361. BOOL bLogIncoming;
  362. BOOL bLogOutgoing;
  363. LPTSTR lptstrDBPath;
  364. DWORD dwLogLimitCriteria;
  365. DWORD dwLogSizeLimit;
  366. DWORD dwLogAgeLimit;
  367. DWORD dwLimitReachedAction;
  368. } FAX_SERVER_ACTIVITY_LOGGING_CONFIG, *PFAX_SERVER_ACTIVITY_LOGGING_CONFIG;
  369. //
  370. // TAPI functions
  371. //
  372. BOOL
  373. GetCallerIDFromCall(
  374. HCALL hCall,
  375. LPTSTR lptstrCallerID,
  376. DWORD dwCallerIDSize
  377. );
  378. //
  379. // file functions
  380. //
  381. #ifndef FAXUTIL_FILE
  382. /*++
  383. Routine name : SafeCreateFile
  384. Routine description:
  385. This is a safe wrapper around the Win32 CreateFile API.
  386. It only supports creating real files (as opposed to COM ports, named pipes, etc.).
  387. It uses some widely-discussed mitigation techniques to guard agaist some well known security
  388. issues in CreateFile().
  389. Author:
  390. Eran Yariv (EranY), Mar, 2002
  391. Arguments:
  392. lpFileName [in] - Refer to the CreateFile() documentation for parameter description.
  393. dwDesiredAccess [in] - Refer to the CreateFile() documentation for parameter description.
  394. dwShareMode [in] - Refer to the CreateFile() documentation for parameter description.
  395. lpSecurityAttributes [in] - Refer to the CreateFile() documentation for parameter description.
  396. dwCreationDisposition [in] - Refer to the CreateFile() documentation for parameter description.
  397. dwFlagsAndAttributes [in] - Refer to the CreateFile() documentation for parameter description.
  398. hTemplateFile [in] - Refer to the CreateFile() documentation for parameter description.
  399. Return Value:
  400. If the function succeeds, the return value is an open handle to the specified file.
  401. If the specified file exists before the function call and dwCreationDisposition is CREATE_ALWAYS or OPEN_ALWAYS,
  402. a call to GetLastError returns ERROR_ALREADY_EXISTS (even though the function has succeeded).
  403. If the file does not exist before the call, GetLastError returns zero.
  404. If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
  405. For more information see the "Return value" section in the CreateFile() documentation.
  406. Remarks:
  407. Please refer to the CreateFile() documentation.
  408. --*/
  409. HANDLE
  410. __stdcall
  411. SafeCreateFile(
  412. LPCTSTR lpFileName, // File name
  413. DWORD dwDesiredAccess, // Access mode
  414. DWORD dwShareMode, // Share mode
  415. LPSECURITY_ATTRIBUTES lpSecurityAttributes, // SD
  416. DWORD dwCreationDisposition, // How to create
  417. DWORD dwFlagsAndAttributes, // File attributes
  418. HANDLE hTemplateFile // Handle to template file
  419. );
  420. /*++
  421. Routine name : SafeCreateTempFile
  422. Routine description:
  423. This is a safe wrapper around the Win32 CreateFile API.
  424. It only supports creating real files (as opposed to COM ports, named pipes, etc.).
  425. It uses some widely-discussed mitigation techniques to guard agaist some well known security
  426. issues in CreateFile().
  427. Use this function to create and open temporary files.
  428. The file will be created / opened using the FILE_FLAG_DELETE_ON_CLOSE flag.
  429. When the last file handle is closed, the file will be automatically deleted.
  430. In addition, the file is marked for deletion after reboot (Unicode-version only).
  431. This will only work if the calling thread's user is a member of the local admins group.
  432. If marking for deletion-post-reboot fails, the InternalSafeCreateFile function call still succeeds.
  433. NOTICE: This function cannot be used to create temporary files which should be used by other applications.
  434. For example, it should not be used to create temporary preview files.
  435. This is because other applications will not specify FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE
  436. in the file share mode and will fail to open the temporary file.
  437. Author:
  438. Eran Yariv (EranY), Mar, 2002
  439. Arguments:
  440. lpFileName [in] - Refer to the CreateFile() documentation for parameter description.
  441. dwDesiredAccess [in] - Refer to the CreateFile() documentation for parameter description.
  442. dwShareMode [in] - Refer to the CreateFile() documentation for parameter description.
  443. lpSecurityAttributes [in] - Refer to the CreateFile() documentation for parameter description.
  444. dwCreationDisposition [in] - Refer to the CreateFile() documentation for parameter description.
  445. dwFlagsAndAttributes [in] - Refer to the CreateFile() documentation for parameter description.
  446. hTemplateFile [in] - Refer to the CreateFile() documentation for parameter description.
  447. Return Value:
  448. If the function succeeds, the return value is an open handle to the specified file.
  449. If the specified file exists before the function call and dwCreationDisposition is CREATE_ALWAYS or OPEN_ALWAYS,
  450. a call to GetLastError returns ERROR_ALREADY_EXISTS (even though the function has succeeded).
  451. If the file does not exist before the call, GetLastError returns zero.
  452. If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
  453. For more information see the "Return value" section in the CreateFile() documentation.
  454. Remarks:
  455. Please refer to the CreateFile() documentation.
  456. --*/
  457. HANDLE
  458. __stdcall
  459. SafeCreateTempFile(
  460. LPCTSTR lpFileName, // File name
  461. DWORD dwDesiredAccess, // Access mode
  462. DWORD dwShareMode, // Share mode
  463. LPSECURITY_ATTRIBUTES lpSecurityAttributes, // SD
  464. DWORD dwCreationDisposition, // How to create
  465. DWORD dwFlagsAndAttributes, // File attributes
  466. HANDLE hTemplateFile // Handle to template file
  467. );
  468. typedef struct _FILE_MAPPING {
  469. HANDLE hFile;
  470. HANDLE hMap;
  471. LPBYTE fPtr;
  472. DWORD fSize;
  473. } FILE_MAPPING, *PFILE_MAPPING;
  474. BOOL
  475. MapFileOpen(
  476. LPCTSTR FileName,
  477. BOOL ReadOnly,
  478. DWORD ExtendBytes,
  479. PFILE_MAPPING FileMapping
  480. );
  481. VOID
  482. MapFileClose(
  483. PFILE_MAPPING FileMapping,
  484. DWORD TrimOffset
  485. );
  486. DWORDLONG
  487. GenerateUniqueFileName(
  488. LPTSTR Directory,
  489. LPTSTR Extension,
  490. OUT LPTSTR FileName,
  491. DWORD FileNameSize
  492. );
  493. DWORDLONG
  494. GenerateUniqueFileNameWithPrefix(
  495. BOOL bUseProcessId,
  496. LPTSTR lptstrDirectory,
  497. LPTSTR lptstrPrefix,
  498. LPTSTR lptstrExtension,
  499. LPTSTR lptstrFileName,
  500. DWORD dwFileNameSize
  501. );
  502. VOID
  503. DeleteTempPreviewFiles (
  504. LPTSTR lptstrDirectory,
  505. BOOL bConsole
  506. );
  507. DWORD
  508. GetFileVersion (
  509. LPCTSTR lpctstrFileName,
  510. PFAX_VERSION pVersion
  511. );
  512. DWORD
  513. GetVersionIE(
  514. BOOL* fInstalled,
  515. INT* iMajorVersion,
  516. INT* iMinorVersion
  517. );
  518. DWORD
  519. ViewFile (
  520. LPCTSTR lpctstrTiffFile
  521. );
  522. DWORD
  523. IsValidFaxFolder(
  524. LPCTSTR szFolder
  525. );
  526. BOOL
  527. ValidateCoverpage(
  528. IN LPCTSTR CoverPageName,
  529. IN LPCTSTR ServerName,
  530. IN BOOL ServerCoverpage,
  531. OUT LPTSTR ResolvedName,
  532. IN DWORD dwResolvedNameSize
  533. );
  534. HINSTANCE
  535. WINAPI
  536. LoadLibraryFromLocalFolder(
  537. IN LPCTSTR lpctstrModuleName,
  538. IN HINSTANCE hModule
  539. );
  540. #endif // FAXUTIL_FILE
  541. //
  542. // string functions
  543. //
  544. LPTSTR
  545. AllocateAndLoadString(
  546. HINSTANCE hInstance,
  547. UINT uID
  548. );
  549. #ifndef FAXUTIL_STRING
  550. typedef struct _STRING_PAIR {
  551. LPTSTR lptstrSrc;
  552. LPTSTR * lpptstrDst;
  553. } STRING_PAIR, * PSTRING_PAIR;
  554. int MultiStringDup(PSTRING_PAIR lpPairs, int nPairCount);
  555. VOID
  556. StoreString(
  557. LPCTSTR String,
  558. PULONG_PTR DestString,
  559. LPBYTE Buffer,
  560. PULONG_PTR Offset,
  561. DWORD dwBufferSize
  562. );
  563. VOID
  564. StoreStringW(
  565. LPCWSTR String,
  566. PULONG_PTR DestString,
  567. LPBYTE Buffer,
  568. PULONG_PTR Offset,
  569. DWORD dwBufferSize
  570. );
  571. DWORD
  572. IsValidGUID (
  573. LPCWSTR lpcwstrGUID
  574. );
  575. LPCTSTR
  576. GetCurrentUserName ();
  577. LPCTSTR
  578. GetRegisteredOrganization ();
  579. BOOL
  580. IsValidSubscriberIdA (
  581. LPCSTR lpcstrSubscriberId
  582. );
  583. BOOL
  584. IsValidSubscriberIdW (
  585. LPCWSTR lpcwstrSubscriberId
  586. );
  587. #ifdef UNICODE
  588. #define IsValidSubscriberId IsValidSubscriberIdW
  589. #else
  590. #define IsValidSubscriberId IsValidSubscriberIdA
  591. #endif
  592. BOOL
  593. IsValidFaxAddress (
  594. LPCTSTR lpctstrFaxAddress,
  595. BOOL bAllowCanonicalFormat
  596. );
  597. LPTSTR
  598. StringDup(
  599. LPCTSTR String
  600. );
  601. LPWSTR
  602. StringDupW(
  603. LPCWSTR String
  604. );
  605. LPWSTR
  606. AnsiStringToUnicodeString(
  607. LPCSTR AnsiString
  608. );
  609. LPSTR
  610. UnicodeStringToAnsiString(
  611. LPCWSTR UnicodeString
  612. );
  613. VOID
  614. FreeString(
  615. LPVOID String
  616. );
  617. BOOL
  618. MakeDirectory(
  619. LPCTSTR Dir
  620. );
  621. VOID
  622. DeleteDirectory(
  623. LPTSTR Dir
  624. );
  625. VOID
  626. HideDirectory(
  627. LPTSTR Dir
  628. );
  629. #ifdef UNICODE
  630. DWORD
  631. CheckToSeeIfSameDir(
  632. LPWSTR lpwstrDir1,
  633. LPWSTR lpwstrDir2,
  634. BOOL* pIsSameDir
  635. );
  636. #endif
  637. VOID
  638. ConsoleDebugPrint(
  639. LPCTSTR buf
  640. );
  641. int
  642. FormatElapsedTimeStr(
  643. FILETIME *ElapsedTime,
  644. LPTSTR TimeStr,
  645. DWORD StringSize
  646. );
  647. LPTSTR
  648. ExpandEnvironmentString(
  649. LPCTSTR EnvString
  650. );
  651. LPTSTR
  652. GetEnvVariable(
  653. LPCTSTR EnvString
  654. );
  655. DWORD
  656. IsCanonicalAddress(
  657. LPCTSTR lpctstrAddress,
  658. BOOL* lpbRslt,
  659. LPDWORD lpdwCountryCode,
  660. LPDWORD lpdwAreaCode,
  661. LPCTSTR* lppctstrSubNumber
  662. );
  663. BOOL
  664. IsLocalMachineNameA (
  665. LPCSTR lpcstrMachineName
  666. );
  667. BOOL
  668. IsLocalMachineNameW (
  669. LPCWSTR lpcwstrMachineName
  670. );
  671. void
  672. GetSecondsFreeTimeFormat(
  673. LPTSTR tszTimeFormat,
  674. ULONG cchTimeFormat
  675. );
  676. size_t
  677. MultiStringLength(
  678. LPCTSTR psz
  679. );
  680. #ifdef UNICODE
  681. #define IsLocalMachineName IsLocalMachineNameW
  682. #else
  683. #define IsLocalMachineName IsLocalMachineNameA
  684. #endif
  685. #endif
  686. //
  687. // product suite functions
  688. //
  689. #ifndef FAXUTIL_SUITE
  690. #include "FaxSuite.h"
  691. BOOL
  692. IsWinXPOS();
  693. PRODUCT_SKU_TYPE GetProductSKU();
  694. DWORD GetProductBuild();
  695. LPCTSTR StringFromSKU(PRODUCT_SKU_TYPE pst);
  696. BOOL IsDesktopSKU();
  697. BOOL IsDesktopSKUFromSKU(PRODUCT_SKU_TYPE);
  698. BOOL IsFaxShared();
  699. DWORD IsFaxInstalled (
  700. LPBOOL lpbInstalled
  701. );
  702. DWORD
  703. GetDeviceLimit();
  704. typedef enum
  705. {
  706. FAX_COMPONENT_SERVICE = 0x0001, // FXSSVC.exe - Fax service
  707. FAX_COMPONENT_CONSOLE = 0x0002, // FXSCLNT.exe - Fax console
  708. FAX_COMPONENT_ADMIN = 0x0004, // FXSADMIN.dll - Fax admin console
  709. FAX_COMPONENT_SEND_WZRD = 0x0008, // FXSSEND.exe - Send wizard invocation
  710. FAX_COMPONENT_CONFIG_WZRD = 0x0010, // FXSCFGWZ.dll - Configuration wizard
  711. FAX_COMPONENT_CPE = 0x0020, // FXSCOVER.exe - Cover page editor
  712. FAX_COMPONENT_HELP_CLIENT_HLP = 0x0040, // fxsclnt.hlp - Client help
  713. FAX_COMPONENT_HELP_CLIENT_CHM = 0x0080, // fxsclnt.chm - Client context help
  714. FAX_COMPONENT_HELP_ADMIN_HLP = 0x0100, // fxsadmin.hlp - Admin help
  715. FAX_COMPONENT_HELP_ADMIN_CHM = 0x0200, // fxsadmin.chm - Admin context help
  716. FAX_COMPONENT_HELP_CPE_CHM = 0x0400, // fxscover.chm - Cover page editor help
  717. FAX_COMPONENT_MONITOR = 0x0800, // fxsst.dll - Fax monitor
  718. FAX_COMPONENT_DRIVER_UI = 0x1000 // fxsui.dll - Fax printer driver
  719. } FAX_COMPONENT_TYPE;
  720. BOOL
  721. IsFaxComponentInstalled(FAX_COMPONENT_TYPE component);
  722. DWORD GetOpenFileNameStructSize();
  723. #endif
  724. #ifndef FAXUTIL_LANG
  725. //
  726. // Unicode control characters
  727. //
  728. #define UNICODE_RLM 0x200F // RIGHT-TO-LEFT MARK (RLM)
  729. #define UNICODE_RLE 0x202B // RIGHT-TO-LEFT EMBEDDING (RLE)
  730. #define UNICODE_RLO 0x202E // RIGHT-TO-LEFT OVERRIDE (RLO)
  731. #define UNICODE_LRM 0x200E // LEFT-TO-RIGHT MARK (LRM)
  732. #define UNICODE_LRE 0x202A // LEFT-TO-RIGHT EMBEDDING (LRE)
  733. #define UNICODE_LRO 0x202D // LEFT-TO-RIGHT OVERRIDE (LRO)
  734. #define UNICODE_PDF 0x202C // POP DIRECTIONAL FORMATTING (PDF)
  735. //
  736. // language functions
  737. //
  738. BOOL
  739. IsRTLUILanguage();
  740. BOOL
  741. IsWindowRTL(HWND hWnd);
  742. DWORD
  743. SetLTREditDirection(
  744. HWND hDlg,
  745. DWORD dwEditID
  746. );
  747. DWORD
  748. SetLTRControlLayout(
  749. HWND hDlg,
  750. DWORD dwCtrlID
  751. );
  752. DWORD
  753. SetLTRComboBox(
  754. HWND hDlg,
  755. DWORD dwCtrlID
  756. );
  757. BOOL
  758. StrHasRTLChar(
  759. LCID Locale,
  760. LPCTSTR pStr
  761. );
  762. BOOL
  763. IsRTLLanguageInstalled();
  764. int
  765. FaxTimeFormat(
  766. LCID Locale, // locale
  767. DWORD dwFlags, // options
  768. CONST SYSTEMTIME *lpTime, // time
  769. LPCTSTR lpFormat, // time format string
  770. LPTSTR lpTimeStr, // formatted string buffer
  771. int cchTime // size of string buffer
  772. );
  773. int
  774. AlignedMessageBox(
  775. HWND hWnd, // handle to owner window
  776. LPCTSTR lpText, // text in message box
  777. LPCTSTR lpCaption, // message box title
  778. UINT uType // message box style
  779. );
  780. DWORD SetRTLProcessLayout();
  781. DWORD
  782. AskUserAndAdjustFaxFolder(
  783. HWND hWnd,
  784. TCHAR* szServerName,
  785. TCHAR* szPath,
  786. DWORD dwError
  787. );
  788. #endif
  789. #ifndef FAXUTIL_NET
  790. BOOL
  791. IsSimpleUI();
  792. #endif
  793. //
  794. // registry functions
  795. //
  796. #ifndef FAXUTIL_REG
  797. typedef BOOL (WINAPI *PREGENUMCALLBACK) (HKEY,LPTSTR,DWORD,LPVOID);
  798. HKEY
  799. OpenRegistryKey(
  800. HKEY hKey,
  801. LPCTSTR KeyName,
  802. BOOL CreateNewKey,
  803. REGSAM SamDesired
  804. );
  805. //
  806. // caution!!! this is a recursive delete function !!!
  807. //
  808. BOOL
  809. DeleteRegistryKey(
  810. HKEY hKey,
  811. LPCTSTR SubKey
  812. );
  813. DWORD
  814. EnumerateRegistryKeys(
  815. HKEY hKey,
  816. LPCTSTR KeyName,
  817. BOOL ChangeValues,
  818. PREGENUMCALLBACK EnumCallback,
  819. LPVOID ContextData
  820. );
  821. LPTSTR
  822. GetRegistryString(
  823. HKEY hKey,
  824. LPCTSTR ValueName,
  825. LPCTSTR DefaultValue
  826. );
  827. LPTSTR
  828. GetRegistryStringExpand(
  829. HKEY hKey,
  830. LPCTSTR ValueName,
  831. LPCTSTR DefaultValue
  832. );
  833. LPTSTR
  834. GetRegistryStringMultiSz(
  835. HKEY hKey,
  836. LPCTSTR ValueName,
  837. LPCTSTR DefaultValue,
  838. LPDWORD StringSize
  839. );
  840. BOOL
  841. GetRegistryDwordDefault(
  842. HKEY hKey,
  843. LPCTSTR lpszValueName,
  844. LPDWORD lpdwDest,
  845. DWORD dwDefault);
  846. DWORD
  847. GetRegistryDword(
  848. HKEY hKey,
  849. LPCTSTR ValueName
  850. );
  851. DWORD
  852. GetRegistryDwordEx(
  853. HKEY hKey,
  854. LPCTSTR ValueName,
  855. LPDWORD lpdwValue
  856. );
  857. LPBYTE
  858. GetRegistryBinary(
  859. HKEY hKey,
  860. LPCTSTR ValueName,
  861. LPDWORD DataSize
  862. );
  863. DWORD
  864. GetSubKeyCount(
  865. HKEY hKey
  866. );
  867. DWORD
  868. GetMaxSubKeyLen(
  869. HKEY hKey
  870. );
  871. BOOL
  872. SetRegistryStringExpand(
  873. HKEY hKey,
  874. LPCTSTR ValueName,
  875. LPCTSTR Value
  876. );
  877. BOOL
  878. SetRegistryString(
  879. HKEY hKey,
  880. LPCTSTR ValueName,
  881. LPCTSTR Value
  882. );
  883. BOOL
  884. SetRegistryDword(
  885. HKEY hKey,
  886. LPCTSTR ValueName,
  887. DWORD Value
  888. );
  889. BOOL
  890. SetRegistryBinary(
  891. HKEY hKey,
  892. LPCTSTR ValueName,
  893. const LPBYTE Value,
  894. LONG Length
  895. );
  896. BOOL
  897. SetRegistryStringMultiSz(
  898. HKEY hKey,
  899. LPCTSTR ValueName,
  900. LPCTSTR Value,
  901. DWORD Length
  902. );
  903. DWORD
  904. CopyRegistrySubkeysByHandle(
  905. HKEY hkeyDest,
  906. HKEY hkeySrc,
  907. BOOL fForceRestore
  908. );
  909. DWORD
  910. CopyRegistrySubkeys(
  911. LPCTSTR strDest,
  912. LPCTSTR strSrc,
  913. BOOL fForceRestore
  914. );
  915. BOOL SetPrivilege(
  916. LPTSTR pszPrivilege,
  917. BOOL bEnable,
  918. PTOKEN_PRIVILEGES oldPrivilege
  919. );
  920. BOOL RestorePrivilege(
  921. PTOKEN_PRIVILEGES oldPrivilege
  922. );
  923. DWORD
  924. DeleteDeviceEntry(
  925. DWORD dwServerPermanentID
  926. );
  927. DWORD
  928. DeleteTapiEntry(
  929. DWORD dwTapiPermanentLineID
  930. );
  931. DWORD
  932. DeleteCacheEntry(
  933. DWORD dwTapiPermanentLineID
  934. );
  935. #endif
  936. //
  937. // shortcut routines
  938. //
  939. #ifndef FAXUTIL_SHORTCUT
  940. LPTSTR
  941. GetCometPath();
  942. BOOL
  943. IsValidCoverPage(
  944. LPCTSTR pFileName
  945. );
  946. BOOL
  947. GetServerCpDir(
  948. LPCTSTR ServerName OPTIONAL,
  949. LPTSTR CpDir,
  950. DWORD CpDirSize
  951. );
  952. BOOL
  953. GetClientCpDir(
  954. LPTSTR CpDir,
  955. DWORD CpDirSize
  956. );
  957. BOOL
  958. SetClientCpDir(
  959. LPTSTR CpDir
  960. );
  961. BOOL
  962. GetSpecialPath(
  963. IN int nFolder,
  964. OUT LPTSTR lptstrPath,
  965. IN DWORD dwPathSize
  966. );
  967. #ifdef _FAXAPIP_
  968. #endif // _FAXAPIP_
  969. DWORD
  970. WinHelpContextPopup(
  971. ULONG_PTR dwHelpId,
  972. HWND hWnd
  973. );
  974. BOOL
  975. InvokeServiceManager(
  976. HWND hDlg,
  977. HINSTANCE hResource,
  978. UINT uid
  979. );
  980. #endif
  981. PPRINTER_INFO_2
  982. GetFaxPrinterInfo(
  983. LPCTSTR lptstrPrinterName
  984. );
  985. BOOL
  986. GetFirstLocalFaxPrinterName(
  987. OUT LPTSTR lptstrPrinterName,
  988. IN DWORD dwMaxLenInChars
  989. );
  990. BOOL
  991. GetFirstRemoteFaxPrinterName(
  992. OUT LPTSTR lptstrPrinterName,
  993. IN DWORD dwMaxLenInChars
  994. );
  995. DWORD
  996. IsLocalFaxPrinterInstalled(
  997. LPBOOL lpbLocalFaxPrinterInstalled
  998. );
  999. DWORD
  1000. SetLocalFaxPrinterSharing (
  1001. BOOL bShared
  1002. );
  1003. DWORD
  1004. AddOrVerifyLocalFaxPrinter ();
  1005. #ifdef UNICODE
  1006. typedef struct
  1007. {
  1008. LPCWSTR lpcwstrDisplayName; // The display name of the printer
  1009. LPCWSTR lpcwstrPath; // The (UNC or other) path to the printer - as used by the fax service
  1010. } PRINTER_NAMES, *PPRINTER_NAMES;
  1011. PPRINTER_NAMES
  1012. CollectPrinterNames (
  1013. LPDWORD lpdwNumPrinters,
  1014. BOOL bFilterOutFaxPrinters
  1015. );
  1016. VOID
  1017. ReleasePrinterNames (
  1018. PPRINTER_NAMES pNames,
  1019. DWORD dwNumPrinters
  1020. );
  1021. LPCWSTR
  1022. FindPrinterNameFromPath (
  1023. PPRINTER_NAMES pNames,
  1024. DWORD dwNumPrinters,
  1025. LPCWSTR lpcwstrPath
  1026. );
  1027. LPCWSTR
  1028. FindPrinterPathFromName (
  1029. PPRINTER_NAMES pNames,
  1030. DWORD dwNumPrinters,
  1031. LPCWSTR lpcwstrName
  1032. );
  1033. #endif // UNICODE
  1034. BOOL
  1035. VerifyPrinterIsOnline (
  1036. LPCTSTR lpctstrPrinterName
  1037. );
  1038. VOID FaxPrinterProperty(DWORD dwPage);
  1039. PVOID
  1040. MyEnumPrinters(
  1041. LPTSTR pServerName,
  1042. DWORD dwLevel,
  1043. PDWORD pcPrinters,
  1044. DWORD dwFlags
  1045. );
  1046. PVOID
  1047. MyEnumDrivers3(
  1048. LPTSTR pEnvironment,
  1049. PDWORD pcDrivers
  1050. );
  1051. DWORD
  1052. IsLocalFaxPrinterShared (
  1053. LPBOOL lpbShared
  1054. );
  1055. DWORD
  1056. AddLocalFaxPrinter (
  1057. LPCTSTR lpctstrPrinterName,
  1058. LPCTSTR lpctstrPrinterDescription
  1059. );
  1060. HRESULT
  1061. RefreshPrintersAndFaxesFolder ();
  1062. PVOID
  1063. MyEnumMonitors(
  1064. PDWORD pcMonitors
  1065. );
  1066. BOOL
  1067. IsPrinterFaxPrinter(
  1068. LPTSTR PrinterName
  1069. );
  1070. BOOL
  1071. FaxPointAndPrintSetup(
  1072. LPCTSTR pPrinterName,
  1073. BOOL bSilentInstall,
  1074. HINSTANCE hModule
  1075. );
  1076. BOOL
  1077. MultiFileDelete(
  1078. DWORD dwNumberOfFiles,
  1079. LPCTSTR* fileList,
  1080. LPCTSTR lpctstrFilesDirectory
  1081. );
  1082. //
  1083. // START - Functions exported from service.cpp
  1084. //
  1085. BOOL
  1086. EnsureFaxServiceIsStarted(
  1087. LPCTSTR lpctstrMachineName
  1088. );
  1089. BOOL
  1090. StopService (
  1091. LPCTSTR lpctstrMachineName,
  1092. LPCTSTR lpctstrServiceName,
  1093. BOOL bStopDependents,
  1094. #ifdef __cplusplus
  1095. DWORD dwMaxWait = INFINITE
  1096. #else
  1097. DWORD dwMaxWait
  1098. #endif
  1099. );
  1100. BOOL
  1101. WaitForServiceRPCServer (DWORD dwTimeOut);
  1102. DWORD
  1103. IsFaxServiceRunningUnderLocalSystemAccount (
  1104. LPCTSTR lpctstrMachineName,
  1105. LPBOOL lbpResultFlag
  1106. );
  1107. DWORD
  1108. GetServiceStartupType (
  1109. LPCTSTR lpctstrMachine,
  1110. LPCTSTR lpctstrService,
  1111. LPDWORD lpdwStartupType
  1112. );
  1113. DWORD
  1114. SetServiceStartupType (
  1115. LPCTSTR lpctstrMachine,
  1116. LPCTSTR lpctstrService,
  1117. DWORD dwStartupType
  1118. );
  1119. DWORD
  1120. StartServiceEx (
  1121. LPCTSTR lpctstrMachine,
  1122. LPCTSTR lpctstrService,
  1123. DWORD dwNumArgs,
  1124. LPCTSTR*lppctstrCommandLineArgs,
  1125. DWORD dwMaxWait
  1126. );
  1127. #ifdef _WINSVC_
  1128. DWORD
  1129. SetServiceFailureActions (
  1130. LPCTSTR lpctstrMachine,
  1131. LPCTSTR lpctstrService,
  1132. LPSERVICE_FAILURE_ACTIONS lpFailureActions
  1133. );
  1134. #endif // _WINSVC_
  1135. PSID
  1136. GetCurrentThreadSID ();
  1137. SECURITY_ATTRIBUTES *
  1138. CreateSecurityAttributesWithThreadAsOwner (
  1139. DWORD dwCurrentThreadRights,
  1140. DWORD dwAuthUsersAccessRights,
  1141. DWORD dwNetworkServiceRights
  1142. );
  1143. VOID
  1144. DestroySecurityAttributes (
  1145. SECURITY_ATTRIBUTES *pSA
  1146. );
  1147. DWORD
  1148. CreateSvcStartEvent(
  1149. HANDLE *lphEvent,
  1150. HKEY *lphKey
  1151. );
  1152. //
  1153. // END - Functions exported from service.cpp
  1154. //
  1155. //
  1156. // START - Functions exported from security.cpp
  1157. //
  1158. HANDLE
  1159. EnablePrivilege (
  1160. LPCTSTR lpctstrPrivName
  1161. );
  1162. void
  1163. ReleasePrivilege(
  1164. HANDLE hToken
  1165. );
  1166. DWORD
  1167. EnableProcessPrivilege(
  1168. LPCTSTR lpPrivilegeName
  1169. );
  1170. DWORD
  1171. FaxGetAbsoluteSD(
  1172. PSECURITY_DESCRIPTOR pSelfRelativeSD,
  1173. PSECURITY_DESCRIPTOR* ppAbsoluteSD
  1174. );
  1175. void
  1176. FaxFreeAbsoluteSD (
  1177. PSECURITY_DESCRIPTOR pAbsoluteSD,
  1178. BOOL bFreeOwner,
  1179. BOOL bFreeGroup,
  1180. BOOL bFreeDacl,
  1181. BOOL bFreeSacl,
  1182. BOOL bFreeDescriptor
  1183. );
  1184. //
  1185. // END - Functions exported from security.cpp
  1186. //
  1187. BOOL
  1188. MultiFileCopy(
  1189. DWORD dwNumberOfFiles,
  1190. LPCTSTR* fileList,
  1191. LPCTSTR lpctstrSrcDirectory,
  1192. LPCTSTR lpctstrDestDirerctory
  1193. );
  1194. typedef enum
  1195. {
  1196. CDO_AUTH_ANONYMOUS, // No authentication in SMTP server
  1197. CDO_AUTH_BASIC, // Basic (plain-text) authentication in SMTP server
  1198. CDO_AUTH_NTLM // NTLM authentication in SMTP server
  1199. } CDO_AUTH_TYPE;
  1200. HRESULT
  1201. SendMail (
  1202. LPCTSTR lpctstrFrom,
  1203. LPCTSTR lpctstrTo,
  1204. LPCTSTR lpctstrSubject,
  1205. LPCTSTR lpctstrBody,
  1206. LPCTSTR lpctstrHTMLBody,
  1207. LPCTSTR lpctstrAttachmentPath,
  1208. LPCTSTR lpctstrAttachmentMailFileName,
  1209. LPCTSTR lpctstrServer,
  1210. #ifdef __cplusplus // Provide default parameters values for C++ clients
  1211. DWORD dwPort = 25,
  1212. CDO_AUTH_TYPE AuthType = CDO_AUTH_ANONYMOUS,
  1213. LPCTSTR lpctstrUser = NULL,
  1214. LPCTSTR lpctstrPassword = NULL,
  1215. HANDLE hLoggedOnUserToken = NULL
  1216. #else
  1217. DWORD dwPort,
  1218. CDO_AUTH_TYPE AuthType,
  1219. LPCTSTR lpctstrUser,
  1220. LPCTSTR lpctstrPassword,
  1221. HANDLE hLoggedOnUserToken
  1222. #endif
  1223. );
  1224. //
  1225. // FAXAPI structures utils
  1226. //
  1227. #ifdef _FAXAPIP_
  1228. BOOL CopyPersonalProfile(
  1229. PFAX_PERSONAL_PROFILE lpDstProfile,
  1230. LPCFAX_PERSONAL_PROFILE lpcSrcProfile
  1231. );
  1232. void FreePersonalProfile (
  1233. PFAX_PERSONAL_PROFILE lpProfile,
  1234. BOOL bDestroy
  1235. );
  1236. #endif // _FAXAPIP_
  1237. //
  1238. // Tapi helper routines
  1239. //
  1240. #ifndef FAXUTIL_ADAPTIVE
  1241. #include <setupapi.h>
  1242. BOOL
  1243. IsDeviceModem (
  1244. LPLINEDEVCAPS lpLineCaps,
  1245. LPCTSTR lpctstrUnimodemTspName
  1246. );
  1247. LPLINEDEVCAPS
  1248. SmartLineGetDevCaps(
  1249. HLINEAPP hLineApp,
  1250. DWORD dwDeviceId,
  1251. DWORD dwAPIVersion
  1252. );
  1253. DWORD
  1254. GetFaxCapableTapiLinesCount (
  1255. LPDWORD lpdwCount,
  1256. LPCTSTR lpctstrUnimodemTspName
  1257. );
  1258. #endif
  1259. //
  1260. // RPC util functions
  1261. //
  1262. #define LOCAL_HOST_ADDRESS _T("127.0.0.1")
  1263. RPC_STATUS
  1264. GetRpcStringBindingInfo (
  1265. IN handle_t hBinding,
  1266. OUT LPTSTR* pptszNetworkAddress,
  1267. OUT LPTSTR* pptszProtSeq
  1268. );
  1269. RPC_STATUS
  1270. IsLocalRPCConnectionIpTcp(
  1271. handle_t hBinding,
  1272. PBOOL pbIsLocal
  1273. );
  1274. RPC_STATUS
  1275. IsLocalRPCConnectionNP( PBOOL pbIsLocal
  1276. );
  1277. //
  1278. // RPC debug functions
  1279. //
  1280. VOID
  1281. DumpRPCExtendedStatus ();
  1282. //
  1283. // The following macros are used to establish the semantics needed
  1284. // to do a return from within a try-finally clause. As a rule every
  1285. // try clause must end with a label call try_exit. For example,
  1286. //
  1287. // try {
  1288. // :
  1289. // :
  1290. //
  1291. // try_exit: NOTHING;
  1292. // } finally {
  1293. //
  1294. // :
  1295. // :
  1296. // }
  1297. //
  1298. // Every return statement executed inside of a try clause should use the
  1299. // try_return macro. If the compiler fully supports the try-finally construct
  1300. // then the macro should be
  1301. //
  1302. // #define try_return(S) { return(S); }
  1303. //
  1304. // If the compiler does not support the try-finally construct then the macro
  1305. // should be
  1306. //
  1307. // #define try_return(S) { S; goto try_exit; }
  1308. //
  1309. // This was borrowed from fatprocs.h
  1310. #ifdef DBG
  1311. #define try_fail(S) { DebugPrint(( TEXT("Failure in FILE %s LINE %d"), TEXT(__FILE__), __LINE__ )); S; goto try_exit; }
  1312. #else
  1313. #define try_fail(S) { S; goto try_exit; }
  1314. #endif
  1315. #define try_return(S) { S; goto try_exit; }
  1316. #define NOTHING
  1317. #ifdef __cplusplus
  1318. }
  1319. #endif
  1320. #endif