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.

396 lines
6.7 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. LPTSTR pszVendorInstaller;
  50. DWORD cbDriverInfo6;
  51. DRIVER_INFO_6 DriverInfo6;
  52. } PARSEINF_INFO, *PPARSEINF_INFO;
  53. typedef struct _PNP_INFO {
  54. LPTSTR pszPortName;
  55. LPTSTR pszDeviceInstanceId;
  56. } PNP_INFO, *PPNP_INFO;
  57. typedef struct _PSETUP_LOCAL_DATA {
  58. SELECTED_DRV_INFO DrvInfo;
  59. DWORD signature;
  60. DWORD Flags;
  61. PARSEINF_INFO InfInfo;
  62. PNP_INFO PnPInfo;
  63. } PSETUP_LOCAL_DATA;
  64. typedef BOOL (WINAPI* AllOCANDINITSID)(
  65. PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD,
  66. DWORD, DWORD, PSID
  67. );
  68. typedef BOOL (WINAPI* CHECKTOKENMEMBERSHIP)(
  69. HANDLE, PSID, PBOOL
  70. );
  71. typedef PVOID (WINAPI* FREESID)(
  72. PSID
  73. );
  74. extern CHAR szNetprnFile[];
  75. extern const GUID GUID_DEVCLASS_PRINTER;
  76. extern UPGRADE_DATA UpgradeData;
  77. extern OEM_UPGRADE_INFO OEMUpgradeInfo[];
  78. extern LPSTR pszNetPrnEntry;
  79. extern BOOL bDoNetPrnUpgrade;
  80. extern DWORD dwRunOnceCount;
  81. #define MAX_STRING_LEN MAX_PATH
  82. #define IDS_PRODUCTID 1001
  83. #define IDS_TITLE 1002
  84. #define IDS_DRIVERS_UPGRADE_FAILED 2001
  85. #define IDS_DRIVER_UPGRADE_FAILED 2002
  86. #define IDS_ADDDRIVER_FAILED 2003
  87. #define IDS_ICM_FAILED 2004
  88. #define IDS_DEFAULT_PRINTER_FAILED 2005
  89. #define IDS_ADDPRINTER_FAILED 2006
  90. #define IDS_ADDMONITOR_FAILED 2007
  91. #define IDS_PRINTER_CANT_MIGRATE 3001
  92. #define SIZECHARS(x) (sizeof((x))/sizeof(*x))
  93. #if DBG
  94. #define ASSERT(expr) if ( !(expr) ) DebugBreak();
  95. #else
  96. #define ASSERT(expr) ;
  97. #endif
  98. //
  99. // Debug functions
  100. //
  101. VOID
  102. DebugMsg(
  103. LPCSTR pszFormat,
  104. ...
  105. );
  106. //
  107. // Heap management
  108. //
  109. PVOID
  110. AllocMem(
  111. IN UINT cbSize
  112. );
  113. VOID
  114. FreeMem(
  115. IN PVOID pMem
  116. );
  117. LPSTR
  118. AllocStrA(
  119. IN LPCSTR pszStr
  120. );
  121. LPWSTR
  122. AllocStrW(
  123. IN LPCWSTR pszStr
  124. );
  125. LPWSTR
  126. AllocStrWFromStrA(
  127. LPCSTR pszStr
  128. );
  129. LPSTR
  130. AllocStrAFromStrW(
  131. LPCWSTR pszStr
  132. );
  133. VOID
  134. FreePrinterInfo2Strings(
  135. PPRINTER_INFO_2A pPrinterInfo2
  136. );
  137. //
  138. // Functions to write print config to the text file
  139. //
  140. VOID
  141. WriteToFile(
  142. HANDLE hFile,
  143. LPBOOL pbFail,
  144. LPCSTR pszFormat,
  145. ...
  146. );
  147. VOID
  148. WriteString(
  149. IN HANDLE hFile,
  150. IN OUT LPBOOL pbFail,
  151. IN LPCSTR pszStr
  152. );
  153. VOID
  154. WritePrinterInfo2(
  155. IN HANDLE hFile,
  156. IN LPPRINTER_INFO_2A pPrinterInfo2,
  157. IN LPSTR pszDriver,
  158. IN OUT LPBOOL pbFail
  159. );
  160. //
  161. // Functions to parse the text file having printing config info
  162. //
  163. LPSTR
  164. GetLine(
  165. IN HANDLE hFile,
  166. IN OUT LPBOOL pbFail
  167. );
  168. VOID
  169. ReadString(
  170. IN HANDLE hFile,
  171. IN LPSTR pszPrefix,
  172. OUT LPSTR *pszStr,
  173. IN BOOL bOptional,
  174. IN OUT LPBOOL pbFail
  175. );
  176. VOID
  177. ReadDword(
  178. IN HANDLE hFile,
  179. IN LPSTR pszLine,
  180. IN DWORD dwLineSize,
  181. IN LPSTR pszPrefix,
  182. OUT LPDWORD pdwValue,
  183. IN OUT LPBOOL pbFail
  184. );
  185. VOID
  186. ReadPrinterInfo2(
  187. IN HANDLE hFile,
  188. IN LPPRINTER_INFO_2A pPrinterInfo2,
  189. IN OUT LPBOOL pbFail
  190. );
  191. //
  192. // Misc stuff
  193. //
  194. VOID
  195. CopyFilesToWorkingDir(
  196. IN OUT LPBOOL pbFail
  197. );
  198. VOID
  199. CleanupDriverMapping(
  200. IN OUT HDEVINFO *phDevInfo,
  201. IN OUT HINF *phNtInf,
  202. IN OUT HINF *phUpgInf
  203. );
  204. VOID
  205. InitDriverMapping(
  206. OUT HDEVINFO *phDevInfo,
  207. OUT HINF *phNtInf,
  208. OUT HINF *phUpgInf,
  209. IN OUT LPBOOL pbFail
  210. );
  211. BOOL
  212. InitFileCopyOnNT(
  213. IN HDEVINFO hDevInfo
  214. );
  215. BOOL
  216. CommitFileQueueToCopyFiles(
  217. IN HDEVINFO hDevInfo
  218. );
  219. LPSTR
  220. ErrorMsg(
  221. VOID
  222. );
  223. VOID
  224. LogError(
  225. IN LogSeverity Severity,
  226. IN UINT MessageId,
  227. ...
  228. );
  229. LPSTR
  230. GetStringFromRcFileA(
  231. IN UINT uId
  232. );
  233. VOID
  234. SetupNetworkPrinterUpgrade(
  235. IN LPCSTR pszWorkingDir
  236. );
  237. BOOL
  238. ProcessNetPrnUpgradeForUser(
  239. HKEY hKeyUser
  240. );
  241. DWORD
  242. MySetDefaultPrinter(
  243. IN HKEY hUserRegKey,
  244. IN LPSTR pszDefaultPrinterString
  245. );
  246. VOID
  247. WriteRunOnceCount(
  248. );
  249. LPSTR
  250. GetDefPrnString(
  251. IN LPCSTR pszPrinterName
  252. );
  253. CHAR
  254. My_fgetc(
  255. HANDLE hFile
  256. );
  257. LPSTR
  258. My_fgets(
  259. LPSTR pszBuf,
  260. DWORD dwSize,
  261. HANDLE hFile
  262. );
  263. DWORD
  264. My_fread(
  265. LPBYTE pBuf,
  266. DWORD dwSize,
  267. HANDLE hFile
  268. );
  269. BOOL
  270. My_ungetc(
  271. HANDLE hFile
  272. );
  273. DWORD
  274. GetFileNameInSpoolDir(
  275. IN LPSTR szBuf,
  276. IN DWORD cchBuf,
  277. IN LPSTR pszFileName
  278. );
  279. LPSTR
  280. GetVendorSetupRunOnceValueToSet(
  281. VOID
  282. );
  283. LONG
  284. WriteVendorSetupInfoInRegistry(
  285. IN CHAR *pszVendorSetup,
  286. IN CHAR *pszPrinterName
  287. );
  288. LONG
  289. RemoveVendorSetupInfoFromRegistry(
  290. VOID
  291. );
  292. VOID
  293. CallVendorSetupDlls(
  294. VOID
  295. );
  296. BOOL
  297. IsLocalAdmin(
  298. BOOL *pbAdmin
  299. );
  300. LONG
  301. DecrementVendorSetupEnumerator(
  302. VOID
  303. );
  304. BOOL
  305. MakeACopyOfMigrateDll(
  306. IN LPCSTR pszWorkingDir
  307. );
  308. HMODULE LoadLibraryUsingFullPathW(
  309. LPCTSTR lpFileName
  310. );
  311. HMODULE LoadLibraryUsingFullPathA(
  312. LPCTSTR lpFileName
  313. );