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.

163 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. ocwizard.c
  5. Abstract:
  6. Routines to query wizard pages from OC DLLs and manage the results.
  7. No wizard is actually displayed by this routine -- that is up to
  8. whoever links to the OC Manager common library.
  9. Author:
  10. Ted Miller (tedm) 17-Sep-1996
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. UINT
  16. OcGetWizardPages(
  17. IN PVOID OcManagerContext,
  18. OUT PSETUP_REQUEST_PAGES Pages[WizPagesTypeMax]
  19. )
  20. /*++
  21. Routine Description:
  22. Request wizard pages from OC DLL's, according to ordering and omission
  23. rules specified in the master OC inf.
  24. Pages are returned in the form of wizard page handles in SETUP_REQUEST_PAGES
  25. data structures.
  26. Arguments:
  27. OcManagerContext - supplies OC Manager context structure, returned by
  28. OcInitialize().
  29. Pages - points to a block of memory that can hold WizPagesTypeMax pointers to
  30. SETUP_REQUEST_PAGES structures. On successful completion, that array is
  31. filled in with such pointers.
  32. Return Value:
  33. Win32 error code indicating outcome.
  34. --*/
  35. {
  36. WizardPagesType PageType;
  37. UINT n;
  38. LONG Id;
  39. UINT e,ErrorCode;
  40. POC_MANAGER OcManager;
  41. PSETUP_REQUEST_PAGES p,pages;
  42. OPTIONAL_COMPONENT Component;
  43. //
  44. // The context actually points at the OC_MANAGER structure.
  45. //
  46. OcManager = OcManagerContext;
  47. //
  48. // The ordering arrays for each wizard page type are
  49. // stored away for us in the OC_MANAGER data structure.
  50. //
  51. ErrorCode = NO_ERROR;
  52. for(PageType=0; PageType<WizPagesTypeMax; PageType++) {
  53. //
  54. // Allocate an empty list of pages for this page type.
  55. //
  56. Pages[PageType] = pSetupMalloc(offsetof(SETUP_REQUEST_PAGES,Pages));
  57. if(Pages[PageType]) {
  58. Pages[PageType]->MaxPages = 0;
  59. for(n=0;
  60. (n < OcManager->TopLevelOcCount)
  61. && ((Id = OcManager->WizardPagesOrder[PageType][n]) != -1);
  62. n++)
  63. {
  64. //
  65. // Call the component and ask for its pages of the current type.
  66. // If this succeeds, merge the pages of this type from the
  67. // component into the master list for this component.
  68. //
  69. pSetupStringTableGetExtraData(
  70. OcManager->ComponentStringTable,
  71. Id,
  72. &Component,
  73. sizeof(OPTIONAL_COMPONENT)
  74. );
  75. if ((Component.InternalFlags & OCFLAG_NOWIZARDPAGES) == 0) {
  76. e = OcInterfaceRequestPages(OcManager,Id,PageType,&pages);
  77. if(e == NO_ERROR) {
  78. p = pSetupRealloc(
  79. Pages[PageType],
  80. offsetof(SETUP_REQUEST_PAGES,Pages)
  81. + ((Pages[PageType]->MaxPages + pages->MaxPages) * sizeof(HPROPSHEETPAGE))
  82. );
  83. if(p) {
  84. Pages[PageType] = p;
  85. CopyMemory(
  86. &p->Pages[p->MaxPages],
  87. pages->Pages,
  88. pages->MaxPages * sizeof(HPROPSHEETPAGE)
  89. );
  90. Pages[PageType]->MaxPages += pages->MaxPages;
  91. pSetupFree(pages);
  92. } else {
  93. e = ERROR_NOT_ENOUGH_MEMORY;
  94. }
  95. }
  96. } else {
  97. e = NO_ERROR;
  98. }
  99. if (e == ERROR_CALL_COMPONENT) {
  100. continue; // could be a dead component, just go on
  101. }
  102. if((e != NO_ERROR) && (ErrorCode == NO_ERROR)) {
  103. ErrorCode = e;
  104. }
  105. }
  106. } else {
  107. if(ErrorCode == NO_ERROR) {
  108. ErrorCode = ERROR_NOT_ENOUGH_MEMORY;
  109. }
  110. }
  111. }
  112. // set flag if there are no pages before the oc page
  113. if (OcManager->SetupData.OperationFlags & SETUPOP_STANDALONE) {
  114. if (!Pages[WizPagesWelcome]->MaxPages
  115. && !Pages[WizPagesMode]->MaxPages) {
  116. OcManager->InternalFlags |= OCMFLAG_NOPREOCPAGES;
  117. }
  118. }
  119. return(ErrorCode);
  120. }