Changeset 93580 in vbox for trunk/src/VBox
- Timestamp:
- Feb 3, 2022 1:35:16 PM (3 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/UnattendedImpl.h
r93579 r93580 41 41 Utf8Str mArch; 42 42 uint32_t mImageIndex; 43 VBOXOSTYPE mOSType; 44 WIMImage() : mImageIndex(0), mOSType(VBOXOSTYPE_Unknown) { } 43 45 const Utf8Str &formatName(Utf8Str &r_strName) const; 44 46 }; -
trunk/src/VBox/Main/src-server/UnattendedImpl.cpp
r93579 r93580 444 444 445 445 /** 446 * Tries to set the image architecture. 447 * 448 * Input examples (x86 and amd64 respectively): 449 * @verbatim 450 * <ARCH>0</ARCH> 451 * <ARCH>9</ARCH> 452 * @endverbatim 453 * 454 * Will set mArch and update mOSType on success. 455 * 456 * @param pElmArch Points to the vesion XML node, 457 * @param rImage Out reference to an WIMImage instance. 458 */ 459 static void parseArchElement(const xml::ElementNode *pElmArch, WIMImage &rImage) 460 { 461 /* These are from winnt.h */ 462 static struct { const char *pszArch; VBOXOSTYPE enmArch; } s_aArches[] = 463 { 464 /* PROCESSOR_ARCHITECTURE_INTEL / [0] = */ { "x86", VBOXOSTYPE_x86 }, 465 /* PROCESSOR_ARCHITECTURE_MIPS / [1] = */ { "mips", VBOXOSTYPE_UnknownArch }, 466 /* PROCESSOR_ARCHITECTURE_ALPHA / [2] = */ { "alpha", VBOXOSTYPE_UnknownArch }, 467 /* PROCESSOR_ARCHITECTURE_PPC / [3] = */ { "ppc", VBOXOSTYPE_UnknownArch }, 468 /* PROCESSOR_ARCHITECTURE_SHX / [4] = */ { "shx", VBOXOSTYPE_UnknownArch }, 469 /* PROCESSOR_ARCHITECTURE_ARM / [5] = */ { "arm32", VBOXOSTYPE_arm32 }, 470 /* PROCESSOR_ARCHITECTURE_IA64 / [6] = */ { "ia64", VBOXOSTYPE_UnknownArch }, 471 /* PROCESSOR_ARCHITECTURE_ALPHA64 / [7] = */ { "alpha64", VBOXOSTYPE_UnknownArch }, 472 /* PROCESSOR_ARCHITECTURE_MSIL / [8] = */ { "msil", VBOXOSTYPE_UnknownArch }, 473 /* PROCESSOR_ARCHITECTURE_AMD64 / [9] = */ { "x64", VBOXOSTYPE_x64 }, 474 /* PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 / [10] = */ { "x86-on-x64", VBOXOSTYPE_UnknownArch }, 475 /* PROCESSOR_ARCHITECTURE_NEUTRAL / [11] = */ { "noarch", VBOXOSTYPE_UnknownArch }, 476 /* PROCESSOR_ARCHITECTURE_ARM64 / [12] = */ { "arm64", VBOXOSTYPE_arm64 }, 477 /* PROCESSOR_ARCHITECTURE_ARM32_ON_WIN64/ [13] = */ { "arm32-on-arm64", VBOXOSTYPE_UnknownArch }, 478 /* PROCESSOR_ARCHITECTURE_IA32_ON_ARM64 / [14] = */ { "x86-on-arm32", VBOXOSTYPE_UnknownArch }, 479 }; 480 const char *pszArch = pElmArch->getValue(); 481 if (pszArch && *pszArch) 482 { 483 uint32_t uArch; 484 int vrc = RTStrToUInt32Ex(pszArch, NULL, 10 /*uBase*/, &uArch); 485 if ( RT_SUCCESS(vrc) 486 && vrc != VWRN_NUMBER_TOO_BIG 487 && vrc != VWRN_NEGATIVE_UNSIGNED 488 && uArch < RT_ELEMENTS(s_aArches)) 489 { 490 rImage.mArch = s_aArches[uArch].pszArch; 491 rImage.mOSType = (VBOXOSTYPE)(s_aArches[uArch].enmArch | (rImage.mOSType & VBOXOSTYPE_ArchitectureMask)); 492 } 493 else 494 LogRel(("Unattended: bogus ARCH element value: '%s'\n", pszArch)); 495 } 496 } 497 498 /** 446 499 * Parses XML Node assuming a structure as follows 447 500 * @verbatim … … 453 506 * </VERSION> 454 507 * @endverbatim 508 * 509 * Will update mOSType as well as setting mVersion on success. 510 * 455 511 * @param pNode Points to the vesion XML node, 456 512 * @param image Out reference to an WIMImage instance. … … 459 515 { 460 516 /* Major part: */ 461 const xml::ElementNode *pMajorNode = pNode->findChildElement("MAJOR"); 462 if (!pMajorNode) 463 pMajorNode = pNode->findChildElement("major"); 464 if (!pMajorNode) 465 pMajorNode = pNode->findChildElement("Major"); 466 if (pMajorNode) 467 { 468 const char * const pszMajor = pMajorNode->getValue(); 517 const xml::ElementNode *pElmMajor; 518 if ( (pElmMajor = pNode->findChildElement("MAJOR")) != NULL 519 || (pElmMajor = pNode->findChildElement("major")) != NULL 520 || (pElmMajor = pNode->findChildElement("Major")) != NULL) 521 if (pElmMajor) 522 { 523 const char * const pszMajor = pElmMajor->getValue(); 469 524 if (pszMajor && *pszMajor) 470 525 { 471 526 /* Minor part: */ 472 const ElementNode *pMinorNode = pNode->findChildElement("MINOR"); 473 if (!pMinorNode) 474 pMinorNode = pNode->findChildElement("minor"); 475 if (!pMinorNode) 476 pMinorNode = pNode->findChildElement("Minor"); 477 if (pMinorNode) 527 const ElementNode *pElmMinor; 528 if ( (pElmMinor = pNode->findChildElement("MINOR")) != NULL 529 || (pElmMinor = pNode->findChildElement("minor")) != NULL 530 || (pElmMinor = pNode->findChildElement("Minor")) != NULL) 478 531 { 479 const char * const pszMinor = p MinorNode->getValue();532 const char * const pszMinor = pElmMinor->getValue(); 480 533 if (pszMinor && *pszMinor) 481 534 { 482 535 /* Build: */ 483 const ElementNode *pBuildNode = pNode->findChildElement("BUILD"); 484 if (!pBuildNode) 485 pBuildNode = pNode->findChildElement("build"); 486 if (!pBuildNode) 487 pBuildNode = pNode->findChildElement("Build"); 488 if (pBuildNode) 536 const ElementNode *pElmBuild; 537 if ( (pElmBuild = pNode->findChildElement("BUILD")) != NULL 538 || (pElmBuild = pNode->findChildElement("build")) != NULL 539 || (pElmBuild = pNode->findChildElement("Build")) != NULL) 489 540 { 490 const char * const pszBuild = p BuildNode->getValue();541 const char * const pszBuild = pElmBuild->getValue(); 491 542 if (pszBuild && *pszBuild) 492 543 { 493 544 /* SPBuild: */ 494 const ElementNode *pSpBuildNode = pNode->findChildElement("SPBUILD"); 495 if (!pSpBuildNode) 496 pSpBuildNode = pNode->findChildElement("spbuild"); 497 if (!pSpBuildNode) 498 pSpBuildNode = pNode->findChildElement("Spbuild"); 499 if (!pSpBuildNode) 500 pSpBuildNode = pNode->findChildElement("SpBuild"); 501 if (pSpBuildNode && pSpBuildNode->getValue() && *pSpBuildNode->getValue()) 502 image.mVersion.printf("%s.%s.%s.%s", pszMajor, pszMinor, pszBuild, pSpBuildNode->getValue()); 545 const ElementNode *pElmSpBuild; 546 if ( ( (pElmSpBuild = pNode->findChildElement("SPBUILD")) != NULL 547 || (pElmSpBuild = pNode->findChildElement("spbuild")) != NULL 548 || (pElmSpBuild = pNode->findChildElement("Spbuild")) != NULL 549 || (pElmSpBuild = pNode->findChildElement("SpBuild")) != NULL) 550 && pElmSpBuild->getValue() 551 && *pElmSpBuild->getValue() != '\0') 552 image.mVersion.printf("%s.%s.%s.%s", pszMajor, pszMinor, pszBuild, pElmSpBuild->getValue()); 503 553 else 504 554 image.mVersion.printf("%s.%s.%s", pszMajor, pszMinor, pszBuild); 555 556 /* 557 * Convert that to a version windows OS ID (newest first!). 558 */ 559 /** @todo detect server editions. */ 560 VBOXOSTYPE enmVersion = VBOXOSTYPE_Unknown; 561 if (RTStrVersionCompare(image.mVersion.c_str(), "10.0.22000.0") >= 0) 562 enmVersion = VBOXOSTYPE_Win11_x64; 563 else if (RTStrVersionCompare(image.mVersion.c_str(), "10.0") >= 0) 564 enmVersion = VBOXOSTYPE_Win10; 565 else if (RTStrVersionCompare(image.mVersion.c_str(), "6.3") >= 0) 566 enmVersion = VBOXOSTYPE_Win81; 567 else if (RTStrVersionCompare(image.mVersion.c_str(), "6.2") >= 0) 568 enmVersion = VBOXOSTYPE_Win8; 569 else if (RTStrVersionCompare(image.mVersion.c_str(), "6.1") >= 0) 570 enmVersion = VBOXOSTYPE_Win7; 571 else if (RTStrVersionCompare(image.mVersion.c_str(), "6.0") >= 0) 572 enmVersion = VBOXOSTYPE_WinVista; 573 if (enmVersion != VBOXOSTYPE_Unknown) 574 image.mOSType = (VBOXOSTYPE)( (image.mOSType & VBOXOSTYPE_ArchitectureMask) 575 | (enmVersion & VBOXOSTYPE_OsTypeMask)); 576 return; 505 577 } 506 578 } 507 508 579 } 509 580 } 510 581 } 511 582 } 583 Log(("Unattended: Warning! Bogus/missing version info for image #%u / %s\n", image.mImageIndex, image.mName.c_str())); 512 584 } 513 585 … … 525 597 * ... 526 598 * </VERSION> 599 * <LANGUAGES> 600 * <LANGUAGE> 601 * en-US 602 * </LANGUAGE> 603 * <DEFAULT> 604 * en-US 605 * </DEFAULT> 606 * </LANGUAGES> 527 607 * </WINDOWS> 528 608 * </IMAGE> … … 558 638 continue; 559 639 560 const ElementNode *pDisplayDescriptionNode = pChild->findChildElement("DISPLAYNAME"); 561 if (!pDisplayDescriptionNode) 562 pDisplayDescriptionNode = pChild->findChildElement("displayname"); 563 if (!pDisplayDescriptionNode) 564 pDisplayDescriptionNode = pChild->findChildElement("Displayname"); 565 if (!pDisplayDescriptionNode) 566 pDisplayDescriptionNode = pChild->findChildElement("DisplayName"); 567 if (!pDisplayDescriptionNode) 568 pDisplayDescriptionNode = pChild->findChildElement("NAME"); /* Early vista images didn't have DISPLAYNAME. */ 569 if (!pDisplayDescriptionNode) 570 pDisplayDescriptionNode = pChild->findChildElement("name"); 571 if (!pDisplayDescriptionNode) 572 pDisplayDescriptionNode = pChild->findChildElement("Name"); 573 if (!pDisplayDescriptionNode) 640 const ElementNode *pElmName; 641 if ( (pElmName = pChild->findChildElement("DISPLAYNAME")) == NULL 642 && (pElmName = pChild->findChildElement("displayname")) == NULL 643 && (pElmName = pChild->findChildElement("Displayname")) == NULL 644 && (pElmName = pChild->findChildElement("DisplayName")) == NULL 645 /* Early vista images didn't have DISPLAYNAME. */ 646 && (pElmName = pChild->findChildElement("NAME")) == NULL 647 && (pElmName = pChild->findChildElement("name")) == NULL 648 && (pElmName = pChild->findChildElement("Name")) == NULL) 574 649 continue; 575 newImage.mName = p DisplayDescriptionNode->getValue();650 newImage.mName = pElmName->getValue(); 576 651 if (newImage.mName.isEmpty()) 577 652 continue; 578 653 579 const ElementNode *pElmWindows = pChild->findChildElement("WINDOWS"); 580 if (!pElmWindows) 581 pElmWindows = pChild->findChildElement("windows"); 582 if (!pElmWindows) 583 pElmWindows = pChild->findChildElement("Windows"); 584 if (pElmWindows) 585 { 586 const ElementNode *pVersionElement = pElmWindows->findChildElement("VERSION"); 587 if (!pVersionElement) 588 pVersionElement = pChild->findChildElement("version"); 589 if (!pVersionElement) 590 pVersionElement = pChild->findChildElement("Version"); 591 if (pVersionElement) 592 parseVersionElement(pVersionElement, newImage); 654 const ElementNode *pElmWindows; 655 if ( (pElmWindows = pChild->findChildElement("WINDOWS")) != NULL 656 || (pElmWindows = pChild->findChildElement("windows")) != NULL 657 || (pElmWindows = pChild->findChildElement("Windows")) != NULL) 658 { 659 const ElementNode *pElmVersion; 660 if ( (pElmVersion = pElmWindows->findChildElement("VERSION")) != NULL 661 || (pElmVersion = pElmWindows->findChildElement("version")) != NULL 662 || (pElmVersion = pElmWindows->findChildElement("Version")) != NULL) 663 parseVersionElement(pElmVersion, newImage); 593 664 594 665 /* The ARCH element contains a number from the 595 666 PROCESSOR_ARCHITECTURE_XXX set of defines in winnt.h: */ 596 static const char * const s_apszArchs[] = 597 { 598 /* PROCESSOR_ARCHITECTURE_INTEL / [0] = */ "x86", 599 /* PROCESSOR_ARCHITECTURE_MIPS / [1] = */ "mips", 600 /* PROCESSOR_ARCHITECTURE_ALPHA / [2] = */ "alpha", 601 /* PROCESSOR_ARCHITECTURE_PPC / [3] = */ "ppc", 602 /* PROCESSOR_ARCHITECTURE_SHX / [4] = */ "shx", 603 /* PROCESSOR_ARCHITECTURE_ARM / [5] = */ "arm32", 604 /* PROCESSOR_ARCHITECTURE_IA64 / [6] = */ "ia64", 605 /* PROCESSOR_ARCHITECTURE_ALPHA64 / [7] = */ "alpha64", 606 /* PROCESSOR_ARCHITECTURE_MSIL / [8] = */ "msil", 607 /* PROCESSOR_ARCHITECTURE_AMD64 / [9] = */ "x64", 608 /* PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 / [10] = */ "x86-on-x64", 609 /* PROCESSOR_ARCHITECTURE_NEUTRAL / [11] = */ "noarch", 610 /* PROCESSOR_ARCHITECTURE_ARM64 / [12] = */ "arm64", 611 /* PROCESSOR_ARCHITECTURE_ARM32_ON_WIN64/ [13] = */ "arm32-on-arm64", 612 /* PROCESSOR_ARCHITECTURE_IA32_ON_ARM64 / [14] = */ "x86-on-arm32", 613 }; 614 const ElementNode *pElmArch = pElmWindows->findChildElement("ARCH"); 615 if (!pElmArch) 616 pElmArch = pElmWindows->findChildElement("arch"); 617 if (!pElmArch) 618 pElmArch = pElmWindows->findChildElement("Arch"); 619 if (pElmArch) 620 { 621 const char *pszArch = pElmArch->getValue(); 622 if (pszArch && *pszArch) 623 { 624 uint32_t uArch; 625 int vrc = RTStrToUInt32Ex(pszArch, NULL, 10 /*uBase*/, &uArch); 626 if ( RT_SUCCESS(vrc) 627 && vrc != VWRN_NUMBER_TOO_BIG 628 && vrc != VWRN_NEGATIVE_UNSIGNED 629 && uArch < RT_ELEMENTS(s_apszArchs)) 630 newImage.mArch = s_apszArchs[uArch]; 631 else 632 LogRel(("Unattended: bogus ARCH element value: '%s'\n", pszArch)); 633 } 634 } 667 const ElementNode *pElmArch; 668 if ( (pElmArch = pElmWindows->findChildElement("ARCH")) != NULL 669 || (pElmArch = pElmWindows->findChildElement("arch")) != NULL 670 || (pElmArch = pElmWindows->findChildElement("Arch")) != NULL) 671 parseArchElement(pElmArch, newImage); 635 672 } 636 673
Note:
See TracChangeset
for help on using the changeset viewer.