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

Home NTDEV

Before Posting...

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

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


How to access display memory in kernel mode ?

OSR_Community_UserOSR_Community_User Member Posts: 110,217
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 Member 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
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    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;
    }
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    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 !
  • Maxim_S._ShatskihMaxim_S._Shatskih Member Posts: 10,396
    > 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
    [email protected]
    http://www.storagecraft.com
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 16-20 October 2023 Live, Online
Developing Minifilters 13-17 November 2023 Live, Online
Internals & Software Drivers 4-8 Dec 2023 Live, Online
Writing WDF Drivers 10-14 July 2023 Live, Online