none
WdfMemoryCopyFromBuffer RRS feed

  • Question

  • I have already created memory object which contains buffer of 1000 bytes. 

    Now I create a new memory object using WdfMemoryCreate() of length 500bytes.

    Now I want to copy the last 500 bytes from already created memory object buffer to newly created memory. 

    I know only WdfMemoryCopyFromBuffer  but it copies from starting of the source buffer and I want last 500 bytes to be copied. How do I implement that ?

    Thursday, January 2, 2014 11:41 AM

Answers

  • WdfMemoryGetBuffer

    Thursday, January 2, 2014 2:53 PM
  • No, pavel answered it correctly. You pass in a PVOID pointer for the source to WdfMemoryCopyFromBuffer. If your source is a WDFMEMORY, you must do the following

    1. get the starting PVOID by calling WdfMemoryGetBuffer
    2. compute the offset you want to start from, WDF_PTR_ADD_OFFSET helps here and does all the pointer casting/math for you
    3. pass the computed start pointer to WdfMemoryCopyFromBuffer

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Friday, January 3, 2014 7:29 AM

All replies

  • WdfMemoryGetBuffer

    Thursday, January 2, 2014 2:53 PM
  • I think the question asked is different as answer replied is different. I want to copy by setting offset of source buffer.
    Friday, January 3, 2014 5:13 AM
  • No, pavel answered it correctly. You pass in a PVOID pointer for the source to WdfMemoryCopyFromBuffer. If your source is a WDFMEMORY, you must do the following

    1. get the starting PVOID by calling WdfMemoryGetBuffer
    2. compute the offset you want to start from, WDF_PTR_ADD_OFFSET helps here and does all the pointer casting/math for you
    3. pass the computed start pointer to WdfMemoryCopyFromBuffer

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Friday, January 3, 2014 7:29 AM
  • I knew about WdfMemoryGetBuffer but I did not know how to set offset and I was looking for WDF_PTR_ADD_OFFSET.

    Thanks. 

    Friday, January 3, 2014 7:41 AM