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

Sept/Oct 2019 Issue of The NT Insider available


Download PDF here: http://insider.osr.com/2019/ntinsider_2019_01.pdf

It’s a particularly BIG issue, too: 40 pages of technical goodness, ranging from WDF to Minifilters. Check it out.
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

Who Can tell me the difference between MmGetMdlVirtualAddress and MmGetSystemAddressForMdlSafe

OSR_Community_UserOSR_Community_User Member Posts: 110,217
Who Can tell me the difference between MmGetMdlVirtualAddress and MmGetSystemAddressForMdlSafe?

craig

Comments

  • Mark_RoddyMark_Roddy Member - All Emails Posts: 4,310
    MmGetMdlVirtualAddress returns the original va for the physical pages mapped by the mdl. Usually this is a process specific user mode va and is thus not generally used for accessing the data from kernel mode. More typically it is used to calculate the offset into the first physical page where the actual data starts.

    MmGetSystemAddressForMdlSafe returns a kernel mode va for the physical pages mapped by the mdl. This second va is in fact useful in the kernel in any process context for accessing the user data.

    > -----Original Message-----
    > From: xxxxx@lists.osr.com
    > [mailto:xxxxx@lists.osr.com] On Behalf Of craiglei
    > Sent: Monday, June 10, 2002 4:38 AM
    > To: NT Developers Interest List
    > Subject: [ntdev] Who Can tell me the difference between
    > MmGetMdlVirtualAddress and MmGetSystemAddressForMdlSafe
    >
    >
    > Who Can tell me the difference between MmGetMdlVirtualAddress
    > and MmGetSystemAddressForMdlSafe?
    >
    > craig
    >
    >
    > b嫮绠范\够?v诘譲僧J沧吺N嫴鎟竮莡y櫒秹j鞯综]>X妒
    >
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    One returns the original user-mode address on which MDL was built.
    Another maps the MDL pages to kernel space and returns the mapped
    address, which is always valid regardless on what process and on what
    IRQL you are.

    Max

    ----- Original Message -----
    From: "craiglei" <xxxxx@tgegroup.com>
    To: "NT Developers Interest List" <xxxxx@lists.osr.com>
    Sent: Monday, June 10, 2002 12:37 PM
    Subject: [ntdev] Who Can tell me the difference between
    MmGetMdlVirtualAddress and MmGetSystemAddressForMdlSafe


    > Who Can tell me the difference between MmGetMdlVirtualAddress and
    MmGetSystemAddressForMdlSafe?
    >
    > craig
    >
    >
    > b‹­ç®·¶\¹»?vÚµ×jÉÆ)¶Šçiû¢dº{nlj·zwnV‘éŠ[•æz{zþØy²Û²·
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    What about allocate a new mdl in kernel mode driver? If a mdl is allocated in kernel driver why there is difference between the
    value of MmGetMdlVirtualAddress and MmGetSystemAddressForMdlSafe?

    Driver's code address is virtual address or kernel address(System Address)?

    craig
    ----- Original Message -----
    From: "Mark Roddy" <xxxxx@hollistech.com>
    To: "NT Developers Interest List" <xxxxx@lists.osr.com>
    Sent: Monday, June 10, 2002 6:50 PM
    Subject: [ntdev] RE: Who Can tell me the difference between MmGetMdlVirtualAddress and MmGetSystemAddressForMdlSafe


    MmGetMdlVirtualAddress returns the original va for the physical pages mapped by the mdl. Usually this is a process specific user mode va and is thus not generally used for accessing the data from kernel mode. More typically it is used to calculate the offset into the first physical page where the actual data starts.

    MmGetSystemAddressForMdlSafe returns a kernel mode va for the physical pages mapped by the mdl. This second va is in fact useful in the kernel in any process context for accessing the user data.

    > -----Original Message-----
    > From: xxxxx@lists.osr.com
    > [mailto:xxxxx@lists.osr.com] On Behalf Of craiglei
    > Sent: Monday, June 10, 2002 4:38 AM
    > To: NT Developers Interest List
    > Subject: [ntdev] Who Can tell me the difference between
    > MmGetMdlVirtualAddress and MmGetSystemAddressForMdlSafe
    >
    >
    > Who Can tell me the difference between MmGetMdlVirtualAddress
    > and MmGetSystemAddressForMdlSafe?
    >
    > craig
    >
    >
    > b嫮绠范\够?v诘譲僧J沧吺N嫴鎟竮莡y櫒秹j鞯综]>X妒
    >


    ---
    You are currently subscribed to ntdev as: xxxxx@tgegroup.com
    To unsubscribe send a blank email to xxxxx@lists.osr.com
  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,443
    "craiglei" wrote in message news:xxxxx@ntdev...
    > What about allocate a new mdl in kernel mode driver? If a mdl is allocated
    in kernel driver why there is difference between the
    > value of MmGetMdlVirtualAddress and MmGetSystemAddressForMdlSafe?
    >
    > Driver's code address is virtual address or kernel address(System
    Address)?
    >
    > craig

    Mr. Roddy's answer was, perhaps, not as clear as you needed it to be.

    MmGetSystemAddressForMdl(Safe)(...) takes a buffer described by an MDL and
    maps it into the high 2GB of kernel virtual addressing space. If the MDL
    was built CORRECTLY, and the kernel virtual address that represents the data
    buffer is in the high 2GB of kernel virtual address space, then the return
    from these two functions will indeed be the same.

    Something tells me you have a root issue or question here. How about
    sharing that with us, and we'll try to answer it...

    Peter
    OSR

    Peter Viscarola
    OSR
    @OSRDrivers

  • davs_shrusdavs_shrus Member - All Emails Posts: 12

    @Peter_Viscarola_(OSR) said:
    "craiglei" wrote in message news:[email protected]
    > What about allocate a new mdl in kernel mode driver? If a mdl is allocated
    in kernel driver why there is difference between the
    > value of MmGetMdlVirtualAddress and MmGetSystemAddressForMdlSafe?
    >
    > Driver's code address is virtual address or kernel address(System
    Address)?
    >
    > craig

    Mr. Roddy's answer was, perhaps, not as clear as you needed it to be.

    MmGetSystemAddressForMdl(Safe)(...) takes a buffer described by an MDL and
    maps it into the high 2GB of kernel virtual addressing space. If the MDL
    was built CORRECTLY, and the kernel virtual address that represents the data
    buffer is in the high 2GB of kernel virtual address space, then the return
    from these two functions will indeed be the same.

    If physical memory is allocated for different purpose (may be some controller) and another driver might be creating MDL for that physical memory reference then va where it refer. I am just wondering how some controller will operate on physical memory allocated (does it also refer virtual address) if this is the case what virtual address does it be pointing..?

    Something tells me you have a root issue or question here. How about
    sharing that with us, and we'll try to answer it...

    Peter
    OSR

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,104

    When you create an MDL, you always start from a virtual address. The system will fill in the MDL with the physical pages for that set of virtual addresses. You make it sound like we start from a physical address and work backwards, but that's just not the way it is.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 7,443

    @davs_shrus: Good job, re-opening g a 17 year old thread!

    https://i.kym-cdn.com/photos/images/masonry/000/028/451/Necropost.jpg

    Closing thread.

    If you have a question, post it in a new thread. Please.

    Peter

    Peter Viscarola
    OSR
    @OSRDrivers

This discussion has been closed.

Howdy, Stranger!

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

Upcoming OSR Seminars
Writing WDF Drivers 21 Oct 2019 OSR Seminar Space & ONLINE
Internals & Software Drivers 18 Nov 2019 Dulles, VA
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 27 Apr 2020 OSR Seminar Space & ONLINE