Need help using rtlcopystring function.

Hi,

I am using rtlcopystring function to copy a string value to
pIrp->AssociatedIrp.SystemBuffer.

char str[20] = “USA”;
rtlcopystring((char*) pIrp->AssociatedIrp.SystemBuffer, str);

I have included ntddk.h in my program, but I am getting error as " ‘rtlcopystring’ undefined; assuming extern returning int".

Please advise.

Thanks,
Harsha


Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2¢/min with Yahoo! Messenger with Voice.

You need to lookup what a STRING object is. It is not a PCHAR, it is a counted CHAR string. See ntdef.h for the definitions of PSTRING and STRING.

Rule: review all casting operations for correctness. In particular casts that are not associated with PVOID objects are massively suspect.

There are functions that operate on null terminated CHAR buffers, see for example RtlStringCbCopyA.


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Tuesday, April 18, 2006 11:01 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Need help using rtlcopystring function.

Hi,

I am using rtlcopystring function to copy a string value to

pIrp->AssociatedIrp.SystemBuffer.

char str[20] = “USA”;

rtlcopystring((char*) pIrp->AssociatedIrp.SystemBuffer, str);

I have included ntddk.h in my program, but I am getting error as " ‘rtlcopystring’ undefined; assuming extern returning int".

Please advise.

Thanks,

Harsha


Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries http:</http:> for just 2?/min with Yahoo! Messenger with Voice. — 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

Screw Occam…I say that it’s a compiler bug**

Not to be an ass, but really…This has nothing to do with writing drivers
or even the DDK. I’m thinkin’ that should be able to figure this one out in
less time than it would take to post to the group (Hint: It might have
something to do with a PSTRING not being a PCHAR)

Regards,

-scott

**Yes, I’m being sarcastic


Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Harsha Inamdar” wrote in message news:xxxxx@ntdev…
Hi,

I am using rtlcopystring function to copy a string value to
pIrp->AssociatedIrp.SystemBuffer.

char str[20] = “USA”;
rtlcopystring((char*) pIrp->AssociatedIrp.SystemBuffer, str);

I have included ntddk.h in my program, but I am getting error as "
‘rtlcopystring’ undefined; assuming extern returning int".

Please advise.

Thanks,
Harsha

Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2¢/min
with Yahoo! Messenger with Voice.

Oh and what exactly do you mean by “I have included ntddk.h in my program”? If your ‘program’ is not a kernel mode device driver you are in serious trouble.

Finally, are your sources ‘.c’ or ‘.cpp’?

Ah, even more finally, it’s RtlCopyString, not rtlcopystring.


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Tuesday, April 18, 2006 11:01 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Need help using rtlcopystring function.

Hi,

I am using rtlcopystring function to copy a string value to

pIrp->AssociatedIrp.SystemBuffer.

char str[20] = “USA”;

rtlcopystring((char*) pIrp->AssociatedIrp.SystemBuffer, str);

I have included ntddk.h in my program, but I am getting error as " ‘rtlcopystring’ undefined; assuming extern returning int".

Please advise.

Thanks,

Harsha


Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries http:</http:> for just 2?/min with Yahoo! Messenger with Voice. — 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

> rtlcopystring((char*) pIrp->AssociatedIrp.SystemBuffer, str);
Have you noticed that the prototype is

void __stdcall RtlCopyString(PSTRING dest, const STRING* src);

where STRING actually mean not just char* but a struct?

It contains Length, MaximumLength and only then a char* Buffer goes.

You may want to look into ntdef.h for STRING and PSTRING declarations.

Further, can it be that you use “rtlcopystring” instead of “RtlCopyString”?

----- Original Message -----
From: Harsha Inamdar
To: Windows System Software Devs Interest List
Sent: Tuesday, April 18, 2006 11:00 AM
Subject: [ntdev] Need help using rtlcopystring function.

Hi,

I am using rtlcopystring function to copy a string value to
pIrp->AssociatedIrp.SystemBuffer.

char str[20] = “USA”;
rtlcopystring((char*) pIrp->AssociatedIrp.SystemBuffer, str);

I have included ntddk.h in my program, but I am getting error as " ‘rtlcopystring’ undefined; assuming extern returning int".

Please advise.

Thanks,
Harsha


Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2?/min with Yahoo! Messenger with Voice. — 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

Damn Scott, Matt, David and I welcome you to the honorable Hall of
Curmudgeons. :slight_smile:

Besides which, once he figures out how to type, that C/C++ is case
sensitive, and that NTDDK.H is for building kernel components, he/she/it
really needs to realize that a blind copy into an IRP buffer is best done
using the safe string functions such as RtlStringCbCopy.

Gary G. Little

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Scott Noone
Sent: Tuesday, April 18, 2006 10:28 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Need help using rtlcopystring function.

Screw Occam…I say that it’s a compiler bug**

Not to be an ass, but really…This has nothing to do with writing drivers

or even the DDK. I’m thinkin’ that should be able to figure this one out
in
less time than it would take to post to the group (Hint: It might have
something to do with a PSTRING not being a PCHAR)

Regards,

-scott

**Yes, I’m being sarcastic


Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Harsha Inamdar” wrote in message
news:xxxxx@ntdev…
Hi,

I am using rtlcopystring function to copy a string value to
pIrp->AssociatedIrp.SystemBuffer.

char str[20] = “USA”;
rtlcopystring((char*) pIrp->AssociatedIrp.SystemBuffer, str);

I have included ntddk.h in my program, but I am getting error as "
‘rtlcopystring’ undefined; assuming extern returning int".

Please advise.

Thanks,
Harsha

Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just
2?/min
with Yahoo! Messenger with Voice.


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

Harsha Inamdar wrote:

I am using rtlcopystring function to copy a string value to
pIrp->AssociatedIrp.SystemBuffer.

char str[20] = “USA”;
rtlcopystring((char*) pIrp->AssociatedIrp.SystemBuffer, str);

I have included ntddk.h in my program, but I am getting error as "
‘rtlcopystring’ undefined; assuming extern returning int".

The likely problem is that you don’t really want to use RtlCopyString at
all. If you really want to return a string to your client app, then
just use strcpy or memcpy. Be sure you set the IoStatus Information
field to the number of bytes you are returning, INCLUDING the zero byte,
if it’s a zero-terminated string.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks Gary. I found RtlStringCbCopy useful.

–Harsha

xxxxx@seagate.com wrote:
Damn Scott, Matt, David and I welcome you to the honorable Hall of
Curmudgeons. :slight_smile:

Besides which, once he figures out how to type, that C/C++ is case
sensitive, and that NTDDK.H is for building kernel components, he/she/it
really needs to realize that a blind copy into an IRP buffer is best done
using the safe string functions such as RtlStringCbCopy.

Gary G. Little

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Scott Noone
Sent: Tuesday, April 18, 2006 10:28 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Need help using rtlcopystring function.

Screw Occam…I say that it’s a compiler bug**

Not to be an ass, but really…This has nothing to do with writing drivers

or even the DDK. I’m thinkin’ that should be able to figure this one out
in
less time than it would take to post to the group (Hint: It might have
something to do with a PSTRING not being a PCHAR)

Regards,

-scott

**Yes, I’m being sarcastic


Scott Noone
Software Engineer
OSR Open Systems Resources, Inc.
http://www.osronline.com

“Harsha Inamdar” wrote in message
news:xxxxx@ntdev…
Hi,

I am using rtlcopystring function to copy a string value to
pIrp->AssociatedIrp.SystemBuffer.

char str[20] = “USA”;
rtlcopystring((char*) pIrp->AssociatedIrp.SystemBuffer, str);

I have included ntddk.h in my program, but I am getting error as "
‘rtlcopystring’ undefined; assuming extern returning int".

Please advise.

Thanks,
Harsha

Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just
2¢/min
with Yahoo! Messenger with Voice.


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


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


New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.

PAR
Here.here! I.too.wasted.a.couple.of.years.coding.Occam
Here.here? It.might.have.been.great.language.for.kernel.code

Sorry folk, I just could not resist.

“Scott Noone” wrote in message news:xxxxx@ntdev…
> Screw Occam…I say that it’s a compiler bug**
>
> Not to be an ass, but really…This has nothing to do with writing drivers
> or even the DDK. I’m thinkin’ that should be able to figure this one out
> in less time than it would take to post to the group (Hint: It might have
> something to do with a PSTRING not being a PCHAR)
>
> Regards,
>
> -scott
>
>*Yes, I’m being sarcastic
>
> –
> Scott Noone
> Software Engineer
> OSR Open Systems Resources, Inc.
> http://www.osronline.com
>
> “Harsha Inamdar” wrote in message
> news:xxxxx@ntdev…
> Hi,
>
> I am using rtlcopystring function to copy a string value to
> pIrp->AssociatedIrp.SystemBuffer.
>
> char str[20] = “USA”;
> rtlcopystring((char
) pIrp->AssociatedIrp.SystemBuffer, str);
>
> I have included ntddk.h in my program, but I am getting error as "
> ‘rtlcopystring’ undefined; assuming extern returning int".
>
> Please advise.
>
> Thanks,
> Harsha
>
>
> Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just
> 2¢/min with Yahoo! Messenger with Voice.
>
>