I am having an issue with a buffer that I am passing from my application
down to my driver getting overwritten by some code in the driver or kernel.
It is happening in some code that I don’t have source for. I am using KMDF
in WDK RTM 6000. I am not sure if I am having some type of paging issue or
what. I don’t get a protection voilation. Does
WdfRequestRetrieveInputBuffer do something to make sure the buffer is not
paged out and available in my driver? I am new to KMDF and not sure if
there is something I need to do to make sure the buffer is not paged out and
available when I need it. I set a write breakpoint in WinDbg and tracked it
to the code at the end of this message.
I am allocating the buffer like this in my test application:
file_buffer = (VOICE_BUFFER_STRUCT *)malloc(buffer_length);
I am passing the buffer like this:
if (!DeviceIoControl(DriverHandle,
(DWORD)IOCTL_APOLLO_PLAY_BUFFER,
file_buffer, // Ptr to InBuffer
buffer_length, // Length of InBuffer
NULL, // Ptr to OutBuffer
0, // Length of OutBuffer
&index, // BytesReturned
0) ) // Ptr to Overlapped structure
{
And getting the buffer like this:
case IOCTL_APOLLO_PLAY_BUFFER:
status = WdfRequestRetrieveInputBuffer(Request,
2, (PVOID*)&IOBuffer, &IOBufferLength);
if (NT_SUCCESS(status))
{
}
The third word in the buffer structure is being overwritten by the following
code in an area I don’t have source for (the last instruction is doing it):
80549856 8b0dc8f45580 mov ecx,dword ptr [nt!MmPfnDatabase (8055f4c8)]
8054985c 8d0440 lea eax,[eax+eax*2]
8054985f 8d04c1 lea eax,[ecx+eax*8]
80549862 85c0 test eax,eax
80549864 740a je nt!MiFreePoolPages+0x415 (80549870)
80549866 f6400c04 test byte ptr [eax+0Ch],4
8054986a 0f84cf010000 je nt!MiFreePoolPages+0x38b (80549a3f)
80549870 8b4d08 mov ecx,dword ptr [ebp+8]
80549873 8d41ff lea eax,[ecx-1]
80549876 83f804 cmp eax,4
80549879 894e08 mov dword ptr [esi+8],ecx
Any ideas?
Thanks,
Greg