Windows NT 4.0 source code leak
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.

234 lines
4.7 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1991-1996 Microsoft Corporation
  3. Copyright (c) 1992, 1992 Digital Equipment Corporation
  4. Module Name:
  5. arcinst.c
  6. Abstract:
  7. This module contains the code that prepares a ARC compliant platform
  8. for OS installation. It creates system partitions and formats system
  9. partitions
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. PCHAR Banner1 = " Arc Installation Program Version 4.00";
  14. PCHAR Banner2 = " Copyright (c) 1991-1996 Microsoft Corporation";
  15. //
  16. // Menu definitions
  17. //
  18. PCHAR rgszMainMenu[] = {
  19. "Configure Partitions",
  20. "Exit"
  21. };
  22. //
  23. // NOTE! This must be the number of entries in rgszMainMenu. It is used
  24. // to tell AddMenuItems the number of menu items to add.
  25. //
  26. #define CSZMENUITEMS 2
  27. //
  28. // NOTE! These must be kept in sync with the indices for rgszMainMenu
  29. // The main menu is created by AddMenuItems which will generated
  30. // associated data values based upon the index into the array of
  31. // strings passed in. These #defines must match those values
  32. // or the switch statement used to handle the menu selection will
  33. // dispatch to the wrong code.
  34. //
  35. #define CONFIG_SYS_PARTITION 0
  36. #define EXIT 1
  37. #define MENU_START_ROW 4
  38. #define ERROR_ROW_TOP 13
  39. #define ERROR_ROW_BOTTOM 16
  40. //
  41. // Max size for a path or environment variable
  42. //
  43. #define MAX_PATH 256
  44. //
  45. // Max bytes in a line
  46. //
  47. #define CBMAXLINE 120
  48. //
  49. // Define constants to generate a 2 meg stack and a 2 meg heap.
  50. //
  51. #define ARCINST_STACK_PAGES (2*1024*1024 / PAGE_SIZE)
  52. #define ARCINST_HEAP_PAGES (2*1024*1024 / PAGE_SIZE)
  53. ARC_STATUS GetTitlesAndPaths ( PCHAR, PCHAR, ULONG, ULONG, PCHAR **,PULONG, PCHAR **, PULONG);
  54. ARC_STATUS GetSectionElementList ( PCHAR, PCHAR, ULONG, PCHAR **, PULONG );
  55. ARC_STATUS CopySection( PCHAR, PCHAR, PCHAR, PCHAR );
  56. ARC_STATUS UpdateOSFiles( PCHAR, PCHAR, PCHAR );
  57. VOID PrintError( PCHAR, ... );
  58. // Needed for C string functions
  59. int errno;
  60. ARC_STATUS __cdecl
  61. main(
  62. IN ULONG argc,
  63. IN PCHAR argv[],
  64. IN PCHAR envp[]
  65. )
  66. {
  67. PCHAR szSysPartition = NULL;
  68. PCHAR szInfPath = NULL;
  69. PVOID hdMenuId;
  70. ULONG MenuChoice;
  71. DBG_UNREFERENCED_PARAMETER( argc );
  72. DBG_UNREFERENCED_PARAMETER( argv );
  73. DBG_UNREFERENCED_PARAMETER( envp );
  74. if (AlMemoryInitialize (ARCINST_STACK_PAGES, ARCINST_HEAP_PAGES) != ESUCCESS) {
  75. PrintError(NULL, "Failed to initialize the heap");
  76. return( ESUCCESS );
  77. }
  78. if (!AlInitializeMenuPackage()) {
  79. PrintError(NULL, "Could not initialize menu package");
  80. return( ESUCCESS );
  81. }
  82. if (FdiskInitialize() != ESUCCESS) {
  83. PrintError(NULL, "Failed to initialize the FDISK package");
  84. return( ESUCCESS );
  85. }
  86. if (!AlNewMenu(&hdMenuId)) {
  87. PrintError(NULL, "Could not create main menu");
  88. return( ESUCCESS );
  89. }
  90. //
  91. // Initialize the main ArcInst menu.
  92. //
  93. // Not that when you add items in this way the associated data becomes
  94. // the index in the array of strings. Make sure the values used for
  95. // associated data the predefined values CHANGE_ENV etc.
  96. //
  97. if (!AlAddMenuItems(hdMenuId, rgszMainMenu, CSZMENUITEMS)) {
  98. PrintError(NULL, "Failed to Initialize Main Menu");
  99. return( ESUCCESS );
  100. }
  101. //
  102. // Loop till Exit or an ESC key is it.
  103. //
  104. while (TRUE) {
  105. //
  106. // Print Banner
  107. //
  108. AlClearScreen();
  109. AlSetPosition(1, 0);
  110. AlPrint(Banner1);
  111. AlPrint("\r\n");
  112. AlPrint(Banner2);
  113. if (!AlDisplayMenu(hdMenuId,
  114. FALSE,
  115. CONFIG_SYS_PARTITION,
  116. &MenuChoice,
  117. MENU_START_ROW,
  118. 0)) {
  119. //
  120. // User hit ESC key
  121. //
  122. return( ESUCCESS );
  123. }
  124. switch (MenuChoice) {
  125. case CONFIG_SYS_PARTITION:
  126. ConfigureSystemPartitions();
  127. break;
  128. case EXIT:
  129. return(ESUCCESS);
  130. break;
  131. }
  132. }
  133. }
  134. VOID
  135. PrintError(
  136. IN PCHAR szFormat,
  137. ...
  138. )
  139. /*++
  140. Routine Description:
  141. This routine prints a error or information message at a specific
  142. location the screen (ERROR_ROW_TOP) and waits for the user to hit
  143. any key.
  144. Arguments:
  145. szFormat - Format string, if NULL then "%s" is used.
  146. szErrorMessage - Text of string to print
  147. Return Value:
  148. none
  149. --*/
  150. {
  151. va_list ArgList;
  152. va_start(ArgList,szFormat);
  153. if (szFormat == NULL ) {
  154. szFormat = "%s";
  155. }
  156. vAlStatusMsg(ERROR_ROW_TOP, TRUE, szFormat, ArgList);
  157. AlWaitKey(NULL);
  158. AlClearStatusArea(ERROR_ROW_TOP, ERROR_ROW_BOTTOM);
  159. }
  160. VOID
  161. JzShowTime (
  162. BOOLEAN First
  163. )
  164. {
  165. return;
  166. }