VirtualBox

Changeset 46513 in vbox


Ignore:
Timestamp:
Jun 12, 2013 3:26:23 PM (11 years ago)
Author:
vboxsync
Message:

Forward ported / integrated r86363 (4.2: VBoxService/sysprep: Fixed slashes, more logging about looking up executable. Print warning when trying to execute sysprep on 64-bit OSes with 32-bit service executable).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlProcess.cpp

    r46506 r46513  
    14521452        /* Use a predefined sysprep path as default. */
    14531453        char szSysprepCmd[RTPATH_MAX] = "C:\\sysprep\\sysprep.exe";
     1454        /** @todo Check digital signature of file above before executing it? */
    14541455
    14551456        /*
    1456          * On Windows Vista (and up) sysprep is located in "system32\\sysprep\\sysprep.exe",
     1457         * On Windows Vista (and up) sysprep is located in "system32\\Sysprep\\sysprep.exe",
    14571458         * so detect the OS and use a different path.
    14581459         */
     
    14601461        RT_ZERO(OSInfoEx);
    14611462        OSInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
    1462         if (    GetVersionEx((LPOSVERSIONINFO) &OSInfoEx)
     1463        BOOL fRet = GetVersionEx((LPOSVERSIONINFO) &OSInfoEx);
     1464        if (    fRet
    14631465            &&  OSInfoEx.dwPlatformId == VER_PLATFORM_WIN32_NT
    14641466            &&  OSInfoEx.dwMajorVersion >= 6 /* Vista or later */)
    14651467        {
    14661468            rc = RTEnvGetEx(RTENV_DEFAULT, "windir", szSysprepCmd, sizeof(szSysprepCmd), NULL);
     1469#ifndef RT_ARCH_AMD64
     1470            /* Don't execute 64-bit sysprep from a 32-bit service host! */
     1471            char szSysWow64[RTPATH_MAX];
     1472            if (RTStrPrintf(szSysWow64, sizeof(szSysWow64), "%s", szSysprepCmd))
     1473            {
     1474                rc = RTPathAppend(szSysWow64, sizeof(szSysWow64), "SysWow64");
     1475                AssertRC(rc);
     1476            }
     1477            if (   RT_SUCCESS(rc)
     1478                && RTPathExists(szSysWow64))
     1479                VBoxServiceVerbose(0, "Warning: This service is 32-bit; could not execute sysprep on 64-bit OS!\n");
     1480#endif
    14671481            if (RT_SUCCESS(rc))
    1468                 rc = RTPathAppend(szSysprepCmd, sizeof(szSysprepCmd), "system32\\sysprep\\sysprep.exe");
    1469         }
     1482                rc = RTPathAppend(szSysprepCmd, sizeof(szSysprepCmd), "system32\\Sysprep\\sysprep.exe");
     1483            if (RT_SUCCESS(rc))
     1484                RTPathChangeToDosSlashes(szSysprepCmd, false /* No forcing necessary */);
     1485
     1486            if (RT_FAILURE(rc))
     1487                VBoxServiceError("Failed to detect sysrep location, rc=%Rrc\n", rc);
     1488        }
     1489        else if (!fRet)
     1490            VBoxServiceError("Failed to retrieve OS information, last error=%ld\n", GetLastError());
     1491
     1492        VBoxServiceVerbose(3, "Sysprep executable is: %s\n", szSysprepCmd);
    14701493
    14711494        if (RT_SUCCESS(rc))
     
    14761499            if (RT_SUCCESS(rc))
    14771500            {
     1501                /* As we don't specify credentials for the sysprep process, it will
     1502                 * run under behalf of the account VBoxService was started under, most
     1503                 * likely local system. */
    14781504                rc = RTProcCreateEx(szSysprepCmd, papszArgsExp, hEnv, 0 /* fFlags */,
    14791505                                    phStdIn, phStdOut, phStdErr, NULL /* pszAsUser */,
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette