Discussion:
WMI method issue with variable length array input parameters
(too old to reply)
William
2009-01-26 22:56:26 UTC
Permalink
OK... another WMI issue.. I am totally lost with this WMI stuff... Maybe not
really a driver related issue but if anybody worked on this before, please
help me out.

Our NDIS 6 nic miniport driver supports the WMI method interface for the
application to call some driver function like read/write flash. Here is the
mof definition for such method:

[WMI, Dynamic, Provider("WMIProv"),
guid("{2EA8003C-3F66-44a2-851C-FC27356243E2}"),
localeid(0x409),
WmiExpense(1),
Description("Flash Access")]
class Flash
{
[key, read]
string InstanceName; // Instance name returned from WMI
[read]
boolean Active;

[Implemented,
WmiMethodId(1)
]
void WriteFlash(
[in] uint32 Address,
[in] uint32 Length,
[in, WmiSizeIs("Length")]
uint8 Data[],
);
};
This WriteFlash method has variant input paramter Data whose size is defined
by the second parameter Length. In my C++ WMI client app, I pretty much
followed the sample here
http://msdn.microsoft.com/en-us/library/aa390421(VS.85).aspx to call the
method. I setup the Address parameter and set the input Length parameter to
16 and build a SAFEARRAY of 16 uint8 datas and assign it to Data parameter
with following code:
VariantInit(&varParam);
V_VT(&varParam) = VT_ARRAY|VT_UI1;
V_ARRAY(&varParam) = pSA; //safe array with 16 uint8 data
hres = pClassInstance->Put(L"Data", 0, &varParam, 0);

But the ExecMethod return WBEM_E_INVALID_PARAMETER all the time. If the
last parameters is a fixed length data, the method runs fine. When it is
variable length array, I also find some interesting error in the wmiprov.log:

*****************************************
(Mon Jan 26 14:36:40 2009.260296934) : Class ... __PARAMETERS
(Mon Jan 26 14:36:40 2009.260296934) : Current property ... Data
(Mon Jan 26 14:36:40 2009.260296934) :
(Mon Jan 26 14:36:40 2009.260296934) : Expected size ... 1
(Mon Jan 26 14:36:40 2009.260296934) : Current size ... 16
(Mon Jan 26 14:36:40 2009.260296934) :

It looks like that WDM provider is only required 1 byte instead of by 16
bytes Data array. My mof file also compiles to a header file that is used by
my miniport nic driver and in that header file it have the following input
parameter structure:
typedef struct _WriteFlash_IN
{
ULONG Address;
#define WriteFlash_IN_Address_SIZE sizeof(ULONG)
#define WriteFlash_IN_Address_ID 1

ULONG Length;
#define WriteFlash_IN_Length_SIZE sizeof(ULONG)
#define WriteFlash_IN_Length_ID 2

UCHAR Data[1];
#define WriteFlash_IN_Data_ID 3

} WriteFlash_IN, *PWriteFlash_IN;

Obvious the data[1] here only means the array is variable length. So is WMI
provider wrong or my parameter set up has some issue and WMI provider does
not it is variable length array?

Thanks,
William
Kinki Wu
2011-02-09 08:47:15 UTC
Permalink
Excuse me.
I have the same problem with you.
ExecMethod return WBEM_E_INVALID_PARAMETER all the time. I

I have a array variable in mof, and also define the array size to WmiSizeIs("Length").
But the header file will show UCHAR Data[1];
that sound means the array size is one.

now, i don't have any idea about how to solve this situation.

do i must allocate a space for the array variable in my driver?

could you please tell me about how do you solve this problem?
I'll very appreciate your help
thank you very much
Post by William
OK... another WMI issue.. I am totally lost with this WMI stuff... Maybe not
really a driver related issue but if anybody worked on this before, please
help me out.
Our NDIS 6 nic miniport driver supports the WMI method interface for the
application to call some driver function like read/write flash. Here is the
[WMI, Dynamic, Provider("WMIProv"),
guid("{2EA8003C-3F66-44a2-851C-FC27356243E2}"),
localeid(0x409),
WmiExpense(1),
Description("Flash Access")]
class Flash
{
[key, read]
string InstanceName; // Instance name returned from WMI
[read]
boolean Active;
[Implemented,
WmiMethodId(1)
]
void WriteFlash(
[in] uint32 Address,
[in] uint32 Length,
[in, WmiSizeIs("Length")]
uint8 Data[],
);
};
This WriteFlash method has variant input paramter Data whose size is defined
by the second parameter Length. In my C++ WMI client app, I pretty much
followed the sample here
http://msdn.microsoft.com/en-us/library/aa390421(VS.85).aspx to call the
method. I setup the Address parameter and set the input Length parameter to
16 and build a SAFEARRAY of 16 uint8 datas and assign it to Data parameter
VariantInit(&varParam);
V_VT(&varParam) = VT_ARRAY|VT_UI1;
V_ARRAY(&varParam) = pSA; //safe array with 16 uint8 data
hres = pClassInstance->Put(L"Data", 0, &varParam, 0);
But the ExecMethod return WBEM_E_INVALID_PARAMETER all the time. If the
last parameters is a fixed length data, the method runs fine. When it is
*****************************************
(Mon Jan 26 14:36:40 2009.260296934) : Class ... __PARAMETERS
(Mon Jan 26 14:36:40 2009.260296934) : Current property ... Data
(Mon Jan 26 14:36:40 2009.260296934) : Expected size ... 1
(Mon Jan 26 14:36:40 2009.260296934) : Current size ... 16
It looks like that WDM provider is only required 1 byte instead of by 16
bytes Data array. My mof file also compiles to a header file that is used by
my miniport nic driver and in that header file it have the following input
typedef struct _WriteFlash_IN
{
ULONG Address;
#define WriteFlash_IN_Address_SIZE sizeof(ULONG)
#define WriteFlash_IN_Address_ID 1
ULONG Length;
#define WriteFlash_IN_Length_SIZE sizeof(ULONG)
#define WriteFlash_IN_Length_ID 2
UCHAR Data[1];
#define WriteFlash_IN_Data_ID 3
} WriteFlash_IN, *PWriteFlash_IN;
Obvious the data[1] here only means the array is variable length. So is WMI
provider wrong or my parameter set up has some issue and WMI provider does
not it is variable length array?
Thanks,
William
Submitted via EggHeadCafe
SQL Server Best Practices
http://www.eggheadcafe.com/tutorials/aspnet/56efb426-550b-48cc-b52a-eca25b6cd427/sql-server-best-practices.aspx
Loading...