Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: xmllmx Newsgroups: comp.os.ms-windows.programmer.nt.kernel-mode Subject: Re: Is memcmp an unsolved symbol in NT kernel driver even if compiled with /Oi? Date: Sat, 26 May 2012 13:37:11 -0700 (PDT) Organization: http://groups.google.com Lines: 56 Message-ID: <08994d02-b9c9-4bae-ad94-dbc0e99a2997@googlegroups.com> References: <44201cc4-e49a-49fe-9335-5f642e911afd@googlegroups.com> <%Uawr.38069$9H3.6723@newsfe06.iad> NNTP-Posting-Host: 65.49.68.176 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1338069730 15845 127.0.0.1 (26 May 2012 22:02:10 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 26 May 2012 22:02:10 +0000 (UTC) In-Reply-To: <%Uawr.38069$9H3.6723@newsfe06.iad> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=65.49.68.176; posting-account=yQZ4lQoAAABfGlSyiQO-EUykAywJx2gc User-Agent: G2/1.0 X-Received-Bytes: 2451 Xref: csiph.com comp.os.ms-windows.programmer.nt.kernel-mode:27 On Sunday, May 27, 2012 4:19:07 AM UTC+8, Don Burn wrote: > Use RtlCompareMemory not memcmp. > > > Don Burn > Windows Filesystem and Driver Consulting > Website: http://www.windrvr.com > Blog: http://msmvps.com/blogs/WinDrvr > > > > > "xmllmx" wrote in message > news:44201cc4-e49a-49fe-9335-5f642e911afd@googlegroups.com: > > > Code Sample 1: > > > > #include > > > > NTSTATUS DriverEntry(PDRIVER_OBJECT param1, PUNICODE_STRING param2) > > { > > char s1[] = "Hello"; > > char s2[] = "World"; > > > > int n = memcmp(s1, s2, 5); > > > > return 0; > > } > > > > WDK compiler reports: error LNK2019: unsolved extern symbol _memcmp referenced in function _DriverEntry@8 > > > > However, if I modify a bit the code as follows, then the compiler will accept it. > > > > Code Sample 2: > > > > #include > > > > NTSTATUS DriverEntry(PDRIVER_OBJECT param1, PUNICODE_STRING param2) > > { > > char s1[] = "Hello"; > > char s2[] = "World"; > > > > memcmp(s1, s2, 5); > > > > return 0; > > } > > > > Why? > > > > Thanks in advance! Dear Don, I know RtlCompareMemory is a better choice. But I just wonder its cause. I have a third-party source code which uses a lot of memcmp, so I have to solve it. Thank you very much.