/*++ Copyright (c) 1997-1998 Microsoft Corporation Module Name: menu.c Abstract: This module contains the code to process OS Chooser message for the BINL server. Author: Adam Barr (adamba) 9-Jul-1997 Geoff Pease (gpease) 10-Nov-1997 Environment: User Mode - Win32 Revision History: --*/ #include "binl.h" #pragma hdrstop BOOL IsIncompatibleRiprepSIF( PCHAR Path, PCLIENT_STATE clientState ) { CHAR HalName[32]; CHAR ImageType[32]; PCHAR DetectedHalName; BOOL RetVal; ImageType[0] = '\0'; HalName[0] = '\0'; // // if it's not an RIPREP image, then just bail out. // GetPrivateProfileStringA( OSCHOOSER_SIF_SECTIONA, "ImageType", "", ImageType, sizeof(ImageType)/sizeof(ImageType[0]), Path ); if (0 != StrCmpIA(ImageType,"SYSPREP")) { RetVal = FALSE; goto exit; } // // retrieve the hal name from the SIF file // GetPrivateProfileStringA( OSCHOOSER_SIF_SECTIONA, "HalName", "", HalName, sizeof(HalName)/sizeof(HalName[0]), Path ); // // if the hal name isn't present, assume it's an old SIF that // doesn't have the hal type in it, and so we just return success // if (*HalName == '\0') { RetVal = FALSE; goto exit; } // // retrieve the detected HAL type from earlier // DetectedHalName = OscFindVariableA( clientState, "HALTYPE" ); if (StrCmpIA(HalName,DetectedHalName)==0) { RetVal = FALSE; goto exit; } // // if we got this far, the SIF file is incompatible // RetVal = TRUE; exit: return(RetVal); } DWORD OscAppendTemplatesMenus( PCHAR *GeneratedScreen, PDWORD dwGeneratedSize, PCHAR DirToEnum, PCLIENT_STATE clientState, BOOLEAN RecoveryOptionsOnly ) { DWORD Error = ERROR_SUCCESS; WIN32_FIND_DATA FindData; HANDLE hFind; int x = 1; CHAR Path[MAX_PATH]; WCHAR UnicodePath[MAX_PATH]; DWORD dwGeneratedCurrentLength; TraceFunc("OscAppendTemplatesMenus( )\n"); BinlAssert( *GeneratedScreen != NULL ); // // The incoming size is the current length of the buffer // dwGeneratedCurrentLength = *dwGeneratedSize; // Resulting string should be something like: // "D:\RemoteInstall\English\Images\nt50.wks\i386\Templates\*.sif" if ( _snprintf( Path, sizeof(Path) / sizeof(Path[0]), "%s\\%s\\Templates\\*.sif", DirToEnum, OscFindVariableA( clientState, "MACHINETYPE" ) ) == -1 ) { Error = ERROR_BAD_PATHNAME; goto Cleanup; } mbstowcs( UnicodePath, Path, strlen(Path) + 1 ); BinlPrintDbg(( DEBUG_OSC, "Enumerating: %s\n", Path )); hFind = FindFirstFile( UnicodePath, (LPVOID) &FindData ); if ( hFind != INVALID_HANDLE_VALUE ) { DWORD dwPathLen; dwPathLen = strlen( Path ); do { // // If it is not a directory, try to open it // if (!(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { CHAR Description[DESCRIPTION_SIZE]; CHAR HelpLines[HELPLINES_SIZE]; PCHAR NewScreen; // temporary points to newly generated screen DWORD dwErr; DWORD dwFileNameLen; CHAR NewItems[ MAX_PATH * 2 + 512 ]; // arbitrary size DWORD dwNewItemsLength; BOOLEAN IsCmdConsSif; BOOLEAN IsASRSif; BOOLEAN IsRecoveryOption; // // Resulting string should be something like: // "D:\RemoteInstall\English\Images\nt50.wks\i386\Templates\Winnt.Sif" dwFileNameLen = wcslen(FindData.cFileName); if (dwPathLen + dwFileNameLen - 4 > sizeof(Path) / sizeof(Path[0])) { continue; // path too long, skip it } wcstombs( &Path[dwPathLen - 5], FindData.cFileName, dwFileNameLen + 1 ); BinlPrintDbg(( DEBUG_OSC, "Found SIF File: %s\n", Path )); // // Check that the image is the type we are looking for // IsCmdConsSif = OscSifIsCmdConsA(Path); IsASRSif = OscSifIsASR(Path); IsRecoveryOption = ( IsCmdConsSif || IsASRSif ) ? TRUE : FALSE; if ((RecoveryOptionsOnly && !IsRecoveryOption) || (!RecoveryOptionsOnly && IsRecoveryOption)) { continue; // not readable, skip it } if (IsIncompatibleRiprepSIF(Path,clientState)) { // // skip it // BinlPrintDbg(( DEBUG_OSC, "Skipping %s because it's an incompatible RIPREP SIF\n", Path )); continue; } // // Retrieve the description // dwErr = GetPrivateProfileStringA(OSCHOOSER_SIF_SECTIONA, "Description", "", Description, DESCRIPTION_SIZE, Path ); if ( dwErr == 0 || Description[0] == L'\0' ) continue; // not readible, skip it // // Retrieve the help lines // dwErr = GetPrivateProfileStringA(OSCHOOSER_SIF_SECTIONA, "Help", "", HelpLines, HELPLINES_SIZE, Path ); // // Create the new item that look like this: //