mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
- 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:
parent
09edfdc32f
commit
b001203a86
17 changed files with 1207 additions and 694 deletions
|
@ -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;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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,17 +129,17 @@ 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
|
||||
|
||||
#define OBJECT_TYPE_CREATE 0x0001
|
||||
#define OBJECT_TYPE_CREATE 0x0001
|
||||
#define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1)
|
||||
|
||||
// directory access rights
|
||||
|
@ -154,9 +153,9 @@ 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
|
||||
{
|
||||
PVOID FaultingPc;
|
||||
|
@ -166,14 +165,14 @@ typedef struct _PROCESS_WS_WATCH_INFORMATION
|
|||
typedef struct _PROCESS_BASIC_INFORMATION
|
||||
{
|
||||
NTSTATUS ExitStatus;
|
||||
PNT_PEB PebBaseAddress;
|
||||
PPEB PebBaseAddress;
|
||||
KAFFINITY AffinityMask;
|
||||
KPRIORITY BasePriority;
|
||||
ULONG UniqueProcessId;
|
||||
ULONG InheritedFromUniqueProcessId;
|
||||
} PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION;
|
||||
|
||||
typedef struct _QUOTA_LIMITS
|
||||
typedef struct _QUOTA_LIMITS
|
||||
{
|
||||
ULONG PagedPoolLimit;
|
||||
ULONG NonPagedPoolLimit;
|
||||
|
@ -194,7 +193,7 @@ typedef struct _IO_COUNTERS
|
|||
} IO_COUNTERS, *PIO_COUNTERS;
|
||||
|
||||
|
||||
typedef struct _VM_COUNTERS_
|
||||
typedef struct _VM_COUNTERS_
|
||||
{
|
||||
ULONG PeakVirtualSize;
|
||||
ULONG VirtualSize;
|
||||
|
@ -210,7 +209,7 @@ typedef struct _VM_COUNTERS_
|
|||
} VM_COUNTERS, *PVM_COUNTERS;
|
||||
|
||||
|
||||
typedef struct _POOLED_USAGE_AND_LIMITS_
|
||||
typedef struct _POOLED_USAGE_AND_LIMITS_
|
||||
{
|
||||
ULONG PeakPagedPoolUsage;
|
||||
ULONG PagedPoolUsage;
|
||||
|
@ -224,13 +223,13 @@ typedef struct _POOLED_USAGE_AND_LIMITS_
|
|||
} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS;
|
||||
|
||||
|
||||
typedef struct _PROCESS_ACCESS_TOKEN
|
||||
typedef struct _PROCESS_ACCESS_TOKEN
|
||||
{
|
||||
HANDLE Token;
|
||||
HANDLE Thread;
|
||||
} PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN;
|
||||
|
||||
typedef struct _KERNEL_USER_TIMES
|
||||
typedef struct _KERNEL_USER_TIMES
|
||||
{
|
||||
TIME CreateTime;
|
||||
TIME ExitTime;
|
||||
|
@ -253,22 +252,22 @@ typedef struct _THREAD_BASIC_INFORMATION
|
|||
} THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION;
|
||||
|
||||
// object information
|
||||
|
||||
typedef struct _OBJECT_NAME_INFORMATION
|
||||
{
|
||||
UNICODE_STRING Name;
|
||||
} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
|
||||
|
||||
typedef struct _OBJECT_NAME_INFORMATION
|
||||
{
|
||||
UNICODE_STRING Name;
|
||||
} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION;
|
||||
|
||||
|
||||
|
||||
typedef struct _OBJECT_DATA_INFORMATION
|
||||
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
|
||||
typedef struct _OBJECT_TYPE_INFORMATION
|
||||
{
|
||||
UNICODE_STRING Name;
|
||||
UNICODE_STRING Type;
|
||||
|
@ -300,9 +299,9 @@ typedef struct _SYSTEM_TIME_ADJUSTMENT
|
|||
ULONG TimeAdjustment;
|
||||
BOOL TimeAdjustmentDisabled;
|
||||
} SYSTEM_TIME_ADJUSTMENT, *PSYSTEM_TIME_ADJUSTMENT;
|
||||
|
||||
typedef struct _SYSTEM_CONFIGURATION_INFO {
|
||||
union {
|
||||
|
||||
typedef struct _SYSTEM_CONFIGURATION_INFO {
|
||||
union {
|
||||
ULONG OemId;
|
||||
struct {
|
||||
WORD ProcessorArchitecture;
|
||||
|
@ -321,56 +320,58 @@ 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
|
||||
|
||||
typedef struct _FILE_BASIC_INFORMATION
|
||||
{
|
||||
TIME CreationTime;
|
||||
TIME LastAccessTime;
|
||||
TIME LastWriteTime;
|
||||
TIME ChangeTime;
|
||||
ULONG FileAttributes;
|
||||
} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
|
||||
|
||||
typedef struct _FILE_STANDARD_INFORMATION
|
||||
{
|
||||
LARGE_INTEGER AllocationSize;
|
||||
LARGE_INTEGER EndOfFile;
|
||||
ULONG NumberOfLinks;
|
||||
BOOLEAN DeletePending;
|
||||
BOOLEAN Directory;
|
||||
typedef struct _FILE_BASIC_INFORMATION
|
||||
{
|
||||
TIME CreationTime;
|
||||
TIME LastAccessTime;
|
||||
TIME LastWriteTime;
|
||||
TIME ChangeTime;
|
||||
ULONG FileAttributes;
|
||||
} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
|
||||
|
||||
typedef struct _FILE_STANDARD_INFORMATION
|
||||
{
|
||||
LARGE_INTEGER AllocationSize;
|
||||
LARGE_INTEGER EndOfFile;
|
||||
ULONG NumberOfLinks;
|
||||
BOOLEAN DeletePending;
|
||||
BOOLEAN Directory;
|
||||
} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
|
||||
|
||||
typedef struct _FILE_POSITION_INFORMATION
|
||||
{
|
||||
LARGE_INTEGER CurrentByteOffset;
|
||||
} FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
|
||||
|
||||
typedef struct _FILE_ALIGNMENT_INFORMATION
|
||||
{
|
||||
ULONG AlignmentRequirement;
|
||||
} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
|
||||
|
||||
|
||||
typedef struct _FILE_POSITION_INFORMATION
|
||||
{
|
||||
LARGE_INTEGER CurrentByteOffset;
|
||||
} FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
|
||||
|
||||
typedef struct _FILE_ALIGNMENT_INFORMATION
|
||||
{
|
||||
ULONG AlignmentRequirement;
|
||||
} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION;
|
||||
|
||||
typedef struct _FILE_DISPOSITION_INFORMATION
|
||||
{
|
||||
BOOLEAN DeleteFile;
|
||||
} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
|
||||
|
||||
{
|
||||
BOOLEAN DeleteFile;
|
||||
} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
|
||||
|
||||
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 {
|
||||
{
|
||||
LARGE_INTEGER EndOfFile;
|
||||
} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_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;
|
||||
|
||||
|
@ -471,9 +472,9 @@ typedef struct _FILE_ALL_INFORMATION {
|
|||
|
||||
// file system information structures
|
||||
|
||||
typedef struct _FILE_FS_DEVICE_INFORMATION {
|
||||
DEVICE_TYPE DeviceType;
|
||||
ULONG Characteristics;
|
||||
typedef struct _FILE_FS_DEVICE_INFORMATION {
|
||||
DEVICE_TYPE DeviceType;
|
||||
ULONG Characteristics;
|
||||
} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
|
||||
|
||||
|
||||
|
@ -496,13 +497,13 @@ typedef struct _FILE_FS_ATTRIBUTE_INFORMATION {
|
|||
ULONG FileSystemAttributes;
|
||||
LONG MaximumComponentNameLength;
|
||||
ULONG FileSystemNameLength;
|
||||
WCHAR FileSystemName[0];
|
||||
WCHAR FileSystemName[0];
|
||||
} FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_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
|
||||
|
@ -518,17 +519,17 @@ typedef struct _FILE_FS_LABEL_INFORMATION {
|
|||
// read file scatter / write file scatter
|
||||
//FIXME I am a win32 struct aswell
|
||||
|
||||
typedef union _FILE_SEGMENT_ELEMENT {
|
||||
PVOID Buffer;
|
||||
ULONG Alignment;
|
||||
}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
|
||||
typedef union _FILE_SEGMENT_ELEMENT {
|
||||
PVOID Buffer;
|
||||
ULONG Alignment;
|
||||
}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
|
||||
|
||||
// directory information
|
||||
|
||||
typedef struct _OBJDIR_INFORMATION {
|
||||
UNICODE_STRING ObjectName;
|
||||
UNICODE_STRING ObjectTypeName; // Directory, Device ...
|
||||
UCHAR Data[0];
|
||||
UCHAR Data[0];
|
||||
} OBJDIR_INFORMATION, *POBJDIR_INFORMATION;
|
||||
|
||||
|
||||
|
@ -622,28 +623,14 @@ typedef struct _FILE_NOTIFY_INFORMATION {
|
|||
*/
|
||||
|
||||
|
||||
//FIXME: I am a win32 object
|
||||
typedef
|
||||
VOID
|
||||
(*PTIMERAPCROUTINE)(
|
||||
LPVOID lpArgToCompletionRoutine,
|
||||
DWORD dwTimerLowValue,
|
||||
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;
|
||||
//FIXME: I am a win32 object
|
||||
typedef
|
||||
VOID
|
||||
(*PTIMERAPCROUTINE)(
|
||||
LPVOID lpArgToCompletionRoutine,
|
||||
DWORD dwTimerLowValue,
|
||||
DWORD dwTimerHighValue
|
||||
);
|
||||
|
||||
|
||||
// File System Control commands ( related to defragging )
|
||||
|
@ -653,7 +640,7 @@ typedef struct _STARTUP_ARGUMENT {
|
|||
#define FSCTL_GET_RETRIEVAL_POINTERS 0x90073
|
||||
#define FSCTL_MOVE_FILE 0x90074
|
||||
|
||||
typedef struct _MAPPING_PAIR
|
||||
typedef struct _MAPPING_PAIR
|
||||
{
|
||||
ULONGLONG Vcn;
|
||||
ULONGLONG Lcn;
|
||||
|
@ -670,17 +657,17 @@ typedef struct _BITMAP_DESCRIPTOR
|
|||
{
|
||||
ULONGLONG StartLcn;
|
||||
ULONGLONG ClustersToEndOfVol;
|
||||
BYTE Map[0]; // variable size
|
||||
} BITMAP_DESCRIPTOR, *PBITMAP_DESCRIPTOR;
|
||||
BYTE Map[0]; // variable size
|
||||
} BITMAP_DESCRIPTOR, *PBITMAP_DESCRIPTOR;
|
||||
|
||||
typedef struct _MOVEFILE_DESCRIPTOR
|
||||
{
|
||||
HANDLE FileHandle;
|
||||
ULONG Reserved;
|
||||
LARGE_INTEGER StartVcn;
|
||||
HANDLE FileHandle;
|
||||
ULONG Reserved;
|
||||
LARGE_INTEGER StartVcn;
|
||||
LARGE_INTEGER TargetLcn;
|
||||
ULONG NumVcns;
|
||||
ULONG Reserved1;
|
||||
ULONG NumVcns;
|
||||
ULONG Reserved1;
|
||||
} MOVEFILE_DESCRIPTOR, *PMOVEFILE_DESCRIPTOR;
|
||||
|
||||
|
||||
|
@ -694,7 +681,7 @@ typedef struct _SEMAPHORE_BASIC_INFORMATION
|
|||
|
||||
// event information
|
||||
|
||||
typedef struct _EVENT_BASIC_INFORMATION
|
||||
typedef struct _EVENT_BASIC_INFORMATION
|
||||
{
|
||||
BOOL AutomaticReset;
|
||||
BOOL Signaled;
|
||||
|
@ -706,7 +693,7 @@ typedef struct _EVENT_BASIC_INFORMATION
|
|||
// SynchronizationTimer
|
||||
//} TIMER_TYPE;
|
||||
|
||||
typedef
|
||||
typedef
|
||||
struct _LPC_PORT_BASIC_INFORMATION
|
||||
{
|
||||
DWORD Unknown0;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
@ -123,14 +124,13 @@ HANDLE STDCALL CreateFirstThread(HANDLE ProcessHandle,
|
|||
lpThreadAttributes->lpSecurityDescriptor;
|
||||
}
|
||||
ObjectAttributes.SecurityQualityOfService = NULL;
|
||||
|
||||
|
||||
if ((dwCreationFlags & CREATE_SUSPENDED) == CREATE_SUSPENDED)
|
||||
CreateSuspended = TRUE;
|
||||
else
|
||||
CreateSuspended = FALSE;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BaseAddress = (PVOID)(STACK_TOP - dwStackSize);
|
||||
Status = NtAllocateVirtualMemory(ProcessHandle,
|
||||
&BaseAddress,
|
||||
|
@ -153,9 +153,9 @@ HANDLE STDCALL CreateFirstThread(HANDLE ProcessHandle,
|
|||
ThreadContext.SegSs = USER_DS;
|
||||
ThreadContext.Esp = STACK_TOP - 16;
|
||||
ThreadContext.EFlags = (1<<1) + (1<<9);
|
||||
|
||||
|
||||
DPRINT("ThreadContext.Eip %x\n",ThreadContext.Eip);
|
||||
|
||||
|
||||
NtDuplicateObject(NtCurrentProcess(),
|
||||
&SectionHandle,
|
||||
ProcessHandle,
|
||||
|
@ -187,7 +187,7 @@ HANDLE STDCALL CreateFirstThread(HANDLE ProcessHandle,
|
|||
sizeof(DupSectionHandle),
|
||||
&BytesWritten);
|
||||
|
||||
|
||||
|
||||
Status = NtCreateThread(&ThreadHandle,
|
||||
THREAD_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
|
@ -198,7 +198,7 @@ HANDLE STDCALL CreateFirstThread(HANDLE ProcessHandle,
|
|||
CreateSuspended);
|
||||
if ( lpThreadId != NULL )
|
||||
memcpy(lpThreadId, &ClientId.UniqueThread,sizeof(ULONG));
|
||||
|
||||
|
||||
return ThreadHandle;
|
||||
}
|
||||
|
||||
|
@ -222,10 +222,10 @@ HANDLE KERNEL32_MapFile(LPCWSTR lpApplicationName,
|
|||
DWORD len = 0;
|
||||
|
||||
hFile = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Find the application name
|
||||
*/
|
||||
*/
|
||||
TempApplicationName[0] = '\\';
|
||||
TempApplicationName[1] = '?';
|
||||
TempApplicationName[2] = '?';
|
||||
|
@ -233,7 +233,7 @@ HANDLE KERNEL32_MapFile(LPCWSTR lpApplicationName,
|
|||
TempApplicationName[4] = 0;
|
||||
|
||||
DPRINT("TempApplicationName '%w'\n",TempApplicationName);
|
||||
|
||||
|
||||
if (lpApplicationName != NULL)
|
||||
{
|
||||
wcscpy(TempFileName, lpApplicationName);
|
||||
|
@ -241,7 +241,7 @@ HANDLE KERNEL32_MapFile(LPCWSTR lpApplicationName,
|
|||
DPRINT("TempFileName '%w'\n",TempFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
wcscpy(TempFileName, lpCommandLine);
|
||||
|
||||
DPRINT("TempFileName '%w'\n",TempFileName);
|
||||
|
@ -261,11 +261,11 @@ HANDLE KERNEL32_MapFile(LPCWSTR lpApplicationName,
|
|||
wcscat(TempApplicationName,TempDirectoryName);
|
||||
}
|
||||
wcscat(TempApplicationName,TempFileName);
|
||||
|
||||
|
||||
RtlInitUnicodeString(&ApplicationNameString, TempApplicationName);
|
||||
|
||||
|
||||
DPRINT("ApplicationName %w\n",ApplicationNameString.Buffer);
|
||||
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&ApplicationNameString,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
|
@ -275,20 +275,20 @@ HANDLE KERNEL32_MapFile(LPCWSTR lpApplicationName,
|
|||
/*
|
||||
* Try to open the executable
|
||||
*/
|
||||
|
||||
|
||||
Status = NtOpenFile(&hFile,
|
||||
SYNCHRONIZE|FILE_EXECUTE|FILE_READ_DATA,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
FILE_SHARE_DELETE|FILE_SHARE_READ,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE);
|
||||
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
Status = NtReadFile(hFile,
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -303,7 +303,7 @@ HANDLE KERNEL32_MapFile(LPCWSTR lpApplicationName,
|
|||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
FileOffset.u.LowPart = DosHeader->e_lfanew;
|
||||
FileOffset.u.HighPart = 0;
|
||||
|
||||
|
@ -319,10 +319,10 @@ HANDLE KERNEL32_MapFile(LPCWSTR lpApplicationName,
|
|||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return(NULL);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Status = NtCreateSection(&hSection,
|
||||
SECTION_ALL_ACCESS,
|
||||
NULL,
|
||||
|
@ -332,25 +332,27 @@ HANDLE KERNEL32_MapFile(LPCWSTR lpApplicationName,
|
|||
hFile);
|
||||
NtClose(hFile);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
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,7 +423,9 @@ 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);
|
||||
|
||||
|
@ -443,15 +447,31 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
|
|||
wcscat(TempCommandLine, L" ");
|
||||
wcscat(TempCommandLine, lpCommandLine);
|
||||
}
|
||||
|
||||
|
||||
hSection = KERNEL32_MapFile(lpApplicationName,
|
||||
lpCommandLine,
|
||||
&Headers,
|
||||
&DosHeader);
|
||||
|
||||
|
||||
RtlInitUnicodeString (
|
||||
&CommandLine_U,
|
||||
TempCommandLine);
|
||||
|
||||
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,
|
||||
PROCESS_ALL_ACCESS,
|
||||
NULL,
|
||||
NtCurrentProcess(),
|
||||
bInheritHandles,
|
||||
|
@ -466,16 +486,16 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
|
|||
DPRINT("ProcessBasicInfo.UniqueProcessId %d\n",
|
||||
ProcessBasicInfo.UniqueProcessId);
|
||||
lpProcessInformation->dwProcessId = ProcessBasicInfo.UniqueProcessId;
|
||||
|
||||
|
||||
/*
|
||||
* Map NT DLL into the process
|
||||
*/
|
||||
Status = LdrMapNTDllForProcess(hProcess,
|
||||
&NTDllSection);
|
||||
|
||||
InitialViewSize = DosHeader.e_lfanew + sizeof(IMAGE_NT_HEADERS)
|
||||
|
||||
InitialViewSize = DosHeader.e_lfanew + sizeof(IMAGE_NT_HEADERS)
|
||||
+ sizeof(IMAGE_SECTION_HEADER) * Headers.FileHeader.NumberOfSections;
|
||||
|
||||
|
||||
BaseAddress = (PVOID)Headers.OptionalHeader.ImageBase;
|
||||
SectionOffset.QuadPart = 0;
|
||||
Status = NtMapViewOfSection(hSection,
|
||||
|
@ -490,6 +510,7 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
|
|||
PAGE_READWRITE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
RtlDestroyProcessParameters (Ppb);
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -498,18 +519,20 @@ 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)
|
||||
((PIMAGE_OPTIONAL_HEADER)OPTHDROFFSET(NTDLL_BASE))->
|
||||
AddressOfEntryPoint +
|
||||
((PIMAGE_OPTIONAL_HEADER)OPTHDROFFSET(NTDLL_BASE))->ImageBase;
|
||||
hThread = CreateFirstThread(hProcess,
|
||||
hThread = CreateFirstThread(hProcess,
|
||||
lpThreadAttributes,
|
||||
Headers.OptionalHeader.SizeOfStackReserve,
|
||||
lpStartAddress,
|
||||
lpParameter,
|
||||
lpStartAddress,
|
||||
lpParameter,
|
||||
dwCreationFlags,
|
||||
&lpProcessInformation->dwThreadId,
|
||||
TempCommandLine,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -53,7 +53,7 @@ RtlpCreateFirstThread(HANDLE ProcessHandle,
|
|||
PVOID BaseAddress;
|
||||
ULONG BytesWritten;
|
||||
HANDLE DupNTDllSectionHandle, DupSectionHandle;
|
||||
|
||||
|
||||
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||
ObjectAttributes.RootDirectory = NULL;
|
||||
ObjectAttributes.ObjectName = NULL;
|
||||
|
@ -61,14 +61,12 @@ RtlpCreateFirstThread(HANDLE ProcessHandle,
|
|||
// ObjectAttributes.Attributes = OBJ_INHERIT;
|
||||
ObjectAttributes.SecurityDescriptor = SecurityDescriptor;
|
||||
ObjectAttributes.SecurityQualityOfService = NULL;
|
||||
|
||||
|
||||
if ((dwCreationFlags & CREATE_SUSPENDED) == CREATE_SUSPENDED)
|
||||
CreateSuspended = TRUE;
|
||||
else
|
||||
CreateSuspended = FALSE;
|
||||
|
||||
|
||||
|
||||
|
||||
BaseAddress = (PVOID)(STACK_TOP - dwStackSize);
|
||||
Status = NtAllocateVirtualMemory(ProcessHandle,
|
||||
&BaseAddress,
|
||||
|
@ -80,7 +78,7 @@ RtlpCreateFirstThread(HANDLE ProcessHandle,
|
|||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
memset(&ThreadContext,0,sizeof(CONTEXT));
|
||||
ThreadContext.Eip = (ULONG)lpStartAddress;
|
||||
|
@ -89,12 +87,12 @@ RtlpCreateFirstThread(HANDLE ProcessHandle,
|
|||
ThreadContext.SegEs = USER_DS;
|
||||
ThreadContext.SegDs = USER_DS;
|
||||
ThreadContext.SegCs = USER_CS;
|
||||
ThreadContext.SegSs = USER_DS;
|
||||
ThreadContext.SegSs = USER_DS;
|
||||
ThreadContext.Esp = STACK_TOP - 16;
|
||||
ThreadContext.EFlags = (1<<1) + (1<<9);
|
||||
|
||||
|
||||
DPRINT("ThreadContext.Eip %x\n",ThreadContext.Eip);
|
||||
|
||||
|
||||
NtDuplicateObject(NtCurrentProcess(),
|
||||
&SectionHandle,
|
||||
ProcessHandle,
|
||||
|
@ -136,7 +134,7 @@ RtlpCreateFirstThread(HANDLE ProcessHandle,
|
|||
CreateSuspended);
|
||||
if ( lpThreadId != NULL )
|
||||
memcpy(lpThreadId, &ClientId.UniqueThread,sizeof(ULONG));
|
||||
|
||||
|
||||
return ThreadHandle;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -205,7 +202,7 @@ RtlpMapFile(PUNICODE_STRING ApplicationName,
|
|||
&FileOffset,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status;
|
||||
return Status;
|
||||
|
||||
Status = NtCreateSection(Section,
|
||||
SECTION_ALL_ACCESS,
|
||||
|
@ -216,7 +213,7 @@ RtlpMapFile(PUNICODE_STRING ApplicationName,
|
|||
hFile);
|
||||
NtClose(hFile);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
|
@ -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,16 +305,16 @@ 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);
|
||||
|
||||
Status = NtCreateProcess(&hProcess,
|
||||
PROCESS_ALL_ACCESS,
|
||||
PROCESS_ALL_ACCESS,
|
||||
NULL,
|
||||
NtCurrentProcess(),
|
||||
bInheritHandles,
|
||||
|
@ -328,16 +330,16 @@ RtlCreateUserProcess(PUNICODE_STRING ApplicationName,
|
|||
DPRINT("ProcessBasicInfo.UniqueProcessId %d\n",
|
||||
ProcessBasicInfo.UniqueProcessId);
|
||||
LocalClientId.UniqueProcess = ProcessBasicInfo.UniqueProcessId;
|
||||
|
||||
|
||||
/*
|
||||
* Map NT DLL into the process
|
||||
*/
|
||||
Status = LdrMapNTDllForProcess(hProcess,
|
||||
&NTDllSection);
|
||||
|
||||
|
||||
InitialViewSize = DosHeader.e_lfanew + sizeof(IMAGE_NT_HEADERS)
|
||||
+ sizeof(IMAGE_SECTION_HEADER) * Headers.FileHeader.NumberOfSections;
|
||||
|
||||
|
||||
BaseAddress = (PVOID)Headers.OptionalHeader.ImageBase;
|
||||
SectionOffset.QuadPart = 0;
|
||||
Status = NtMapViewOfSection(hSection,
|
||||
|
@ -352,29 +354,30 @@ RtlCreateUserProcess(PUNICODE_STRING ApplicationName,
|
|||
PAGE_READWRITE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status;
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ RtlInitializeContext(HANDLE ProcessHandle,
|
|||
Context->SegEs = USER_DS;
|
||||
Context->SegDs = USER_DS;
|
||||
Context->SegCs = USER_CS;
|
||||
Context->SegSs = USER_DS;
|
||||
Context->SegSs = USER_DS;
|
||||
Context->Esp = (ULONG)InitialTeb->StackBase - 8;
|
||||
Context->EFlags = (1<<1) + (1<<9);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -117,23 +170,23 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle,
|
|||
*/
|
||||
LdrGetSystemDirectory(TmpNameBuffer, sizeof TmpNameBuffer);
|
||||
wcscat(TmpNameBuffer, L"\\ntdll.dll");
|
||||
RtlInitUnicodeString(&DllPathname, TmpNameBuffer);
|
||||
RtlInitUnicodeString(&DllPathname, TmpNameBuffer);
|
||||
InitializeObjectAttributes(&FileObjectAttributes,
|
||||
&DllPathname,
|
||||
&DllPathname,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
DPRINT("Opening NTDLL\n");
|
||||
Status = ZwOpenFile(&FileHandle,
|
||||
FILE_ALL_ACCESS,
|
||||
&FileObjectAttributes,
|
||||
NULL,
|
||||
0,
|
||||
Status = ZwOpenFile(&FileHandle,
|
||||
FILE_ALL_ACCESS,
|
||||
&FileObjectAttributes,
|
||||
NULL,
|
||||
0,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("NTDLL open failed ");
|
||||
DbgPrintErrorMessage(Status);
|
||||
DbgPrintErrorMessage(Status);
|
||||
return Status;
|
||||
}
|
||||
Status = ZwReadFile(FileHandle,
|
||||
|
@ -149,10 +202,10 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle,
|
|||
{
|
||||
DPRINT("NTDLL header read failed ");
|
||||
DbgPrintErrorMessage(Status);
|
||||
ZwClose(FileHandle);
|
||||
ZwClose(FileHandle);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* FIXME: this will fail if the NT headers are
|
||||
* more than 1024 bytes from start.
|
||||
|
@ -192,7 +245,7 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle,
|
|||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Map the NTDLL into the process
|
||||
*/
|
||||
|
@ -222,7 +275,7 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle,
|
|||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0;
|
||||
(i < NTHeaders->FileHeader.NumberOfSections);
|
||||
i++)
|
||||
|
@ -399,9 +452,9 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle,
|
|||
|
||||
Status = ZwAllocateVirtualMemory(
|
||||
ProcessHandle,
|
||||
(PVOID *) & StackBase,
|
||||
(PVOID *) & StackBase,
|
||||
0,
|
||||
& StackSize,
|
||||
& StackSize,
|
||||
MEM_COMMIT,
|
||||
PAGE_READWRITE
|
||||
);
|
||||
|
@ -415,7 +468,7 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle,
|
|||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
ZwDuplicateObject(
|
||||
NtCurrentProcess(),
|
||||
& SectionHandle,
|
||||
|
@ -434,7 +487,7 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle,
|
|||
FALSE,
|
||||
DUPLICATE_SAME_ACCESS
|
||||
);
|
||||
|
||||
|
||||
ZwWriteVirtualMemory(
|
||||
ProcessHandle,
|
||||
(PVOID) (STACK_TOP - 4),
|
||||
|
@ -458,14 +511,14 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle,
|
|||
);
|
||||
/*
|
||||
* Create a peb (grungy)
|
||||
*/
|
||||
*/
|
||||
Status = LdrCreatePeb(ProcessHandle);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("LDR: Failed to create initial peb\n");
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize context to point to LdrStartup
|
||||
*/
|
||||
|
@ -479,7 +532,7 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle,
|
|||
Context.SegEs = USER_DS;
|
||||
Context.SegFs = USER_DS;
|
||||
Context.SegGs = USER_DS;
|
||||
|
||||
|
||||
DPRINT("LdrStartupAddr %x\n",LdrStartupAddr);
|
||||
/*
|
||||
* FIXME: Create process and let 'er rip
|
||||
|
@ -519,8 +572,8 @@ NTSTATUS LdrLoadInitialProcess (VOID)
|
|||
HANDLE ProcessHandle;
|
||||
UNICODE_STRING ProcessName;
|
||||
WCHAR TmpNameBuffer [MAX_PATH];
|
||||
|
||||
|
||||
|
||||
|
||||
Status = ZwCreateProcess(&ProcessHandle,
|
||||
PROCESS_ALL_ACCESS,
|
||||
NULL,
|
||||
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue