Hi
I am receiving NDIS_STRING from INF File as like this “1,2,3,4,5,6”
it is stored in the param->parameterdata.stringdata.
i want to copy it to my local char* variable. i used strcpy function to copy, but system get crashes at the exact place.
char* accopydatas;
strcpy(accopydatas, param->parameterdata.stringdata);
i have tried another option by copying it to ANSI_STRING and it successfully copied , but at the exact strcpy , system get crashes.
anyother way to copy.
thanks,
balaj
-
a UNICODE_STRING is a counted string and not a null terminated
sequence of wide characters. Look at the definition of a
UNICODE_STRING in ntdef.h. Consequently your strcpy call is doomed.
-
strcpy is banned api, you have to use the safe string functions instead.
-
technically not all strings can be converted from wide to narrow
format, but that is not really an issue in this case.
Mark Roddy
On Tue, Sep 22, 2009 at 6:14 AM, wrote:
> Hi
> I am receiving NDIS_STRING from INF File as like this “1,2,3,4,5,6”
> it is stored in the param->parameterdata.stringdata.
> i want to copy it to my local char* variable. i used strcpy function to copy, but system get crashes at the exact place.
> char* accopydatas;
> strcpy(accopydatas, param->parameterdata.stringdata);
>
> i have tried another option by copying it to ANSI_STRING and it successfully copied , but at the exact strcpy , system get crashes.
>
> anyother way to copy.
>
> thanks,
> balaj
>
> —
> 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
>
>
- strcpy is banned api, you have to use the safe string functions
instead.
And you’d use wcscpy for the buffer of a UNICODE_STRING, not strcpy 
James