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.

228 lines
5.0 KiB

  1. // Copyright (c) 2001 Microsoft Corporation
  2. //
  3. // File: state.h
  4. //
  5. // Synopsis: Declares the state object that is global
  6. // to CYS. It holds the network and OS/SKU info
  7. //
  8. // History: 02/02/2001 JeffJon Created
  9. #ifndef __CYS_STATE_H
  10. #define __CYS_STATE_H
  11. #include "NetworkAdapterConfig.h"
  12. #define CYS_DATACENTER_SERVER 0x00000001
  13. #define CYS_ADVANCED_SERVER 0x00000002
  14. #define CYS_SERVER 0x00000004
  15. #define CYS_UNSUPPORTED_SKU 0x00000008
  16. #define CYS_64BIT 0x80000000
  17. #define CYS_32BIT 0x40000000
  18. #define CYS_ALL_SERVER_SKUS (CYS_DATACENTER_SERVER | \
  19. CYS_ADVANCED_SERVER | \
  20. CYS_SERVER | \
  21. CYS_64BIT | \
  22. CYS_32BIT)
  23. #define CYS_ALL_SKUS_NO_64BIT (CYS_DATACENTER_SERVER | \
  24. CYS_ADVANCED_SERVER | \
  25. CYS_SERVER | \
  26. CYS_32BIT)
  27. class State
  28. {
  29. public:
  30. // Called from WinMain to delete the global instance of the state object
  31. static
  32. void
  33. Destroy();
  34. // Retrieves a reference to the global instance of the state object
  35. static
  36. State&
  37. GetInstance();
  38. // Does the work to determine the state of the machine
  39. bool
  40. RetrieveMachineConfigurationInformation(
  41. HWND progressLabel,
  42. bool doDHCPCheck,
  43. int nicInfoResID,
  44. int osInfoResID,
  45. int defaultConnectionNameResID,
  46. int detectSettingsResID);
  47. // Data accessors
  48. unsigned int
  49. GetNICCount() const;
  50. unsigned int
  51. GetNonModemNICCount();
  52. NetworkInterface*
  53. GetNIC(unsigned int nicIndex);
  54. NetworkInterface*
  55. GetNICFromName(
  56. const String& name,
  57. bool& found);
  58. bool
  59. IsRemoteSession() const;
  60. bool
  61. IsWindowsSetupRunning() const;
  62. bool
  63. IsDC() const;
  64. bool
  65. IsDCPromoRunning() const;
  66. bool
  67. IsDCPromoPendingReboot() const;
  68. bool
  69. IsJoinedToDomain() const;
  70. bool
  71. IsUpgradeState() const;
  72. bool
  73. IsFirstDC() const;
  74. bool
  75. IsDHCPServerAvailableOnAllNics() const { return dhcpServerAvailableOnAllNics; }
  76. bool
  77. HasStateBeenRetrieved() const { return hasStateBeenRetrieved; }
  78. bool
  79. RerunWizard() const { return rerunWizard; }
  80. /*
  81. void
  82. SetRerunWizard(bool rerun);
  83. */
  84. void
  85. SetStartPage(UINT startPage) { wizardStartPage = startPage; }
  86. UINT
  87. GetStartPage() const { return wizardStartPage; }
  88. DWORD
  89. GetProductSKU() const { return productSKU; }
  90. DWORD
  91. GetPlatform() const { return platform; }
  92. bool
  93. Is64Bit() const { return (platform & CYS_64BIT) != 0; }
  94. bool
  95. Is32Bit() const { return (platform & CYS_32BIT) != 0; }
  96. bool
  97. HasNTFSDrive() const;
  98. bool
  99. SetHomeRegkey(const String& newKeyValue);
  100. bool
  101. GetHomeRegkey(String& newKeyValue) const;
  102. String
  103. GetComputerName();
  104. String
  105. GetDomainDNSName();
  106. String
  107. GetDomainNetbiosName();
  108. bool
  109. HasDNSServerOnAnyNicToForwardTo();
  110. void
  111. SetLocalNIC(
  112. String guid,
  113. bool setInRegistry = false);
  114. NetworkInterface*
  115. GetLocalNIC();
  116. NetworkInterface*
  117. GetLocalNICFromRegistry();
  118. DWORD
  119. GetNextAvailableIPAddress(
  120. DWORD startAddress,
  121. DWORD subnetMask);
  122. DWORD
  123. RetrieveProductSKU();
  124. bool
  125. IsRebootScenario() const;
  126. void
  127. SetRebootScenario(bool reboot);
  128. bool
  129. ShouldRunMYS() const;
  130. private:
  131. // Determines if there is a DHCP server on the network
  132. void
  133. CheckDhcpServer(
  134. HWND progressStatic,
  135. int defaultConnectionNameResID,
  136. int detectSettingsResID);
  137. HRESULT
  138. RetrieveNICInformation();
  139. void
  140. RetrievePlatform();
  141. void
  142. RetrieveDriveInformation();
  143. bool hasStateBeenRetrieved;
  144. bool dhcpAvailabilityRetrieved;
  145. UINT wizardStartPage;
  146. bool dhcpServerAvailableOnAllNics;
  147. bool rerunWizard;
  148. bool isRebootScenario;
  149. bool hasNTFSDrive;
  150. DWORD productSKU;
  151. DWORD platform;
  152. Computer localComputer;
  153. String computerName;
  154. String domainDNSName;
  155. String domainNetbiosName;
  156. NetworkAdapterConfig adapterConfiguration;
  157. // Constructor
  158. State();
  159. // not defined: no copying allowed
  160. State(const State&);
  161. const State& operator=(const State&);
  162. };
  163. #endif // __CYS_STATE_H