https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7481bda679eccdf1eba3666e500074dcb966e748

commit 7481bda679eccdf1eba3666e500074dcb966e748
Author:     Bișoc George <[email protected]>
AuthorDate: Sat Mar 28 19:17:10 2020 +0100
Commit:     GitHub <[email protected]>
CommitDate: Sat Mar 28 19:17:10 2020 +0100

    [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.
---
 sdk/include/ndk/pstypes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sdk/include/ndk/pstypes.h b/sdk/include/ndk/pstypes.h
index 543afcb618d..219b880368f 100644
--- a/sdk/include/ndk/pstypes.h
+++ b/sdk/include/ndk/pstypes.h
@@ -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;

Reply via email to