Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

UMDF can not pass a stucture with pointers?

14 views
Skip to first unread message

gti4ever

unread,
Dec 31, 2009, 10:49:01 PM12/31/09
to
Hi there,

I am trying to port a old wdm driver to UMDF and ran into a problem. I hope
some WDF experts out there can shed some lights for me.

Basically, there is a structure defines as follows:

typedef struct _VendorRequest
{
UINT32 xxx;
UINT32 yyy;
PVOID pDataBuffer ;
UINT32 dataLength;
} SVendorRequest, *PSVendorRequest;

and applications is trying to pass this structure as input buffer when
calling DeviceIoControl

PSVendorRequest vr = (PSVendorRequest) malloc(sizeof (SVendorRequest) + 8);

vr->xxx = xxx;
vr->yyy = yyy;
vr->pDataBuffer = (uint8_t *)(vr + 1) ;
vr->dataLength = 8;

ptr = (uint8_t *)(vr + 1);

ptr[0] = something;
ptr[1] = something;
ptr[2] = something;
ptr[3] = something;
ptr[4] = something;
ptr[5] = something;
ptr[6] = something;
ptr[7] = something;

dwInSize = sizeof(SVendorRequest);
dwInSize += vr->dataLength;
DeviceIoControl((HANDLE) handle,
IOCTL_VENDOR_REQUEST_EX,
(LPVOID) regParam, // Ptr to InBuffer
dwInSize, // Length of InBuffer
NULL, // Ptr to OutBuffer
0, // Length of OutBuffer
(LPDWORD) &nBytesRead,
0);

The problem is: when the intput buffer gets to the OnDeviceIoControl
function in my UMDF driver, all the structure members xxx, yyy and dataLength
are all correct, but the pDataBuffer is either pointing to some invalid
addresses, or all the data become 0.

I have tried both Buffered IO or Direct IO but both of them have the same
problem. However, the same method works with KMDF and WDM driver.

I am just wondering has anyone out there seen this problem before?

Thanks in advance.

G.

gti4ever

unread,
Dec 31, 2009, 10:54:01 PM12/31/09
to
Oops,

there is a typo in my previous post, the correct DeviceIoControl code should
be:

DeviceIoControl((HANDLE) handle,
IOCTL_VENDOR_REQUEST_EX,
(LPVOID) vr, // Ptr to InBuffer

Don Burn

unread,
Jan 1, 2010, 7:50:11 AM1/1/10
to
AFAIK you cannot use METHOD_NEITHER type stuff in UMDF. Of course for any
good design, and particularily with the challenges of 32/64 bit it is almost
never the case you should use a structure like the one you show as a
parameter.


--
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

"gti4ever" <gti4...@discussions.microsoft.com> wrote in message
news:856B6E72-12D5-44B1...@microsoft.com...

> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 4734 (20100101) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4734 (20100101) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


gti4ever

unread,
Jan 3, 2010, 9:19:02 PM1/3/10
to
Thanks Don.

I digged into this issue further and found there is a way to do
METHOD_NEITHER stuff in UMDF. You will have to add UmdfMethodNeitherAction =
Copy to your INF file.

I will try that later and see if it works.

G.

"Don Burn" wrote:

> .
>

gti4ever

unread,
Jan 4, 2010, 9:06:02 AM1/4/10
to
I tried the UmdfMethodNeitherAction=Copy thing in my INF file but still no
luck, so I changed my structure to the following:

typedef struct _VendorRequest
{
UINT32 xxx;
UINT32 yyy;

UINT8 pDataBuffer[10] ;
} SVendorRequest, *PSVendorRequest;

Now I can use this structure to pass data to the lower KMDF driver to set
some registers. However, if I try to read registers, the pDataBuffer always
returns all 0s. I put breakpoint in the lower KMDF driver and did see the
right register value got copied to the pDataBuffer but when the io control
returned from UMDF, the buffer is still 0.

What did I do wrong? How does UMDF handle the buffered IO? If the same data
can be passed in as input buffer, how come the data can't be returned in the
same buffer?

G

Doron Holan [MSFT]

unread,
Jan 4, 2010, 4:33:03 PM1/4/10
to
how are you calling WdfRequestComplete? are you passing the sizse of the
structure as the information? are you passing the buffer here as an input
or output buffer to the KMDF driver?

d

--

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


"gti4ever" <gti4...@discussions.microsoft.com> wrote in message

news:9062FEB8-4E68-445D...@microsoft.com...

gti4ever

unread,
Jan 4, 2010, 9:40:01 PM1/4/10
to
Doron, you are the man! I checked my code and found I did forget to return
the proper size when calling WdfRequestCompleteWithInformation().

Thank you Doron and Don for the answers and helps, my new driver is up and
running now.

I am still curious to see how UMDF handles METHOD_NEITHER, but that is low
priority now.

G.

Doron Holan [MSFT]

unread,
Jan 5, 2010, 12:55:22 PM1/5/10
to
method neither is not supported by UMDF at all

d

--

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

"gti4ever" <gti4...@discussions.microsoft.com> wrote in message

news:C9C82D72-9A83-456E...@microsoft.com...

0 new messages