~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
 
22
22
 
23
 
 
24
23
/*******************************************************************************
25
24
*   Header Files                                                               *
26
25
*******************************************************************************/
36
35
#include <iprt/semaphore.h>
37
36
#include <iprt/system.h>
38
37
#include <iprt/time.h>
39
 
#include <VBox/VBoxGuest.h>
 
38
#include <VBox/VBoxGuestLib.h>
40
39
#include "VBoxServiceInternal.h"
41
40
#include "VBoxServiceUtils.h"
42
41
 
54
53
 
55
54
#ifndef TARGET_NT4
56
55
/* Function GetLUIDsFromProcesses() written by Stefan Kuhr. */
57
 
DWORD VboxServiceVMInfoWinGetLUIDsFromProcesses(PLUID *ppLuid)
 
56
DWORD VBoxServiceVMInfoWinGetLUIDsFromProcesses(PLUID *ppLuid)
58
57
{
59
58
    DWORD dwSize, dwSize2, dwIndex ;
60
59
    LPDWORD lpdwPIDs ;
166
165
    return dwSize2;
167
166
}
168
167
 
169
 
BOOL VboxServiceVMInfoWinIsLoggedIn(VBOXSERVICEVMINFOUSER* a_pUserInfo,
 
168
BOOL VBoxServiceVMInfoWinIsLoggedIn(VBOXSERVICEVMINFOUSER* a_pUserInfo,
170
169
                                    PLUID a_pSession,
171
170
                                    PLUID a_pLuid,
172
171
                                    DWORD a_dwNumOfProcLUIDs)
330
329
 
331
330
#endif /* TARGET_NT4 */
332
331
 
333
 
int VboxServiceWinGetAddsVersion(uint32_t uiClientID)
334
 
{
335
 
    char szInstDir[_MAX_PATH] = {0};
336
 
    char szRev[_MAX_PATH] = {0};
337
 
    char szVer[_MAX_PATH] = {0};
338
 
 
339
 
    HKEY hKey = NULL;
340
 
    int rc;
341
 
    DWORD dwSize = 0;
342
 
    DWORD dwType = 0;
343
 
 
344
 
    VBoxServiceVerbose(3, "Guest Additions version lookup: Looking up ...\n");
345
 
 
346
 
    /* Check the new path first. */
347
 
    rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\VirtualBox Guest Additions", 0, KEY_READ, &hKey);
348
 
#ifdef RT_ARCH_AMD64
349
 
    if (rc != ERROR_SUCCESS)
350
 
    {  
351
 
        /* Check Wow6432Node (for new entries). */
352
 
        rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Sun\\VirtualBox Guest Additions", 0, KEY_READ, &hKey);
353
 
    }
354
 
#endif
355
 
 
356
 
    /* Still no luck? Then try the old xVM paths ... */
357
 
    if (RT_FAILURE(rc))
358
 
    {
359
 
        rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\xVM VirtualBox Guest Additions", 0, KEY_READ, &hKey);
360
 
#ifdef RT_ARCH_AMD64
361
 
        if (rc != ERROR_SUCCESS)
362
 
        {
363
 
            /* Check Wow6432Node (for new entries). */
364
 
            rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Sun\\xVM VirtualBox Guest Additions", 0, KEY_READ, &hKey);
365
 
        }
366
 
#endif
367
 
    }
368
 
 
369
 
    /* Did we get something worth looking at? */
370
 
    if (RT_FAILURE(rc))
371
 
    {
372
 
        VBoxServiceError("Failed to open registry key (guest additions)! Error: %Rrc\n", rc);
373
 
    }
374
 
    else
375
 
    {
376
 
        VBoxServiceVerbose(3, "Guest Additions version lookup: Key: 0x%p, rc: %Rrc\n", hKey, rc);
377
 
        /* Installation directory. */
378
 
        dwSize = sizeof(szInstDir);
379
 
        rc = RegQueryValueEx(hKey, "InstallDir", NULL, &dwType, (BYTE*)(LPCTSTR)szInstDir, &dwSize);
380
 
        if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND))
381
 
        {
382
 
            VBoxServiceError("Failed to query registry key (install directory)! Error: %Rrc\n", rc);
383
 
        }    
384
 
        else
385
 
        {
386
 
            /* Flip slashes. */
387
 
            for (char* pszTmp = &szInstDir[0]; *pszTmp; ++pszTmp)
388
 
                if (*pszTmp == '\\')
389
 
                    *pszTmp = '/';
390
 
        }
391
 
        /* Revision. */
392
 
        dwSize = sizeof(szRev);
393
 
        rc = RegQueryValueEx(hKey, "Revision", NULL, &dwType, (BYTE*)(LPCTSTR)szRev, &dwSize);
394
 
        if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND))
395
 
            VBoxServiceError("Failed to query registry key (revision)! Error: %Rrc\n", rc);
396
 
        /* Version. */
397
 
        dwSize = sizeof(szVer);
398
 
        rc = RegQueryValueEx(hKey, "Version", NULL, &dwType, (BYTE*)(LPCTSTR)szVer, &dwSize);
399
 
        if ((rc != ERROR_SUCCESS) && (rc != ERROR_FILE_NOT_FOUND))
400
 
            VBoxServiceError("Failed to query registry key (version)! Error: %Rrc\n", rc);
401
 
    }
402
 
 
403
 
    /* Write information to host. */
404
 
    VboxServiceWriteProp(uiClientID, "GuestAdd/InstallDir", szInstDir);
405
 
    VboxServiceWriteProp(uiClientID, "GuestAdd/Revision", szRev);
406
 
    VboxServiceWriteProp(uiClientID, "GuestAdd/Version", szVer);
407
 
 
408
 
    if (NULL != hKey)
409
 
        RegCloseKey(hKey);
410
 
 
411
 
    return rc;
412
 
}
413
 
 
414
 
int VboxServiceWinGetComponentVersions(uint32_t uiClientID)
 
332
int VBoxServiceWinGetComponentVersions(uint32_t uiClientID)
415
333
{
416
334
    int rc;
417
335
    char szVer[_MAX_PATH] = {0};
439
357
        { szSysDir, "VBoxService.exe", },
440
358
        { szSysDir, "VBoxTray.exe", },
441
359
        { szSysDir, "VBoxGINA.dll", },
 
360
        { szSysDir, "VBoxCredProv.dll", },
442
361
 
443
362
 /* On 64-bit we don't yet have the OpenGL DLLs in native format.
444
363
    So just enumerate the 32-bit files in the SYSWOW directory. */
492
411
    Assert(pTable);
493
412
    while (pTable->pszFileName)
494
413
    {
495
 
        rc = VboxServiceGetFileVersionString(pTable->pszFilePath, pTable->pszFileName, szVer, sizeof(szVer));
496
 
        RTStrPrintf(szPropPath, sizeof(szPropPath), "GuestAdd/Components/%s", pTable->pszFileName);
497
 
        VboxServiceWriteProp(uiClientID, szPropPath, szVer);
 
414
        rc = VBoxServiceGetFileVersionString(pTable->pszFilePath, pTable->pszFileName, szVer, sizeof(szVer));
 
415
        RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestAdd/Components/%s", pTable->pszFileName);
 
416
        rc = VBoxServiceWritePropF(uiClientID, szPropPath, "%s", szVer);
498
417
        pTable++;
499
418
    }
500
419
 
501
420
    return VINF_SUCCESS;
502
421
}
503