wrong msvcrt.dll?

Hi everyone,
I’m compiling an executable with WDK . Which use printf_s function
,when running I’m told can’t find printf_s in msvcrt.dll , why? Should
I update a new version msvcrt.dll?
Thanks in advance

Which wdk? Which target os?

d

debt from my phone


From: yushang
Sent: 10/16/2011 8:43 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] wrong msvcrt.dll?

Hi everyone,
I’m compiling an executable with WDK . Which use printf_s function
,when running I’m told can’t find printf_s in msvcrt.dll , why? Should
I update a new version msvcrt.dll?
Thanks in advance


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

WDK 7600.16385.1and the target is XP

2011/10/17 Doron Holan :
> Which wdk? Which target os

XP doesn’t have the safe crt functions

d

debt from my phone


From: yushang
Sent: 10/16/2011 9:48 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] wrong msvcrt.dll?

WDK 7600.16385.1and the target is XP

2011/10/17 Doron Holan :
> Which wdk? Which target os


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

But why the linker can find it in msvcrt.lib? which is for XP.

2011/10/17 Doron Holan :
> XP doesn’t have the safe crt functions

I don’t think the wdk’s CRT contains the _s functions because it’s really old (and hence compatible). You’d need to link to one of the specific versions like msvcr100 to get the new functions.


Bruce Cran

On 16 Oct 2011, at 16:42, yushang wrote:

> Hi everyone,
> I’m compiling an executable with WDK . Which use printf_s function
> ,when running I’m told can’t find printf_s in msvcrt.dll , why? Should
> I update a new version msvcrt.dll?
> Thanks in advance
>
> —
> 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

OK but why don’t the the linker emit an error ? That is to say the
msvcrt.lib and msvcrt.dll don’t match , right ?

2011/10/17 Bruce Cran :
> I don’t think the wdk’s CRT contains the _s functions

“yushang” wrote in message news:xxxxx@ntdev…
> OK but why don’t the the linker emit an error ? That is to say the
> msvcrt.lib and msvcrt.dll don’t match , right ?
>
> 2011/10/17 Bruce Cran :
>> I don’t think the wdk’s CRT contains the _s functions
>

They could use the latest version of the lib that covers all historical
variants of the DLL.
To see what is available on the target system, use dependency viewer on the
specific DLL on the target.

– pa

Thanks pa , I saw it .

2011/10/17 Pavel A. :
> “yushang” wrote in message news:xxxxx@ntdev…
>>
>> OK but why don’t the the linker emit an error ? That is to say the
>> msvcrt.lib and msvcrt.dll don’t match , right ?
>>
>> 2011/10/17 Bruce Cran :
>>>
>>> I don’t think the wdk’s CRT contains the _s functions
>>
>
> They could use the latest version of the lib that covers all historical
> variants of the DLL.
> To see what is available on the target system, use dependency viewer on the
> specific DLL on the target.
>
> – pa
>
>
>
> —
> 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
>

> OK but why don’t the the linker emit an error ? That is to say the

msvcrt.lib and msvcrt.dll don’t match , right ?

> I don’t think the wdk’s CRT contains the _s functions

yushang,

The problem you are experiencing is common.

The version of the WDK you are using is based upon Visual Studio 8. The
CRT library in that version contains the safe functions (_s). As such,
when you do a build containing the safe functions, the linker will not
report any errors.

Windows XP comes with a much earlier version of the CRT that does not
support the safe functions. You can either remove the safe functions
from your code or you can install the Visual Studio 2008 run-time on the
target system. The later is the preferable option.

You can download the Visual Studio 2008 Redistributable package from
Microsoft at
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=29.
Then, you can install the package as part of your installation process.
This is what I have done in when necessary. (You can add the /q
parameter to the executable provided by Microsoft to perform the
installation silently.)

Mike

If you use the vs2008 crt you will have to wire the libs and include oaths manually to point to the right vs2008 versions

d

debt from my phone


From: Michael Burns
Sent: 10/16/2011 9:27 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] wrong msvcrt.dll?

OK but why don’t the the linker emit an error ? That is to say the
msvcrt.lib and msvcrt.dll don’t match , right ?

> I don’t think the wdk’s CRT contains the _s functions

yushang,

The problem you are experiencing is common.

The version of the WDK you are using is based upon Visual Studio 8. The
CRT library in that version contains the safe functions (_s). As such,
when you do a build containing the safe functions, the linker will not
report any errors.

Windows XP comes with a much earlier version of the CRT that does not
support the safe functions. You can either remove the safe functions
from your code or you can install the Visual Studio 2008 run-time on the
target system. The later is the preferable option.

You can download the Visual Studio 2008 Redistributable package from
Microsoft at
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=29.
Then, you can install the package as part of your installation process.
This is what I have done in when necessary. (You can add the /q
parameter to the executable provided by Microsoft to perform the
installation silently.)

Mike


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

I’ve done this and installed the package , but the problem still
exists . I doubt the redistributable had update the msvcrt.dll , did
it?

2011/10/17 Michael Burns :
> You can download the Visual Studio 2008 Redistributable package from
> Microsoft

On 17 Oct 2011, at 08:03, yushang wrote:

I’ve done this and installed the package , but the problem still
exists . I doubt the redistributable had update the msvcrt.dll , did
it?

The msvcrt.dll in Windows XP doesn’t contain the _s functions - you’ll need to link against the version-specific DLL from Visual Studio 2008/2010/etc. - it’ll be named something like msvcr90.dll, msvcr100.dll etc.


Bruce Cran

I see . Did you mean I must link with msvcrt.lib provided by VS2008
not the WDK one?

2011/10/17 Bruce Cran :
> you’ll need to link against the version-specific DLL from Visual Studio 2008/2010/etc

On 17-Oct-2011 09:03, yushang wrote:

I’ve done this and installed the package , but the problem still
exists . I doubt the redistributable had update the msvcrt.dll , did
it?

No, VC++ redistributable runtime does not touch msvcrt.dll (at least
should not). VC++ has its own set of DLLs.
The msvcrt.dll of XP is similar to runtime of VC++ 6.
If you use it, refer to documentation of VC6 (or 2003?)
Besides of _s functions, many things have been added since then to VC++,
such as extra options in fopen() for unicode, extra formats in printf
(%llx) and so on. This obviously won’t work as well with the old dll.

– pa

> Besides of _s functions, many things have been added since then to VC++,

_s will probably fail, but WDK’s StringCchXxx do work with XP’s and even w2k’s msvcrt, at least if you use w2k build env of 6001.18002.

extra formats in printf (%llx)

Oh yes. Not in XP’s msvcrt. More so, this stuff is UNIX-compatible, unlike %I64x.


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

>I see . Did you mean I must link with msvcrt.lib provided by VS2008

Try replacing printf_s with StringCchPrintf.


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

StringCchXxx works on win2k and XP because it is a self contained static lib, not a crt import via (nt)strsafe.lib. Funny enough, it is a static lib vs import because it relies on _vsnprintf which was added as an export in the XP or Vista timeframe

d

debt from my phone


From: Maxim S. Shatskih
Sent: 10/17/2011 12:19 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] wrong msvcrt.dll?

Besides of _s functions, many things have been added since then to VC++,

_s will probably fail, but WDK’s StringCchXxx do work with XP’s and even w2k’s msvcrt, at least if you use w2k build env of 6001.18002.

extra formats in printf (%llx)

Oh yes. Not in XP’s msvcrt. More so, this stuff is UNIX-compatible, unlike %I64x.


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


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

The root cause is the WDK msvcrt.lib and XP msvcrt.dll do not match ,
can I think so ? I know WDK is oriented for driver development , it
may provide limited CRT functionality , but it should not confuse me ,
right ? And where can I get the matching msvcrt.dll ? Many thanks.

They match, are you explicitly putting the lib in your sources file or using _NT_TARGET_VERSION and letting the build system add the right lib automatically

d

debt from my phone


From: yushang
Sent: 10/18/2011 5:47 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] wrong msvcrt.dll?

The root cause is the WDK msvcrt.lib and XP msvcrt.dll do not match ,
can I think so ? I know WDK is oriented for driver development , it
may provide limited CRT functionality , but it should not confuse me ,
right ? And where can I get the matching msvcrt.dll ? Many thanks.


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