You are dealing with string constants, there is no need to go from ANSI to Unicode. What was this
RtlInitAnsiString(&ntString,\DosDevices\COM3);
RtlAnsiStringToUnicodeString(&uString,&ntString,TRUE);
Can be this
RtlInitUnicodeString(&uString, L"\DosDevices\COM3");
Same for the 2nd method, this
RtlInitAnsiString(&ntString,“\DosDevices\”);
RtlAnsiStringToUnicodeString(&uString,&ntString,TRUE);
Becomes
RtlInitUnicodeString(&uString, L"\DosDevices\");
D
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Launay Ronan
Sent: Thursday, October 14, 2004 5:43 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] UnicodeString or Registry prob ?
i found my mistake .
buffer of first unicode string was too small .
actually RtlAppendUnicodeStringToString failed .
sorry for bothering … ![:stuck_out_tongue: :stuck_out_tongue:](/images/emoji/twitter/stuck_out_tongue.png?v=12)
“Launay Ronan” a ?crit dans le message de
news:xxxxx@ntdev…
> should read :
> status = IoGetDeviceObjectPointer(&uString,FILE_ALL_ACCESS,
> &pdx->fileObject,&pdx->SerialDeviceObject);
>
> in the second code sample .
>
>
> “Launay Ronan” a ?crit dans le message de
> news:xxxxx@ntdev…
> > when i do this :
> > //Opening COM Port .
> > RtlInitAnsiString(&ntString,\DosDevices\COM3);
> > RtlAnsiStringToUnicodeString(&uString,&ntString,TRUE);
> > status = IoGetDeviceObjectPointer(&uString,FILE_ALL_ACCESS,
> > &pdx->fileObject,&pdx->SerialDeviceObject);
> > if(!NT_SUCCESS(status)){
> > KdPrint((DRIVERNAME" - IoGetDeviceObjectPointer Fails ,status :
> > %X\n",status));
> > return status;
> > }
> >
> > it works just fine but if i do this i got IoGetDeviceObjectPointer
fails
> ,
> > with a C000003B status code :
> > (i got a good value in Registry , Port (REG_SZ) :COM3 )
> > i’m geting others values from registry w/o any problem .
> > so i guess the concatenation is wrong but can’t figure why :((
> >
> > RtlInitUnicodeString(&uName, L"Port");
> > status = ZwQueryValueKey(hFolder,&uName,
> > KeyValuePartialInformation,pValue,structLength,&ResultLength);
> > if(!NT_SUCCESS(status))return status;
> > RtlInitUnicodeString(&uResult,(PWCHAR)pValue->Data);
> >
> > // Opening COM Port .
> > RtlInitAnsiString(&ntString,“\DosDevices\”);
> > RtlAnsiStringToUnicodeString(&uString,&ntString,TRUE);
> > RtlAppendUnicodeStringToString(&uString,&uResult);
> > status = IoGetDeviceObjectPointer(&uResult,FILE_ALL_ACCESS,
> > &pdx->fileObject,&pdx->SerialDeviceObject);
> > if(!NT_SUCCESS(status)){
> > KdPrint((DRIVERNAME" - IoGetDeviceObjectPointer Fails ,status :
> > %X\n",status));
> > return status;
> > }
> >
> >
> >
>
>
>
—
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com