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.

185 lines
5.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation
  6. //
  7. // File: install.c
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "hdwwiz.h"
  11. typedef
  12. UINT
  13. (*PINSTALLDEVINST)(
  14. HWND hwndParent,
  15. LPCWSTR DeviceInstanceId,
  16. BOOL UpdateDriver,
  17. PDWORD pReboot
  18. );
  19. HMODULE hNewDev = NULL;
  20. PINSTALLDEVINST pInstallDevInst = NULL;
  21. void
  22. InstallSilentChilds(
  23. HWND hwdnParent,
  24. PHARDWAREWIZ HardwareWiz
  25. );
  26. void
  27. InstallSilentChildSiblings(
  28. HWND hwndParent,
  29. PHARDWAREWIZ HardwareWiz,
  30. DEVINST DeviceInstance,
  31. BOOL ReinstallAll
  32. )
  33. {
  34. CONFIGRET ConfigRet;
  35. DEVINST ChildDeviceInstance;
  36. ULONG Ulong, ulValue;
  37. BOOL NeedsInstall, IsSilent;
  38. do {
  39. //
  40. // If this device instance needs installing and is silent then install it,
  41. // and its children.
  42. //
  43. IsSilent = FALSE;
  44. if (!ReinstallAll) {
  45. Ulong = sizeof(ulValue);
  46. ConfigRet = CM_Get_DevNode_Registry_Property_Ex(DeviceInstance,
  47. CM_DRP_CAPABILITIES,
  48. NULL,
  49. (PVOID)&ulValue,
  50. &Ulong,
  51. 0,
  52. NULL
  53. );
  54. if (ConfigRet == CR_SUCCESS && (ulValue & CM_DEVCAP_SILENTINSTALL)) {
  55. IsSilent = TRUE;
  56. }
  57. }
  58. if (IsSilent || ReinstallAll) {
  59. Ulong = sizeof(ulValue);
  60. ConfigRet = CM_Get_DevNode_Registry_Property_Ex(DeviceInstance,
  61. CM_DRP_CONFIGFLAGS,
  62. NULL,
  63. (PVOID)&ulValue,
  64. &Ulong,
  65. 0,
  66. NULL
  67. );
  68. if (ConfigRet == CR_SUCCESS && (ulValue & CONFIGFLAG_FINISH_INSTALL)) {
  69. NeedsInstall = TRUE;
  70. } else {
  71. ConfigRet = CM_Get_DevNode_Status(&Ulong,
  72. &ulValue,
  73. DeviceInstance,
  74. 0
  75. );
  76. NeedsInstall = ConfigRet == CR_SUCCESS &&
  77. (ulValue == CM_PROB_REINSTALL ||
  78. ulValue == CM_PROB_NOT_CONFIGURED
  79. );
  80. }
  81. if (NeedsInstall) {
  82. TCHAR DeviceInstanceId[MAX_DEVICE_ID_LEN];
  83. ConfigRet = CM_Get_Device_ID(DeviceInstance,
  84. DeviceInstanceId,
  85. SIZECHARS(DeviceInstanceId),
  86. 0
  87. );
  88. if (ConfigRet == CR_SUCCESS) {
  89. if (hNewDev) {
  90. if (!pInstallDevInst) {
  91. pInstallDevInst = (PINSTALLDEVINST)GetProcAddress(hNewDev, "InstallDevInst");
  92. }
  93. }
  94. if (pInstallDevInst) {
  95. if (pInstallDevInst(hwndParent,
  96. DeviceInstanceId,
  97. FALSE, // only for found new.
  98. &Ulong
  99. )) {
  100. HardwareWiz->Reboot |= Ulong;
  101. }
  102. }
  103. //
  104. // If this devinst has children, then recurse to install them as well.
  105. //
  106. ConfigRet = CM_Get_Child_Ex(&ChildDeviceInstance,
  107. DeviceInstance,
  108. 0,
  109. NULL
  110. );
  111. if (ConfigRet == CR_SUCCESS) {
  112. InstallSilentChildSiblings(hwndParent, HardwareWiz, ChildDeviceInstance, ReinstallAll);
  113. }
  114. }
  115. }
  116. }
  117. //
  118. // Next sibling ...
  119. //
  120. ConfigRet = CM_Get_Sibling_Ex(&DeviceInstance,
  121. DeviceInstance,
  122. 0,
  123. NULL
  124. );
  125. } while (ConfigRet == CR_SUCCESS);
  126. }
  127. void
  128. InstallSilentChilds(
  129. HWND hwndParent,
  130. PHARDWAREWIZ HardwareWiz
  131. )
  132. {
  133. CONFIGRET ConfigRet;
  134. DEVINST ChildDeviceInstance;
  135. ConfigRet = CM_Get_Child_Ex(&ChildDeviceInstance,
  136. HardwareWiz->DeviceInfoData.DevInst,
  137. 0,
  138. NULL
  139. );
  140. if (ConfigRet == CR_SUCCESS) {
  141. InstallSilentChildSiblings(hwndParent, HardwareWiz, ChildDeviceInstance, FALSE);
  142. }
  143. }