WDF WMI and returning strings from the Kernel.

Hi folks,

Strings in WMI methods appear to be less than perfectly working.

Input strings work:

void EFX_Port_SetMemo ( [in, MaxLen(256)] string Memo );

However, I want to do something like this:

void EFX_Root_GetCapability ( [in] uint32 CapabilityIndex , [out,
MaxLen(256)] string CapabilityName );

And I get a nasty shock. Sure, the MOF compiler doesn’t give me a
_OUT_SIZE declaration, but that’s no problem, because the string is the
only parameter. I figure that in my EvtWmiInstanceExecuteMethod, I’ll
discover the max string length from the OutBufferSize. Unfortunately,
when my method gets called, OutBufferSize is 2 bytes.

Just big enough for me to store the length indicator for a zero length
string.

MH.

Did his work for a WDM driver? KMDF does not do any minimum buffer size checking for ExecuteMethod, it just passes the buffer sizes and data buffer to the callback. Are you passing a big enough buffer in the calling application to the ExecuteMethod call?

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Martin Harvey
Sent: Monday, October 29, 2007 1:00 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] WDF WMI and returning strings from the Kernel.

Hi folks,

Strings in WMI methods appear to be less than perfectly working.

Input strings work:

void EFX_Port_SetMemo ( [in, MaxLen(256)] string Memo );

However, I want to do something like this:

void EFX_Root_GetCapability ( [in] uint32 CapabilityIndex , [out,
MaxLen(256)] string CapabilityName );

And I get a nasty shock. Sure, the MOF compiler doesn’t give me a
_OUT_SIZE declaration, but that’s no problem, because the string is the
only parameter. I figure that in my EvtWmiInstanceExecuteMethod, I’ll
discover the max string length from the OutBufferSize. Unfortunately,
when my method gets called, OutBufferSize is 2 bytes.

Just big enough for me to store the length indicator for a zero length
string.

MH.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Doron Holan wrote:

Did his work for a WDM driver? KMDF does not do any minimum buffer size checking for ExecuteMethod, it just passes the buffer sizes and data buffer to the callback. Are you passing a big enough buffer in the calling application to the ExecuteMethod call?

Looks like that’s a “no” - the calling app is PowerShell. Perhaps it’ll
be better for the function to return a string instead of having it as an
out parameter, but I then need to work out what the rules are for buffer
allocation in that case - I didn’t think that was possible.

MH.

Martin Harvey wrote:

Looks like that’s a “no” - the calling app is PowerShell.

Now fixed. My error. Some of the autogenerated code in our driver was
setting *BufferUsed to zero.

*sigh* .

MH.