Source code of Windows XP (NT5)
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.

449 lines
9.3 KiB

  1. /*++
  2. Copyright (c) 1990 - 1995 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. splcom.h
  6. Abstract:
  7. Header file for Common Routines in the Spooler.
  8. Note -- link with spoolss.lib to find these routines
  9. Author:
  10. Krishna Ganugapati (KrishnaG) 02-Feb-1994
  11. Revision History:
  12. --*/
  13. #ifndef _SPLCOM
  14. #define _SPLCOM
  15. #include "spllib.hxx"
  16. //
  17. // Include necessary for PATTRIBUTE_INFO_3, parameter in GetJobAttributes
  18. // which was moved from prtprocs\winprint to spoolss\dll
  19. //
  20. #include <winddiui.h>
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. //
  25. // This assumes that addr is an LPBYTE type.
  26. //
  27. #define WORD_ALIGN_DOWN(addr) ((LPBYTE)((ULONG_PTR)addr &= ~1))
  28. #define DWORD_ALIGN_UP(size) (((size)+3)&~3)
  29. #define DWORD_ALIGN_DOWN(size) ((size)&~3)
  30. #define ALIGN_UP(addr, type) ((type) ((ULONG_PTR) (addr) + (sizeof(type) - 1))&~(sizeof(type) - 1))
  31. #define ALIGN_DOWN(addr, type) ((type) ((ULONG_PTR) (addr) & ~(sizeof(type) - 1)))
  32. #define ALIGN_PTR_UP(addr) ALIGN_UP(addr, ULONG_PTR)
  33. #define ALIGN_PTR_DOWN(addr) ALIGN_DOWN(addr, ULONG_PTR)
  34. //
  35. // BitMap macros, assumes map is a DWORD array
  36. //
  37. #define MARKUSE(map, pos) ((map)[(pos) / 32] |= (1 << ((pos) % 32) ))
  38. #define MARKOFF(map, pos) ((map)[(pos) / 32] &= ~(1 << ((pos) % 32) ))
  39. #define ISBITON(map, id) ((map)[id / 32] & ( 1 << ((id) % 32) ) )
  40. #define BROADCAST_TYPE_MESSAGE 1
  41. #define BROADCAST_TYPE_CHANGEDEFAULT 2
  42. VOID
  43. UpdatePrinterRegAll(
  44. LPWSTR pszPrinterName,
  45. LPWSTR pszPort,
  46. BOOL bDelete
  47. );
  48. #define UPDATE_REG_CHANGE FALSE
  49. #define UPDATE_REG_DELETE TRUE
  50. #if defined(_MIPS_)
  51. #define LOCAL_ENVIRONMENT L"Windows NT R4000"
  52. #elif defined(_AXP64_)
  53. #define LOCAL_ENVIRONMENT L"Windows Alpha_AXP64"
  54. #elif defined(_ALPHA_)
  55. #define LOCAL_ENVIRONMENT L"Windows NT Alpha_AXP"
  56. #elif defined(_PPC_)
  57. #define LOCAL_ENVIRONMENT L"Windows NT PowerPC"
  58. #elif defined(_IA64_)
  59. #define LOCAL_ENVIRONMENT L"Windows IA64"
  60. #else
  61. #define LOCAL_ENVIRONMENT L"Windows NT x86"
  62. #endif
  63. #define SPOOLER_VERSION 3
  64. #define NOTIFICATION_VERSION 2
  65. #define DSPRINTQUEUE_VERSION SPOOLER_VERSION
  66. //
  67. // Flags for ResetPrinterEx
  68. //
  69. #define RESET_PRINTER_DATATYPE 0x00000001
  70. #define RESET_PRINTER_DEVMODE 0x00000002
  71. VOID
  72. SplShutDownRouter(
  73. VOID
  74. );
  75. PVOID
  76. MIDL_user_allocate1 (
  77. IN size_t NumBytes
  78. );
  79. VOID
  80. MIDL_user_free1 (
  81. IN void *MemPointer
  82. );
  83. BOOL
  84. BroadcastMessage(
  85. DWORD dwType,
  86. DWORD dwMessage,
  87. WPARAM wParam,
  88. LPARAM lParam
  89. );
  90. VOID
  91. DllSetFailCount(
  92. DWORD FailCount
  93. );
  94. LPVOID
  95. DllAllocSplMem(
  96. DWORD cb
  97. );
  98. BOOL
  99. DllFreeSplMem(
  100. LPVOID pMem
  101. );
  102. LPVOID
  103. ReallocSplMem(
  104. LPVOID lpOldMem,
  105. DWORD cbOld,
  106. DWORD cbNew
  107. );
  108. LPWSTR
  109. AllocSplStr(
  110. LPCWSTR lpStr
  111. );
  112. BOOL
  113. DllFreeSplStr(
  114. LPWSTR lpStr
  115. );
  116. BOOL
  117. ReallocSplStr(
  118. LPWSTR *plpStr,
  119. LPCWSTR lpStr
  120. );
  121. LPVOID
  122. AlignRpcPtr (
  123. LPVOID pBuffer,
  124. LPDWORD pcbBuf
  125. );
  126. VOID
  127. UndoAlignRpcPtr (
  128. LPVOID pBuffer,
  129. LPVOID pAligned,
  130. SIZE_T cbSize,
  131. LPDWORD pcbNeeded
  132. );
  133. VOID
  134. UndoAlignKMPtr (
  135. LPVOID pDestination,
  136. LPVOID pSource
  137. );
  138. LPVOID
  139. AlignKMPtr (
  140. LPVOID pBuffer,
  141. DWORD cbBuf
  142. );
  143. LPBYTE
  144. PackStrings(
  145. LPWSTR *pSource,
  146. LPBYTE pDest,
  147. DWORD *DestOffsets,
  148. LPBYTE pEnd
  149. );
  150. BOOL
  151. IsNamedPipeRpcCall(
  152. VOID
  153. );
  154. BOOL
  155. IsLocalCall(
  156. VOID
  157. );
  158. HKEY
  159. GetClientUserHandle(
  160. IN REGSAM samDesired
  161. );
  162. VOID
  163. UpdatePrinterRegAll(
  164. LPWSTR pPrinterName,
  165. LPWSTR pszValue,
  166. BOOL bGenerateNetId
  167. );
  168. DWORD
  169. UpdatePrinterRegUser(
  170. HKEY hKey,
  171. LPWSTR pszKey,
  172. LPWSTR pPrinterName,
  173. LPWSTR pszValue,
  174. BOOL bGenerateNetId
  175. );
  176. DWORD
  177. GetNetworkId(
  178. HKEY hKeyUser,
  179. LPWSTR pDeviceName);
  180. HANDLE
  181. LoadDriverFiletoConvertDevmode(
  182. IN LPWSTR pDriverFile
  183. );
  184. HANDLE
  185. LoadDriver(
  186. LPWSTR pDriverFile
  187. );
  188. VOID
  189. UnloadDriver(
  190. HANDLE hModule
  191. );
  192. VOID
  193. UnloadDriverFile(
  194. IN OUT HANDLE hDevModeChgInfo
  195. );
  196. BOOL
  197. SplIsUpgrade(
  198. VOID
  199. );
  200. BOOL
  201. SpoolerHasInitialized(
  202. VOID
  203. );
  204. //
  205. // DWORD used instead of NTSTATUS to prevent including NT headers.
  206. //
  207. VOID
  208. SplLogEventExternal(
  209. IN WORD EventType,
  210. IN DWORD EventID,
  211. IN LPWSTR pFirstString,
  212. ...
  213. );
  214. typedef
  215. DWORD
  216. (*PFN_QUERYREMOVE_CALLBACK)(
  217. LPVOID
  218. );
  219. HANDLE
  220. SplRegisterForDeviceEvents(
  221. HANDLE hDevice,
  222. LPVOID pData,
  223. PFN_QUERYREMOVE_CALLBACK pfnQueryRemove
  224. );
  225. BOOL
  226. SplUnregisterForDeviceEvents(
  227. HANDLE hNotify
  228. );
  229. DWORD
  230. CallDrvDevModeConversion(
  231. IN HANDLE pfnConvertDevMode,
  232. IN LPWSTR pszPrinterName,
  233. IN LPBYTE pInDevMode,
  234. IN OUT LPBYTE *pOutDevMode,
  235. IN OUT LPDWORD pdwOutDevModeSize,
  236. IN DWORD dwConvertMode,
  237. IN BOOL bAlloc
  238. );
  239. typedef struct _pfnWinSpoolDrv {
  240. BOOL (*pfnOpenPrinter)(LPTSTR, LPHANDLE, LPPRINTER_DEFAULTS);
  241. BOOL (*pfnClosePrinter)(HANDLE);
  242. BOOL (*pfnDevQueryPrint)(HANDLE, LPDEVMODE, DWORD *, LPWSTR, DWORD);
  243. BOOL (*pfnPrinterEvent)(LPWSTR, INT, DWORD, LPARAM);
  244. LONG (*pfnDocumentProperties)(HWND, HANDLE, LPWSTR, PDEVMODE, PDEVMODE, DWORD);
  245. HANDLE (*pfnLoadPrinterDriver)(HANDLE);
  246. HANDLE (*pfnRefCntLoadDriver)(LPWSTR, DWORD, DWORD, BOOL);
  247. BOOL (*pfnRefCntUnloadDriver)(HANDLE, BOOL);
  248. BOOL (*pfnForceUnloadDriver)(LPWSTR);
  249. } fnWinSpoolDrv, *pfnWinSpoolDrv;
  250. BOOL
  251. SplInitializeWinSpoolDrv(
  252. pfnWinSpoolDrv pfnList
  253. );
  254. BOOL
  255. GetJobAttributes(
  256. LPWSTR pPrinterName,
  257. LPDEVMODEW pDevmode,
  258. PATTRIBUTE_INFO_3 pAttributeInfo
  259. );
  260. #if 1
  261. #define AllocSplMem( cb ) DllAllocSplMem( cb )
  262. #define FreeSplMem( pMem ) DllFreeSplMem( pMem )
  263. #define FreeSplStr( lpStr ) DllFreeSplStr( lpStr )
  264. #else
  265. #define AllocSplMem( cb ) LocalAlloc( LPTR, cb )
  266. #define FreeSplMem( pMem ) (LocalFree( pMem ) ? FALSE:TRUE)
  267. #define FreeSplStr( lpStr ) ((lpStr) ? (LocalFree(lpStr) ? FALSE:TRUE):TRUE)
  268. #endif
  269. // Spooler treats MAX_PATH as including NULL terminator
  270. #define MAX_PRINTER_NAME MAX_PATH
  271. // Maximum size PrinterName ( including the ServerName ).
  272. // "\\MAX_COMPUTER_NAME_LENGTH\MAX_PRINTER_NAME" NULL Terminated
  273. #define MAX_UNC_PRINTER_NAME ( 2 + INTERNET_MAX_HOST_NAME_LENGTH + 1 + MAX_PRINTER_NAME )
  274. // "\\MAX_PRINTER_NAME,DriverName,Location"
  275. #define MAX_PRINTER_BROWSE_NAME ( MAX_UNC_PRINTER_NAME + 1 + MAX_PATH + 1 + MAX_PATH )
  276. //
  277. // Suffix string for hidden printers
  278. // (e.g., ", Job 00322" or ", Port" or ", LocalOnly")
  279. //
  280. #define PRINTER_NAME_SUFFIX_MAX 20
  281. #define NUMBER_OF_DRV_INFO_6_STRINGS 14
  282. #define MAX_PRINTER_INFO1 ( (MAX_PRINTER_BROWSE_NAME + MAX_UNC_PRINTER_NAME + MAX_PATH) *sizeof(WCHAR) + sizeof( PRINTER_INFO_1) )
  283. #define MAX_DRIVER_INFO_2 ( 5*MAX_PATH*sizeof(WCHAR) + sizeof( DRIVER_INFO_2 ) )
  284. #define MAX_DRIVER_INFO_3 ( 8*MAX_PATH*sizeof(WCHAR) + sizeof( DRIVER_INFO_3 ) )
  285. #define MAX_DRIVER_INFO_6 ( NUMBER_OF_DRV_INFO_6_STRINGS*MAX_PATH*sizeof(WCHAR) + sizeof( DRIVER_INFO_6 ) )
  286. #define MAX_DRIVER_INFO_VERSION ( NUMBER_OF_DRV_INFO_6_STRINGS*MAX_PATH*sizeof(DRIVER_FILE_INFO)*sizeof(WCHAR) + sizeof( DRIVER_INFO_VERSION ) )
  287. // NT Server Spooler base priority
  288. #define SPOOLSS_SERVER_BASE_PRIORITY 9
  289. #define SPOOLSS_WORKSTATION_BASE_PRIORITY 7
  290. #define MIN_DEVMODE_SIZEW 72
  291. #define MIN_DEVMODE_SIZEA 40
  292. //
  293. // PrinterData value keys for the server handle
  294. //
  295. #define SPLREG_W3SVCINSTALLED TEXT("W3SvcInstalled")
  296. //
  297. // If SPOOLER_REG_SYSTEM is not defined then setup moves the Printers data to
  298. // HKLM\Software\Microsoft\Windows NT\CurrentVersion\Print\Printers during an
  299. // upgrade or clean install. The spooler will then migrate the keys back to
  300. // HKLM\System\CurrentControlSet\Control\Print\Printers when it starts up for
  301. // the first time.
  302. //
  303. #define SPOOLER_REG_SYSTEM
  304. //
  305. // Event logging constants
  306. //
  307. #define LOG_ERROR EVENTLOG_ERROR_TYPE
  308. #define LOG_WARNING EVENTLOG_WARNING_TYPE
  309. #define LOG_INFO EVENTLOG_INFORMATION_TYPE
  310. #define LOG_SUCCESS EVENTLOG_AUDIT_SUCCESS
  311. #define LOG_FAILURE EVENTLOG_AUDIT_FAILURE
  312. #define LOG_ALL_EVENTS ( LOG_ERROR | LOG_WARNING | LOG_INFO | LOG_SUCCESS | LOG_FAILURE )
  313. #define LOG_DEFAULTS_WORKSTATION_EVENTS ( LOG_ERROR | LOG_WARNING | LOG_SUCCESS | LOG_FAILURE )
  314. typedef struct _DRIVER_INFO_7A {
  315. DWORD cbSize;
  316. DWORD cVersion;
  317. LPSTR pszDriverName;
  318. LPSTR pszInfName;
  319. LPSTR pszInstallSourceRoot;
  320. } DRIVER_INFO_7A, *PDRIVER_INFO_7A, *LPDRIVER_INFO_7A;
  321. typedef struct _DRIVER_INFO_7W {
  322. DWORD cbSize;
  323. DWORD cVersion;
  324. LPWSTR pszDriverName;
  325. LPWSTR pszInfName;
  326. LPWSTR pszInstallSourceRoot;
  327. } DRIVER_INFO_7W, *PDRIVER_INFO_7W, *LPDRIVER_INFO_7W;
  328. #ifdef UNICODE
  329. typedef DRIVER_INFO_7W DRIVER_INFO_7;
  330. typedef PDRIVER_INFO_7W PDRIVER_INFO_7;
  331. typedef LPDRIVER_INFO_7W LPDRIVER_INFO_7;
  332. #else
  333. typedef DRIVER_INFO_7A DRIVER_INFO_7;
  334. typedef PDRIVER_INFO_7A PDRIVER_INFO_7;
  335. typedef LPDRIVER_INFO_7A LPDRIVER_INFO_7;
  336. #endif // UNICODE
  337. //
  338. // The initial commit for the stack is 3 pages on IA64 and 4 pages on X86
  339. //
  340. //
  341. // This reserves 32KB for in-proc server stack on x86 and 48KB for IA64.
  342. //
  343. #ifdef _IA64_
  344. #define INITIAL_STACK_COMMIT (6 * 0x2000)
  345. #else
  346. #define INITIAL_STACK_COMMIT (8 * 0x1000)
  347. #endif
  348. #define LARGE_INITIAL_STACK_COMMIT (64 * 1024)
  349. #ifdef __cplusplus
  350. }
  351. #endif
  352. #endif // for #ifndef _SPLCOM