VirtualBox

Changeset 4343 in vbox for trunk


Ignore:
Timestamp:
Aug 24, 2007 12:42:53 PM (17 years ago)
Author:
vboxsync
Message:

Added DdMapMemory

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Display
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/dd.c

    r4265 r4343  
     1#define LOG_ENABLED
     2
    13#ifdef VBOX_WITH_DDRAW
    24
     
    213215    pCallBacks->dwFlags               = 0;
    214216
    215     pCallBacks->dwFlags               = DDHAL_CB32_CREATESURFACE | DDHAL_CB32_CANCREATESURFACE;
     217    pCallBacks->dwFlags               = DDHAL_CB32_CREATESURFACE | DDHAL_CB32_CANCREATESURFACE | DDHAL_CB32_MAPMEMORY;
    216218    pCallBacks->CreateSurface         = DdCreateSurface;
    217219    pCallBacks->CanCreateSurface      = DdCanCreateSurface;
     220    pCallBacks->MapMemory             = DdMapMemory;
    218221    // pCallBacks->WaitForVerticalBlank  = DdWaitForVerticalBlank;
    219222    // pCallBacks->GetScanLine           = DdGetScanLine;
    220     // pCallBacks->MapMemory             = DdMapMemory;
    221     // DDHAL_CB32_WAITFORVERTICALBLANK | DDHAL_CB32_MAPMEMORY | DDHAL_CB32_GETSCANLINE
     223    // DDHAL_CB32_WAITFORVERTICALBLANK | DDHAL_CB32_GETSCANLINE
    222224    /* Note: pCallBacks->SetMode & pCallBacks->DestroyDriver are unused in Windows 2000 and up */
    223225
    224226    /* Fill in the Surface Callback pointers */
    225227    pSurfaceCallBacks->dwSize           = sizeof(DD_SURFACECALLBACKS);
    226     pSurfaceCallBacks->dwFlags          = 0;
     228    pSurfaceCallBacks->dwFlags          = DDHAL_SURFCB32_LOCK | DDHAL_SURFCB32_UNLOCK;
     229    pSurfaceCallBacks->Lock             = DdLock;
     230    pSurfaceCallBacks->Unlock           = DdUnlock;
    227231
    228232    /*
    229233    pSurfaceCallBacks->dwFlags          = DDHAL_SURFCB32_DESTROYSURFACE | DDHAL_SURFCB32_LOCK; // DDHAL_SURFCB32_UNLOCK;
    230234    pSurfaceCallBacks->DestroySurface   = DdDestroySurface;
    231     pSurfaceCallBacks->Lock             = DdLock;
    232     pSurfaceCallBacks->Unlock           = DdUnlock;
    233235    pSurfaceCallBacks->Flip             = DdFlip;
    234236    pSurfaceCallBacks->GetBltStatus     = DdGetBltStatus;
     
    584586}
    585587
     588// ***************************WIN NT ONLY**********************************
     589//
     590// DdMapMemory
     591//
     592// Maps application-modifiable portions of the frame buffer into the
     593// user-mode address space of the specified process, or unmaps memory.
     594//
     595// DdMapMemory is called to perform memory mapping before the first call to
     596// DdLock. The handle returned by the driver in fpProcess will be passed to
     597// every DdLock call made on the driver.
     598//
     599// DdMapMemory is also called to unmap memory after the last DdUnLock call is
     600// made.
     601//
     602// To prevent driver crashes, the driver must not map any portion of the frame
     603// buffer that must not be modified by an application.
     604//
     605// Parameters
     606//      lpMapMemory
     607//          Points to a DD_MAPMEMORYDATA structure that contains details for
     608//          the memory mapping or unmapping operation.
     609//
     610//          .lpDD
     611//              Points to a DD_DIRECTDRAW_GLOBAL structure that represents
     612//              the driver.
     613//          .bMap
     614//              Specifies the memory operation that the driver should perform.
     615//              A value of TRUE indicates that the driver should map memory;
     616//              FALSE means that the driver should unmap memory.
     617//          .hProcess
     618//              Specifies a handle to the process whose address space is
     619//              affected.
     620//          .fpProcess
     621//              Specifies the location in which the driver should return the
     622//              base address of the process's memory mapped space when bMap
     623//              is TRUE. When bMap is FALSE, fpProcess contains the base
     624//              address of the memory to be unmapped by the driver.
     625//          .ddRVal
     626//              Specifies the location in which the driver writes the return
     627//              value of the DdMapMemory callback. A return code of DD_OK
     628//              indicates success.
     629//
     630//-----------------------------------------------------------------------------
     631
     632DWORD CALLBACK DdMapMemory(PDD_MAPMEMORYDATA lpMapMemory)
     633{
     634    PPDEV pDev = (PPDEV)lpMapMemory->lpDD->dhpdev;
     635
     636    VIDEO_SHARE_MEMORY              ShareMemory;
     637    VIDEO_SHARE_MEMORY_INFORMATION  ShareMemoryInformation;
     638    DWORD                           ReturnedDataLength;
     639
     640    DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev));
     641
     642    if (lpMapMemory->bMap)
     643    {
     644        ShareMemory.ProcessHandle = lpMapMemory->hProcess;
     645
     646        // 'RequestedVirtualAddress' isn't actually used for the SHARE IOCTL:
     647
     648        ShareMemory.RequestedVirtualAddress = 0;
     649
     650        // We map in starting at the top of the frame buffer:
     651
     652        ShareMemory.ViewOffset = 0;
     653        ShareMemory.ViewSize   = pDev->cyScreen * pDev->lDeltaScreen;
     654
     655        DISPDBG((0, "ViewSize = %x", ShareMemory.ViewSize));
     656
     657        if (EngDeviceIoControl(pDev->hDriver,
     658                       IOCTL_VIDEO_SHARE_VIDEO_MEMORY,
     659                       &ShareMemory,
     660                       sizeof(VIDEO_SHARE_MEMORY),
     661                       &ShareMemoryInformation,
     662                       sizeof(VIDEO_SHARE_MEMORY_INFORMATION),
     663                       &ReturnedDataLength))
     664        {
     665            DISPDBG((0, "Failed IOCTL_VIDEO_SHARE_MEMORY"));
     666
     667            lpMapMemory->ddRVal = DDERR_GENERIC;
     668     
     669            DISPDBG((0, "DdMapMemory: Exit GEN, DDHAL_DRIVER_HANDLED"));
     670           
     671            return(DDHAL_DRIVER_HANDLED);
     672        }
     673
     674        lpMapMemory->fpProcess =
     675                            (FLATPTR) ShareMemoryInformation.VirtualAddress;
     676    }
     677    else
     678    {
     679        ShareMemory.ProcessHandle           = lpMapMemory->hProcess;
     680        ShareMemory.ViewOffset              = 0;
     681        ShareMemory.ViewSize                = 0;
     682        ShareMemory.RequestedVirtualAddress = (VOID*) lpMapMemory->fpProcess;
     683
     684        if (EngDeviceIoControl(pDev->hDriver,
     685                       IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY,
     686                       &ShareMemory,
     687                       sizeof(VIDEO_SHARE_MEMORY),
     688                       NULL,
     689                       0,
     690                       &ReturnedDataLength))
     691        {
     692            DISPDBG((0, "Failed IOCTL_VIDEO_UNSHARE_MEMORY"));
     693        }
     694    }
     695
     696    lpMapMemory->ddRVal = DD_OK;
     697
     698    return(DDHAL_DRIVER_HANDLED);
     699}
     700
    586701/**
    587702 * DdLock
     
    611726    // care of adding in the user-mode frame buffer address if we return
    612727    // DDHAL_DRIVER_NOTHANDLED:
     728    lpLock->ddRVal = DD_OK;
    613729    return DDHAL_DRIVER_NOTHANDLED;
    614730}
     
    636752    DISPDBG((0, "%s: %p\n", __FUNCTION__, pDev));
    637753
     754    lpUnlock->ddRVal = DD_OK;
    638755    return DDHAL_DRIVER_NOTHANDLED;
    639756}
  • trunk/src/VBox/Additions/WINNT/Graphics/Display/dd.h

    r4071 r4343  
    3333DWORD APIENTRY DdFlipToGDISurface(PDD_FLIPTOGDISURFACEDATA lpFlipToGDISurface);
    3434HBITMAP DrvDeriveSurface(DD_DIRECTDRAW_GLOBAL*  pDirectDraw, DD_SURFACE_LOCAL* pSurface);
     35DWORD CALLBACK DdMapMemory(PDD_MAPMEMORYDATA lpMapMemory);
    3536
    3637#endif /* __VBOX_DD_H__*/
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