Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > NdisOpenConfigurationKeyByIndex returns KeyName not NULL terminate

Reply
Thread Tools Display Modes

NdisOpenConfigurationKeyByIndex returns KeyName not NULL terminate

 
 
Daniel
Guest
Posts: n/a

 
      10-21-2009

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,Configurat ionHandle,i++,&KeyName,&KeyHandle);
if(Status != NDIS_STATUS_SUCCESS) break;


DbgPrint("key = %ws\n",KeyName.Buffer);

--
Thanks,

Daniel
 
Reply With Quote
 
 
 
 
Pavel A.
Guest
Posts: n/a

 
      10-25-2009
"Daniel" <> wrote in message
news948E245-FBAA-4503-AF65-...
>
> 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,Configurat ionHandle,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


 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP sfc /scannow William Beard Windows Vista Performance 17 05-11-2007 04:28 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59