From 7e3fbb3780cfbd7a16bb29463bfee75a0db6836a Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Sun, 22 Sep 2013 18:47:36 +0000 Subject: [PATCH] [NTOSKRNL]: Implement and export PsGetProcessSessionIdEx, and MmGetSessionIdEx. Dedicated to hbelusca. If you look at the diff (please don't), yes, this is seriously how it works in Windows. svn path=/trunk/; revision=60317 --- reactos/ntoskrnl/include/internal/mm.h | 6 ++++++ reactos/ntoskrnl/mm/ARM3/procsup.c | 15 +++++++++++++++ reactos/ntoskrnl/ntoskrnl.spec | 2 +- reactos/ntoskrnl/ps/process.c | 12 +++++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index 7e7f6dcd123..ad236fac27d 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -493,6 +493,12 @@ MmGetSessionId( IN PEPROCESS Process ); +ULONG +NTAPI +MmGetSessionIdEx( + IN PEPROCESS Process +); + /* marea.c *******************************************************************/ NTSTATUS diff --git a/reactos/ntoskrnl/mm/ARM3/procsup.c b/reactos/ntoskrnl/mm/ARM3/procsup.c index 9a0ae20da46..982fc5b63f3 100644 --- a/reactos/ntoskrnl/mm/ARM3/procsup.c +++ b/reactos/ntoskrnl/mm/ARM3/procsup.c @@ -1561,6 +1561,21 @@ MmGetSessionId(IN PEPROCESS Process) return SessionGlobal->SessionId; } +ULONG +NTAPI +MmGetSessionIdEx(IN PEPROCESS Process) +{ + PMM_SESSION_SPACE SessionGlobal; + + /* The session leader is always session zero */ + if (Process->Vm.Flags.SessionLeader == 1) return 0; + + /* Otherwise, get the session global, and read the session ID from it */ + SessionGlobal = (PMM_SESSION_SPACE)Process->Session; + if (!SessionGlobal) return -1; + return SessionGlobal->SessionId; +} + VOID NTAPI MiReleaseProcessReferenceToSessionDataPage(IN PMM_SESSION_SPACE SessionGlobal) diff --git a/reactos/ntoskrnl/ntoskrnl.spec b/reactos/ntoskrnl/ntoskrnl.spec index 085a22a12cb..f024e7fda2e 100644 --- a/reactos/ntoskrnl/ntoskrnl.spec +++ b/reactos/ntoskrnl/ntoskrnl.spec @@ -987,7 +987,7 @@ @ stdcall PsGetProcessSectionBaseAddress(ptr) @ stdcall PsGetProcessSecurityPort(ptr) @ stdcall PsGetProcessSessionId(ptr) -;PsGetProcessSessionIdEx +@ stdcall PsGetProcessSessionIdEx(ptr) @ stdcall PsGetProcessWin32Process(ptr) @ stdcall PsGetProcessWin32WindowStation(ptr) ;@ cdecl -arch=x86_64 PsGetProcessWow64Process() diff --git a/reactos/ntoskrnl/ps/process.c b/reactos/ntoskrnl/ps/process.c index 48e5054e616..bd9746bca12 100644 --- a/reactos/ntoskrnl/ps/process.c +++ b/reactos/ntoskrnl/ps/process.c @@ -1149,11 +1149,21 @@ PsGetProcessSecurityPort(PEPROCESS Process) */ ULONG NTAPI -PsGetProcessSessionId(PEPROCESS Process) +PsGetProcessSessionId(IN PEPROCESS Process) { return MmGetSessionId(Process); } +/* + * @implemented + */ +ULONG +NTAPI +PsGetProcessSessionIdEx(IN PEPROCESS Process) +{ + return MmGetSessionIdEx(Process); +} + /* * @implemented */