mirror of
https://github.com/reactos/reactos.git
synced 2024-08-30 23:28:58 +00:00
![George Bișoc](/assets/img/avatar_default.png)
In addition to that, here are some stuff done in this commit whilst testing: - ICIF_QUERY_SIZE_VARIABLE and friends were badly misused, they should be used only when an information class whose information length size is dyanmic and not fixed. By removing such flags from erroneous classes, this fixes the STATUS_INFO_LENGTH_MISMATCH testcases. - Use CHAR instead of UCHAR for classes that do not need alignment probing, as every other class in the table do, for the sake of consistency. - ProcessEnableAlignmentFaultFixup uses BOOLEAN as type size, not CHAR. This fixes a testcase failure on ROS. - Check for information length size before proceeding further on querying the process' cookie information. - ProcessHandleTracing wants an alignment of a ULONG, not CHAR. - Move PROCESS_LDT_INFORMATION and PROCESS_LDT_SIZE outside of NTOS_MODE_USER macro case. This fixes a compilation issue when enabling the alignment probing. My mistake of having them inside NTOS_MODE_USER case, sorry. - On functions like NtQueryInformationThread and the Process equivalent, complete probing is not done at the beginning of the function, complete probing including if the buffer is writable alongside with datatype misalignment check that is. Instead such check is done on each information class case basis. With that said, we have to explicitly tell DefaultQueryInfoBufferCheck if we want a complete probing or not initially.
130 lines
3.8 KiB
C
130 lines
3.8 KiB
C
#pragma once
|
|
|
|
#include <reactos/probe.h>
|
|
|
|
static
|
|
__inline
|
|
NTSTATUS
|
|
DefaultSetInfoBufferCheck(ULONG Class,
|
|
const INFORMATION_CLASS_INFO *ClassList,
|
|
ULONG ClassListEntries,
|
|
PVOID Buffer,
|
|
ULONG BufferLength,
|
|
KPROCESSOR_MODE PreviousMode)
|
|
{
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
if (Class < ClassListEntries)
|
|
{
|
|
if (!(ClassList[Class].Flags & ICIF_SET))
|
|
{
|
|
Status = STATUS_INVALID_INFO_CLASS;
|
|
}
|
|
else if (ClassList[Class].RequiredSizeSET > 0 &&
|
|
BufferLength != ClassList[Class].RequiredSizeSET)
|
|
{
|
|
if (!(ClassList[Class].Flags & ICIF_SET_SIZE_VARIABLE))
|
|
{
|
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
|
}
|
|
}
|
|
|
|
if (NT_SUCCESS(Status))
|
|
{
|
|
if (PreviousMode != KernelMode)
|
|
{
|
|
_SEH2_TRY
|
|
{
|
|
ProbeForRead(Buffer,
|
|
BufferLength,
|
|
ClassList[Class].AlignmentSET);
|
|
}
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
{
|
|
Status = _SEH2_GetExceptionCode();
|
|
}
|
|
_SEH2_END;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
Status = STATUS_INVALID_INFO_CLASS;
|
|
|
|
return Status;
|
|
}
|
|
|
|
static
|
|
__inline
|
|
NTSTATUS
|
|
DefaultQueryInfoBufferCheck(ULONG Class,
|
|
const INFORMATION_CLASS_INFO *ClassList,
|
|
ULONG ClassListEntries,
|
|
PVOID Buffer,
|
|
ULONG BufferLength,
|
|
PULONG ReturnLength,
|
|
PULONG_PTR ReturnLengthPtr,
|
|
KPROCESSOR_MODE PreviousMode,
|
|
BOOLEAN CompleteProbing)
|
|
{
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
if (Class < ClassListEntries)
|
|
{
|
|
if (!(ClassList[Class].Flags & ICIF_QUERY))
|
|
{
|
|
Status = STATUS_INVALID_INFO_CLASS;
|
|
}
|
|
else if (ClassList[Class].RequiredSizeQUERY > 0 &&
|
|
BufferLength != ClassList[Class].RequiredSizeQUERY)
|
|
{
|
|
if (!(ClassList[Class].Flags & ICIF_QUERY_SIZE_VARIABLE))
|
|
{
|
|
Status = STATUS_INFO_LENGTH_MISMATCH;
|
|
}
|
|
}
|
|
|
|
if (NT_SUCCESS(Status))
|
|
{
|
|
if (PreviousMode != KernelMode)
|
|
{
|
|
_SEH2_TRY
|
|
{
|
|
if (Buffer != NULL)
|
|
{
|
|
if (!CompleteProbing)
|
|
{
|
|
ProbeForRead(Buffer,
|
|
BufferLength,
|
|
ClassList[Class].AlignmentQUERY);
|
|
}
|
|
else
|
|
{
|
|
ProbeForWrite(Buffer,
|
|
BufferLength,
|
|
ClassList[Class].AlignmentQUERY);
|
|
}
|
|
}
|
|
|
|
if (ReturnLength != NULL)
|
|
{
|
|
ProbeForWriteUlong(ReturnLength);
|
|
}
|
|
if (ReturnLengthPtr != NULL)
|
|
{
|
|
ProbeForWrite(ReturnLengthPtr, sizeof(ULONG_PTR), sizeof(ULONG_PTR));
|
|
}
|
|
}
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
{
|
|
Status = _SEH2_GetExceptionCode();
|
|
}
|
|
_SEH2_END;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
Status = STATUS_INVALID_INFO_CLASS;
|
|
|
|
return Status;
|
|
}
|