开发者

Does RTLCopyMemory work in Vista?

I've noticed that RTLMoveMemory s开发者_开发技巧eems to work just fine. But when I try to use RTLCopyMemory I get: "Can't find DLL entry point RtlCopyMemory in kernel32". Here is my declare:

Private Declare Sub CopyMem Lib "kernel32" Alias "RtlCopyMemory" ( _
    ByVal dest As Long, _
    ByVal source As Long, _
    ByVal bytLen As Long)


RtlCopyMemory is provided inline. It is defined in winnt.h as memcpy. This means that it's not included in a Win32 DLL, it's part of the C runtime library. You could try importing memcpy from c:\windows\system32\msvcrt.dll.


Why not just use RtlMoveMemory? It works just like RtlCopyMemory except that it handles overlapped memory in a different fashion.

Bruce McKinney pioneered the use of RtlMoveMemory over 10 years ago and it's been standard for VB6 memory copying ever since.


I know this is an old question, but I had the same problem, so I thought I could answer.

RtlCopyMemory in kernel32.dll should be an Export Forward into ntdll, but somehow guys at MS missed that one on x64 version of Vista (dunno how it's on x86) (see below).

You can try importing it directly from ntdll, if it's only for your needs.

EDIT: the method I mean is not exported, but with Symbols it's visible in ntdll as RtlCopyMemoryNonTemporal

EDIT2: Just to be sure I've checked some things, here's summary:

  • both RtlCopyMemory and RtlCopyMemoryNonTemporal are exported from ntdll.dll in x64 Vista's (plain, SP1, SP2)
  • there is export forward for RtlCopyMemory in kernel32.dll in x64 Vista's
  • there is unexported RtlCopyMemoryNonTemporal in ntdll.dll in x86 Vista's

So it all should be if you're writing x64 application.

P.S. I was wrong about x64 vs x86, because I was compiling x86 app, and running it on x64 (WOW mode), so it used 32-bit version of kernel32, ntdll and not the x64 one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜