VirtualBox

Changeset 32322 in vbox


Ignore:
Timestamp:
Sep 8, 2010 3:00:46 PM (14 years ago)
Author:
vboxsync
Message:

Guest Additions/common: Make NT4 legacy driver build. Moved more code to common base.

Location:
trunk/src/VBox/Additions/common/VBoxGuest
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/Makefile.kmk

    r32317 r32322  
    3535 VBoxGuest_DEFS.linux    = KBUILD_MODNAME=KBUILD_STR\(vboxguest\) KBUILD_BASENAME=KBUILD_STR\(vboxguest\) DEBUG_HASH=2 DEBUG_HASH2=3 EXPORT_SYMTAB
    3636 VBoxGuest_DEFS.solaris  = VBOX_SVN_REV=$(VBOX_SVN_REV)
    37  VBoxGuest_DEFS.win      = VBOX_SVN_REV=$(VBOX_SVN_REV) # VBOX_WITH_VRDP_SESSION_HANDLING
     37 VBoxGuest_DEFS.win      = # VBOX_WITH_VRDP_SESSION_HANDLING
    3838 ifeq ($(KBUILD_TYPE),release)
    3939  # Allow stopping/removing the driver without a reboot
     
    6060   ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
    6161    VBoxGuest_LIBS      += \
    62         $(PATH_SDK_WINDDKWLH_LIB)/aux_klib.lib \
    63         $(PATH_SDK_WINDDKWLH_LIB)/ksecdd.lib \
    64         $(PATH_SDK_WINDDKWLH_LIB)/BufferOverflowK.lib
     62        $(PATH_SDK_WINDDKWLH_LIB)/aux_klib.lib \
     63        $(PATH_SDK_WINDDKWLH_LIB)/ksecdd.lib \
     64        $(PATH_SDK_WINDDKWLH_LIB)/BufferOverflowK.lib
    6565    VBoxGuest.cpp_SDKS   = WINDDKWLH
    6666   endif
     
    7474        VBoxGuest.cpp \
    7575        VBoxGuest2.cpp
    76   VBoxGuest_SOURCES.win = \
     76  ifeq ($(KBUILD_TARGET), win)
     77   VBoxGuest_SOURCES += \
    7778        VBoxGuest-$(KBUILD_TARGET)-pnp.cpp \
    7879        win/VBoxGuest.rc
     80  endif
    7981  VBoxGuest2.cpp_DEFS    = VBOX_SVN_REV=$(VBOX_SVN_REV)
    8082  VBoxGuest.cpp_DEFS     = VBOX_SVN_REV=$(VBOX_SVN_REV)
     
    119121  # Windows NT4 driver.
    120122  #
    121   #SYSMODS.x86 += VBoxGuestNT # Not yet buildable!
     123  SYSMODS.x86 += VBoxGuestNT
    122124  VBoxGuestNT_EXTENDS = VBoxGuest
    123125  VBoxGuestNT_NOINST  = $(NO_SUCH_VARIABLE)
    124126  VBoxGuestNT_DEFS    = $(VBoxGuest_DEFS) TARGET_NT4
    125127  VBoxGuestNT_SOURCES = \
    126         VBoxGuest-$(KBUILD_TARGET).cpp \
     128        VBoxGuest.cpp \
     129        VBoxGuest2.cpp \
     130        VBoxGuest-$(KBUILD_TARGET).cpp \
    127131        VBoxGuest-$(KBUILD_TARGET)-legacy.cpp \
    128132        win/VBoxGuest.rc
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win-legacy.cpp

    r32282 r32322  
    11/** @file
    2  * VBoxGuest -- VirtualBox Win32 guest support driver
    3  */
    4 
    5 /*
    6  * Copyright (C) 2006-2010 Oracle Corporation
     2 *
     3 * VBoxGuest-win-legacy - Windows NT4 specifics.
     4 *
     5 * Copyright (C) 2010 Oracle Corporation
    76 *
    87 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1514 */
    1615
    17 // enable backdoor logging
    18 //#define LOG_ENABLED
    19 
    2016/*******************************************************************************
    2117*   Header Files                                                               *
    2218*******************************************************************************/
    23 #include "NTLegacy.h"
    24 #include "Helper.h"
    25 
     19#include "VBoxGuest-win.h"
     20#include "VBoxGuestInternal.h"
     21#include <VBox/err.h>
     22#include <VBox/log.h>
     23#include <VBox/version.h>
    2624#include <VBox/VBoxGuestLib.h>
    27 #include "../../common/VBoxGuest/VBoxGuest2.h"
     25
    2826
    2927/*******************************************************************************
     
    3129*******************************************************************************/
    3230
     31/* Reenable logging, this was #undef'ed on iprt/log.h for RING0. */
     32#define LOG_ENABLED
     33
     34#ifndef PCI_MAX_BUSES
     35# define PCI_MAX_BUSES 256
     36#endif
     37
    3338
    3439/*******************************************************************************
    3540*   Internal Functions                                                         *
    3641*******************************************************************************/
    37 extern "C"
    38 {
    39 static NTSTATUS            findPCIDevice(PULONG pBusNumber, PPCI_SLOT_NUMBER pSlotNumber);
    40 static void                freeDeviceResources(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj);
    41 }
     42RT_C_DECLS_BEGIN
     43static NTSTATUS vboxguestwinnt4FindPCIDevice(PULONG pBusNumber, PPCI_SLOT_NUMBER pSlotNumber);
     44static void     vboxguestwinnt4FreeDeviceResources(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj);
     45RT_C_DECLS_END
    4246
    4347#ifdef ALLOC_PRAGMA
    44 #pragma alloc_text (INIT, ntCreateDevice)
    45 #pragma alloc_text (INIT, findPCIDevice)
    46 #pragma alloc_text (INIT, freeDeviceResources)
     48#pragma alloc_text (INIT, vboxguestwinnt4CreateDevice)
     49#pragma alloc_text (INIT, vboxguestwinnt4FindPCIDevice)
     50#pragma alloc_text (INIT, vboxguestwinnt4FreeDeviceResources)
    4751#endif
     52
    4853
    4954/**
     
    5358 * @param
    5459 */
    55 NTSTATUS ntCreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath)
     60NTSTATUS vboxguestwinnt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath)
    5661{
    57     ULONG busNumber, slotNumber;
    5862    int vrc = VINF_SUCCESS;
    5963    NTSTATUS rc = STATUS_SUCCESS;
    6064
    61     dprintf(("VBoxGuest::ntCreateDevice: entered, pDrvObj=%x, pDevObj=%x, pRegPath=%x\n",
    62         pDrvObj, pDevObj, pRegPath));
     65    Log(("VBoxGuest::vboxguestwinnt4CreateDevice: pDrvObj=%x, pDevObj=%x, pRegPath=%x\n",
     66         pDrvObj, pDevObj, pRegPath));
    6367
    6468    /*
    6569     * Find our virtual PCI device
    6670     */
    67     rc = findPCIDevice(&busNumber, (PCI_SLOT_NUMBER*)&slotNumber);
    68     if (!NT_SUCCESS(rc))
    69     {
    70         dprintf(("VBoxGuest::createDevice: device not found, returning\n"));
    71         return rc;
    72     }
    73 
    74     /*
    75      * Create device.
    76      */
    77     PDEVICE_OBJECT deviceObject = NULL;
    78     UNICODE_STRING  DevName;
    79     RtlInitUnicodeString(&DevName, VBOXGUEST_DEVICE_NAME_NT);
    80     rc = IoCreateDevice(pDrvObj, sizeof(VBOXGUESTDEVEXT), &DevName, FILE_DEVICE_UNKNOWN, 0, FALSE, &deviceObject);
    81     if (!NT_SUCCESS(rc))
    82     {
    83         dprintf(("VBoxGuest::ntCreateDevice: IoCreateDevice failed with rc=%#x!\n", rc));
    84         return rc;
    85     }
    86     dprintf(("VBoxGuest::ntCreateDevice: device created\n"));
    87     UNICODE_STRING DosName;
    88     RtlInitUnicodeString(&DosName, VBOXGUEST_DEVICE_NAME_DOS);
    89     rc = IoCreateSymbolicLink(&DosName, &DevName);
    90     if (!NT_SUCCESS(rc))
    91     {
    92         dprintf(("VBoxGuest::ntCreateDevice: IoCreateSymbolicLink failed with rc=%#x!\n", rc));
    93         IoDeleteDevice(deviceObject);
    94         return rc;
    95     }
    96     dprintf(("VBoxGuest::ntCreateDevice: symlink created\n"));
     71    ULONG uBusNumber, uSlotNumber;
     72    rc = vboxguestwinnt4FindPCIDevice(&uBusNumber, (PCI_SLOT_NUMBER*)&uSlotNumber);
     73    if (NT_ERROR(rc))
     74        Log(("VBoxGuest::vboxguestwinnt4CreateDevice: Device not found!\n"));
     75
     76    PDEVICE_OBJECT pDeviceObject = NULL;
     77    if (NT_SUCCESS(rc))
     78    {
     79        /*
     80         * Create device.
     81         */
     82        UNICODE_STRING szDevName;
     83        RtlInitUnicodeString(&szDevName, VBOXGUEST_DEVICE_NAME_NT);
     84        rc = IoCreateDevice(pDrvObj, sizeof(VBOXGUESTDEVEXT), &szDevName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDeviceObject);
     85        if (NT_SUCCESS(rc))
     86        {
     87            Log(("VBoxGuest::vboxguestwinnt4CreateDevice: Device created\n"));
     88
     89            UNICODE_STRING DosName;
     90            RtlInitUnicodeString(&DosName, VBOXGUEST_DEVICE_NAME_DOS);
     91            rc = IoCreateSymbolicLink(&DosName, &szDevName);
     92            if (NT_ERROR(rc))
     93            {
     94                Log(("VBoxGuest::vboxguestwinnt4CreateDevice: IoCreateSymbolicLink failed with rc = %#x\n", rc));
     95                //IoDeleteDevice(pDeviceObject);
     96            }
     97            Log(("VBoxGuest::vboxguestwinnt4CreateDevice: Symlink created\n"));
     98        }
     99        else
     100            Log(("VBoxGuest::vboxguestwinnt4CreateDevice: IoCreateDevice failed with rc = %#x\n", rc));
     101    }
    97102
    98103    /*
    99104     * Setup the device extension.
    100105     */
    101     PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)deviceObject->DeviceExtension;
    102     RtlZeroMemory(pDevExt, sizeof(VBOXGUESTDEVEXT));
    103 
    104     if (pDevObj) /* pDevObj always is NULL at the moment, so don't attach to the driver stack */
    105     {
    106         pDevExt->nextLowerDriver = IoAttachDeviceToDeviceStack(deviceObject, pDevObj);
    107         if (pDevExt->nextLowerDriver == NULL)
    108         {
    109             dprintf(("VBoxGuest::ntCreateDevice: IoAttachDeviceToDeviceStack did not give a nextLowerDrive\n"));
    110             IoDeleteSymbolicLink(&DosName);
    111             IoDeleteDevice(deviceObject);
    112             return STATUS_NO_SUCH_DEVICE;
    113         }
    114         dprintf(("VBoxGuest::ntCreateDevice: device attached to stack\n"));
    115     }
    116 
    117 #ifdef VBOX_WITH_HGCM
    118     /* Create global spinlock for all driver sessions */
    119     int rc2 = RTSpinlockCreate(&pDevExt->SessionSpinlock);
    120     if (RT_FAILURE(rc2))
    121     {
    122         dprintf(("VBoxGuest::ntCreateDevice: RTSpinlockCreate failed\n"));
    123         IoDetachDevice(pDevExt->nextLowerDriver);
    124         IoDeleteSymbolicLink(&DosName);
    125         IoDeleteDevice(deviceObject);
    126         return STATUS_DRIVER_UNABLE_TO_LOAD;
    127     }
    128     dprintf(("VBoxGuest::ntCreateDevice: spinlock created\n"));
    129 #endif
    130 
    131     /* Store a reference to ourself */
    132     pDevExt->deviceObject = deviceObject;
    133     /* Store bus and slot number we've queried before */
    134     pDevExt->busNumber = busNumber;
    135     pDevExt->slotNumber = slotNumber;
    136 
    137 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
    138     rc = hlpRegisterBugCheckCallback(pDevExt);
    139 #endif
    140 
    141     //
    142     // let's have a look at what our PCI adapter offers
    143     //
    144     dprintf(("VBoxGuest::ntCreateDevice: starting to scan PCI resources of VBoxGuest\n"));
    145     // assign the PCI resources
    146     PCM_RESOURCE_LIST resourceList;
    147     UNICODE_STRING classNameString;
    148     RtlInitUnicodeString(&classNameString, L"VBoxGuestAdapter");
    149     rc = HalAssignSlotResources(pRegPath, &classNameString,
    150                                 pDrvObj, pDevObj,
    151                                 PCIBus, busNumber, slotNumber,
    152                                 &resourceList);
    153     if (!NT_SUCCESS(rc))
    154     {
    155         dprintf(("VBoxGuest::ntCreateDevice: HalAssignSlotResources failed with rc=%#x!\n", rc));
    156         freeDeviceResources(pDrvObj, pDevObj);
    157         return rc;
    158     }
    159 
    160     rc = VBoxScanPCIResourceList(resourceList, pDevExt);
    161 
    162     rc = VbglInit (pDevExt->startPortAddress, pDevExt->pVMMDevMemory);
    163     if (!RT_SUCCESS(rc))
    164     {
    165         dprintf(("VBoxGuest::START_DEVICE: VbglInit failed. rc = %d\n", rc));
    166     }
    167 
    168 
    169     rc = VbglGRAlloc ((VMMDevRequestHeader **)&pDevExt->irqAckEvents, sizeof (VMMDevEvents), VMMDevReq_AcknowledgeEvents);
    170     if (!RT_SUCCESS(rc))
    171     {
    172        dprintf(("VBoxGuest::START_DEVICE: VbglAlloc failed for irqAckEvents. rc = %d\n", rc));
    173     }
    174     rc = VbglGRAlloc ((VMMDevRequestHeader **)&pDevExt->powerStateRequest, sizeof (VMMDevPowerStateRequest), VMMDevReq_SetPowerStatus);
    175     if (!RT_SUCCESS(rc))
    176     {
    177        dprintf(("VBoxGuest::START_DEVICE: VbglAlloc failed for powerStateRequest. rc = %d\n", rc));
    178     }
    179 
    180 #if 0
    181     //
    182     // now proceed to the busmaster DMA stuff
    183     //
    184 
    185     DEVICE_DESCRIPTION deviceDescription;
    186     ULONG numberOfMapRegisters;
    187     deviceDescription.Version = DEVICE_DESCRIPTION_VERSION;
    188     deviceDescription.Master = TRUE;
    189     deviceDescription.ScatterGather = TRUE;
    190     deviceDescription.BusNumber = pDevExt->busNumber;
    191     deviceDescription.InterfaceType = PCIBus;
    192     deviceDescription.MaximumLength = MAXIMUM_TRANSFER_LENGTH;
    193     pDevExt->adapterObject = HalGetAdapter(&deviceDescription, &numberOfMapRegisters);
    194     if (pDevExt->adapterObject == NULL)
    195     {
    196         dprintf(("VBoxGuest::ntCreateDevice: HalGetAdapter failed!\n"));
    197         freeDeviceResources(pDrvObj, pDevObj);
    198         return rc;
    199     }
    200 
    201     // @todo allocate S/G buffer
    202 #endif
    203 
    204 
    205     //
    206     // it's time to map the I/O and memory spaces
    207     //
    208 
    209     // Map physical address of VMMDev memory
    210     rc = hlpVBoxMapVMMDevMemory (pDevExt);
    211     if (!NT_SUCCESS(rc))
    212     {
    213         dprintf(("VBoxGuest::ntCreateDevice: Unable to map VMMDev Memory, rc=%#x!\n", rc));
    214         freeDeviceResources(pDrvObj, pDevObj);
    215         return rc;
    216     }
    217 
    218     //
    219     // now we need an ISR and DPC
    220     //
    221 
    222     // register DPC routine
    223     dprintf(("VBoxGuest::ntCreateDevice: initializing DPC...\n"));
    224     IoInitializeDpcRequest(pDevExt->deviceObject, VBoxGuestDpcHandler);
    225     // get an interrupt vector
    226     ULONG vector;
    227     KIRQL irql;
    228     KAFFINITY affinity;
    229     // only proceed if the device provides an interrupt
    230     if (pDevExt->interruptLevel || pDevExt->interruptVector)
    231     {
    232         vector = HalGetInterruptVector(PCIBus,
    233                                        pDevExt->busNumber,
    234                                        pDevExt->interruptLevel,
    235                                        pDevExt->interruptVector,
    236                                        &irql,
    237                                        &affinity);
    238         dprintf(("VBoxGuest::ntCreateDevice: HalGetInterruptVector returns vector %u\n", vector));
    239         rc = IoConnectInterrupt(&pDevExt->interruptObject,              // out: interrupt object
    240                                 (PKSERVICE_ROUTINE)VBoxGuestIsrHandler, // ISR
    241                                 pDevExt,                                // context
    242                                 NULL,                                   // optional spinlock
    243                                 vector,                                 // interrupt vector
    244                                 irql,                                   // interrupt level
    245                                 irql,                                   // interrupt level
    246                                 pDevExt->interruptMode,                 // LevelSensitive or Latched
    247                                 TRUE,                                   // shareable interrupt
    248                                 affinity,                               // CPU affinity
    249                                 FALSE);                                 // don't save FPU stack
    250         if (!NT_SUCCESS(rc))
    251         {
    252             dprintf(("VBoxGuest::ntCreateDevice: Unable to connect interrupt, rc=%#x!\n", rc));
    253             pDevExt->interruptObject = NULL;
    254             freeDeviceResources(pDrvObj, pDevObj);
    255             return rc;
    256         }
    257         dprintf(("VBoxGuest::ntCreateDevice: IRQ connected!\n"));
    258     }
    259 
     106    PVBOXGUESTDEVEXT pDevExt = NULL;
    260107    if (NT_SUCCESS(rc))
    261108    {
    262         // create our thread to inform the VBoxMouse driver
    263         rc = createThreads(pDevExt);
     109        Log(("VBoxGuest::vboxguestwinnt4CreateDevice: Setting up device extension ...\n"));
     110
     111        pDevExt = (PVBOXGUESTDEVEXT)pDeviceObject->DeviceExtension;
     112        Assert(pDevExt);
     113        RtlZeroMemory(pDevExt, sizeof(VBOXGUESTDEVEXT));
     114    }
     115
     116    if (   NT_SUCCESS(rc)
     117        && pDevExt)
     118    {
     119        /* Store a reference to ourself. */
     120        pDevExt->win.s.pDeviceObject = pDeviceObject;
     121
     122        /* Store bus and slot number we've queried before. */
     123        pDevExt->win.s.busNumber = uBusNumber;
     124        pDevExt->win.s.slotNumber = uSlotNumber;
     125
     126    #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
     127        rc = hlpRegisterBugCheckCallback(pDevExt);
     128    #endif
    264129    }
    265130
    266131    if (NT_SUCCESS(rc))
    267132    {
    268         // initialize the event notification semaphore
    269         KeInitializeEvent(&pDevExt->keventNotification, NotificationEvent, FALSE);
    270 
    271         /* Preallocated constant timeout 250ms for HGCM async waiter. */
    272         pDevExt->HGCMWaitTimeout.QuadPart  = 250;
    273         pDevExt->HGCMWaitTimeout.QuadPart *= -10000;     /* relative in 100ns units */
    274     }
    275 
    276     /** @todo Cleanup on failure. */
    277 
    278     /** @todo Don't mix up IPRT rc and NTSTATUS rc above! */
    279 
    280     if (NT_SUCCESS(rc))
    281     {
    282         vrc = VBoxGuestReportGuestInfo(hlpVBoxWinVersionToOSType(winVersion));
    283         if (RT_SUCCESS(vrc))
    284         {
    285             vrc = VBoxInitMemBalloon(pDevExt);
    286             if (RT_SUCCESS(vrc))
    287             {
    288                 vrc = VBoxGuestReportDriverStatus(true /* Driver is active */);
    289                 if (RT_FAILURE(vrc))
    290                     dprintf(("VBoxGuest::VBoxGuestPnp::IRP_MN_START_DEVICE: could not report guest driver status, vrc = %d\n", vrc));
    291             }
    292             else
    293                 dprintf(("VBoxGuest::VBoxGuestPnp::IRP_MN_START_DEVICE: could not init mem balloon, vrc = %d\n", vrc));
    294         }
    295         else
    296             dprintf(("VBoxGuest::VBoxGuestPnp::IRP_MN_START_DEVICE: could not report guest information to host, vrc = %d\n", vrc));
    297 
    298         if (RT_FAILURE(vrc))
    299             rc = STATUS_UNSUCCESSFUL;
    300     }
    301 
    302     if (NT_SUCCESS(rc))
    303     {
    304         // ready to rumble!
    305         pDevExt->devState = WORKING;
    306     }
    307     else
    308     {
    309         freeDeviceResources(pDrvObj, pDevObj);
    310     }
    311 
    312     dprintf(("returning from ntCreateDevice with rc = 0x%x\n, vrc = %Rrc", rc, vrc));
     133        rc = vboxguestwinInit(pDrvObj, pDevObj, pRegPath);
     134    }
     135
     136    Log(("VBoxGuest::vboxguestwinnt4CreateDevice: Returning rc = 0x%x\n", rc));
    313137    return rc;
    314138}
     
    320144 * @returns NT error codes
    321145 */
    322 static NTSTATUS findPCIDevice(PULONG pBusNumber, PPCI_SLOT_NUMBER pSlotNumber)
     146static NTSTATUS vboxguestwinnt4FindPCIDevice(PULONG pBusNumber, PPCI_SLOT_NUMBER pSlotNumber)
    323147{
    324148    NTSTATUS rc;
     
    330154    PCI_COMMON_CONFIG pciData;
    331155
    332     dprintf(("findPCIDevice\n"));
     156    Log(("VBoxGuest::vboxguestwinnt4FindPCIDevice\n"));
    333157
    334158    rc = STATUS_DEVICE_DOES_NOT_EXIST;
    335159    slotNumber.u.AsULONG = 0;
    336     // scan each bus
     160
     161    /* Scan each bus. */
    337162    for (busNumber = 0; busNumber < PCI_MAX_BUSES; busNumber++)
    338163    {
    339         // scan each device
     164        /* Scan each device. */
    340165        for (deviceNumber = 0; deviceNumber < PCI_MAX_DEVICES; deviceNumber++)
    341166        {
    342167            slotNumber.u.bits.DeviceNumber = deviceNumber;
    343             // scan each function (not really required...)
     168
     169            /* Scan each function (not really required...). */
    344170            for (functionNumber = 0; functionNumber < PCI_MAX_FUNCTION; functionNumber++)
    345171            {
    346172                slotNumber.u.bits.FunctionNumber = functionNumber;
    347                 // have a look at what's in this slot
     173
     174                /* Have a look at what's in this slot. */
    348175                if (!HalGetBusData(PCIConfiguration, busNumber, slotNumber.u.AsULONG,
    349176                                   &pciData, sizeof(ULONG)))
    350177                {
    351                     // no such bus, we're done with it
     178                    /* No such bus, we're done with it. */
    352179                    deviceNumber = PCI_MAX_DEVICES;
    353180                    break;
     
    356183                if (pciData.VendorID == PCI_INVALID_VENDORID)
    357184                {
    358                     // we have to proceed to the next function
     185                    /* We have to proceed to the next function. */
    359186                    continue;
    360187                }
    361188
    362                 // check if it's another device
     189                /* Check if it's another device. */
    363190                if ((pciData.VendorID != VMMDEV_VENDORID) ||
    364191                    (pciData.DeviceID != VMMDEV_DEVICEID))
     
    367194                }
    368195
    369                 // Hooray, we've found it!
    370                 dprintf(("device found!\n"));
     196                /* Hooray, we've found it! */
     197                Log(("VBoxGuest::vboxguestwinnt4FindPCIDevice: Device found!\n"));
     198
    371199                *pBusNumber = busNumber;
    372200                *pSlotNumber = slotNumber;
     
    379207}
    380208
    381 /**
    382  * Helper function to cleanup resources
    383  *
    384  * @param   pDrvObj     Driver object.
    385  * @param   pDevObj     Device object.
    386  */
    387 static void freeDeviceResources(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj)
    388 {
    389     PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension;
    390 
    391     // if there's no device extension, we're screwed
    392     if (!pDevExt)
    393     {
    394         dprintf(("freeDeviceResources: FATAL ERROR! device extension pointer is NULL! Not freeing resources!\n"));
    395         return;
    396     }
    397 
    398     // indicate that the device is no longer ready
    399     pDevExt->devState = STOPPED;
    400 
    401     // disconnect interrupts
    402     if (pDevExt->interruptObject)
    403     {
    404         IoDisconnectInterrupt(pDevExt->interruptObject);
    405     }
    406 
    407     // unmap mem/io resources
    408     hlpVBoxUnmapVMMDevMemory (pDevExt);
    409 
    410     VBoxCleanupMemBalloon(pDevExt);
    411 }
    412 
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win-pnp.cpp

    r32317 r32322  
    170170                else
    171171                {
    172                     vboxguestwinShowDeviceResources(&pStack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList);
    173 
    174                     vboxguestwinScanPCIResourceList(pStack->Parameters.StartDevice.AllocatedResourcesTranslated,
    175                                                     pDevExt);
    176 
    177                     /* Map physical address of VMMDev memory into MMIO region. */
    178                     void *pvMMIOBase = NULL;
    179                     uint32_t cbMMIO = 0;
    180                     rc = vboxguestwinMapVMMDevMemory(pDevExt,
    181                                                      pDevExt->win.s.vmmDevPhysMemoryAddress,
    182                                                      pDevExt->win.s.vmmDevPhysMemoryLength,
    183                                                      &pvMMIOBase,
    184                                                      &cbMMIO);
    185                     if (NT_SUCCESS(rc))
    186                     {
    187                         pDevExt->pVMMDevMemory = (VMMDevMemory *)pvMMIOBase;
    188 
    189                         Log(("VBoxGuest::vboxguestwinVBoxGuestPnP: START_DEVICE: pvMMIOBase = 0x%p, pDevExt = 0x%p, pDevExt->pVMMDevMemory = 0x%p\n",
    190                              pvMMIOBase, pDevExt, pDevExt ? pDevExt->pVMMDevMemory : NULL));
    191 
    192                         int vrc = VBoxGuestInitDevExt(pDevExt,
    193                                                       pDevExt->IOPortBase,
    194                                                       pvMMIOBase, cbMMIO,
    195                                                       vboxguestwinVersionToOSType(g_winVersion),
    196                                                       VMMDEV_EVENT_MOUSE_POSITION_CHANGED);
    197                         if (RT_FAILURE(vrc))
    198                         {
    199                             Log(("VBoxGuest::vboxguestwinVBoxGuestPnP: START_DEVICE: Could not init device extension, rc = %Rrc!\n", vrc));
    200                             rc = STATUS_DEVICE_CONFIGURATION_ERROR;
    201                         }
    202                     }
    203                     else
    204                         Log(("VBoxGuest::vboxguestwinVBoxGuestPnP: START_DEVICE: Could not map physical address of VMMDev, rc = 0x%x!\n", rc));
    205 
    206                     if (NT_SUCCESS(rc))
    207                     {
    208                         int vrc = VbglGRAlloc((VMMDevRequestHeader **)&pDevExt->win.s.pPowerStateRequest,
    209                                               sizeof (VMMDevPowerStateRequest), VMMDevReq_SetPowerStatus);
    210                         if (RT_FAILURE(vrc))
    211                         {
    212                             Log(("VBoxGuest::vboxguestwinVBoxGuestPnP: START_DEVICE: Alloc for pPowerStateRequest failed, rc = %Rrc\n", vrc));
    213                             rc = STATUS_UNSUCCESSFUL;
    214                         }
    215                     }
    216 
    217                     if (NT_SUCCESS(rc))
    218                     {
    219                         /* Register DPC and ISR. */
    220                         Log(("VBoxGuest::vboxguestwinGuestPnp: START_DEVICE: Initializing DPC/ISR ...\n"));
    221 
    222                         IoInitializeDpcRequest(pDevExt->win.s.pDeviceObject, vboxguestwinDpcHandler);
    223                         rc = IoConnectInterrupt(&pDevExt->win.s.pInterruptObject,          /* Out: interrupt object. */
    224                                                 (PKSERVICE_ROUTINE)vboxguestwinIsrHandler, /* Our ISR handler. */
    225                                                 pDevExt,                                   /* Device context. */
    226                                                 NULL,                                      /* Optional spinlock. */
    227                                                 pDevExt->win.s.interruptVector,            /* Interrupt vector. */
    228                                                 (KIRQL)pDevExt->win.s.interruptLevel,      /* Interrupt level. */
    229                                                 (KIRQL)pDevExt->win.s.interruptLevel,      /* Interrupt level. */
    230                                                 pDevExt->win.s.interruptMode,              /* LevelSensitive or Latched. */
    231                                                 TRUE,                                      /* Shareable interrupt. */
    232                                                 pDevExt->win.s.interruptAffinity,          /* CPU affinity. */
    233                                                 FALSE);                                    /* Don't save FPU stack. */
    234                         if (NT_ERROR(rc))
    235                             Log(("VBoxGuest::vboxguestwinGuestPnp: START_DEVICE: Could not connect interrupt, rc = 0x%x\n", rc));
    236                     }
     172                    rc = vboxguestwinInit(pDevObj, pIrp);
    237173                }
    238174            }
    239175
    240             if (NT_SUCCESS(rc))
    241             {
    242 #ifdef VBOX_WITH_HGCM
    243                 /* Initialize the HGCM event notification semaphore. */
    244                 KeInitializeEvent(&pDevExt->win.s.hgcm.s.keventNotification, NotificationEvent, FALSE);
    245 
    246                 /* Preallocated constant timeout 250ms for HGCM async waiter. */
    247                 pDevExt->win.s.hgcm.s.WaitTimeout.QuadPart  = 250;
    248                 pDevExt->win.s.hgcm.s.WaitTimeout.QuadPart *= -10000; /* Relative in 100ns units. */
    249 
    250                 int vrc = VBoxGuestCreateKernelSession(pDevExt, &pDevExt->win.s.pKernelSession);
    251                 if (RT_FAILURE(vrc))
    252                     Log(("VBoxGuest::vboxguestwinGuestPnp: START_DEVICE: Failed to allocated kernel session data! rc = %Rrc\n", rc));
    253 #endif
    254 
    255                 /* Ready to rumble! */
    256                 Log(("VBoxGuest::vboxguestwinGuestPnp: START_DEVICE: Device is ready!\n"));
    257                 pDevExt->win.s.devState = WORKING;
    258             }
    259             else
     176            if (NT_ERROR(rc))
    260177            {
    261178                Log(("VBoxGuest::vboxguestwinGuestPnp: START_DEVICE: Error: rc = 0x%x\n", rc));
     
    304221            if (pDevExt->win.s.devState == PENDINGREMOVE)
    305222            {
    306                 rc = vboxguestwinCleanup(pDevObj, pIrp);
     223                rc = vboxguestwinCleanup(pDevObj);
    307224                if (NT_SUCCESS(rc))
    308225                {
     
    377294            if (pDevExt->win.s.devState == PENDINGSTOP)
    378295            {
    379                 rc = vboxguestwinCleanup(pDevObj, pIrp);
     296                rc = vboxguestwinCleanup(pDevObj);
    380297                if (NT_SUCCESS(rc))
    381298                {
     
    406323    Log(("VBoxGuest::vboxguestwinGuestPnp: Returning with rc = 0x%x\n", rc));
    407324    return rc;
    408 }
    409 
    410 
    411 /**
    412  * Debug helper to dump a device resource list.
    413  *
    414  * @param pResourceList  list of device resources.
    415  */
    416 static VOID vboxguestwinShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList)
    417 {
    418 #ifdef LOG_ENABLED
    419     PCM_PARTIAL_RESOURCE_DESCRIPTOR resource = pResourceList->PartialDescriptors;
    420     ULONG nres = pResourceList->Count;
    421     ULONG i;
    422 
    423     for (i = 0; i < nres; ++i, ++resource)
    424     {
    425         ULONG uType = resource->Type;
    426         static char* aszName[] =
    427         {
    428             "CmResourceTypeNull",
    429             "CmResourceTypePort",
    430             "CmResourceTypeInterrupt",
    431             "CmResourceTypeMemory",
    432             "CmResourceTypeDma",
    433             "CmResourceTypeDeviceSpecific",
    434             "CmResourceTypeBusNumber",
    435             "CmResourceTypeDevicePrivate",
    436             "CmResourceTypeAssignedResource",
    437             "CmResourceTypeSubAllocateFrom",
    438         };
    439 
    440         Log(("VBoxGuest::vboxguestwinShowDeviceResources: Type %s",
    441                uType < (sizeof(aszName) / sizeof(aszName[0]))
    442              ? aszName[uType] : "Unknown"));
    443 
    444         switch (uType)
    445         {
    446             case CmResourceTypePort:
    447             case CmResourceTypeMemory:
    448                 Log(("VBoxGuest::vboxguestwinShowDeviceResources: Start %8X%8.8lX length %X\n",
    449                          resource->u.Port.Start.HighPart, resource->u.Port.Start.LowPart,
    450                          resource->u.Port.Length));
    451                 break;
    452 
    453             case CmResourceTypeInterrupt:
    454                 Log(("VBoxGuest::vboxguestwinShowDeviceResources: Level %X, Vector %X, Affinity %X\n",
    455                          resource->u.Interrupt.Level, resource->u.Interrupt.Vector,
    456                          resource->u.Interrupt.Affinity));
    457                 break;
    458 
    459             case CmResourceTypeDma:
    460                 Log(("VBoxGuest::vboxguestwinShowDeviceResources: Channel %d, Port %X\n",
    461                          resource->u.Dma.Channel, resource->u.Dma.Port));
    462                 break;
    463 
    464             default:
    465                 Log(("\n"));
    466                 break;
    467         }
    468     }
    469 #endif
    470325}
    471326
     
    591446
    592447                            /* Cleanup. */
    593                             vboxguestwinCleanup(pDevObj, pIrp);
     448                            vboxguestwinCleanup(pDevObj);
    594449                            break;
    595450                        }
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp

    r32317 r32322  
    171171        pDrvObj->MajorFunction[IRP_MJ_WRITE]                   = vboxguestwinNotSupportedStub;
    172172#ifdef TARGET_NT4
    173         rc = vboxguestwinNT4CreateDevice(pDrvObj, NULL /* pDevObj */, pRegPath);
     173        rc = vboxguestwinnt4CreateDevice(pDrvObj, NULL /* pDevObj */, pRegPath);
    174174#else
    175175        pDrvObj->MajorFunction[IRP_MJ_PNP]                     = vboxguestwinPnP;
     
    274274
    275275/**
     276 * Debug helper to dump a device resource list.
     277 *
     278 * @param pResourceList  list of device resources.
     279 */
     280static VOID vboxguestwinShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList)
     281{
     282#ifdef LOG_ENABLED
     283    PCM_PARTIAL_RESOURCE_DESCRIPTOR resource = pResourceList->PartialDescriptors;
     284    ULONG nres = pResourceList->Count;
     285    ULONG i;
     286
     287    for (i = 0; i < nres; ++i, ++resource)
     288    {
     289        ULONG uType = resource->Type;
     290        static char* aszName[] =
     291        {
     292            "CmResourceTypeNull",
     293            "CmResourceTypePort",
     294            "CmResourceTypeInterrupt",
     295            "CmResourceTypeMemory",
     296            "CmResourceTypeDma",
     297            "CmResourceTypeDeviceSpecific",
     298            "CmResourceTypeBusNumber",
     299            "CmResourceTypeDevicePrivate",
     300            "CmResourceTypeAssignedResource",
     301            "CmResourceTypeSubAllocateFrom",
     302        };
     303
     304        Log(("VBoxGuest::vboxguestwinShowDeviceResources: Type %s",
     305               uType < (sizeof(aszName) / sizeof(aszName[0]))
     306             ? aszName[uType] : "Unknown"));
     307
     308        switch (uType)
     309        {
     310            case CmResourceTypePort:
     311            case CmResourceTypeMemory:
     312                Log(("VBoxGuest::vboxguestwinShowDeviceResources: Start %8X%8.8lX length %X\n",
     313                         resource->u.Port.Start.HighPart, resource->u.Port.Start.LowPart,
     314                         resource->u.Port.Length));
     315                break;
     316
     317            case CmResourceTypeInterrupt:
     318                Log(("VBoxGuest::vboxguestwinShowDeviceResources: Level %X, Vector %X, Affinity %X\n",
     319                         resource->u.Interrupt.Level, resource->u.Interrupt.Vector,
     320                         resource->u.Interrupt.Affinity));
     321                break;
     322
     323            case CmResourceTypeDma:
     324                Log(("VBoxGuest::vboxguestwinShowDeviceResources: Channel %d, Port %X\n",
     325                         resource->u.Dma.Channel, resource->u.Dma.Port));
     326                break;
     327
     328            default:
     329                Log(("\n"));
     330                break;
     331        }
     332    }
     333#endif
     334}
     335
     336
     337/**
     338 * Global initialisation stuff (PnP + NT4 legacy).
     339 *
     340 * @param  pDevObj    Device object.
     341 * @param  pIrp       Request packet.
     342 */
     343#ifndef TARGET_NT4
     344NTSTATUS vboxguestwinInit(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     345#else
     346NTSTATUS vboxguestwinInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath)
     347#endif
     348{
     349    PVBOXGUESTDEVEXT pDevExt   = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension;
     350#ifndef TARGET_NT4
     351    PIO_STACK_LOCATION pStack  = IoGetCurrentIrpStackLocation(pIrp);
     352#endif
     353
     354    Log(("VBoxGuest::vboxguestwinInit\n"));
     355
     356    int rc = STATUS_SUCCESS;
     357#ifdef TARGET_NT4
     358    /*
     359     * Let's have a look at what our PCI adapter offers.
     360     */
     361    Log(("VBoxGuest::vboxguestwinInit: Starting to scan PCI resources of VBoxGuest ...\n"));
     362
     363    /* Assign the PCI resources. */
     364    PCM_RESOURCE_LIST pResourceList = NULL;
     365    UNICODE_STRING classNameString;
     366    RtlInitUnicodeString(&classNameString, L"VBoxGuestAdapter");
     367    rc = HalAssignSlotResources(pRegPath, &classNameString,
     368                                pDrvObj, pDevObj,
     369                                PCIBus, pDevExt->win.s.busNumber, pDevExt->win.s.slotNumber,
     370                                &pResourceList);
     371    if (pResourceList && pResourceList->Count > 0)
     372        vboxguestwinShowDeviceResources(&pResourceList->List[0].PartialResourceList);
     373    if (NT_SUCCESS(rc))
     374        rc = vboxguestwinScanPCIResourceList(pResourceList, pDevExt);
     375#else
     376    if (pStack->Parameters.StartDevice.AllocatedResources->Count > 0)
     377        vboxguestwinShowDeviceResources(&pStack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList);
     378    if (NT_SUCCESS(rc))
     379        rc = vboxguestwinScanPCIResourceList(pStack->Parameters.StartDevice.AllocatedResourcesTranslated,
     380                                             pDevExt);
     381#endif
     382    if (NT_SUCCESS(rc))
     383    {
     384        /*
     385         * Map physical address of VMMDev memory into MMIO region
     386         * and init the common device extension bits.
     387         */
     388        void *pvMMIOBase = NULL;
     389        uint32_t cbMMIO = 0;
     390        rc = vboxguestwinMapVMMDevMemory(pDevExt,
     391                                         pDevExt->win.s.vmmDevPhysMemoryAddress,
     392                                         pDevExt->win.s.vmmDevPhysMemoryLength,
     393                                         &pvMMIOBase,
     394                                         &cbMMIO);
     395        if (NT_SUCCESS(rc))
     396        {
     397            pDevExt->pVMMDevMemory = (VMMDevMemory *)pvMMIOBase;
     398
     399            Log(("VBoxGuest::vboxguestwinInit: pvMMIOBase = 0x%p, pDevExt = 0x%p, pDevExt->pVMMDevMemory = 0x%p\n",
     400                 pvMMIOBase, pDevExt, pDevExt ? pDevExt->pVMMDevMemory : NULL));
     401
     402            int vrc = VBoxGuestInitDevExt(pDevExt,
     403                                          pDevExt->IOPortBase,
     404                                          pvMMIOBase, cbMMIO,
     405                                          vboxguestwinVersionToOSType(g_winVersion),
     406                                          VMMDEV_EVENT_MOUSE_POSITION_CHANGED);
     407            if (RT_FAILURE(vrc))
     408            {
     409                Log(("VBoxGuest::vboxguestwinInit: Could not init device extension, rc = %Rrc!\n", vrc));
     410                rc = STATUS_DEVICE_CONFIGURATION_ERROR;
     411            }
     412        }
     413        else
     414            Log(("VBoxGuest::vboxguestwinInit: Could not map physical address of VMMDev, rc = 0x%x!\n", rc));
     415    }
     416
     417    if (NT_SUCCESS(rc))
     418    {
     419        int vrc = VbglGRAlloc((VMMDevRequestHeader **)&pDevExt->win.s.pPowerStateRequest,
     420                              sizeof (VMMDevPowerStateRequest), VMMDevReq_SetPowerStatus);
     421        if (RT_FAILURE(vrc))
     422        {
     423            Log(("VBoxGuest::vboxguestwinInit: Alloc for pPowerStateRequest failed, rc = %Rrc\n", vrc));
     424            rc = STATUS_UNSUCCESSFUL;
     425        }
     426    }
     427
     428    if (NT_SUCCESS(rc))
     429    {
     430        /*
     431         * Register DPC and ISR.
     432         */
     433        Log(("VBoxGuest::vboxguestwinInit: Initializing DPC/ISR ...\n"));
     434
     435        IoInitializeDpcRequest(pDevExt->win.s.pDeviceObject, vboxguestwinDpcHandler);
     436#ifdef TARGET_NT4
     437        /* Get an interrupt vector. */
     438        /* Only proceed if the device provides an interrupt. */
     439        if (   pDevExt->win.s.interruptLevel
     440            || pDevExt->win.s.interruptVector)
     441        {
     442            pDevExt->win.s.interruptVector = HalGetInterruptVector(PCIBus,
     443                                                                   pDevExt->win.s.busNumber,
     444                                                                   pDevExt->win.s.interruptLevel,
     445                                                                   pDevExt->win.s.interruptVector,
     446                                                                   (PKIRQL)pDevExt->win.s.interruptLevel,
     447                                                                   &pDevExt->win.s.interruptAffinity);
     448        }
     449        else
     450            Log(("VBoxGuest::vboxguestwinInit: Device does not provide an interrupt!\n"));
     451#endif
     452        if (pDevExt->win.s.interruptVector)
     453        {
     454            rc = IoConnectInterrupt(&pDevExt->win.s.pInterruptObject,          /* Out: interrupt object. */
     455                                    (PKSERVICE_ROUTINE)vboxguestwinIsrHandler, /* Our ISR handler. */
     456                                    pDevExt,                                   /* Device context. */
     457                                    NULL,                                      /* Optional spinlock. */
     458                                    pDevExt->win.s.interruptVector,            /* Interrupt vector. */
     459                                    (KIRQL)pDevExt->win.s.interruptLevel,      /* Interrupt level. */
     460                                    (KIRQL)pDevExt->win.s.interruptLevel,      /* Interrupt level. */
     461                                    pDevExt->win.s.interruptMode,              /* LevelSensitive or Latched. */
     462                                    TRUE,                                      /* Shareable interrupt. */
     463                                    pDevExt->win.s.interruptAffinity,          /* CPU affinity. */
     464                                    FALSE);                                    /* Don't save FPU stack. */
     465            if (NT_ERROR(rc))
     466                Log(("VBoxGuest::vboxguestwinInit: Could not connect interrupt, rc = 0x%x\n", rc));
     467        }
     468        else
     469            Log(("VBoxGuest::vboxguestwinInit: No interrupt vector found!\n"));
     470    }
     471
     472
     473#ifdef VBOX_WITH_HGCM
     474    /* Initialize the HGCM event notification semaphore. */
     475    KeInitializeEvent(&pDevExt->win.s.hgcm.s.keventNotification, NotificationEvent, FALSE);
     476
     477    /* Preallocated constant timeout 250ms for HGCM async waiter. */
     478    pDevExt->win.s.hgcm.s.WaitTimeout.QuadPart  = 250;
     479    pDevExt->win.s.hgcm.s.WaitTimeout.QuadPart *= -10000; /* Relative in 100ns units. */
     480
     481    int vrc = VBoxGuestCreateKernelSession(pDevExt, &pDevExt->win.s.pKernelSession);
     482    if (RT_FAILURE(vrc))
     483    {
     484        Log(("VBoxGuest::vboxguestwinInit: Failed to allocated kernel session data! rc = %Rrc\n", rc));
     485        rc = STATUS_UNSUCCESSFUL;
     486    }
     487#endif
     488
     489    if (RT_SUCCESS(rc))
     490    {
     491        /* Ready to rumble! */
     492        Log(("VBoxGuest::vboxguestwinInit: Device is ready!\n"));
     493        pDevExt->win.s.devState = WORKING;
     494    }
     495
     496    Log(("VBoxGuest::vboxguestwinInit: Returned with rc = 0x%x\n", rc));
     497    return rc;
     498}
     499
     500
     501/**
    276502 * Cleans up all data (like device extension and guest mapping).
    277503 *
    278504 * @param   pDrvObj     Driver object.
    279  * @param   pIrp        Request packet.
    280  */
    281 NTSTATUS vboxguestwinCleanup(PDEVICE_OBJECT pDevObj, PIRP pIrp)
     505 */
     506NTSTATUS vboxguestwinCleanup(PDEVICE_OBJECT pDevObj)
    282507{
    283508    Log(("VBoxGuest::vboxguestwinCleanup\n"));
    284509
    285     NOREF(pIrp);
    286510    PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension;
    287 
    288511    if (pDevExt)
    289512    {
     513#ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
     514        hlpDeregisterBugCheckCallback(pDevExt); /* ignore failure! */
     515#endif
    290516        /* According to MSDN we have to unmap previously mapped memory. */
    291517        vboxguestwinUnmapVMMDevMemory(pDevExt);
     
    307533    Log(("VBoxGuest::vboxguestwinGuestUnload\n"));
    308534#ifdef TARGET_NT4
    309     PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pDrvObj->DeviceObject->DeviceExtension;
    310     unreserveHypervisorMemory(pDevExt);
    311 
    312     hlpVBoxUnmapVMMDevMemory (pDevExt);
    313 
    314     VBoxCleanupMemBalloon(pDevExt);
    315 
    316 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
    317     hlpDeregisterBugCheckCallback(pDevExt); /* ignore failure! */
    318 #endif
    319 
     535    vboxguestwinCleanup(pDrvObj->DeviceObject);
    320536    /*
    321537     * I don't think it's possible to unload a driver which processes have
     
    508724        /* Add at least one (bogus) fall through case to shut up MSVC! */
    509725        case 0:
    510 #endif
    511 
    512 #if 0
    513 #ifdef VBOX_WITH_MANAGEMENT
    514         case VBOXGUEST_IOCTL_CHECK_BALLOON:
    515         {
    516             VBoxGuestCheckBalloonInfo *pInfo = (VBoxGuestCheckBalloonInfo *)pBuf;
    517 
    518             if (pStack->Parameters.DeviceIoControl.OutputBufferLength != sizeof(VBoxGuestCheckBalloonInfo))
    519             {
    520                 Log(("VBoxGuest::vboxguestwinGuestDeviceControl: OutputBufferLength %d != sizeof(ULONG) %d\n",
    521                          pStack->Parameters.DeviceIoControl.OutputBufferLength, sizeof(VBoxGuestCheckBalloonInfo)));
    522                 Status = STATUS_INVALID_PARAMETER;
    523                 break;
    524             }
    525 
    526             ULONG cMemoryBalloonChunks;
    527             int rc = VBoxGuestQueryMemoryBalloon(pDevExt, &cMemoryBalloonChunks);
    528             if (RT_FAILURE(rc))
    529             {
    530                 Log(("VBOXGUEST_IOCTL_CHECK_BALLOON: vbox rc = %Rrc\n", rc));
    531                 Status = STATUS_UNSUCCESSFUL;
    532             }
    533             else
    534             {
    535                 cbOut = pStack->Parameters.DeviceIoControl.OutputBufferLength;
    536                 pInfo->cBalloonChunks = cMemoryBalloonChunks;
    537                 pInfo->fHandleInR3 = false;
    538             }
    539             break;
    540         }
    541 #endif
    542 
    543         case VBOXGUEST_IOCTL_LOG(0):    /* The size isn't relevant on NT. */
    544         {
    545             /* Enable this only for debugging:
    546             Log(("VBoxGuest::vboxguestwinGuestDeviceControl: VBOXGUEST_IOCTL_LOG %.*s\n", (int)pStack->Parameters.DeviceIoControl.InputBufferLength, pBuf));
    547              */
    548             LogRel(("%.*s", (int)pStack->Parameters.DeviceIoControl.InputBufferLength, pBuf));
    549             cbOut = 0;
    550             break;
    551         }
    552726#endif
    553727        default:
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.h

    r32317 r32322  
    174174
    175175RT_C_DECLS_BEGIN
    176 NTSTATUS   vboxguestwinCleanup(PDEVICE_OBJECT pDevObj, PIRP pIrp);
     176#ifdef TARGET_NT4
     177NTSTATUS   vboxguestwinnt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);
     178NTSTATUS   vboxguestwinInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);
     179#else
     180NTSTATUS   vboxguestwinInit(PDEVICE_OBJECT pDevObj, PIRP pIrp);
     181#endif
     182NTSTATUS   vboxguestwinCleanup(PDEVICE_OBJECT pDevObj);
    177183NTSTATUS   vboxguestwinPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp);
    178184VOID       vboxguestwinDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext);
     
    186192RT_C_DECLS_END
    187193
     194#ifdef TARGET_NT4
     195/*
     196 * XP DDK #defines ExFreePool to ExFreePoolWithTag. The latter does not exist
     197 * on NT4, so... The same for ExAllocatePool.
     198 */
     199#undef ExAllocatePool
     200#undef ExFreePool
     201#endif
     202
    188203#endif /* ___VBoxGuest_win_h */
    189204
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