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.

507 lines
11 KiB

  1. #ifndef _UNATTEND_H_
  2. #define _UNATTEND_H_
  3. #define MAX_BUF MAX_INF_STRING_LENGTH
  4. typedef enum _UNATTENDTYPE {
  5. UAT_STRING,
  6. UAT_LONGINT,
  7. UAT_BOOLEAN,
  8. UAT_NONE,
  9. } UNATTENDTYPE;
  10. //
  11. // Each possible Answer from the unattended file must have a
  12. // corresponding enumerated type present in this typedef.
  13. // This is required since it is the method by which Pages
  14. // can be assured that they point to the correct answer
  15. //
  16. typedef enum _UNATTENDENTRIES {
  17. UAE_PROGRAM, // DetachedProgram
  18. UAE_ARGUMENT, // Arguments
  19. UAE_TIMEZONE, // TimeZone
  20. UAE_FULLNAME, // FullName
  21. UAE_ORGNAME, // OrgName
  22. UAE_COMPNAME, // Computer Name
  23. UAE_ADMINPASS, // Administrator Password
  24. UAE_PRODID, // Product ID
  25. UAE_MODE, // SetupMode
  26. UAE_AUTOLOGON, // autoadminlogon
  27. UAE_PROFILESDIR, // Profiles directory
  28. UAE_PROGRAMFILES, // Program Files directory
  29. UAE_COMMONPROGRAMFILES, // Program Files\Common Files directory
  30. UAE_PROGRAMFILES_X86, // Program Files (x86) directory
  31. UAE_COMMONPROGRAMFILES_X86, // Program Files\Common Files (x86) directory
  32. } UNATTENDENTRIES;
  33. #ifndef MIDL_PASS
  34. struct _UNATTENDANSWER;
  35. struct _UNATTENDITEM;
  36. struct _UNATTENDPAGE;
  37. struct _UNATTENDWIZARD;
  38. #endif
  39. //
  40. // This is the callback function that checks wether or not an
  41. // answer is valid. Called automatically by UnattendFindAnswer
  42. //
  43. typedef
  44. BOOL
  45. (* LPFNCHECKVALID)(
  46. struct _UNATTENDANSWER *rec
  47. );
  48. //
  49. // This is the callback function that is used to special case
  50. // the activation code. Really useful for those dialog boxes
  51. // which include check boxes, radio buttons, etc, etc.
  52. //
  53. typedef
  54. BOOL
  55. (* LPFNSETACTIVE)(
  56. HWND hwnd,
  57. DWORD contextinfo,
  58. struct _UNATTENDITEM *item
  59. );
  60. //
  61. // This structure is used to determine where and how to find
  62. // an answer and also to determine wether or not that answer
  63. // is present, of the correct type, etc, etc. This structure
  64. // should never be used by anything other then the unattend
  65. // module.
  66. //
  67. typedef struct _UNATTENDANSWER {
  68. //
  69. // Unique identifier for this answer.
  70. //
  71. UNATTENDENTRIES AnswerId;
  72. //
  73. // Has the answer been found in the unattend file and
  74. // is it known to be of the correct 'format'
  75. //
  76. BOOL Present;
  77. //
  78. // Is the answer absolutely required for setup to work?
  79. //
  80. BOOL Required;
  81. //
  82. // Was there an error in parsing the string? If so it might
  83. // be appropriate to display a message box notifying the
  84. // user of this condition
  85. //
  86. BOOL ParseErrors;
  87. //
  88. // The Answer structure. Since there are several possible
  89. // types, from string to numbers, a union is required
  90. //
  91. union {
  92. PWSTR String;
  93. LONG Num;
  94. BOOL Bool;
  95. } Answer;
  96. //
  97. // The following 3 items are the implementation dependant
  98. // portion of this structure. Each pointer points to
  99. // a string which is used in a GetPrivateProfile call.
  100. // Note that it is important to keep these as constant
  101. // pointers and that they will have to be changed when
  102. // an OLE model is implemented.
  103. //
  104. const PCWSTR Section;
  105. const PCWSTR Key;
  106. const PCWSTR DefaultAnswer;
  107. //
  108. // This specifies which of the members in the union is
  109. // the one we want ie: is it a string, an int, or a bool?
  110. //
  111. UNATTENDTYPE Type;
  112. //
  113. // This callback function is called so that the validity
  114. // of the answer can be determined
  115. //
  116. LPFNCHECKVALID pfnCheckValid;
  117. } UNATTENDANSWER, *PUNATTENDANSWER;
  118. //
  119. // Each item on a dialog page must be represented by the following
  120. // structure. An array of items is built and is stored in the
  121. // structure for the page
  122. //
  123. typedef struct _UNATTENDITEM {
  124. //
  125. // Specifies the control id of item so that we can send
  126. // messages to it
  127. //
  128. DWORD ControlId;
  129. //
  130. // Reserved for special message passing
  131. //
  132. DWORD Reserved1;
  133. //
  134. // Reserved for special message passing
  135. //
  136. DWORD Reserved2;
  137. //
  138. // Callback function to call when we are trying to set active
  139. // the dialog. Really useful in the case radio and check boxes.
  140. //
  141. LPFNSETACTIVE pfnSetActive;
  142. //
  143. // Pointer to the answer which is associated with this item
  144. //
  145. PUNATTENDANSWER Item;
  146. } UNATTENDITEM, *PUNATTENDITEM;
  147. //
  148. // Each page in the wizard must have one of the following structures
  149. // filled out to describe its contents
  150. //
  151. typedef struct _UNATTENDPAGE {
  152. //
  153. // The IDD of the dialog page
  154. // Required so that we can correspond to a dialog box
  155. //
  156. DWORD PageId;
  157. //
  158. // RUN TIME Flag that determines if we show the page to the user
  159. // Is determined by wether or not the answer is present and correct
  160. //
  161. BOOL ShowPage;
  162. //
  163. // Wether or not the page has been loaded once. Since we only
  164. // want to copy the answer to the screen once, this acts as a
  165. // sentry
  166. //
  167. BOOL LoadPage;
  168. //
  169. // After we have loaded the page, should we show it no matter what?
  170. // Useful for the title and finish pages
  171. //
  172. BOOL NeverSkip;
  173. //
  174. // How many items we have on the page
  175. //
  176. UINT ItemCount;
  177. //
  178. // Pointer to an array of items of size ItemCount
  179. //
  180. PUNATTENDITEM Item;
  181. } UNATTENDPAGE, *PUNATTENDPAGE;
  182. //
  183. // Information structure about how the unattended operation for the Wizard
  184. // is proceeding
  185. //
  186. typedef struct _UNATTENDWIZARD {
  187. //
  188. // Wether or not we should show the wizard -- IGNORED since TedM
  189. // doesn't want to duplicated the code in PSN_WIZNEXT. Kept for
  190. // Future use
  191. //
  192. BOOL ShowWizard;
  193. //
  194. // Flag that indicates that we have filled the array of answers
  195. // specified in this structure. Since we ideally once want to do
  196. // this once...
  197. //
  198. BOOL Initialized;
  199. //
  200. // Wether or not the ENTIRE unattended operation was successful.
  201. // If he required a single input from the user, then it was not.
  202. // Determines if the 'finish' page is a place were the user must
  203. // supply some input
  204. //
  205. BOOL Successful;
  206. //
  207. // How many pages we have information about
  208. //
  209. UINT PageCount;
  210. //
  211. // Pointer to an array of pages
  212. //
  213. PUNATTENDPAGE Page;
  214. //
  215. // How many answer we have to fill
  216. //
  217. UINT AnswerCount;
  218. //
  219. // Pointer to an array of answers that are to be used
  220. //
  221. PUNATTENDANSWER Answer;
  222. } UNATTENDWIZARD, *PUNATTENDWIZARD;
  223. //
  224. // Global pointer to the answer file
  225. //
  226. extern WCHAR AnswerFile[MAX_PATH];
  227. //
  228. // Constants for the wizard notification messages
  229. //
  230. #define WIZARD_NEXT_OK 0
  231. #define WIZARD_NEXT_DISALLOWED -1
  232. #define WIZARD_ACTIVATE_PAGE 0
  233. #define WIZARD_SKIP_PAGE -1
  234. #define VALIDATE_DATA_INVALID -1
  235. #define VALIDATE_DATA_OK 1
  236. //
  237. // Interface Functions
  238. //
  239. VOID
  240. UnattendInitialize(
  241. VOID
  242. );
  243. BOOL
  244. UnattendSetActiveDlg(
  245. IN HWND hwnd,
  246. IN DWORD controlid
  247. );
  248. // For PSN_WIZNEXT/PSN_WIZFINISH only
  249. VOID
  250. UnattendAdvanceIfValid (
  251. IN HWND hwnd
  252. );
  253. BOOL
  254. UnattendErrorDlg(
  255. IN HWND hwnd,
  256. IN DWORD controlid
  257. );
  258. PWSTR
  259. UnattendFetchString(
  260. IN UNATTENDENTRIES entry
  261. );
  262. // Wrapper to simply return a value in DWL_MSGRESULT, return value is always TRUE
  263. BOOL
  264. ReturnDlgResult (
  265. HWND hdlg,
  266. LRESULT Result
  267. );
  268. // Sends message, returns DWL_MSGRESULT, preservs original value in DWL_MSGRESULT
  269. LRESULT
  270. SendDlgMessage (
  271. HWND hdlg,
  272. UINT Message,
  273. WPARAM wParam,
  274. LPARAM lParam
  275. );
  276. //
  277. // Types and routines for afpnp.c
  278. //
  279. typedef struct {
  280. PVOID Buffer;
  281. UINT Size;
  282. } BUFFER, *PBUFFER;
  283. typedef struct {
  284. PWSTR Start;
  285. PWSTR End;
  286. UINT Size;
  287. } MULTISZ, *PMULTISZ;
  288. typedef struct {
  289. PCWSTR Start;
  290. PCWSTR Current;
  291. } MULTISZ_ENUM, *PMULTISZ_ENUM;
  292. #define BUFFER_INIT {NULL,0}
  293. #define MULTISZ_INIT {NULL,NULL,0}
  294. typedef struct _tagAFDRIVERATTRIBS {
  295. BOOL Broken;
  296. BOOL Initialized;
  297. HINF InfHandle;
  298. PCWSTR FilePath;
  299. PCWSTR InfPath;
  300. PCWSTR OriginalInstallMedia;
  301. MULTISZ PnpIdList;
  302. PCWSTR ClassInstall32Section; // no cleanup needed
  303. GUID Guid;
  304. struct _tagAFDRIVERATTRIBS *Next;
  305. } AF_DRIVER_ATTRIBS, *PAF_DRIVER_ATTRIBS;
  306. typedef struct {
  307. PAF_DRIVER_ATTRIBS Driver;
  308. BOOL WantAll;
  309. } AF_DRIVER_ENUM, *PAF_DRIVER_ENUM;
  310. typedef struct {
  311. PVOID DriverTable;
  312. PAF_DRIVER_ATTRIBS FirstDriver;
  313. } AF_DRIVERS, *PAF_DRIVERS;
  314. // Alloc or realloc depending on presense of Old (like c runtime realloc)
  315. PVOID
  316. MySmartAlloc (
  317. PCVOID Old, OPTIONAL
  318. UINT Size
  319. );
  320. // Free if p is not NULL
  321. VOID
  322. MySmartFree (
  323. PCVOID p
  324. );
  325. // Allocs only if SizeNeeded outgrew size previously allocated in Buf
  326. PVOID
  327. ReusableAlloc (
  328. IN OUT PBUFFER Buf,
  329. IN UINT SizeNeeded
  330. );
  331. // Cleans up BUFFER structs
  332. VOID
  333. ReusableFree (
  334. IN OUT PBUFFER Buf
  335. );
  336. // Adds a string to a MULTISZ alloc, growing/reallocating if necessary
  337. PWSTR
  338. MultiSzAppendString (
  339. IN OUT PMULTISZ MultiSz,
  340. IN PCWSTR String
  341. );
  342. // Cleans up MULTISZ structs
  343. VOID
  344. MultiSzFree (
  345. IN OUT PMULTISZ MultiSz
  346. );
  347. // Simplifies logic surrounding multisz processing
  348. BOOL
  349. EnumFirstMultiSz (
  350. IN OUT PMULTISZ_ENUM EnumPtr,
  351. IN PCWSTR MultiSz
  352. );
  353. BOOL
  354. EnumNextMultiSz (
  355. IN OUT PMULTISZ_ENUM EnumPtr
  356. );
  357. // Simplifies getting string fields in loops
  358. PCWSTR
  359. SyssetupGetStringField (
  360. IN PINFCONTEXT InfContext,
  361. IN DWORD Field,
  362. IN OUT PBUFFER Buf
  363. );
  364. // For progress bar UI computations
  365. INT
  366. CountAfDrivers (
  367. IN PAF_DRIVERS Drivers,
  368. OUT INT *ClassInstallers OPTIONAL
  369. );
  370. // Pulls in answer file data, parses into structs
  371. PAF_DRIVERS
  372. CreateAfDriverTable (
  373. VOID
  374. );
  375. VOID
  376. DestroyAfDriverTable (
  377. IN PAF_DRIVERS Drivers
  378. );
  379. // Enumeration of AF_DRIVERS
  380. BOOL
  381. EnumFirstAfDriver (
  382. OUT PAF_DRIVER_ENUM EnumPtr,
  383. IN PAF_DRIVERS Drivers
  384. );
  385. BOOL
  386. EnumFirstAfDriverEx (
  387. OUT PAF_DRIVER_ENUM EnumPtr,
  388. IN PAF_DRIVERS Drivers,
  389. IN BOOL WantAll
  390. );
  391. BOOL
  392. EnumNextAfDriver (
  393. IN OUT PAF_DRIVER_ENUM EnumPtr
  394. );
  395. // Builds INF list of answer file-supplied drivers for a device
  396. BOOL
  397. SyssetupInstallAnswerFileDriver (
  398. IN PAF_DRIVERS Drivers,
  399. IN HDEVINFO hDevInfo,
  400. IN PSP_DEVINFO_DATA DeviceInfoData,
  401. OUT PAF_DRIVER_ATTRIBS *AfDriver
  402. );
  403. // Fixes the source INF path after installation completes
  404. BOOL
  405. SyssetupFixAnswerFileDriverPath (
  406. IN PAF_DRIVER_ATTRIBS Driver,
  407. IN HDEVINFO hDevInfo,
  408. IN PSP_DEVINFO_DATA DeviceInfoData
  409. );
  410. HINF
  411. pOpenAnswerFile (
  412. VOID
  413. );
  414. BOOL
  415. GetAnswerFileSetting (
  416. IN PCWSTR Section,
  417. IN PCWSTR Key,
  418. OUT PWSTR Buffer,
  419. IN UINT BufferSize
  420. );
  421. #endif // _UNATTEND_H_