VirtualBox

Changeset 44339 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Jan 23, 2013 3:32:39 PM (12 years ago)
Author:
vboxsync
Message:

VBoxDrvInst: Try using advpack.dll for DefaultInstall actions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Installer/VBoxDrvInst.cpp

    r43033 r44339  
    5757} DIFXAPI_LOG;
    5858
    59 typedef void (WINAPI * DIFXLOGCALLBACK_W)( DIFXAPI_LOG Event, DWORD Error, PCWSTR EventDescription, PVOID CallbackContext);
    60 typedef void ( __cdecl* DIFXAPILOGCALLBACK_W)( DIFXAPI_LOG Event, DWORD Error, PCWSTR EventDescription, PVOID CallbackContext);
     59typedef void (WINAPI * DIFXLOGCALLBACK_W) (DIFXAPI_LOG Event, DWORD Error, PCWSTR EventDescription, PVOID CallbackContext);
     60typedef void ( __cdecl* DIFXAPILOGCALLBACK_W) (DIFXAPI_LOG Event, DWORD Error, PCWSTR EventDescription, PVOID CallbackContext);
    6161
    6262typedef DWORD (WINAPI *fnDriverPackageInstall) (PCTSTR DriverPackageInfPath, DWORD Flags, PCINSTALLERINFO pInstallerInfo, BOOL *pNeedReboot);
     
    6868typedef VOID (WINAPI *fnDIFXAPISetLogCallback) (DIFXAPILOGCALLBACK_W LogCallback, PVOID CallbackContext);
    6969fnDIFXAPISetLogCallback g_pfnDIFXAPISetLogCallback = NULL;
     70
     71typedef HRESULT (WINAPI *fnLaunchINFSectionEx) (HWND hwnd, HINSTANCE hInst, PSTR pszParams, INT nShow);
     72fnLaunchINFSectionEx g_pfnLaunchINFSectionEx = NULL;
    7073
    7174/* Defines */
     
    358361 *
    359362 * @return  Exit code (EXIT_OK, EXIT_FAIL)
     363 * @param   pszInf              Full qualified path of the .INF file to use.
    360364 * @param   pszSection          Section to execute; usually it's "DefaultInstall".
    361365 * @param   iMode               Execution mode to use (see MSDN).
    362  * @param   pszInf              Full qualified path of the .INF file to use.
    363366 */
    364 int ExecuteInfFile(const _TCHAR *pszSection, int iMode, const _TCHAR *pszInf)
     367int ExecuteInfFile(const _TCHAR *pszInf, const _TCHAR *pszSection, int iMode)
    365368{
    366369    _tprintf(_T("Executing INF-File: %ws (Section: %ws) ...\n"), pszInf, pszSection);
    367370
    368371    /* Executed by the installer that already has proper privileges. */
    369     _TCHAR szCommandLine[_MAX_PATH + 1] = { 0 };
    370     swprintf(szCommandLine, sizeof(szCommandLine), TEXT( "%ws %d %ws" ), pszSection, iMode, pszInf);
     372
     373    HRESULT hr = S_OK;
     374    HMODULE hAdvPack = LoadLibrary(_T("advpack.dll"));
     375    if (NULL == hAdvPack)
     376    {
     377        _tprintf(_T("ERROR: Unable to locate advpack.dll!\n"));
     378        hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
     379    }
     380    else
     381    {
     382        g_pfnLaunchINFSectionEx = (fnLaunchINFSectionEx)GetProcAddress(hAdvPack, "LaunchINFSectionEx");
     383        if (g_pfnLaunchINFSectionEx == NULL)
     384        {
     385            _tprintf(_T("ERROR: Unable to retrieve entry point for LaunchINFSectionEx!\n"));
     386            hr = HRESULT_FROM_WIN32(ERROR_PROC_NOT_FOUND);
     387        }
     388    }
    371389
    372390#ifdef DEBUG
    373     _tprintf (_T( "Commandline: %ws\n"), szCommandLine);
     391    _tprintf (_T( "pfnLaunchINFSectionEx=%p\n"), g_pfnLaunchINFSectionEx);
    374392#endif
    375393
    376     InstallHinfSection(NULL, NULL, szCommandLine, SW_SHOW);
    377     /* No return value given! */
     394    if (!g_pfnLaunchINFSectionEx)
     395    {
     396        _TCHAR szCommandLine[_MAX_PATH + 1] = { 0 };
     397
     398        swprintf(szCommandLine, sizeof(szCommandLine), TEXT("%ws %d %ws"),
     399                 pszSection, iMode, pszInf);
     400
     401        InstallHinfSection(NULL /* hWnd */, NULL /* hInst */,
     402                           szCommandLine, SW_SHOW);
     403        /* No return value given! */
     404    }
     405    else
     406    {
     407        char szCommandLine[_MAX_PATH + 1] = { 0 };
     408
     409        /* 4 means silent mode. */
     410        _snprintf(szCommandLine, sizeof(szCommandLine), "%ws,%ws,,4",
     411                  pszInf, pszSection);
     412
     413        hr = g_pfnLaunchINFSectionEx(NULL /* hWnd */, NULL /* hInst */,
     414                                     szCommandLine, 0 /* Not used */);
     415        if (FAILED(hr))
     416            _tprintf(_T("ERROR: LaunchINFSectionEx failed: 0x%08lx\n"), hr);
     417    }
     418
     419    if (NULL != hAdvPack)
     420       FreeLibrary(hAdvPack);
    378421
    379422    return EXIT_OK;
     
    10671110            {
    10681111                _sntprintf(szINF, sizeof(szINF) / sizeof(TCHAR), _T("%ws"), argv[3]);
    1069                 rc = ExecuteInfFile(_T("DefaultInstall"), 132, szINF);
     1112                rc = ExecuteInfFile(szINF, _T("DefaultInstall"), 132);
    10701113            }
    10711114        }
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