Problem with wcscpy

Hello all,

At one point in my driver I need to copy a wchar from one variable to another so I have been using wcscpy. While in checked build mode this works although it gives me a warning saying that it is found in dontuse.h as a security concern. When I switched to trying the free build it treated this warning as an error and did not build. So I switched from using wcscpy to wcscpy_s and now I am getting:

error LNK2019: unresolved external symbol _wcscpy_s referenced in function “long __stdcall CreateConnection(struct _USER_GLOBAL_INFO *,struct _CONNECT_IN*)” (?CreateConnection@@YGJPAU_USER_GLOBAL_INFO@@PAU_CONNECT_IN@@@Z)

So now I am unsure what to do, wcscpy builds fine in checked mode but won’t build in release mode, but the correct function wcscpy_s won’t build in either mode.

Here is the code so you can see I am using wcscpy_s correctly:

//BEFORE THE CHANGE
wcscpy(pEntry->Disk0BaseAddress, PConnectInfo->Disk0Path);
//AFTER THE CHANGE
wcscpy_s(pEntry->Disk0BaseAddress, 256, PConnectInfo->Disk0Path);

Thanks for your help in advance. I will continue to work in the checked build until this problem is resolved.

Daniel

Try linking against libcntpr.lib. instead, you might just want to use RtlStringCchCopy or RtlStringCbCopy if you are already going to the trouble to change the call to pass the length

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of dducharme@my.uri.edu
Sent: Monday, April 04, 2011 3:27 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Problem with wcscpy

Hello all,

At one point in my driver I need to copy a wchar from one variable to another so I have been using wcscpy. While in checked build mode this works although it gives me a warning saying that it is found in dontuse.h as a security concern. When I switched to trying the free build it treated this warning as an error and did not build. So I switched from using wcscpy to wcscpy_s and now I am getting:

error LNK2019: unresolved external symbol _wcscpy_s referenced in function “long __stdcall CreateConnection(struct _USER_GLOBAL_INFO *,struct _CONNECT_IN*)” (?CreateConnection@@YGJPAU_USER_GLOBAL_INFO@@PAU_CONNECT_IN@@@Z)

So now I am unsure what to do, wcscpy builds fine in checked mode but won’t build in release mode, but the correct function wcscpy_s won’t build in either mode.

Here is the code so you can see I am using wcscpy_s correctly:

//BEFORE THE CHANGE
wcscpy(pEntry->Disk0BaseAddress, PConnectInfo->Disk0Path); //AFTER THE CHANGE wcscpy_s(pEntry->Disk0BaseAddress, 256, PConnectInfo->Disk0Path);

Thanks for your help in advance. I will continue to work in the checked build until this problem is resolved.

Daniel


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

RtlStringCchCopy or RtlStringCbCopy are the functions.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntdev…
> Hello all,
>
> At one point in my driver I need to copy a wchar from one variable to another so I have been using wcscpy. While in checked build mode this works although it gives me a warning saying that it is found in dontuse.h as a security concern. When I switched to trying the free build it treated this warning as an error and did not build. So I switched from using wcscpy to wcscpy_s and now I am getting:
>
> error LNK2019: unresolved external symbol _wcscpy_s referenced in function “long __stdcall CreateConnection(struct _USER_GLOBAL_INFO ,struct _CONNECT_IN)” (?CreateConnection@@YGJPAU_USER_GLOBAL_INFO@@PAU_CONNECT_IN@@@Z)
>
> So now I am unsure what to do, wcscpy builds fine in checked mode but won’t build in release mode, but the correct function wcscpy_s won’t build in either mode.
>
> Here is the code so you can see I am using wcscpy_s correctly:
>
> //BEFORE THE CHANGE
> wcscpy(pEntry->Disk0BaseAddress, PConnectInfo->Disk0Path);
> //AFTER THE CHANGE
> wcscpy_s(pEntry->Disk0BaseAddress, 256, PConnectInfo->Disk0Path);
>
> Thanks for your help in advance. I will continue to work in the checked build until this problem is resolved.
>
> Daniel
>