I’m curious: if you are about to overwrite the contents of the buffer with
RtlCopyMemory, why are you bothering to call RtlZeroMemory? If this makes a
difference, your code is erroneous. It means you are depending on a
NUL-terminated string (usually a mistake in the kernel, except for
RtlInitUnicodeString), and in any case, because FileName is a
UNICODE_STRING, it can have a string of FileName.MaximumLength, so if you
copy it to the space you just allocated, such a string would not have a NUL
at the end. So if you think that RtlCopyMemory/RtlMoveMemory makes a
difference in performance, you should eliminate a completely pointless
operation that sets-to-zero data that is about to be overwritten by content.
For that matter, why is your buffer not allocated as
FileName.Buffer = ExAllocatePoolWithTag(PagedPool,
FileName.MaximumLength + sizeof(UNICODE_STRING),
MAGIC_TAG);
Then initialize the UNICODE_STRING at the front of the storage to point to
the rest, and use Rtl functions to copy the UNICODE_STRING. I don’t see why
you are just copying the filename without dealing with either the NUL
character or using a reasonable structure such as UNICODE_STRING.
joe
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Pavel A.
Sent: Thursday, January 15, 2009 11:21 AM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] RtlCopyMemory RtlMoveMemory
xxxxx@gmail.com wrote:
Hi list,
I am working on a file system driver , it heavily uses buffer copy
operations. As of now we replaced RtlMoveMemory by RtlCopyMemory to improve
performance of the copy operation.
Is there any alternate to RtlCopyMemory API to fastly copy the buffer?
Here is the code snippet…
FileName.Buffer = ExAllocatePoolWithTag(
PagedPool,
FileName.MaximumLength,
MAGIC_TAG
);
RtlZeroMemory(FileName.Buffer, FileName.MaximumLength);
RtlCopyMemory(FileName.Buffer,
IrpSp->FileObject->FileName.Buffer, FileName.Length);
Any pointer to improve performance would be of help.
Rodney.
The following “improvement” could save you and your customers several days
(rather than few microseconds):
FileName.Buffer = ExAllocatePoolWithTag(
PagedPool,
FileName.MaximumLength,
MAGIC_TAG
);
if ( !FileName.Buffer )
{
// handle this
} else {
…your code …
}
Regards,
–pa
NTFSD is sponsored by OSR
For our schedule debugging and file system seminars (including our new fs
mini-filter seminar) visit:
http://www.osr.com/seminars
You are currently subscribed to ntfsd as: xxxxx@flounder.com To
unsubscribe send a blank email to xxxxx@lists.osr.com
–
This message has been scanned for viruses and dangerous content by
MailScanner, and is believed to be clean.