From 477e56e2949942fd9456b791b5303b100f3146dd Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Tue, 20 Feb 2024 16:08:10 +0100 Subject: [PATCH] Move RtlFillMemory() routine to ntosdrv driver --- drivers/ntosdrv/CMakeLists.txt | 3 ++- drivers/ntosdrv/ntosdrv.spec | 1 + drivers/ntosdrv/rtl.c | 36 ++++++++++++++++++++++++++++++++++ sdk/xtdk/rtlfuncs.h | 7 ------- xtoskrnl/rtl/memory.c | 26 ------------------------ xtoskrnl/xtoskrnl.spec | 1 - 6 files changed, 39 insertions(+), 35 deletions(-) create mode 100644 drivers/ntosdrv/rtl.c diff --git a/drivers/ntosdrv/CMakeLists.txt b/drivers/ntosdrv/CMakeLists.txt index c243389..6552909 100644 --- a/drivers/ntosdrv/CMakeLists.txt +++ b/drivers/ntosdrv/CMakeLists.txt @@ -7,7 +7,8 @@ include_directories( # Specify list of source code files list(APPEND NTOSDRV_SOURCE - ${NTOSDRV_SOURCE_DIR}/ntosdrv.c) + ${NTOSDRV_SOURCE_DIR}/ntosdrv.c + ${NTOSDRV_SOURCE_DIR}/rtl.c) # Set module definition SPEC file set_specfile(ntosdrv.spec ntosdrv.sys) diff --git a/drivers/ntosdrv/ntosdrv.spec b/drivers/ntosdrv/ntosdrv.spec index fb4aaa7..8ce35fe 100644 --- a/drivers/ntosdrv/ntosdrv.spec +++ b/drivers/ntosdrv/ntosdrv.spec @@ -1,2 +1,3 @@ # NT compatibilty layer exports @ fastcall ExRundownCompleted(ptr) ExCompleteRundownProtection +@ stdcall RtlFillMemory(ptr long long) diff --git a/drivers/ntosdrv/rtl.c b/drivers/ntosdrv/rtl.c new file mode 100644 index 0000000..ab33304 --- /dev/null +++ b/drivers/ntosdrv/rtl.c @@ -0,0 +1,36 @@ +/** + * PROJECT: ExectOS + * COPYRIGHT: See COPYING.md in the top level directory + * FILE: drivers/ntosdrv/rtl.c + * DESCRIPTION: NTOS compatibility driver runtime library + * DEVELOPERS: Rafal Kupiec + */ + +#include + + +/** + * This routine fills a section of memory with a specified byte. + * + * @param Destination + * Supplies a pointer to the buffer to fill. + * + * @param Length + * Specifies a number of bytes to store in memory. + * + * @param Byte + * Supplies a pattern to fill memory. + * + * @return This routine does not return any value. + * + * @since NT 3.5 + */ +XTAPI +VOID +RtlFillMemory(OUT PVOID Destination, + IN SIZE_T Length, + IN UCHAR Byte) +{ + /* Fill the buffer with specified byte */ + RtlSetMemory(Destination, Byte, Length); +} diff --git a/sdk/xtdk/rtlfuncs.h b/sdk/xtdk/rtlfuncs.h index 6d14684..1e90597 100644 --- a/sdk/xtdk/rtlfuncs.h +++ b/sdk/xtdk/rtlfuncs.h @@ -116,13 +116,6 @@ RtlDivideLargeInteger(IN LARGE_INTEGER Dividend, IN ULONG Divisor, OUT PULONG Remainder); - -XTAPI -VOID -RtlFillMemory(OUT PVOID Destination, - IN SIZE_T Length, - IN UCHAR Value); - XTAPI XTSTATUS RtlFormatWideString(IN PRTL_PRINT_CONTEXT Context, diff --git a/xtoskrnl/rtl/memory.c b/xtoskrnl/rtl/memory.c index dbeeed1..3d59f01 100644 --- a/xtoskrnl/rtl/memory.c +++ b/xtoskrnl/rtl/memory.c @@ -87,32 +87,6 @@ RtlCopyMemory(OUT PVOID Destination, } } -/** - * This routine fills a section of memory with a specified byte. - * - * @param Destination - * Supplies a pointer to the buffer to fill. - * - * @param Length - * Specifies a number of bytes to store in memory. - * - * @param Byte - * Supplies a pattern to fill memory. - * - * @return This routine does not return any value. - * - * @since NT 3.5 - */ -XTAPI -VOID -RtlFillMemory(OUT PVOID Destination, - IN SIZE_T Length, - IN UCHAR Byte) -{ - /* Fill the buffer with specified byte */ - RtlSetMemory(Destination, Byte, Length); -} - /** * This routine copies a block of memory either forward of backward, depeding * if source and destination buffers overlap or not. diff --git a/xtoskrnl/xtoskrnl.spec b/xtoskrnl/xtoskrnl.spec index d893bb7..7a15360 100644 --- a/xtoskrnl/xtoskrnl.spec +++ b/xtoskrnl/xtoskrnl.spec @@ -42,7 +42,6 @@ @ stdcall RtlConvertToLargeIntegerUnsigned32(long) @ stdcall RtlCopyMemory(ptr ptr long) @ stdcall RtlDivideLargeInteger(long long long ptr) -@ stdcall RtlFillMemory(ptr long long) @ stdcall RtlMoveMemory(ptr ptr long) @ stdcall RtlMultiplyLargeInteger(long long long) @ stdcall RtlReadRegisterByte(ptr)