mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 12:29:56 +00:00
[RTL]
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:
parent
c66702eae9
commit
ad26240c79
5 changed files with 63 additions and 30 deletions
|
@ -44,3 +44,14 @@ RtlpFreeMemory(PVOID Mem,
|
||||||
{
|
{
|
||||||
MmHeapFree(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;
|
||||||
|
}
|
||||||
|
|
|
@ -576,4 +576,24 @@ RtlComputeImportTableHash(IN HANDLE FileHandle,
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
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 */
|
/* EOF */
|
||||||
|
|
|
@ -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)))
|
#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
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlpGetStackLimits(PULONG_PTR LowLimit,
|
RtlpGetStackLimits(PULONG_PTR LowLimit,
|
||||||
|
|
|
@ -1735,7 +1735,6 @@ RtlLargeIntegerToChar(
|
||||||
IN OUT PCHAR String)
|
IN OUT PCHAR String)
|
||||||
{
|
{
|
||||||
ULONGLONG Val = Value->QuadPart;
|
ULONGLONG Val = Value->QuadPart;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
|
||||||
CHAR Buffer[65];
|
CHAR Buffer[65];
|
||||||
CHAR Digit;
|
CHAR Digit;
|
||||||
SIZE_T Len;
|
SIZE_T Len;
|
||||||
|
@ -1769,36 +1768,12 @@ RtlLargeIntegerToChar(
|
||||||
if (Len > Length)
|
if (Len > Length)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
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)
|
/* Copy the string to the target using SEH */
|
||||||
{
|
return RtlpSafeCopyMemory(String, Pos, Len);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -676,5 +676,25 @@ done:
|
||||||
return STATUS_SUCCESS;
|
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 */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue