Implement RtlCopyString() and RtlCopyWideString() routines

This commit is contained in:
Rafal Kupiec 2024-02-20 16:25:16 +01:00
parent 015faa53a0
commit 83a976dd3a
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
4 changed files with 99 additions and 0 deletions

View File

@ -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,

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

View File

@ -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)