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.

374 lines
11 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. factoryp.h
  5. Abstract:
  6. Private top-level header file for Factory Pre-install module.
  7. Author:
  8. Donald McNamara (donaldm) 2/8/2000
  9. Revision History:
  10. - Added exported prototypes from preinstall.c: Jason Lawrence (t-jasonl) 6/7/2000
  11. - Added DeleteTree() prototype: Jason Lawrence (t-jasonl) 6/7/2000
  12. - Added additional prototypes from misc.c and log.c: Jason Lawrence (t-jasonl) 6/14/2000
  13. --*/
  14. #include <nt.h>
  15. #include <ntrtl.h>
  16. #include <nturtl.h>
  17. #include <ntpoapi.h>
  18. #include <windows.h>
  19. #include <tchar.h>
  20. #include <stdlib.h>
  21. #include <lmcons.h>
  22. #include <lmerr.h>
  23. #include <lmjoin.h>
  24. #include <commctrl.h>
  25. #include <setupapi.h>
  26. #include <shlwapi.h>
  27. #include <cfgmgr32.h>
  28. #include <devguid.h>
  29. #include <lmuse.h>
  30. #include <msi.h>
  31. #include <msiquery.h>
  32. #include <regstr.h>
  33. #include <limits.h>
  34. #include <powrprof.h>
  35. #include <syssetup.h>
  36. #include <opklib.h> // OPK common functions
  37. #include <strsafe.h>
  38. #include <ntverp.h>
  39. #include "msg.h"
  40. #include "res.h"
  41. #include "winbom.h"
  42. #include "status.h"
  43. //
  44. // Defined Value(s):
  45. //
  46. // Flags for Logging
  47. //
  48. // Some of these flags are also defined in opklib.h. ( Planning to use opklib for all logging in the future. )
  49. //
  50. #define LOG_DEBUG 0x00000003 // Only log in debug builds if this is specified. (Debug Level for logging.)
  51. #define LOG_LEVEL_MASK 0x0000000F // Mask to only show the log level bits
  52. #define LOG_MSG_BOX 0x00000010 // Display the message boxes if this is enabled.
  53. #define LOG_ERR 0x00000020 // Prefix the logged string with "Error:" if the message is level 0,
  54. // or "WARNx" if the message is at level x > 0.
  55. #define LOG_TIME 0x00000040 // Display time if this is enabled
  56. #define LOG_NO_NL 0x00000080 // Don't add new Line to the end of log string if this is set.
  57. // Other factory flags
  58. //
  59. #define FLAG_STOP_ON_ERROR 0x00000001 // Stop on error. We should not really use this.
  60. #define FLAG_QUIET_MODE 0x00000002 // Quiet mode: do not display any message boxes.
  61. #define FLAG_IA64_MODE 0x00000004 // Set if factory is running on an Itanium machine.
  62. #define FLAG_LOG_PERF 0x00000008 // If set, log how long each state takes to run.
  63. #define FLAG_PNP_DONE 0x00000010 // If set, we know for sure that pnp is done.
  64. #define FLAG_PNP_STARTED 0x00000020 // If set, we have already started pnp.
  65. #define FLAG_LOGGEDON 0x00000040 // Only set when we are logged in.
  66. #define FLAG_NOUI 0x00000080 // Set if we don't want to show any UI in factory.
  67. #define FLAG_OOBE 0x00000100 // Set if we are launched from OOBE.
  68. // Flags for the STATE structure.
  69. //
  70. #define FLAG_STATE_NONE 0x00000000
  71. #define FLAG_STATE_ONETIME 0x00000001 // Set if this state should only be executed once, not for every boot.
  72. #define FLAG_STATE_NOTONSERVER 0x00000002 // Set if this state should not run on server SKUs.
  73. #define FLAG_STATE_QUITONERR 0x00000004 // Set if no other states should run if this state fails.
  74. #define FLAG_STATE_DISPLAYED 0x00000008 // Set only at run time, and only if the item is displayed in the status window.
  75. #define ALWAYS DisplayAlways
  76. #define NEVER NULL
  77. // Log files.
  78. //
  79. #define WINBOM_LOGFILE _T("WINBOM.LOG")
  80. // Registry strings.
  81. //
  82. #define REG_FACTORY_STATE _T("SOFTWARE\\Microsoft\\Factory\\State") // Registry path for the factory states.
  83. // Extra debug Logging.
  84. //
  85. #ifdef DBG
  86. #define DBGLOG FacLogFileStr
  87. #else // DBG
  88. #define DBGLOG
  89. #endif // DBG
  90. //
  91. // Defined Macro(s):
  92. //
  93. //
  94. // Type Definition(s):
  95. //
  96. typedef enum _FACTMODE
  97. {
  98. modeUnknown,
  99. modeSetup,
  100. modeMiniNt,
  101. modeWinPe,
  102. modeLogon,
  103. modeOobe,
  104. } FACTMODE, *PFACTMODE, *LPFACTMODE;
  105. typedef enum _STATE
  106. {
  107. stateUnknown,
  108. stateStart,
  109. stateComputerName,
  110. stateSetupNetwork,
  111. stateUpdateDrivers,
  112. stateInstallDrivers,
  113. stateNormalPnP,
  114. stateWaitPnP,
  115. stateWaitPnP2,
  116. stateSetDisplay,
  117. stateSetDisplay2,
  118. stateOptShell,
  119. stateAutoLogon,
  120. stateLogon,
  121. stateUserIdent,
  122. stateInfInstall,
  123. statePidPopulate,
  124. stateOCManager,
  125. stateOemRunOnce,
  126. stateOemRun,
  127. stateReseal,
  128. statePartitionFormat,
  129. stateCopyFiles,
  130. stateStartMenuMFU,
  131. stateSetDefaultApps,
  132. stateOemData,
  133. stateSetPowerOptions,
  134. stateSetFontOptions,
  135. stateShellSettings,
  136. stateShellSettings2,
  137. stateHomeNet,
  138. stateExtendPart,
  139. stateResetSource,
  140. stateTestCert,
  141. stateSlpFiles,
  142. stateWinpeReboot,
  143. stateWinpeNet,
  144. stateCreatePageFile,
  145. stateFinish,
  146. } STATE;
  147. typedef struct _STATEDATA
  148. {
  149. LPTSTR lpszWinBOMPath;
  150. STATE state;
  151. BOOL bQuit;
  152. } STATEDATA, *PSTATEDATA, *LPSTATEDATA;
  153. typedef BOOL (WINAPI *STATEFUNC)(LPSTATEDATA);
  154. typedef struct _STATES
  155. {
  156. STATE state; // State number.
  157. STATEFUNC statefunc; // Function to call for this state.
  158. STATEFUNC displayfunc; // Function that decides if this state is displayed or not.
  159. INT nFriendlyName; // Resource ID of the name to be displayed in the log and UI for this state.
  160. DWORD dwFlags; // Any flags for the state.
  161. } STATES, *PSTATES, *LPSTATES;
  162. //
  163. // Function Prototype(s):
  164. //
  165. BOOL CheckParams(LPSTR lpCmdLine);
  166. INT_PTR FactoryPreinstallDlgProc(HWND, UINT, WPARAM, LPARAM);
  167. // In WINBOM.C:
  168. //
  169. BOOL ProcessWinBOM(LPTSTR lpszWinBOMPath, LPSTATES lpStates, DWORD cbStates);
  170. BOOL DisplayAlways(LPSTATEDATA lpStateData);
  171. // From MISC.C
  172. TCHAR GetDriveLetter(UINT uDriveType);
  173. BOOL ComputerName(LPSTATEDATA lpStateData);
  174. BOOL DisplayComputerName(LPSTATEDATA lpStateData);
  175. BOOL Reseal(LPSTATEDATA lpStateData);
  176. BOOL DisplayReseal(LPSTATEDATA lpStateData);
  177. // From PNPDRIVERS.C:
  178. //
  179. BOOL StartPnP();
  180. BOOL WaitForPnp(DWORD dwTimeOut);
  181. BOOL UpdateDrivers(LPSTATEDATA lpStateData);
  182. BOOL DisplayUpdateDrivers(LPSTATEDATA lpStateData);
  183. BOOL InstallDrivers(LPSTATEDATA lpStateData);
  184. BOOL DisplayInstallDrivers(LPSTATEDATA lpStateData);
  185. BOOL NormalPnP(LPSTATEDATA lpStateData);
  186. BOOL DisplayWaitPnP(LPSTATEDATA lpStateData);
  187. BOOL WaitPnP(LPSTATEDATA lpStateData);
  188. BOOL SetDisplay(LPSTATEDATA lpStateData);
  189. // From Net.c
  190. BOOL InstallNetworkCard(PWSTR pszWinBOMPath, BOOL bForceIDScan);
  191. BOOL SetupNetwork(LPSTATEDATA lpStateData);
  192. NTSTATUS ForceNetbtRegistryRead(VOID);
  193. // From mini.c
  194. BOOL SetupMiniNT(VOID);
  195. BOOL PartitionFormat(LPSTATEDATA lpStateData);
  196. BOOL DisplayPartitionFormat(LPSTATEDATA lpStateData);
  197. BOOL CopyFiles(LPSTATEDATA lpStateData);
  198. BOOL DisplayCopyFiles(LPSTATEDATA lpStateData);
  199. BOOL WinpeReboot(LPSTATEDATA lpStateData);
  200. BOOL
  201. IsRemoteBoot(
  202. VOID
  203. );
  204. // From autologon.c
  205. BOOL AutoLogon(LPSTATEDATA lpStateData);
  206. BOOL DisplayAutoLogon(LPSTATEDATA lpStateData);
  207. // From ident.c
  208. BOOL UserIdent(LPSTATEDATA lpStateData);
  209. BOOL DisplayUserIdent(LPSTATEDATA lpStateData);
  210. // From inf.c
  211. BOOL ProcessInfSection(LPTSTR, LPTSTR);
  212. BOOL InfInstall(LPSTATEDATA lpStateData);
  213. BOOL DisplayInfInstall(LPSTATEDATA lpStateData);
  214. // From factory.c
  215. VOID InitLogging(LPTSTR lpszWinBOMPath);
  216. // From log.c
  217. DWORD FacLogFileStr(DWORD dwLogOpt, LPTSTR lpFormat, ...);
  218. DWORD FacLogFile(DWORD dwLogOpt, UINT uFormat, ...);
  219. // From StartMenuMfu.c
  220. BOOL StartMenuMFU(LPSTATEDATA lpStateData);
  221. BOOL DisplayStartMenuMFU(LPSTATEDATA lpStateData);
  222. BOOL SetDefaultApps(LPSTATEDATA lpStateData);
  223. // From OemFolder.c
  224. BOOL OemData(LPSTATEDATA lpStateData);
  225. BOOL DisplayOemData(LPSTATEDATA lpStateData);
  226. void NotifyStartMenu(UINT code);
  227. #define TMFACTORY_OEMLINK 0
  228. #define TMFACTORY_MFU 1
  229. // From oemrun.c
  230. BOOL OemRun(LPSTATEDATA lpStateData);
  231. BOOL DisplayOemRun(LPSTATEDATA lpStateData);
  232. BOOL OemRunOnce(LPSTATEDATA lpStateData);
  233. BOOL DisplayOemRunOnce(LPSTATEDATA lpStateData);
  234. // From winpenet.c
  235. BOOL ConfigureNetwork(LPTSTR lpszWinBOMPath);
  236. BOOL WinpeNet(LPSTATEDATA lpStateData);
  237. BOOL DisplayWinpeNet(LPSTATEDATA lpStateData);
  238. DWORD WaitForServiceStartName(LPTSTR lpszServiceName);
  239. DWORD StartMyService(LPTSTR lpszServiceName, SC_HANDLE schSCManager);
  240. // From power.c
  241. BOOL SetPowerOptions(LPSTATEDATA lpStateData);
  242. BOOL DisplaySetPowerOptions(LPSTATEDATA lpStateData);
  243. // From FONT.C:
  244. //
  245. BOOL SetFontOptions(LPSTATEDATA lpStateData);
  246. BOOL DisplaySetFontOptions(LPSTATEDATA lpStateData);
  247. // From HOMENET.C:
  248. //
  249. BOOL HomeNet(LPSTATEDATA lpStateData);
  250. BOOL DisplayHomeNet(LPSTATEDATA lpStateData);
  251. // From SRCPATH.C:
  252. //
  253. BOOL ResetSource(LPSTATEDATA lpStateData);
  254. BOOL DisplayResetSource(LPSTATEDATA lpStateData);
  255. // From EXTPART.C:
  256. //
  257. BOOL ExtendPart(LPSTATEDATA lpStateData);
  258. BOOL DisplayExtendPart(LPSTATEDATA lpStateData);
  259. // From TESTCERT.C:
  260. //
  261. BOOL TestCert(LPSTATEDATA lpStateData);
  262. BOOL DisplayTestCert(LPSTATEDATA lpStateData);
  263. // From SHELL.C:
  264. //
  265. BOOL OptimizeShell(LPSTATEDATA lpStateData);
  266. BOOL DisplayOptimizeShell(LPSTATEDATA lpStateData);
  267. // From SETSHELL.C:
  268. //
  269. BOOL ShellSettings(LPSTATEDATA lpStateData);
  270. BOOL ShellSettings2(LPSTATEDATA lpStateData);
  271. BOOL DisplayShellSettings(LPSTATEDATA lpStateData);
  272. // From pagefile.c
  273. //
  274. BOOL CreatePageFile(LPSTATEDATA lpStateData);
  275. BOOL DisplayCreatePageFile(LPSTATEDATA lpStateData);
  276. // From OCMGR.C:
  277. //
  278. BOOL OCManager(LPSTATEDATA lpStateData);
  279. BOOL DisplayOCManager(LPSTATEDATA lpStateData);
  280. // From SLPFILES.C:
  281. //
  282. BOOL SlpFiles(LPSTATEDATA lpStateData);
  283. BOOL DisplaySlpFiles(LPSTATEDATA lpStateData);
  284. // From PID.C
  285. //
  286. BOOL PidPopulate(LPSTATEDATA lpStateData);
  287. // External functions
  288. extern BOOL IsUserAdmin(VOID);
  289. //extern BOOL CheckOSVersion(VOID);
  290. //extern BOOL IsDomainMember(VOID);
  291. //extern BOOL IsUserAdmin(VOID);
  292. extern BOOL DoesUserHavePrivilege(PCTSTR);
  293. // ============================================================================
  294. // Global Variables
  295. // ============================================================================
  296. extern HINSTANCE g_hInstance;
  297. extern DWORD g_dwFactoryFlags;
  298. extern DWORD g_dwDebugLevel;
  299. extern TCHAR g_szWinBOMPath[];
  300. extern TCHAR g_szLogFile[MAX_PATH];
  301. extern TCHAR g_szFactoryPath[MAX_PATH];
  302. extern TCHAR g_szSysprepDir[MAX_PATH];
  303. // ============================================================================
  304. // Global Constants
  305. // ============================================================================
  306. #define MAX_MESSAGE 4096
  307. #define FACTORY_MESSAGE_TYPE_ERROR 1