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.

395 lines
7.1 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. local.h
  6. Abstract:
  7. Utility functions for Win95 upgrade of printing
  8. Author:
  9. Muhunthan Sivapragasam (MuhuntS) 15-Jan-1997
  10. Revision History:
  11. --*/
  12. //
  13. // Type definitions
  14. //
  15. typedef struct _UPGRADE_DATA {
  16. HINSTANCE hInst;
  17. LPSTR pszDir;
  18. LPSTR pszProductId;
  19. LPSTR pszSourceA;
  20. LPWSTR pszSourceW;
  21. } UPGRADE_DATA, *PUPGRADE_DATA;
  22. typedef struct _OEM_UPGRADE_INFO {
  23. LPSTR pszModuleName;
  24. HMODULE hModule;
  25. } OEM_UPGRADE_INFO, *POEM_UPGRADE_INFO;
  26. typedef struct _UPGRADABLE_LIST {
  27. LPSTR pszName;
  28. } UPGRADABLE_LIST, *PUPGRADABLE_LIST;
  29. typedef struct _SELECTED_DRV_INFO {
  30. LPTSTR pszInfName;
  31. LPTSTR pszModelName;
  32. LPTSTR pszDriverSection;
  33. PSP_DEVINFO_DATA pDevInfoData;
  34. LPTSTR pszHardwareID;
  35. LPTSTR pszManufacturer;
  36. LPTSTR pszOEMUrl;
  37. LPTSTR pszProvider;
  38. FILETIME ftDriverDate;
  39. DWORDLONG dwlDriverVersion;
  40. DWORD Flags;
  41. LPTSTR pszzPreviousNames;
  42. } SELECTED_DRV_INFO, *PSELECTED_DRV_INFO;
  43. typedef struct _PARSEINF_INFO {
  44. PLATFORM platform;
  45. LPTSTR pszInstallSection; // Can be platform dependent
  46. LPTSTR pszzICMFiles;
  47. LPTSTR pszPrintProc;
  48. LPTSTR pszVendorSetup;
  49. DWORD cbDriverInfo6;
  50. DRIVER_INFO_6 DriverInfo6;
  51. } PARSEINF_INFO, *PPARSEINF_INFO;
  52. typedef struct _PNP_INFO {
  53. LPTSTR pszPortName;
  54. LPTSTR pszDeviceInstanceId;
  55. } PNP_INFO, *PPNP_INFO;
  56. typedef struct _PSETUP_LOCAL_DATA {
  57. SELECTED_DRV_INFO DrvInfo;
  58. DWORD signature;
  59. DWORD Flags;
  60. PARSEINF_INFO InfInfo;
  61. PNP_INFO PnPInfo;
  62. } PSETUP_LOCAL_DATA;
  63. typedef BOOL (WINAPI* AllOCANDINITSID)(
  64. PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD,
  65. DWORD, DWORD, PSID
  66. );
  67. typedef BOOL (WINAPI* CHECKTOKENMEMBERSHIP)(
  68. HANDLE, PSID, PBOOL
  69. );
  70. typedef PVOID (WINAPI* FREESID)(
  71. PSID
  72. );
  73. extern CHAR szNetprnFile[];
  74. extern const GUID GUID_DEVCLASS_PRINTER;
  75. extern UPGRADE_DATA UpgradeData;
  76. extern OEM_UPGRADE_INFO OEMUpgradeInfo[];
  77. extern LPSTR pszNetPrnEntry;
  78. extern BOOL bDoNetPrnUpgrade;
  79. extern DWORD dwRunOnceCount;
  80. #define MAX_STRING_LEN MAX_PATH
  81. #define IDS_PRODUCTID 1001
  82. #define IDS_TITLE 1002
  83. #define IDS_DRIVERS_UPGRADE_FAILED 2001
  84. #define IDS_DRIVER_UPGRADE_FAILED 2002
  85. #define IDS_ADDDRIVER_FAILED 2003
  86. #define IDS_ICM_FAILED 2004
  87. #define IDS_DEFAULT_PRINTER_FAILED 2005
  88. #define IDS_ADDPRINTER_FAILED 2006
  89. #define IDS_ADDMONITOR_FAILED 2007
  90. #define IDS_PRINTER_CANT_MIGRATE 3001
  91. #define SIZECHARS(x) (sizeof((x))/sizeof(*x))
  92. #if DBG
  93. #define ASSERT(expr) if ( !(expr) ) DebugBreak();
  94. #else
  95. #define ASSERT(expr) ;
  96. #endif
  97. //
  98. // Debug functions
  99. //
  100. VOID
  101. DebugMsg(
  102. LPCSTR pszFormat,
  103. ...
  104. );
  105. //
  106. // Heap management
  107. //
  108. PVOID
  109. AllocMem(
  110. IN UINT cbSize
  111. );
  112. VOID
  113. FreeMem(
  114. IN PVOID pMem
  115. );
  116. LPSTR
  117. AllocStrA(
  118. IN LPCSTR pszStr
  119. );
  120. LPWSTR
  121. AllocStrW(
  122. IN LPCWSTR pszStr
  123. );
  124. LPWSTR
  125. AllocStrWFromStrA(
  126. LPCSTR pszStr
  127. );
  128. LPSTR
  129. AllocStrAFromStrW(
  130. LPCWSTR pszStr
  131. );
  132. VOID
  133. FreePrinterInfo2Strings(
  134. PPRINTER_INFO_2A pPrinterInfo2
  135. );
  136. //
  137. // Functions to write print config to the text file
  138. //
  139. VOID
  140. WriteToFile(
  141. HANDLE hFile,
  142. LPBOOL pbFail,
  143. LPCSTR pszFormat,
  144. ...
  145. );
  146. VOID
  147. WriteString(
  148. IN HANDLE hFile,
  149. IN OUT LPBOOL pbFail,
  150. IN LPCSTR pszStr
  151. );
  152. VOID
  153. WritePrinterInfo2(
  154. IN HANDLE hFile,
  155. IN LPPRINTER_INFO_2A pPrinterInfo2,
  156. IN LPSTR pszDriver,
  157. IN OUT LPBOOL pbFail
  158. );
  159. //
  160. // Functions to parse the text file having printing config info
  161. //
  162. LPSTR
  163. GetLine(
  164. IN HANDLE hFile,
  165. IN OUT LPBOOL pbFail
  166. );
  167. VOID
  168. ReadString(
  169. IN HANDLE hFile,
  170. IN LPSTR pszPrefix,
  171. OUT LPSTR *pszStr,
  172. IN BOOL bOptional,
  173. IN OUT LPBOOL pbFail
  174. );
  175. VOID
  176. ReadDword(
  177. IN HANDLE hFile,
  178. IN LPSTR pszLine,
  179. IN DWORD dwLineSize,
  180. IN LPSTR pszPrefix,
  181. OUT LPDWORD pdwValue,
  182. IN OUT LPBOOL pbFail
  183. );
  184. VOID
  185. ReadPrinterInfo2(
  186. IN HANDLE hFile,
  187. IN LPPRINTER_INFO_2A pPrinterInfo2,
  188. IN OUT LPBOOL pbFail
  189. );
  190. //
  191. // Misc stuff
  192. //
  193. VOID
  194. CopyFilesToWorkingDir(
  195. IN OUT LPBOOL pbFail
  196. );
  197. VOID
  198. CleanupDriverMapping(
  199. IN OUT HDEVINFO *phDevInfo,
  200. IN OUT HINF *phNtInf,
  201. IN OUT HINF *phUpgInf
  202. );
  203. VOID
  204. InitDriverMapping(
  205. OUT HDEVINFO *phDevInfo,
  206. OUT HINF *phNtInf,
  207. OUT HINF *phUpgInf,
  208. IN OUT LPBOOL pbFail
  209. );
  210. BOOL
  211. InitFileCopyOnNT(
  212. IN HDEVINFO hDevInfo
  213. );
  214. BOOL
  215. CommitFileQueueToCopyFiles(
  216. IN HDEVINFO hDevInfo
  217. );
  218. LPSTR
  219. ErrorMsg(
  220. VOID
  221. );
  222. VOID
  223. LogError(
  224. IN LogSeverity Severity,
  225. IN UINT MessageId,
  226. ...
  227. );
  228. LPSTR
  229. GetStringFromRcFileA(
  230. IN UINT uId
  231. );
  232. VOID
  233. SetupNetworkPrinterUpgrade(
  234. IN LPCSTR pszWorkingDir
  235. );
  236. BOOL
  237. ProcessNetPrnUpgradeForUser(
  238. HKEY hKeyUser
  239. );
  240. DWORD
  241. MySetDefaultPrinter(
  242. IN HKEY hUserRegKey,
  243. IN LPSTR pszDefaultPrinterString
  244. );
  245. VOID
  246. WriteRunOnceCount(
  247. );
  248. LPSTR
  249. GetDefPrnString(
  250. IN LPCSTR pszPrinterName
  251. );
  252. CHAR
  253. My_fgetc(
  254. HANDLE hFile
  255. );
  256. LPSTR
  257. My_fgets(
  258. LPSTR pszBuf,
  259. DWORD dwSize,
  260. HANDLE hFile
  261. );
  262. DWORD
  263. My_fread(
  264. LPBYTE pBuf,
  265. DWORD dwSize,
  266. HANDLE hFile
  267. );
  268. BOOL
  269. My_ungetc(
  270. HANDLE hFile
  271. );
  272. DWORD
  273. GetFileNameInSpoolDir(
  274. IN LPSTR szBuf,
  275. IN DWORD cchBuf,
  276. IN LPSTR pszFileName
  277. );
  278. LPSTR
  279. GetVendorSetupRunOnceValueToSet(
  280. VOID
  281. );
  282. LONG
  283. WriteVendorSetupInfoInRegistry(
  284. IN CHAR *pszVendorSetup,
  285. IN CHAR *pszPrinterName
  286. );
  287. LONG
  288. RemoveVendorSetupInfoFromRegistry(
  289. VOID
  290. );
  291. VOID
  292. CallVendorSetupDlls(
  293. VOID
  294. );
  295. BOOL
  296. IsLocalAdmin(
  297. BOOL *pbAdmin
  298. );
  299. LONG
  300. DecrementVendorSetupEnumerator(
  301. VOID
  302. );
  303. BOOL
  304. MakeACopyOfMigrateDll(
  305. IN LPCSTR pszWorkingDir
  306. );
  307. HMODULE LoadLibraryUsingFullPathW(
  308. LPCTSTR lpFileName
  309. );
  310. HMODULE LoadLibraryUsingFullPathA(
  311. LPCTSTR lpFileName
  312. );