From: Daniel on 21 Oct 2009 15:25 Hi, When my driver is verified by the driver verifir on Win7 (64 bit), NdisOpenConfigurationKeyByIndex returns KeyName not NULL terminated. The system crashes when the driver tries to access the buffer. For example it crashes by printing the buffer. Why this functions does not return a good unicode string? How can I NULL terminate the returned Unicode string? CODE: NdisOpenConfigurationKeyByIndex(&Status,ConfigurationHandle,i++,&KeyName,&KeyHandle); if(Status != NDIS_STATUS_SUCCESS) break; DbgPrint("key = %ws\n",KeyName.Buffer); -- Thanks, Daniel
From: Pavel A. on 24 Oct 2009 22:34 "Daniel" <Daniel(a)discussions.microsoft.com> wrote in message news:D948E245-FBAA-4503-AF65-D6AAA71C4FEA(a)microsoft.com... > > When my driver is verified by the driver verifir on Win7 (64 bit), > NdisOpenConfigurationKeyByIndex returns KeyName not NULL terminated. > > The system crashes when the driver tries to access the buffer. > For example it crashes by printing the buffer. > Why this functions does not return a good unicode string? This is a design decision from days of yore. Strings used in NT kernel stuff are counted. Expecting them to be null terminated is a bug. > How can I NULL terminate the returned Unicode string? You don't. Just work with counted strings, like everyone else does. > CODE: > NdisOpenConfigurationKeyByIndex(&Status,ConfigurationHandle,i++,&KeyName,&KeyHandle); > if(Status != NDIS_STATUS_SUCCESS) break; > > DbgPrint("key = %ws\n",KeyName.Buffer); Use the %wZ format: DbgPrint("key = %wZ\n", &KeyName); Regards, --pa
|
Pages: 1 Prev: [Commercial] : Windows Kernel Programming Training from Experts Next: virtual driver |