- implemented process parameter block (PPB) code

- improved process environment block (PEB) code
- improved environment code

svn path=/trunk/; revision=828
This commit is contained in:
Eric Kohl 1999-12-06 00:25:14 +00:00
parent 09edfdc32f
commit b001203a86
17 changed files with 1207 additions and 694 deletions

View file

@ -46,32 +46,37 @@ typedef struct linux_sigcontext {
typedef ULONG THREADINFOCLASS;
typedef struct _PROCESSINFO
typedef struct _PPB
{
WCHAR WindowTitle[MAX_PATH];
WCHAR ImageFile[MAX_PATH];
WCHAR CommandLine[MAX_PATH];
WCHAR DllPath[MAX_PATH];
WCHAR Reserved[MAX_PATH];
WCHAR Desktop[MAX_PATH];
WCHAR Title[MAX_PATH];
PVOID Environment;
DWORD dwX;
DWORD dwY;
DWORD dwXSize;
DWORD dwYSize;
DWORD dwXCountChars;
DWORD dwYCountChars;
DWORD dwFillAttribute;
DWORD dwFlags;
WORD wShowWindow;
WORD cbReserved2;
unsigned char *lpReserved2;
HANDLE hStdInput;
HANDLE hStdOutput;
HANDLE hStdError;
} PROCESSINFO, *PPROCESSINFO;
ULONG TotalSize; // 00h
ULONG DataSize; // 04h
BOOLEAN Normalized; // 08h
ULONG Unknown1; // 0Ch
ULONG Unknown2; // 10h
ULONG Unknown3; // 14h
HANDLE InputHandle; // 18h
HANDLE OutputHandle; // 1Ch
HANDLE ErrorHandle; // 20h
UNICODE_STRING CurrentDirectory; // 24h
ULONG Unknown4; // 2Ch
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 Flags; // 68h
DWORD ShowWindow; // 6Ch
UNICODE_STRING Title; // 70h
UNICODE_STRING Desktop; // 78h
UNICODE_STRING Reserved; // 80h
UNICODE_STRING Reserved2; // 88h
} PPB, *PPPB;
typedef struct _LDR {
@ -82,7 +87,7 @@ typedef struct _LDR {
} LDR, *PLDR;
typedef struct _NT_PEB
typedef struct _PEB
{
UCHAR InheritedAddressSpace; // 00
UCHAR ReadImageFileExecOptions; // 01h
@ -90,10 +95,11 @@ typedef struct _NT_PEB
LONG ImageBaseAddress; // 03h
LDR Ldr; // 07h
PPPB Ppb; // 10h
WORD NumberOfProcessors; // 11h
WORD NtGlobalFlag; // 13h
PPROCESSINFO ProcessInfo; // 15h
HANDLE ProcessHeap; // 19h
ATOMTABLE LocalAtomTable; // 1Dh
LPCRITICAL_SECTION CriticalSection; // 35h
@ -102,7 +108,7 @@ typedef struct _NT_PEB
WORD MinorVersion; // 3Fh
WORD BuildNumber; // 41h
WORD PlatformId; // 43h
} NT_PEB, *PNT_PEB;
} PEB, *PPEB;
typedef struct _CLIENT_ID
{
@ -130,7 +136,7 @@ typedef struct _NT_TEB
CLIENT_ID Cid; // 20h
ULONG reserved2; // 28h ???
ULONG reserved3; // 2Ch ???
PNT_PEB Peb; // 30h
PPEB Peb; // 30h
DWORD LastErrorCode; // 34h
HANDLE RPCHandle; // 36
@ -371,7 +377,7 @@ typedef struct _EPROCESS
UCHAR ExitProcessCalled;
UCHAR CreateProcessReported;
HANDLE SectionHandle;
PNT_PEB Peb;
PPEB Peb;
PVOID SectionBaseAddress;
PVOID QuotaBlock;
NTSTATUS LastThreadExitStatus;

View file

@ -1,4 +1,4 @@
/* $Id: zw.h,v 1.21 1999/11/25 10:47:53 dwelch Exp $
/* $Id: zw.h,v 1.22 1999/12/06 00:14:47 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -75,7 +75,7 @@ typedef struct _TOKEN_USER {
* FUNCTION: Checks a clients access rights to a object
* ARGUMENTS:
* SecurityDescriptor = Security information against which the access is checked
* ClientToken = Represents a client
* ClientToken = Represents a client
* DesiredAcces =
* GenericMapping =
* PrivilegeSet =
@ -93,11 +93,12 @@ NtAccessCheck(
IN HANDLE ClientToken,
IN ACCESS_MASK DesiredAcces,
IN PGENERIC_MAPPING GenericMapping,
OUT PPRIVILEGE_SET PrivilegeSet,
OUT PPRIVILEGE_SET PrivilegeSet,
OUT PULONG ReturnLength,
OUT PULONG GrantedAccess,
OUT PBOOLEAN AccessStatus
);
NTSTATUS
STDCALL
ZwAccessCheck(
@ -105,7 +106,7 @@ ZwAccessCheck(
IN HANDLE ClientToken,
IN ACCESS_MASK DesiredAcces,
IN PGENERIC_MAPPING GenericMapping,
OUT PPRIVILEGE_SET PrivilegeSet,
OUT PPRIVILEGE_SET PrivilegeSet,
OUT PULONG ReturnLength,
OUT PULONG GrantedAccess,
OUT PBOOLEAN AccessStatus
@ -114,15 +115,15 @@ ZwAccessCheck(
/*
* FUNCTION: Checks a clients access rights to a object and issues a audit a alarm. ( it logs the access )
* ARGUMENTS:
SubsystemName = Specifies the name of the subsystem, can be "WIN32" or "DEBUG"
ObjectHandle =
ObjectAttributes =
DesiredAcces =
GenericMapping =
ObjectCreation =
GrantedAccess =
AccessStatus =
GenerateOnClose =
* SubsystemName = Specifies the name of the subsystem, can be "WIN32" or "DEBUG"
* ObjectHandle =
* ObjectAttributes =
* DesiredAcces =
* GenericMapping =
* ObjectCreation =
* GrantedAccess =
* AccessStatus =
* GenerateOnClose =
* REMARKS: The arguments map to the win32 AccessCheck
* RETURNS: Status
*/
@ -182,14 +183,14 @@ ZwAddAtom(
/*
* FUNCTION: Adjusts the groups in an access token
* ARGUMENTS:
TokenHandle = Specifies the access token
* ResetToDefault = If true the NewState parameter is ignored and the groups are set to
their default state, if false the groups specified in
NewState are set.
NewState =
BufferLength = Specifies the size of the buffer for the PreviousState.
PreviousState =
ReturnLength = Bytes written in PreviousState buffer.
* TokenHandle = Specifies the access token
* ResetToDefault = If true the NewState parameter is ignored and the groups are set to
* their default state, if false the groups specified in
* NewState are set.
* NewState =
* BufferLength = Specifies the size of the buffer for the PreviousState.
* PreviousState =
* ReturnLength = Bytes written in PreviousState buffer.
* REMARKS: The arguments map to the win32 AdjustTokenGroups
* RETURNS: Status
*/
@ -208,8 +209,8 @@ NtAdjustGroupsToken(
NTSTATUS
STDCALL
ZwAdjustGroupsToken(
IN HANDLE TokenHandle,
IN BOOLEAN ResetToDefault,
IN HANDLE TokenHandle,
IN BOOLEAN ResetToDefault,
IN PTOKEN_GROUPS NewState,
IN ULONG BufferLength,
OUT PTOKEN_GROUPS PreviousState,
@ -357,7 +358,7 @@ ZwAllocateUuids(
*/
NTSTATUS
STDCALL
NtAllocateVirtualMemory(
NtAllocateVirtualMemory (
IN HANDLE ProcessHandle,
IN OUT PVOID *BaseAddress,
IN ULONG ZeroBits,
@ -366,12 +367,15 @@ NtAllocateVirtualMemory(
IN ULONG Protect
);
NTSTATUS STDCALL ZwAllocateVirtualMemory(IN HANDLE ProcessHandle,
IN OUT PVOID *BaseAddress,
IN ULONG ZeroBits,
IN OUT PULONG RegionSize,
IN ULONG AllocationType,
IN ULONG Protect);
NTSTATUS
STDCALL
ZwAllocateVirtualMemory (
IN HANDLE ProcessHandle,
IN OUT PVOID *BaseAddress,
IN ULONG ZeroBits,
IN OUT PULONG RegionSize,
IN ULONG AllocationType,
IN ULONG Protect);
/*
* FUNCTION: Returns from a callback into user mode
@ -396,7 +400,7 @@ ZwCallbackReturn(
* ARGUMENTS:
* FileHandle = Handle to the file
* IoStatusBlock =
*
* REMARKS:
* This function maps to the win32 CancelIo.
* RETURNS: Status
@ -469,14 +473,14 @@ ZwClearEvent(
NTSTATUS
STDCALL
NtClose(
IN HANDLE Handle
);
IN HANDLE Handle
);
NTSTATUS
STDCALL
ZwClose(
IN HANDLE Handle
);
IN HANDLE Handle
);
/*
* FUNCTION: Generates an audit message when a handle to an object is dereferenced
@ -545,18 +549,18 @@ NTSTATUS STDCALL ZwContinue(IN PCONTEXT Context, IN CINT IrqLevel);
NTSTATUS
STDCALL
NtCreateDirectoryObject(
OUT PHANDLE DirectoryHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes
);
OUT PHANDLE DirectoryHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes
);
NTSTATUS
STDCALL
ZwCreateDirectoryObject(
OUT PHANDLE DirectoryHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes
);
OUT PHANDLE DirectoryHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes
);
/*
* FUNCTION: Creates an event object
@ -652,7 +656,7 @@ NtCreateFile(
IN ULONG CreateOptions,
IN PVOID EaBuffer OPTIONAL,
IN ULONG EaLength
);
);
NTSTATUS
STDCALL
@ -668,7 +672,7 @@ ZwCreateFile(
IN ULONG CreateOptions,
IN PVOID EaBuffer OPTIONAL,
IN ULONG EaLength
);
);
/*
* FUNCTION: Creates or opens a file, directory or device object.
@ -2477,18 +2481,18 @@ NTSTATUS
STDCALL
NtOpenThreadToken(
IN HANDLE ThreadHandle,
IN ACCESS_MASK DesiredAccess,
IN BOOLEAN OpenAsSelf,
OUT PHANDLE TokenHandle
IN ACCESS_MASK DesiredAccess,
IN BOOLEAN OpenAsSelf,
OUT PHANDLE TokenHandle
);
NTSTATUS
STDCALL
ZwOpenThreadToken(
IN HANDLE ThreadHandle,
IN ACCESS_MASK DesiredAccess,
IN BOOLEAN OpenAsSelf,
OUT PHANDLE TokenHandle
IN ACCESS_MASK DesiredAccess,
IN BOOLEAN OpenAsSelf,
OUT PHANDLE TokenHandle
);
/*
* FUNCTION: Opens an existing timer
@ -2504,14 +2508,14 @@ NtOpenTimer(
OUT PHANDLE TimerHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes
);
);
NTSTATUS
STDCALL
ZwOpenTimer(
OUT PHANDLE TimerHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes
);
);
/*
* FUNCTION: Checks an access token for specific privileges
@ -2531,6 +2535,7 @@ NtPrivilegeCheck(
IN PPRIVILEGE_SET RequiredPrivileges,
IN PBOOLEAN Result
);
NTSTATUS
STDCALL
ZwPrivilegeCheck(
@ -2584,13 +2589,15 @@ ZwPrivilegeObjectAuditAlarm(
/*
* FUNCTION: Entry point for native applications
* ARGUMENTS:
* Argument = Arguments passed to the application by the system [ at boot time ]
* Peb = Pointes to the Process Environment Block (PEB)
* REMARKS:
* Native applications should use this function instead of a main. Calling proces should terminate itself.
* Native applications should use this function instead of a main.
* Calling proces should terminate itself.
* RETURNS: Status
*/
void NtProcessStartup(
IN PSTARTUP_ARGUMENT Argument
VOID
NtProcessStartup(
IN PPEB Peb
);
/*
@ -2617,6 +2624,7 @@ NtProtectVirtualMemory(
IN ULONG NewAccessProtection,
OUT PULONG OldAccessProtection
);
NTSTATUS
STDCALL
ZwProtectVirtualMemory(
@ -2744,13 +2752,13 @@ ZwQueryDirectoryFile(
NTSTATUS
STDCALL
NtQueryDirectoryObject(
IN HANDLE DirObjHandle,
OUT POBJDIR_INFORMATION DirObjInformation,
IN ULONG BufferLength,
IN BOOLEAN GetNextIndex,
IN BOOLEAN IgnoreInputIndex,
IN OUT PULONG ObjectIndex,
OUT PULONG DataWritten OPTIONAL
IN HANDLE DirObjHandle,
OUT POBJDIR_INFORMATION DirObjInformation,
IN ULONG BufferLength,
IN BOOLEAN GetNextIndex,
IN BOOLEAN IgnoreInputIndex,
IN OUT PULONG ObjectIndex,
OUT PULONG DataWritten OPTIONAL
);
NTSTATUS
@ -2932,17 +2940,25 @@ NtQueryInformationAtom(
GetFullPathName, GetFileType, GetFileSize, GetFileTime functions.
* RETURNS: Status
*/
NTSTATUS STDCALL NtQueryInformationFile(IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass);
NTSTATUS
STDCALL
NtQueryInformationFile(
IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass
);
NTSTATUS STDCALL ZwQueryInformationFile(HANDLE FileHandle,
PIO_STATUS_BLOCK IoStatusBlock,
PVOID FileInformation,
ULONG Length,
FILE_INFORMATION_CLASS FileInformationClass);
NTSTATUS
STDCALL
ZwQueryInformationFile(
HANDLE FileHandle,
PIO_STATUS_BLOCK IoStatusBlock,
PVOID FileInformation,
ULONG Length,
FILE_INFORMATION_CLASS FileInformationClass
);
/*
* FUNCTION: Queries the information of a process object.
@ -2986,9 +3002,6 @@ NTSTATUS STDCALL ZwQueryInformationFile(HANDLE FileHandle,
* RETURNS: Status
*/
NTSTATUS
STDCALL
NtQueryInformationProcess(
@ -3010,7 +3023,6 @@ ZwQueryInformationProcess(
);
/*
* FUNCTION: Queries the information of a thread object.
* ARGUMENTS:
@ -3056,14 +3068,15 @@ NtQueryInformationThread(
OUT PULONG ReturnLength
);
NTSTATUS
STDCALL
NtQueryInformationToken(
IN HANDLE TokenHandle,
IN TOKEN_INFORMATION_CLASS TokenInformationClass,
OUT PVOID TokenInformation,
IN ULONG TokenInformationLength,
OUT PULONG ReturnLength
IN ULONG TokenInformationLength,
OUT PULONG ReturnLength
);
NTSTATUS
@ -3072,8 +3085,8 @@ ZwQueryInformationToken(
IN HANDLE TokenHandle,
IN TOKEN_INFORMATION_CLASS TokenInformationClass,
OUT PVOID TokenInformation,
IN ULONG TokenInformationLength,
OUT PULONG ReturnLength
IN ULONG TokenInformationLength,
OUT PULONG ReturnLength
);
/*
@ -3224,6 +3237,7 @@ NtQueryObject(
IN ULONG Length,
OUT PULONG ResultLength
);
NTSTATUS
STDCALL
ZwQueryObject(
@ -3278,6 +3292,7 @@ NtQuerySection(
IN ULONG Length,
OUT PULONG ResultLength
);
NTSTATUS
STDCALL
ZwQuerySection(
@ -3330,6 +3345,7 @@ NtQuerySemaphore(
ULONG Length,
PULONG ReturnLength
);
NTSTATUS
STDCALL
ZwQuerySemaphore(
@ -3384,6 +3400,7 @@ NtQuerySystemEnvironmentValue(
ULONG Length,
PULONG ReturnLength
);
NTSTATUS
STDCALL
ZwQuerySystemEnvironmentValue(
@ -3417,6 +3434,7 @@ NtQuerySystemInformation(
IN ULONG Length,
OUT PULONG ResultLength
);
NTSTATUS
STDCALL
ZwQuerySystemInformation(
@ -3623,7 +3641,7 @@ ZwQueryVolumeInformationFile(
OUT PVOID FsInformation,
IN ULONG Length,
IN FS_INFORMATION_CLASS FsInformationClass
);
);
// draft
// FIXME: Should I specify if the apc is user or kernel mode somewhere ??
/*
@ -3656,6 +3674,8 @@ ZwQueueApcThread(
PVOID NormalContext,
PVOID SystemArgument1,
PVOID SystemArgument2);
/*
* FUNCTION: Raises an exception
* ARGUMENTS:
@ -3666,7 +3686,6 @@ ZwQueueApcThread(
*
*/
NTSTATUS
STDCALL
NtRaiseException(

View file

@ -44,9 +44,9 @@ typedef struct _LPC_MESSAGE
//process query / set information class
#define ProcessBasicInformation 0
#define ProcessQuotaLimits 1
#define ProcessIoCounters 2
#define ProcessBasicInformation 0
#define ProcessQuotaLimits 1
#define ProcessIoCounters 2
#define ProcessVmCounters 3
#define ProcessTimes 4
#define ProcessBasePriority 5
@ -104,16 +104,15 @@ typedef struct _LPC_MESSAGE
// system information
#define SystemPerformanceInformation 5
#define SystemPerformanceInformation 5
#define SystemDriverInformation 11
#define SystemCacheInformation 21
#define SystemTimeAdjustmentInformation 28
#define SystemTimeZoneInformation 44
// memory information
#define MemoryBasicInformation 0
#define MemoryBasicInformation 0
// shutdown action
@ -130,13 +129,13 @@ typedef enum SHUTDOWN_ACTION_TAG {
// number of wait objects
#define THREAD_WAIT_OBJECTS 3
//#define MAXIMUM_WAIT_OBJECTS 64
#define THREAD_WAIT_OBJECTS 3
//#define MAXIMUM_WAIT_OBJECTS 64
// key restore flags
#define REG_WHOLE_HIVE_VOLATILE 1
#define REG_REFRESH_HIVE 2
#define REG_WHOLE_HIVE_VOLATILE 1
#define REG_REFRESH_HIVE 2
// object type access rights
@ -154,7 +153,7 @@ typedef enum SHUTDOWN_ACTION_TAG {
// symbolic link access rights
#define SYMBOLIC_LINK_QUERY 0x0001
#define SYMBOLIC_LINK_QUERY 0x0001
#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
typedef struct _PROCESS_WS_WATCH_INFORMATION
@ -166,7 +165,7 @@ typedef struct _PROCESS_WS_WATCH_INFORMATION
typedef struct _PROCESS_BASIC_INFORMATION
{
NTSTATUS ExitStatus;
PNT_PEB PebBaseAddress;
PPEB PebBaseAddress;
KAFFINITY AffinityMask;
KPRIORITY BasePriority;
ULONG UniqueProcessId;
@ -256,7 +255,7 @@ typedef struct _THREAD_BASIC_INFORMATION
typedef struct _OBJECT_NAME_INFORMATION
{
UNICODE_STRING Name;
UNICODE_STRING Name;
} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
@ -265,7 +264,7 @@ typedef struct _OBJECT_DATA_INFORMATION
{
BOOLEAN bInheritHandle;
BOOLEAN bProtectFromClose;
} OBJECT_DATA_INFORMATION, *POBJECT_DATA_INFORMATION;
} OBJECT_DATA_INFORMATION, *POBJECT_DATA_INFORMATION;
typedef struct _OBJECT_TYPE_INFORMATION
@ -302,7 +301,7 @@ typedef struct _SYSTEM_TIME_ADJUSTMENT
} SYSTEM_TIME_ADJUSTMENT, *PSYSTEM_TIME_ADJUSTMENT;
typedef struct _SYSTEM_CONFIGURATION_INFO {
union {
union {
ULONG OemId;
struct {
WORD ProcessorArchitecture;
@ -321,13 +320,14 @@ typedef struct _SYSTEM_CONFIGURATION_INFO {
} SYSTEM_CONFIGURATION_INFO, *PSYSTEM_CONFIGURATION_INFO;
typedef struct _SYSTEM_CACHE_INFORMATION {
ULONG CurrentSize;
ULONG PeakSize;
ULONG PageFaultCount;
ULONG MinimumWorkingSet;
ULONG MaximumWorkingSet;
ULONG Unused[4];
typedef struct _SYSTEM_CACHE_INFORMATION
{
ULONG CurrentSize;
ULONG PeakSize;
ULONG PageFaultCount;
ULONG MinimumWorkingSet;
ULONG MaximumWorkingSet;
ULONG Unused[4];
} SYSTEM_CACHE_INFORMATION;
// file information
@ -370,7 +370,8 @@ typedef struct _FILE_END_OF_FILE_INFORMATION
LARGE_INTEGER EndOfFile;
} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
typedef struct _FILE_NETWORK_OPEN_INFORMATION {
typedef struct _FILE_NETWORK_OPEN_INFORMATION
{
TIME CreationTime;
TIME LastAccessTime;
TIME LastWriteTime;
@ -402,11 +403,11 @@ typedef struct _FILE_GET_EA_INFORMATION {
} FILE_GET_EA_INFORMATION, *PFILE_GET_EA_INFORMATION;
typedef struct _FILE_STREAM_INFORMATION {
ULONG NextEntryOffset;
ULONG StreamNameLength;
LARGE_INTEGER StreamSize;
LARGE_INTEGER StreamAllocationSize;
WCHAR StreamName[0];
ULONG NextEntryOffset;
ULONG StreamNameLength;
LARGE_INTEGER StreamSize;
LARGE_INTEGER StreamAllocationSize;
WCHAR StreamName[0];
} FILE_STREAM_INFORMATION, *PFILE_STREAM_INFORMATION;
typedef struct _FILE_ALLOCATION_INFORMATION {
@ -430,7 +431,7 @@ typedef struct _FILE_NAMES_INFORMATION
typedef struct _FILE_RENAME_INFORMATION {
BOOLEAN Replace;
HANDLE RootDir;
ULONG FileNameLength;
ULONG FileNameLength;
WCHAR FileName[0];
} FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION;
@ -502,7 +503,7 @@ typedef struct _FILE_FS_ATTRIBUTE_INFORMATION {
/*
FileSystemAttributes is one of the following values:
FILE_CASE_SENSITIVE_SEARCH 0x00000001
FILE_CASE_SENSITIVE_SEARCH 0x00000001
FILE_CASE_PRESERVED_NAMES 0x00000002
FILE_UNICODE_ON_DISK 0x00000004
FILE_PERSISTENT_ACLS 0x00000008
@ -631,20 +632,6 @@ VOID
DWORD dwTimerHighValue
);
// NtProcessStartup parameters
typedef struct _ENVIRONMENT_INFORMATION {
ULONG Unknown[21];
UNICODE_STRING CommandLine;
UNICODE_STRING ImageFile;
} ENVIRONMENT_INFORMATION, *PENVIRONMENT_INFORMATION;
typedef struct _STARTUP_ARGUMENT {
ULONG Unknown[3];
PENVIRONMENT_INFORMATION Environment;
} STARTUP_ARGUMENT, *PSTARTUP_ARGUMENT;
// File System Control commands ( related to defragging )

View file

@ -7,6 +7,6 @@
#define PEB_BASE (0xb0001000)
#define PEB_STARTUPINFO (0xb0003000)
#define NtCurrentPeb() ((PNT_PEB)PEB_BASE)
#define NtCurrentPeb() ((PPEB)PEB_BASE)
#endif /* __INCLUDE_INTERNAL_TEB */

View file

@ -1,4 +1,4 @@
/* $Id: rtl.h,v 1.4 1999/12/01 15:16:56 ekohl Exp $
/* $Id: rtl.h,v 1.5 1999/12/06 00:16:33 ekohl Exp $
*
*/
@ -109,32 +109,17 @@ RtlCreateUserThread (
IN OUT PCLIENT_ID ClientId
);
VOID
STDCALL
RtlDeNormalizeProcessParams (
IN OUT PSTARTUP_ARGUMENT pArgument
);
VOID
STDCALL
RtlDestroyProcessParameters (
IN OUT PSTARTUP_ARGUMENT pArgument
);
VOID
STDCALL
RtlNormalizeProcessParams (
IN OUT PSTARTUP_ARGUMENT pArgument
);
/* Preliminary prototype!! */
/*
* Preliminary prototype!!
*
* This prototype is not finished yet. It will change in the future.
*/
NTSTATUS
STDCALL
RtlCreateUserProcess (
PUNICODE_STRING ApplicationName,
PUNICODE_STRING CommandLine,
ULONG Unknown1,
PPPB Ppb,
PSECURITY_DESCRIPTOR ProcessSd,
PSECURITY_DESCRIPTOR ThreadSd,
WINBOOL bInheritHandles,
@ -144,5 +129,37 @@ RtlCreateUserProcess (
PHANDLE ThreadHandle
);
NTSTATUS
STDCALL
RtlCreateProcessParameters (
IN OUT PPPB *Ppb,
IN PUNICODE_STRING CommandLine,
IN PUNICODE_STRING LibraryPath,
IN PUNICODE_STRING CurrentDirectory,
IN PUNICODE_STRING ImageName,
IN PVOID Environment,
IN PUNICODE_STRING Title,
IN PUNICODE_STRING Desktop,
IN PUNICODE_STRING Reserved,
IN PVOID Reserved2
);
VOID
STDCALL
RtlDeNormalizeProcessParams (
IN OUT PPPB Ppb
);
VOID
STDCALL
RtlDestroyProcessParameters (
IN OUT PPPB Ppb
);
VOID
STDCALL
RtlNormalizeProcessParams (
IN OUT PPPB Ppb
);
/* EOF */

View file

@ -39,8 +39,8 @@ LPSTR STDCALL GetCommandLineA(VOID)
return(CommandLineA);
}
LPWSTR STDCALL GetCommandLineW(VOID)
LPWSTR STDCALL GetCommandLineW (VOID)
{
return(NtCurrentPeb()->ProcessInfo->CommandLine);
return (NtCurrentPeb()->Ppb->CommandLine.Buffer);
}

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.13 1999/11/24 11:51:45 dwelch Exp $
/* $Id: create.c,v 1.14 1999/12/06 00:23:40 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -23,6 +23,7 @@
#include <ntdll/ldr.h>
#include <internal/teb.h>
#include <ntdll/base.h>
#include <ntdll/rtl.h>
#define NDEBUG
#include <kernel32/kernel32.h>
@ -130,7 +131,6 @@ HANDLE STDCALL CreateFirstThread(HANDLE ProcessHandle,
CreateSuspended = FALSE;
BaseAddress = (PVOID)(STACK_TOP - dwStackSize);
Status = NtAllocateVirtualMemory(ProcessHandle,
&BaseAddress,
@ -341,16 +341,18 @@ HANDLE KERNEL32_MapFile(LPCWSTR lpApplicationName,
return(hSection);
}
static NTSTATUS CreatePeb(HANDLE ProcessHandle, PWSTR CommandLine)
static NTSTATUS
CreatePeb (
HANDLE ProcessHandle,
PPPB Ppb)
{
NTSTATUS Status;
PVOID PebBase;
ULONG PebSize;
NT_PEB Peb;
PEB Peb;
PVOID PpbBase;
ULONG PpbSize;
ULONG BytesWritten;
PVOID ProcessInfoBase;
ULONG ProcessInfoSize;
PROCESSINFO ProcessInfo;
PebBase = (PVOID)PEB_BASE;
PebSize = 0x1000;
@ -361,7 +363,7 @@ static NTSTATUS CreatePeb(HANDLE ProcessHandle, PWSTR CommandLine)
sizeof(Peb),
&BytesWritten);
Peb.ProcessInfo = (PPROCESSINFO)PEB_STARTUPINFO;
Peb.Ppb = (PPPB)PEB_STARTUPINFO;
NtWriteVirtualMemory(ProcessHandle,
(PVOID)PEB_BASE,
@ -369,12 +371,12 @@ static NTSTATUS CreatePeb(HANDLE ProcessHandle, PWSTR CommandLine)
sizeof(Peb),
&BytesWritten);
ProcessInfoBase = (PVOID)PEB_STARTUPINFO;
ProcessInfoSize = 0x1000;
PpbBase = (PVOID)PEB_STARTUPINFO;
PpbSize = Ppb->TotalSize;
Status = NtAllocateVirtualMemory(ProcessHandle,
&ProcessInfoBase,
&PpbBase,
0,
&ProcessInfoSize,
&PpbSize,
MEM_COMMIT,
PAGE_READWRITE);
if (!NT_SUCCESS(Status))
@ -382,30 +384,30 @@ static NTSTATUS CreatePeb(HANDLE ProcessHandle, PWSTR CommandLine)
return(Status);
}
memset(&ProcessInfo, 0, sizeof(PROCESSINFO));
wcscpy(ProcessInfo.CommandLine, CommandLine);
DPRINT("ProcessInfoSize %x\n",ProcessInfoSize);
DPRINT("Ppb size %x\n", Ppb->TotalSize);
ZwWriteVirtualMemory(ProcessHandle,
(PVOID)PEB_STARTUPINFO,
&ProcessInfo,
ProcessInfoSize,
&Ppb,
Ppb->TotalSize,
&BytesWritten);
return(STATUS_SUCCESS);
}
WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
LPWSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
WINBOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory,
LPSTARTUPINFOW lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation)
WINBOOL
STDCALL
CreateProcessW (
LPCWSTR lpApplicationName,
LPWSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
WINBOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCWSTR lpCurrentDirectory,
LPSTARTUPINFOW lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation)
{
HANDLE hSection, hProcess, hThread;
NTSTATUS Status;
@ -421,6 +423,8 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
PROCESS_BASIC_INFORMATION ProcessBasicInfo;
ULONG retlen;
DWORD len = 0;
PPPB Ppb;
UNICODE_STRING CommandLine_U;
DPRINT("CreateProcessW(lpApplicationName '%w', lpCommandLine '%w')\n",
lpApplicationName,lpCommandLine);
@ -444,11 +448,27 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
wcscat(TempCommandLine, lpCommandLine);
}
RtlInitUnicodeString (
&CommandLine_U,
TempCommandLine);
hSection = KERNEL32_MapFile(lpApplicationName,
lpCommandLine,
&Headers,
&DosHeader);
RtlCreateProcessParameters (
&Ppb,
&CommandLine_U,
NULL,
NULL,
NULL,
lpEnvironment,
NULL,
NULL,
NULL,
NULL);
hSection = KERNEL32_MapFile (
lpApplicationName,
lpCommandLine,
&Headers,
&DosHeader);
Status = NtCreateProcess(&hProcess,
PROCESS_ALL_ACCESS,
@ -490,6 +510,7 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
PAGE_READWRITE);
if (!NT_SUCCESS(Status))
{
RtlDestroyProcessParameters (Ppb);
SetLastError(RtlNtStatusToDosError(Status));
return FALSE;
}
@ -498,7 +519,9 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
* Create Process Environment Block
*/
DPRINT("Creating peb\n");
CreatePeb(hProcess, TempCommandLine);
CreatePeb(hProcess, Ppb);
RtlDestroyProcessParameters (Ppb);
DPRINT("Creating thread for process\n");
lpStartAddress = (LPTHREAD_START_ROUTINE)

View file

@ -1,4 +1,4 @@
/* $Id: proc.c,v 1.23 1999/10/18 21:50:11 ariadne Exp $
/* $Id: proc.c,v 1.24 1999/12/06 00:23:40 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -11,7 +11,6 @@
/* INCLUDES ****************************************************************/
//#define UNICODE
#include <ddk/ntddk.h>
#include <windows.h>
#include <kernel32/proc.h>
@ -327,10 +326,10 @@ SleepEx (
VOID
STDCALL
GetStartupInfoW (
LPSTARTUPINFOW lpStartupInfo
LPSTARTUPINFOW lpStartupInfo
)
{
NT_PEB *pPeb = NtCurrentPeb();
PPEB pPeb = NtCurrentPeb();
if (lpStartupInfo == NULL)
{
@ -339,34 +338,34 @@ GetStartupInfoW (
}
lpStartupInfo->cb = sizeof(STARTUPINFOW);
// lstrcpyW(lpStartupInfo->lpDesktop, pPeb->ProcessInfo->Desktop);
// lstrcpyW(lpStartupInfo->lpTitle, pPeb->ProcessInfo->Title);
lpStartupInfo->dwX = pPeb->ProcessInfo->dwX;
lpStartupInfo->dwY = pPeb->ProcessInfo->dwY;
lpStartupInfo->dwXSize = pPeb->ProcessInfo->dwXSize;
lpStartupInfo->dwYSize = pPeb->ProcessInfo->dwYSize;
lpStartupInfo->dwXCountChars = pPeb->ProcessInfo->dwXCountChars;
lpStartupInfo->dwYCountChars = pPeb->ProcessInfo->dwYCountChars;
lpStartupInfo->dwFillAttribute = pPeb->ProcessInfo->dwFillAttribute;
lpStartupInfo->dwFlags = pPeb->ProcessInfo->dwFlags;
lpStartupInfo->wShowWindow = pPeb->ProcessInfo->wShowWindow;
// lpStartupInfo->cbReserved2 = pPeb->ProcessInfo->cbReserved;
// lpStartupInfo->lpReserved = pPeb->ProcessInfo->lpReserved1;
// lpStartupInfo->lpReserved2 = pPeb->ProcessInfo->lpReserved2;
// lstrcpyW(lpStartupInfo->lpDesktop, pPeb->Ppb->Desktop);
// lstrcpyW(lpStartupInfo->lpTitle, pPeb->Ppb->Title);
lpStartupInfo->dwX = pPeb->Ppb->X;
lpStartupInfo->dwY = pPeb->Ppb->Y;
lpStartupInfo->dwXSize = pPeb->Ppb->XSize;
lpStartupInfo->dwYSize = pPeb->Ppb->YSize;
lpStartupInfo->dwXCountChars = pPeb->Ppb->XCountChars;
lpStartupInfo->dwYCountChars = pPeb->Ppb->YCountChars;
lpStartupInfo->dwFillAttribute = pPeb->Ppb->FillAttribute;
lpStartupInfo->dwFlags = pPeb->Ppb->Flags;
lpStartupInfo->wShowWindow = pPeb->Ppb->ShowWindow;
// lpStartupInfo->lpReserved = pPeb->Ppb->lpReserved1;
// lpStartupInfo->cbReserved2 = pPeb->Ppb->cbReserved;
// lpStartupInfo->lpReserved2 = pPeb->Ppb->lpReserved2;
lpStartupInfo->hStdInput = pPeb->ProcessInfo->hStdInput;
lpStartupInfo->hStdOutput = pPeb->ProcessInfo->hStdOutput;
lpStartupInfo->hStdError = pPeb->ProcessInfo->hStdError;
lpStartupInfo->hStdInput = pPeb->Ppb->InputHandle;
lpStartupInfo->hStdOutput = pPeb->Ppb->OutputHandle;
lpStartupInfo->hStdError = pPeb->Ppb->ErrorHandle;
}
VOID
STDCALL
GetStartupInfoA (
LPSTARTUPINFOA lpStartupInfo
LPSTARTUPINFOA lpStartupInfo
)
{
NT_PEB *pPeb = NtCurrentPeb();
PPEB pPeb = NtCurrentPeb();
ULONG i = 0;
if (lpStartupInfo == NULL)
@ -376,40 +375,40 @@ GetStartupInfoA (
}
lpStartupInfo->cb = sizeof(STARTUPINFOA);
#if 0
i = 0;
while ((pPeb->ProcessInfo->Desktop[i])!=0 && i < MAX_PATH)
while ((pPeb->Ppb->Desktop[i])!=0 && i < MAX_PATH)
{
lpStartupInfo->lpDesktop[i] = (unsigned char)
pPeb->ProcessInfo->Desktop[i];
pPeb->Ppb->Desktop[i];
i++;
}
lpStartupInfo->lpDesktop[i] = 0;
i = 0;
while ((pPeb->ProcessInfo->Title[i])!=0 && i < MAX_PATH)
while ((pPeb->Ppb->Title[i])!=0 && i < MAX_PATH)
{
lpStartupInfo->lpTitle[i] = (unsigned char)pPeb->ProcessInfo->Title[i];
lpStartupInfo->lpTitle[i] = (unsigned char)pPeb->ProcessParameters->Title[i];
i++;
}
lpStartupInfo->lpTitle[i] = 0;
#endif
lpStartupInfo->dwX = pPeb->Ppb->X;
lpStartupInfo->dwY = pPeb->Ppb->Y;
lpStartupInfo->dwXSize = pPeb->Ppb->XSize;
lpStartupInfo->dwYSize = pPeb->Ppb->YSize;
lpStartupInfo->dwXCountChars = pPeb->Ppb->XCountChars;
lpStartupInfo->dwYCountChars = pPeb->Ppb->YCountChars;
lpStartupInfo->dwFillAttribute = pPeb->Ppb->FillAttribute;
lpStartupInfo->dwFlags = pPeb->Ppb->Flags;
lpStartupInfo->wShowWindow = pPeb->Ppb->ShowWindow;
// lpStartupInfo->cbReserved2 = pPeb->Ppb->cbReserved;
// lpStartupInfo->lpReserved = pPeb->Ppb->lpReserved1;
// lpStartupInfo->lpReserved2 = pPeb->Ppb->lpReserved2;
lpStartupInfo->dwX = pPeb->ProcessInfo->dwX;
lpStartupInfo->dwY = pPeb->ProcessInfo->dwY;
lpStartupInfo->dwXSize = pPeb->ProcessInfo->dwXSize;
lpStartupInfo->dwYSize = pPeb->ProcessInfo->dwYSize;
lpStartupInfo->dwXCountChars = pPeb->ProcessInfo->dwXCountChars;
lpStartupInfo->dwYCountChars = pPeb->ProcessInfo->dwYCountChars;
lpStartupInfo->dwFillAttribute = pPeb->ProcessInfo->dwFillAttribute;
lpStartupInfo->dwFlags = pPeb->ProcessInfo->dwFlags;
lpStartupInfo->wShowWindow = pPeb->ProcessInfo->wShowWindow;
// lpStartupInfo->cbReserved2 = pPeb->ProcessInfo->cbReserved;
// lpStartupInfo->lpReserved = pPeb->ProcessInfo->lpReserved1;
// lpStartupInfo->lpReserved2 = pPeb->ProcessInfo->lpReserved2;
lpStartupInfo->hStdInput = pPeb->ProcessInfo->hStdInput;
lpStartupInfo->hStdOutput = pPeb->ProcessInfo->hStdOutput;
lpStartupInfo->hStdError = pPeb->ProcessInfo->hStdError;
lpStartupInfo->hStdInput = pPeb->Ppb->InputHandle;
lpStartupInfo->hStdOutput = pPeb->Ppb->OutputHandle;
lpStartupInfo->hStdError = pPeb->Ppb->ErrorHandle;
}

View file

@ -1,4 +1,4 @@
; $Id: ntdll.def,v 1.27 1999/12/04 21:03:22 ea Exp $
; $Id: ntdll.def,v 1.28 1999/12/06 00:22:00 ekohl Exp $
;
; ReactOS Operating System
;
@ -440,9 +440,10 @@ RtlAppendUnicodeToString@12
RtlCharToInteger@12
RtlCreateEnvironment@8
RtlCreateHeap@24
RtlCreateProcessParameters@40
RtlCreateUnicodeString@8
RtlCreateUnicodeStringFromAsciiz@8
RtlCreateUserProcess@32
RtlCreateUserProcess@40
RtlCreateUserThread@40
RtlCompactHeap@8
RtlCompareString@12
@ -451,8 +452,10 @@ RtlConvertLongToLargeInteger@4
RtlConvertUlongToLargeInteger@4
RtlCopyString@8
RtlCopyUnicodeString@8
RtlDeNormalizeProcessParams@4
RtlDestroyEnvironment@4
RtlDestroyHeap@4
RtlDestroyProcessParameters@4
RtlDowncaseUnicodeString@12
RtlEnlargedIntegerMultiply@8
RtlEnlargedUnsignedDivide@16
@ -486,6 +489,7 @@ RtlLengthSecurityDescriptor
RtlLockHeap@4
RtlMoveMemory@12
RtlMultiByteToUnicodeN@20
RtlNormalizeProcessParams@4
RtlNtStatusToDosError
RtlNtStatusToPsxErrno@4
RtlOemStringToUnicodeSize@4
@ -494,6 +498,7 @@ RtlOemToUnicodeN@20
RtlQueryEnvironmentVariable_U@12
RtlReAllocateHeap@16
RtlReleasePebLock@0
RtlSetCurrentEnvironment@8
RtlSetEnvironmentVariable@12
RtlSizeHeap@12
RtlUnlockHeap@4

View file

@ -1,4 +1,4 @@
; $Id: ntdll.edf,v 1.17 1999/12/04 21:03:22 ea Exp $
; $Id: ntdll.edf,v 1.18 1999/12/06 00:22:00 ekohl Exp $
;
; ReactOS Operating System
;
@ -438,9 +438,10 @@ RtlAppendUnicodeToString=RtlAppendUnicodeToString@8
RtlCharToInteger=RtlCharToInteger@12
RtlCreateEnvironment=RtlCreateEnvironment@8
RtlCreateHeap=RtlCreateHeap@24
RtlCreateProcessParameters=RtlCreateProcessParameters@40
RtlCreateUnicodeString=RtlCreateUnicodeString@8
RtlCreateUnicodeStringFromAsciiz=RtlCreateUnicodeStringFromAsciiz@8
RtlCreateUserProcess=RtlCreateUserProcess@32
RtlCreateUserProcess=RtlCreateUserProcess@40
RtlCreateUserThread=RtlCreateUserThread@40
RtlCompactHeap=RtlCompactHeap@8
RtlCompareString=RtlCompareString@12
@ -449,8 +450,10 @@ RtlConvertLongToLargeInteger=RtlConvertLongToLargeInteger@4
RtlConvertUlongToLargeInteger=RtlConvertUlongToLargeInteger@4
RtlCopyString=RtlCopyString@8
RtlCopyUnicodeString=RtlCopyUnicodeString@8
RtlDeNormalizeProcessParams=RtlDeNormalizeProcessParams@4
RtlDestroyEnvironment=RtlDestroyEnvironment@4
RtlDestroyHeap=RtlDestroyHeap@4
RtlDestroyProcessParameters=RtlDestroyProcessParameters@4
RtlDowncaseUnicodeString=RtlDowncaseUnicodeString@12
RtlEnlargedIntegerMultiply=RtlEnlargedIntegerMultiply@8
RtlEnlargedUnsignedDivide=RtlEnlargedUnsignedDivide@16
@ -483,6 +486,7 @@ RtlLengthSecurityDescriptor
RtlLockHeap=RtlLockHeap@4
RtlMoveMemory=RtlMoveMemory@12
RtlMultiByteToUnicodeN=RtlMultiByteToUnicodeN@20
RtlNormalizeProcessParams=RtlNormalizeProcessParams@4
RtlNtStatusToDosError
RtlNtStatusToPsxErrno=RtlNtStatusToPsxErrno@4
RtlOemStringToUnicodeSize=RtlOemStringToUnicodeSize@4
@ -491,6 +495,7 @@ RtlOemToUnicodeN=RtlOemToUnicodeN@20
RtlQueryEnvironmentVariable_U=RtlQueryEnvironmentVariable_U@12
RtlReAllocateHeap=RtlReAllocateHeap@16
RtlReleasePebLock=RtlReleasePebLock@0
RtlSetCurrentEnvironment=RtlSetCurrentEnvironment@8
RtlSetEnvironmentVariable=RtlSetEnvironmentVariable@12
RtlSizeHeap=RtlSizeHeap@12
RtlUnlockHeap=RtlUnlockHeap@4

View file

@ -1,4 +1,4 @@
/* $Id: env.c,v 1.2 1999/12/01 17:34:55 ekohl Exp $
/* $Id: env.c,v 1.3 1999/12/06 00:22:43 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -16,12 +16,15 @@
#include <internal/teb.h>
#include <string.h>
//#define NDEBUG
#include <ntdll/ntdll.h>
/* FUNCTIONS *****************************************************************/
NTSTATUS
STDCALL
RtlCreateEnvironment (
BOOLEAN Inherit,
BOOLEAN Initialize,
PVOID *Environment
)
{
@ -29,11 +32,11 @@ RtlCreateEnvironment (
PVOID EnvPtr = NULL;
NTSTATUS Status = STATUS_SUCCESS;
ULONG RegionSize = 1;
#if 0
if (Inherit == TRUE)
if (Initialize == FALSE)
{
RtlAcquirePebLock ();
#if 0
if (NtCurrentPeb()->ProcessParameters->Environment != NULL)
{
Status = NtQueryVirtualMemory (NtCurrentProcess (),
@ -69,6 +72,7 @@ RtlCreateEnvironment (
*Environment = EnvPtr;
}
#endif
RtlReleasePebLock ();
}
else
@ -83,7 +87,7 @@ RtlCreateEnvironment (
if (NT_SUCCESS(Status))
*Environment = EnvPtr;
}
#endif
return Status;
}
@ -112,14 +116,17 @@ RtlSetCurrentEnvironment (
{
PVOID EnvPtr;
DPRINT ("NewEnvironment %x OldEnvironment %x\n",
NewEnvironment, OldEnvironment);
RtlAcquirePebLock ();
#if 0
EnvPtr = NtCurrentPeb()->ProcessParameters->Environment;
NtCurrentPeb()->ProcessParameters->Environment = NewEnvironment;
EnvPtr = NtCurrentPeb()->Ppb->Environment;
NtCurrentPeb()->Ppb->Environment = NewEnvironment;
if (OldEnvironment != NULL)
*OldEnvironment = EnvPtr;
#endif
RtlReleasePebLock ();
}

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.4 1999/12/01 15:14:59 ekohl Exp $
/* $Id: process.c,v 1.5 1999/12/06 00:22:43 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -67,8 +67,6 @@ RtlpCreateFirstThread(HANDLE ProcessHandle,
else
CreateSuspended = FALSE;
BaseAddress = (PVOID)(STACK_TOP - dwStackSize);
Status = NtAllocateVirtualMemory(ProcessHandle,
&BaseAddress,
@ -176,7 +174,6 @@ RtlpMapFile(PUNICODE_STRING ApplicationName,
&IoStatusBlock,
FILE_SHARE_DELETE|FILE_SHARE_READ,
FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE);
if (!NT_SUCCESS(Status))
return Status;
@ -224,28 +221,31 @@ RtlpMapFile(PUNICODE_STRING ApplicationName,
static NTSTATUS
RtlpCreatePeb(HANDLE ProcessHandle, PUNICODE_STRING CommandLine)
RtlpCreatePeb (
HANDLE ProcessHandle,
PPPB Ppb)
{
NTSTATUS Status;
ULONG BytesWritten;
PVOID PebBase;
ULONG PebSize;
NT_PEB Peb;
ULONG BytesWritten;
PVOID ProcessInfoBase;
ULONG ProcessInfoSize;
PROCESSINFO ProcessInfo;
PEB Peb;
PVOID PpbBase;
ULONG PpbSize;
PebBase = (PVOID)PEB_BASE;
PebSize = 0x1000;
NtReadVirtualMemory(ProcessHandle,
(PVOID)PEB_BASE,
&Peb,
sizeof(Peb),
&BytesWritten);
Status = NtAllocateVirtualMemory (
ProcessHandle,
&PebBase,
0,
&PebSize,
MEM_COMMIT,
PAGE_READWRITE);
memset(&Peb, 0, sizeof(Peb));
Peb.ProcessInfo = (PPROCESSINFO)PEB_STARTUPINFO;
memset(&Peb, 0, sizeof(Peb));
Peb.Ppb = (PPPB)PEB_STARTUPINFO;
NtWriteVirtualMemory(ProcessHandle,
(PVOID)PEB_BASE,
@ -253,40 +253,42 @@ RtlpCreatePeb(HANDLE ProcessHandle, PUNICODE_STRING CommandLine)
sizeof(Peb),
&BytesWritten);
ProcessInfoBase = (PVOID)PEB_STARTUPINFO;
ProcessInfoSize = 0x1000;
PpbBase = (PVOID)PEB_STARTUPINFO;
PpbSize = Ppb->TotalSize;
Status = NtAllocateVirtualMemory(ProcessHandle,
&ProcessInfoBase,
&PpbBase,
0,
&ProcessInfoSize,
&PpbSize,
MEM_COMMIT,
PAGE_READWRITE);
if (!NT_SUCCESS(Status))
return(Status);
memset(&ProcessInfo, 0, sizeof(PROCESSINFO));
wcscpy(ProcessInfo.CommandLine, CommandLine->Buffer);
DPRINT("Ppb size %x\n", PpbSize);
NtWriteVirtualMemory (
ProcessHandle,
(PVOID)PEB_STARTUPINFO,
Ppb,
Ppb->TotalSize,
&BytesWritten);
DPRINT("ProcessInfoSize %x\n",ProcessInfoSize);
NtWriteVirtualMemory(ProcessHandle,
(PVOID)PEB_STARTUPINFO,
&ProcessInfo,
ProcessInfoSize,
&BytesWritten);
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
NTSTATUS STDCALL
RtlCreateUserProcess(PUNICODE_STRING ApplicationName,
PSECURITY_DESCRIPTOR ProcessSd,
PSECURITY_DESCRIPTOR ThreadSd,
WINBOOL bInheritHandles,
DWORD dwCreationFlags,
PCLIENT_ID ClientId,
PHANDLE ProcessHandle,
PHANDLE ThreadHandle)
NTSTATUS
STDCALL
RtlCreateUserProcess (
PUNICODE_STRING CommandLine,
ULONG Unknown1,
PPPB Ppb,
PSECURITY_DESCRIPTOR ProcessSd,
PSECURITY_DESCRIPTOR ThreadSd,
WINBOOL bInheritHandles,
DWORD dwCreationFlags,
PCLIENT_ID ClientId,
PHANDLE ProcessHandle,
PHANDLE ThreadHandle)
{
HANDLE hSection, hProcess, hThread;
NTSTATUS Status;
@ -303,10 +305,10 @@ RtlCreateUserProcess(PUNICODE_STRING ApplicationName,
CLIENT_ID LocalClientId;
ULONG retlen;
DPRINT("RtlCreateUserProcess(ApplicationName '%w')\n",
ApplicationName->Buffer);
DPRINT ("RtlCreateUserProcess(CommandLine '%w')\n",
CommandLine->Buffer);
Status = RtlpMapFile(ApplicationName,
Status = RtlpMapFile(CommandLine,
&Headers,
&DosHeader,
&hSection);
@ -357,24 +359,25 @@ RtlCreateUserProcess(PUNICODE_STRING ApplicationName,
*
*/
DPRINT("Creating peb\n");
RtlpCreatePeb(hProcess, ApplicationName);
RtlpCreatePeb (hProcess, Ppb);
DPRINT("Creating thread for process\n");
lpStartAddress = (LPTHREAD_START_ROUTINE)
((PIMAGE_OPTIONAL_HEADER)OPTHDROFFSET(NTDLL_BASE))->
AddressOfEntryPoint +
((PIMAGE_OPTIONAL_HEADER)OPTHDROFFSET(NTDLL_BASE))->ImageBase;
hThread = RtlpCreateFirstThread(hProcess,
ThreadSd,
Headers.OptionalHeader.SizeOfStackReserve,
lpStartAddress,
lpParameter,
dwCreationFlags,
&LocalClientId.UniqueThread,
TempCommandLine,
NTDllSection,
hSection,
(PVOID)Headers.OptionalHeader.ImageBase);
hThread = RtlpCreateFirstThread (
hProcess,
ThreadSd,
Headers.OptionalHeader.SizeOfStackReserve,
lpStartAddress,
lpParameter,
dwCreationFlags,
&LocalClientId.UniqueThread,
TempCommandLine,
NTDllSection,
hSection,
(PVOID)Headers.OptionalHeader.ImageBase);
if ( hThread == NULL )
return Status;
@ -410,4 +413,346 @@ RtlReleasePebLock (VOID)
}
NTSTATUS
STDCALL
RtlCreateProcessParameters (
PPPB *Ppb,
PUNICODE_STRING CommandLine,
PUNICODE_STRING LibraryPath,
PUNICODE_STRING CurrentDirectory,
PUNICODE_STRING ImageName,
PVOID Environment,
PUNICODE_STRING Title,
PUNICODE_STRING Desktop,
PUNICODE_STRING Reserved,
PVOID Reserved2
)
{
NTSTATUS Status = STATUS_SUCCESS;
PPPB Param = NULL;
ULONG RegionSize = 0;
ULONG DataSize = 0;
PWCHAR Dest;
DPRINT ("RtlCreateProcessParameters\n");
RtlAcquirePebLock ();
/* size of process parameter block */
DataSize = sizeof (PPB);
/* size of (reserved) buffer */
DataSize += (256 * sizeof(WCHAR));
/* size of current directory buffer */
DataSize += (MAX_PATH * sizeof(WCHAR));
/* add string lengths */
if (LibraryPath != NULL)
DataSize += (LibraryPath->Length + sizeof(WCHAR));
if (CommandLine != NULL)
DataSize += (CommandLine->Length + sizeof(WCHAR));
if (ImageName != NULL)
DataSize += (ImageName->Length + sizeof(WCHAR));
if (Title != NULL)
DataSize += (Title->Length + sizeof(WCHAR));
if (Desktop != NULL)
DataSize += (Desktop->Length + sizeof(WCHAR));
if (Reserved != NULL)
DataSize += (Reserved->Length + sizeof(WCHAR));
/* Calculate the required block size */
RegionSize = DataSize;
Status = NtAllocateVirtualMemory (
NtCurrentProcess (),
(PVOID*)&Param,
0,
&RegionSize,
MEM_COMMIT,
PAGE_READWRITE);
if (!NT_SUCCESS(Status))
{
RtlReleasePebLock ();
return Status;
}
DPRINT ("Ppb allocated\n");
Param->TotalSize = RegionSize;
Param->DataSize = DataSize;
Param->Normalized = TRUE;
Param->Environment = Environment;
// Param->Unknown1 =
// Param->Unknown2 =
// Param->Unknown3 =
// Param->Unknown4 =
/* copy current directory */
Dest = (PWCHAR)(((PBYTE)Param) + sizeof(PPB) + (256 * sizeof(WCHAR)));
Param->CurrentDirectory.Buffer = Dest;
if (CurrentDirectory != NULL)
{
Param->CurrentDirectory.Length = CurrentDirectory->Length;
Param->CurrentDirectory.MaximumLength = CurrentDirectory->Length + sizeof(WCHAR);
memcpy (Dest,
CurrentDirectory->Buffer,
CurrentDirectory->Length);
Dest = (PWCHAR)(((PBYTE)Dest) + CurrentDirectory->Length);
}
*Dest = 0;
Dest = (PWCHAR)(((PBYTE)Param) + sizeof(PPB) +
(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,
ImageName->Buffer,
ImageName->Length);
Dest = (PWCHAR)(((PBYTE)Dest) + ImageName->Length);
}
Param->ImageName.MaximumLength = Param->ImageName.Length + sizeof(WCHAR);
*Dest = 0;
Dest++;
/* copy title */
Param->Title.Buffer = Dest;
if (Title != NULL)
{
Param->Title.Length = Title->Length;
memcpy (Dest,
Title->Buffer,
Title->Length);
Dest = (PWCHAR)(((PBYTE)Dest) + Title->Length);
}
Param->Title.MaximumLength = Param->Title.Length + sizeof(WCHAR);
*Dest = 0;
Dest++;
/* copy desktop */
Param->Desktop.Buffer = Dest;
if (Desktop != NULL)
{
Param->Desktop.Length = Desktop->Length;
memcpy (Dest,
Desktop->Buffer,
Desktop->Length);
Dest = (PWCHAR)(((PBYTE)Dest) + Desktop->Length);
}
Param->Desktop.MaximumLength = Param->Desktop.Length + sizeof(WCHAR);
*Dest = 0;
Dest++;
/* copy reserved */
Param->Reserved.Buffer = Dest;
if (Reserved != NULL)
{
Param->Reserved.Length = Reserved->Length;
memcpy (Dest,
Reserved->Buffer,
Reserved->Length);
Dest = (PWCHAR)(((PBYTE)Dest) + Reserved->Length);
}
Param->Reserved.MaximumLength = Param->Reserved.Length + sizeof(WCHAR);
*Dest = 0;
Dest++;
/* set reserved2 */
Param->Reserved2.Length = 0;
Param->Reserved2.MaximumLength = 0;
Param->Reserved2.Buffer = NULL;
RtlDeNormalizeProcessParams (Param);
*Ppb = Param;
RtlReleasePebLock ();
return Status;
}
VOID
STDCALL
RtlDestroyProcessParameters (
PPPB Ppb
)
{
ULONG RegionSize = 0;
NtFreeVirtualMemory (NtCurrentProcess (),
(PVOID)Ppb,
&RegionSize,
MEM_RELEASE);
}
/*
* denormalize process parameters (Pointer-->Offset)
*/
VOID
STDCALL
RtlDeNormalizeProcessParams (
PPPB Ppb
)
{
if (Ppb == NULL)
return;
if (Ppb->Normalized == FALSE)
return;
if (Ppb->CurrentDirectory.Buffer != NULL)
{
Ppb->CurrentDirectory.Buffer =
(PWSTR)((ULONG)Ppb->CurrentDirectory.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 (Ppb->Reserved.Buffer != NULL)
{
Ppb->Reserved.Buffer =
(PWSTR)((ULONG)Ppb->Reserved.Buffer -
(ULONG)Ppb);
}
Ppb->Normalized = FALSE;
}
/*
* normalize process parameters (Offset-->Pointer)
*/
VOID
STDCALL
RtlNormalizeProcessParams (
PPPB Ppb
)
{
if (Ppb == NULL)
return;
if (Ppb->Normalized == TRUE)
return;
if (Ppb->CurrentDirectory.Buffer != NULL)
{
Ppb->CurrentDirectory.Buffer =
(PWSTR)((ULONG)Ppb->CurrentDirectory.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 (Ppb->Reserved.Buffer != NULL)
{
Ppb->Reserved.Buffer =
(PWSTR)((ULONG)Ppb->Reserved.Buffer +
(ULONG)Ppb);
}
Ppb->Normalized = TRUE;
}
/* EOF */

View file

@ -103,7 +103,7 @@ RtlCreateUserThread(HANDLE ProcessHandle,
&RegionSize,
MEM_RELEASE);
DPRINT("Error committing stack page!\n");
DPRINT("Error comitting stack page!\n");
return Status;
}
@ -126,7 +126,7 @@ RtlCreateUserThread(HANDLE ProcessHandle,
&RegionSize,
MEM_RELEASE);
DPRINT("Error committing guard page!\n");
DPRINT("Error comitting guard page!\n");
return Status;
}

View file

@ -57,27 +57,80 @@
static NTSTATUS LdrCreatePeb(HANDLE ProcessHandle)
{
PVOID PebBase;
ULONG PebSize;
NT_PEB Peb;
ULONG BytesWritten;
PVOID PebBase;
ULONG PebSize;
PEB Peb;
PVOID PpbBase;
ULONG PpbSize;
PPB Ppb;
ULONG BytesWritten;
NTSTATUS Status;
PebBase = (PVOID)PEB_BASE;
PebSize = 0x1000;
PebBase = (PVOID)PEB_BASE;
PebSize = 0x1000;
memset(&Peb, 0, sizeof Peb);
memset(&Peb, 0, sizeof Peb);
Peb.ProcessInfo = (PPROCESSINFO) PEB_STARTUPINFO;
Peb.Ppb = (PPPB)PEB_STARTUPINFO;
ZwWriteVirtualMemory(ProcessHandle,
(PVOID)PEB_BASE,
&Peb,
sizeof(Peb),
Status = ZwAllocateVirtualMemory (
ProcessHandle,
(PVOID*)&PebBase,
0,
&PebSize,
MEM_COMMIT,
PAGE_READWRITE
);
if (!NT_SUCCESS(Status))
{
DbgPrint ("Peb allocation failed \n");
DbgPrintErrorMessage (Status);
}
ZwWriteVirtualMemory (
ProcessHandle,
PebBase,
&Peb,
sizeof(Peb),
&BytesWritten);
/* write pointer to peb on the stack (parameter of NtProcessStartup) */
ZwWriteVirtualMemory(
ProcessHandle,
(PVOID) (STACK_TOP - 16),
&PebBase,
sizeof (PVOID),
& BytesWritten
);
/* Create process parameters block (PPB)*/
PpbBase = (PVOID)PEB_STARTUPINFO;
PpbSize = sizeof (PPB);
Status = ZwAllocateVirtualMemory (
ProcessHandle,
(PVOID*)&PpbBase,
0,
&PpbSize,
MEM_COMMIT,
PAGE_READWRITE
);
if (!NT_SUCCESS(Status))
{
DbgPrint ("Ppb allocation failed \n");
DbgPrintErrorMessage (Status);
}
memset(&Ppb, 0, sizeof(PPB));
ZwWriteVirtualMemory (
ProcessHandle,
PpbBase,
&Ppb,
sizeof(PPB),
&BytesWritten);
/* FIXME: Create ProcessInfo block */
return(STATUS_SUCCESS);
return(STATUS_SUCCESS);
}
@ -399,9 +452,9 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle,
Status = ZwAllocateVirtualMemory(
ProcessHandle,
(PVOID *) & StackBase,
(PVOID *) & StackBase,
0,
& StackSize,
& StackSize,
MEM_COMMIT,
PAGE_READWRITE
);
@ -540,7 +593,6 @@ NTSTATUS LdrLoadInitialProcess (VOID)
* alias name which is in \\??\\).
*/
LdrGetSystemDirectory(TmpNameBuffer, sizeof TmpNameBuffer);
// wcscat(TmpNameBuffer, L"\\shell.exe");
wcscat(TmpNameBuffer, L"\\smss.exe");
RtlInitUnicodeString(&ProcessName, TmpNameBuffer);
Status = LdrLoadImage(ProcessHandle, &ProcessName);

View file

@ -141,7 +141,7 @@ static NTSTATUS PsCreatePeb(HANDLE ProcessHandle)
NTSTATUS Status;
PVOID PebBase;
ULONG PebSize;
NT_PEB Peb;
PEB Peb;
ULONG BytesWritten;
PebBase = (PVOID)PEB_BASE;

View file

@ -1,4 +1,4 @@
/* $Id: init.c,v 1.5 1999/12/04 21:11:00 ea Exp $
/* $Id: init.c,v 1.6 1999/12/06 00:25:14 ekohl Exp $
*
* init.c - Session Manager initialization
*
@ -74,6 +74,8 @@ InitSessionManager (
UNICODE_STRING UnicodeString;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING CmdLineW;
PPPB Ppb;
/* Create the "\SmApiPort" object (LPC) */
RtlInitUnicodeString (&UnicodeString,
@ -131,6 +133,12 @@ InitSessionManager (
DisplayString (L"SM: System Environment created\n");
#endif
RtlSetCurrentEnvironment (SmSystemEnvironment,
NULL);
#ifndef NDEBUG
DisplayString (L"System Environment set\n");
#endif
/* FIXME: Define symbolic links to kernel devices (MS-DOS names) */
/* FIXME: Run all programs in the boot execution list */
@ -184,13 +192,27 @@ InitSessionManager (
DisplayString (L"SM: Executing shell\n");
RtlInitUnicodeString (&UnicodeString,
L"\\??\\C:\\reactos\\system32\\shell.exe");
#if 0
/* Start the logon process (winlogon.exe) */
RtlInitUnicodeString (&CmdLineW,
L"\\??\\C:\\reactos\\system32\\winlogon.exe");
#endif
RtlCreateProcessParameters (&Ppb,
&UnicodeString,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
Status = RtlCreateUserProcess (&UnicodeString,
0,
Ppb,
NULL,
NULL,
FALSE,
@ -199,6 +221,8 @@ InitSessionManager (
&Children[CHILD_WINLOGON],
NULL);
RtlDestroyProcessParameters (Ppb);
if (!NT_SUCCESS(Status))
{
DisplayString (L"SM: Loading shell.exe failed!\n");

View file

@ -1,4 +1,4 @@
/* $Id: smss.c,v 1.2 1999/12/01 15:18:54 ekohl Exp $
/* $Id: smss.c,v 1.3 1999/12/06 00:25:14 ekohl Exp $
*
* smss.c - Session Manager
*
@ -41,15 +41,39 @@ DisplayString( LPCWSTR lpwString )
}
void
PrintString (char* fmt,...)
{
char buffer[512];
va_list ap;
UNICODE_STRING UnicodeString;
ANSI_STRING AnsiString;
ULONG i;
va_start(ap, fmt);
vsprintf(buffer, fmt, ap);
va_end(ap);
RtlInitAnsiString (&AnsiString, buffer);
RtlAnsiStringToUnicodeString (
&UnicodeString,
&AnsiString,
TRUE);
NtDisplayString(&UnicodeString);
RtlFreeUnicodeString (&UnicodeString);
}
/* Native image's entry point */
void
NtProcessStartup( PSTARTUP_ARGUMENT StartupArgument )
NtProcessStartup (PPEB Peb)
{
HANDLE Children[2]; /* csrss, winlogon */
DisplayString( L"Session Manager\n" );
PrintString ("Peb %x\n", Peb);
if (TRUE == InitSessionManager(Children))
{