[SDK][NDK][PSTYPES] Align the PROCESS_PRIORITY_CLASS structure during compile time (#2478)

CORE-16757

After doing investigations on the priority class structure alignment, it's been revealed that in Windows XP and Server 2003 this PROCESS_PRIORITY_CLASS structure is aligned as a 4-bytes of size hence NtQueryInformationProcess() probes the alignment of user mode arguments buffer output and buffer length with requirement of a ULONG.

As PROCESS_PRIORITY_CLASS was initially aligned as a 1-byte size because both BOOLEAN and UCHAR are just unsigned characters, the compiler may not align such structure and gracefully let the default alignment of such structure as is, 1-byte because an unsigned char has a size of 1 byte. Setting an align attribute to this structure fixes the problem of a potential datatype misalignment which caused GetPriorityClass() to not retrieve the process' priority class properly.
This commit is contained in:
Bișoc George 2020-03-28 19:17:10 +01:00 committed by GitHub
parent 2d36be4963
commit 7481bda679
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -902,7 +902,7 @@ typedef struct _PROCESS_SESSION_INFORMATION
#endif
typedef struct _PROCESS_PRIORITY_CLASS
typedef struct DECLSPEC_ALIGN(4) _PROCESS_PRIORITY_CLASS
{
BOOLEAN Foreground;
UCHAR PriorityClass;