Updated Ps* functions

Implemented PsGetVersion()

svn path=/trunk/; revision=1170
This commit is contained in:
Eric Kohl 2000-06-03 21:36:32 +00:00
parent 8123995861
commit abc6758e63
12 changed files with 177 additions and 78 deletions

View file

@ -1,3 +1,7 @@
/* $Id: psfuncs.h,v 1.7 2000/06/03 21:33:57 ekohl Exp $
*/
#ifndef _INCLUDE_DDK_PSFUNCS_H
#define _INCLUDE_DDK_PSFUNCS_H
PACCESS_TOKEN PsReferenceEffectiveToken(PETHREAD Thread,
PTOKEN_TYPE TokenType,
@ -7,8 +11,8 @@ PACCESS_TOKEN PsReferenceEffectiveToken(PETHREAD Thread,
NTSTATUS PsOpenTokenOfProcess(HANDLE ProcessHandle,
PACCESS_TOKEN* Token);
HANDLE PsGetCurrentProcessId(VOID);
HANDLE PsGetCurrentThreadId(VOID);
HANDLE STDCALL PsGetCurrentProcessId(VOID);
HANDLE STDCALL PsGetCurrentThreadId(VOID);
/*
* FUNCTION: Creates a thread which executes in kernel mode
@ -26,14 +30,14 @@ HANDLE PsGetCurrentThreadId(VOID);
* execution
* RETURNS: Success or failure status
*/
NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
HANDLE ProcessHandle,
PCLIENT_ID ClientId,
PKSTART_ROUTINE StartRoutine,
PVOID StartContext);
NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus);
NTSTATUS STDCALL PsCreateSystemThread(PHANDLE ThreadHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
HANDLE ProcessHandle,
PCLIENT_ID ClientId,
PKSTART_ROUTINE StartRoutine,
PVOID StartContext);
NTSTATUS STDCALL PsTerminateSystemThread(NTSTATUS ExitStatus);
ULONG PsSuspendThread(PETHREAD Thread,
PNTSTATUS WaitStatus,
UCHAR Alertable,
@ -42,17 +46,31 @@ ULONG PsResumeThread(PETHREAD Thread,
PNTSTATUS WaitStatus);
PETHREAD PsGetCurrentThread(VOID);
struct _EPROCESS* PsGetCurrentProcess(VOID);
PACCESS_TOKEN PsReferenceImpersonationToken(PETHREAD Thread,
PULONG Unknown1,
PULONG Unknown2,
SECURITY_IMPERSONATION_LEVEL*
Level);
PACCESS_TOKEN PsReferencePrimaryToken(PEPROCESS Process);
NTSTATUS PsAssignImpersonationToken(PETHREAD Thread,
HANDLE TokenHandle);
PACCESS_TOKEN STDCALL PsReferenceImpersonationToken(PETHREAD Thread,
PULONG Unknown1,
PULONG Unknown2,
SECURITY_IMPERSONATION_LEVEL*
Level);
PACCESS_TOKEN STDCALL PsReferencePrimaryToken(PEPROCESS Process);
NTSTATUS STDCALL PsAssignImpersonationToken(PETHREAD Thread,
HANDLE TokenHandle);
VOID PsImpersonateClient(PETHREAD Thread,
PACCESS_TOKEN Token,
UCHAR b,
UCHAR c,
SECURITY_IMPERSONATION_LEVEL Level);
VOID STDCALL PsImpersonateClient(PETHREAD Thread,
PACCESS_TOKEN Token,
UCHAR b,
UCHAR c,
SECURITY_IMPERSONATION_LEVEL Level);
VOID STDCALL PsRevertToSelf(PETHREAD Thread);
BOOLEAN
STDCALL
PsGetVersion (
PULONG MajorVersion OPTIONAL,
PULONG MinorVersion OPTIONAL,
PULONG BuildNumber OPTIONAL,
PUNICODE_STRING CSDVersion OPTIONAL
);
#endif
/* EOF */

View file

@ -316,4 +316,14 @@ typedef struct _EPROCESS
#define MAXIMUM_PRIORITY (32)
#ifdef __NTOSKRNL__
extern PEPROCESS EXPORTED PsInitialSystemProcess;
extern POBJECT_TYPE EXPORTED PsProcessType;
extern POBJECT_TYPE EXPORTED PsThreadType;
#else
extern PEPROCESS IMPORTED PsInitialSystemProcess;
extern POBJECT_TYPE IMPORTED PsProcessType;
extern POBJECT_TYPE IMPORTED PsThreadType;
#endif
#endif /* __INCLUDE_DDK_PSTYPES_H */

View file

@ -4,6 +4,11 @@
#define NtCurrentProcess() ( (HANDLE) 0xFFFFFFFF )
#define NtCurrentThread() ( (HANDLE) 0xFFFFFFFE )
#ifdef __NTOSKRNL__
extern ULONG EXPORTED NtBuildNumber;
#else
extern ULONG IMPORTED NtBuildNumber;
#endif
// event access mask

View file

@ -3,12 +3,9 @@
#include <internal/hal.h>
extern PEPROCESS SystemProcess;
extern HANDLE SystemProcessHandle;
/* ntoskrnl/ps/thread.c */
extern POBJECT_TYPE PsThreadType;
extern POBJECT_TYPE PsProcessType;
extern PETHREAD CurrentThread;
VOID PiInitProcessManager(VOID);

View file

@ -3,7 +3,6 @@
#include <internal/hal.h>
extern EPROCESS SystemProcess;
extern HANDLE SystemProcessHandle;
void PsInitThreadManagment(void);

View file

@ -68,7 +68,7 @@ typedef struct _RTL_USER_PROCESS_PARAMETERS
typedef struct _PEB_LDR_DATA
{
ULONG Length;
UCHAR Initialized;
BOOLEAN Initialized;
PVOID SsHandle;
LIST_ENTRY InLoadOrderModuleList;
LIST_ENTRY InMemoryOrderModuleList;

View file

@ -1,4 +1,4 @@
/* $Id: main.c,v 1.44 2000/05/13 14:56:46 ea Exp $
/* $Id: main.c,v 1.45 2000/06/03 21:35:51 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -30,7 +30,7 @@
/* DATA *********************************************************************/
USHORT EXPORTED NtBuildNumber = KERNEL_VERSION_BUILD;
ULONG EXPORTED NtBuildNumber = KERNEL_VERSION_BUILD;
ULONG EXPORTED NtGlobalFlag = 0;
/* FUNCTIONS ****************************************************************/

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.15 2000/05/13 13:51:07 dwelch Exp $
/* $Id: create.c,v 1.16 2000/06/03 21:36:32 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -43,8 +43,10 @@ extern LIST_ENTRY PiThreadListHead;
/* FUNCTIONS ***************************************************************/
NTSTATUS PsAssignImpersonationToken(PETHREAD Thread,
HANDLE TokenHandle)
NTSTATUS
STDCALL
PsAssignImpersonationToken(PETHREAD Thread,
HANDLE TokenHandle)
{
PACCESS_TOKEN Token;
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
@ -82,7 +84,7 @@ NTSTATUS PsAssignImpersonationToken(PETHREAD Thread,
return(STATUS_SUCCESS);
}
VOID PsRevertToSelf(PETHREAD Thread)
VOID STDCALL PsRevertToSelf(PETHREAD Thread)
{
if (Thread->ActiveImpersonationInfo != 0)
{
@ -91,11 +93,11 @@ VOID PsRevertToSelf(PETHREAD Thread)
}
}
VOID PsImpersonateClient(PETHREAD Thread,
PACCESS_TOKEN Token,
UCHAR b,
UCHAR c,
SECURITY_IMPERSONATION_LEVEL Level)
VOID STDCALL PsImpersonateClient(PETHREAD Thread,
PACCESS_TOKEN Token,
UCHAR b,
UCHAR c,
SECURITY_IMPERSONATION_LEVEL Level)
{
if (Token == 0)
{
@ -230,11 +232,11 @@ NTSTATUS STDCALL NtOpenThreadToken(IN HANDLE ThreadHandle,
return(STATUS_UNSUCCESSFUL);
}
PACCESS_TOKEN PsReferenceImpersonationToken(PETHREAD Thread,
PULONG Unknown1,
PULONG Unknown2,
SECURITY_IMPERSONATION_LEVEL*
Level)
PACCESS_TOKEN STDCALL PsReferenceImpersonationToken(PETHREAD Thread,
PULONG Unknown1,
PULONG Unknown2,
SECURITY_IMPERSONATION_LEVEL*
Level)
{
if (Thread->ActiveImpersonationInfo == 0)
{
@ -339,7 +341,7 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
}
else
{
Process = SystemProcess;
Process = PsInitialSystemProcess;
ObReferenceObjectByPointer(Process,
PROCESS_CREATE_THREAD,
PsProcessType,
@ -584,13 +586,13 @@ NTSTATUS STDCALL NtCreateThread (PHANDLE ThreadHandle,
}
NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
HANDLE ProcessHandle,
PCLIENT_ID ClientId,
PKSTART_ROUTINE StartRoutine,
PVOID StartContext)
NTSTATUS STDCALL PsCreateSystemThread(PHANDLE ThreadHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
HANDLE ProcessHandle,
PCLIENT_ID ClientId,
PKSTART_ROUTINE StartRoutine,
PVOID StartContext)
/*
* FUNCTION: Creates a thread which executes in kernel mode
* ARGUMENTS:

View file

@ -255,7 +255,7 @@ NTSTATUS STDCALL NtTerminateThread(IN HANDLE ThreadHandle,
}
NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus)
NTSTATUS STDCALL PsTerminateSystemThread(NTSTATUS ExitStatus)
/*
* FUNCTION: Terminates the current thread
* ARGUMENTS:

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.42 2000/05/14 09:34:14 ea Exp $
/* $Id: process.c,v 1.43 2000/06/03 21:36:32 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -30,10 +30,10 @@
/* GLOBALS ******************************************************************/
PEPROCESS SystemProcess = NULL;
PEPROCESS EXPORTED PsInitialSystemProcess = NULL;
HANDLE SystemProcessHandle = NULL;
POBJECT_TYPE PsProcessType = NULL;
POBJECT_TYPE EXPORTED PsProcessType = NULL;
static LIST_ENTRY PsProcessListHead;
static KSPIN_LOCK PsProcessListLock;
@ -63,7 +63,7 @@ NTSTATUS STDCALL NtOpenProcessToken(IN HANDLE ProcessHandle,
return(Status);
}
PACCESS_TOKEN PsReferencePrimaryToken(PEPROCESS Process)
PACCESS_TOKEN STDCALL PsReferencePrimaryToken(PEPROCESS Process)
{
ObReferenceObjectByPointer(Process->Token,
GENERIC_ALL,
@ -108,7 +108,7 @@ VOID PiKillMostProcesses(VOID)
Pcb.ProcessListEntry);
current_entry = current_entry->Flink;
if (current->UniqueProcessId != SystemProcess->UniqueProcessId &&
if (current->UniqueProcessId != PsInitialSystemProcess->UniqueProcessId &&
current->UniqueProcessId != (ULONG)PsGetCurrentProcessId())
{
PiTerminateProcess(current, STATUS_SUCCESS);
@ -155,22 +155,22 @@ VOID PsInitProcessManagment(VOID)
/*
* Initialize the system process
*/
SystemProcess = ObCreateObject(NULL,
PROCESS_ALL_ACCESS,
NULL,
PsProcessType);
SystemProcess->Pcb.BasePriority = PROCESS_PRIO_NORMAL;
KeInitializeDispatcherHeader(&SystemProcess->Pcb.DispatcherHeader,
PsInitialSystemProcess = ObCreateObject(NULL,
PROCESS_ALL_ACCESS,
NULL,
PsProcessType);
PsInitialSystemProcess->Pcb.BasePriority = PROCESS_PRIO_NORMAL;
KeInitializeDispatcherHeader(&PsInitialSystemProcess->Pcb.DispatcherHeader,
InternalProcessType,
sizeof(EPROCESS),
FALSE);
KProcess = &SystemProcess->Pcb;
KProcess = &PsInitialSystemProcess->Pcb;
MmInitializeAddressSpace(SystemProcess,
&SystemProcess->Pcb.AddressSpace);
ObCreateHandleTable(NULL,FALSE,SystemProcess);
MmInitializeAddressSpace(PsInitialSystemProcess,
&PsInitialSystemProcess->Pcb.AddressSpace);
ObCreateHandleTable(NULL,FALSE,PsInitialSystemProcess);
KProcess->PageTableDirectory = get_page_directory();
SystemProcess->UniqueProcessId =
PsInitialSystemProcess->UniqueProcessId =
InterlockedIncrement(&PiNextProcessUniqueId);
KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
@ -178,10 +178,10 @@ VOID PsInitProcessManagment(VOID)
InitializeListHead( &KProcess->ThreadListHead );
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
strcpy(SystemProcess->ImageFileName, "SYSTEM");
strcpy(PsInitialSystemProcess->ImageFileName, "SYSTEM");
ObCreateHandle(SystemProcess,
SystemProcess,
ObCreateHandle(PsInitialSystemProcess,
PsInitialSystemProcess,
PROCESS_ALL_ACCESS,
FALSE,
&SystemProcessHandle);
@ -249,7 +249,7 @@ PKPROCESS KeGetCurrentProcess(VOID)
return(&(PsGetCurrentProcess()->Pcb));
}
HANDLE PsGetCurrentProcessId(VOID)
HANDLE STDCALL PsGetCurrentProcessId(VOID)
{
return((HANDLE)PsGetCurrentProcess()->UniqueProcessId);
}
@ -262,7 +262,7 @@ struct _EPROCESS* PsGetCurrentProcess(VOID)
if (PsGetCurrentThread() == NULL ||
PsGetCurrentThread()->ThreadsProcess == NULL)
{
return(SystemProcess);
return(PsInitialSystemProcess);
}
else
{

View file

@ -1,4 +1,5 @@
/*
/* $Id: psmgr.c,v 1.7 2000/06/03 21:36:32 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ps/psmgr.c
@ -10,6 +11,7 @@
#include <ddk/ntddk.h>
#include <internal/ps.h>
#include <reactos/version.h>
#include <internal/debug.h>
@ -29,3 +31,69 @@ VOID PiInitProcessManager(VOID)
PsInitIdleThread();
PiInitApcManagement();
}
/**********************************************************************
* NAME EXPORTED
* PsGetVersion
*
* DESCRIPTION
* Retrieves the current OS version.
*
* ARGUMENTS
* MajorVersion Pointer to a variable that will be set to the
* major version of the OS. Can be NULL.
*
* MinorVersion Pointer to a variable that will be set to the
* minor version of the OS. Can be NULL.
*
* BuildNumber Pointer to a variable that will be set to the
* build number of the OS. Can be NULL.
*
* CSDVersion Pointer to a variable that will be set to the
* CSD string of the OS. Can be NULL.
*
* RETURN VALUE
* TRUE OS is a checked build.
* FALSE OS is a free build.
*
* NOTES
* The DDK docs say something about a 'CmCSDVersionString'.
* How do we determine in the build is checked or free??
*/
BOOLEAN
STDCALL
PsGetVersion (
PULONG MajorVersion OPTIONAL,
PULONG MinorVersion OPTIONAL,
PULONG BuildNumber OPTIONAL,
PUNICODE_STRING CSDVersion OPTIONAL
)
{
if (MajorVersion)
*MajorVersion = KERNEL_VERSION_MAJOR;
if (MinorVersion)
*MinorVersion = KERNEL_VERSION_MINOR;
if (BuildNumber)
*BuildNumber = NtBuildNumber;
if (CSDVersion)
{
CSDVersion->Length = 0;
CSDVersion->MaximumLength = 0;
CSDVersion->Buffer = NULL;
#if 0
CSDVersion->Length = CmCSDVersionString.Length;
CSDVersion->MaximumLength = CmCSDVersionString.Maximum;
CSDVersion->Buffer = CmCSDVersionString.Buffer;
#endif
}
/* FIXME: How do we determine if build is checked or free? */
return FALSE;
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: thread.c,v 1.46 2000/05/13 13:51:08 dwelch Exp $
/* $Id: thread.c,v 1.47 2000/06/03 21:36:32 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -36,7 +36,7 @@
/* GLOBALS ******************************************************************/
POBJECT_TYPE PsThreadType = NULL;
POBJECT_TYPE EXPORTED PsThreadType = NULL;
#define NR_THREAD_PRIORITY_LEVELS (32)
#define THREAD_PRIORITY_MAX (15)
@ -116,7 +116,7 @@ PETHREAD PsGetCurrentThread(VOID)
return(CurrentThread);
}
HANDLE PsGetCurrentThreadId(VOID)
HANDLE STDCALL PsGetCurrentThreadId(VOID)
{
return(CurrentThread->Cid.UniqueThread);
}