diff --git a/sdk/xtdk/rtlfuncs.h b/sdk/xtdk/rtlfuncs.h index 1e90597..bb1e634 100644 --- a/sdk/xtdk/rtlfuncs.h +++ b/sdk/xtdk/rtlfuncs.h @@ -110,6 +110,18 @@ RtlCopyMemory(OUT PVOID Destination, IN PCVOID Source, IN SIZE_T Length); +XTAPI +VOID +RtlCopyString(IN PCHAR Destination, + IN PCCHAR Source, + IN ULONG Length); + +XTAPI +VOID +RtlCopyWideString(IN PWCHAR Destination, + IN CONST PWCHAR Source, + IN ULONG Length); + XTAPI LARGE_INTEGER RtlDivideLargeInteger(IN LARGE_INTEGER Dividend, diff --git a/xtoskrnl/rtl/string.c b/xtoskrnl/rtl/string.c index d65d641..0c62edf 100644 --- a/xtoskrnl/rtl/string.c +++ b/xtoskrnl/rtl/string.c @@ -187,6 +187,48 @@ RtlConcatenateString(OUT PCHAR Destination, return DestString; } +/** + * Copies a string from a buffer into another buffer, ensuring that the destination string is NULL-terminated. + * + * @param Destination + * Supplies a pointer to the destination buffer. + * + * @param Source + * Supplies a pointer to the source buffer. + * + * @param Length + * Supplies the length of the string to copy. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTAPI +VOID +RtlCopyString(IN PCHAR Destination, + IN PCCHAR Source, + IN ULONG Length) +{ + ULONG Index; + + /* Copy characters */ + for(Index = 0; Index < Length; Index++) + { + /* Copy source character */ + Destination[Index] = Source[Index]; + + /* Check if NULL terminated character found */ + if(Source[Index] == '\0') + { + /* End of source string reached */ + break; + } + } + + /* Make sure the destination string is terminated properly */ + Destination[Index] = '\0'; +} + /** * Reverses a characters order in a string. It modifies the original, input variable. * diff --git a/xtoskrnl/rtl/widestr.c b/xtoskrnl/rtl/widestr.c index 0732c15..ff8da57 100644 --- a/xtoskrnl/rtl/widestr.c +++ b/xtoskrnl/rtl/widestr.c @@ -187,6 +187,49 @@ RtlConcatenateWideString(OUT PWCHAR Destination, return DestString; } +/** + * Copies a wide string from a buffer into another buffer, ensuring that the destination string is NULL-terminated. + * + * @param Destination + * Supplies a pointer to the destination buffer. + * + * @param Source + * Supplies a pointer to the source buffer. + * + * @param Length + * Supplies the length of the wide string to copy. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ + +XTAPI +VOID +RtlCopyWideString(IN PWCHAR Destination, + IN CONST PWCHAR Source, + IN ULONG Length) +{ + ULONG Index; + + /* Copy characters */ + for(Index = 0; Index < Length; Index++) + { + /* Copy source character */ + Destination[Index] = Source[Index]; + + /* Check if NULL terminated character found */ + if(Source[Index] == L'\0') + { + /* End of source string reached */ + break; + } + } + + /* Make sure the destination string is terminated properly */ + Destination[Index] = L'\0'; +} + /** * Formats a wide string according to the given printf-alike format string. * diff --git a/xtoskrnl/xtoskrnl.spec b/xtoskrnl/xtoskrnl.spec index 7a15360..fb4de45 100644 --- a/xtoskrnl/xtoskrnl.spec +++ b/xtoskrnl/xtoskrnl.spec @@ -41,6 +41,8 @@ @ stdcall RtlConvertToLargeInteger32(long) @ stdcall RtlConvertToLargeIntegerUnsigned32(long) @ stdcall RtlCopyMemory(ptr ptr long) +@ stdcall RtlCopyString(ptr ptr long) +@ stdcall RtlCopyWideString(ptr ptr long) @ stdcall RtlDivideLargeInteger(long long long ptr) @ stdcall RtlMoveMemory(ptr ptr long) @ stdcall RtlMultiplyLargeInteger(long long long)