Just to be clear, WMIREG_FLAG_INSTANCE_PDO only works for pnp device
stacks. WMIREG_FLAG_INSTANCE_PDO to requires a PDO, something that you
don’t have when you create a device object in DriverEntry() (which is an
older style, legacy driver, but both WDM and this style are still kernel
mode drivers).
I think your problem is that you are including the NULL for the string
in the buffer’s length, which means that the NULL character is a part of
the name itself and not a terminator.
Instead of this
InstanceName->Length = InstanceName->MaximumLength =
sizeof(INSTANCENAME);
Try this
InstanceName->Length = sizeof(INSTANCENAME) - sizeof(UNICODE_NULL);
InstanceName->MaximumLength = sizeof(INSTANCENAME);
On failure to allocate InstanceName->Buffer you should be returning a
!NT_SUCCESS value, probably STATUS_INSUFFICIENT_RESOURCES.
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of R.Yang
Sent: Sunday, May 06, 2007 10:54 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] WMI & KMD
Hi,
KMD is kernel mode driver (service) which has no PnP stuff. Do we call
it in this name?
My driver just creates a DO in DriverEntry and is very simple. I add
some WMI code to this driver with WMIREG_FLAG_INSTANCE_BASENAME and
copy a UNICODE name to InstanceName as required by DDK.
The following code is in driver part:
NTSTATUS ScutumWmiQueryReginfo(
IN PDEVICE_OBJECT DeviceObject,
OUT PULONG RegFlags,
OUT PUNICODE_STRING InstanceName,
OUT PUNICODE_STRING* RegistryPath,
OUT PUNICODE_STRING MofResourceName,
OUT PDEVICE_OBJECT* Pdo
)
{
PSCUTUM_DEVICE_EXTENSION deviceExtension;
ODS(DBG_WMI, DBG_TRACE, FUNCTION"++");
deviceExtension =
(PSCUTUM_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
*RegFlags = WMIREG_FLAG_INSTANCE_BASENAME;
*RegistryPath = &g_Data.RegistryPath;
#define INSTANCENAME L"ScutumDriver"
InstanceName->Buffer = (PWCH)ExAllocatePool(
PagedPool,
sizeof(INSTANCENAME)
);
if(InstanceName->Buffer)
{
InstanceName->Length = InstanceName->MaximumLength =
sizeof(INSTANCENAME);
RtlCopyMemory(
InstanceName->Buffer,
INSTANCENAME,
sizeof(INSTANCENAME)
);
}
RtlInitUnicodeString(MofResourceName, L"MofResource");
*Pdo = NULL;
ODS(DBG_WMI, DBG_TRACE, FUNCTION"–");
return STATUS_SUCCESS;
}
And JavaScript:
Scutum Device Information
CLASSID=“CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223”>
onClick="Prev()">
onClick="Update()">
onClick="Submit()">
onClick="Next()">
|
Instance Path: |
|
|
DriverVersion: |
|
|
DriverDescription: |
|
ScutumEventNotification Message:
READONLY>
And mof:
[Dynamic,
Provider(“WMIProv”),
WMI,
Description(“Scutum driver information”),
guid(“{1BC528BD-26D3-4C3D-A67F-1C9BD2936836}”),
locale(“MS\0x409”)]
class ScutumDeviceInformation
{
[
key,
read
]
string InstanceName;
[
read
]
boolean Active;
[
WmiDataId(1),
read,
write,
Description(“Scutum DriverVersion property”)
]
uint64 DriverVersion;
[
WmiDataId(2),
read,
write,
Description(“Scutum DriverDescription property”)
]
string DriverDescription;
};
[Dynamic,
Provider(“WMIProv”),
WMI,
Description(“Scutum EventNotification event”),
guid(“{2F4F262B-C352-4152-848C-5977C5010C2C}”),
locale(“MS\0x409”)]
class ScutumEventNotification : WMIEvent
{
[
key,
read
]
string InstanceName;
[
read
]
boolean Active;
[
WmiDataId(1),
read,
Description(“Informational Message”)
]
string Message;
};
Sorry that the code looks too long. 
The problem occurs on this line in JavaScript:
var Collection = new
Enumerator(Service.InstancesOf(“ScutumDeviceInformation”));
Any hints?
On Mon, 7 May 2007 00:55:07 -0400 (EDT), xxxxx@Microsoft.com
wrote:
By KMD, do you mean KMDF? KMDF does support being a WMI provider (with
the appropriately named WDFWMIPROVIDER object); KMDF currently only
supports WMIREG_FLAG_INSTANCE_PDO as a way to register a name, does
your javascript use a hard coded instance name? can you post your
script? What OS is this on?
d
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer