Implement RtlpSafeCopyMemory, which uses SEH to copy the memory (not in freeldr)
Make RtlLargeIntegerToChar use RtlpSafeCopyMemory to copy the string to the target buffer.
CORE-3767 #resolve

svn path=/trunk/; revision=57295
This commit is contained in:
Timo Kreuzer 2012-09-14 09:56:23 +00:00
parent c66702eae9
commit ad26240c79
5 changed files with 63 additions and 30 deletions

View file

@ -44,3 +44,14 @@ RtlpFreeMemory(PVOID Mem,
{
MmHeapFree(Mem);
}
NTSTATUS
NTAPI
RtlpSafeCopyMemory(
_Out_writes_bytes_all_(Length) VOID UNALIGNED *Destination,
_In_reads_bytes_(Length) CONST VOID UNALIGNED *Source,
_In_ SIZE_T Length)
{
RtlCopyMemory(Destination, Source, Length);
return STATUS_SUCCESS;
}

View file

@ -576,4 +576,24 @@ RtlComputeImportTableHash(IN HANDLE FileHandle,
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
RtlpSafeCopyMemory(
_Out_writes_bytes_all_(Length) VOID UNALIGNED *Destination,
_In_reads_bytes_(Length) CONST VOID UNALIGNED *Source,
_In_ SIZE_T Length)
{
_SEH2_TRY
{
RtlCopyMemory(Destination, Source, Length);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
return STATUS_SUCCESS;
}
/* EOF */

View file

@ -34,6 +34,13 @@ extern VOID FASTCALL CHECK_PAGED_CODE_RTL(char *file, int line);
#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m)))
NTSTATUS
NTAPI
RtlpSafeCopyMemory(
_Out_writes_bytes_all_(Length) VOID UNALIGNED *Destination,
_In_reads_bytes_(Length) CONST VOID UNALIGNED *Source,
_In_ SIZE_T Length);
VOID
NTAPI
RtlpGetStackLimits(PULONG_PTR LowLimit,

View file

@ -1735,7 +1735,6 @@ RtlLargeIntegerToChar(
IN OUT PCHAR String)
{
ULONGLONG Val = Value->QuadPart;
NTSTATUS Status = STATUS_SUCCESS;
CHAR Buffer[65];
CHAR Digit;
SIZE_T Len;
@ -1769,36 +1768,12 @@ RtlLargeIntegerToChar(
if (Len > Length)
return STATUS_BUFFER_OVERFLOW;
#if 1 /* It needs to be removed, when will probably use SEH in rtl */
/* If possible, add the 0 termination */
if (Len < Length)
Len += 1;
if (String == NULL)
{
return STATUS_ACCESS_VIOLATION;
}
#endif
#if 0
_SEH2_TRY
{
#endif
if (Len == Length)
RtlCopyMemory(String, Pos, Len);
else
RtlCopyMemory(String, Pos, Len + 1);
#if 0
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
/* Get the error code */
Status = _SEH2_GetExceptionCode();
}
_SEH2_END;
#endif
return Status;
/* Copy the string to the target using SEH */
return RtlpSafeCopyMemory(String, Pos, Len);
}
/*

View file

@ -676,5 +676,25 @@ done:
return STATUS_SUCCESS;
}
NTSTATUS
NTAPI
RtlpSafeCopyMemory(
_Out_writes_bytes_all_(Length) VOID UNALIGNED *Destination,
_In_reads_bytes_(Length) CONST VOID UNALIGNED *Source,
_In_ SIZE_T Length)
{
_SEH2_TRY
{
RtlCopyMemory(Destination, Source, Length);
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
_SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
return STATUS_SUCCESS;
}
/* EOF */