From f4fdc957c5c06fb938d9a8cf6e74a2d7d36f0ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 26 Jan 2020 18:41:03 +0100 Subject: [PATCH] [FREELDR] Use RTL copy/zero-memory helper functions. --- boot/freeldr/freeldr/lib/fs/ext2.c | 2 +- boot/freeldr/freeldr/lib/fs/fat.c | 22 +++++++++++----------- boot/freeldr/freeldr/lib/fs/fs.c | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/boot/freeldr/freeldr/lib/fs/ext2.c b/boot/freeldr/freeldr/lib/fs/ext2.c index 6ab00f3d1ab..65fae203e30 100644 --- a/boot/freeldr/freeldr/lib/fs/ext2.c +++ b/boot/freeldr/freeldr/lib/fs/ext2.c @@ -872,7 +872,7 @@ BOOLEAN Ext2ReadPartialBlock(PEXT2_VOLUME_INFO Volume, ULONG BlockNumber, ULONG return FALSE; } - memcpy(Buffer, ((PUCHAR)TempBuffer + StartingOffset), Length); + RtlCopyMemory(Buffer, ((PUCHAR)TempBuffer + StartingOffset), Length); FrLdrTempFree(TempBuffer, TAG_EXT_BUFFER); diff --git a/boot/freeldr/freeldr/lib/fs/fat.c b/boot/freeldr/freeldr/lib/fs/fat.c index 4c3358b9f2b..af0bcb1e7fd 100644 --- a/boot/freeldr/freeldr/lib/fs/fat.c +++ b/boot/freeldr/freeldr/lib/fs/fat.c @@ -519,8 +519,8 @@ BOOLEAN FatSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID Directory TRACE("FatSearchDirectoryBufferForFile() DirectoryBuffer = 0x%x EntryCount = %d FileName = %s\n", DirectoryBuffer, EntryCount, FileName); - memset(ShortNameBuffer, 0, 13 * sizeof(CHAR)); - memset(LfnNameBuffer, 0, 261 * sizeof(CHAR)); + RtlZeroMemory(ShortNameBuffer, 13 * sizeof(CHAR)); + RtlZeroMemory(LfnNameBuffer, 261 * sizeof(CHAR)); for (CurrentEntry=0; CurrentEntryFileName[0] == '\xE5') { - memset(ShortNameBuffer, 0, 13 * sizeof(CHAR)); - memset(LfnNameBuffer, 0, 261 * sizeof(CHAR)); + RtlZeroMemory(ShortNameBuffer, 13 * sizeof(CHAR)); + RtlZeroMemory(LfnNameBuffer, 261 * sizeof(CHAR)); continue; } @@ -642,8 +642,8 @@ BOOLEAN FatSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID Directory // if (DirEntry->Attr & ATTR_VOLUMENAME) { - memset(ShortNameBuffer, 0, 13 * sizeof(UCHAR)); - memset(LfnNameBuffer, 0, 261 * sizeof(UCHAR)); + RtlZeroMemory(ShortNameBuffer, 13 * sizeof(UCHAR)); + RtlZeroMemory(LfnNameBuffer, 261 * sizeof(UCHAR)); continue; } @@ -700,8 +700,8 @@ BOOLEAN FatSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID Directory // // Nope, no match - zero buffers and continue looking // - memset(ShortNameBuffer, 0, 13 * sizeof(UCHAR)); - memset(LfnNameBuffer, 0, 261 * sizeof(UCHAR)); + RtlZeroMemory(ShortNameBuffer, 13 * sizeof(UCHAR)); + RtlZeroMemory(LfnNameBuffer, 261 * sizeof(UCHAR)); continue; } @@ -783,7 +783,7 @@ ARC_STATUS FatLookupFile(PFAT_VOLUME_INFO Volume, PCSTR FileName, PFAT_FILE_INFO TRACE("FatLookupFile() FileName = %s\n", FileName); - memset(FatFileInfoPointer, 0, sizeof(FAT_FILE_INFO)); + RtlZeroMemory(FatFileInfoPointer, sizeof(FAT_FILE_INFO)); // // Figure out how many sub-directories we are nested in @@ -852,7 +852,7 @@ ARC_STATUS FatLookupFile(PFAT_VOLUME_INFO Volume, PCSTR FileName, PFAT_FILE_INFO } } - memcpy(FatFileInfoPointer, &FatFileInfo, sizeof(FAT_FILE_INFO)); + RtlCopyMemory(FatFileInfoPointer, &FatFileInfo, sizeof(FAT_FILE_INFO)); return ESUCCESS; } @@ -1178,7 +1178,7 @@ BOOLEAN FatReadPartialCluster(PFAT_VOLUME_INFO Volume, ULONG ClusterNumber, ULON if (FatReadVolumeSectors(Volume, ClusterStartSector + SectorOffset, SectorCount, ReadBuffer)) { - memcpy(Buffer, ReadBuffer + StartingOffset, Length); + RtlCopyMemory(Buffer, ReadBuffer + StartingOffset, Length); Success = TRUE; } diff --git a/boot/freeldr/freeldr/lib/fs/fs.c b/boot/freeldr/freeldr/lib/fs/fs.c index 9aa7ca1da65..0b44e500694 100644 --- a/boot/freeldr/freeldr/lib/fs/fs.c +++ b/boot/freeldr/freeldr/lib/fs/fs.c @@ -394,7 +394,7 @@ VOID FsRegisterDevice(CHAR* Prefix, const DEVVTBL* FuncTable) pNewEntry->FuncTable = FuncTable; pNewEntry->ReferenceCount = 0; pNewEntry->Prefix = (CHAR*)(pNewEntry + 1); - memcpy(pNewEntry->Prefix, Prefix, Length); + RtlCopyMemory(pNewEntry->Prefix, Prefix, Length); InsertHeadList(&DeviceListHead, &pNewEntry->ListEntry); }