Implement RtlCopyString() and RtlCopyWideString() routines

This commit is contained in:
2024-02-20 16:25:16 +01:00
parent 015faa53a0
commit 83a976dd3a
4 changed files with 99 additions and 0 deletions

View File

@@ -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.
*

View File

@@ -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.
*