none
MmMapIOSpace and RtlCopyMemory RRS feed

  • Question

  • Hi All,

    I have a doubt about using RtlCopyMemory() function to read large amounts of data (like 1KB) from MmMapIOSpace  mapped space. 

    Still now i have not faced this scenario. All these days i have used READ_REGISTER_BUFFER_XXX .

    Please clarify.

    I am not finding answer for this. In some places RtlCopyMemory() used to access MmMapIOSpace. But it was answered that generally this method is not preferable. 

    When at what situation RtlCopyMemory() can be used to access MmMapIOSpace spaces.

    • Edited by Boomi.s Thursday, October 30, 2014 12:13 PM
    Thursday, October 30, 2014 7:06 AM

Answers

  • Yes, you can use RtlCopyMemory on memory mapped using MmMapIOSpace. READ_REGISTER_BUFFER_XXX issues a memory barrier and uses the MOVSB instruction, while RtlCopyMemory is really memcpy, which does the copy in a loop, moving 8 bytes at a time.

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    Thursday, October 30, 2014 8:15 PM
    Moderator

All replies

  • Yes, you can use RtlCopyMemory on memory mapped using MmMapIOSpace. READ_REGISTER_BUFFER_XXX issues a memory barrier and uses the MOVSB instruction, while RtlCopyMemory is really memcpy, which does the copy in a loop, moving 8 bytes at a time.

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    Thursday, October 30, 2014 8:15 PM
    Moderator
  • Thanks for the clarifications and inputs.



    Friday, October 31, 2014 5:53 AM
  • If it really is memory that he is mapping (rather than registers masquerading as memory), then there is no reason not to treat it as memory. Using the READ_REGISTER_BUFFER_XXX routines will induce a performance hit because of the memory barrier.

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    Friday, October 31, 2014 7:10 PM
    Moderator