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.

180 lines
5.7 KiB

  1. /****************************************************************************
  2. Copyright (c) Microsoft Corporation 1997-1999
  3. All rights reserved
  4. ***************************************************************************/
  5. #include "pch.h"
  6. DEFINE_MODULE("RISETUP")
  7. //
  8. // GetAutomatedOptions( )
  9. //
  10. HRESULT
  11. GetAutomatedOptions( )
  12. {
  13. TraceFunc("GetAutomatedOptions( )\n" );
  14. HRESULT hr = S_OK;
  15. BOOL b;
  16. DWORD dwSize;
  17. WCHAR szTemp[ 32 ];
  18. DWORD pathlen,archlen;
  19. WCHAR archscratch[10];
  20. INFCONTEXT SectionContext;
  21. INFCONTEXT context;
  22. Assert( g_Options.hinfAutomated != INVALID_HANDLE_VALUE );
  23. // make sure this is our automated file
  24. b = SetupFindFirstLine( g_Options.hinfAutomated, L"risetup", NULL, &SectionContext );
  25. if ( !b ) goto Cleanup;
  26. // Tree Root
  27. dwSize = ARRAYSIZE( g_Options.szIntelliMirrorPath );
  28. b = SetupFindFirstLine( g_Options.hinfAutomated, L"risetup", L"RootDir", &context );
  29. if ( !b ) goto Cleanup;
  30. b = SetupGetStringField( &context, 1, g_Options.szIntelliMirrorPath, dwSize, &dwSize );
  31. if ( !b ) goto Cleanup;
  32. g_Options.fIMirrorDirectory = TRUE;
  33. // Source Path
  34. dwSize = ARRAYSIZE( g_Options.szSourcePath );
  35. b = SetupFindFirstLine( g_Options.hinfAutomated, L"risetup", L"Source", &context );
  36. if ( !b ) goto Cleanup;
  37. b = SetupGetStringField( &context, 1, g_Options.szSourcePath, dwSize, &dwSize );
  38. if ( !b ) goto Cleanup;
  39. // Installation Directory Name
  40. dwSize = ARRAYSIZE( g_Options.szInstallationName );
  41. b = SetupFindFirstLine( g_Options.hinfAutomated, L"risetup", L"Directory", &context );
  42. if ( !b ) goto Cleanup;
  43. b = SetupGetStringField( &context, 1, g_Options.szInstallationName, dwSize, &dwSize );
  44. if ( !b ) goto Cleanup;
  45. // SIF Description
  46. dwSize = ARRAYSIZE( g_Options.szDescription );
  47. b = SetupFindFirstLine( g_Options.hinfAutomated, L"risetup", L"Description", &context );
  48. if ( !b ) goto Cleanup;
  49. b = SetupGetStringField( &context, 1, g_Options.szDescription, dwSize, &dwSize );
  50. if ( !b ) goto Cleanup;
  51. g_Options.fRetrievedWorkstationString = TRUE;
  52. // SIF Help Text
  53. dwSize = ARRAYSIZE( g_Options.szHelpText );
  54. b = SetupFindFirstLine( g_Options.hinfAutomated, L"risetup", L"HelpText", &context );
  55. if ( !b ) goto Cleanup;
  56. b = SetupGetStringField( &context, 1, g_Options.szHelpText, dwSize, &dwSize );
  57. if ( !b ) goto Cleanup;
  58. // language -- OPTIONAL --
  59. dwSize = ARRAYSIZE( g_Options.szLanguage );
  60. b = SetupFindFirstLine( g_Options.hinfAutomated, L"risetup", L"Language", &context );
  61. if ( b ) {
  62. b = SetupGetStringField( &context, 1, g_Options.szLanguage, dwSize, &dwSize );
  63. g_Options.fLanguageSet = TRUE;
  64. if (b) {
  65. g_Options.fLanguageOverRide = TRUE;
  66. }
  67. }
  68. // OSC Screens - OPTIONAL - defaults to LeaveAlone
  69. g_Options.fScreenLeaveAlone = FALSE;
  70. g_Options.fScreenOverwrite = FALSE;
  71. g_Options.fScreenSaveOld = FALSE;
  72. dwSize = ARRAYSIZE( szTemp );
  73. b = SetupFindFirstLine( g_Options.hinfAutomated, L"risetup", L"Screens", &context );
  74. if ( b )
  75. {
  76. b = SetupGetStringField( &context, 1, szTemp, dwSize, &dwSize );
  77. if ( b )
  78. {
  79. if ( _wcsicmp( szTemp, L"overwrite" ) == 0 )
  80. {
  81. DebugMsg( "AUTO: Overwrite existing screens\n" );
  82. g_Options.fScreenOverwrite = TRUE;
  83. }
  84. else if ( _wcsicmp( szTemp, L"backup" ) == 0 )
  85. {
  86. g_Options.fScreenSaveOld = TRUE;
  87. }
  88. }
  89. }
  90. if ( !g_Options.fScreenOverwrite && !g_Options.fScreenSaveOld )
  91. {
  92. g_Options.fScreenLeaveAlone = TRUE;
  93. }
  94. // Archtecture - OPTIONAL - defaults to INTEL
  95. dwSize = ARRAYSIZE( szTemp );
  96. b = SetupFindFirstLine( g_Options.hinfAutomated, L"risetup", L"Architecture", &context );
  97. if ( b )
  98. {
  99. b = SetupGetStringField( &context, 1, szTemp, dwSize, &dwSize );
  100. if ( b )
  101. {
  102. if ( _wcsicmp( szTemp, L"ia64" ) == 0 )
  103. {
  104. g_Options.ProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64;
  105. wcscpy( g_Options.ProcessorArchitectureString, L"ia64" );
  106. }
  107. if ( _wcsicmp( szTemp, L"x86" ) == 0 )
  108. {
  109. g_Options.ProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
  110. wcscpy( g_Options.ProcessorArchitectureString, L"i386" );
  111. }
  112. }
  113. }
  114. if (g_Options.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) {
  115. wcscpy( archscratch, L"\\i386");
  116. archlen = 5;
  117. } else {
  118. wcscpy( archscratch, L"\\ia64");
  119. archlen = 5;
  120. }
  121. pathlen = (DWORD)wcslen(g_Options.szSourcePath);
  122. // Remove any trailing slashes
  123. if ( g_Options.szSourcePath[ pathlen - 1 ] == L'\\' ) {
  124. g_Options.szSourcePath[ pathlen - 1 ] = L'\0';
  125. pathlen -= 1;
  126. }
  127. //
  128. // remove any processor specific subdir at the end of the path
  129. // if that's there as well, being careful not to underflow
  130. // the array
  131. //
  132. if ( (pathlen > archlen) &&
  133. (0 == _wcsicmp(
  134. &g_Options.szSourcePath[pathlen-archlen],
  135. archscratch))) {
  136. g_Options.szSourcePath[ pathlen - archlen ] = L'\0';
  137. }
  138. g_Options.fNewOS = TRUE;
  139. b = TRUE;
  140. Cleanup:
  141. if ( !b )
  142. {
  143. hr = THR( HRESULT_FROM_WIN32( GetLastError( ) ) );
  144. ErrorBox( NULL, L"RISETUP" );
  145. }
  146. if ( g_Options.hinfAutomated != INVALID_HANDLE_VALUE )
  147. SetupCloseInfFile( g_Options.hinfAutomated );
  148. HRETURN(hr);
  149. }