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.

427 lines
13 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: A F I L E X P . H
  7. //
  8. // Contents: Interface classes to access the AnswerFile in modular way.
  9. //
  10. // Author: kumarp 25-November-97
  11. //
  12. //----------------------------------------------------------------------------
  13. #pragma once
  14. #include "edc.h"
  15. #include "kkcwinf.h"
  16. #include "netcfgp.h"
  17. #include "oemupgrd.h"
  18. #include "nsexports.h"
  19. enum EPageDisplayMode { PDM_UNKNOWN, PDM_NO, PDM_YES, PDM_ONLY_ON_ERROR };
  20. // ----------------------------------------------------------------------
  21. // forward declarations
  22. // ----------------------------------------------------------------------
  23. class CNetInstallInfo;
  24. class CPageDisplayCommonInfo;
  25. class CCommonInfo;
  26. class CNetComponentsPageBase;
  27. class CNetAdaptersPage;
  28. class CNetProtocolsPage;
  29. class CNetServicesPage;
  30. class CNetClientsPage;
  31. class CNetBindingsPage;
  32. class CNetComponent;
  33. class CNetComponentList;
  34. class CNetAdapter;
  35. class CNetProtocol;
  36. class CNetService;
  37. class CNetClient;
  38. enum ENetComponentType;
  39. class CNetComponentList : public TPtrList
  40. {
  41. };
  42. // ----------------------------------------------------------------------
  43. class CNetInstallInfo
  44. {
  45. private:
  46. CNetInstallInfo();
  47. public:
  48. ~CNetInstallInfo();
  49. static
  50. HRESULT
  51. HrCreateInstance (
  52. IN PCWSTR pszAnswerFileName,
  53. OUT CNetInstallInfo** ppObj);
  54. //void InitDefaults();
  55. HRESULT CNetInstallInfo::InitRepairMode (VOID);
  56. HRESULT HrInitFromAnswerFile(IN PCWSTR pszAnswerFileName);
  57. HRESULT HrInitFromAnswerFile(IN CWInfFile* pwifAnswerFile);
  58. BOOL AnswerFileInitialized() { return m_pwifAnswerFile != NULL;}
  59. PCWSTR AnswerFileName();
  60. CWInfFile* AnswerFile() { return m_pwifAnswerFile; }
  61. HRESULT HrInitForDefaultComponents();
  62. CNetComponent* Find(IN PCWSTR pszComponentName) const;
  63. CNetComponent* FindFromInfID(IN PCWSTR szInfID) const;
  64. HRESULT
  65. FindAdapter (
  66. IN QWORD qwNetCardAddress,
  67. OUT CNetAdapter** ppNetAdapter) const;
  68. HRESULT
  69. FindAdapter (
  70. IN DWORD BusNumber,
  71. IN DWORD Address,
  72. OUT CNetAdapter** ppNetAdapter) const;
  73. CNetAdapter* FindAdapter(IN PCWSTR pszInfID) const;
  74. HRESULT HrGetInstanceGuidOfPreNT5NetCardInstance(IN PCWSTR szPreNT5NetCardInstance,
  75. OUT LPGUID pguid);
  76. HRESULT HrDoUnattended(IN HWND hParent, IN IUnknown * punk,
  77. IN EUnattendWorkType uawType,
  78. OUT EPageDisplayMode *ppdm, OUT BOOL *pfAllowChanges);
  79. CNetAdaptersPage* AdaptersPage() { return m_pnaiAdaptersPage; }
  80. CNetProtocolsPage* ProtocolsPage() { return m_pnpiProtocolsPage;}
  81. CNetServicesPage* ServicesPage() { return m_pnsiServicesPage; }
  82. CNetClientsPage* ClientsPage() { return m_pnciClientsPage; }
  83. CNetBindingsPage* BindingsPage() { return m_pnbiBindingsPage; }
  84. DWORD UpgradeFlag() const { return m_dwUpgradeFlag; }
  85. DWORD BuildNumber() const { return m_dwBuildNumber; }
  86. private:
  87. CWInfFile* m_pwifAnswerFile;
  88. CNetAdaptersPage* m_pnaiAdaptersPage;
  89. CNetProtocolsPage* m_pnpiProtocolsPage;
  90. CNetServicesPage* m_pnsiServicesPage;
  91. CNetClientsPage* m_pnciClientsPage;
  92. CNetBindingsPage* m_pnbiBindingsPage;
  93. DWORD m_dwUpgradeFlag;
  94. DWORD m_dwBuildNumber;
  95. BOOL m_fProcessPageSections;
  96. BOOL m_fUpgrade;
  97. BOOL m_fInstallDefaultComponents;
  98. TStringList m_slNetComponentsToRemove;
  99. public:
  100. NetUpgradeInfo m_nui;
  101. HINF m_hinfAnswerFile;
  102. };
  103. extern CNetInstallInfo* g_pnii;
  104. // ----------------------------------------------------------------------
  105. class CPageDisplayCommonInfo
  106. {
  107. public:
  108. CPageDisplayCommonInfo();
  109. //void InitDefaults();
  110. virtual HRESULT HrInitFromAnswerFile(IN CWInfFile* pwifAnswerFile);
  111. EPageDisplayMode Display() const { return m_pdmDisplay; }
  112. BOOL AllowChanges() const { return m_fAllowChanges; }
  113. void GetDisplaySettings(OUT EPageDisplayMode* ppdm,
  114. OUT BOOL* pfAllowChanges) const
  115. { *ppdm = m_pdmDisplay;
  116. *pfAllowChanges = m_fAllowChanges; }
  117. private:
  118. EPageDisplayMode m_pdmDisplay;
  119. BOOL m_fAllowChanges;
  120. };
  121. // ----------------------------------------------------------------------
  122. class CNetComponentsPageBase : public CPageDisplayCommonInfo
  123. {
  124. public:
  125. CNetComponentsPageBase(IN CNetInstallInfo* pnii,
  126. IN const GUID* lpguidDevClass);
  127. ~CNetComponentsPageBase();
  128. virtual HRESULT HrInitFromAnswerFile(IN CWInfFile* pwifAnswerFile,
  129. IN PCWSTR pszSectionName);
  130. HRESULT HrInitForDefaultComponents();
  131. CNetComponent* Find(IN PCWSTR pszComponentName) const;
  132. CNetComponent* FindFromInfID(IN PCWSTR szInfID) const;
  133. virtual HRESULT HrValidate() const;
  134. virtual CNetComponent* GetNewComponent(IN PCWSTR pszName) = 0;
  135. virtual HRESULT HrDoNetworkInstall(IN HWND hParent, IN INetCfg* pnc);
  136. virtual HRESULT HrDoOsUpgrade(IN INetCfg* pnc);
  137. protected:
  138. CNetInstallInfo* m_pnii;
  139. const GUID* m_lpguidDevClass;
  140. CNetComponentList m_pnclComponents;
  141. PCWSTR m_pszClassName;
  142. ENetComponentType m_eType;;
  143. friend
  144. VOID
  145. CALLBACK
  146. DefaultComponentCallback (
  147. IN EDC_CALLBACK_MESSAGE Message,
  148. IN ULONG_PTR MessageData,
  149. IN PVOID pvCallerData OPTIONAL);
  150. };
  151. // ----------------------------------------------------------------------
  152. class CNetAdaptersPage : public CNetComponentsPageBase
  153. {
  154. public:
  155. CNetAdaptersPage(IN CNetInstallInfo* pnii);
  156. virtual CNetComponent* GetNewComponent(IN PCWSTR pszName);
  157. HRESULT HrInitFromAnswerFile(IN CWInfFile* pwifAnswerFile);
  158. HRESULT
  159. FindAdapter(IN QWORD qwNetCardAddress, OUT CNetAdapter** ppNetAdapter ) const;
  160. HRESULT
  161. FindAdapter (IN DWORD BusNumber, IN DWORD Address, OUT CNetAdapter** ppNetAdapter) const;
  162. CNetAdapter* FindAdapter(IN PCWSTR pszInfID) const;
  163. CNetAdapter* FindCompatibleAdapter(IN PCWSTR mszInfIDs) const;
  164. CNetAdapter* FindAdapterFromPreUpgradeInstance(IN PCWSTR szPreUpgradeInstance);
  165. DWORD GetNumCompatibleAdapters(IN PCWSTR mszInfID) const;
  166. HRESULT HrResolveNetAdapters(IN INetCfg* pnc);
  167. HRESULT HrDoOemPostUpgradeProcessing(IN INetCfg* pnc,
  168. IN HWND hwndParent);
  169. HRESULT HrSetConnectionNames();
  170. private:
  171. };
  172. // ----------------------------------------------------------------------
  173. class CNetProtocolsPage : public CNetComponentsPageBase
  174. {
  175. public:
  176. CNetProtocolsPage(IN CNetInstallInfo* pnii);
  177. virtual CNetComponent* GetNewComponent(IN PCWSTR pszName);
  178. HRESULT HrInitFromAnswerFile(IN CWInfFile* pwifAnswerFile);
  179. private:
  180. };
  181. // ----------------------------------------------------------------------
  182. class CNetServicesPage : public CNetComponentsPageBase
  183. {
  184. public:
  185. CNetServicesPage(IN CNetInstallInfo* pnii);
  186. virtual CNetComponent* GetNewComponent(IN PCWSTR pszName);
  187. HRESULT HrInitFromAnswerFile(IN CWInfFile* pwifAnswerFile);
  188. private:
  189. };
  190. // ----------------------------------------------------------------------
  191. class CNetClientsPage : public CNetComponentsPageBase
  192. {
  193. public:
  194. CNetClientsPage(IN CNetInstallInfo* pnii);
  195. virtual CNetComponent* GetNewComponent(IN PCWSTR pszName);
  196. HRESULT HrInitFromAnswerFile(IN CWInfFile* pwifAnswerFile);
  197. private:
  198. };
  199. // ----------------------------------------------------------------------
  200. class CNetBindingsPage : public CPageDisplayCommonInfo
  201. {
  202. public:
  203. CNetBindingsPage(IN CNetInstallInfo* pnii);
  204. HRESULT HrInitFromAnswerFile(IN CWInfFile* pwifAnswerFile);
  205. virtual HRESULT HrDoUnattended(IN INetCfg* pnc);
  206. private:
  207. CNetInstallInfo* m_pnii;
  208. TPtrList m_plBindingActions;
  209. };
  210. // ----------------------------------------------------------------------
  211. enum ENetComponentType { NCT_Unknown, NCT_Client, NCT_Service,
  212. NCT_Protocol, NCT_Adapter };
  213. class CNetComponent
  214. {
  215. friend HRESULT CNetComponentsPageBase::HrDoNetworkInstall(IN HWND hParent,
  216. IN INetCfg* pnc);
  217. public:
  218. CNetComponent(IN PCWSTR pszName);
  219. ENetComponentType Type() const { return m_eType; }
  220. virtual HRESULT HrInitFromAnswerFile(IN CWInfFile* pwifAnswerFile,
  221. IN PCWSTR pszParamsSections);
  222. const tstring& Name() const { return m_strName; }
  223. const tstring& InfID() const { return m_strInfID; }
  224. const tstring& InfIDReal() const { return m_strInfIDReal; }
  225. const tstring& ParamsSections() const { return m_strParamsSections; }
  226. const tstring& OemDll() const { return m_strOemDll; }
  227. const tstring& OemDir() const { return m_strOemDir; }
  228. void GetInstanceGuid(LPGUID pguid) const;
  229. void SetInfID(IN PCWSTR pszInfID) { m_strInfID = pszInfID; }
  230. void SetInstanceGuid(const GUID* pguid);
  231. virtual BOOL IsInitializedFromAnswerFile() const
  232. { return ! m_strParamsSections.empty(); }
  233. virtual HRESULT HrValidate() const;
  234. tstring m_strParamsSections;
  235. protected:
  236. ENetComponentType m_eType;
  237. tstring m_strName;
  238. tstring m_strInfID;
  239. tstring m_strInfIDReal;
  240. GUID m_guidInstance;
  241. BOOL m_fIsOemComponent;
  242. BOOL m_fSkipInstall;
  243. tstring m_strOemSection;
  244. tstring m_strOemDir;
  245. tstring m_strOemDll;
  246. tstring m_strInfToRunBeforeInstall;
  247. tstring m_strSectionToRunBeforeInstall;
  248. tstring m_strInfToRunAfterInstall;
  249. tstring m_strSectionToRunAfterInstall;
  250. };
  251. // ----------------------------------------------------------------------
  252. class CNetAdapter : public CNetComponent
  253. {
  254. public:
  255. CNetAdapter(IN PCWSTR pszName);
  256. virtual HRESULT HrInitFromAnswerFile(IN CWInfFile* pwifAnswerFile,
  257. IN PCWSTR pszParamsSections);
  258. virtual HRESULT HrValidate();
  259. PCWSTR PreUpgradeInstance() const
  260. { return m_strPreUpgradeInstance.c_str();}
  261. INTERFACE_TYPE BusType() const { return m_itBus; }
  262. WORD IOAddr() const { return m_wIOAddr; }
  263. WORD IRQ() const { return m_wIRQ; }
  264. WORD DMA() const { return m_wDMA; }
  265. DWORD Mem() const { return m_dwMem; }
  266. QWORD NetCardAddr() const { return m_qwNetCardAddress; }
  267. BOOL IsPseudoAdapter() const { return m_fPseudoAdapter; }
  268. PCWSTR ConnectionName() const { return m_strConnectionName.c_str();}
  269. DWORD PciAddress () const { return MAKELONG(m_PciFunctionNumber, m_PciDeviceNumber); }
  270. DWORD PciBusNumber () const { return m_PciBusNumber; }
  271. BOOL FPciInfoSpecified() const { return m_fPciLocationInfoSpecified; }
  272. private:
  273. BOOL m_fDetect;
  274. BOOL m_fPseudoAdapter;
  275. tstring m_strPreUpgradeInstance;
  276. INTERFACE_TYPE m_itBus;
  277. WORD m_wIOAddr;
  278. WORD m_wIRQ;
  279. WORD m_wDMA;
  280. DWORD m_dwMem;
  281. WORD m_PciBusNumber;
  282. WORD m_PciDeviceNumber;
  283. WORD m_PciFunctionNumber;
  284. BOOL m_fPciLocationInfoSpecified;
  285. QWORD m_qwNetCardAddress;
  286. tstring m_strConnectionName;
  287. };
  288. // ----------------------------------------------------------------------
  289. class CNetProtocol : public CNetComponent
  290. {
  291. public:
  292. CNetProtocol(IN PCWSTR pszName);
  293. };
  294. // ----------------------------------------------------------------------
  295. class CNetService : public CNetComponent
  296. {
  297. public:
  298. CNetService(IN PCWSTR pszName);
  299. };
  300. // ----------------------------------------------------------------------
  301. class CNetClient : public CNetComponent
  302. {
  303. public:
  304. CNetClient(IN PCWSTR pszName);
  305. };
  306. // ----------------------------------------------------------------------
  307. enum EBindingAction
  308. {
  309. BND_Unknown,
  310. BND_Enable,
  311. BND_Disable,
  312. BND_Promote,
  313. BND_Demote
  314. };
  315. class CBindingAction
  316. {
  317. friend
  318. HRESULT
  319. CNetInstallInfo::HrCreateInstance (
  320. IN PCWSTR pszAnswerFileName,
  321. OUT CNetInstallInfo** ppObj);
  322. public:
  323. CBindingAction();
  324. ~CBindingAction();
  325. HRESULT HrInitFromAnswerFile(IN const CWInfKey* pwikKey);
  326. HRESULT HrPerformAction(IN INetCfg* pnc);
  327. private:
  328. static CNetInstallInfo* m_pnii;
  329. EBindingAction m_eBindingAction;
  330. TStringList m_slBindingPath;
  331. #if DBG
  332. tstring m_strBindingPath;
  333. #endif
  334. };
  335. // ----------------------------------------------------------------------
  336. VOID
  337. GetAnswerFileErrorList_Internal(OUT TStringList*& slErrors);
  338. void ShowAnswerFileErrorsIfAny();
  339. void ShowProgressMessage(IN PCWSTR szFormatStr, ...);