Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting... Please check out the Community Guidelines in the
Announcements and Administration Category.

How to access display memory in kernel mode ?

I am trying to read display contents from a kernel mode application. Is
there any way to do this ? Most likely the source of call will be either
display driver or a miniport driver..

Comments

  • Don_Burn_1Don_Burn_1 Posts: 4,311
    > I am trying to read display contents from a kernel mode application. Is
    > there any way to do this ? Most likely the source of call will be either
    > display driver or a miniport driver..

    Seriously, think about the fact that if your driver is general purpose,
    Windows does not require a display. Also with a terminal services model
    which "display" do you want to model. In general have any dependency in
    your driver on displaying on a desktop is a bad idea.

    Don Burn (MVP for DDK)
    Windows Filesystem and Driver Consulting
  • VideoPortMapMemory is mapping the video memory address to virtual address.

    But the caller is NOT Display driver... , You must access Video miniport dirver.

    How ? I don't know.... In general... video card provider prohibit... -.-;

    But, U can access video memory, by .... Memory mapping... If U know address space of

    Video Ram.

    Then How can I access video memory information or something....?

    The formal way... is through.. EngIoControl(?) in display driver.... But, as I mentioned...

    U can get the information from registry....

    HKLM\SYSTEM\CurrentControlSet\Enum\PCI\VEN_????&DEV_????....\Control\AllocConfig

    Next, U can map the address to your user level application address, as follows

    PHYSICAL_ADDRESS PhysicalAddress;
    PhysicalAddress.u.HighPart = 0;
    PhysicalAddress.u.LowPart = 0x????????; // IoAddress of video card.

    if (!pBI->pBuf||pBI->nSize==0) return NULL;

    //Virtual address which driver can access
    pBI->pBuf = MmMapIoSpace( PhysicalAddress, pBI->nSize, FALSE );
    if (pBI->pBuf == NULL)
    {
    return NULL;
    }

    pBI->pmdl = IoAllocateMdl( pBI->pBuf, pBI->nSize, 0, 0, 0 );
    if (!pBI->pmdl)
    {
    MmUnmapIoSpace( pBI->pBuf, pBI->nSize);
    return NULL;
    }

    MmBuildMdlForNonPagedPool( pBI->pmdl );
    pBI->pUserVa = MmMapLockedPages( pBI->pmdl, UserMode );

    if (!pBI->pUserVa)
    {
    IoFreeMdl(pBI->pmdl);
    MmUnmapIoSpace( pBI->pBuf, pBI->nSize);
    return NULL;
    }
  • You see the thing is I am not sure I need a driver. My goal is to have
    access to display data across Windows logics (locked workstation, fast
    user switching etc).

    If you ever tried to get display using GDI, GDI+, DirectX, or any other
    high level APIs, there is a problem which is like, display data handles,
    variables, or objects you use to access the data, become invalid when you
    hit 'Lock Workstation' or switch user... For me this is an indication,
    that i need to go deeper, to get under this logics, because my remote
    desktop application is not a user mode service but a terminal emulator.
    This means that a remote client can logon to a locked workstation and log
    in remotely... While Terminal Services EMULATES user login screens, I want
    to send those screens to client as-is and provide remote keyboard and
    mouse services.

    This is the only reason for my question ;) Hope I made this clear, i dont
    know how to explain it better !
  • > in remotely... While Terminal Services EMULATES user login screens, I want
    > to send those screens to client as-is and provide remote keyboard and
    > mouse services.

    Add a mirror driver, and mirror the display drawing to some in-memory surface.

    Maxim Shatskih, Windows DDK MVP
    StorageCraft Corporation
    xxxxx@storagecraft.com
    http://www.storagecraft.com
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!