mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
More improvements to LPC code
Updated TEB structure Changed selectors value to be closer to nt Some bugfixes svn path=/trunk/; revision=965
This commit is contained in:
parent
52404fd1c8
commit
d24a48cd94
32 changed files with 2002 additions and 1326 deletions
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <kernel32/atom.h>
|
#include <kernel32/atom.h>
|
||||||
#include <internal/hal.h>
|
#include <internal/hal.h>
|
||||||
|
#include <internal/teb.h>
|
||||||
|
|
||||||
#ifndef TLS_MINIMUM_AVAILABLE
|
#ifndef TLS_MINIMUM_AVAILABLE
|
||||||
#define TLS_MINIMUM_AVAILABLE (64)
|
#define TLS_MINIMUM_AVAILABLE (64)
|
||||||
|
@ -46,127 +47,6 @@ typedef struct linux_sigcontext {
|
||||||
|
|
||||||
typedef ULONG THREADINFOCLASS;
|
typedef ULONG THREADINFOCLASS;
|
||||||
|
|
||||||
typedef struct _CURDIR
|
|
||||||
{
|
|
||||||
UNICODE_STRING DosPath;
|
|
||||||
HANDLE Handle;
|
|
||||||
} CURDIR, *PCURDIR;
|
|
||||||
|
|
||||||
typedef struct _RTL_DRIVE_LETTER_CURDIR
|
|
||||||
{
|
|
||||||
USHORT Flags;
|
|
||||||
USHORT Length;
|
|
||||||
ULONG TimeStamp;
|
|
||||||
UNICODE_STRING DosPath;
|
|
||||||
} RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
|
|
||||||
|
|
||||||
typedef struct _RTL_USER_PROCESS_PARAMETERS
|
|
||||||
{
|
|
||||||
ULONG MaximumLength; // 00h
|
|
||||||
ULONG Length; // 04h
|
|
||||||
ULONG Flags; // 08h
|
|
||||||
ULONG DebugFlags; // 0Ch
|
|
||||||
HANDLE ConsoleHandle; // 10h
|
|
||||||
ULONG ConsoleFlags; // 14h
|
|
||||||
HANDLE StandardInput; // 18h
|
|
||||||
HANDLE StandardOutput; // 1Ch
|
|
||||||
HANDLE StandardError; // 20h
|
|
||||||
CURDIR CurrentDirectory; // 24h
|
|
||||||
UNICODE_STRING DllPath; // 30h
|
|
||||||
UNICODE_STRING ImagePathName; // 38h
|
|
||||||
UNICODE_STRING CommandLine; // 40h
|
|
||||||
PVOID Environment; // 48h
|
|
||||||
ULONG StartingX; // 4Ch
|
|
||||||
ULONG StartingY; // 50h
|
|
||||||
ULONG CountX; // 54h
|
|
||||||
ULONG CountY; // 58h
|
|
||||||
ULONG CountCharsX; // 5Ch
|
|
||||||
ULONG CountCharsY; // 60h
|
|
||||||
ULONG FillAttribute; // 64h
|
|
||||||
ULONG WindowFlags; // 68h
|
|
||||||
ULONG ShowWindowFlags; // 6Ch
|
|
||||||
UNICODE_STRING WindowTitle; // 70h
|
|
||||||
UNICODE_STRING DesktopInfo; // 78h
|
|
||||||
UNICODE_STRING ShellInfo; // 80h
|
|
||||||
UNICODE_STRING RuntimeData; // 88h
|
|
||||||
RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[32]; // 90h
|
|
||||||
} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _LDR
|
|
||||||
{
|
|
||||||
UCHAR Initialized;
|
|
||||||
UCHAR InInitializationOrderModuleList;
|
|
||||||
PVOID InLoadOrderModuleList;
|
|
||||||
PVOID InMemoryOrderModuleList;
|
|
||||||
} LDR, *PLDR;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _PEB
|
|
||||||
{
|
|
||||||
UCHAR InheritedAddressSpace; // 00
|
|
||||||
UCHAR ReadImageFileExecOptions; // 01h
|
|
||||||
UCHAR BeingDebugged; // 02h
|
|
||||||
LONG ImageBaseAddress; // 03h
|
|
||||||
LDR Ldr; // 07h
|
|
||||||
|
|
||||||
PRTL_USER_PROCESS_PARAMETERS ProcessParameters; // 10h
|
|
||||||
|
|
||||||
WORD NumberOfProcessors; // 11h
|
|
||||||
WORD NtGlobalFlag; // 13h
|
|
||||||
|
|
||||||
HANDLE ProcessHeap; // 19h
|
|
||||||
ATOMTABLE LocalAtomTable; // 1Dh
|
|
||||||
LPCRITICAL_SECTION CriticalSection; // 35h
|
|
||||||
DWORD CriticalSectionTimeout; // 39h
|
|
||||||
WORD MajorVersion; // 3Dh
|
|
||||||
WORD MinorVersion; // 3Fh
|
|
||||||
WORD BuildNumber; // 41h
|
|
||||||
WORD PlatformId; // 43h
|
|
||||||
} PEB, *PPEB;
|
|
||||||
|
|
||||||
typedef struct _CLIENT_ID
|
|
||||||
{
|
|
||||||
HANDLE UniqueProcess;
|
|
||||||
HANDLE UniqueThread;
|
|
||||||
} CLIENT_ID, *PCLIENT_ID;
|
|
||||||
|
|
||||||
typedef struct _NT_TIB {
|
|
||||||
struct _EXCEPTION_REGISTRATION_RECORD* ExceptionList; // 00h
|
|
||||||
PVOID StackBase; // 04h
|
|
||||||
PVOID StackLimit; // 08h
|
|
||||||
PVOID SubSystemTib; // 0Ch
|
|
||||||
union {
|
|
||||||
PVOID FiberData; // 10h
|
|
||||||
ULONG Version; // 10h
|
|
||||||
} Fib;
|
|
||||||
PVOID ArbitraryUserPointer; // 14h
|
|
||||||
struct _NT_TIB *Self; // 18h
|
|
||||||
} NT_TIB, *PNT_TIB;
|
|
||||||
|
|
||||||
typedef struct _NT_TEB
|
|
||||||
{
|
|
||||||
NT_TIB Tib; // 00h
|
|
||||||
ULONG reserved1; // 1Ch ???
|
|
||||||
CLIENT_ID Cid; // 20h
|
|
||||||
ULONG reserved2; // 28h ???
|
|
||||||
ULONG reserved3; // 2Ch ???
|
|
||||||
PPEB Peb; // 30h
|
|
||||||
DWORD LastErrorCode; // 34h
|
|
||||||
|
|
||||||
HANDLE RPCHandle; // 36
|
|
||||||
PVOID TlsData[TLS_MINIMUM_AVAILABLE]; // 40
|
|
||||||
DWORD dwTlsIndex; // 230
|
|
||||||
NTSTATUS LastStatusValue; // 242
|
|
||||||
DWORD LockCount; // 244
|
|
||||||
UCHAR HardErrorMode; // 248
|
|
||||||
|
|
||||||
/* reactos only ??? (Eric Kohl) */
|
|
||||||
PVOID StackCommit;
|
|
||||||
PVOID StackCommitMax;
|
|
||||||
PVOID StackReserved;
|
|
||||||
} NT_TEB, *PNT_TEB;
|
|
||||||
|
|
||||||
struct _KPROCESS;
|
struct _KPROCESS;
|
||||||
|
|
||||||
typedef struct _KAPC_STATE
|
typedef struct _KAPC_STATE
|
||||||
|
@ -428,4 +308,10 @@ typedef struct _EPROCESS
|
||||||
#define PROCESS_STATE_TERMINATED (1)
|
#define PROCESS_STATE_TERMINATED (1)
|
||||||
#define PROCESS_STATE_ACTIVE (2)
|
#define PROCESS_STATE_ACTIVE (2)
|
||||||
|
|
||||||
|
#define LOW_PRIORITY (0)
|
||||||
|
#define LOW_REALTIME_PRIORITY (16)
|
||||||
|
#define HIGH_PRIORITY (31)
|
||||||
|
#define MAXIMUM_PRIORITY (32)
|
||||||
|
|
||||||
|
|
||||||
#endif /* __INCLUDE_DDK_PSTYPES_H */
|
#endif /* __INCLUDE_DDK_PSTYPES_H */
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#ifndef _INCLUDE_DDK_SEFUNCS_H
|
#ifndef _INCLUDE_DDK_SEFUNCS_H
|
||||||
#define _INCLUDE_DDK_SEFUNCS_H
|
#define _INCLUDE_DDK_SEFUNCS_H
|
||||||
/* $Id: sefuncs.h,v 1.4 2000/01/05 21:56:58 dwelch Exp $ */
|
/* $Id: sefuncs.h,v 1.5 2000/01/26 10:07:22 dwelch Exp $ */
|
||||||
NTSTATUS STDCALL RtlCreateSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor, ULONG Revision);
|
NTSTATUS STDCALL RtlCreateSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor, ULONG Revision);
|
||||||
BOOLEAN STDCALL RtlValidSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor);
|
BOOLEAN STDCALL RtlValidSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor);
|
||||||
ULONG STDCALL RtlLengthSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor);
|
ULONG STDCALL RtlLengthSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor);
|
||||||
|
@ -26,11 +26,12 @@ BOOLEAN STDCALL SeAccessCheck (IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
OUT PACCESS_MODE GrantedAccess,
|
OUT PACCESS_MODE GrantedAccess,
|
||||||
OUT PNTSTATUS AccessStatus);
|
OUT PNTSTATUS AccessStatus);
|
||||||
NTSTATUS STDCALL SeAssignSecurity (PSECURITY_DESCRIPTOR ParentDescriptor,
|
NTSTATUS STDCALL SeAssignSecurity (PSECURITY_DESCRIPTOR ParentDescriptor,
|
||||||
PSECURITY_DESCRIPTOR ExplicitDescriptor,
|
PSECURITY_DESCRIPTOR ExplicitDescriptor,
|
||||||
BOOLEAN IsDirectoryObject,
|
PSECURITY_DESCRIPTOR* NewDescriptor,
|
||||||
PSECURITY_SUBJECT_CONTEXT SubjectContext,
|
BOOLEAN IsDirectoryObject,
|
||||||
PGENERIC_MAPPING GenericMapping,
|
PSECURITY_SUBJECT_CONTEXT SubjectContext,
|
||||||
POOL_TYPE PoolType);
|
PGENERIC_MAPPING GenericMapping,
|
||||||
|
POOL_TYPE PoolType);
|
||||||
NTSTATUS STDCALL SeDeassignSecurity (PSECURITY_DESCRIPTOR* SecurityDescriptor);
|
NTSTATUS STDCALL SeDeassignSecurity (PSECURITY_DESCRIPTOR* SecurityDescriptor);
|
||||||
BOOLEAN STDCALL SeSinglePrivilegeCheck (LUID PrivilegeValue, KPROCESSOR_MODE PreviousMode);
|
BOOLEAN STDCALL SeSinglePrivilegeCheck (LUID PrivilegeValue, KPROCESSOR_MODE PreviousMode);
|
||||||
ULONG STDCALL RtlLengthSid (PSID Sid);
|
ULONG STDCALL RtlLengthSid (PSID Sid);
|
||||||
|
@ -43,6 +44,20 @@ NTSTATUS SeCreateClientSecurity(PETHREAD Thread,
|
||||||
PSECURITY_QUALITY_OF_SERVICE Qos,
|
PSECURITY_QUALITY_OF_SERVICE Qos,
|
||||||
ULONG e,
|
ULONG e,
|
||||||
PSE_SOME_STRUCT2 f);
|
PSE_SOME_STRUCT2 f);
|
||||||
|
NTSTATUS SeExchangePrimaryToken(PEPROCESS Process,
|
||||||
|
PACCESS_TOKEN NewToken,
|
||||||
|
PACCESS_TOKEN* OldTokenP);
|
||||||
|
VOID STDCALL SeReleaseSubjectContext (PSECURITY_SUBJECT_CONTEXT SubjectContext);
|
||||||
|
VOID STDCALL SeCaptureSubjectContext (PSECURITY_SUBJECT_CONTEXT SubjectContext);
|
||||||
|
NTSTATUS SeCaptureLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Src,
|
||||||
|
ULONG PrivilegeCount,
|
||||||
|
KPROCESSOR_MODE PreviousMode,
|
||||||
|
PLUID_AND_ATTRIBUTES AllocatedMem,
|
||||||
|
ULONG AllocatedLength,
|
||||||
|
POOL_TYPE PoolType,
|
||||||
|
ULONG d,
|
||||||
|
PLUID_AND_ATTRIBUTES* Dest,
|
||||||
|
PULONG Length);
|
||||||
|
|
||||||
|
|
||||||
#endif /* ndef _INCLUDE_DDK_SEFUNCS_H */
|
#endif /* ndef _INCLUDE_DDK_SEFUNCS_H */
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
#ifndef _ASM_SEGMENT_H
|
#ifndef _ASM_SEGMENT_H
|
||||||
#define _ASM_SEGMENT_H
|
#define _ASM_SEGMENT_H
|
||||||
|
|
||||||
#define USER_CS (0x8+0x3)
|
#define KERNEL_CS (0x8)
|
||||||
#define USER_DS (0x10+0x3)
|
#define KERNEL_DS (0x10)
|
||||||
#define ZERO_DS 0x18
|
#define USER_CS (0x18 + 0x3)
|
||||||
#define KERNEL_CS 0x20
|
#define USER_DS (0x20 + 0x3)
|
||||||
#define KERNEL_DS 0x28
|
#define RESERVED_FOR_TSS (0x28)
|
||||||
|
#define PCR_SELECTOR (0x30)
|
||||||
|
#define TEB_SELECTOR (0x38 + 0x3)
|
||||||
|
|
||||||
|
//#define USER_CS (0x8+0x3)
|
||||||
|
//#define USER_DS (0x10+0x3)
|
||||||
|
//#define ZERO_DS 0x18
|
||||||
|
//#define KERNEL_CS 0x20
|
||||||
|
//#define KERNEL_DS 0x28
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
|
|
23
reactos/include/internal/port.h
Normal file
23
reactos/include/internal/port.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
typedef struct _EPORT
|
||||||
|
{
|
||||||
|
KSPIN_LOCK Lock;
|
||||||
|
KEVENT Event;
|
||||||
|
|
||||||
|
struct _EPORT* OtherPort;
|
||||||
|
|
||||||
|
ULONG QueueLength;
|
||||||
|
LIST_ENTRY QueueListHead;
|
||||||
|
|
||||||
|
ULONG ConnectQueueLength;
|
||||||
|
LIST_ENTRY ConnectQueueListHead;
|
||||||
|
|
||||||
|
ULONG MaxDataLength;
|
||||||
|
ULONG MaxConnectInfoLength;
|
||||||
|
} EPORT, *PEPORT;
|
||||||
|
|
||||||
|
NTSTATUS STDCALL LpcRequestPort(PEPORT Port,
|
||||||
|
PLPCMESSAGE LpcMessage);
|
||||||
|
|
||||||
|
#define PORT_ALL_ACCESS (0x1)
|
||||||
|
|
||||||
|
extern POBJECT_TYPE ExPortType;
|
|
@ -2,9 +2,214 @@
|
||||||
#ifndef __INCLUDE_INTERNAL_TEB
|
#ifndef __INCLUDE_INTERNAL_TEB
|
||||||
#define __INCLUDE_INTERNAL_TEB
|
#define __INCLUDE_INTERNAL_TEB
|
||||||
|
|
||||||
#include <internal/ps.h>
|
typedef struct _CLIENT_ID
|
||||||
|
{
|
||||||
|
HANDLE UniqueProcess;
|
||||||
|
HANDLE UniqueThread;
|
||||||
|
} CLIENT_ID, *PCLIENT_ID;
|
||||||
|
|
||||||
|
typedef struct _CURDIR
|
||||||
|
{
|
||||||
|
UNICODE_STRING DosPath;
|
||||||
|
PVOID Handle;
|
||||||
|
} CURDIR, *PCURDIR;
|
||||||
|
|
||||||
|
typedef struct RTL_DRIVE_LETTER_CURDIR
|
||||||
|
{
|
||||||
|
USHORT Flags;
|
||||||
|
USHORT Length;
|
||||||
|
ULONG TimeStamp;
|
||||||
|
UNICODE_STRING DosPath;
|
||||||
|
} RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
|
||||||
|
|
||||||
|
typedef struct _PEB_FREE_BLOCK
|
||||||
|
{
|
||||||
|
struct _PEB_FREE_BLOCK* Next;
|
||||||
|
ULONG Size;
|
||||||
|
} PEB_FREE_BLOCK, *PPEB_FREE_BLOCK;
|
||||||
|
|
||||||
|
typedef struct _RTL_USER_PROCESS_PARAMETERS
|
||||||
|
{
|
||||||
|
ULONG TotalSize; // 00h
|
||||||
|
ULONG DataSize; // 04h
|
||||||
|
ULONG Flags; // 08h
|
||||||
|
ULONG DebugFlags; // 0Ch
|
||||||
|
PVOID ConsoleHandle; // 10h
|
||||||
|
ULONG ConsoleFlags; // 14h
|
||||||
|
HANDLE InputHandle; // 18h
|
||||||
|
HANDLE OutputHandle; // 1Ch
|
||||||
|
HANDLE ErrorHandle; // 20h
|
||||||
|
CURDIR CurrentDirectory; // 24h
|
||||||
|
UNICODE_STRING LibraryPath; // 30h
|
||||||
|
UNICODE_STRING CommandLine; // 38h
|
||||||
|
UNICODE_STRING ImageName; // 40h
|
||||||
|
PVOID Environment; // 48h
|
||||||
|
DWORD X; // 4Ch
|
||||||
|
DWORD Y; // 50h
|
||||||
|
DWORD XSize; // 54h
|
||||||
|
DWORD YSize; // 58h
|
||||||
|
DWORD XCountChars; // 5Ch
|
||||||
|
DWORD YCountChars; // 60h
|
||||||
|
DWORD FillAttribute; // 64h
|
||||||
|
DWORD WindowFlags; // 68h
|
||||||
|
DWORD ShowWindow; // 6Ch
|
||||||
|
UNICODE_STRING Title; // 70h
|
||||||
|
UNICODE_STRING Desktop; // 78h
|
||||||
|
UNICODE_STRING ShellInfo; // 80h
|
||||||
|
UNICODE_STRING RuntimeData; // 88h
|
||||||
|
RTL_DRIVE_LETTER_CURDIR RtlCurrentDirectory[0x20]; // 90h
|
||||||
|
} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
|
||||||
|
|
||||||
|
#define PEB_BASE (0x7FFDF000)
|
||||||
|
|
||||||
|
typedef struct _PEB_LDR_DATA
|
||||||
|
{
|
||||||
|
ULONG Length;
|
||||||
|
UCHAR Initialized;
|
||||||
|
PVOID SsHandle;
|
||||||
|
LIST_ENTRY InLoadOrderModuleList;
|
||||||
|
LIST_ENTRY InMemoryOrderModuleList;
|
||||||
|
LIST_ENTRY InInitializationOrderModuleList;
|
||||||
|
} PEB_LDR_DATA, *PPEB_LDR_DATA;
|
||||||
|
|
||||||
|
typedef struct _PEB
|
||||||
|
{
|
||||||
|
UCHAR InheritedAddressSpace; // 00h
|
||||||
|
UCHAR ReadImageFileExecOptions; // 01h
|
||||||
|
UCHAR BeingDebugged; // 02h
|
||||||
|
UCHAR Spare; // 03h
|
||||||
|
PVOID Mutant; // 04h
|
||||||
|
PVOID ImageBaseAddress; // 08h
|
||||||
|
PPEB_LDR_DATA Ldr; // 0Ch
|
||||||
|
PRTL_USER_PROCESS_PARAMETERS ProcessParameters; // 10h
|
||||||
|
PVOID SubSystemData; // 14h
|
||||||
|
PVOID ProcessHeap; // 18h
|
||||||
|
PVOID LastPebLock; // 1Ch
|
||||||
|
PVOID FastPebLockRoutine; // 20h
|
||||||
|
PVOID FastPebUnlockRoutine; // 24h
|
||||||
|
ULONG EnvironmentUpdateCount; // 28h
|
||||||
|
PVOID KernelCallbackTable; // 2Ch
|
||||||
|
PVOID EventLogSection; // 30h
|
||||||
|
PVOID EventLog; // 34h
|
||||||
|
PPEB_FREE_BLOCK FreeList; // 38h
|
||||||
|
ULONG TlsExpansionCounter; // 3Ch
|
||||||
|
PVOID TlsBitmap; // 40h
|
||||||
|
ULONG TlsBitmapBits[0x2]; // 44h
|
||||||
|
PVOID ReadOnlySharedMemoryBase; // 4Ch
|
||||||
|
PVOID ReadOnlySharedMemoryHeap; // 50h
|
||||||
|
PVOID* ReadOnlyStaticServerData; // 54h
|
||||||
|
PVOID AnsiCodePageData; // 58h
|
||||||
|
PVOID OemCodePageData; // 5Ch
|
||||||
|
PVOID UnicodeCaseTableData; // 60h
|
||||||
|
ULONG NumberOfProcessors; // 64h
|
||||||
|
ULONG NtGlobalFlag; // 68h
|
||||||
|
UCHAR Spare2[0x4]; // 6Ch
|
||||||
|
LARGE_INTEGER CriticalSectionTimeout; // 70h
|
||||||
|
ULONG HeapSegmentReserve; // 78h
|
||||||
|
ULONG HeapSegmentCommit; // 7Ch
|
||||||
|
ULONG HeapDeCommitTotalFreeThreshold; // 80h
|
||||||
|
ULONG HeapDeCommitFreeBlockThreshold; // 84h
|
||||||
|
ULONG NumberOfHeaps; // 88h
|
||||||
|
ULONG MaximumNumberOfHeaps; // 8Ch
|
||||||
|
PVOID** ProcessHeaps; // 90h
|
||||||
|
PVOID GdiSharedHandleTable; // 94h
|
||||||
|
PVOID ProcessStarterHelper; // 98h
|
||||||
|
PVOID GdiDCAttributeList; // 9Ch
|
||||||
|
PVOID LoaderLock; // A0h
|
||||||
|
ULONG OSMajorVersion; // A4h
|
||||||
|
ULONG OSMinorVersion; // A8h
|
||||||
|
ULONG OSBuildNumber; // ACh
|
||||||
|
ULONG OSPlatformId; // B0h
|
||||||
|
ULONG ImageSubSystem; // B4h
|
||||||
|
ULONG ImageSubSystemMajorVersion; // B8h
|
||||||
|
ULONG ImageSubSystemMinorVersion; // C0h
|
||||||
|
ULONG GdiHandleBuffer[0x22]; // C4h
|
||||||
|
} PEB, *PPEB;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _NT_TIB {
|
||||||
|
struct _EXCEPTION_REGISTRATION_RECORD* ExceptionList; // 00h
|
||||||
|
PVOID StackBase; // 04h
|
||||||
|
PVOID StackLimit; // 08h
|
||||||
|
PVOID SubSystemTib; // 0Ch
|
||||||
|
union {
|
||||||
|
PVOID FiberData; // 10h
|
||||||
|
ULONG Version; // 10h
|
||||||
|
} Fib;
|
||||||
|
PVOID ArbitraryUserPointer; // 14h
|
||||||
|
struct _NT_TIB *Self; // 18h
|
||||||
|
} NT_TIB, *PNT_TIB;
|
||||||
|
|
||||||
|
typedef struct _GDI_TEB_BATCH
|
||||||
|
{
|
||||||
|
ULONG Offset;
|
||||||
|
ULONG HDC;
|
||||||
|
ULONG Buffer[0x136];
|
||||||
|
} GDI_TEB_BATCH, *PGDI_TEB_BATCH;
|
||||||
|
|
||||||
|
typedef struct _NT_TEB
|
||||||
|
{
|
||||||
|
NT_TIB Tib; // 00h
|
||||||
|
PVOID EnvironmentPointer; // 1Ch
|
||||||
|
CLIENT_ID Cid; // 20h
|
||||||
|
PVOID ActiveRpcInfo; // 28h
|
||||||
|
PVOID ThreadLocalStoragePointer; // 2Ch
|
||||||
|
PPEB Peb; // 30h
|
||||||
|
ULONG LastErrorValue; // 34h
|
||||||
|
ULONG CountOfOwnedCriticalSections; // 38h
|
||||||
|
PVOID CsrClientThread; // 3Ch
|
||||||
|
PVOID Win32ThreadInfo; // 40h
|
||||||
|
ULONG Win32ClientInfo[0x1F]; // 44h
|
||||||
|
PVOID WOW32Reserved; // C0h
|
||||||
|
ULONG CurrentLocale; // C4h
|
||||||
|
ULONG FpSoftwareStatusRegister; // C8h
|
||||||
|
PVOID SystemReserved1[0x36]; // CCh
|
||||||
|
PVOID Spare1; // 1A4h
|
||||||
|
LONG ExceptionCode; // 1A8h
|
||||||
|
ULONG SpareBytes1[0x28]; // 1ACh
|
||||||
|
PVOID SystemReserved2[0xA]; // 1D4h
|
||||||
|
GDI_TEB_BATCH GdiTebBatch; // 1FCh
|
||||||
|
ULONG gdiRgn; // 6DCh
|
||||||
|
ULONG gdiPen; // 6E0h
|
||||||
|
ULONG gdiBrush; // 6E4h
|
||||||
|
CLIENT_ID RealClientId; // 6E8h
|
||||||
|
PVOID GdiCachedProcessHandle; // 6F0h
|
||||||
|
ULONG GdiClientPID; // 6F4h
|
||||||
|
ULONG GdiClientTID; // 6F8h
|
||||||
|
PVOID GdiThreadLocaleInfo; // 6FCh
|
||||||
|
PVOID UserReserved[5]; // 700h
|
||||||
|
PVOID glDispatchTable[0x118]; // 714h
|
||||||
|
ULONG glReserved1[0x1A]; // B74h
|
||||||
|
PVOID glReserved2; // BDCh
|
||||||
|
PVOID glSectionInfo; // BE0h
|
||||||
|
PVOID glSection; // BE4h
|
||||||
|
PVOID glTable; // BE8h
|
||||||
|
PVOID glCurrentRC; // BECh
|
||||||
|
PVOID glContext; // BF0h
|
||||||
|
ULONG LastStatusValue; // BF4h
|
||||||
|
UNICODE_STRING StaticUnicodeString; // BF8h
|
||||||
|
WCHAR StaticUnicodeBuffer[0x105]; // C00h
|
||||||
|
PVOID DeallocationStack; // E0Ch
|
||||||
|
PVOID TlsSlots[0x40]; // E10h
|
||||||
|
LIST_ENTRY TlsLinks; // F10h
|
||||||
|
PVOID Vdm; // F18h
|
||||||
|
PVOID ReservedForNtRpc; // F1Ch
|
||||||
|
PVOID DbgSsReserved[0x2]; // F20h
|
||||||
|
ULONG HardErrorDisabled; // F28h
|
||||||
|
PVOID Instrumentation[0x10]; // F2Ch
|
||||||
|
PVOID WinSockData; // F6Ch
|
||||||
|
ULONG GdiBatchCount; // F70h
|
||||||
|
ULONG Spare2; // F74h
|
||||||
|
ULONG Spare3; // F78h
|
||||||
|
ULONG Spare4; // F7Ch
|
||||||
|
PVOID ReservedForOle; // F80h
|
||||||
|
ULONG WaitingOnLoaderLock; // F84h
|
||||||
|
|
||||||
|
PVOID StackCommit; // F88h
|
||||||
|
PVOID StackCommitMax; // F8Ch
|
||||||
|
PVOID StackReserved; // F90h
|
||||||
|
} NT_TEB, *PNT_TEB;
|
||||||
|
|
||||||
#define PEB_BASE (0xb0001000)
|
|
||||||
#define PEB_STARTUPINFO (0xb0003000)
|
#define PEB_STARTUPINFO (0xb0003000)
|
||||||
|
|
||||||
#define NtCurrentPeb() ((PPEB)PEB_BASE)
|
#define NtCurrentPeb() ((PPEB)PEB_BASE)
|
||||||
|
|
|
@ -1,37 +1,19 @@
|
||||||
/* $Id: rtl.h,v 1.6 2000/01/11 17:28:11 ekohl Exp $
|
/* $Id: rtl.h,v 1.7 2000/01/26 10:07:22 dwelch Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID
|
VOID WINAPI __RtlInitHeap(PVOID base,
|
||||||
WINAPI
|
ULONG minsize,
|
||||||
__RtlInitHeap (
|
ULONG maxsize);
|
||||||
PVOID base,
|
|
||||||
ULONG minsize,
|
|
||||||
ULONG maxsize
|
|
||||||
);
|
|
||||||
|
|
||||||
#define HEAP_BASE (0xa0000000)
|
#define HEAP_BASE (0xa0000000)
|
||||||
|
|
||||||
VOID
|
VOID RtlDeleteCriticalSection (LPCRITICAL_SECTION lpCriticalSection);
|
||||||
RtlDeleteCriticalSection (
|
VOID RtlEnterCriticalSection (LPCRITICAL_SECTION lpCriticalSection);
|
||||||
LPCRITICAL_SECTION lpCriticalSection
|
VOID RtlInitializeCriticalSection (LPCRITICAL_SECTION pcritical);
|
||||||
);
|
VOID RtlLeaveCriticalSection (LPCRITICAL_SECTION lpCriticalSection);
|
||||||
VOID
|
WINBOOL RtlTryEntryCriticalSection (LPCRITICAL_SECTION lpCriticalSection);
|
||||||
RtlEnterCriticalSection (
|
|
||||||
LPCRITICAL_SECTION lpCriticalSection
|
|
||||||
);
|
|
||||||
VOID
|
|
||||||
RtlInitializeCriticalSection (
|
|
||||||
LPCRITICAL_SECTION pcritical
|
|
||||||
);
|
|
||||||
VOID
|
|
||||||
RtlLeaveCriticalSection (
|
|
||||||
LPCRITICAL_SECTION lpCriticalSection
|
|
||||||
);
|
|
||||||
WINBOOL
|
|
||||||
RtlTryEntryCriticalSection (
|
|
||||||
LPCRITICAL_SECTION lpCriticalSection
|
|
||||||
);
|
|
||||||
UINT
|
UINT
|
||||||
STDCALL
|
STDCALL
|
||||||
RtlCompactHeap (
|
RtlCompactHeap (
|
||||||
|
@ -162,4 +144,4 @@ RtlNormalizeProcessParams (
|
||||||
IN OUT PRTL_USER_PROCESS_PARAMETERS ProcessParameters
|
IN OUT PRTL_USER_PROCESS_PARAMETERS ProcessParameters
|
||||||
);
|
);
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -92,40 +92,40 @@ typedef struct _IMAGE_OPTIONAL_HEADER {
|
||||||
// Standard fields.
|
// Standard fields.
|
||||||
//
|
//
|
||||||
|
|
||||||
WORD Magic;
|
WORD Magic; // 0x04
|
||||||
BYTE MajorLinkerVersion;
|
BYTE MajorLinkerVersion;
|
||||||
BYTE MinorLinkerVersion;
|
BYTE MinorLinkerVersion;
|
||||||
DWORD SizeOfCode;
|
DWORD SizeOfCode; // 0x08
|
||||||
DWORD SizeOfInitializedData;
|
DWORD SizeOfInitializedData; // 0x0C
|
||||||
DWORD SizeOfUninitializedData;
|
DWORD SizeOfUninitializedData; // 0x10
|
||||||
DWORD AddressOfEntryPoint;
|
DWORD AddressOfEntryPoint; // 0x14
|
||||||
DWORD BaseOfCode;
|
DWORD BaseOfCode; // 0x18
|
||||||
DWORD BaseOfData;
|
DWORD BaseOfData; // 0x1C
|
||||||
|
|
||||||
//
|
//
|
||||||
// NT additional fields.
|
// NT additional fields.
|
||||||
//
|
//
|
||||||
|
|
||||||
DWORD ImageBase;
|
DWORD ImageBase; // 0x20
|
||||||
DWORD SectionAlignment;
|
DWORD SectionAlignment; // 0x24
|
||||||
DWORD FileAlignment;
|
DWORD FileAlignment; // 0x28
|
||||||
WORD MajorOperatingSystemVersion;
|
WORD MajorOperatingSystemVersion; // 0x2C
|
||||||
WORD MinorOperatingSystemVersion;
|
WORD MinorOperatingSystemVersion; // 0x2E
|
||||||
WORD MajorImageVersion;
|
WORD MajorImageVersion; // 0x30
|
||||||
WORD MinorImageVersion;
|
WORD MinorImageVersion; // 0x32
|
||||||
WORD MajorSubsystemVersion;
|
WORD MajorSubsystemVersion; // 0x34
|
||||||
WORD MinorSubsystemVersion;
|
WORD MinorSubsystemVersion; // 0x36
|
||||||
DWORD Win32VersionValue;
|
DWORD Win32VersionValue; // 0x38
|
||||||
DWORD SizeOfImage;
|
DWORD SizeOfImage; // 0x3C
|
||||||
DWORD SizeOfHeaders;
|
DWORD SizeOfHeaders; // 0x40
|
||||||
DWORD CheckSum;
|
DWORD CheckSum; // 0x44
|
||||||
WORD Subsystem;
|
WORD Subsystem; // 0x48
|
||||||
WORD DllCharacteristics;
|
WORD DllCharacteristics; // 0x4A
|
||||||
DWORD SizeOfStackReserve;
|
DWORD SizeOfStackReserve; // 0x4C
|
||||||
DWORD SizeOfStackCommit;
|
DWORD SizeOfStackCommit; // 0x50
|
||||||
DWORD SizeOfHeapReserve;
|
DWORD SizeOfHeapReserve; // 0x54
|
||||||
DWORD SizeOfHeapCommit;
|
DWORD SizeOfHeapCommit; // 0x58
|
||||||
DWORD LoaderFlags;
|
DWORD LoaderFlags; // 0x5C
|
||||||
DWORD NumberOfRvaAndSizes;
|
DWORD NumberOfRvaAndSizes;
|
||||||
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
|
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
|
||||||
} IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
|
} IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: cmdline.c,v 1.10 2000/01/11 17:30:46 ekohl Exp $
|
/* $Id: cmdline.c,v 1.11 2000/01/26 10:07:23 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -41,7 +41,6 @@ static VOID
|
||||||
InitCommandLines (VOID)
|
InitCommandLines (VOID)
|
||||||
{
|
{
|
||||||
PRTL_USER_PROCESS_PARAMETERS Params;
|
PRTL_USER_PROCESS_PARAMETERS Params;
|
||||||
|
|
||||||
// initialize command line buffers
|
// initialize command line buffers
|
||||||
CommandLineW[0] = 0;
|
CommandLineW[0] = 0;
|
||||||
CommandLineStringW.Buffer = CommandLineW;
|
CommandLineStringW.Buffer = CommandLineW;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.17 2000/01/11 17:30:46 ekohl Exp $
|
/* $Id: create.c,v 1.18 2000/01/26 10:07:23 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -236,19 +236,19 @@ HANDLE KERNEL32_MapFile(LPCWSTR lpApplicationName,
|
||||||
TempApplicationName[3] = '\\';
|
TempApplicationName[3] = '\\';
|
||||||
TempApplicationName[4] = 0;
|
TempApplicationName[4] = 0;
|
||||||
|
|
||||||
DPRINT("TempApplicationName '%S'\n",TempApplicationName);
|
DPRINT("TempApplicationName '%w'\n",TempApplicationName);
|
||||||
|
|
||||||
if (lpApplicationName != NULL)
|
if (lpApplicationName != NULL)
|
||||||
{
|
{
|
||||||
wcscpy(TempFileName, lpApplicationName);
|
wcscpy(TempFileName, lpApplicationName);
|
||||||
|
|
||||||
DPRINT("TempFileName '%S'\n",TempFileName);
|
DPRINT("TempFileName '%w'\n",TempFileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wcscpy(TempFileName, lpCommandLine);
|
wcscpy(TempFileName, lpCommandLine);
|
||||||
|
|
||||||
DPRINT("TempFileName '%S'\n",TempFileName);
|
DPRINT("TempFileName '%w'\n",TempFileName);
|
||||||
|
|
||||||
for (i=0; TempFileName[i]!=' ' && TempFileName[i] != 0; i++);
|
for (i=0; TempFileName[i]!=' ' && TempFileName[i] != 0; i++);
|
||||||
TempFileName[i]=0;
|
TempFileName[i]=0;
|
||||||
|
@ -268,7 +268,7 @@ HANDLE KERNEL32_MapFile(LPCWSTR lpApplicationName,
|
||||||
|
|
||||||
RtlInitUnicodeString(&ApplicationNameString, TempApplicationName);
|
RtlInitUnicodeString(&ApplicationNameString, TempApplicationName);
|
||||||
|
|
||||||
DPRINT("ApplicationName %S\n",ApplicationNameString.Buffer);
|
DPRINT("ApplicationName %w\n",ApplicationNameString.Buffer);
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&ApplicationNameString,
|
&ApplicationNameString,
|
||||||
|
@ -349,7 +349,7 @@ static NTSTATUS
|
||||||
CreatePeb (
|
CreatePeb (
|
||||||
PPEB *PebPtr,
|
PPEB *PebPtr,
|
||||||
HANDLE ProcessHandle,
|
HANDLE ProcessHandle,
|
||||||
PRTL_USER_PROCESS_PARAMETERS Ppb)
|
PRTL_USER_PROCESS_PARAMETERS Ppb)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PVOID PebBase;
|
PVOID PebBase;
|
||||||
|
@ -361,7 +361,7 @@ CreatePeb (
|
||||||
|
|
||||||
/* create the PPB */
|
/* create the PPB */
|
||||||
PpbBase = (PVOID)PEB_STARTUPINFO;
|
PpbBase = (PVOID)PEB_STARTUPINFO;
|
||||||
PpbSize = Ppb->MaximumLength;
|
PpbSize = Ppb->TotalSize;
|
||||||
Status = NtAllocateVirtualMemory(ProcessHandle,
|
Status = NtAllocateVirtualMemory(ProcessHandle,
|
||||||
&PpbBase,
|
&PpbBase,
|
||||||
0,
|
0,
|
||||||
|
@ -373,11 +373,11 @@ CreatePeb (
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("Ppb->MaximumLength %x\n", Ppb->MaximumLength);
|
DPRINT("Ppb->TotalSize %x\n", Ppb->TotalSize);
|
||||||
NtWriteVirtualMemory(ProcessHandle,
|
NtWriteVirtualMemory(ProcessHandle,
|
||||||
PpbBase,
|
PpbBase,
|
||||||
Ppb,
|
Ppb,
|
||||||
Ppb->MaximumLength,
|
Ppb->TotalSize,
|
||||||
&BytesWritten);
|
&BytesWritten);
|
||||||
|
|
||||||
|
|
||||||
|
@ -439,11 +439,11 @@ CreateProcessW (
|
||||||
PROCESS_BASIC_INFORMATION ProcessBasicInfo;
|
PROCESS_BASIC_INFORMATION ProcessBasicInfo;
|
||||||
ULONG retlen;
|
ULONG retlen;
|
||||||
DWORD len = 0;
|
DWORD len = 0;
|
||||||
PRTL_USER_PROCESS_PARAMETERS ProcessParams;
|
PRTL_USER_PROCESS_PARAMETERS Ppb;
|
||||||
UNICODE_STRING CommandLine_U;
|
UNICODE_STRING CommandLine_U;
|
||||||
PPEB Peb;
|
PPEB Peb;
|
||||||
|
|
||||||
DPRINT("CreateProcessW(lpApplicationName '%S', lpCommandLine '%S')\n",
|
DPRINT("CreateProcessW(lpApplicationName '%w', lpCommandLine '%w')\n",
|
||||||
lpApplicationName,lpCommandLine);
|
lpApplicationName,lpCommandLine);
|
||||||
|
|
||||||
if (lpApplicationName[1] != ':')
|
if (lpApplicationName[1] != ':')
|
||||||
|
@ -469,10 +469,10 @@ CreateProcessW (
|
||||||
&CommandLine_U,
|
&CommandLine_U,
|
||||||
TempCommandLine);
|
TempCommandLine);
|
||||||
|
|
||||||
DPRINT("CommandLine_U %S\n", CommandLine_U.Buffer);
|
DPRINT("CommandLine_U %w\n", CommandLine_U.Buffer);
|
||||||
|
|
||||||
RtlCreateProcessParameters (
|
RtlCreateProcessParameters (
|
||||||
&ProcessParams,
|
&Ppb,
|
||||||
&CommandLine_U,
|
&CommandLine_U,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -529,7 +529,7 @@ CreateProcessW (
|
||||||
PAGE_READWRITE);
|
PAGE_READWRITE);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
RtlDestroyProcessParameters (ProcessParams);
|
RtlDestroyProcessParameters (Ppb);
|
||||||
SetLastError(RtlNtStatusToDosError(Status));
|
SetLastError(RtlNtStatusToDosError(Status));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -538,9 +538,9 @@ CreateProcessW (
|
||||||
* Create Process Environment Block
|
* Create Process Environment Block
|
||||||
*/
|
*/
|
||||||
DPRINT("Creating peb\n");
|
DPRINT("Creating peb\n");
|
||||||
CreatePeb(&Peb, hProcess, ProcessParams);
|
CreatePeb(&Peb, hProcess, Ppb);
|
||||||
|
|
||||||
RtlDestroyProcessParameters (ProcessParams);
|
RtlDestroyProcessParameters (Ppb);
|
||||||
|
|
||||||
DPRINT("Creating thread for process\n");
|
DPRINT("Creating thread for process\n");
|
||||||
lpStartAddress = (LPTHREAD_START_ROUTINE)
|
lpStartAddress = (LPTHREAD_START_ROUTINE)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: proc.c,v 1.27 2000/01/20 22:56:49 ekohl Exp $
|
/* $Id: proc.c,v 1.28 2000/01/26 10:07:23 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -23,6 +23,30 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <kernel32/kernel32.h>
|
#include <kernel32/kernel32.h>
|
||||||
|
|
||||||
|
/* TYPES *********************************************************************/
|
||||||
|
/*
|
||||||
|
typedef struct _WSTARTUPINFO {
|
||||||
|
DWORD cb;
|
||||||
|
LPWSTR lpReserved;
|
||||||
|
LPWSTR lpDesktop;
|
||||||
|
LPWSTR lpTitle;
|
||||||
|
DWORD dwX;
|
||||||
|
DWORD dwY;
|
||||||
|
DWORD dwXSize;
|
||||||
|
DWORD dwYSize;
|
||||||
|
DWORD dwXCountChars;
|
||||||
|
DWORD dwYCountChars;
|
||||||
|
DWORD dwFillAttribute;
|
||||||
|
DWORD dwFlags;
|
||||||
|
WORD wShowWindow;
|
||||||
|
WORD cbReserved2;
|
||||||
|
LPBYTE lpReserved2;
|
||||||
|
HANDLE hStdInput;
|
||||||
|
HANDLE hStdOutput;
|
||||||
|
HANDLE hStdError;
|
||||||
|
} WSTARTUPINFO, *LPWSTARTUPINFO;
|
||||||
|
*/
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
WaitForInputIdleType lpfnGlobalRegisterWaitForInputIdle;
|
WaitForInputIdleType lpfnGlobalRegisterWaitForInputIdle;
|
||||||
|
@ -56,7 +80,7 @@ GetProcessTimes (
|
||||||
LPFILETIME lpUserTime
|
LPFILETIME lpUserTime
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DPRINT("GetProcessTimes is unimplemented\n");
|
dprintf("GetProcessTimes is unimplemented\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,9 +320,7 @@ GetStartupInfoW (
|
||||||
LPSTARTUPINFOW lpStartupInfo
|
LPSTARTUPINFOW lpStartupInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
PRTL_USER_PROCESS_PARAMETERS Params;
|
PPEB pPeb = NtCurrentPeb();
|
||||||
|
|
||||||
Params = NtCurrentPeb()->ProcessParameters;
|
|
||||||
|
|
||||||
if (lpStartupInfo == NULL)
|
if (lpStartupInfo == NULL)
|
||||||
{
|
{
|
||||||
|
@ -307,24 +329,24 @@ GetStartupInfoW (
|
||||||
}
|
}
|
||||||
|
|
||||||
lpStartupInfo->cb = sizeof(STARTUPINFOW);
|
lpStartupInfo->cb = sizeof(STARTUPINFOW);
|
||||||
wcscpy (lpStartupInfo->lpDesktop, Params->DesktopInfo.Buffer);
|
// lstrcpyW(lpStartupInfo->lpDesktop, pPeb->Ppb->Desktop);
|
||||||
wcscpy (lpStartupInfo->lpTitle, Params->WindowTitle.Buffer);
|
// lstrcpyW(lpStartupInfo->lpTitle, pPeb->Ppb->Title);
|
||||||
lpStartupInfo->dwX = Params->StartingX;
|
lpStartupInfo->dwX = pPeb->ProcessParameters->X;
|
||||||
lpStartupInfo->dwY = Params->StartingY;
|
lpStartupInfo->dwY = pPeb->ProcessParameters->Y;
|
||||||
lpStartupInfo->dwXSize = Params->CountX;
|
lpStartupInfo->dwXSize = pPeb->ProcessParameters->XSize;
|
||||||
lpStartupInfo->dwYSize = Params->CountY;
|
lpStartupInfo->dwYSize = pPeb->ProcessParameters->YSize;
|
||||||
lpStartupInfo->dwXCountChars = Params->CountCharsX;
|
lpStartupInfo->dwXCountChars = pPeb->ProcessParameters->XCountChars;
|
||||||
lpStartupInfo->dwYCountChars = Params->CountCharsY;
|
lpStartupInfo->dwYCountChars = pPeb->ProcessParameters->YCountChars;
|
||||||
lpStartupInfo->dwFillAttribute = Params->FillAttribute;
|
lpStartupInfo->dwFillAttribute = pPeb->ProcessParameters->FillAttribute;
|
||||||
lpStartupInfo->dwFlags = Params->WindowFlags;
|
lpStartupInfo->dwFlags = pPeb->ProcessParameters->Flags;
|
||||||
lpStartupInfo->wShowWindow = Params->ShowWindowFlags;
|
lpStartupInfo->wShowWindow = pPeb->ProcessParameters->ShowWindow;
|
||||||
wcscpy (lpStartupInfo->lpReserved, Params->ShellInfo.Buffer);
|
// lpStartupInfo->lpReserved = pPeb->ProcessParameters->lpReserved1;
|
||||||
// lpStartupInfo->cbReserved2 = Params->cbReserved;
|
// lpStartupInfo->cbReserved2 = pPeb->ProcessParameters->cbReserved;
|
||||||
// lpStartupInfo->lpReserved2 = Params->lpReserved2;
|
// lpStartupInfo->lpReserved2 = pPeb->ProcessParameters->lpReserved2;
|
||||||
|
|
||||||
lpStartupInfo->hStdInput = Params->StandardInput;
|
lpStartupInfo->hStdInput = pPeb->ProcessParameters->InputHandle;
|
||||||
lpStartupInfo->hStdOutput = Params->StandardOutput;
|
lpStartupInfo->hStdOutput = pPeb->ProcessParameters->OutputHandle;
|
||||||
lpStartupInfo->hStdError = Params->StandardError;
|
lpStartupInfo->hStdError = pPeb->ProcessParameters->ErrorHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -334,11 +356,9 @@ GetStartupInfoA (
|
||||||
LPSTARTUPINFOA lpStartupInfo
|
LPSTARTUPINFOA lpStartupInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
PRTL_USER_PROCESS_PARAMETERS Params;
|
PPEB pPeb = NtCurrentPeb();
|
||||||
ULONG i = 0;
|
ULONG i = 0;
|
||||||
|
|
||||||
Params = NtCurrentPeb()->ProcessParameters;
|
|
||||||
|
|
||||||
if (lpStartupInfo == NULL)
|
if (lpStartupInfo == NULL)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
@ -348,38 +368,38 @@ GetStartupInfoA (
|
||||||
lpStartupInfo->cb = sizeof(STARTUPINFOA);
|
lpStartupInfo->cb = sizeof(STARTUPINFOA);
|
||||||
#if 0
|
#if 0
|
||||||
i = 0;
|
i = 0;
|
||||||
while ((pPeb->Ppb->Desktop[i])!=0 && i < MAX_PATH)
|
while ((pPeb->ProcessParameters->Desktop[i])!=0 && i < MAX_PATH)
|
||||||
{
|
{
|
||||||
lpStartupInfo->lpDesktop[i] = (unsigned char)
|
lpStartupInfo->lpDesktop[i] = (unsigned char)
|
||||||
pPeb->Ppb->Desktop[i];
|
pPeb->ProcessParameters->Desktop[i];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
lpStartupInfo->lpDesktop[i] = 0;
|
lpStartupInfo->lpDesktop[i] = 0;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while ((pPeb->Ppb->Title[i])!=0 && i < MAX_PATH)
|
while ((pPeb->ProcessParameters->Title[i])!=0 && i < MAX_PATH)
|
||||||
{
|
{
|
||||||
lpStartupInfo->lpTitle[i] = (unsigned char)pPeb->ProcessParameters->Title[i];
|
lpStartupInfo->lpTitle[i] = (unsigned char)pPeb->ProcessParameters->Title[i];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
lpStartupInfo->lpTitle[i] = 0;
|
lpStartupInfo->lpTitle[i] = 0;
|
||||||
#endif
|
#endif
|
||||||
lpStartupInfo->dwX = Params->StartingX;
|
lpStartupInfo->dwX = pPeb->ProcessParameters->X;
|
||||||
lpStartupInfo->dwY = Params->StartingY;
|
lpStartupInfo->dwY = pPeb->ProcessParameters->Y;
|
||||||
lpStartupInfo->dwXSize = Params->CountX;
|
lpStartupInfo->dwXSize = pPeb->ProcessParameters->XSize;
|
||||||
lpStartupInfo->dwYSize = Params->CountY;
|
lpStartupInfo->dwYSize = pPeb->ProcessParameters->YSize;
|
||||||
lpStartupInfo->dwXCountChars = Params->CountCharsX;
|
lpStartupInfo->dwXCountChars = pPeb->ProcessParameters->XCountChars;
|
||||||
lpStartupInfo->dwYCountChars = Params->CountCharsY;
|
lpStartupInfo->dwYCountChars = pPeb->ProcessParameters->YCountChars;
|
||||||
lpStartupInfo->dwFillAttribute = Params->FillAttribute;
|
lpStartupInfo->dwFillAttribute = pPeb->ProcessParameters->FillAttribute;
|
||||||
lpStartupInfo->dwFlags = Params->WindowFlags;
|
lpStartupInfo->dwFlags = pPeb->ProcessParameters->Flags;
|
||||||
lpStartupInfo->wShowWindow = Params->ShowWindowFlags;
|
lpStartupInfo->wShowWindow = pPeb->ProcessParameters->ShowWindow;
|
||||||
// lpStartupInfo->cbReserved2 = Params->cbReserved;
|
// lpStartupInfo->cbReserved2 = pPeb->ProcessParameters->cbReserved;
|
||||||
// lpStartupInfo->lpReserved = Params->lpReserved1;
|
// lpStartupInfo->lpReserved = pPeb->ProcessParameters->lpReserved1;
|
||||||
// lpStartupInfo->lpReserved2 = Params->lpReserved2;
|
// lpStartupInfo->lpReserved2 = pPeb->ProcessParameters->lpReserved2;
|
||||||
|
|
||||||
lpStartupInfo->hStdInput = Params->StandardInput;
|
lpStartupInfo->hStdInput = pPeb->ProcessParameters->InputHandle;
|
||||||
lpStartupInfo->hStdOutput = Params->StandardOutput;
|
lpStartupInfo->hStdOutput = pPeb->ProcessParameters->OutputHandle;
|
||||||
lpStartupInfo->hStdError = Params->StandardError;
|
lpStartupInfo->hStdError = pPeb->ProcessParameters->ErrorHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
DWORD STDCALL TlsAlloc(VOID)
|
DWORD STDCALL TlsAlloc(VOID)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
DWORD dwTlsIndex = GetTeb()->dwTlsIndex;
|
DWORD dwTlsIndex = GetTeb()->dwTlsIndex;
|
||||||
void **TlsData = GetTeb()->TlsData;
|
void **TlsData = GetTeb()->TlsData;
|
||||||
|
|
||||||
|
@ -29,15 +30,19 @@ DWORD STDCALL TlsAlloc(VOID)
|
||||||
return (dwTlsIndex++);
|
return (dwTlsIndex++);
|
||||||
}
|
}
|
||||||
return (0xFFFFFFFFUL);
|
return (0xFFFFFFFFUL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
WINBOOL STDCALL TlsFree(DWORD dwTlsIndex)
|
WINBOOL STDCALL TlsFree(DWORD dwTlsIndex)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
LPVOID STDCALL TlsGetVlue(DWORD dwTlsIndex)
|
LPVOID STDCALL TlsGetVlue(DWORD dwTlsIndex)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
void **TlsData = GetTeb()->TlsData;
|
void **TlsData = GetTeb()->TlsData;
|
||||||
|
|
||||||
if (dwTlsIndex < (sizeof(TlsData) / sizeof(TlsData[0])))
|
if (dwTlsIndex < (sizeof(TlsData) / sizeof(TlsData[0])))
|
||||||
|
@ -47,10 +52,12 @@ LPVOID STDCALL TlsGetVlue(DWORD dwTlsIndex)
|
||||||
}
|
}
|
||||||
SetLastError(1);
|
SetLastError(1);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
WINBOOL STDCALL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
|
WINBOOL STDCALL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
void **TlsData = GetTeb()->TlsData;
|
void **TlsData = GetTeb()->TlsData;
|
||||||
|
|
||||||
if (dwTlsIndex < (sizeof(TlsData) / sizeof(TlsData[0])))
|
if (dwTlsIndex < (sizeof(TlsData) / sizeof(TlsData[0])))
|
||||||
|
@ -59,4 +66,5 @@ WINBOOL STDCALL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: process.c,v 1.8 2000/01/11 17:28:57 ekohl Exp $
|
/* $Id: process.c,v 1.9 2000/01/26 10:07:24 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -161,7 +161,7 @@ RtlpMapFile(PUNICODE_STRING ApplicationName,
|
||||||
*Section = NULL;
|
*Section = NULL;
|
||||||
|
|
||||||
|
|
||||||
DPRINT("ApplicationName %S\n", ApplicationName->Buffer);
|
DPRINT("ApplicationName %w\n", ApplicationName->Buffer);
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
ApplicationName,
|
ApplicationName,
|
||||||
|
@ -229,7 +229,7 @@ static NTSTATUS
|
||||||
RtlpCreatePpbAndPeb (
|
RtlpCreatePpbAndPeb (
|
||||||
PPEB *PebPtr,
|
PPEB *PebPtr,
|
||||||
HANDLE ProcessHandle,
|
HANDLE ProcessHandle,
|
||||||
PRTL_USER_PROCESS_PARAMETERS ProcessParameters)
|
PRTL_USER_PROCESS_PARAMETERS Ppb)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG BytesWritten;
|
ULONG BytesWritten;
|
||||||
|
@ -239,52 +239,48 @@ RtlpCreatePpbAndPeb (
|
||||||
PVOID PpbBase;
|
PVOID PpbBase;
|
||||||
ULONG PpbSize;
|
ULONG PpbSize;
|
||||||
|
|
||||||
/* create the process parameter block */
|
/* create the PPB */
|
||||||
PpbBase = (PVOID)PEB_STARTUPINFO;
|
PpbBase = (PVOID)PEB_STARTUPINFO;
|
||||||
PpbSize = ProcessParameters->MaximumLength;
|
PpbSize = Ppb->TotalSize;
|
||||||
Status = NtAllocateVirtualMemory (
|
Status = NtAllocateVirtualMemory (ProcessHandle,
|
||||||
ProcessHandle,
|
&PpbBase,
|
||||||
&PpbBase,
|
0,
|
||||||
0,
|
&PpbSize,
|
||||||
&PpbSize,
|
MEM_COMMIT,
|
||||||
MEM_COMMIT,
|
PAGE_READWRITE);
|
||||||
PAGE_READWRITE);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
return(Status);
|
return(Status);
|
||||||
|
|
||||||
DPRINT("Ppb size %x\n", PpbSize);
|
DPRINT("Ppb size %x\n", PpbSize);
|
||||||
NtWriteVirtualMemory (
|
NtWriteVirtualMemory (ProcessHandle,
|
||||||
ProcessHandle,
|
PpbBase,
|
||||||
PpbBase,
|
Ppb,
|
||||||
ProcessParameters,
|
Ppb->TotalSize,
|
||||||
ProcessParameters->MaximumLength,
|
&BytesWritten);
|
||||||
&BytesWritten);
|
|
||||||
|
/* create the PEB */
|
||||||
/* create the PEB */
|
PebBase = (PVOID)PEB_BASE;
|
||||||
PebBase = (PVOID)PEB_BASE;
|
PebSize = 0x1000;
|
||||||
PebSize = 0x1000;
|
Status = NtAllocateVirtualMemory (ProcessHandle,
|
||||||
Status = NtAllocateVirtualMemory (
|
&PebBase,
|
||||||
ProcessHandle,
|
0,
|
||||||
&PebBase,
|
&PebSize,
|
||||||
0,
|
MEM_COMMIT,
|
||||||
&PebSize,
|
PAGE_READWRITE);
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE);
|
memset (&Peb, 0, sizeof(PEB));
|
||||||
|
Peb.ProcessParameters = (PRTL_USER_PROCESS_PARAMETERS)PpbBase;
|
||||||
memset (&Peb, 0, sizeof(PEB));
|
|
||||||
Peb.ProcessParameters = (PRTL_USER_PROCESS_PARAMETERS)PpbBase;
|
NtWriteVirtualMemory (ProcessHandle,
|
||||||
|
PebBase,
|
||||||
NtWriteVirtualMemory (
|
&Peb,
|
||||||
ProcessHandle,
|
sizeof(PEB),
|
||||||
PebBase,
|
&BytesWritten);
|
||||||
&Peb,
|
|
||||||
sizeof(PEB),
|
*PebPtr = (PPEB)PebBase;
|
||||||
&BytesWritten);
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
*PebPtr = (PPEB)PebBase;
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -293,7 +289,7 @@ STDCALL
|
||||||
RtlCreateUserProcess (
|
RtlCreateUserProcess (
|
||||||
PUNICODE_STRING CommandLine,
|
PUNICODE_STRING CommandLine,
|
||||||
ULONG Unknown1,
|
ULONG Unknown1,
|
||||||
PRTL_USER_PROCESS_PARAMETERS Params,
|
PRTL_USER_PROCESS_PARAMETERS Ppb,
|
||||||
PSECURITY_DESCRIPTOR ProcessSd,
|
PSECURITY_DESCRIPTOR ProcessSd,
|
||||||
PSECURITY_DESCRIPTOR ThreadSd,
|
PSECURITY_DESCRIPTOR ThreadSd,
|
||||||
WINBOOL bInheritHandles,
|
WINBOOL bInheritHandles,
|
||||||
|
@ -316,7 +312,7 @@ RtlCreateUserProcess (
|
||||||
ULONG retlen;
|
ULONG retlen;
|
||||||
PPEB Peb;
|
PPEB Peb;
|
||||||
|
|
||||||
DPRINT ("RtlCreateUserProcess(CommandLine '%S')\n",
|
DPRINT ("RtlCreateUserProcess(CommandLine '%w')\n",
|
||||||
CommandLine->Buffer);
|
CommandLine->Buffer);
|
||||||
|
|
||||||
Status = RtlpMapFile(CommandLine,
|
Status = RtlpMapFile(CommandLine,
|
||||||
|
@ -340,7 +336,7 @@ RtlCreateUserProcess (
|
||||||
&retlen);
|
&retlen);
|
||||||
DPRINT("ProcessBasicInfo.UniqueProcessId %d\n",
|
DPRINT("ProcessBasicInfo.UniqueProcessId %d\n",
|
||||||
ProcessBasicInfo.UniqueProcessId);
|
ProcessBasicInfo.UniqueProcessId);
|
||||||
LocalClientId.UniqueProcess = (HANDLE)ProcessBasicInfo.UniqueProcessId;
|
LocalClientId.UniqueProcess = ProcessBasicInfo.UniqueProcessId;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map NT DLL into the process
|
* Map NT DLL into the process
|
||||||
|
@ -370,7 +366,7 @@ RtlCreateUserProcess (
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
DPRINT("Creating PPB and PEB\n");
|
DPRINT("Creating PPB and PEB\n");
|
||||||
RtlpCreatePpbAndPeb (&Peb, hProcess, Params);
|
RtlpCreatePpbAndPeb (&Peb, hProcess, Ppb);
|
||||||
|
|
||||||
DPRINT("Creating thread for process\n");
|
DPRINT("Creating thread for process\n");
|
||||||
lpStartAddress = (LPTHREAD_START_ROUTINE)
|
lpStartAddress = (LPTHREAD_START_ROUTINE)
|
||||||
|
@ -384,7 +380,7 @@ RtlCreateUserProcess (
|
||||||
lpStartAddress,
|
lpStartAddress,
|
||||||
Peb,
|
Peb,
|
||||||
dwCreationFlags,
|
dwCreationFlags,
|
||||||
(LPDWORD)&LocalClientId.UniqueThread,
|
&LocalClientId.UniqueThread,
|
||||||
NTDllSection,
|
NTDllSection,
|
||||||
hSection,
|
hSection,
|
||||||
(PVOID)Headers.OptionalHeader.ImageBase);
|
(PVOID)Headers.OptionalHeader.ImageBase);
|
||||||
|
@ -407,16 +403,14 @@ RtlCreateUserProcess (
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
|
||||||
STDCALL
|
VOID STDCALL RtlAcquirePebLock(VOID)
|
||||||
RtlAcquirePebLock (VOID)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
|
||||||
STDCALL
|
VOID STDCALL RtlReleasePebLock(VOID)
|
||||||
RtlReleasePebLock (VOID)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -424,20 +418,20 @@ RtlReleasePebLock (VOID)
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
STDCALL
|
STDCALL
|
||||||
RtlCreateProcessParameters (
|
RtlCreateProcessParameters (
|
||||||
PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
|
PRTL_USER_PROCESS_PARAMETERS *Ppb,
|
||||||
PUNICODE_STRING CommandLine,
|
PUNICODE_STRING CommandLine,
|
||||||
PUNICODE_STRING DllPath,
|
PUNICODE_STRING LibraryPath,
|
||||||
PUNICODE_STRING CurrentDirectory,
|
PUNICODE_STRING CurrentDirectory,
|
||||||
PUNICODE_STRING ImagePathName,
|
PUNICODE_STRING ImageName,
|
||||||
PVOID Environment,
|
PVOID Environment,
|
||||||
PUNICODE_STRING WindowTitle,
|
PUNICODE_STRING Title,
|
||||||
PUNICODE_STRING DesktopInfo,
|
PUNICODE_STRING Desktop,
|
||||||
PUNICODE_STRING ShellInfo,
|
PUNICODE_STRING Reserved,
|
||||||
PVOID Reserved2
|
PVOID Reserved2
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
PRTL_USER_PROCESS_PARAMETERS Params = NULL;
|
PRTL_USER_PROCESS_PARAMETERS Param = NULL;
|
||||||
ULONG RegionSize = 0;
|
ULONG RegionSize = 0;
|
||||||
ULONG DataSize = 0;
|
ULONG DataSize = 0;
|
||||||
PWCHAR Dest;
|
PWCHAR Dest;
|
||||||
|
@ -449,34 +443,37 @@ RtlCreateProcessParameters (
|
||||||
/* size of process parameter block */
|
/* size of process parameter block */
|
||||||
DataSize = sizeof (RTL_USER_PROCESS_PARAMETERS);
|
DataSize = sizeof (RTL_USER_PROCESS_PARAMETERS);
|
||||||
|
|
||||||
|
/* size of (reserved) buffer */
|
||||||
|
DataSize += (256 * sizeof(WCHAR));
|
||||||
|
|
||||||
/* size of current directory buffer */
|
/* size of current directory buffer */
|
||||||
DataSize += (MAX_PATH * sizeof(WCHAR));
|
DataSize += (MAX_PATH * sizeof(WCHAR));
|
||||||
|
|
||||||
/* add string lengths */
|
/* add string lengths */
|
||||||
if (DllPath != NULL)
|
if (LibraryPath != NULL)
|
||||||
DataSize += (DllPath->Length + sizeof(WCHAR));
|
DataSize += (LibraryPath->Length + sizeof(WCHAR));
|
||||||
|
|
||||||
if (ImagePathName != NULL)
|
|
||||||
DataSize += (ImagePathName->Length + sizeof(WCHAR));
|
|
||||||
|
|
||||||
if (CommandLine != NULL)
|
if (CommandLine != NULL)
|
||||||
DataSize += (CommandLine->Length + sizeof(WCHAR));
|
DataSize += (CommandLine->Length + sizeof(WCHAR));
|
||||||
|
|
||||||
if (WindowTitle != NULL)
|
if (ImageName != NULL)
|
||||||
DataSize += (WindowTitle->Length + sizeof(WCHAR));
|
DataSize += (ImageName->Length + sizeof(WCHAR));
|
||||||
|
|
||||||
if (DesktopInfo != NULL)
|
if (Title != NULL)
|
||||||
DataSize += (DesktopInfo->Length + sizeof(WCHAR));
|
DataSize += (Title->Length + sizeof(WCHAR));
|
||||||
|
|
||||||
if (ShellInfo != NULL)
|
if (Desktop != NULL)
|
||||||
DataSize += (ShellInfo->Length + sizeof(WCHAR));
|
DataSize += (Desktop->Length + sizeof(WCHAR));
|
||||||
|
|
||||||
|
if (Reserved != NULL)
|
||||||
|
DataSize += (Reserved->Length + sizeof(WCHAR));
|
||||||
|
|
||||||
/* Calculate the required block size */
|
/* Calculate the required block size */
|
||||||
RegionSize = ROUNDUP(DataSize, PAGESIZE);
|
RegionSize = ROUNDUP(DataSize, PAGESIZE);
|
||||||
|
|
||||||
Status = NtAllocateVirtualMemory (
|
Status = NtAllocateVirtualMemory (
|
||||||
NtCurrentProcess (),
|
NtCurrentProcess (),
|
||||||
(PVOID*)&Params,
|
(PVOID*)&Param,
|
||||||
0,
|
0,
|
||||||
&RegionSize,
|
&RegionSize,
|
||||||
MEM_COMMIT,
|
MEM_COMMIT,
|
||||||
|
@ -487,153 +484,124 @@ RtlCreateProcessParameters (
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT ("Process parameter block allocated\n");
|
DPRINT ("Ppb allocated\n");
|
||||||
|
|
||||||
Params->MaximumLength = RegionSize;
|
Param->TotalSize = RegionSize;
|
||||||
Params->Length = DataSize;
|
Param->DataSize = DataSize;
|
||||||
Params->Flags = TRUE;
|
Param->Flags = TRUE;
|
||||||
Params->Environment = Environment;
|
Param->Environment = Environment;
|
||||||
// Params->Unknown1 =
|
// Param->Unknown1 =
|
||||||
// Params->Unknown2 =
|
// Param->Unknown2 =
|
||||||
// Params->Unknown3 =
|
// Param->Unknown3 =
|
||||||
// Params->Unknown4 =
|
// Param->Unknown4 =
|
||||||
|
|
||||||
/* copy current directory */
|
/* copy current directory */
|
||||||
Dest = (PWCHAR)(((PBYTE)Params) +
|
Dest = (PWCHAR)(((PBYTE)Param) +
|
||||||
sizeof(RTL_USER_PROCESS_PARAMETERS));
|
sizeof(RTL_USER_PROCESS_PARAMETERS) +
|
||||||
|
(256 * sizeof(WCHAR)));
|
||||||
|
|
||||||
Params->CurrentDirectory.DosPath.Buffer = Dest;
|
Param->CurrentDirectory.DosPath.Buffer = Dest;
|
||||||
if (CurrentDirectory != NULL)
|
if (CurrentDirectory != NULL)
|
||||||
{
|
{
|
||||||
Params->CurrentDirectory.DosPath.Length =
|
Param->CurrentDirectory.DosPath.Length = CurrentDirectory->Length;
|
||||||
CurrentDirectory->Length;
|
Param->CurrentDirectory.DosPath.MaximumLength =
|
||||||
Params->CurrentDirectory.DosPath.MaximumLength =
|
CurrentDirectory->Length + sizeof(WCHAR);
|
||||||
CurrentDirectory->Length + sizeof(WCHAR);
|
memcpy(Dest,
|
||||||
|
CurrentDirectory->Buffer,
|
||||||
|
CurrentDirectory->Length);
|
||||||
|
Dest = (PWCHAR)(((PBYTE)Dest) + CurrentDirectory->Length);
|
||||||
|
}
|
||||||
|
*Dest = 0;
|
||||||
|
|
||||||
|
Dest = (PWCHAR)(((PBYTE)Param) + sizeof(RTL_USER_PROCESS_PARAMETERS) +
|
||||||
|
(256 * sizeof(WCHAR)) + (MAX_PATH * sizeof(WCHAR)));
|
||||||
|
|
||||||
|
/* copy library path */
|
||||||
|
Param->LibraryPath.Buffer = Dest;
|
||||||
|
if (LibraryPath != NULL)
|
||||||
|
{
|
||||||
|
Param->LibraryPath.Length = LibraryPath->Length;
|
||||||
|
memcpy (Dest,
|
||||||
|
LibraryPath->Buffer,
|
||||||
|
LibraryPath->Length);
|
||||||
|
Dest = (PWCHAR)(((PBYTE)Dest) + LibraryPath->Length);
|
||||||
|
}
|
||||||
|
Param->LibraryPath.MaximumLength = Param->LibraryPath.Length +
|
||||||
|
sizeof(WCHAR);
|
||||||
|
*Dest = 0;
|
||||||
|
Dest++;
|
||||||
|
|
||||||
|
/* copy command line */
|
||||||
|
Param->CommandLine.Buffer = Dest;
|
||||||
|
if (CommandLine != NULL)
|
||||||
|
{
|
||||||
|
Param->CommandLine.Length = CommandLine->Length;
|
||||||
|
memcpy (Dest,
|
||||||
|
CommandLine->Buffer,
|
||||||
|
CommandLine->Length);
|
||||||
|
Dest = (PWCHAR)(((PBYTE)Dest) + CommandLine->Length);
|
||||||
|
}
|
||||||
|
Param->CommandLine.MaximumLength = Param->CommandLine.Length + sizeof(WCHAR);
|
||||||
|
*Dest = 0;
|
||||||
|
Dest++;
|
||||||
|
|
||||||
|
/* copy image name */
|
||||||
|
Param->ImageName.Buffer = Dest;
|
||||||
|
if (ImageName != NULL)
|
||||||
|
{
|
||||||
|
Param->ImageName.Length = ImageName->Length;
|
||||||
memcpy (Dest,
|
memcpy (Dest,
|
||||||
CurrentDirectory->Buffer,
|
ImageName->Buffer,
|
||||||
CurrentDirectory->Length);
|
ImageName->Length);
|
||||||
Dest = (PWCHAR)(((PBYTE)Dest) + CurrentDirectory->Length);
|
Dest = (PWCHAR)(((PBYTE)Dest) + ImageName->Length);
|
||||||
}
|
}
|
||||||
*Dest = 0;
|
Param->ImageName.MaximumLength = Param->ImageName.Length + sizeof(WCHAR);
|
||||||
|
*Dest = 0;
|
||||||
|
Dest++;
|
||||||
|
|
||||||
Dest = (PWCHAR)(((PBYTE)Params) +
|
/* copy title */
|
||||||
sizeof(RTL_USER_PROCESS_PARAMETERS) +
|
Param->Title.Buffer = Dest;
|
||||||
(MAX_PATH * sizeof(WCHAR)));
|
if (Title != NULL)
|
||||||
|
|
||||||
/* copy dll path */
|
|
||||||
Params->DllPath.Buffer = Dest;
|
|
||||||
if (DllPath != NULL)
|
|
||||||
{
|
{
|
||||||
Params->DllPath.Length = DllPath->Length;
|
Param->Title.Length = Title->Length;
|
||||||
memcpy (Dest,
|
memcpy (Dest,
|
||||||
DllPath->Buffer,
|
Title->Buffer,
|
||||||
DllPath->Length);
|
Title->Length);
|
||||||
Dest = (PWCHAR)(((PBYTE)Dest) + DllPath->Length);
|
Dest = (PWCHAR)(((PBYTE)Dest) + Title->Length);
|
||||||
}
|
}
|
||||||
Params->DllPath.MaximumLength =
|
Param->Title.MaximumLength = Param->Title.Length + sizeof(WCHAR);
|
||||||
Params->DllPath.Length + sizeof(WCHAR);
|
|
||||||
*Dest = 0;
|
*Dest = 0;
|
||||||
Dest++;
|
Dest++;
|
||||||
|
|
||||||
/* copy image path name */
|
/* copy desktop */
|
||||||
Params->ImagePathName.Buffer = Dest;
|
Param->Desktop.Buffer = Dest;
|
||||||
if (ImagePathName != NULL)
|
if (Desktop != NULL)
|
||||||
{
|
{
|
||||||
Params->ImagePathName.Length = ImagePathName->Length;
|
Param->Desktop.Length = Desktop->Length;
|
||||||
memcpy (Dest,
|
memcpy (Dest,
|
||||||
ImagePathName->Buffer,
|
Desktop->Buffer,
|
||||||
ImagePathName->Length);
|
Desktop->Length);
|
||||||
Dest = (PWCHAR)(((PBYTE)Dest) + ImagePathName->Length);
|
Dest = (PWCHAR)(((PBYTE)Dest) + Desktop->Length);
|
||||||
}
|
}
|
||||||
Params->ImagePathName.MaximumLength =
|
Param->Desktop.MaximumLength = Param->Desktop.Length + sizeof(WCHAR);
|
||||||
Params->ImagePathName.Length + sizeof(WCHAR);
|
*Dest = 0;
|
||||||
*Dest = 0;
|
Dest++;
|
||||||
Dest++;
|
|
||||||
|
RtlDeNormalizeProcessParams (Param);
|
||||||
/* copy command line */
|
*Ppb = Param;
|
||||||
Params->CommandLine.Buffer = Dest;
|
RtlReleasePebLock ();
|
||||||
if (CommandLine != NULL)
|
|
||||||
{
|
return(Status);
|
||||||
Params->CommandLine.Length = CommandLine->Length;
|
|
||||||
memcpy (Dest,
|
|
||||||
CommandLine->Buffer,
|
|
||||||
CommandLine->Length);
|
|
||||||
Dest = (PWCHAR)(((PBYTE)Dest) + CommandLine->Length);
|
|
||||||
}
|
|
||||||
Params->CommandLine.MaximumLength =
|
|
||||||
Params->CommandLine.Length + sizeof(WCHAR);
|
|
||||||
*Dest = 0;
|
|
||||||
Dest++;
|
|
||||||
|
|
||||||
/* copy window title */
|
|
||||||
Params->WindowTitle.Buffer = Dest;
|
|
||||||
if (WindowTitle != NULL)
|
|
||||||
{
|
|
||||||
Params->WindowTitle.Length = WindowTitle->Length;
|
|
||||||
memcpy (Dest,
|
|
||||||
WindowTitle->Buffer,
|
|
||||||
WindowTitle->Length);
|
|
||||||
Dest = (PWCHAR)(((PBYTE)Dest) + WindowTitle->Length);
|
|
||||||
}
|
|
||||||
Params->WindowTitle.MaximumLength =
|
|
||||||
Params->WindowTitle.Length + sizeof(WCHAR);
|
|
||||||
*Dest = 0;
|
|
||||||
Dest++;
|
|
||||||
|
|
||||||
/* copy desktop info */
|
|
||||||
Params->DesktopInfo.Buffer = Dest;
|
|
||||||
if (DesktopInfo != NULL)
|
|
||||||
{
|
|
||||||
Params->DesktopInfo.Length = DesktopInfo->Length;
|
|
||||||
memcpy (Dest,
|
|
||||||
DesktopInfo->Buffer,
|
|
||||||
DesktopInfo->Length);
|
|
||||||
Dest = (PWCHAR)(((PBYTE)Dest) + DesktopInfo->Length);
|
|
||||||
}
|
|
||||||
Params->DesktopInfo.MaximumLength =
|
|
||||||
Params->DesktopInfo.Length + sizeof(WCHAR);
|
|
||||||
*Dest = 0;
|
|
||||||
Dest++;
|
|
||||||
|
|
||||||
/* copy shell info */
|
|
||||||
Params->ShellInfo.Buffer = Dest;
|
|
||||||
if (ShellInfo != NULL)
|
|
||||||
{
|
|
||||||
Params->ShellInfo.Length = ShellInfo->Length;
|
|
||||||
memcpy (Dest,
|
|
||||||
ShellInfo->Buffer,
|
|
||||||
ShellInfo->Length);
|
|
||||||
Dest = (PWCHAR)(((PBYTE)Dest) + ShellInfo->Length);
|
|
||||||
}
|
|
||||||
Params->ShellInfo.MaximumLength =
|
|
||||||
Params->ShellInfo.Length + sizeof(WCHAR);
|
|
||||||
*Dest = 0;
|
|
||||||
Dest++;
|
|
||||||
|
|
||||||
/* set runtime data */
|
|
||||||
Params->RuntimeData.Length = 0;
|
|
||||||
Params->RuntimeData.MaximumLength = 0;
|
|
||||||
Params->RuntimeData.Buffer = NULL;
|
|
||||||
|
|
||||||
RtlDeNormalizeProcessParams (Params);
|
|
||||||
*ProcessParameters = Params;
|
|
||||||
RtlReleasePebLock ();
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID STDCALL RtlDestroyProcessParameters (PRTL_USER_PROCESS_PARAMETERS Ppb)
|
||||||
STDCALL
|
|
||||||
RtlDestroyProcessParameters (
|
|
||||||
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
ULONG RegionSize = 0;
|
ULONG RegionSize = 0;
|
||||||
|
|
||||||
NtFreeVirtualMemory (NtCurrentProcess (),
|
NtFreeVirtualMemory (NtCurrentProcess (),
|
||||||
(PVOID)ProcessParameters,
|
(PVOID)Ppb,
|
||||||
&RegionSize,
|
&RegionSize,
|
||||||
MEM_RELEASE);
|
MEM_RELEASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -642,132 +610,114 @@ RtlDestroyProcessParameters (
|
||||||
VOID
|
VOID
|
||||||
STDCALL
|
STDCALL
|
||||||
RtlDeNormalizeProcessParams (
|
RtlDeNormalizeProcessParams (
|
||||||
PRTL_USER_PROCESS_PARAMETERS Params
|
PRTL_USER_PROCESS_PARAMETERS Ppb
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (Params == NULL)
|
if (Ppb == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Params->Flags == FALSE)
|
if (Ppb->Flags == FALSE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Params->CurrentDirectory.DosPath.Buffer != NULL)
|
if (Ppb->CurrentDirectory.DosPath.Buffer != NULL)
|
||||||
{
|
{
|
||||||
Params->CurrentDirectory.DosPath.Buffer =
|
Ppb->CurrentDirectory.DosPath.Buffer =
|
||||||
(PWSTR)((ULONG)Params->CurrentDirectory.DosPath.Buffer -
|
(PWSTR)((ULONG)Ppb->CurrentDirectory.DosPath.Buffer -
|
||||||
(ULONG)Params);
|
(ULONG)Ppb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Params->DllPath.Buffer != NULL)
|
if (Ppb->LibraryPath.Buffer != NULL)
|
||||||
{
|
{
|
||||||
Params->DllPath.Buffer =
|
Ppb->LibraryPath.Buffer =
|
||||||
(PWSTR)((ULONG)Params->DllPath.Buffer -
|
(PWSTR)((ULONG)Ppb->LibraryPath.Buffer -
|
||||||
(ULONG)Params);
|
(ULONG)Ppb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Params->ImagePathName.Buffer != NULL)
|
if (Ppb->CommandLine.Buffer != NULL)
|
||||||
{
|
{
|
||||||
Params->ImagePathName.Buffer =
|
Ppb->CommandLine.Buffer =
|
||||||
(PWSTR)((ULONG)Params->ImagePathName.Buffer -
|
(PWSTR)((ULONG)Ppb->CommandLine.Buffer -
|
||||||
(ULONG)Params);
|
(ULONG)Ppb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Params->CommandLine.Buffer != NULL)
|
if (Ppb->ImageName.Buffer != NULL)
|
||||||
{
|
{
|
||||||
Params->CommandLine.Buffer =
|
Ppb->ImageName.Buffer =
|
||||||
(PWSTR)((ULONG)Params->CommandLine.Buffer -
|
(PWSTR)((ULONG)Ppb->ImageName.Buffer -
|
||||||
(ULONG)Params);
|
(ULONG)Ppb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Params->WindowTitle.Buffer != NULL)
|
if (Ppb->Title.Buffer != NULL)
|
||||||
{
|
{
|
||||||
Params->WindowTitle.Buffer =
|
Ppb->Title.Buffer =
|
||||||
(PWSTR)((ULONG)Params->WindowTitle.Buffer -
|
(PWSTR)((ULONG)Ppb->Title.Buffer -
|
||||||
(ULONG)Params);
|
(ULONG)Ppb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Params->DesktopInfo.Buffer != NULL)
|
if (Ppb->Desktop.Buffer != NULL)
|
||||||
{
|
{
|
||||||
Params->DesktopInfo.Buffer =
|
Ppb->Desktop.Buffer =
|
||||||
(PWSTR)((ULONG)Params->DesktopInfo.Buffer -
|
(PWSTR)((ULONG)Ppb->Desktop.Buffer -
|
||||||
(ULONG)Params);
|
(ULONG)Ppb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Params->ShellInfo.Buffer != NULL)
|
Ppb->Flags = FALSE;
|
||||||
{
|
|
||||||
Params->ShellInfo.Buffer =
|
|
||||||
(PWSTR)((ULONG)Params->ShellInfo.Buffer -
|
|
||||||
(ULONG)Params);
|
|
||||||
}
|
|
||||||
|
|
||||||
Params->Flags = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* normalize process parameters (Offset-->Pointer)
|
* normalize process parameters (Offset-->Pointer)
|
||||||
*/
|
*/
|
||||||
VOID
|
VOID STDCALL RtlNormalizeProcessParams (PRTL_USER_PROCESS_PARAMETERS Ppb)
|
||||||
STDCALL
|
|
||||||
RtlNormalizeProcessParams (
|
|
||||||
PRTL_USER_PROCESS_PARAMETERS Params
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (Params == NULL)
|
if (Ppb == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (Ppb->Flags == TRUE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Ppb->CurrentDirectory.DosPath.Buffer != NULL)
|
||||||
|
{
|
||||||
|
Ppb->CurrentDirectory.DosPath.Buffer =
|
||||||
|
(PWSTR)((ULONG)Ppb->CurrentDirectory.DosPath.Buffer +
|
||||||
|
(ULONG)Ppb);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Ppb->LibraryPath.Buffer != NULL)
|
||||||
|
{
|
||||||
|
Ppb->LibraryPath.Buffer =
|
||||||
|
(PWSTR)((ULONG)Ppb->LibraryPath.Buffer +
|
||||||
|
(ULONG)Ppb);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Ppb->CommandLine.Buffer != NULL)
|
||||||
|
{
|
||||||
|
Ppb->CommandLine.Buffer =
|
||||||
|
(PWSTR)((ULONG)Ppb->CommandLine.Buffer +
|
||||||
|
(ULONG)Ppb);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Ppb->ImageName.Buffer != NULL)
|
||||||
|
{
|
||||||
|
Ppb->ImageName.Buffer =
|
||||||
|
(PWSTR)((ULONG)Ppb->ImageName.Buffer +
|
||||||
|
(ULONG)Ppb);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Ppb->Title.Buffer != NULL)
|
||||||
|
{
|
||||||
|
Ppb->Title.Buffer =
|
||||||
|
(PWSTR)((ULONG)Ppb->Title.Buffer +
|
||||||
|
(ULONG)Ppb);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Ppb->Desktop.Buffer != NULL)
|
||||||
|
{
|
||||||
|
Ppb->Desktop.Buffer =
|
||||||
|
(PWSTR)((ULONG)Ppb->Desktop.Buffer +
|
||||||
|
(ULONG)Ppb);
|
||||||
|
}
|
||||||
|
|
||||||
if (Params->Flags == TRUE) // & PPF_NORMALIZED
|
Ppb->Flags = TRUE;
|
||||||
return;
|
|
||||||
|
|
||||||
if (Params->CurrentDirectory.DosPath.Buffer != NULL)
|
|
||||||
{
|
|
||||||
Params->CurrentDirectory.DosPath.Buffer =
|
|
||||||
(PWSTR)((ULONG)Params->CurrentDirectory.DosPath.Buffer +
|
|
||||||
(ULONG)Params);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Params->DllPath.Buffer != NULL)
|
|
||||||
{
|
|
||||||
Params->DllPath.Buffer =
|
|
||||||
(PWSTR)((ULONG)Params->DllPath.Buffer +
|
|
||||||
(ULONG)Params);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Params->ImagePathName.Buffer != NULL)
|
|
||||||
{
|
|
||||||
Params->ImagePathName.Buffer =
|
|
||||||
(PWSTR)((ULONG)Params->ImagePathName.Buffer +
|
|
||||||
(ULONG)Params);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Params->CommandLine.Buffer != NULL)
|
|
||||||
{
|
|
||||||
Params->CommandLine.Buffer =
|
|
||||||
(PWSTR)((ULONG)Params->CommandLine.Buffer +
|
|
||||||
(ULONG)Params);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Params->WindowTitle.Buffer != NULL)
|
|
||||||
{
|
|
||||||
Params->WindowTitle.Buffer =
|
|
||||||
(PWSTR)((ULONG)Params->WindowTitle.Buffer +
|
|
||||||
(ULONG)Params);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Params->DesktopInfo.Buffer != NULL)
|
|
||||||
{
|
|
||||||
Params->DesktopInfo.Buffer =
|
|
||||||
(PWSTR)((ULONG)Params->DesktopInfo.Buffer +
|
|
||||||
(ULONG)Params);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Params->ShellInfo.Buffer != NULL)
|
|
||||||
{
|
|
||||||
Params->ShellInfo.Buffer =
|
|
||||||
(PWSTR)((ULONG)Params->ShellInfo.Buffer +
|
|
||||||
(ULONG)Params);
|
|
||||||
}
|
|
||||||
|
|
||||||
Params->Flags = TRUE; // |= PPF_NORMALIZED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -11,10 +11,13 @@ KERNEL_BASE equ 0c0000000h
|
||||||
;
|
;
|
||||||
; Segment selectors
|
; Segment selectors
|
||||||
;
|
;
|
||||||
USER_CS equ 08h
|
;USER_CS equ 08h
|
||||||
USER_DS equ 010h
|
;USER_DS equ 010h
|
||||||
KERNEL_CS equ 020h
|
;KERNEL_CS equ 020h
|
||||||
KERNEL_DS equ 028h
|
;KERNEL_DS equ 028h
|
||||||
|
|
||||||
|
KERNEL_CS equ 08h
|
||||||
|
KERNEL_DS equ 010h
|
||||||
|
|
||||||
;
|
;
|
||||||
; Space reserved in the gdt for tss descriptors
|
; Space reserved in the gdt for tss descriptors
|
||||||
|
@ -850,7 +853,7 @@ empty_8042:
|
||||||
align 8
|
align 8
|
||||||
gdt_descr:
|
gdt_descr:
|
||||||
gdt_limit:
|
gdt_limit:
|
||||||
dw (((6+NR_TASKS)*8)-1)
|
dw (3*8)-1
|
||||||
gdt_base:
|
gdt_base:
|
||||||
dd gdt
|
dd gdt
|
||||||
|
|
||||||
|
@ -1122,20 +1125,20 @@ gdt:
|
||||||
dw 0
|
dw 0
|
||||||
dw 0
|
dw 0
|
||||||
|
|
||||||
dw 00000h ; User code descriptor
|
;dw 00000h ; User code descriptor
|
||||||
dw 00000h ; base: 0h limit: 3gb
|
;dw 00000h ; base: 0h limit: 3gb
|
||||||
dw 0fa00h
|
;dw 0fa00h
|
||||||
dw 000cch
|
;dw 000cch
|
||||||
|
|
||||||
dw 00000h ; User data descriptor
|
;dw 00000h ; User data descriptor
|
||||||
dw 00000h ; base: 0h limit: 3gb
|
;dw 00000h ; base: 0h limit: 3gb
|
||||||
dw 0f200h
|
;dw 0f200h
|
||||||
dw 000cch
|
;dw 000cch
|
||||||
|
|
||||||
dw 00000h
|
;dw 00000h
|
||||||
dw 00000h
|
;dw 00000h
|
||||||
dw 00000h
|
;dw 00000h
|
||||||
dw 00000h
|
;dw 00000h
|
||||||
|
|
||||||
dw 0ffffh ; Kernel code descriptor
|
dw 0ffffh ; Kernel code descriptor
|
||||||
dw 00000h ;
|
dw 00000h ;
|
||||||
|
@ -1148,7 +1151,7 @@ gdt:
|
||||||
dw 000cfh
|
dw 000cfh
|
||||||
|
|
||||||
|
|
||||||
times NR_TASKS*8 db 0
|
;times NR_TASKS*8 db 0
|
||||||
|
|
||||||
_end:
|
_end:
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,9 @@
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
VOID
|
VOID ExInit (VOID)
|
||||||
ExInit (VOID)
|
|
||||||
{
|
{
|
||||||
ExInitTimeZoneInfo ();
|
ExInitTimeZoneInfo();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -12,11 +12,17 @@
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
#include <internal/ps.h>
|
||||||
|
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* DEFINES *******************************************************************/
|
||||||
|
|
||||||
|
#define NUMBER_OF_WORKER_THREADS (5)
|
||||||
|
|
||||||
/* TYPES *********************************************************************/
|
/* TYPES *********************************************************************/
|
||||||
|
|
||||||
typedef struct
|
typedef struct _WORK_QUEUE
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* PURPOSE: Head of the list of waiting work items
|
* PURPOSE: Head of the list of waiting work items
|
||||||
|
@ -31,12 +37,12 @@ typedef struct
|
||||||
/*
|
/*
|
||||||
* PURPOSE: Worker threads with nothing to do wait on this event
|
* PURPOSE: Worker threads with nothing to do wait on this event
|
||||||
*/
|
*/
|
||||||
KEVENT Busy;
|
KSEMAPHORE Sem;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PURPOSE: Thread associated with work queue
|
* PURPOSE: Thread associated with work queue
|
||||||
*/
|
*/
|
||||||
HANDLE Thread;
|
HANDLE Thread[NUMBER_OF_WORKER_THREADS];
|
||||||
} WORK_QUEUE, *PWORK_QUEUE;
|
} WORK_QUEUE, *PWORK_QUEUE;
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
@ -44,9 +50,11 @@ typedef struct
|
||||||
/*
|
/*
|
||||||
* PURPOSE: Queue of items waiting to be processed at normal priority
|
* PURPOSE: Queue of items waiting to be processed at normal priority
|
||||||
*/
|
*/
|
||||||
WORK_QUEUE normal_work_queue = {{0,}};
|
WORK_QUEUE EiNormalWorkQueue;
|
||||||
|
|
||||||
#define WAIT_INTERVAL (0)
|
WORK_QUEUE EiCriticalWorkQueue;
|
||||||
|
|
||||||
|
WORK_QUEUE EiHyperCriticalWorkQueue;
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
@ -60,13 +68,14 @@ static NTSTATUS ExWorkerThreadEntryPoint(PVOID context)
|
||||||
* calls PsTerminateSystemThread
|
* calls PsTerminateSystemThread
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PWORK_QUEUE param = (PWORK_QUEUE)context;
|
PWORK_QUEUE queue = (PWORK_QUEUE)context;
|
||||||
PWORK_QUEUE_ITEM item;
|
PWORK_QUEUE_ITEM item;
|
||||||
PLIST_ENTRY current;
|
PLIST_ENTRY current;
|
||||||
|
|
||||||
while (1)
|
for(;;)
|
||||||
{
|
{
|
||||||
current = ExInterlockedRemoveHeadList(¶m->Head,¶m->Lock);
|
current = ExInterlockedRemoveHeadList(&queue->Head,
|
||||||
|
&queue->Lock);
|
||||||
if (current!=NULL)
|
if (current!=NULL)
|
||||||
{
|
{
|
||||||
item = CONTAINING_RECORD(current,WORK_QUEUE_ITEM,Entry);
|
item = CONTAINING_RECORD(current,WORK_QUEUE_ITEM,Entry);
|
||||||
|
@ -74,37 +83,55 @@ static NTSTATUS ExWorkerThreadEntryPoint(PVOID context)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
KeClearEvent(¶m->Busy);
|
KeWaitForSingleObject((PVOID)&queue->Sem,
|
||||||
KeWaitForSingleObject((PVOID)¶m->Busy,Executive,KernelMode,
|
Executive,
|
||||||
FALSE,WAIT_INTERVAL);
|
KernelMode,
|
||||||
|
FALSE,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID ExKillWorkerThreadCallback(PVOID Context)
|
static VOID ExInitializeWorkQueue(PWORK_QUEUE WorkQueue,
|
||||||
|
KPRIORITY Priority)
|
||||||
{
|
{
|
||||||
PsTerminateSystemThread(STATUS_SUCCESS);
|
ULONG i;
|
||||||
}
|
PETHREAD Thread;
|
||||||
|
|
||||||
void ExKillWorkerThreads(void)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Kill all running worker threads in preparation for a shutdown
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
WORK_QUEUE_ITEM item1;
|
|
||||||
|
|
||||||
ExInitializeWorkItem(&item1,ExKillWorkerThreadCallback,NULL);
|
InitializeListHead(&WorkQueue->Head);
|
||||||
ExQueueWorkItem(&item1,DelayedWorkQueue);
|
KeInitializeSpinLock(&WorkQueue->Lock);
|
||||||
|
KeInitializeSemaphore(&WorkQueue->Sem,
|
||||||
|
0,
|
||||||
|
256);
|
||||||
|
for (i=0; i<NUMBER_OF_WORKER_THREADS; i++)
|
||||||
|
{
|
||||||
|
PsCreateSystemThread(&WorkQueue->Thread[i],
|
||||||
|
THREAD_ALL_ACCESS,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
ExWorkerThreadEntryPoint,
|
||||||
|
WorkQueue);
|
||||||
|
ObReferenceObjectByHandle(WorkQueue->Thread[i],
|
||||||
|
THREAD_ALL_ACCESS,
|
||||||
|
PsThreadType,
|
||||||
|
KernelMode,
|
||||||
|
(PVOID*)&Thread,
|
||||||
|
NULL);
|
||||||
|
KeSetPriorityThread(&Thread->Tcb,
|
||||||
|
Priority);
|
||||||
|
ObDereferenceObject(Thread);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExInitializeWorkerThreads(void)
|
VOID ExInitializeWorkerThreads(VOID)
|
||||||
{
|
{
|
||||||
InitializeListHead(&normal_work_queue.Head);
|
ExInitializeWorkQueue(&EiNormalWorkQueue,
|
||||||
KeInitializeSpinLock(&normal_work_queue.Lock);
|
LOW_PRIORITY);
|
||||||
KeInitializeEvent(&normal_work_queue.Busy,NotificationEvent,FALSE);
|
ExInitializeWorkQueue(&EiCriticalWorkQueue,
|
||||||
PsCreateSystemThread(&normal_work_queue.Thread,THREAD_ALL_ACCESS,
|
LOW_REALTIME_PRIORITY);
|
||||||
NULL,NULL,NULL,ExWorkerThreadEntryPoint,
|
ExInitializeWorkQueue(&EiHyperCriticalWorkQueue,
|
||||||
&normal_work_queue);
|
HIGH_PRIORITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID ExInitializeWorkItem(PWORK_QUEUE_ITEM Item,
|
VOID ExInitializeWorkItem(PWORK_QUEUE_ITEM Item,
|
||||||
|
@ -121,10 +148,10 @@ VOID ExInitializeWorkItem(PWORK_QUEUE_ITEM Item,
|
||||||
{
|
{
|
||||||
ASSERT_IRQL(DISPATCH_LEVEL);
|
ASSERT_IRQL(DISPATCH_LEVEL);
|
||||||
|
|
||||||
Item->Routine=Routine;
|
Item->Routine = Routine;
|
||||||
Item->Context=Context;
|
Item->Context = Context;
|
||||||
Item->Entry.Flink=NULL;
|
Item->Entry.Flink = NULL;
|
||||||
Item->Entry.Blink=NULL;
|
Item->Entry.Blink = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,
|
VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,
|
||||||
|
@ -147,9 +174,34 @@ VOID ExQueueWorkItem(PWORK_QUEUE_ITEM WorkItem,
|
||||||
switch(QueueType)
|
switch(QueueType)
|
||||||
{
|
{
|
||||||
case DelayedWorkQueue:
|
case DelayedWorkQueue:
|
||||||
ExInterlockedInsertTailList(&normal_work_queue.Head,&(WorkItem->Entry),
|
ExInterlockedInsertTailList(&EiNormalWorkQueue.Head,
|
||||||
&normal_work_queue.Lock);
|
&WorkItem->Entry,
|
||||||
KeSetEvent(&normal_work_queue.Busy,IO_NO_INCREMENT,FALSE);
|
&EiNormalWorkQueue.Lock);
|
||||||
|
KeReleaseSemaphore(&EiNormalWorkQueue.Sem,
|
||||||
|
1,
|
||||||
|
IO_NO_INCREMENT,
|
||||||
|
FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CriticalWorkQueue:
|
||||||
|
ExInterlockedInsertTailList(&EiCriticalWorkQueue.Head,
|
||||||
|
&WorkItem->Entry,
|
||||||
|
&EiCriticalWorkQueue.Lock);
|
||||||
|
KeReleaseSemaphore(&EiCriticalWorkQueue.Sem,
|
||||||
|
1,
|
||||||
|
IO_NO_INCREMENT,
|
||||||
|
FALSE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HyperCriticalWorkQueue:
|
||||||
|
ExInterlockedInsertTailList(&EiHyperCriticalWorkQueue.Head,
|
||||||
|
&WorkItem->Entry,
|
||||||
|
&EiHyperCriticalWorkQueue.Lock);
|
||||||
|
KeReleaseSemaphore(&EiHyperCriticalWorkQueue.Sem,
|
||||||
|
1,
|
||||||
|
IO_NO_INCREMENT,
|
||||||
|
FALSE);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ start:
|
||||||
lidt _idt_descr
|
lidt _idt_descr
|
||||||
lgdt _gdt_descr
|
lgdt _gdt_descr
|
||||||
|
|
||||||
movw $0x28,%ax
|
movw $0x10,%ax
|
||||||
movw %ax,%ds
|
movw %ax,%ds
|
||||||
|
|
||||||
popl %eax
|
popl %eax
|
||||||
|
@ -34,7 +34,7 @@ _idt_descr:
|
||||||
.long _KiIdt
|
.long _KiIdt
|
||||||
|
|
||||||
_gdt_descr:
|
_gdt_descr:
|
||||||
.word ((6+NR_TASKS)*8)-1
|
.word ((8+NR_TASKS)*8)-1
|
||||||
.long _KiGdt
|
.long _KiGdt
|
||||||
|
|
||||||
/*_idt:
|
/*_idt:
|
||||||
|
|
|
@ -12,10 +12,192 @@
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
#include <internal/port.h>
|
||||||
|
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* TYPES *********************************************************************/
|
||||||
|
|
||||||
|
typedef struct _IO_ERROR_LOG_PACKET
|
||||||
|
{
|
||||||
|
UCHAR MajorFunctionCode;
|
||||||
|
UCHAR RetryCount;
|
||||||
|
USHORT DumpDataSize;
|
||||||
|
USHORT NumberOfStrings;
|
||||||
|
USHORT StringOffset;
|
||||||
|
USHORT EventCategory;
|
||||||
|
NTSTATUS ErrorCode;
|
||||||
|
ULONG UniqueErrorValue;
|
||||||
|
NTSTATUS FinalStatus;
|
||||||
|
ULONG SequenceNumber;
|
||||||
|
ULONG IoControlCode;
|
||||||
|
LARGE_INTEGER DeviceOffset;
|
||||||
|
ULONG DumpData[1];
|
||||||
|
} IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
|
||||||
|
|
||||||
|
typedef struct _ERROR_LOG_MESSAGE
|
||||||
|
{
|
||||||
|
PIO_ERROR_LOG_PACKET Packet;
|
||||||
|
LIST_ENTRY ListEntry;
|
||||||
|
} IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
|
||||||
|
|
||||||
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
|
static HANDLE ErrorLogPortHandle;
|
||||||
|
static HANDLE ErrorLogThreadHandle;
|
||||||
|
static PEPORT ErrorLogPort;
|
||||||
|
|
||||||
|
static LIST_ENTRY ErrorLogListHead;
|
||||||
|
static KSPIN_LOCK ErrorLogListLock;
|
||||||
|
static KSEMAPHORE ErrorLogSemaphore;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
static VOID IoSendErrorLogEntry(PIO_ERROR_LOG_PACKET Packet)
|
||||||
|
{
|
||||||
|
LPCMESSAGE Message;
|
||||||
|
ULONG Size;
|
||||||
|
ULONG i;
|
||||||
|
|
||||||
|
Size = sizeof(IO_ERROR_LOG_PACKET) +
|
||||||
|
(Packet->DumpDataSize * sizeof(UCHAR));
|
||||||
|
|
||||||
|
for (i=0; i<((Size % MAX_MESSAGE_DATA) - 1); i++)
|
||||||
|
{
|
||||||
|
Message.ActualMessageLength = MAX_MESSAGE_DATA;
|
||||||
|
Message.TotalMessageLength = sizeof(LPCMESSAGE);
|
||||||
|
Message.MessageType = i;
|
||||||
|
memcpy(Message.MessageData, (PVOID)Packet, MAX_MESSAGE_DATA);
|
||||||
|
LpcRequestPort(ErrorLogPort, &Message);
|
||||||
|
}
|
||||||
|
Message.ActualMessageLength = MAX_MESSAGE_DATA;
|
||||||
|
Message.TotalMessageLength = sizeof(LPCMESSAGE);
|
||||||
|
Message.MessageType = i;
|
||||||
|
memcpy(Message.MessageData, (PVOID)Packet, Size % MAX_MESSAGE_DATA);
|
||||||
|
LpcRequestPort(ErrorLogPort, &Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS IoErrorLogThreadMain(PVOID Context)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
LPCMESSAGE ConnectMsg;
|
||||||
|
HANDLE PortHandle;
|
||||||
|
PIO_ERROR_LOG_MESSAGE Message;
|
||||||
|
KIRQL oldIrql;
|
||||||
|
PLIST_ENTRY ListEntry;
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
Status = NtListenPort(ErrorLogPortHandle, &ConnectMsg);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = NtAcceptConnectPort(&PortHandle,
|
||||||
|
ErrorLogPortHandle,
|
||||||
|
NULL,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = NtCompleteConnectPort(PortHandle);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(PortHandle,
|
||||||
|
PORT_ALL_ACCESS,
|
||||||
|
ExPortType,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)&ErrorLogPort,
|
||||||
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ZwClose(PortHandle);
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
ZwClose(PortHandle);
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
|
||||||
|
KeWaitForSingleObject(&ErrorLogSemaphore,
|
||||||
|
UserRequest,
|
||||||
|
KernelMode,
|
||||||
|
FALSE,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&ErrorLogListLock, &oldIrql);
|
||||||
|
|
||||||
|
ListEntry = RemoveHeadList(&ErrorLogListHead);
|
||||||
|
|
||||||
|
KeReleaseSpinLock(&ErrorLogListLock, oldIrql);
|
||||||
|
|
||||||
|
Message = CONTAINING_RECORD(ListEntry,
|
||||||
|
IO_ERROR_LOG_MESSAGE,
|
||||||
|
ListEntry);
|
||||||
|
|
||||||
|
IoSendErrorLogEntry(Message->Packet);
|
||||||
|
|
||||||
|
ExFreePool(Message->Packet);
|
||||||
|
ExFreePool(Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS IoInitErrorLog(VOID)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
UNICODE_STRING PortName;
|
||||||
|
CLIENT_ID Cid;
|
||||||
|
|
||||||
|
InitializeListHead(&ErrorLogListHead);
|
||||||
|
KeInitializeSpinLock(&ErrorLogListLock);
|
||||||
|
|
||||||
|
KeInitializeSemaphore(&ErrorLogSemaphore,
|
||||||
|
0,
|
||||||
|
500);
|
||||||
|
|
||||||
|
RtlInitUnicodeString(&PortName, L"\\ErrorLogPort");
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&PortName,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
Status = NtCreatePort(&ErrorLogPortHandle,
|
||||||
|
&ObjectAttributes,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = PsCreateSystemThread(ErrorLogThreadHandle,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&Cid,
|
||||||
|
IoErrorLogThreadMain,
|
||||||
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PVOID IoAllocateErrorLogEntry(PVOID IoObject, UCHAR EntrySize)
|
PVOID IoAllocateErrorLogEntry(PVOID IoObject, UCHAR EntrySize)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
|
@ -23,6 +205,21 @@ PVOID IoAllocateErrorLogEntry(PVOID IoObject, UCHAR EntrySize)
|
||||||
|
|
||||||
VOID IoWriteErrorLogEntry(PVOID ElEntry)
|
VOID IoWriteErrorLogEntry(PVOID ElEntry)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
KIRQL oldIrql;
|
||||||
|
PIO_ERROR_LOG_MESSAGE Message;
|
||||||
|
|
||||||
|
Message = ExAllocatePool(NonPagedPool, sizeof(IO_ERROR_LOG_MESSAGE));
|
||||||
|
Message->Packet = (PIO_ERROR_LOG_PACKET)ElEntry;
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&ErrorLogListLock, &oldIrql);
|
||||||
|
|
||||||
|
InsertTailList(&ErrorLogListHead, &Message->ListEntry);
|
||||||
|
|
||||||
|
KeReleaseSemaphore(&ErrorLogSemaphore,
|
||||||
|
IO_NO_INCREMENT,
|
||||||
|
1,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
|
KeReleaseSpinLock(&ErrorLogListLock, oldIrql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,9 @@ VOID ExRaiseStatus(NTSTATUS Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtRaiseException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||||
STDCALL
|
IN PCONTEXT Context,
|
||||||
NtRaiseException (
|
IN BOOL IsDebugger OPTIONAL)
|
||||||
IN PEXCEPTION_RECORD ExceptionRecord,
|
|
||||||
IN PCONTEXT Context,
|
|
||||||
IN BOOL IsDebugger OPTIONAL
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,14 @@
|
||||||
|
|
||||||
#define NR_TASKS 128
|
#define NR_TASKS 128
|
||||||
|
|
||||||
USHORT KiGdt[(6 + NR_TASKS) * 4] = {0x0, 0x0, 0x0, 0x0,
|
USHORT KiGdt[(8 + NR_TASKS) * 4] = {0x0, 0x0, 0x0, 0x0,
|
||||||
|
0xffff, 0x0, 0x9a00, 0xcf,
|
||||||
|
0xffff, 0x0, 0x9200, 0xcf,
|
||||||
0x0, 0x0, 0xfa00, 0xcc,
|
0x0, 0x0, 0xfa00, 0xcc,
|
||||||
0x0, 0x0, 0xf200, 0xcc,
|
0x0, 0x0, 0xf200, 0xcc,
|
||||||
0xffff, 0x0, 0x9200, 0xcf,
|
0x0, 0x0, 0x0, 0x0,
|
||||||
0xffff, 0x0, 0x9a00, 0xcf,
|
0x0, 0x0, 0x0, 0x0,
|
||||||
0xffff, 0x0, 0x9200, 0xcf};
|
0x0, 0x0, 0x0, 0x0};
|
||||||
static KSPIN_LOCK GdtLock;
|
static KSPIN_LOCK GdtLock;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
@ -44,7 +46,7 @@ VOID KeFreeGdtSelector(ULONG Entry)
|
||||||
|
|
||||||
DPRINT("KeFreeGdtSelector(Entry %d)\n",Entry);
|
DPRINT("KeFreeGdtSelector(Entry %d)\n",Entry);
|
||||||
|
|
||||||
if (Entry > (6 + NR_TASKS))
|
if (Entry > (8 + NR_TASKS))
|
||||||
{
|
{
|
||||||
DPRINT1("Entry too large\n");
|
DPRINT1("Entry too large\n");
|
||||||
KeBugCheck(0);
|
KeBugCheck(0);
|
||||||
|
@ -52,7 +54,9 @@ VOID KeFreeGdtSelector(ULONG Entry)
|
||||||
|
|
||||||
KeAcquireSpinLock(&GdtLock, &oldIrql);
|
KeAcquireSpinLock(&GdtLock, &oldIrql);
|
||||||
KiGdt[Entry*4] = 0;
|
KiGdt[Entry*4] = 0;
|
||||||
|
KiGdt[Entry*4 + 1] = 0;
|
||||||
KiGdt[Entry*4 + 2] = 0;
|
KiGdt[Entry*4 + 2] = 0;
|
||||||
|
KiGdt[Entry*4 + 3] = 0;
|
||||||
KeReleaseSpinLock(&GdtLock, oldIrql);
|
KeReleaseSpinLock(&GdtLock, oldIrql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,10 +75,12 @@ ULONG KeAllocateGdtSelector(ULONG Desc[2])
|
||||||
Desc[0], Desc[1]);
|
Desc[0], Desc[1]);
|
||||||
|
|
||||||
KeAcquireSpinLock(&GdtLock, &oldIrql);
|
KeAcquireSpinLock(&GdtLock, &oldIrql);
|
||||||
for (i=6; i<(6 + NR_TASKS); i++)
|
for (i=8; i<(8 + NR_TASKS); i++)
|
||||||
{
|
{
|
||||||
if (KiGdt[i*4] == 0 &&
|
if (KiGdt[i*4] == 0 &&
|
||||||
KiGdt[i*4 + 2] == 0)
|
KiGdt[i*4 + 1] == 0 &&
|
||||||
|
KiGdt[i*4 + 2] == 0 &&
|
||||||
|
KiGdt[i*4 + 3] == 0)
|
||||||
{
|
{
|
||||||
((PULONG)KiGdt)[i*2] = Desc[0];
|
((PULONG)KiGdt)[i*2] = Desc[0];
|
||||||
((PULONG)KiGdt)[i*2 + 1] = Desc[1];
|
((PULONG)KiGdt)[i*2 + 1] = Desc[1];
|
||||||
|
|
|
@ -181,7 +181,7 @@ asmlinkage void exception_handler(unsigned int edi,
|
||||||
unsigned int cr2, cr3;
|
unsigned int cr2, cr3;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
// unsigned int j, sym;
|
// unsigned int j, sym;
|
||||||
unsigned int* stack;
|
PULONG stack;
|
||||||
static char *TypeStrings[] =
|
static char *TypeStrings[] =
|
||||||
{
|
{
|
||||||
"Divide Error",
|
"Divide Error",
|
||||||
|
@ -282,8 +282,9 @@ asmlinkage void exception_handler(unsigned int edi,
|
||||||
if ((cs & 0xffff) == KERNEL_CS)
|
if ((cs & 0xffff) == KERNEL_CS)
|
||||||
{
|
{
|
||||||
DbgPrint("ESP %x\n",esp);
|
DbgPrint("ESP %x\n",esp);
|
||||||
stack = (unsigned int *) (esp + 24);
|
stack = (PULONG) (esp + 24);
|
||||||
|
stack = (PULONG)(((ULONG)stack) & (~0x3));
|
||||||
|
|
||||||
DbgPrint("Stack:\n");
|
DbgPrint("Stack:\n");
|
||||||
for (i = 0; i < 16; i = i + 4)
|
for (i = 0; i < 16; i = i + 4)
|
||||||
{
|
{
|
||||||
|
@ -309,7 +310,7 @@ asmlinkage void exception_handler(unsigned int edi,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DbgPrint("SS:ESP %x:%x\n",ss0,esp0);
|
DbgPrint("SS:ESP %x:%x\n",ss0,esp0);
|
||||||
stack=(unsigned int *)(esp0);
|
stack=(PULONG)(esp0);
|
||||||
|
|
||||||
DbgPrint("Stack:\n");
|
DbgPrint("Stack:\n");
|
||||||
for (i=0; i<16; i++)
|
for (i=0; i<16; i++)
|
||||||
|
@ -348,6 +349,11 @@ VOID KeDumpStackFrames(PVOID _Stack, ULONG NrFrames)
|
||||||
|
|
||||||
Stack = (PVOID)(((ULONG)Stack) & (~0x3));
|
Stack = (PVOID)(((ULONG)Stack) & (~0x3));
|
||||||
DbgPrint("Stack: %x\n", Stack);
|
DbgPrint("Stack: %x\n", Stack);
|
||||||
|
if (PsGetCurrentThread() != NULL)
|
||||||
|
{
|
||||||
|
DbgPrint("kernel stack base %x\n",
|
||||||
|
PsGetCurrentThread()->Tcb.Context.KernelStackBase);
|
||||||
|
}
|
||||||
|
|
||||||
DbgPrint("Frames:\n");
|
DbgPrint("Frames:\n");
|
||||||
for (i=0; i<NrFrames; i++)
|
for (i=0; i<NrFrames; i++)
|
||||||
|
|
|
@ -193,7 +193,7 @@ NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context)
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_start = kernel_stack + 4096 - sizeof(CONTEXT);
|
stack_start = kernel_stack + 3*PAGESIZE - sizeof(CONTEXT);
|
||||||
memcpy(stack_start, Context, sizeof(CONTEXT));
|
memcpy(stack_start, Context, sizeof(CONTEXT));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -40,97 +40,86 @@
|
||||||
|
|
||||||
#define STACK_TOP (0xb0000000)
|
#define STACK_TOP (0xb0000000)
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS LdrCreateUserProcessParameters (
|
||||||
LdrCreatePpb (
|
PRTL_USER_PROCESS_PARAMETERS *PpbPtr,
|
||||||
PRTL_USER_PROCESS_PARAMETERS *PpbPtr,
|
HANDLE ProcessHandle)
|
||||||
HANDLE ProcessHandle
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
RTL_USER_PROCESS_PARAMETERS Ppb;
|
PVOID PpbBase;
|
||||||
PVOID PpbBase;
|
ULONG PpbSize;
|
||||||
ULONG PpbSize;
|
RTL_USER_PROCESS_PARAMETERS Ppb;
|
||||||
ULONG BytesWritten;
|
ULONG BytesWritten;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* Create process parameters block (PPB)*/
|
||||||
|
PpbBase = (PVOID)PEB_STARTUPINFO;
|
||||||
|
PpbSize = sizeof (RTL_USER_PROCESS_PARAMETERS);
|
||||||
|
|
||||||
/* Create process parameters block (PPB)*/
|
Status = ZwAllocateVirtualMemory (ProcessHandle,
|
||||||
PpbBase = (PVOID)PEB_STARTUPINFO;
|
(PVOID*)&PpbBase,
|
||||||
PpbSize = sizeof (RTL_USER_PROCESS_PARAMETERS);
|
0,
|
||||||
|
&PpbSize,
|
||||||
|
MEM_COMMIT,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DbgPrint("Ppb allocation failed (Status %x)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
Status = NtAllocateVirtualMemory (
|
/* initialize the ppb */
|
||||||
ProcessHandle,
|
memset (&Ppb, 0, sizeof(RTL_USER_PROCESS_PARAMETERS));
|
||||||
(PVOID*)&PpbBase,
|
|
||||||
0,
|
DPRINT("PpbBase %x\n", PpbBase);
|
||||||
&PpbSize,
|
ZwWriteVirtualMemory(ProcessHandle,
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE
|
|
||||||
);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DbgPrint ("Process Parameters allocation failed \n");
|
|
||||||
DbgPrintErrorMessage (Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize the ppb */
|
|
||||||
memset (&Ppb, 0, sizeof(RTL_USER_PROCESS_PARAMETERS));
|
|
||||||
|
|
||||||
NtWriteVirtualMemory (
|
|
||||||
ProcessHandle,
|
|
||||||
PpbBase,
|
PpbBase,
|
||||||
&Ppb,
|
&Ppb,
|
||||||
sizeof(RTL_USER_PROCESS_PARAMETERS),
|
sizeof(RTL_USER_PROCESS_PARAMETERS),
|
||||||
&BytesWritten);
|
&BytesWritten);
|
||||||
|
|
||||||
*PpbPtr = PpbBase;
|
*PpbPtr = PpbBase;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS LdrCreatePeb (PPEB *PebPtr,
|
||||||
LdrCreatePeb (
|
HANDLE ProcessHandle,
|
||||||
PPEB *PebPtr,
|
PRTL_USER_PROCESS_PARAMETERS Ppb)
|
||||||
HANDLE ProcessHandle,
|
|
||||||
PRTL_USER_PROCESS_PARAMETERS Ppb
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
PPEB PebBase;
|
PPEB PebBase;
|
||||||
ULONG PebSize;
|
ULONG PebSize;
|
||||||
PEB Peb;
|
PEB Peb;
|
||||||
ULONG BytesWritten;
|
ULONG BytesWritten;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
PebBase = (PVOID)PEB_BASE;
|
||||||
|
PebSize = 0x1000;
|
||||||
|
|
||||||
|
Status = ZwAllocateVirtualMemory (ProcessHandle,
|
||||||
|
(PVOID*)&PebBase,
|
||||||
|
0,
|
||||||
|
&PebSize,
|
||||||
|
MEM_COMMIT,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DbgPrint ("Peb allocation failed (Status %x)\n", Status);
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
PebBase = (PVOID)PEB_BASE;
|
/* initialize the peb */
|
||||||
PebSize = 0x1000;
|
memset(&Peb, 0, sizeof Peb);
|
||||||
|
Peb.ProcessParameters = Ppb;
|
||||||
Status = ZwAllocateVirtualMemory (
|
|
||||||
ProcessHandle,
|
ZwWriteVirtualMemory (ProcessHandle,
|
||||||
(PVOID*)&PebBase,
|
PebBase,
|
||||||
0,
|
&Peb,
|
||||||
&PebSize,
|
sizeof(Peb),
|
||||||
MEM_COMMIT,
|
&BytesWritten);
|
||||||
PAGE_READWRITE
|
|
||||||
);
|
*PebPtr = (PPEB)PebBase;
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
return(STATUS_SUCCESS);
|
||||||
DbgPrint ("Peb allocation failed \n");
|
|
||||||
DbgPrintErrorMessage (Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize the peb */
|
|
||||||
memset(&Peb, 0, sizeof Peb);
|
|
||||||
Peb.ProcessParameters = Ppb;
|
|
||||||
|
|
||||||
ZwWriteVirtualMemory (
|
|
||||||
ProcessHandle,
|
|
||||||
PebBase,
|
|
||||||
&Peb,
|
|
||||||
sizeof(Peb),
|
|
||||||
&BytesWritten);
|
|
||||||
|
|
||||||
*PebPtr = (PPEB)PebBase;
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,7 +166,7 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle,
|
||||||
|
|
||||||
WCHAR TmpNameBuffer [MAX_PATH];
|
WCHAR TmpNameBuffer [MAX_PATH];
|
||||||
|
|
||||||
PRTL_USER_PROCESS_PARAMETERS Ppb;
|
PRTL_USER_PROCESS_PARAMETERS Ppb;
|
||||||
PPEB Peb;
|
PPEB Peb;
|
||||||
|
|
||||||
|
|
||||||
|
@ -459,117 +448,102 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle,
|
||||||
|
|
||||||
/* -- PART III -- */
|
/* -- PART III -- */
|
||||||
|
|
||||||
/* Create the process parameter block (PPB) */
|
/* Create the process parameter block (PPB) */
|
||||||
Status = LdrCreatePpb (&Ppb,
|
DPRINT("Creating PPB\n");
|
||||||
ProcessHandle);
|
Status = LdrCreateUserProcessParameters (&Ppb, ProcessHandle);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("PPB creation failed ");
|
DPRINT("PPB creation failed ");
|
||||||
DbgPrintErrorMessage(Status);
|
DbgPrintErrorMessage(Status);
|
||||||
|
|
||||||
/* FIXME: unmap the section here */
|
/* FIXME: unmap the section here */
|
||||||
/* FIXME: destroy the section here */
|
/* FIXME: destroy the section here */
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the process environment block (PEB) */
|
/* Create the process environment block (PEB) */
|
||||||
Status = LdrCreatePeb (&Peb,
|
DPRINT("Creating Peb\n");
|
||||||
ProcessHandle,
|
Status = LdrCreatePeb (&Peb,
|
||||||
Ppb);
|
ProcessHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
Ppb);
|
||||||
{
|
if (!NT_SUCCESS(Status))
|
||||||
DPRINT("PEB creation failed ");
|
{
|
||||||
|
DPRINT("PEB creation failed ");
|
||||||
DbgPrintErrorMessage(Status);
|
DbgPrintErrorMessage(Status);
|
||||||
|
|
||||||
/* FIXME: unmap the section here */
|
/* FIXME: unmap the section here */
|
||||||
/* FIXME: destroy the section here */
|
/* FIXME: destroy the section here */
|
||||||
/* FIXME: free the PPB */
|
/* FIXME: free the PPB */
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create page backed section for stack
|
||||||
|
*/
|
||||||
|
DPRINT("Allocating stack\n");
|
||||||
|
StackBase = (STACK_TOP - NTHeaders->OptionalHeader.SizeOfStackReserve);
|
||||||
|
StackSize = NTHeaders->OptionalHeader.SizeOfStackReserve;
|
||||||
|
DbgPrint ("Stack size %x\n", StackSize);
|
||||||
|
|
||||||
/*
|
Status = ZwAllocateVirtualMemory(ProcessHandle,
|
||||||
* Create page backed section for stack
|
(PVOID*)&StackBase,
|
||||||
*/
|
0,
|
||||||
StackBase = (
|
&StackSize,
|
||||||
STACK_TOP
|
MEM_COMMIT,
|
||||||
- NTHeaders->OptionalHeader.SizeOfStackReserve
|
PAGE_READWRITE);
|
||||||
);
|
if (!NT_SUCCESS(Status))
|
||||||
StackSize =
|
{
|
||||||
NTHeaders->OptionalHeader.SizeOfStackReserve;
|
DPRINT("Stack allocation failed ");
|
||||||
DbgPrint ("Stack size %x\n", StackSize);
|
DbgPrintErrorMessage(Status);
|
||||||
|
|
||||||
Status = ZwAllocateVirtualMemory(
|
/* FIXME: unmap the section here */
|
||||||
ProcessHandle,
|
/* FIXME: destroy the section here */
|
||||||
(PVOID *) & StackBase,
|
|
||||||
0,
|
return Status;
|
||||||
& StackSize,
|
}
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE
|
ZwDuplicateObject(NtCurrentProcess(),
|
||||||
);
|
&SectionHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
ProcessHandle,
|
||||||
{
|
&DupSectionHandle,
|
||||||
DPRINT("Stack allocation failed ");
|
0,
|
||||||
DbgPrintErrorMessage(Status);
|
FALSE,
|
||||||
|
DUPLICATE_SAME_ACCESS);
|
||||||
|
ZwDuplicateObject(NtCurrentProcess(),
|
||||||
|
&NTDllSectionHandle,
|
||||||
|
ProcessHandle,
|
||||||
|
&DupNTDllSectionHandle,
|
||||||
|
0,
|
||||||
|
FALSE,
|
||||||
|
DUPLICATE_SAME_ACCESS);
|
||||||
|
|
||||||
|
DPRINT("DupNTDllSectionHandle %x\n", DupNTDllSectionHandle);
|
||||||
|
ZwWriteVirtualMemory(ProcessHandle,
|
||||||
|
(PVOID)(STACK_TOP - 4),
|
||||||
|
&DupNTDllSectionHandle,
|
||||||
|
sizeof(DupNTDllSectionHandle),
|
||||||
|
&BytesWritten);
|
||||||
|
ZwWriteVirtualMemory(ProcessHandle,
|
||||||
|
(PVOID)(STACK_TOP - 8),
|
||||||
|
&ImageBase,
|
||||||
|
sizeof (ImageBase),
|
||||||
|
&BytesWritten);
|
||||||
|
ZwWriteVirtualMemory(ProcessHandle,
|
||||||
|
(PVOID)(STACK_TOP - 12),
|
||||||
|
&DupSectionHandle,
|
||||||
|
sizeof (DupSectionHandle),
|
||||||
|
&BytesWritten);
|
||||||
|
|
||||||
/* FIXME: unmap the section here */
|
/* write pointer to peb on the stack (parameter of NtProcessStartup) */
|
||||||
/* FIXME: destroy the section here */
|
ZwWriteVirtualMemory(ProcessHandle,
|
||||||
|
(PVOID) (STACK_TOP - 16),
|
||||||
return Status;
|
&Peb,
|
||||||
}
|
sizeof (ULONG),
|
||||||
|
&BytesWritten);
|
||||||
ZwDuplicateObject(
|
|
||||||
NtCurrentProcess(),
|
DbgPrint ("NTOSKRNL: Peb = %x\n", Peb);
|
||||||
& SectionHandle,
|
|
||||||
ProcessHandle,
|
|
||||||
& DupSectionHandle,
|
|
||||||
0,
|
|
||||||
FALSE,
|
|
||||||
DUPLICATE_SAME_ACCESS
|
|
||||||
);
|
|
||||||
ZwDuplicateObject(
|
|
||||||
NtCurrentProcess(),
|
|
||||||
& NTDllSectionHandle,
|
|
||||||
ProcessHandle,
|
|
||||||
&DupNTDllSectionHandle,
|
|
||||||
0,
|
|
||||||
FALSE,
|
|
||||||
DUPLICATE_SAME_ACCESS
|
|
||||||
);
|
|
||||||
|
|
||||||
ZwWriteVirtualMemory(
|
|
||||||
ProcessHandle,
|
|
||||||
(PVOID) (STACK_TOP - 4),
|
|
||||||
& DupNTDllSectionHandle,
|
|
||||||
sizeof (DupNTDllSectionHandle),
|
|
||||||
& BytesWritten
|
|
||||||
);
|
|
||||||
ZwWriteVirtualMemory(
|
|
||||||
ProcessHandle,
|
|
||||||
(PVOID) (STACK_TOP - 8),
|
|
||||||
& ImageBase,
|
|
||||||
sizeof (ImageBase),
|
|
||||||
& BytesWritten
|
|
||||||
);
|
|
||||||
ZwWriteVirtualMemory(
|
|
||||||
ProcessHandle,
|
|
||||||
(PVOID) (STACK_TOP - 12),
|
|
||||||
& DupSectionHandle,
|
|
||||||
sizeof (DupSectionHandle),
|
|
||||||
& BytesWritten
|
|
||||||
);
|
|
||||||
|
|
||||||
/* write pointer to peb on the stack (parameter of NtProcessStartup) */
|
|
||||||
ZwWriteVirtualMemory(
|
|
||||||
ProcessHandle,
|
|
||||||
(PVOID) (STACK_TOP - 16),
|
|
||||||
&Peb,
|
|
||||||
sizeof (ULONG),
|
|
||||||
&BytesWritten
|
|
||||||
);
|
|
||||||
|
|
||||||
DbgPrint ("NTOSKRNL: Peb = %x\n", Peb);
|
|
||||||
/*
|
/*
|
||||||
* Initialize context to point to LdrStartup
|
* Initialize context to point to LdrStartup
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile_rex,v 1.48 2000/01/20 22:14:08 ea Exp $
|
# $Id: makefile_rex,v 1.49 2000/01/26 10:07:24 dwelch Exp $
|
||||||
#
|
#
|
||||||
# ReactOS Operating System
|
# ReactOS Operating System
|
||||||
#
|
#
|
||||||
|
@ -58,7 +58,8 @@ EX_OBJECTS = ex/work.o ex/fmutex.o ex/resource.o ex/time.o ex/interlck.o \
|
||||||
|
|
||||||
FS_OBJECTS = fs/mcb.o fs/unc.o fs/util.o
|
FS_OBJECTS = fs/mcb.o fs/unc.o fs/util.o
|
||||||
|
|
||||||
SE_OBJECTS = se/semgr.o se/acl.o se/sid.o se/sd.o se/token.o se/luid.o
|
SE_OBJECTS = se/semgr.o se/acl.o se/sid.o se/sd.o se/token.o se/luid.o \
|
||||||
|
se/priv.o
|
||||||
|
|
||||||
CM_OBJECTS = cm/registry.o
|
CM_OBJECTS = cm/registry.o
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,19 @@ static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
|
||||||
DPRINT("Scanning %x BaseAddress %x Length %x\n",
|
DPRINT("Scanning %x BaseAddress %x Length %x\n",
|
||||||
current, current->BaseAddress, current->Length);
|
current, current->BaseAddress, current->Length);
|
||||||
assert(current_entry->Blink->Flink == current_entry);
|
assert(current_entry->Blink->Flink == current_entry);
|
||||||
|
if (current_entry->Flink->Blink != current_entry)
|
||||||
|
{
|
||||||
|
DPRINT("BaseAddress %x\n", current->BaseAddress);
|
||||||
|
DPRINT("current_entry->Flink %x ", current_entry->Flink);
|
||||||
|
DPRINT("¤t_entry->Flink %x\n",
|
||||||
|
¤t_entry->Flink);
|
||||||
|
DPRINT("current_entry->Flink->Blink %x\n",
|
||||||
|
current_entry->Flink->Blink);
|
||||||
|
DPRINT("¤t_entry->Flink->Blink %x\n",
|
||||||
|
¤t_entry->Flink->Blink);
|
||||||
|
DPRINT("¤t_entry->Flink %x\n",
|
||||||
|
¤t_entry->Flink);
|
||||||
|
}
|
||||||
assert(current_entry->Flink->Blink == current_entry);
|
assert(current_entry->Flink->Blink == current_entry);
|
||||||
assert(previous_entry->Flink == current_entry);
|
assert(previous_entry->Flink == current_entry);
|
||||||
if (current->BaseAddress <= Address &&
|
if (current->BaseAddress <= Address &&
|
||||||
|
@ -170,7 +183,7 @@ MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
|
||||||
DPRINT("MmInternalOpenMemoryAreaByRegion(ListHead %x, Address %x, "
|
DPRINT("MmInternalOpenMemoryAreaByRegion(ListHead %x, Address %x, "
|
||||||
"Length %x)\n",ListHead,Address,Length);
|
"Length %x)\n",ListHead,Address,Length);
|
||||||
|
|
||||||
// MmDumpMemoryAreas();
|
// MmDumpMemoryAreas(ListHead);
|
||||||
|
|
||||||
current_entry = ListHead->Flink;
|
current_entry = ListHead->Flink;
|
||||||
while (current_entry!=ListHead)
|
while (current_entry!=ListHead)
|
||||||
|
@ -179,7 +192,7 @@ MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
|
||||||
DPRINT("current->BaseAddress %x current->Length %x\n",
|
DPRINT("current->BaseAddress %x current->Length %x\n",
|
||||||
current->BaseAddress,current->Length);
|
current->BaseAddress,current->Length);
|
||||||
if (current->BaseAddress >= Address &&
|
if (current->BaseAddress >= Address &&
|
||||||
current->BaseAddress <= (Address+Length))
|
current->BaseAddress < (Address+Length))
|
||||||
{
|
{
|
||||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
||||||
current);
|
current);
|
||||||
|
@ -273,7 +286,7 @@ static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
|
||||||
{
|
{
|
||||||
PLIST_ENTRY ListHead;
|
PLIST_ENTRY ListHead;
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
PLIST_ENTRY inserted_entry = &(marea->Entry);
|
PLIST_ENTRY inserted_entry = &marea->Entry;
|
||||||
MEMORY_AREA* current;
|
MEMORY_AREA* current;
|
||||||
MEMORY_AREA* next;
|
MEMORY_AREA* next;
|
||||||
|
|
||||||
|
@ -288,6 +301,7 @@ static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
|
||||||
{
|
{
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
InsertHeadList(ListHead,&marea->Entry);
|
InsertHeadList(ListHead,&marea->Entry);
|
||||||
|
DPRINT("Inserting at list head\n");
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -298,6 +312,7 @@ static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
|
||||||
{
|
{
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
InsertHeadList(ListHead,&marea->Entry);
|
InsertHeadList(ListHead,&marea->Entry);
|
||||||
|
DPRINT("Inserting at list head\n");
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -312,15 +327,17 @@ static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
|
||||||
if (current->BaseAddress < marea->BaseAddress &&
|
if (current->BaseAddress < marea->BaseAddress &&
|
||||||
current->Entry.Flink==ListHead)
|
current->Entry.Flink==ListHead)
|
||||||
{
|
{
|
||||||
|
DPRINT("Insert after %x\n", current_entry);
|
||||||
current_entry->Flink = inserted_entry;
|
current_entry->Flink = inserted_entry;
|
||||||
inserted_entry->Flink=ListHead;
|
inserted_entry->Flink=ListHead;
|
||||||
inserted_entry->Blink=current_entry;
|
inserted_entry->Blink=current_entry;
|
||||||
ListHead->Blink = inserted_entry;
|
ListHead->Blink = inserted_entry;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (current->BaseAddress < marea->BaseAddress &&
|
if (current->BaseAddress < marea->BaseAddress &&
|
||||||
next->BaseAddress > marea->BaseAddress)
|
next->BaseAddress > marea->BaseAddress)
|
||||||
{
|
{
|
||||||
|
DPRINT("Inserting before %x\n", current_entry);
|
||||||
inserted_entry->Flink = current_entry->Flink;
|
inserted_entry->Flink = current_entry->Flink;
|
||||||
inserted_entry->Blink = current_entry;
|
inserted_entry->Blink = current_entry;
|
||||||
inserted_entry->Flink->Blink = inserted_entry;
|
inserted_entry->Flink->Blink = inserted_entry;
|
||||||
|
@ -330,6 +347,7 @@ static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
DPRINT("Inserting at list tail\n");
|
||||||
InsertTailList(ListHead,inserted_entry);
|
InsertTailList(ListHead,inserted_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,8 @@ VOID MmBuildMdlFromPages(PMDL Mdl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID MmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode,
|
VOID MmProbeAndLockPages(PMDL Mdl,
|
||||||
|
KPROCESSOR_MODE AccessMode,
|
||||||
LOCK_OPERATION Operation)
|
LOCK_OPERATION Operation)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Probes the specified pages, makes them resident and locks them
|
* FUNCTION: Probes the specified pages, makes them resident and locks them
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: port.c,v 1.16 2000/01/12 19:04:01 ekohl Exp $
|
/* $Id: port.c,v 1.17 2000/01/26 10:07:28 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -24,6 +24,7 @@
|
||||||
#include <internal/ob.h>
|
#include <internal/ob.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
|
#include <internal/port.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -31,8 +32,6 @@
|
||||||
|
|
||||||
/* TYPES ********************************************************************/
|
/* TYPES ********************************************************************/
|
||||||
|
|
||||||
#define PORT_ALL_ACCESS (0x1)
|
|
||||||
|
|
||||||
#define EPORT_INACTIVE (0)
|
#define EPORT_INACTIVE (0)
|
||||||
#define EPORT_WAIT_FOR_CONNECT (1)
|
#define EPORT_WAIT_FOR_CONNECT (1)
|
||||||
#define EPORT_WAIT_FOR_ACCEPT (2)
|
#define EPORT_WAIT_FOR_ACCEPT (2)
|
||||||
|
@ -49,23 +48,6 @@ typedef struct _QUEUEDMESSAGE
|
||||||
LPCMESSAGE Message;
|
LPCMESSAGE Message;
|
||||||
} QUEUEDMESSAGE, *PQUEUEDMESSAGE;
|
} QUEUEDMESSAGE, *PQUEUEDMESSAGE;
|
||||||
|
|
||||||
typedef struct _EPORT
|
|
||||||
{
|
|
||||||
KSPIN_LOCK Lock;
|
|
||||||
KEVENT Event;
|
|
||||||
|
|
||||||
struct _EPORT* OtherPort;
|
|
||||||
|
|
||||||
ULONG QueueLength;
|
|
||||||
LIST_ENTRY QueueListHead;
|
|
||||||
|
|
||||||
ULONG ConnectQueueLength;
|
|
||||||
LIST_ENTRY ConnectQueueListHead;
|
|
||||||
|
|
||||||
ULONG MaxDataLength;
|
|
||||||
ULONG MaxConnectInfoLength;
|
|
||||||
} EPORT, *PEPORT;
|
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
POBJECT_TYPE ExPortType = NULL;
|
POBJECT_TYPE ExPortType = NULL;
|
||||||
|
@ -603,6 +585,21 @@ NTSTATUS STDCALL NtReplyWaitReceivePort (IN HANDLE PortHandle,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL LpcRequestPort(PEPORT Port,
|
||||||
|
PLPCMESSAGE LpcMessage)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("LpcRequestPort(PortHandle %x LpcMessage %x)\n", Port, LpcMessage);
|
||||||
|
|
||||||
|
Status = EiReplyOrRequestPort(Port->OtherPort,
|
||||||
|
LpcMessage,
|
||||||
|
LPC_DATAGRAM,
|
||||||
|
Port);
|
||||||
|
KeSetEvent(&Port->OtherPort->Event, IO_NO_INCREMENT, FALSE);
|
||||||
|
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtRequestPort (IN HANDLE PortHandle,
|
NTSTATUS STDCALL NtRequestPort (IN HANDLE PortHandle,
|
||||||
IN PLPCMESSAGE LpcMessage /* guess */)
|
IN PLPCMESSAGE LpcMessage /* guess */)
|
||||||
|
@ -625,11 +622,7 @@ NTSTATUS STDCALL NtRequestPort (IN HANDLE PortHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = EiReplyOrRequestPort(Port->OtherPort,
|
Status = LpcRequestPort(Port, LpcMessage);
|
||||||
LpcMessage,
|
|
||||||
LPC_DATAGRAM,
|
|
||||||
Port);
|
|
||||||
KeSetEvent(&Port->OtherPort->Event, IO_NO_INCREMENT, FALSE);
|
|
||||||
|
|
||||||
ObDereferenceObject(Port);
|
ObDereferenceObject(Port);
|
||||||
return(Status);
|
return(Status);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.7 2000/01/05 21:57:00 dwelch Exp $
|
/* $Id: create.c,v 1.8 2000/01/26 10:07:29 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -307,11 +307,11 @@ VOID PiCloseThread(PVOID ObjectBody, ULONG HandleCount)
|
||||||
ObGetHandleCount(ObjectBody));
|
ObGetHandleCount(ObjectBody));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
||||||
PETHREAD * ThreadPtr,
|
PETHREAD* ThreadPtr,
|
||||||
PHANDLE ThreadHandle,
|
PHANDLE ThreadHandle,
|
||||||
ACCESS_MASK DesiredAccess,
|
ACCESS_MASK DesiredAccess,
|
||||||
POBJECT_ATTRIBUTES ThreadAttributes)
|
POBJECT_ATTRIBUTES ThreadAttributes)
|
||||||
{
|
{
|
||||||
PETHREAD Thread;
|
PETHREAD Thread;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -363,7 +363,7 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
||||||
Thread->Tcb.KernelApcDisable = 1;
|
Thread->Tcb.KernelApcDisable = 1;
|
||||||
Thread->Tcb.WaitIrql = PASSIVE_LEVEL;
|
Thread->Tcb.WaitIrql = PASSIVE_LEVEL;
|
||||||
Thread->ThreadsProcess = Process;
|
Thread->ThreadsProcess = Process;
|
||||||
KeInitializeDpc( &Thread->Tcb.TimerDpc, PiTimeoutThread, Thread );
|
KeInitializeDpc(&Thread->Tcb.TimerDpc, PiTimeoutThread, Thread);
|
||||||
Thread->Tcb.WaitBlockList = NULL;
|
Thread->Tcb.WaitBlockList = NULL;
|
||||||
InsertTailList( &Thread->ThreadsProcess->Pcb.ThreadListHead, &Thread->Tcb.ProcessThreadListEntry );
|
InsertTailList( &Thread->ThreadsProcess->Pcb.ThreadListHead, &Thread->Tcb.ProcessThreadListEntry );
|
||||||
KeInitializeDispatcherHeader(&Thread->Tcb.DispatcherHeader,
|
KeInitializeDispatcherHeader(&Thread->Tcb.DispatcherHeader,
|
||||||
|
@ -395,7 +395,7 @@ static NTSTATUS PsCreateTeb (HANDLE ProcessHandle,
|
||||||
PETHREAD Thread,
|
PETHREAD Thread,
|
||||||
PINITIAL_TEB InitialTeb)
|
PINITIAL_TEB InitialTeb)
|
||||||
{
|
{
|
||||||
MEMORY_BASIC_INFORMATION Info;
|
// MEMORY_BASIC_INFORMATION Info;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG ByteCount;
|
ULONG ByteCount;
|
||||||
ULONG RegionSize;
|
ULONG RegionSize;
|
||||||
|
@ -423,9 +423,12 @@ static NTSTATUS PsCreateTeb (HANDLE ProcessHandle,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DPRINT ("TEB allocation failed! Status %x\n",Status);
|
DPRINT ("TEB allocation failed! Status %x\n",Status);
|
||||||
|
for(;;);
|
||||||
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
TebBase = Info.BaseAddress - TebSize;
|
// TebBase = Info.BaseAddress - TebSize;
|
||||||
|
TebBase = TebBase - TebSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT ("TebBase %p TebSize %lu\n", TebBase, TebSize);
|
DPRINT ("TebBase %p TebSize %lu\n", TebBase, TebSize);
|
||||||
|
|
|
@ -334,7 +334,7 @@ NTSTATUS STDCALL NtCreateProcess (
|
||||||
InitializeListHead( &KProcess->ThreadListHead );
|
InitializeListHead( &KProcess->ThreadListHead );
|
||||||
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
|
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
|
||||||
|
|
||||||
Status = PsCreatePeb (*ProcessHandle);
|
Status = PsCreatePeb(*ProcessHandle);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
// DPRINT("NtCreateProcess() Peb creation failed: Status %x\n",Status);
|
// DPRINT("NtCreateProcess() Peb creation failed: Status %x\n",Status);
|
||||||
|
@ -358,14 +358,10 @@ NTSTATUS STDCALL NtCreateProcess (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtOpenProcess (OUT PHANDLE ProcessHandle,
|
||||||
STDCALL
|
IN ACCESS_MASK DesiredAccess,
|
||||||
NtOpenProcess (
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
OUT PHANDLE ProcessHandle,
|
IN PCLIENT_ID ClientId)
|
||||||
IN ACCESS_MASK DesiredAccess,
|
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
|
||||||
IN PCLIENT_ID ClientId
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
DPRINT("NtOpenProcess(ProcessHandle %x, DesiredAccess %x, "
|
DPRINT("NtOpenProcess(ProcessHandle %x, DesiredAccess %x, "
|
||||||
"ObjectAttributes %x, ClientId %x { UniP %d, UniT %d })\n",
|
"ObjectAttributes %x, ClientId %x { UniP %d, UniT %d })\n",
|
||||||
|
@ -444,15 +440,11 @@ NtOpenProcess (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtQueryInformationProcess (IN HANDLE ProcessHandle,
|
||||||
STDCALL
|
IN CINT ProcessInformationClass,
|
||||||
NtQueryInformationProcess (
|
OUT PVOID ProcessInformation,
|
||||||
IN HANDLE ProcessHandle,
|
IN ULONG ProcessInformationLength,
|
||||||
IN CINT ProcessInformationClass,
|
OUT PULONG ReturnLength)
|
||||||
OUT PVOID ProcessInformation,
|
|
||||||
IN ULONG ProcessInformationLength,
|
|
||||||
OUT PULONG ReturnLength
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -474,7 +466,8 @@ NtQueryInformationProcess (
|
||||||
case ProcessBasicInformation:
|
case ProcessBasicInformation:
|
||||||
ProcessBasicInformationP = (PPROCESS_BASIC_INFORMATION)
|
ProcessBasicInformationP = (PPROCESS_BASIC_INFORMATION)
|
||||||
ProcessInformation;
|
ProcessInformation;
|
||||||
memset(ProcessBasicInformationP, 0, sizeof(PROCESS_BASIC_INFORMATION));
|
ProcessBasicInformationP->ExitStatus = Process->ExitStatus;
|
||||||
|
ProcessBasicInformationP->PebBaseAddress = Process->Peb;
|
||||||
ProcessBasicInformationP->AffinityMask = Process->Pcb.Affinity;
|
ProcessBasicInformationP->AffinityMask = Process->Pcb.Affinity;
|
||||||
ProcessBasicInformationP->UniqueProcessId =
|
ProcessBasicInformationP->UniqueProcessId =
|
||||||
Process->UniqueProcessId;
|
Process->UniqueProcessId;
|
||||||
|
@ -494,7 +487,13 @@ NtQueryInformationProcess (
|
||||||
case ProcessAccessToken:
|
case ProcessAccessToken:
|
||||||
case ProcessLdtInformation:
|
case ProcessLdtInformation:
|
||||||
case ProcessLdtSize:
|
case ProcessLdtSize:
|
||||||
|
Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
break;
|
||||||
|
|
||||||
case ProcessDefaultHardErrorMode:
|
case ProcessDefaultHardErrorMode:
|
||||||
|
*((PULONG)ProcessInformation) = Process->DefaultHardErrorProcessing;
|
||||||
|
break;
|
||||||
|
|
||||||
case ProcessIoPortHandlers:
|
case ProcessIoPortHandlers:
|
||||||
case ProcessWorkingSetWatch:
|
case ProcessWorkingSetWatch:
|
||||||
case ProcessUserModeIOPL:
|
case ProcessUserModeIOPL:
|
||||||
|
@ -510,19 +509,41 @@ NtQueryInformationProcess (
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS PspAssignPrimaryToken(PEPROCESS Process,
|
||||||
|
HANDLE TokenHandle)
|
||||||
|
{
|
||||||
|
PACCESS_TOKEN Token;
|
||||||
|
PACCESS_TOKEN OldToken;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(TokenHandle,
|
||||||
|
0,
|
||||||
|
SeTokenType,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)&Token,
|
||||||
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
Status = SeExchangePrimaryToken(Process, Token, &OldToken);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ObDereferenceObject(OldToken);
|
||||||
|
}
|
||||||
|
ObDereferenceObject(Token);
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtSetInformationProcess(IN HANDLE ProcessHandle,
|
||||||
STDCALL
|
IN CINT ProcessInformationClass,
|
||||||
NtSetInformationProcess (
|
IN PVOID ProcessInformation,
|
||||||
IN HANDLE ProcessHandle,
|
IN ULONG ProcessInformationLength)
|
||||||
IN CINT ProcessInformationClass,
|
|
||||||
IN PVOID ProcessInformation,
|
|
||||||
IN ULONG ProcessInformationLength
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PPROCESS_BASIC_INFORMATION ProcessBasicInformationP;
|
PPROCESS_BASIC_INFORMATION ProcessBasicInformationP;
|
||||||
|
PHANDLE ProcessAccessTokenP;
|
||||||
|
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_SET_INFORMATION,
|
PROCESS_SET_INFORMATION,
|
||||||
|
@ -530,7 +551,7 @@ NtSetInformationProcess (
|
||||||
UserMode,
|
UserMode,
|
||||||
(PVOID*)&Process,
|
(PVOID*)&Process,
|
||||||
NULL);
|
NULL);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
@ -554,6 +575,10 @@ NtSetInformationProcess (
|
||||||
case ProcessDebugPort:
|
case ProcessDebugPort:
|
||||||
case ProcessExceptionPort:
|
case ProcessExceptionPort:
|
||||||
case ProcessAccessToken:
|
case ProcessAccessToken:
|
||||||
|
ProcessAccessTokenP = (PHANDLE)ProcessInformation;
|
||||||
|
Status = PspAssignPrimaryToken(Process, *ProcessAccessTokenP);
|
||||||
|
break;
|
||||||
|
|
||||||
case ProcessLdtInformation:
|
case ProcessLdtInformation:
|
||||||
case ProcessLdtSize:
|
case ProcessLdtSize:
|
||||||
case ProcessDefaultHardErrorMode:
|
case ProcessDefaultHardErrorMode:
|
||||||
|
|
244
reactos/ntoskrnl/se/priv.c
Normal file
244
reactos/ntoskrnl/se/priv.c
Normal file
|
@ -0,0 +1,244 @@
|
||||||
|
/* $Id: priv.c,v 1.1 2000/01/26 10:07:30 dwelch Exp $
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* PURPOSE: Security manager
|
||||||
|
* FILE: kernel/se/priv.c
|
||||||
|
* PROGRAMER: ?
|
||||||
|
* REVISION HISTORY:
|
||||||
|
* 26/07/98: Added stubs for security functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
|
BOOLEAN SepPrivilegeCheck(PACCESS_TOKEN Token,
|
||||||
|
PLUID_AND_ATTRIBUTES Privileges,
|
||||||
|
ULONG PrivilegeCount,
|
||||||
|
ULONG PrivilegeControl,
|
||||||
|
KPROCESSOR_MODE PreviousMode)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
PLUID_AND_ATTRIBUTES Current;
|
||||||
|
ULONG j;
|
||||||
|
ULONG k;
|
||||||
|
|
||||||
|
if (PreviousMode == KernelMode)
|
||||||
|
{
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
j = 0;
|
||||||
|
if (PrivilegeCount != 0)
|
||||||
|
{
|
||||||
|
k = PrivilegeCount;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
i = Token->PrivilegeCount;
|
||||||
|
Current = Token->Privileges;
|
||||||
|
for (i = 0; i < Token->PrivilegeCount; i++)
|
||||||
|
{
|
||||||
|
if (!(Current[i].Attributes & SE_PRIVILEGE_ENABLED) &&
|
||||||
|
Privileges[i].Luid.u.LowPart ==
|
||||||
|
Current[i].Luid.u.LowPart &&
|
||||||
|
Privileges[i].Luid.u.HighPart ==
|
||||||
|
Current[i].Luid.u.HighPart)
|
||||||
|
{
|
||||||
|
Privileges[i].Attributes =
|
||||||
|
Privileges[i].Attributes |
|
||||||
|
SE_PRIVILEGE_USED_FOR_ACCESS;
|
||||||
|
j++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
k--;
|
||||||
|
} while (k > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((PrivilegeControl & PRIVILEGE_SET_ALL_NECESSARY) &&
|
||||||
|
PrivilegeCount == j)
|
||||||
|
{
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j > 0 &&
|
||||||
|
!(PrivilegeControl & PRIVILEGE_SET_ALL_NECESSARY))
|
||||||
|
{
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS SeCaptureLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Src,
|
||||||
|
ULONG PrivilegeCount,
|
||||||
|
KPROCESSOR_MODE PreviousMode,
|
||||||
|
PLUID_AND_ATTRIBUTES AllocatedMem,
|
||||||
|
ULONG AllocatedLength,
|
||||||
|
POOL_TYPE PoolType,
|
||||||
|
ULONG d,
|
||||||
|
PLUID_AND_ATTRIBUTES* Dest,
|
||||||
|
PULONG Length)
|
||||||
|
{
|
||||||
|
PLUID_AND_ATTRIBUTES* NewMem;
|
||||||
|
ULONG SrcLength;
|
||||||
|
|
||||||
|
if (PrivilegeCount == 0)
|
||||||
|
{
|
||||||
|
*Dest = 0;
|
||||||
|
*Length = 0;
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
if (PreviousMode == 0 && d == 0)
|
||||||
|
{
|
||||||
|
*Dest = Src;
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
SrcLength = ((PrivilegeCount * sizeof(LUID_AND_ATTRIBUTES)) + 3) & 0xfc;
|
||||||
|
*Length = SrcLength;
|
||||||
|
if (AllocatedMem == NULL)
|
||||||
|
{
|
||||||
|
NewMem = ExAllocatePool(PoolType, SrcLength);
|
||||||
|
*Dest = (PLUID_AND_ATTRIBUTES)NewMem;
|
||||||
|
if (NewMem == NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (SrcLength > AllocatedLength)
|
||||||
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
*Dest = AllocatedMem;
|
||||||
|
}
|
||||||
|
memmove(*Dest, Src, SrcLength);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID SeReleaseLuidAndAttributesArray(PLUID_AND_ATTRIBUTES Privilege,
|
||||||
|
KPROCESSOR_MODE PreviousMode,
|
||||||
|
ULONG a)
|
||||||
|
{
|
||||||
|
ExFreePool(Privilege);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtPrivilegeCheck (IN HANDLE ClientToken,
|
||||||
|
IN PPRIVILEGE_SET RequiredPrivileges,
|
||||||
|
IN PBOOLEAN Result)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
PACCESS_TOKEN Token;
|
||||||
|
ULONG PrivilegeCount;
|
||||||
|
BOOLEAN TResult;
|
||||||
|
ULONG PrivilegeControl;
|
||||||
|
PLUID_AND_ATTRIBUTES Privilege;
|
||||||
|
ULONG Length;
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(ClientToken,
|
||||||
|
0,
|
||||||
|
SeTokenType,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)&Token,
|
||||||
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
if (Token->TokenType == TokenImpersonation &&
|
||||||
|
Token->ImpersonationLevel < SecurityAnonymous)
|
||||||
|
{
|
||||||
|
ObDereferenceObject(Token);
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
PrivilegeCount = RequiredPrivileges->PrivilegeCount;
|
||||||
|
PrivilegeControl = RequiredPrivileges->Control;
|
||||||
|
Privilege = 0;
|
||||||
|
Status = SeCaptureLuidAndAttributesArray(RequiredPrivileges->Privilege,
|
||||||
|
PrivilegeCount,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
&Privilege,
|
||||||
|
&Length);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ObDereferenceObject(Token);
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
TResult = SepPrivilegeCheck(Token,
|
||||||
|
Privilege,
|
||||||
|
PrivilegeCount,
|
||||||
|
PrivilegeControl,
|
||||||
|
UserMode);
|
||||||
|
memmove(RequiredPrivileges->Privilege, Privilege, Length);
|
||||||
|
*Result = TResult;
|
||||||
|
SeReleaseLuidAndAttributesArray(Privilege, UserMode, 1);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN STDCALL SePrivilegeCheck(PPRIVILEGE_SET Privileges,
|
||||||
|
PSECURITY_SUBJECT_CONTEXT SubjectContext,
|
||||||
|
KPROCESSOR_MODE PreviousMode)
|
||||||
|
{
|
||||||
|
PACCESS_TOKEN Token = NULL;
|
||||||
|
|
||||||
|
if (SubjectContext->ClientToken == NULL)
|
||||||
|
{
|
||||||
|
Token = SubjectContext->PrimaryToken;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Token = SubjectContext->ClientToken;
|
||||||
|
if (SubjectContext->ImpersonationLevel < 2)
|
||||||
|
{
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(SepPrivilegeCheck(Token,
|
||||||
|
Privileges->Privilege,
|
||||||
|
Privileges->PrivilegeCount,
|
||||||
|
Privileges->Control,
|
||||||
|
PreviousMode));
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN STDCALL SeSinglePrivilegeCheck(LUID PrivilegeValue,
|
||||||
|
KPROCESSOR_MODE PreviousMode)
|
||||||
|
{
|
||||||
|
SECURITY_SUBJECT_CONTEXT SubjectContext;
|
||||||
|
BOOLEAN r;
|
||||||
|
PRIVILEGE_SET Priv;
|
||||||
|
|
||||||
|
SeCaptureSubjectContext(&SubjectContext);
|
||||||
|
|
||||||
|
Priv.PrivilegeCount = 1;
|
||||||
|
Priv.Control = 1;
|
||||||
|
Priv.Privilege[0].Luid = PrivilegeValue;
|
||||||
|
Priv.Privilege[0].Attributes = 0;
|
||||||
|
|
||||||
|
r = SePrivilegeCheck(&Priv,
|
||||||
|
&SubjectContext,
|
||||||
|
PreviousMode);
|
||||||
|
|
||||||
|
if (PreviousMode != KernelMode)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
SePrivilegeServiceAuditAlarm(0,
|
||||||
|
&SubjectContext,
|
||||||
|
&PrivilegeValue);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
SeReleaseSubjectContext(&SubjectContext);
|
||||||
|
return(r);
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: semgr.c,v 1.14 2000/01/05 21:57:00 dwelch Exp $
|
/* $Id: semgr.c,v 1.15 2000/01/26 10:07:30 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -27,266 +27,6 @@ VOID SepDeReferenceLogonSession(PLUID AuthenticationId)
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID SepFreeProxyData(PVOID ProxyData)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS SepCopyProxyData(PVOID* Dest, PVOID Src)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS SepDuplicationToken(PACCESS_TOKEN Token,
|
|
||||||
PULONG a,
|
|
||||||
ULONG b,
|
|
||||||
TOKEN_TYPE TokenType,
|
|
||||||
SECURITY_IMPERSONATION_LEVEL Level,
|
|
||||||
ULONG d,
|
|
||||||
PACCESS_TOKEN* e)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
PVOID mem1;
|
|
||||||
PVOID mem2;
|
|
||||||
PVOID f;
|
|
||||||
PACCESS_TOKEN g;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
if (TokenType == 2 &&
|
|
||||||
(Level > 3 || Level < 0))
|
|
||||||
{
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
|
|
||||||
SepReferenceLogonSession(&Token->AuthenticationId);
|
|
||||||
|
|
||||||
mem1 = ExAllocatePool(NonPagedPool, Token->DynamicCharged);
|
|
||||||
if (mem1 == NULL)
|
|
||||||
{
|
|
||||||
SepDeReferenceLogonSession(&Token->AuthenticationId);
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
if (Token->ProxyData != NULL)
|
|
||||||
{
|
|
||||||
Status = SepCopyProxyData(&f, Token->ProxyData);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
SepDeReferenceLogonSession(&Token->AuthenticationId);
|
|
||||||
ExFreePool(mem1);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
f = 0;
|
|
||||||
}
|
|
||||||
if (Token->AuditData != NULL)
|
|
||||||
{
|
|
||||||
mem2 = ExAllocatePool(NonPagedPool, 0xc);
|
|
||||||
if (mem2 == NULL)
|
|
||||||
{
|
|
||||||
SepFreeProxyData(f);
|
|
||||||
SepDeReferenceLogonSession(&Token->AuthenticationId);
|
|
||||||
ExFreePool(mem1);
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
memcpy(mem2, Token->AuditData, 0xc);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mem2 = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = ObCreateObject(d,
|
|
||||||
SeTokenType,
|
|
||||||
b,
|
|
||||||
d,
|
|
||||||
0,
|
|
||||||
Token->VariableLength + 0x78,
|
|
||||||
Token->DynamicCharged,
|
|
||||||
Token->VariableLength + 0x78,
|
|
||||||
&g);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
SepDeReferenceLogonSession(Token->AuthenticationId);
|
|
||||||
ExFreePool(mem1);
|
|
||||||
SepFreeProxyData(f);
|
|
||||||
if (mem2 != NULL)
|
|
||||||
{
|
|
||||||
ExFreePool(mem2);
|
|
||||||
}
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
g->TokenId = Token->TokenId;
|
|
||||||
g->ModifiedId = Token->ModifiedId;
|
|
||||||
g->ExpirationTime = Token->ExpirationTime;
|
|
||||||
memcpy(&g->TokenSource, &Token->TokenSource, sizeof(TOKEN_SOURCE));
|
|
||||||
g->DynamicCharged = Token->DynamicCharged;
|
|
||||||
g->DynamicAvailable = Token->DynamicAvailable;
|
|
||||||
g->DefaultOwnerIndex = Token->DefaultOwnerIndex;
|
|
||||||
g->UserAndGroupCount = Token->UserAndGroupCount;
|
|
||||||
g->PrivilegeCount = Token->PrivilegeCount;
|
|
||||||
g->VariableLength = Token->VariableLength;
|
|
||||||
g->TokenFlags = Token->TokenFlags;
|
|
||||||
g->ProxyData = f;
|
|
||||||
g->AuditData = mem2;
|
|
||||||
//g->TokenId = ExInterlockedExchangeAdd();
|
|
||||||
g->TokenInUse = 0;
|
|
||||||
g->TokenType = TokenType;
|
|
||||||
g->ImpersonationLevel = Level;
|
|
||||||
memmove(g->VariablePart, Token->VariablePart, Token->VariableLength);
|
|
||||||
/* ... */
|
|
||||||
*e = g;
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
#endif
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS SeCopyClientToken(PACCESS_TOKEN Token,
|
|
||||||
SECURITY_IMPERSONATION_LEVEL Level,
|
|
||||||
ULONG a,
|
|
||||||
PACCESS_TOKEN* b)
|
|
||||||
{
|
|
||||||
ULONG c;
|
|
||||||
PACCESS_TOKEN d;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
c = 18;
|
|
||||||
Status = SepDuplicationToken(Token,
|
|
||||||
&c,
|
|
||||||
0,
|
|
||||||
TokenImpersonation,
|
|
||||||
Level,
|
|
||||||
a,
|
|
||||||
&d);
|
|
||||||
*b = d;
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS SeCreateClientSecurity(PETHREAD Thread,
|
|
||||||
PSECURITY_QUALITY_OF_SERVICE Qos,
|
|
||||||
ULONG e,
|
|
||||||
PSE_SOME_STRUCT2 f)
|
|
||||||
{
|
|
||||||
TOKEN_TYPE TokenType;
|
|
||||||
UCHAR b;
|
|
||||||
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
|
|
||||||
PACCESS_TOKEN Token;
|
|
||||||
ULONG g;
|
|
||||||
PACCESS_TOKEN NewToken;
|
|
||||||
|
|
||||||
Token = PsReferenceEffectiveToken(Thread,
|
|
||||||
&TokenType,
|
|
||||||
&b,
|
|
||||||
&ImpersonationLevel);
|
|
||||||
if (TokenType != 2)
|
|
||||||
{
|
|
||||||
f->Unknown9 = Qos->EffectiveOnly;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (Qos->ImpersonationLevel > ImpersonationLevel)
|
|
||||||
{
|
|
||||||
if (Token != NULL)
|
|
||||||
{
|
|
||||||
ObDereferenceObject(Token);
|
|
||||||
}
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
if (ImpersonationLevel == 0 ||
|
|
||||||
ImpersonationLevel == 1 ||
|
|
||||||
(e != 0 && ImpersonationLevel != 3))
|
|
||||||
{
|
|
||||||
if (Token != NULL)
|
|
||||||
{
|
|
||||||
ObDereferenceObject(Token);
|
|
||||||
}
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
if (b != 0 ||
|
|
||||||
Qos->EffectiveOnly != 0)
|
|
||||||
{
|
|
||||||
f->Unknown9 = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
f->Unknown9 = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Qos->ContextTrackingMode == 0)
|
|
||||||
{
|
|
||||||
f->Unknown8 = 0;
|
|
||||||
g = SeCopyClientToken(Token, ImpersonationLevel, 0, &NewToken);
|
|
||||||
if (g >= 0)
|
|
||||||
{
|
|
||||||
// ObDeleteCapturedInsertInfo(NewToken);
|
|
||||||
}
|
|
||||||
if (TokenType == TokenPrimary || Token != NULL)
|
|
||||||
{
|
|
||||||
ObDereferenceObject(Token);
|
|
||||||
}
|
|
||||||
if (g < 0)
|
|
||||||
{
|
|
||||||
return(g);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
f->Unknown8 = 1;
|
|
||||||
if (e != 0)
|
|
||||||
{
|
|
||||||
// SeGetTokenControlInformation(Token, &f->Unknown11);
|
|
||||||
}
|
|
||||||
NewToken = Token;
|
|
||||||
}
|
|
||||||
f->Unknown1 = 0xc;
|
|
||||||
f->Level = Qos->ImpersonationLevel;
|
|
||||||
f->ContextTrackingMode = Qos->ContextTrackingMode;
|
|
||||||
f->EffectiveOnly = Qos->EffectiveOnly;
|
|
||||||
f->Unknown10 = e;
|
|
||||||
f->Token = NewToken;
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VOID SeImpersonateClient(PSE_SOME_STRUCT2 a,
|
|
||||||
PETHREAD Thread)
|
|
||||||
{
|
|
||||||
UCHAR b;
|
|
||||||
|
|
||||||
if (a->Unknown8 == 0)
|
|
||||||
{
|
|
||||||
b = a->EffectiveOnly;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
b = a->Unknown9;
|
|
||||||
}
|
|
||||||
if (Thread == NULL)
|
|
||||||
{
|
|
||||||
Thread = PsGetCurrentThread();
|
|
||||||
}
|
|
||||||
PsImpersonateClient(Thread,
|
|
||||||
a->Token,
|
|
||||||
1,
|
|
||||||
(ULONG)b,
|
|
||||||
a->Level);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtPrivilegeCheck (IN HANDLE ClientToken,
|
|
||||||
IN PPRIVILEGE_SET RequiredPrivileges,
|
|
||||||
IN PBOOLEAN Result)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtPrivilegedServiceAuditAlarm(
|
NTSTATUS STDCALL NtPrivilegedServiceAuditAlarm(
|
||||||
IN PUNICODE_STRING SubsystemName,
|
IN PUNICODE_STRING SubsystemName,
|
||||||
IN PUNICODE_STRING ServiceName,
|
IN PUNICODE_STRING ServiceName,
|
||||||
|
@ -392,6 +132,8 @@ NtDeleteObjectAuditAlarm (
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID STDCALL SeReleaseSubjectContext (PSECURITY_SUBJECT_CONTEXT SubjectContext)
|
VOID STDCALL SeReleaseSubjectContext (PSECURITY_SUBJECT_CONTEXT SubjectContext)
|
||||||
{
|
{
|
||||||
ObDereferenceObject(SubjectContext->PrimaryToken);
|
ObDereferenceObject(SubjectContext->PrimaryToken);
|
||||||
|
@ -417,129 +159,127 @@ VOID STDCALL SeCaptureSubjectContext (PSECURITY_SUBJECT_CONTEXT SubjectContext)
|
||||||
&SubjectContext->ImpersonationLevel);
|
&SubjectContext->ImpersonationLevel);
|
||||||
SubjectContext->PrimaryToken = PsReferencePrimaryToken(Process);
|
SubjectContext->PrimaryToken = PsReferencePrimaryToken(Process);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN SepPrivilegeCheck(PACCESS_TOKEN Token,
|
NTSTATUS STDCALL SeDeassignSecurity(PSECURITY_DESCRIPTOR* SecurityDescriptor)
|
||||||
PLUID_AND_ATTRIBUTES Privileges,
|
|
||||||
ULONG PrivilegeCount,
|
|
||||||
ULONG PrivilegeControl,
|
|
||||||
KPROCESSOR_MODE PreviousMode)
|
|
||||||
{
|
{
|
||||||
ULONG i;
|
if ((*SecurityDescriptor) != NULL)
|
||||||
PLUID_AND_ATTRIBUTES Current;
|
|
||||||
ULONG j;
|
|
||||||
ULONG k;
|
|
||||||
|
|
||||||
if (PreviousMode == KernelMode)
|
|
||||||
{
|
{
|
||||||
return(TRUE);
|
ExFreePool(*SecurityDescriptor);
|
||||||
|
(*SecurityDescriptor) = NULL;
|
||||||
}
|
}
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
j = 0;
|
|
||||||
if (PrivilegeCount != 0)
|
|
||||||
{
|
|
||||||
k = PrivilegeCount;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
i = Token->PrivilegeCount;
|
|
||||||
Current = Token->Privileges;
|
|
||||||
for (i = 0; i < Token->PrivilegeCount; i++)
|
|
||||||
{
|
|
||||||
if (!(Current[i].Attributes & 2) &&
|
|
||||||
Privileges[i].Luid.u.LowPart ==
|
|
||||||
Current[i].Luid.u.LowPart &&
|
|
||||||
Privileges[i].Luid.u.HighPart ==
|
|
||||||
Current[i].Luid.u.HighPart)
|
|
||||||
{
|
|
||||||
Privileges[i].Attributes =
|
|
||||||
Privileges[i].Attributes | 0x80;
|
|
||||||
j++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
k--;
|
|
||||||
} while (k > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((PrivilegeControl & 0x2) && PrivilegeCount == j)
|
|
||||||
{
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j > 0 && !(PrivilegeControl & 0x2))
|
|
||||||
{
|
|
||||||
return(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN STDCALL SePrivilegeCheck(PPRIVILEGE_SET Privileges,
|
#if 0
|
||||||
PSECURITY_SUBJECT_CONTEXT SubjectContext,
|
VOID SepGetDefaultsSubjectContext(PSECURITY_SUBJECT_CONTEXT SubjectContext,
|
||||||
KPROCESSOR_MODE PreviousMode)
|
PSID* Owner,
|
||||||
|
PSID* PrimaryGroup,
|
||||||
|
PSID* ProcessOwner,
|
||||||
|
PSID* ProcessPrimaryGroup,
|
||||||
|
PACL* DefaultDacl)
|
||||||
{
|
{
|
||||||
PACCESS_TOKEN Token = NULL;
|
PACCESS_TOKEN Token;
|
||||||
|
|
||||||
if (SubjectContext->ClientToken == NULL)
|
if (SubjectContext->ClientToken != NULL)
|
||||||
{
|
{
|
||||||
Token = SubjectContext->PrimaryToken;
|
Token = SubjectContext->ClientToken;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Token = SubjectContext->ClientToken;
|
Token = SubjectContext->PrimaryToken;
|
||||||
if (SubjectContext->ImpersonationLevel < 2)
|
|
||||||
{
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
*Owner = Token->UserAndGroups[Token->DefaultOwnerIndex].Sid;
|
||||||
return(SepPrivilegeCheck(Token,
|
*PrimaryGroup = Token->PrimaryGroup;
|
||||||
Privileges->Privilege,
|
*DefaultDacl = Token->DefaultDacl;
|
||||||
Privileges->PrivilegeCount,
|
*ProcessOwner = SubjectContext->PrimaryToken->
|
||||||
Privileges->Control,
|
UserAndGroups[Token->DefaultOwnerIndex].Sid;
|
||||||
PreviousMode));
|
*ProcessPrimaryGroup = SubjectContext->PrimaryToken->PrimaryGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN STDCALL SeSinglePrivilegeCheck(LUID PrivilegeValue,
|
NTSTATUS SepInheritAcl(PACL Acl,
|
||||||
KPROCESSOR_MODE PreviousMode)
|
BOOLEAN IsDirectoryObject,
|
||||||
|
PSID Owner,
|
||||||
|
PSID PrimaryGroup,
|
||||||
|
PACL DefaultAcl,
|
||||||
|
PSID ProcessOwner,
|
||||||
|
PSID ProcessGroup,
|
||||||
|
PGENERIC_MAPPING GenericMapping)
|
||||||
{
|
{
|
||||||
SECURITY_SUBJECT_CONTEXT SubjectContext;
|
if (Acl == NULL)
|
||||||
BOOLEAN r;
|
|
||||||
PRIVILEGE_SET Priv;
|
|
||||||
|
|
||||||
SeCaptureSubjectContext(&SubjectContext);
|
|
||||||
|
|
||||||
Priv.PrivilegeCount = 1;
|
|
||||||
Priv.Control = 1;
|
|
||||||
Priv.Privilege[0].Luid = PrivilegeValue;
|
|
||||||
Priv.Privilege[0].Attributes = 0;
|
|
||||||
|
|
||||||
r = SePrivilegeCheck(&Priv,
|
|
||||||
&SubjectContext,
|
|
||||||
PreviousMode);
|
|
||||||
|
|
||||||
if (PreviousMode != KernelMode)
|
|
||||||
{
|
{
|
||||||
/* SePrivilegeServiceAuditAlarm(0,
|
return(STATUS_UNSUCCESSFUL);
|
||||||
&SubjectContext,
|
|
||||||
&PrivilegeValue);*/
|
|
||||||
}
|
}
|
||||||
SeReleaseSubjectContext(&SubjectContext);
|
if (Acl->AclRevision != 2 &&
|
||||||
return(r);
|
Acl->AclRevision != 3 )
|
||||||
}
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
NTSTATUS STDCALL SeDeassignSecurity(PSECURITY_DESCRIPTOR* SecurityDescriptor)
|
}
|
||||||
{
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
NTSTATUS STDCALL SeAssignSecurity(PSECURITY_DESCRIPTOR ParentDescriptor,
|
NTSTATUS STDCALL SeAssignSecurity(PSECURITY_DESCRIPTOR ParentDescriptor,
|
||||||
PSECURITY_DESCRIPTOR ExplicitDescriptor,
|
PSECURITY_DESCRIPTOR ExplicitDescriptor,
|
||||||
|
PSECURITY_DESCRIPTOR* NewDescriptor,
|
||||||
BOOLEAN IsDirectoryObject,
|
BOOLEAN IsDirectoryObject,
|
||||||
PSECURITY_SUBJECT_CONTEXT SubjectContext,
|
PSECURITY_SUBJECT_CONTEXT SubjectContext,
|
||||||
PGENERIC_MAPPING GenericMapping,
|
PGENERIC_MAPPING GenericMapping,
|
||||||
POOL_TYPE PoolType)
|
POOL_TYPE PoolType)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
#if 0
|
||||||
|
PSECURITY_DESCRIPTOR Descriptor;
|
||||||
|
PSID Owner;
|
||||||
|
PSID PrimaryGroup;
|
||||||
|
PACL DefaultDacl;
|
||||||
|
PSID ProcessOwner;
|
||||||
|
PSID ProcessPrimaryGroup;
|
||||||
|
PACL Sacl;
|
||||||
|
|
||||||
|
if (ExplicitDescriptor == NULL)
|
||||||
|
{
|
||||||
|
RtlCreateSecurityDescriptor(&Descriptor, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Descriptor = ExplicitDescriptor;
|
||||||
|
}
|
||||||
|
SeLockSubjectContext(SubjectContext);
|
||||||
|
SepGetDefaultsSubjectContext(SubjectContext,
|
||||||
|
&Owner,
|
||||||
|
&PrimaryGroup,
|
||||||
|
&DefaultDacl,
|
||||||
|
&ProcessOwner,
|
||||||
|
&ProcessPrimaryGroup);
|
||||||
|
if (Descriptor->Control & SE_SACL_PRESENT ||
|
||||||
|
Descriptor->Control & SE_SACL_DEFAULTED)
|
||||||
|
{
|
||||||
|
if (ParentDescriptor == NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
if (Descriptor->Control & SE_SACL_PRESENT ||
|
||||||
|
Descriptor->Sacl == NULL ||)
|
||||||
|
{
|
||||||
|
Sacl = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Sacl = Descriptor->Sacl;
|
||||||
|
if (Descriptor->Control & SE_SELF_RELATIVE)
|
||||||
|
{
|
||||||
|
Sacl = (PACL)(((PVOID)Sacl) + (PVOID)Descriptor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SepInheritAcl(Sacl,
|
||||||
|
IsDirectoryObject,
|
||||||
|
Owner,
|
||||||
|
PrimaryGroup,
|
||||||
|
DefaultDacl,
|
||||||
|
ProcessOwner,
|
||||||
|
GenericMapping);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN SepSidInToken(PACCESS_TOKEN Token,
|
BOOLEAN SepSidInToken(PACCESS_TOKEN Token,
|
||||||
|
@ -557,7 +297,7 @@ BOOLEAN SepSidInToken(PACCESS_TOKEN Token,
|
||||||
if (RtlEqualSid(Sid, Token->UserAndGroups[i].Sid))
|
if (RtlEqualSid(Sid, Token->UserAndGroups[i].Sid))
|
||||||
{
|
{
|
||||||
if (i == 0 ||
|
if (i == 0 ||
|
||||||
(!(Token->UserAndGroups[i].Attributes & 0x4)))
|
(!(Token->UserAndGroups[i].Attributes & SE_GROUP_ENABLED)))
|
||||||
{
|
{
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: token.c,v 1.3 2000/01/05 21:57:00 dwelch Exp $
|
/* $Id: token.c,v 1.4 2000/01/26 10:07:30 dwelch Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -21,6 +21,188 @@ POBJECT_TYPE SeTokenType = NULL;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
VOID SepFreeProxyData(PVOID ProxyData)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS SepCopyProxyData(PVOID* Dest, PVOID Src)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS SeExchangePrimaryToken(PEPROCESS Process,
|
||||||
|
PACCESS_TOKEN NewToken,
|
||||||
|
PACCESS_TOKEN* OldTokenP)
|
||||||
|
{
|
||||||
|
PACCESS_TOKEN OldToken;
|
||||||
|
|
||||||
|
if (NewToken->TokenType != TokenPrimary)
|
||||||
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
if (NewToken->TokenInUse != 0)
|
||||||
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
OldToken = Process->Token;
|
||||||
|
Process->Token = NewToken;
|
||||||
|
NewToken->TokenInUse = 1;
|
||||||
|
ObReferenceObjectByPointer(NewToken,
|
||||||
|
GENERIC_ALL,
|
||||||
|
SeTokenType,
|
||||||
|
KernelMode);
|
||||||
|
OldToken->TokenInUse = 0;
|
||||||
|
*OldTokenP = OldToken;
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS SepDuplicationToken(PACCESS_TOKEN Token,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
TOKEN_TYPE TokenType,
|
||||||
|
SECURITY_IMPERSONATION_LEVEL Level,
|
||||||
|
SECURITY_IMPERSONATION_LEVEL ExistingLevel,
|
||||||
|
KPROCESSOR_MODE PreviousMode,
|
||||||
|
PACCESS_TOKEN* NewAccessToken)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS SeCopyClientToken(PACCESS_TOKEN Token,
|
||||||
|
SECURITY_IMPERSONATION_LEVEL Level,
|
||||||
|
KPROCESSOR_MODE PreviousMode,
|
||||||
|
PACCESS_TOKEN* NewToken)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
Status = SepDuplicationToken(Token,
|
||||||
|
&ObjectAttributes,
|
||||||
|
0,
|
||||||
|
SecurityIdentification,
|
||||||
|
Level,
|
||||||
|
PreviousMode,
|
||||||
|
NewToken);
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS SeCreateClientSecurity(PETHREAD Thread,
|
||||||
|
PSECURITY_QUALITY_OF_SERVICE Qos,
|
||||||
|
ULONG e,
|
||||||
|
PSE_SOME_STRUCT2 f)
|
||||||
|
{
|
||||||
|
TOKEN_TYPE TokenType;
|
||||||
|
UCHAR b;
|
||||||
|
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
|
||||||
|
PACCESS_TOKEN Token;
|
||||||
|
ULONG g;
|
||||||
|
PACCESS_TOKEN NewToken;
|
||||||
|
|
||||||
|
Token = PsReferenceEffectiveToken(Thread,
|
||||||
|
&TokenType,
|
||||||
|
&b,
|
||||||
|
&ImpersonationLevel);
|
||||||
|
if (TokenType != 2)
|
||||||
|
{
|
||||||
|
f->Unknown9 = Qos->EffectiveOnly;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Qos->ImpersonationLevel > ImpersonationLevel)
|
||||||
|
{
|
||||||
|
if (Token != NULL)
|
||||||
|
{
|
||||||
|
ObDereferenceObject(Token);
|
||||||
|
}
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
if (ImpersonationLevel == 0 ||
|
||||||
|
ImpersonationLevel == 1 ||
|
||||||
|
(e != 0 && ImpersonationLevel != 3))
|
||||||
|
{
|
||||||
|
if (Token != NULL)
|
||||||
|
{
|
||||||
|
ObDereferenceObject(Token);
|
||||||
|
}
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
if (b != 0 ||
|
||||||
|
Qos->EffectiveOnly != 0)
|
||||||
|
{
|
||||||
|
f->Unknown9 = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
f->Unknown9 = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Qos->ContextTrackingMode == 0)
|
||||||
|
{
|
||||||
|
f->Unknown8 = 0;
|
||||||
|
g = SeCopyClientToken(Token, ImpersonationLevel, 0, &NewToken);
|
||||||
|
if (g >= 0)
|
||||||
|
{
|
||||||
|
// ObDeleteCapturedInsertInfo(NewToken);
|
||||||
|
}
|
||||||
|
if (TokenType == TokenPrimary || Token != NULL)
|
||||||
|
{
|
||||||
|
ObDereferenceObject(Token);
|
||||||
|
}
|
||||||
|
if (g < 0)
|
||||||
|
{
|
||||||
|
return(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
f->Unknown8 = 1;
|
||||||
|
if (e != 0)
|
||||||
|
{
|
||||||
|
// SeGetTokenControlInformation(Token, &f->Unknown11);
|
||||||
|
}
|
||||||
|
NewToken = Token;
|
||||||
|
}
|
||||||
|
f->Unknown1 = 0xc;
|
||||||
|
f->Level = Qos->ImpersonationLevel;
|
||||||
|
f->ContextTrackingMode = Qos->ContextTrackingMode;
|
||||||
|
f->EffectiveOnly = Qos->EffectiveOnly;
|
||||||
|
f->Unknown10 = e;
|
||||||
|
f->Token = NewToken;
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID SeImpersonateClient(PSE_SOME_STRUCT2 a,
|
||||||
|
PETHREAD Thread)
|
||||||
|
{
|
||||||
|
UCHAR b;
|
||||||
|
|
||||||
|
if (a->Unknown8 == 0)
|
||||||
|
{
|
||||||
|
b = a->EffectiveOnly;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
b = a->Unknown9;
|
||||||
|
}
|
||||||
|
if (Thread == NULL)
|
||||||
|
{
|
||||||
|
Thread = PsGetCurrentThread();
|
||||||
|
}
|
||||||
|
PsImpersonateClient(Thread,
|
||||||
|
a->Token,
|
||||||
|
1,
|
||||||
|
(ULONG)b,
|
||||||
|
a->Level);
|
||||||
|
}
|
||||||
|
|
||||||
VOID SeInitializeTokenManager(VOID)
|
VOID SeInitializeTokenManager(VOID)
|
||||||
{
|
{
|
||||||
UNICODE_STRING TypeName;
|
UNICODE_STRING TypeName;
|
||||||
|
@ -214,20 +396,54 @@ NtSetInformationToken(
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtDuplicateToken(IN HANDLE ExistingTokenHandle,
|
||||||
STDCALL
|
IN ACCESS_MASK DesiredAccess,
|
||||||
NtDuplicateToken (
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
IN HANDLE ExistingToken,
|
IN SECURITY_IMPERSONATION_LEVEL
|
||||||
IN ACCESS_MASK DesiredAccess,
|
ImpersonationLevel,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
IN TOKEN_TYPE TokenType,
|
||||||
IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
|
OUT PHANDLE NewTokenHandle)
|
||||||
IN TOKEN_TYPE TokenType,
|
|
||||||
OUT PHANDLE NewToken
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
#if 0
|
||||||
|
PACCESS_TOKEN Token;
|
||||||
|
PACCESS_TOKEN NewToken;
|
||||||
|
NTSTATUS Status;
|
||||||
|
ULONG ExistingImpersonationLevel;
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(ExistingTokenHandle,
|
||||||
|
?,
|
||||||
|
SeTokenType,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)&Token,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
ExistingImpersonationLevel = Token->ImpersonationLevel;
|
||||||
|
SepDuplicateToken(Token,
|
||||||
|
ObjectAttributes,
|
||||||
|
ImpersonationLevel,
|
||||||
|
TokenType,
|
||||||
|
ExistingImpersonationLevel,
|
||||||
|
KeGetPreviousMode(),
|
||||||
|
&NewToken);
|
||||||
|
#else
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID SepAdjustGroups(PACCESS_TOKEN Token,
|
||||||
|
ULONG a,
|
||||||
|
BOOLEAN ResetToDefault,
|
||||||
|
PSID_AND_ATTRIBUTES Groups,
|
||||||
|
ULONG b,
|
||||||
|
KPROCESSOR_MODE PreviousMode,
|
||||||
|
ULONG c,
|
||||||
|
PULONG d,
|
||||||
|
PULONG e,
|
||||||
|
PULONG f)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtAdjustGroupsToken(IN HANDLE TokenHandle,
|
NTSTATUS STDCALL NtAdjustGroupsToken(IN HANDLE TokenHandle,
|
||||||
IN BOOLEAN ResetToDefault,
|
IN BOOLEAN ResetToDefault,
|
||||||
IN PTOKEN_GROUPS NewState,
|
IN PTOKEN_GROUPS NewState,
|
||||||
|
@ -235,20 +451,128 @@ NTSTATUS STDCALL NtAdjustGroupsToken(IN HANDLE TokenHandle,
|
||||||
OUT PTOKEN_GROUPS PreviousState OPTIONAL,
|
OUT PTOKEN_GROUPS PreviousState OPTIONAL,
|
||||||
OUT PULONG ReturnLength)
|
OUT PULONG ReturnLength)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
|
NTSTATUS Status;
|
||||||
|
PACCESS_TOKEN Token;
|
||||||
|
ULONG a;
|
||||||
|
ULONG b;
|
||||||
|
ULONG c;
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(TokenHandle,
|
||||||
|
?,
|
||||||
|
SeTokenType,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)&Token,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
|
||||||
|
SepAdjustGroups(Token,
|
||||||
|
0,
|
||||||
|
ResetToDefault,
|
||||||
|
NewState->Groups,
|
||||||
|
?,
|
||||||
|
PreviousState,
|
||||||
|
0,
|
||||||
|
&a,
|
||||||
|
&b,
|
||||||
|
&c);
|
||||||
|
#else
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
NTSTATUS
|
NTSTATUS SepAdjustPrivileges(PACCESS_TOKEN Token, // 0x8
|
||||||
STDCALL
|
ULONG a, // 0xC
|
||||||
NtAdjustPrivilegesToken(IN HANDLE TokenHandle,
|
KPROCESSOR_MODE PreviousMode, // 0x10
|
||||||
|
ULONG PrivilegeCount, // 0x14
|
||||||
|
PLUID_AND_ATTRIBUTES Privileges, // 0x18
|
||||||
|
PTOKEN_PRIVILEGES* PreviousState, // 0x1C
|
||||||
|
PULONG b, // 0x20
|
||||||
|
PULONG c, // 0x24
|
||||||
|
PULONG d) // 0x28
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
|
||||||
|
*c = 0;
|
||||||
|
if (Token->PrivilegeCount > 0)
|
||||||
|
{
|
||||||
|
for (i=0; i<Token->PrivilegeCount; i++)
|
||||||
|
{
|
||||||
|
if (PreviousMode != 0)
|
||||||
|
{
|
||||||
|
if (!(Token->Privileges[i]->Attributes &
|
||||||
|
SE_PRIVILEGE_ENABLED))
|
||||||
|
{
|
||||||
|
if (a != 0)
|
||||||
|
{
|
||||||
|
if (PreviousState != NULL)
|
||||||
|
{
|
||||||
|
memcpy(&PreviousState[i],
|
||||||
|
&Token->Privileges[i],
|
||||||
|
sizeof(LUID_AND_ATTRIBUTES));
|
||||||
|
}
|
||||||
|
Token->Privileges[i].Attributes =
|
||||||
|
Token->Privileges[i].Attributes &
|
||||||
|
(~SE_PRIVILEGE_ENABLED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (PreviousMode != 0)
|
||||||
|
{
|
||||||
|
Token->TokenFlags = Token->TokenFlags & (~1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (PrivilegeCount <= ?)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtAdjustPrivilegesToken(IN HANDLE TokenHandle,
|
||||||
IN BOOLEAN DisableAllPrivileges,
|
IN BOOLEAN DisableAllPrivileges,
|
||||||
IN PTOKEN_PRIVILEGES NewState,
|
IN PTOKEN_PRIVILEGES NewState,
|
||||||
IN ULONG BufferLength,
|
IN ULONG BufferLength,
|
||||||
OUT PTOKEN_PRIVILEGES PreviousState,
|
OUT PTOKEN_PRIVILEGES PreviousState,
|
||||||
OUT PULONG ReturnLength)
|
OUT PULONG ReturnLength)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
#if 0
|
||||||
|
ULONG PrivilegeCount;
|
||||||
|
ULONG Length;
|
||||||
|
PSID_AND_ATTRIBUTES Privileges;
|
||||||
|
ULONG a;
|
||||||
|
ULONG b;
|
||||||
|
ULONG c;
|
||||||
|
|
||||||
|
PrivilegeCount = NewState->PrivilegeCount;
|
||||||
|
|
||||||
|
SeCaptureLuidAndAttributesArray(NewState->Privileges,
|
||||||
|
&PrivilegeCount,
|
||||||
|
KeGetPreviousMode(),
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NonPagedPool,
|
||||||
|
1,
|
||||||
|
&Privileges.
|
||||||
|
&Length);
|
||||||
|
SepAdjustPrivileges(Token,
|
||||||
|
0,
|
||||||
|
KeGetPreviousMode(),
|
||||||
|
PrivilegeCount,
|
||||||
|
Privileges,
|
||||||
|
PreviousState,
|
||||||
|
&a,
|
||||||
|
&b,
|
||||||
|
&c);
|
||||||
|
#else
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtCreateToken(OUT PHANDLE TokenHandle,
|
NTSTATUS STDCALL NtCreateToken(OUT PHANDLE TokenHandle,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: smss.c,v 1.4 1999/12/15 06:48:10 phreak Exp $
|
/* $Id: smss.c,v 1.5 2000/01/26 10:07:30 dwelch Exp $
|
||||||
*
|
*
|
||||||
* smss.c - Session Manager
|
* smss.c - Session Manager
|
||||||
*
|
*
|
||||||
|
@ -66,67 +66,66 @@ PrintString (char* fmt,...)
|
||||||
|
|
||||||
/* Native image's entry point */
|
/* Native image's entry point */
|
||||||
|
|
||||||
void
|
void NtProcessStartup (PPEB Peb)
|
||||||
NtProcessStartup (PPEB Peb)
|
|
||||||
{
|
{
|
||||||
HANDLE Children[2]; /* csrss, winlogon */
|
HANDLE Children[2]; /* csrss, winlogon */
|
||||||
|
|
||||||
DisplayString( L"Session Manager\n" );
|
DisplayString( L"Session Manager\n" );
|
||||||
|
|
||||||
PrintString ("Peb %x\n", Peb);
|
PrintString ("Peb %x\n", Peb);
|
||||||
|
|
||||||
if (TRUE == InitSessionManager(Children))
|
if (TRUE == InitSessionManager(Children))
|
||||||
{
|
{
|
||||||
NTSTATUS wws;
|
NTSTATUS wws;
|
||||||
|
|
||||||
DisplayString( L"SM: Waiting for process termination...\n" );
|
DisplayString( L"SM: Waiting for process termination...\n" );
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
wws = NtWaitForMultipleObjects (
|
wws = NtWaitForMultipleObjects (
|
||||||
((LONG) sizeof Children / sizeof (HANDLE)),
|
((LONG) sizeof Children / sizeof (HANDLE)),
|
||||||
Children,
|
Children,
|
||||||
WaitAny,
|
WaitAny,
|
||||||
TRUE, /* alertable */
|
TRUE, /* alertable */
|
||||||
NULL /* NULL for infinite */
|
NULL /* NULL for infinite */
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
wws = NtWaitForSingleObject (
|
wws = NtWaitForSingleObject (
|
||||||
Children[CHILD_WINLOGON],
|
Children[CHILD_WINLOGON],
|
||||||
TRUE, /* alertable */
|
TRUE, /* alertable */
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// if (!NT_SUCCESS(wws))
|
// if (!NT_SUCCESS(wws))
|
||||||
if (wws > 1)
|
if (wws > 1)
|
||||||
{
|
{
|
||||||
DisplayString( L"SM: NtWaitForMultipleObjects failed!\n" );
|
DisplayString( L"SM: NtWaitForMultipleObjects failed!\n" );
|
||||||
/* FIXME: CRASH THE SYSTEM (BSOD) */
|
/* FIXME: CRASH THE SYSTEM (BSOD) */
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
DisplayString( L"SM: Process terminated!\n" );
|
|
||||||
/* FIXME: CRASH THE SYSTEM (BSOD) */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DisplayString( L"SM: initialization failed!\n" );
|
DisplayString( L"SM: Process terminated!\n" );
|
||||||
/* FIXME: CRASH SYSTEM (BSOD)*/
|
/* FIXME: CRASH THE SYSTEM (BSOD) */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
/*
|
{
|
||||||
* OK: CSRSS asked to shutdown the system;
|
DisplayString( L"SM: initialization failed!\n" );
|
||||||
* We die.
|
/* FIXME: CRASH SYSTEM (BSOD)*/
|
||||||
*/
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* OK: CSRSS asked to shutdown the system;
|
||||||
|
* We die.
|
||||||
|
*/
|
||||||
#if 0
|
#if 0
|
||||||
NtRaiseHardError (
|
NtRaiseHardError (
|
||||||
STATUS_SYSTEM_PROCESS_TERMINATED,
|
STATUS_SYSTEM_PROCESS_TERMINATED,
|
||||||
...);
|
...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NtTerminateProcess( NtCurrentProcess(), 0 );
|
NtTerminateProcess( NtCurrentProcess(), 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue