https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2791ecd303b72fe74414c651031522b770377b80

commit 2791ecd303b72fe74414c651031522b770377b80
Author:     George Bișoc <[email protected]>
AuthorDate: Sun Jun 20 15:46:58 2021 +0200
Commit:     George Bișoc <[email protected]>
CommitDate: Fri Jun 25 10:33:18 2021 +0200

    [NTOS:PS] Fix several issues within info classes in AMD64 build
    
    ProcessUserModeIOPL, ProcessWow64Information and ThreadZeroTlsCell classes 
fail on AMD64 build because of wrong IQS values assigned to them. Also 
explicitly tell the compiler that ProcessUserModeIOPL is strictly for x86 as 
user mode I/O privilege level is 32-bit stuff.
    In addition to that, implement IQS_NO_TYPE_LENGTH macro which it'll be used 
for classes such as ProcessUserModeIOPL where type length is not required and 
that it should be 0. With that said, we indirectly fix a size length mismatch 
issue with ProcessUserModeIOPL on 32-bit of ReactOS as well.
---
 ntoskrnl/include/internal/icif.h |  3 +++
 ntoskrnl/include/internal/ps_i.h | 13 ++++++++-----
 ntoskrnl/ps/query.c              |  6 +++---
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/ntoskrnl/include/internal/icif.h b/ntoskrnl/include/internal/icif.h
index 6eb4a3d5f87..e73ad9e1b2c 100644
--- a/ntoskrnl/include/internal/icif.h
+++ b/ntoskrnl/include/internal/icif.h
@@ -37,5 +37,8 @@ typedef struct _INFORMATION_CLASS_INFO
 #define IQS(TypeQuery, AlignmentQuery, TypeSet, AlignmentSet, Flags) \
   { sizeof(TypeQuery), sizeof(AlignmentQuery), sizeof(TypeSet), 
sizeof(AlignmentSet), Flags }
 
+#define IQS_NO_TYPE_LENGTH(Alignment, Flags) \
+  { 0, sizeof(Alignment), 0, sizeof(Alignment), Flags }
+
 #define IQS_NONE \
   { 0, sizeof(CHAR), 0, sizeof(CHAR), ICIF_NONE }
diff --git a/ntoskrnl/include/internal/ps_i.h b/ntoskrnl/include/internal/ps_i.h
index adec4cb8275..3e54c27b636 100644
--- a/ntoskrnl/include/internal/ps_i.h
+++ b/ntoskrnl/include/internal/ps_i.h
@@ -142,13 +142,16 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
         ICIF_QUERY | ICIF_SET | ICIF_SET_SIZE_VARIABLE
     ),
 
-    /* ProcessUserModeIOPL */
-    IQS_SAME
+    /* ProcessUserModeIOPL is only implemented in x86 */
+#if defined (_X86_)
+    IQS_NO_TYPE_LENGTH
     (
-        UCHAR,
         ULONG,
         ICIF_SET
     ),
+#else
+    IQS_NONE,
+#endif
 
     /* ProcessEnableAlignmentFaultFixup */
     IQS
@@ -233,7 +236,7 @@ static const INFORMATION_CLASS_INFO PsProcessInfoClass[] =
     /* ProcessWow64Information */
     IQS_SAME
     (
-        ULONG,
+        ULONG_PTR,
         ULONG,
         ICIF_QUERY
     ),
@@ -443,7 +446,7 @@ static const INFORMATION_CLASS_INFO PsThreadInfoClass[] =
     /* ThreadZeroTlsCell */
     IQS_SAME
     (
-        ULONG_PTR,
+        ULONG,
         ULONG,
         ICIF_SET
     ),
diff --git a/ntoskrnl/ps/query.c b/ntoskrnl/ps/query.c
index 5c28b03d068..7211a63e964 100644
--- a/ntoskrnl/ps/query.c
+++ b/ntoskrnl/ps/query.c
@@ -1172,7 +1172,7 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
         case ProcessWx86Information:
 
             /* Check buffer length */
-            if (ProcessInformationLength != sizeof(HANDLE))
+            if (ProcessInformationLength != sizeof(ULONG))
             {
                 Status = STATUS_INFO_LENGTH_MISMATCH;
                 break;
@@ -2439,7 +2439,7 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
         case ThreadZeroTlsCell:
 
             /* Check buffer length */
-            if (ThreadInformationLength != sizeof(ULONG_PTR))
+            if (ThreadInformationLength != sizeof(ULONG))
             {
                 Status = STATUS_INFO_LENGTH_MISMATCH;
                 break;
@@ -2449,7 +2449,7 @@ NtSetInformationThread(IN HANDLE ThreadHandle,
             _SEH2_TRY
             {
                 /* Get the priority */
-                TlsIndex = *(PULONG_PTR)ThreadInformation;
+                TlsIndex = *(PULONG)ThreadInformation;
             }
             _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
             {

Reply via email to