Partial patch of larger rosrtl removal patch. This one merely is a structure fix patch, and renames/corrects RTL_USER_PROCESS_INFORMATION (which had the totally wrong names) as well as updates the TEB to the latest version. It also fixes SECTION_IMAGE_INFORMATION to have the right format and names. Also, some callers of CreateProcessW are modified to not send a constant string as lpCommandLine (this was illegal and will crash on Windows/my patch). INITIAL_TEB was also renamed to the more correct fields, although they won't make sense with the current rosrtl/rtl implementation, the names will only make sense with the next patch. Finally NtTerminateThread was fixed to support sending NULL as handle, and PspExitThread was updated to work with the new FreestackOnExit flag, both of which will be used in the next patch.

svn path=/trunk/; revision=16540
This commit is contained in:
Alex Ionescu 2005-07-12 01:56:14 +00:00
parent e36f90a9f9
commit a10ed009b7
46 changed files with 505 additions and 451 deletions

View file

@ -26,14 +26,15 @@ List:
- Object Directory + implementation doesn't match NT (Alex) [obtypes.h] - Object Directory + implementation doesn't match NT (Alex) [obtypes.h]
Priority 3: Priority 3:
- Some RTL Structures need review (Alex) [rtltypes.h]
- Pushlock support is needed to fix EPROCESS (Alex) [pstypes.h] - Pushlock support is needed to fix EPROCESS (Alex) [pstypes.h]
- MADDRESS_SPACE must be converted into the NT Type (Alex) [pstypes.h, mmtypes.h] - MADDRESS_SPACE must be converted into the NT Type (Alex) [pstypes.h, mmtypes.h]
Priority 4: Priority 4:
- FIXED: Kernel and Memory Types are not architecture-specific (Eric) [ketypes.h, mmtypes.h] - FIXED: Kernel and Memory Types are not architecture-specific (Eric) [ketypes.h, mmtypes.h]
- Win32K Builds with windows.h [extypes.h, ketypes.h] - Win32K Builds with windows.h (Filip, bugzilla id 666) [extypes.h, ketypes.h]
Priority 5: Priority 5:
- LPC Types are totally wrong. [lpctypes.h] - LPC Types are totally wrong. [lpctypes.h]
- Missing System Info Classes [zwtypes.h] - Missing System Info Classes [zwtypes.h]
- Process Priority Classes are messed up [pstypes.h] - Process Priority Classes are messed up (Alex) [pstypes.h]

View file

@ -93,12 +93,6 @@ typedef NTSTATUS
struct _ETHREAD; struct _ETHREAD;
typedef struct _CURDIR
{
UNICODE_STRING DosPath;
PVOID Handle;
} CURDIR, *PCURDIR;
typedef struct _DESCRIPTOR_TABLE_ENTRY typedef struct _DESCRIPTOR_TABLE_ENTRY
{ {
ULONG Selector; ULONG Selector;
@ -181,75 +175,101 @@ typedef struct _GDI_TEB_BATCH
typedef struct _INITIAL_TEB typedef struct _INITIAL_TEB
{ {
PVOID PreviousStackBase;
PVOID PreviousStackLimit;
PVOID StackBase; PVOID StackBase;
PVOID StackLimit; PVOID StackLimit;
PVOID StackCommit; PVOID AllocatedStackBase;
PVOID StackCommitMax;
PVOID StackReserved;
} INITIAL_TEB, *PINITIAL_TEB; } INITIAL_TEB, *PINITIAL_TEB;
typedef struct _TEB_ACTIVE_FRAME_CONTEXT
{
ULONG Flags;
LPSTR FrameName;
} TEB_ACTIVE_FRAME_CONTEXT, *PTEB_ACTIVE_FRAME_CONTEXT;
typedef struct _TEB_ACTIVE_FRAME
{
ULONG Flags;
struct _TEB_ACTIVE_FRAME *Previous;
PTEB_ACTIVE_FRAME_CONTEXT Context;
} TEB_ACTIVE_FRAME, *PTEB_ACTIVE_FRAME;
typedef struct _TEB typedef struct _TEB
{ {
NT_TIB Tib; /* 00h */ NT_TIB Tib; /* 00h */
PVOID EnvironmentPointer; /* 1Ch */ PVOID EnvironmentPointer; /* 1Ch */
CLIENT_ID Cid; /* 20h */ CLIENT_ID Cid; /* 20h */
PVOID ActiveRpcInfo; /* 28h */ PVOID ActiveRpcHandle; /* 28h */
PVOID ThreadLocalStoragePointer; /* 2Ch */ PVOID ThreadLocalStoragePointer; /* 2Ch */
struct _PEB *Peb; /* 30h */ struct _PEB *ProcessEnvironmentBlock; /* 30h */
ULONG LastErrorValue; /* 34h */ ULONG LastErrorValue; /* 34h */
ULONG CountOfOwnedCriticalSections; /* 38h */ ULONG CountOfOwnedCriticalSections; /* 38h */
PVOID CsrClientThread; /* 3Ch */ PVOID CsrClientThread; /* 3Ch */
struct _W32THREAD* Win32ThreadInfo; /* 40h */ struct _W32THREAD* Win32ThreadInfo; /* 40h */
ULONG Win32ClientInfo[0x1F]; /* 44h */ ULONG User32Reserved[0x1A]; /* 44h */
PVOID WOW32Reserved; /* C0h */ ULONG UserReserved[5]; /* ACh */
LCID CurrentLocale; /* C4h */ PVOID WOW32Reserved; /* C0h */
ULONG FpSoftwareStatusRegister; /* C8h */ LCID CurrentLocale; /* C4h */
PVOID SystemReserved1[0x36]; /* CCh */ ULONG FpSoftwareStatusRegister; /* C8h */
PVOID Spare1; /* 1A4h */ PVOID SystemReserved1[0x36]; /* CCh */
LONG ExceptionCode; /* 1A8h */ LONG ExceptionCode; /* 1A4h */
UCHAR SpareBytes1[0x28]; /* 1ACh */ struct _ACTIVATION_CONTEXT_STACK *ActivationContextStackPointer; /* 1A8h */
PVOID SystemReserved2[0xA]; /* 1D4h */ UCHAR SpareBytes1[0x28]; /* 1ACh */
GDI_TEB_BATCH GdiTebBatch; /* 1FCh */ GDI_TEB_BATCH GdiTebBatch; /* 1D4h */
ULONG gdiRgn; /* 6DCh */ CLIENT_ID RealClientId; /* 6B4h */
ULONG gdiPen; /* 6E0h */ PVOID GdiCachedProcessHandle; /* 6BCh */
ULONG gdiBrush; /* 6E4h */ ULONG GdiClientPID; /* 6C0h */
CLIENT_ID RealClientId; /* 6E8h */ ULONG GdiClientTID; /* 6C4h */
PVOID GdiCachedProcessHandle; /* 6F0h */ PVOID GdiThreadLocalInfo; /* 6C8h */
ULONG GdiClientPID; /* 6F4h */ ULONG Win32ClientInfo[62]; /* 6CCh */
ULONG GdiClientTID; /* 6F8h */ PVOID glDispatchTable[0xE9]; /* 7C4h */
PVOID GdiThreadLocaleInfo; /* 6FCh */ ULONG glReserved1[0x1D]; /* B68h */
PVOID UserReserved[5]; /* 700h */ PVOID glReserved2; /* BDCh */
PVOID glDispatchTable[0x118]; /* 714h */ PVOID glSectionInfo; /* BE0h */
ULONG glReserved1[0x1A]; /* B74h */ PVOID glSection; /* BE4h */
PVOID glReserved2; /* BDCh */ PVOID glTable; /* BE8h */
PVOID glSectionInfo; /* BE0h */ PVOID glCurrentRC; /* BECh */
PVOID glSection; /* BE4h */ PVOID glContext; /* BF0h */
PVOID glTable; /* BE8h */ NTSTATUS LastStatusValue; /* BF4h */
PVOID glCurrentRC; /* BECh */ UNICODE_STRING StaticUnicodeString; /* BF8h */
PVOID glContext; /* BF0h */ WCHAR StaticUnicodeBuffer[0x105]; /* C00h */
NTSTATUS LastStatusValue; /* BF4h */ PVOID DeallocationStack; /* E0Ch */
UNICODE_STRING StaticUnicodeString; /* BF8h */ PVOID TlsSlots[0x40]; /* E10h */
WCHAR StaticUnicodeBuffer[0x105]; /* C00h */ LIST_ENTRY TlsLinks; /* F10h */
PVOID DeallocationStack; /* E0Ch */ PVOID Vdm; /* F18h */
PVOID TlsSlots[0x40]; /* E10h */ PVOID ReservedForNtRpc; /* F1Ch */
LIST_ENTRY TlsLinks; /* F10h */ PVOID DbgSsReserved[0x2]; /* F20h */
PVOID Vdm; /* F18h */ ULONG HardErrorDisabled; /* F28h */
PVOID ReservedForNtRpc; /* F1Ch */ PVOID Instrumentation[14]; /* F2Ch */
PVOID DbgSsReserved[0x2]; /* F20h */ PVOID SubProcessTag; /* F64h */
ULONG HardErrorDisabled; /* F28h */ PVOID EtwTraceData; /* F68h */
PVOID Instrumentation[0x10]; /* F2Ch */ PVOID WinSockData; /* F6Ch */
PVOID WinSockData; /* F6Ch */ ULONG GdiBatchCount; /* F70h */
ULONG GdiBatchCount; /* F70h */ BOOLEAN InDbgPrint; /* F74h */
USHORT _Spare2; /* F74h */ BOOLEAN FreeStackOnTermination; /* F75h */
BOOLEAN IsFiber; /* F76h */ BOOLEAN HasFiberData; /* F76h */
UCHAR Spare3; /* F77h */ UCHAR IdealProcessor; /* F77h */
ULONG _Spare4; /* F78h */ ULONG GuaranteedStackBytes; /* F78h */
ULONG _Spare5; /* F7Ch */ PVOID ReservedForPerf; /* F7Ch */
PVOID ReservedForOle; /* F80h */ PVOID ReservedForOle; /* F80h */
ULONG WaitingOnLoaderLock; /* F84h */ ULONG WaitingOnLoaderLock; /* F84h */
ULONG _Unknown[11]; /* F88h */ ULONG SparePointer1; /* F88h */
PVOID FlsSlots; /* FB4h */ ULONG SoftPatchPtr1; /* F8Ch */
PVOID WineDebugInfo; /* Needed for WINE DLL's */ ULONG SoftPatchPtr2; /* F90h */
PVOID *TlsExpansionSlots; /* F94h */
ULONG ImpersionationLocale; /* F98h */
ULONG IsImpersonating; /* F9Ch */
PVOID NlsCache; /* FA0h */
PVOID pShimData; /* FA4h */
ULONG HeapVirualAffinity; /* FA8h */
PVOID CurrentTransactionHandle; /* FACh */
PTEB_ACTIVE_FRAME ActiveFrame; /* FB0h */
PVOID FlsData; /* FB4h */
UCHAR SafeThunkCall; /* FB8h */
UCHAR BooleanSpare[3]; /* FB9h */
/* FIXME: Needed for WINE DLL's */
PVOID WineDebugInfo; /* FBCh */
} TEB, *PTEB; } TEB, *PTEB;
/* KERNEL MODE ONLY **********************************************************/ /* KERNEL MODE ONLY **********************************************************/

View file

@ -1049,7 +1049,7 @@ RtlCreateUserProcess(
IN BOOLEAN CurrentDirectory, IN BOOLEAN CurrentDirectory,
IN HANDLE DebugPort OPTIONAL, IN HANDLE DebugPort OPTIONAL,
IN HANDLE ExceptionPort OPTIONAL, IN HANDLE ExceptionPort OPTIONAL,
OUT PRTL_PROCESS_INFO ProcessInfo OUT PRTL_USER_PROCESS_INFORMATION ProcessInfo
); );
NTSTATUS NTSTATUS
@ -1059,8 +1059,8 @@ RtlCreateUserThread(
IN PSECURITY_DESCRIPTOR SecurityDescriptor, IN PSECURITY_DESCRIPTOR SecurityDescriptor,
IN BOOLEAN CreateSuspended, IN BOOLEAN CreateSuspended,
IN LONG StackZeroBits, IN LONG StackZeroBits,
IN OUT PULONG StackReserve, IN ULONG StackReserve,
IN OUT PULONG StackCommit, IN ULONG StackCommit,
IN PTHREAD_START_ROUTINE StartAddress, IN PTHREAD_START_ROUTINE StartAddress,
IN PVOID Parameter, IN PVOID Parameter,
IN OUT PHANDLE ThreadHandle, IN OUT PHANDLE ThreadHandle,
@ -1075,11 +1075,11 @@ NTSTATUS
STDCALL STDCALL
RtlDestroyProcessParameters(IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters); RtlDestroyProcessParameters(IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
NTSTATUS VOID
STDCALL STDCALL
RtlExitUserThread(NTSTATUS Status); RtlExitUserThread(NTSTATUS Status);
NTSTATUS VOID
STDCALL STDCALL
RtlInitializeContext( RtlInitializeContext(
IN HANDLE ProcessHandle, IN HANDLE ProcessHandle,

View file

@ -17,9 +17,17 @@
/* CONSTANTS *****************************************************************/ /* CONSTANTS *****************************************************************/
#define MAXIMUM_LEADBYTES 12 #define MAXIMUM_LEADBYTES 12
#define PPF_NORMALIZED (1) #define PPF_NORMALIZED 0x01
#define PPF_PROFILE_USER 0x02
#define PPF_PROFILE_SERVER 0x04
#define PPF_PROFILE_KERNEL 0x08
#define PEB_BASE (0x7FFDF000) #define PPF_RESERVE_1MB 0x20
#define PPF_DISABLE_HEAP_CHECKS 0x100
#define PPF_PROCESS_OR_1 0x200
#define PPF_PROCESS_OR_2 0x400
#define PEB_BASE (0x7FFDF000)
#define EXCEPTION_CONTINUE_SEARCH 0 #define EXCEPTION_CONTINUE_SEARCH 0
#define EXCEPTION_EXECUTE_HANDLER 1 #define EXCEPTION_EXECUTE_HANDLER 1
@ -218,6 +226,12 @@ typedef struct _MODULE_INFORMATION
ULONG ModuleCount; ULONG ModuleCount;
DEBUG_MODULE_INFORMATION ModuleEntry[1]; DEBUG_MODULE_INFORMATION ModuleEntry[1];
} MODULE_INFORMATION, *PMODULE_INFORMATION; } MODULE_INFORMATION, *PMODULE_INFORMATION;
typedef struct _RTL_HEAP_DEFINITION
{
ULONG Length;
ULONG Unknown[11];
} RTL_HEAP_DEFINITION, *PRTL_HEAP_DEFINITION;
/* END REVIEW AREA */ /* END REVIEW AREA */
typedef struct _EXCEPTION_REGISTRATION typedef struct _EXCEPTION_REGISTRATION
@ -229,6 +243,12 @@ typedef struct _EXCEPTION_REGISTRATION
typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD; typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD;
typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD; typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD;
typedef struct _CURDIR
{
UNICODE_STRING DosPath;
HANDLE Handle;
} CURDIR, *PCURDIR;
typedef struct RTL_DRIVE_LETTER_CURDIR typedef struct RTL_DRIVE_LETTER_CURDIR
{ {
USHORT Flags; USHORT Flags;
@ -237,12 +257,6 @@ typedef struct RTL_DRIVE_LETTER_CURDIR
UNICODE_STRING DosPath; UNICODE_STRING DosPath;
} RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR; } RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
typedef struct _RTL_HEAP_DEFINITION
{
ULONG Length;
ULONG Unknown[11];
} RTL_HEAP_DEFINITION, *PRTL_HEAP_DEFINITION;
typedef struct _RTL_RANGE_LIST typedef struct _RTL_RANGE_LIST
{ {
LIST_ENTRY ListHead; LIST_ENTRY ListHead;
@ -323,44 +337,44 @@ typedef struct _NLS_FILE_HEADER
typedef struct _RTL_USER_PROCESS_PARAMETERS typedef struct _RTL_USER_PROCESS_PARAMETERS
{ {
ULONG AllocationSize; ULONG MaximumLength;
ULONG Size; ULONG Length;
ULONG Flags; ULONG Flags;
ULONG DebugFlags; ULONG DebugFlags;
HANDLE hConsole; HANDLE ConsoleHandle;
ULONG ProcessGroup; ULONG ConsoleFlags;
HANDLE hStdInput; HANDLE StandardInput;
HANDLE hStdOutput; HANDLE StandardOutput;
HANDLE hStdError; HANDLE StandardError;
UNICODE_STRING CurrentDirectoryName; CURDIR CurrentDirectory;
HANDLE CurrentDirectoryHandle; UNICODE_STRING DllPath;
UNICODE_STRING DllPath; UNICODE_STRING ImagePathName;
UNICODE_STRING ImagePathName; UNICODE_STRING CommandLine;
UNICODE_STRING CommandLine; PWSTR Environment;
PWSTR Environment; ULONG StartingX;
ULONG dwX; ULONG StartingY;
ULONG dwY; ULONG CountX;
ULONG dwXSize; ULONG CountY;
ULONG dwYSize; ULONG CountCharsX;
ULONG dwXCountChars; ULONG CountCharsY;
ULONG dwYCountChars; ULONG FillAttribute;;
ULONG dwFillAttribute; ULONG WindowFlags;
ULONG dwFlags; ULONG ShowWindowFlags;
ULONG wShowWindow; UNICODE_STRING WindowTitle;
UNICODE_STRING WindowTitle; UNICODE_STRING DesktopInfo;
UNICODE_STRING DesktopInfo; UNICODE_STRING ShellInfo;
UNICODE_STRING ShellInfo; UNICODE_STRING RuntimeData;
UNICODE_STRING RuntimeInfo; RTL_DRIVE_LETTER_CURDIR CurrentDirectories[32];
} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS; } RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
typedef struct _RTL_PROCESS_INFO typedef struct _RTL_USER_PROCESS_INFORMATION
{ {
ULONG Size; ULONG Size;
HANDLE ProcessHandle; HANDLE ProcessHandle;
HANDLE ThreadHandle; HANDLE ThreadHandle;
CLIENT_ID ClientId; CLIENT_ID ClientId;
SECTION_IMAGE_INFORMATION ImageInfo; SECTION_IMAGE_INFORMATION ImageInformation;
} RTL_PROCESS_INFO, *PRTL_PROCESS_INFO; } RTL_USER_PROCESS_INFORMATION, *PRTL_USER_PROCESS_INFORMATION;
typedef struct _RTL_ATOM_TABLE_ENTRY typedef struct _RTL_ATOM_TABLE_ENTRY
{ {

View file

@ -122,7 +122,7 @@ DbgUiWaitStateChange(
ULONG Unknown2 ULONG Unknown2
); );
NTSTATUS VOID
STDCALL STDCALL
DbgUiRemoteBreakin(VOID); DbgUiRemoteBreakin(VOID);

View file

@ -3693,6 +3693,7 @@ NtTerminateThread(
IN HANDLE ThreadHandle, IN HANDLE ThreadHandle,
IN NTSTATUS ExitStatus IN NTSTATUS ExitStatus
); );
NTSTATUS NTSTATUS
STDCALL STDCALL
ZwTerminateThread( ZwTerminateThread(

View file

@ -427,19 +427,22 @@ typedef struct _SECTION_BASIC_INFORMATION
/* Class 1 */ /* Class 1 */
typedef struct _SECTION_IMAGE_INFORMATION typedef struct _SECTION_IMAGE_INFORMATION
{ {
ULONG EntryPoint; PVOID TransferAddress;
ULONG Unknown1; ULONG ZeroBits;
ULONG_PTR StackReserve; ULONG MaximumStackSize;
ULONG_PTR StackCommit; ULONG CommittedStackSize;
ULONG Subsystem; ULONG SubsystemType;
USHORT MinorSubsystemVersion; USHORT SubSystemMinorVersion;
USHORT MajorSubsystemVersion; USHORT SubSystemMajorVersion;
ULONG Unknown2; ULONG GpValue;
ULONG Characteristics; USHORT ImageCharacteristics;
USHORT ImageNumber; USHORT DllChracteristics;
BOOLEAN Executable; USHORT Machine;
UCHAR Unknown3; UCHAR ImageContainsCode;
ULONG Unknown4[3]; UCHAR Spare1;
ULONG LoaderFlags;
ULONG ImageFileSIze;
ULONG Reserved[1];
} SECTION_IMAGE_INFORMATION, *PSECTION_IMAGE_INFORMATION; } SECTION_IMAGE_INFORMATION, *PSECTION_IMAGE_INFORMATION;
/* /*

View file

@ -32,7 +32,7 @@ GdiProcessSetup (VOID)
hProcessHeap = GetProcessHeap(); hProcessHeap = GetProcessHeap();
/* map the gdi handle table to user space */ /* map the gdi handle table to user space */
GdiHandleTable = NtCurrentTeb()->Peb->GdiSharedHandleTable; GdiHandleTable = NtCurrentTeb()->ProcessEnvironmentBlock->GdiSharedHandleTable;
CurrentProcessId = NtCurrentTeb()->Cid.UniqueProcess; CurrentProcessId = NtCurrentTeb()->Cid.UniqueProcess;
} }

View file

@ -534,15 +534,15 @@ GetFileType(HANDLE hFile)
switch ((ULONG)hFile) switch ((ULONG)hFile)
{ {
case STD_INPUT_HANDLE: case STD_INPUT_HANDLE:
hFile = NtCurrentPeb()->ProcessParameters->hStdInput; hFile = NtCurrentPeb()->ProcessParameters->StandardInput;
break; break;
case STD_OUTPUT_HANDLE: case STD_OUTPUT_HANDLE:
hFile = NtCurrentPeb()->ProcessParameters->hStdOutput; hFile = NtCurrentPeb()->ProcessParameters->StandardOutput;
break; break;
case STD_ERROR_HANDLE: case STD_ERROR_HANDLE:
hFile = NtCurrentPeb()->ProcessParameters->hStdError; hFile = NtCurrentPeb()->ProcessParameters->StandardError;
break; break;
} }

View file

@ -23,6 +23,9 @@
#define FIELD_OFFSET(type,fld) ((LONG)&(((type *)0)->fld)) #define FIELD_OFFSET(type,fld) ((LONG)&(((type *)0)->fld))
#endif #endif
#define IsConsoleHandle(h) \
((((ULONG)h) & 0x10000003) == 0x3) ? TRUE : FALSE
#define SetLastErrorByStatus(__S__) \ #define SetLastErrorByStatus(__S__) \
((void)SetLastError(RtlNtStatusToDosError(__S__))) ((void)SetLastError(RtlNtStatusToDosError(__S__)))
@ -47,8 +50,6 @@ extern LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter;
/* FUNCTION PROTOTYPES *******************************************************/ /* FUNCTION PROTOTYPES *******************************************************/
BOOL STDCALL IsConsoleHandle(HANDLE Handle);
BOOL STDCALL VerifyConsoleIoHandle(HANDLE Handle); BOOL STDCALL VerifyConsoleIoHandle(HANDLE Handle);
BOOL STDCALL CloseConsoleHandle(HANDLE Handle); BOOL STDCALL CloseConsoleHandle(HANDLE Handle);

View file

@ -91,7 +91,7 @@ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
RtlEnterCriticalSection(&ConsoleLock); RtlEnterCriticalSection(&ConsoleLock);
if(!(nCode == CTRL_C_EVENT && if(!(nCode == CTRL_C_EVENT &&
NtCurrentPeb()->ProcessParameters->ProcessGroup & 1)) NtCurrentPeb()->ProcessParameters->ConsoleFlags & 1))
{ {
for(i = NrCtrlHandlers; i > 0; -- i) for(i = NrCtrlHandlers; i > 0; -- i)
if(CtrlHandlers[i - 1](nCode)) break; if(CtrlHandlers[i - 1](nCode)) break;
@ -110,7 +110,7 @@ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
RtlEnterCriticalSection(&ConsoleLock); RtlEnterCriticalSection(&ConsoleLock);
if(!(nCode == CTRL_C_EVENT && if(!(nCode == CTRL_C_EVENT &&
NtCurrentPeb()->ProcessParameters->ProcessGroup & 1)) NtCurrentPeb()->ProcessParameters->ConsoleFlags & 1))
{ {
i = NrCtrlHandlers; i = NrCtrlHandlers;
while(i > 0) while(i > 0)
@ -1012,21 +1012,6 @@ CloseConsoleHandle(HANDLE Handle)
return TRUE; return TRUE;
} }
/*
* internal function
*/
BOOL STDCALL
IsConsoleHandle(HANDLE Handle)
{
if ((((ULONG)Handle) & 0x10000003) == 0x3)
{
return(TRUE);
}
return(FALSE);
}
/* /*
* @implemented * @implemented
*/ */
@ -1047,13 +1032,13 @@ GetStdHandle(DWORD nStdHandle)
switch (nStdHandle) switch (nStdHandle)
{ {
case STD_INPUT_HANDLE: case STD_INPUT_HANDLE:
return Ppb->hStdInput; return Ppb->StandardInput;
case STD_OUTPUT_HANDLE: case STD_OUTPUT_HANDLE:
return Ppb->hStdOutput; return Ppb->StandardOutput;
case STD_ERROR_HANDLE: case STD_ERROR_HANDLE:
return Ppb->hStdError; return Ppb->StandardError;
} }
SetLastError (ERROR_INVALID_PARAMETER); SetLastError (ERROR_INVALID_PARAMETER);
@ -1085,15 +1070,15 @@ SetStdHandle(DWORD nStdHandle,
switch (nStdHandle) switch (nStdHandle)
{ {
case STD_INPUT_HANDLE: case STD_INPUT_HANDLE:
Ppb->hStdInput = hHandle; Ppb->StandardInput = hHandle;
return TRUE; return TRUE;
case STD_OUTPUT_HANDLE: case STD_OUTPUT_HANDLE:
Ppb->hStdOutput = hHandle; Ppb->StandardOutput = hHandle;
return TRUE; return TRUE;
case STD_ERROR_HANDLE: case STD_ERROR_HANDLE:
Ppb->hStdError = hHandle; Ppb->StandardError = hHandle;
return TRUE; return TRUE;
} }
@ -1347,7 +1332,7 @@ BOOL STDCALL AllocConsole(VOID)
NTSTATUS Status; NTSTATUS Status;
HANDLE hStdError; HANDLE hStdError;
if(NtCurrentPeb()->ProcessParameters->hConsole) if(NtCurrentPeb()->ProcessParameters->ConsoleHandle)
{ {
DPRINT("AllocConsole: Allocate duplicate console to the same Process\n"); DPRINT("AllocConsole: Allocate duplicate console to the same Process\n");
SetLastErrorByStatus (STATUS_OBJECT_NAME_EXISTS); SetLastErrorByStatus (STATUS_OBJECT_NAME_EXISTS);
@ -1363,7 +1348,7 @@ BOOL STDCALL AllocConsole(VOID)
SetLastErrorByStatus ( Status ); SetLastErrorByStatus ( Status );
return FALSE; return FALSE;
} }
NtCurrentPeb()->ProcessParameters->hConsole = Request.Data.AllocConsoleRequest.Console; NtCurrentPeb()->ProcessParameters->ConsoleHandle = Request.Data.AllocConsoleRequest.Console;
SetStdHandle( STD_INPUT_HANDLE, Request.Data.AllocConsoleRequest.InputHandle ); SetStdHandle( STD_INPUT_HANDLE, Request.Data.AllocConsoleRequest.InputHandle );
SetStdHandle( STD_OUTPUT_HANDLE, Request.Data.AllocConsoleRequest.OutputHandle ); SetStdHandle( STD_OUTPUT_HANDLE, Request.Data.AllocConsoleRequest.OutputHandle );
hStdError = DuplicateConsoleHandle(Request.Data.AllocConsoleRequest.OutputHandle, hStdError = DuplicateConsoleHandle(Request.Data.AllocConsoleRequest.OutputHandle,

View file

@ -43,13 +43,13 @@ GetHandleInformation (HANDLE hObject,
switch ((ULONG)hObject) switch ((ULONG)hObject)
{ {
case STD_INPUT_HANDLE: case STD_INPUT_HANDLE:
hObject = Ppb->hStdInput; hObject = Ppb->StandardInput;
break; break;
case STD_OUTPUT_HANDLE: case STD_OUTPUT_HANDLE:
hObject = Ppb->hStdOutput; hObject = Ppb->StandardOutput;
break; break;
case STD_ERROR_HANDLE: case STD_ERROR_HANDLE:
hObject = Ppb->hStdError; hObject = Ppb->StandardError;
break; break;
} }
@ -95,13 +95,13 @@ SetHandleInformation (HANDLE hObject,
switch ((ULONG)hObject) switch ((ULONG)hObject)
{ {
case STD_INPUT_HANDLE: case STD_INPUT_HANDLE:
hObject = Ppb->hStdInput; hObject = Ppb->StandardInput;
break; break;
case STD_OUTPUT_HANDLE: case STD_OUTPUT_HANDLE:
hObject = Ppb->hStdOutput; hObject = Ppb->StandardOutput;
break; break;
case STD_ERROR_HANDLE: case STD_ERROR_HANDLE:
hObject = Ppb->hStdError; hObject = Ppb->StandardError;
break; break;
} }
@ -153,13 +153,13 @@ BOOL STDCALL CloseHandle(HANDLE hObject)
switch ((ULONG)hObject) switch ((ULONG)hObject)
{ {
case STD_INPUT_HANDLE: case STD_INPUT_HANDLE:
hObject = Ppb->hStdInput; hObject = Ppb->StandardInput;
break; break;
case STD_OUTPUT_HANDLE: case STD_OUTPUT_HANDLE:
hObject = Ppb->hStdOutput; hObject = Ppb->StandardOutput;
break; break;
case STD_ERROR_HANDLE: case STD_ERROR_HANDLE:
hObject = Ppb->hStdError; hObject = Ppb->StandardError;
break; break;
} }
@ -198,13 +198,13 @@ BOOL STDCALL DuplicateHandle(HANDLE hSourceProcessHandle,
switch ((ULONG)hSourceHandle) switch ((ULONG)hSourceHandle)
{ {
case STD_INPUT_HANDLE: case STD_INPUT_HANDLE:
hSourceHandle = Ppb->hStdInput; hSourceHandle = Ppb->StandardInput;
break; break;
case STD_OUTPUT_HANDLE: case STD_OUTPUT_HANDLE:
hSourceHandle = Ppb->hStdOutput; hSourceHandle = Ppb->StandardOutput;
break; break;
case STD_ERROR_HANDLE: case STD_ERROR_HANDLE:
hSourceHandle = Ppb->hStdError; hSourceHandle = Ppb->StandardError;
break; break;
} }

View file

@ -43,7 +43,7 @@ GetDllLoadPath(LPCWSTR lpModule)
} }
else else
{ {
ModuleName = NtCurrentTeb()->Peb->ProcessParameters->ImagePathName; ModuleName = NtCurrentTeb()->ProcessEnvironmentBlock->ProcessParameters->ImagePathName;
lpModule = ModuleName.Buffer; lpModule = ModuleName.Buffer;
lpModuleEnd = lpModule + (ModuleName.Length / sizeof(WCHAR)); lpModuleEnd = lpModule + (ModuleName.Length / sizeof(WCHAR));
} }

View file

@ -101,7 +101,7 @@ NlsInit()
/* Setup ANSI code page. */ /* Setup ANSI code page. */
AnsiCodePage.CodePage = CP_ACP; AnsiCodePage.CodePage = CP_ACP;
AnsiCodePage.SectionHandle = NULL; AnsiCodePage.SectionHandle = NULL;
AnsiCodePage.SectionMapping = NtCurrentTeb()->Peb->AnsiCodePageData; AnsiCodePage.SectionMapping = NtCurrentTeb()->ProcessEnvironmentBlock->AnsiCodePageData;
RtlInitCodePageTable((PUSHORT)AnsiCodePage.SectionMapping, RtlInitCodePageTable((PUSHORT)AnsiCodePage.SectionMapping,
&AnsiCodePage.CodePageTable); &AnsiCodePage.CodePageTable);
InsertTailList(&CodePageListHead, &AnsiCodePage.Entry); InsertTailList(&CodePageListHead, &AnsiCodePage.Entry);
@ -109,7 +109,7 @@ NlsInit()
/* Setup OEM code page. */ /* Setup OEM code page. */
OemCodePage.CodePage = CP_OEMCP; OemCodePage.CodePage = CP_OEMCP;
OemCodePage.SectionHandle = NULL; OemCodePage.SectionHandle = NULL;
OemCodePage.SectionMapping = NtCurrentTeb()->Peb->OemCodePageData; OemCodePage.SectionMapping = NtCurrentTeb()->ProcessEnvironmentBlock->OemCodePageData;
RtlInitCodePageTable((PUSHORT)OemCodePage.SectionMapping, RtlInitCodePageTable((PUSHORT)OemCodePage.SectionMapping,
&OemCodePage.CodePageTable); &OemCodePage.CodePageTable);
InsertTailList(&CodePageListHead, &OemCodePage.Entry); InsertTailList(&CodePageListHead, &OemCodePage.Entry);

View file

@ -16,7 +16,7 @@
/* FIXME */ /* FIXME */
#include <rosrtl/thread.h> #include <rosrtl/thread.h>
#define NDEBUG //#define NDEBUG
#include "../include/debug.h" #include "../include/debug.h"
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
@ -339,7 +339,7 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle,
RtlRosR32AttribsToNativeAttribs(&oaThreadAttribs, lpThreadAttributes); RtlRosR32AttribsToNativeAttribs(&oaThreadAttribs, lpThreadAttributes);
/* native image */ /* native image */
if(Sii->Subsystem != IMAGE_SUBSYSTEM_NATIVE) if(Sii->SubsystemType != IMAGE_SUBSYSTEM_NATIVE)
{ {
pTrueStartAddress = (PVOID)BaseProcessStart; pTrueStartAddress = (PVOID)BaseProcessStart;
} }
@ -368,8 +368,8 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle,
&oaThreadAttribs, &oaThreadAttribs,
dwCreationFlags & CREATE_SUSPENDED, dwCreationFlags & CREATE_SUSPENDED,
0, 0,
Sii->StackReserve, Sii->MaximumStackSize,
Sii->StackCommit, Sii->CommittedStackSize,
pTrueStartAddress, pTrueStartAddress,
&hThread, &hThread,
&cidClientId, &cidClientId,
@ -382,8 +382,8 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle,
&oaThreadAttribs, &oaThreadAttribs,
dwCreationFlags & CREATE_SUSPENDED, dwCreationFlags & CREATE_SUSPENDED,
0, 0,
&(Sii->StackReserve), &(Sii->MaximumStackSize),
&(Sii->StackCommit), &(Sii->CommittedStackSize),
pTrueStartAddress, pTrueStartAddress,
&hThread, &hThread,
&cidClientId, &cidClientId,
@ -401,8 +401,8 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle,
"StackCommit %p\n" "StackCommit %p\n"
"ThreadHandle %p\n" "ThreadHandle %p\n"
"ClientId.UniqueThread %p\n", "ClientId.UniqueThread %p\n",
Sii->StackReserve, Sii->MaximumStackSize,
Sii->StackCommit, Sii->CommittedStackSize,
hThread, hThread,
cidClientId.UniqueThread); cidClientId.UniqueThread);
@ -550,7 +550,7 @@ static NTSTATUS KlInitPeb(HANDLE ProcessHandle,
/* create the PPB */ /* create the PPB */
PpbBase = NULL; PpbBase = NULL;
PpbSize = Ppb->AllocationSize; PpbSize = Ppb->MaximumLength;
Status = NtAllocateVirtualMemory(ProcessHandle, Status = NtAllocateVirtualMemory(ProcessHandle,
&PpbBase, &PpbBase,
0, 0,
@ -566,7 +566,7 @@ static NTSTATUS KlInitPeb(HANDLE ProcessHandle,
NtWriteVirtualMemory(ProcessHandle, NtWriteVirtualMemory(ProcessHandle,
PpbBase, PpbBase,
Ppb, Ppb,
Ppb->AllocationSize, Ppb->MaximumLength,
&BytesWritten); &BytesWritten);
/* write pointer to environment */ /* write pointer to environment */
@ -996,7 +996,7 @@ CreateProcessW(LPCWSTR lpApplicationName,
return FALSE; return FALSE;
} }
if (0 != (Sii.Characteristics & IMAGE_FILE_DLL)) if (0 != (Sii.ImageCharacteristics & IMAGE_FILE_DLL))
{ {
NtClose(hSection); NtClose(hSection);
DPRINT("Can't execute a DLL\n"); DPRINT("Can't execute a DLL\n");
@ -1004,11 +1004,11 @@ CreateProcessW(LPCWSTR lpApplicationName,
return FALSE; return FALSE;
} }
if (IMAGE_SUBSYSTEM_WINDOWS_GUI != Sii.Subsystem if (IMAGE_SUBSYSTEM_WINDOWS_GUI != Sii.SubsystemType
&& IMAGE_SUBSYSTEM_WINDOWS_CUI != Sii.Subsystem) && IMAGE_SUBSYSTEM_WINDOWS_CUI != Sii.SubsystemType)
{ {
NtClose(hSection); NtClose(hSection);
DPRINT("Invalid subsystem %d\n", Sii.Subsystem); DPRINT("Invalid subsystem %d\n", Sii.SubsystemType);
SetLastError(ERROR_CHILD_NOT_COMPLETE); SetLastError(ERROR_CHILD_NOT_COMPLETE);
return FALSE; return FALSE;
} }
@ -1124,12 +1124,12 @@ CreateProcessW(LPCWSTR lpApplicationName,
/* /*
* Translate some handles for the new process * Translate some handles for the new process
*/ */
if (Ppb->CurrentDirectoryHandle) if (Ppb->CurrentDirectory.Handle)
{ {
Status = NtDuplicateObject (NtCurrentProcess(), Status = NtDuplicateObject (NtCurrentProcess(),
Ppb->CurrentDirectoryHandle, Ppb->CurrentDirectory.Handle,
hProcess, hProcess,
&Ppb->CurrentDirectoryHandle, &Ppb->CurrentDirectory.Handle,
0, 0,
TRUE, TRUE,
DUPLICATE_SAME_ACCESS); DUPLICATE_SAME_ACCESS);
@ -1159,15 +1159,15 @@ CreateProcessW(LPCWSTR lpApplicationName,
Request = CREATE_PROCESS; Request = CREATE_PROCESS;
CsrRequest.Data.CreateProcessRequest.NewProcessId = CsrRequest.Data.CreateProcessRequest.NewProcessId =
(HANDLE)ProcessBasicInfo.UniqueProcessId; (HANDLE)ProcessBasicInfo.UniqueProcessId;
if (Sii.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) if (Sii.SubsystemType == IMAGE_SUBSYSTEM_WINDOWS_GUI)
{ {
/* Do not create a console for GUI applications */ /* Do not create a console for GUI applications */
dwCreationFlags &= ~CREATE_NEW_CONSOLE; dwCreationFlags &= ~CREATE_NEW_CONSOLE;
dwCreationFlags |= DETACHED_PROCESS; dwCreationFlags |= DETACHED_PROCESS;
} }
else if (Sii.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI) else if (Sii.SubsystemType == IMAGE_SUBSYSTEM_WINDOWS_CUI)
{ {
if (NULL == Ppb->hConsole) if (NULL == Ppb->ConsoleHandle)
{ {
dwCreationFlags |= CREATE_NEW_CONSOLE; dwCreationFlags |= CREATE_NEW_CONSOLE;
} }
@ -1183,7 +1183,7 @@ CreateProcessW(LPCWSTR lpApplicationName,
DbgPrint("Failed to tell csrss about new process. Expect trouble.\n"); DbgPrint("Failed to tell csrss about new process. Expect trouble.\n");
} }
Ppb->hConsole = CsrRequest.Data.CreateProcessRequest.Console; Ppb->ConsoleHandle = CsrRequest.Data.CreateProcessRequest.Console;
InputSet = FALSE; InputSet = FALSE;
OutputSet = FALSE; OutputSet = FALSE;
@ -1196,19 +1196,19 @@ CreateProcessW(LPCWSTR lpApplicationName,
{ {
if (lpStartupInfo->hStdInput) if (lpStartupInfo->hStdInput)
{ {
Ppb->hStdInput = lpStartupInfo->hStdInput; Ppb->StandardInput = lpStartupInfo->hStdInput;
InputSet = TRUE; InputSet = TRUE;
InputDup = TRUE; InputDup = TRUE;
} }
if (lpStartupInfo->hStdOutput) if (lpStartupInfo->hStdOutput)
{ {
Ppb->hStdOutput = lpStartupInfo->hStdOutput; Ppb->StandardOutput = lpStartupInfo->hStdOutput;
OutputSet = TRUE; OutputSet = TRUE;
OutputDup = TRUE; OutputDup = TRUE;
} }
if (lpStartupInfo->hStdError) if (lpStartupInfo->hStdError)
{ {
Ppb->hStdError = lpStartupInfo->hStdError; Ppb->StandardError = lpStartupInfo->hStdError;
ErrorSet = TRUE; ErrorSet = TRUE;
ErrorDup = TRUE; ErrorDup = TRUE;
} }
@ -1221,19 +1221,19 @@ CreateProcessW(LPCWSTR lpApplicationName,
{ {
if (! InputSet) if (! InputSet)
{ {
Ppb->hStdInput = CsrRequest.Data.CreateProcessRequest.InputHandle; Ppb->StandardInput = CsrRequest.Data.CreateProcessRequest.InputHandle;
InputSet = TRUE; InputSet = TRUE;
InputDup = FALSE; InputDup = FALSE;
} }
if (! OutputSet) if (! OutputSet)
{ {
Ppb->hStdOutput = CsrRequest.Data.CreateProcessRequest.OutputHandle; Ppb->StandardOutput = CsrRequest.Data.CreateProcessRequest.OutputHandle;
OutputSet = TRUE; OutputSet = TRUE;
OutputDup = FALSE; OutputDup = FALSE;
} }
if (! ErrorSet) if (! ErrorSet)
{ {
Ppb->hStdError = CsrRequest.Data.CreateProcessRequest.OutputHandle; Ppb->StandardError = CsrRequest.Data.CreateProcessRequest.OutputHandle;
ErrorSet = TRUE; ErrorSet = TRUE;
ErrorDup = FALSE; ErrorDup = FALSE;
} }
@ -1242,34 +1242,34 @@ CreateProcessW(LPCWSTR lpApplicationName,
/* Use existing handles otherwise */ /* Use existing handles otherwise */
if (! InputSet) if (! InputSet)
{ {
Ppb->hStdInput = NtCurrentPeb()->ProcessParameters->hStdInput; Ppb->StandardInput = NtCurrentPeb()->ProcessParameters->StandardInput;
InputDup = TRUE; InputDup = TRUE;
} }
if (! OutputSet) if (! OutputSet)
{ {
Ppb->hStdOutput = NtCurrentPeb()->ProcessParameters->hStdOutput; Ppb->StandardOutput = NtCurrentPeb()->ProcessParameters->StandardOutput;
OutputDup = TRUE; OutputDup = TRUE;
} }
if (! ErrorSet) if (! ErrorSet)
{ {
Ppb->hStdError = NtCurrentPeb()->ProcessParameters->hStdError; Ppb->StandardError = NtCurrentPeb()->ProcessParameters->StandardError;
ErrorDup = TRUE; ErrorDup = TRUE;
} }
/* Now duplicate handles if required */ /* Now duplicate handles if required */
if (InputDup && Ppb->hStdInput != NULL) if (InputDup && Ppb->StandardInput != NULL)
{ {
if (IsConsoleHandle(Ppb->hStdInput)) if (IsConsoleHandle(Ppb->StandardInput))
{ {
Ppb->hStdInput = CsrRequest.Data.CreateProcessRequest.InputHandle; Ppb->StandardInput = CsrRequest.Data.CreateProcessRequest.InputHandle;
} }
else else
{ {
DPRINT("Duplicate input handle\n"); DPRINT("Duplicate input handle\n");
Status = NtDuplicateObject (NtCurrentProcess(), Status = NtDuplicateObject (NtCurrentProcess(),
Ppb->hStdInput, Ppb->StandardInput,
hProcess, hProcess,
&Ppb->hStdInput, &Ppb->StandardInput,
0, 0,
TRUE, TRUE,
DUPLICATE_SAME_ACCESS); DUPLICATE_SAME_ACCESS);
@ -1280,19 +1280,19 @@ CreateProcessW(LPCWSTR lpApplicationName,
} }
} }
if (OutputDup && Ppb->hStdOutput != NULL) if (OutputDup && Ppb->StandardOutput != NULL)
{ {
if (IsConsoleHandle(Ppb->hStdOutput)) if (IsConsoleHandle(Ppb->StandardOutput))
{ {
Ppb->hStdOutput = CsrRequest.Data.CreateProcessRequest.OutputHandle; Ppb->StandardOutput = CsrRequest.Data.CreateProcessRequest.OutputHandle;
} }
else else
{ {
DPRINT("Duplicate output handle\n"); DPRINT("Duplicate output handle\n");
Status = NtDuplicateObject (NtCurrentProcess(), Status = NtDuplicateObject (NtCurrentProcess(),
Ppb->hStdOutput, Ppb->StandardOutput,
hProcess, hProcess,
&Ppb->hStdOutput, &Ppb->StandardOutput,
0, 0,
TRUE, TRUE,
DUPLICATE_SAME_ACCESS); DUPLICATE_SAME_ACCESS);
@ -1303,9 +1303,9 @@ CreateProcessW(LPCWSTR lpApplicationName,
} }
} }
if (ErrorDup && Ppb->hStdError != NULL) if (ErrorDup && Ppb->StandardError != NULL)
{ {
if (IsConsoleHandle(Ppb->hStdError)) if (IsConsoleHandle(Ppb->StandardError))
{ {
Request = DUPLICATE_HANDLE; Request = DUPLICATE_HANDLE;
CsrRequest.Data.DuplicateHandleRequest.ProcessId = (HANDLE)ProcessBasicInfo.UniqueProcessId; CsrRequest.Data.DuplicateHandleRequest.ProcessId = (HANDLE)ProcessBasicInfo.UniqueProcessId;
@ -1316,20 +1316,20 @@ CreateProcessW(LPCWSTR lpApplicationName,
sizeof(CSR_API_MESSAGE)); sizeof(CSR_API_MESSAGE));
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status)) if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrRequest.Status))
{ {
Ppb->hStdError = INVALID_HANDLE_VALUE; Ppb->StandardError = INVALID_HANDLE_VALUE;
} }
else else
{ {
Ppb->hStdError = CsrRequest.Data.DuplicateHandleRequest.Handle; Ppb->StandardError = CsrRequest.Data.DuplicateHandleRequest.Handle;
} }
} }
else else
{ {
DPRINT("Duplicate error handle\n"); DPRINT("Duplicate error handle\n");
Status = NtDuplicateObject (NtCurrentProcess(), Status = NtDuplicateObject (NtCurrentProcess(),
Ppb->hStdError, Ppb->StandardError,
hProcess, hProcess,
&Ppb->hStdError, &Ppb->StandardError,
0, 0,
TRUE, TRUE,
DUPLICATE_SAME_ACCESS); DUPLICATE_SAME_ACCESS);
@ -1345,20 +1345,20 @@ CreateProcessW(LPCWSTR lpApplicationName,
*/ */
if (lpStartupInfo) if (lpStartupInfo)
{ {
Ppb->dwFlags = lpStartupInfo->dwFlags; Ppb->Flags = lpStartupInfo->dwFlags;
if (Ppb->dwFlags & STARTF_USESHOWWINDOW) if (Ppb->Flags & STARTF_USESHOWWINDOW)
{ {
Ppb->wShowWindow = lpStartupInfo->wShowWindow; Ppb->ShowWindowFlags = lpStartupInfo->wShowWindow;
} }
else else
{ {
Ppb->wShowWindow = SW_SHOWDEFAULT; Ppb->ShowWindowFlags = SW_SHOWDEFAULT;
} }
Ppb->dwX = lpStartupInfo->dwX; Ppb->StartingX = lpStartupInfo->dwX;
Ppb->dwY = lpStartupInfo->dwY; Ppb->StartingY = lpStartupInfo->dwY;
Ppb->dwXSize = lpStartupInfo->dwXSize; Ppb->CountX = lpStartupInfo->dwXSize;
Ppb->dwYSize = lpStartupInfo->dwYSize; Ppb->CountY = lpStartupInfo->dwYSize;
Ppb->dwFillAttribute = lpStartupInfo->dwFillAttribute; Ppb->FillAttribute = lpStartupInfo->dwFillAttribute;
} }
else else
{ {
@ -1370,7 +1370,7 @@ CreateProcessW(LPCWSTR lpApplicationName,
*/ */
DPRINT("Creating peb\n"); DPRINT("Creating peb\n");
KlInitPeb(hProcess, Ppb, &ImageBaseAddress, Sii.Subsystem); KlInitPeb(hProcess, Ppb, &ImageBaseAddress, Sii.SubsystemType);
RtlDestroyProcessParameters (Ppb); RtlDestroyProcessParameters (Ppb);
@ -1378,11 +1378,11 @@ CreateProcessW(LPCWSTR lpApplicationName,
* Create the thread for the kernel * Create the thread for the kernel
*/ */
DPRINT("Creating thread for process (EntryPoint = 0x%.08x)\n", DPRINT("Creating thread for process (EntryPoint = 0x%.08x)\n",
(PVOID)((ULONG_PTR)ImageBaseAddress + Sii.EntryPoint)); (PVOID)((ULONG_PTR)ImageBaseAddress + (ULONG_PTR)Sii.TransferAddress));
hThread = KlCreateFirstThread(hProcess, hThread = KlCreateFirstThread(hProcess,
lpThreadAttributes, lpThreadAttributes,
&Sii, &Sii,
(PVOID)((ULONG_PTR)ImageBaseAddress + Sii.EntryPoint), (PVOID)((ULONG_PTR)ImageBaseAddress + (ULONG_PTR)Sii.TransferAddress),
dwCreationFlags, dwCreationFlags,
&lpProcessInformation->dwThreadId); &lpProcessInformation->dwThreadId);
if (hThread == NULL) if (hThread == NULL)

View file

@ -452,22 +452,21 @@ GetStartupInfoW(LPSTARTUPINFOW lpStartupInfo)
lpStartupInfo->cb = sizeof(STARTUPINFOW); lpStartupInfo->cb = sizeof(STARTUPINFOW);
lpStartupInfo->lpDesktop = Params->DesktopInfo.Buffer; lpStartupInfo->lpDesktop = Params->DesktopInfo.Buffer;
lpStartupInfo->lpTitle = Params->WindowTitle.Buffer; lpStartupInfo->lpTitle = Params->WindowTitle.Buffer;
lpStartupInfo->dwX = Params->dwX; lpStartupInfo->dwX = Params->StartingX;
lpStartupInfo->dwY = Params->dwY; lpStartupInfo->dwY = Params->StartingY;
lpStartupInfo->dwXSize = Params->dwXSize; lpStartupInfo->dwXSize = Params->CountX;
lpStartupInfo->dwYSize = Params->dwYSize; lpStartupInfo->dwYSize = Params->CountY;
lpStartupInfo->dwXCountChars = Params->dwXCountChars; lpStartupInfo->dwXCountChars = Params->CountCharsX;
lpStartupInfo->dwYCountChars = Params->dwYCountChars; lpStartupInfo->dwYCountChars = Params->CountCharsY;
lpStartupInfo->dwFillAttribute = Params->dwFillAttribute; lpStartupInfo->dwFillAttribute = Params->FillAttribute;
lpStartupInfo->dwFlags = Params->dwFlags; lpStartupInfo->dwFlags = Params->WindowFlags;
lpStartupInfo->wShowWindow = Params->wShowWindow; lpStartupInfo->wShowWindow = Params->ShowWindowFlags;
lpStartupInfo->lpReserved = Params->ShellInfo.Buffer; lpStartupInfo->cbReserved2 = Params->RuntimeData.Length;
lpStartupInfo->cbReserved2 = Params->RuntimeInfo.Length; lpStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeData.Buffer;
lpStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeInfo.Buffer;
lpStartupInfo->hStdInput = Params->StandardInput;
lpStartupInfo->hStdInput = Params->hStdInput; lpStartupInfo->hStdOutput = Params->StandardOutput;
lpStartupInfo->hStdOutput = Params->hStdOutput; lpStartupInfo->hStdError = Params->StandardError;
lpStartupInfo->hStdError = Params->hStdError;
} }
@ -517,21 +516,21 @@ GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
TRUE); TRUE);
lpLocalStartupInfo->lpReserved = AnsiString.Buffer; lpLocalStartupInfo->lpReserved = AnsiString.Buffer;
lpLocalStartupInfo->dwX = Params->dwX; lpLocalStartupInfo->dwX = Params->StartingX;
lpLocalStartupInfo->dwY = Params->dwY; lpLocalStartupInfo->dwY = Params->StartingY;
lpLocalStartupInfo->dwXSize = Params->dwXSize; lpLocalStartupInfo->dwXSize = Params->CountX;
lpLocalStartupInfo->dwYSize = Params->dwYSize; lpLocalStartupInfo->dwYSize = Params->CountY;
lpLocalStartupInfo->dwXCountChars = Params->dwXCountChars; lpLocalStartupInfo->dwXCountChars = Params->CountCharsX;
lpLocalStartupInfo->dwYCountChars = Params->dwYCountChars; lpLocalStartupInfo->dwYCountChars = Params->CountCharsY;
lpLocalStartupInfo->dwFillAttribute = Params->dwFillAttribute; lpLocalStartupInfo->dwFillAttribute = Params->FillAttribute;
lpLocalStartupInfo->dwFlags = Params->dwFlags; lpLocalStartupInfo->dwFlags = Params->WindowFlags;
lpLocalStartupInfo->wShowWindow = Params->wShowWindow; lpLocalStartupInfo->wShowWindow = Params->ShowWindowFlags;
lpLocalStartupInfo->cbReserved2 = Params->RuntimeInfo.Length; lpLocalStartupInfo->cbReserved2 = Params->RuntimeData.Length;
lpLocalStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeInfo.Buffer; lpLocalStartupInfo->lpReserved2 = (LPBYTE)Params->RuntimeData.Buffer;
lpLocalStartupInfo->hStdInput = Params->hStdInput; lpLocalStartupInfo->hStdInput = Params->StandardInput;
lpLocalStartupInfo->hStdOutput = Params->hStdOutput; lpLocalStartupInfo->hStdOutput = Params->StandardOutput;
lpLocalStartupInfo->hStdError = Params->hStdError; lpLocalStartupInfo->hStdError = Params->StandardError;
} }
RtlReleasePebLock (); RtlReleasePebLock ();

View file

@ -51,15 +51,15 @@ WaitForSingleObjectEx(HANDLE hHandle,
switch ((ULONG)hHandle) switch ((ULONG)hHandle)
{ {
case STD_INPUT_HANDLE: case STD_INPUT_HANDLE:
hHandle = NtCurrentPeb()->ProcessParameters->hStdInput; hHandle = NtCurrentPeb()->ProcessParameters->StandardInput;
break; break;
case STD_OUTPUT_HANDLE: case STD_OUTPUT_HANDLE:
hHandle = NtCurrentPeb()->ProcessParameters->hStdOutput; hHandle = NtCurrentPeb()->ProcessParameters->StandardOutput;
break; break;
case STD_ERROR_HANDLE: case STD_ERROR_HANDLE:
hHandle = NtCurrentPeb()->ProcessParameters->hStdError; hHandle = NtCurrentPeb()->ProcessParameters->StandardError;
break; break;
} }
@ -159,15 +159,15 @@ WaitForMultipleObjectsEx(DWORD nCount,
switch ((DWORD)lpHandles[i]) switch ((DWORD)lpHandles[i])
{ {
case STD_INPUT_HANDLE: case STD_INPUT_HANDLE:
HandleBuffer[i] = NtCurrentPeb()->ProcessParameters->hStdInput; HandleBuffer[i] = NtCurrentPeb()->ProcessParameters->StandardInput;
break; break;
case STD_OUTPUT_HANDLE: case STD_OUTPUT_HANDLE:
HandleBuffer[i] = NtCurrentPeb()->ProcessParameters->hStdOutput; HandleBuffer[i] = NtCurrentPeb()->ProcessParameters->StandardOutput;
break; break;
case STD_ERROR_HANDLE: case STD_ERROR_HANDLE:
HandleBuffer[i] = NtCurrentPeb()->ProcessParameters->hStdError; HandleBuffer[i] = NtCurrentPeb()->ProcessParameters->StandardError;
break; break;
default: default:
@ -247,15 +247,15 @@ SignalObjectAndWait(HANDLE hObjectToSignal,
switch ((ULONG)hObjectToWaitOn) switch ((ULONG)hObjectToWaitOn)
{ {
case STD_INPUT_HANDLE: case STD_INPUT_HANDLE:
hObjectToWaitOn = NtCurrentPeb()->ProcessParameters->hStdInput; hObjectToWaitOn = NtCurrentPeb()->ProcessParameters->StandardInput;
break; break;
case STD_OUTPUT_HANDLE: case STD_OUTPUT_HANDLE:
hObjectToWaitOn = NtCurrentPeb()->ProcessParameters->hStdOutput; hObjectToWaitOn = NtCurrentPeb()->ProcessParameters->StandardOutput;
break; break;
case STD_ERROR_HANDLE: case STD_ERROR_HANDLE:
hObjectToWaitOn = NtCurrentPeb()->ProcessParameters->hStdError; hObjectToWaitOn = NtCurrentPeb()->ProcessParameters->StandardError;
break; break;
} }

View file

@ -53,18 +53,18 @@ BOOL WINAPI ConvertFiberToThread(void)
PTEB pTeb = NtCurrentTeb(); PTEB pTeb = NtCurrentTeb();
/* the current thread isn't running a fiber: failure */ /* the current thread isn't running a fiber: failure */
if(!pTeb->IsFiber) if(!pTeb->HasFiberData)
{ {
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
return FALSE; return FALSE;
} }
/* this thread won't run a fiber anymore */ /* this thread won't run a fiber anymore */
pTeb->IsFiber = FALSE; pTeb->HasFiberData = FALSE;
/* free the fiber */ /* free the fiber */
if(pTeb->Tib.FiberData != NULL) if(pTeb->Tib.FiberData != NULL)
RtlFreeHeap(pTeb->Peb->ProcessHeap, 0, pTeb->Tib.FiberData); RtlFreeHeap(pTeb->ProcessEnvironmentBlock->ProcessHeap, 0, pTeb->Tib.FiberData);
/* success */ /* success */
return TRUE; return TRUE;
@ -80,10 +80,10 @@ LPVOID WINAPI ConvertThreadToFiberEx(LPVOID lpParameter, DWORD dwFlags)
PFIBER pfCurFiber; PFIBER pfCurFiber;
/* the current thread is already a fiber */ /* the current thread is already a fiber */
if(pTeb->IsFiber && pTeb->Tib.FiberData) return pTeb->Tib.FiberData; if(pTeb->HasFiberData && pTeb->Tib.FiberData) return pTeb->Tib.FiberData;
/* allocate the fiber */ /* allocate the fiber */
pfCurFiber = (PFIBER)RtlAllocateHeap(pTeb->Peb->ProcessHeap, 0, sizeof(FIBER)); pfCurFiber = (PFIBER)RtlAllocateHeap(pTeb->ProcessEnvironmentBlock->ProcessHeap, 0, sizeof(FIBER));
/* failure */ /* failure */
if(pfCurFiber == NULL) if(pfCurFiber == NULL)
@ -103,7 +103,7 @@ LPVOID WINAPI ConvertThreadToFiberEx(LPVOID lpParameter, DWORD dwFlags)
/* associate the fiber to the current thread */ /* associate the fiber to the current thread */
pTeb->Tib.FiberData = pfCurFiber; pTeb->Tib.FiberData = pfCurFiber;
pTeb->IsFiber = TRUE; pTeb->HasFiberData = TRUE;
/* success */ /* success */
return (LPVOID)pfCurFiber; return (LPVOID)pfCurFiber;
@ -154,7 +154,7 @@ LPVOID WINAPI CreateFiberEx
PTEB pTeb = NtCurrentTeb(); PTEB pTeb = NtCurrentTeb();
/* allocate the fiber */ /* allocate the fiber */
pfCurFiber = (PFIBER)RtlAllocateHeap(pTeb->Peb->ProcessHeap, 0, sizeof(FIBER)); pfCurFiber = (PFIBER)RtlAllocateHeap(pTeb->ProcessEnvironmentBlock->ProcessHeap, 0, sizeof(FIBER));
/* failure */ /* failure */
if(pfCurFiber == NULL) if(pfCurFiber == NULL)
@ -197,23 +197,23 @@ LPVOID WINAPI CreateFiberEx
/* copy the data into the fiber */ /* copy the data into the fiber */
/* fixed-size stack */ /* fixed-size stack */
if(usFiberInitialTeb.StackBase && usFiberInitialTeb.StackLimit) if(usFiberInitialTeb.PreviousStackBase && usFiberInitialTeb.PreviousStackLimit)
{ {
pfCurFiber->StackBase = usFiberInitialTeb.StackBase; pfCurFiber->StackBase = usFiberInitialTeb.PreviousStackBase;
pfCurFiber->StackLimit = usFiberInitialTeb.StackLimit; pfCurFiber->StackLimit = usFiberInitialTeb.PreviousStackLimit;
pfCurFiber->DeallocationStack = usFiberInitialTeb.StackLimit; pfCurFiber->DeallocationStack = usFiberInitialTeb.PreviousStackLimit;
} }
/* expandable stack */ /* expandable stack */
else if else if
( (
usFiberInitialTeb.StackCommit && usFiberInitialTeb.StackBase &&
usFiberInitialTeb.StackCommitMax && usFiberInitialTeb.StackLimit &&
usFiberInitialTeb.StackReserved usFiberInitialTeb.AllocatedStackBase
) )
{ {
pfCurFiber->StackBase = usFiberInitialTeb.StackCommit; pfCurFiber->StackBase = usFiberInitialTeb.StackBase;
pfCurFiber->StackLimit = usFiberInitialTeb.StackCommitMax; pfCurFiber->StackLimit = usFiberInitialTeb.StackLimit;
pfCurFiber->DeallocationStack = usFiberInitialTeb.StackReserved; pfCurFiber->DeallocationStack = usFiberInitialTeb.AllocatedStackBase;
} }
/* bad initial stack */ /* bad initial stack */
else goto l_CleanupStack; else goto l_CleanupStack;
@ -246,7 +246,7 @@ l_CleanupStack:
l_CleanupFiber: l_CleanupFiber:
/* free the fiber */ /* free the fiber */
RtlFreeHeap(pTeb->Peb->ProcessHeap, 0, pfCurFiber); RtlFreeHeap(pTeb->ProcessEnvironmentBlock->ProcessHeap, 0, pfCurFiber);
/* failure */ /* failure */
ASSERT(!NT_SUCCESS(nErrCode)); ASSERT(!NT_SUCCESS(nErrCode));
@ -265,7 +265,7 @@ void WINAPI DeleteFiber(LPVOID lpFiber)
PTEB pTeb = NtCurrentTeb(); PTEB pTeb = NtCurrentTeb();
/* free the fiber */ /* free the fiber */
RtlFreeHeap(pTeb->Peb->ProcessHeap, 0, lpFiber); RtlFreeHeap(pTeb->ProcessEnvironmentBlock->ProcessHeap, 0, lpFiber);
/* the fiber is deleting itself: let the system deallocate the stack */ /* the fiber is deleting itself: let the system deallocate the stack */
if(pTeb->Tib.FiberData == lpFiber) ExitThread(1); if(pTeb->Tib.FiberData == lpFiber) ExitThread(1);

View file

@ -51,7 +51,7 @@ PVOID WINAPI FlsGetValue(DWORD dwFlsIndex)
if(dwFlsIndex >= 128) goto l_InvalidParam; if(dwFlsIndex >= 128) goto l_InvalidParam;
ppFlsSlots = NtCurrentTeb()->FlsSlots; ppFlsSlots = NtCurrentTeb()->FlsData;
if(ppFlsSlots == NULL) goto l_InvalidParam; if(ppFlsSlots == NULL) goto l_InvalidParam;
@ -76,11 +76,11 @@ BOOL WINAPI FlsSetValue(DWORD dwFlsIndex, PVOID lpFlsData)
if(dwFlsIndex >= 128) goto l_InvalidParam; if(dwFlsIndex >= 128) goto l_InvalidParam;
ppFlsSlots = pTeb->FlsSlots; ppFlsSlots = pTeb->FlsData;
if(ppFlsSlots == NULL) if(ppFlsSlots == NULL)
{ {
PEB * pPeb = pTeb->Peb; PEB * pPeb = pTeb->ProcessEnvironmentBlock;
ppFlsSlots = RtlAllocateHeap ppFlsSlots = RtlAllocateHeap
( (
@ -91,7 +91,7 @@ BOOL WINAPI FlsSetValue(DWORD dwFlsIndex, PVOID lpFlsData)
if(ppFlsSlots == NULL) goto l_OutOfMemory; if(ppFlsSlots == NULL) goto l_OutOfMemory;
pTeb->FlsSlots = ppFlsSlots; pTeb->FlsData = ppFlsSlots;
RtlAcquirePebLock(); RtlAcquirePebLock();

View file

@ -14,7 +14,6 @@
#include <ntdll.h> #include <ntdll.h>
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
#include <rosrtl/thread.h>
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -111,8 +110,8 @@ DbgSsInitialize(HANDLE ReplyPort,
NULL, NULL,
FALSE, FALSE,
0, 0,
NULL, 0,
NULL, 0,
(PTHREAD_START_ROUTINE)DbgSsServerThread, (PTHREAD_START_ROUTINE)DbgSsServerThread,
NULL, NULL,
NULL, NULL,
@ -184,14 +183,11 @@ DbgUiWaitStateChange(ULONG Unknown1,
return STATUS_NOT_IMPLEMENTED; return STATUS_NOT_IMPLEMENTED;
} }
NTSTATUS STDCALL DbgUiRemoteBreakin(VOID) VOID STDCALL DbgUiRemoteBreakin(VOID)
{ {
DbgBreakPoint(); DbgBreakPoint();
RtlRosExitUserThread(0); RtlExitUserThread(STATUS_SUCCESS);
DbgBreakPoint();
return STATUS_SUCCESS;
} }
NTSTATUS STDCALL DbgUiIssueRemoteBreakin(HANDLE Process) NTSTATUS STDCALL DbgUiIssueRemoteBreakin(HANDLE Process)
@ -207,8 +203,8 @@ NTSTATUS STDCALL DbgUiIssueRemoteBreakin(HANDLE Process)
NULL, NULL,
FALSE, FALSE,
0, 0,
&nStackSize, nStackSize,
&nStackSize, nStackSize,
(PTHREAD_START_ROUTINE)DbgUiRemoteBreakin, (PTHREAD_START_ROUTINE)DbgUiRemoteBreakin,
NULL, NULL,
&hThread, &hThread,

View file

@ -200,7 +200,7 @@ RtlGetCurrentDirectory_U(ULONG MaximumLength,
RtlAcquirePebLock(); RtlAcquirePebLock();
cd = (PCURDIR)&(NtCurrentPeb ()->ProcessParameters->CurrentDirectoryName); cd = (PCURDIR)&(NtCurrentPeb ()->ProcessParameters->CurrentDirectory.DosPath);
Length = cd->DosPath.Length / sizeof(WCHAR); Length = cd->DosPath.Length / sizeof(WCHAR);
if (cd->DosPath.Buffer[Length - 1] == L'\\' && if (cd->DosPath.Buffer[Length - 1] == L'\\' &&
cd->DosPath.Buffer[Length - 2] != L':') cd->DosPath.Buffer[Length - 2] != L':')
@ -251,7 +251,7 @@ RtlSetCurrentDirectory_U(PUNICODE_STRING dir)
RtlAcquirePebLock (); RtlAcquirePebLock ();
cd = (PCURDIR)&NtCurrentPeb ()->ProcessParameters->CurrentDirectoryName; cd = (PCURDIR)&NtCurrentPeb ()->ProcessParameters->CurrentDirectory.DosPath;
if (!RtlDosPathNameToNtPathName_U (dir->Buffer, &full, 0, 0)) if (!RtlDosPathNameToNtPathName_U (dir->Buffer, &full, 0, 0))
{ {
@ -511,7 +511,7 @@ static ULONG get_full_path_helper(
RtlAcquirePebLock(); RtlAcquirePebLock();
cd = &((PCURDIR)&NtCurrentTeb()->Peb->ProcessParameters->CurrentDirectoryName)->DosPath; cd = &((PCURDIR)&NtCurrentTeb()->ProcessEnvironmentBlock->ProcessParameters->CurrentDirectory.DosPath)->DosPath;
switch (type = RtlDetermineDosPathNameType_U(name)) switch (type = RtlDetermineDosPathNameType_U(name))
{ {
@ -835,7 +835,7 @@ RtlDosPathNameToNtPathName_U(PWSTR dosname,
if (nah) if (nah)
{ {
memset (nah, 0, sizeof(CURDIR)); memset (nah, 0, sizeof(CURDIR));
cd = (PCURDIR)&(NtCurrentPeb ()->ProcessParameters->CurrentDirectoryName); cd = (PCURDIR)&(NtCurrentPeb ()->ProcessParameters->CurrentDirectory.DosPath);
if (Type == 5 && cd->Handle) if (Type == 5 && cd->Handle)
{ {
RtlInitUnicodeString(&us, fullname); RtlInitUnicodeString(&us, fullname);

View file

@ -3,13 +3,12 @@
/* /*
*/ */
#include <string.h>
#include <windows.h> #include <windows.h>
#define NTOS_MODE_USER #define NTOS_MODE_USER
#include <ndk/ntndk.h> #include <ndk/ntndk.h>
#include <rosrtl/thread.h> #include <rosrtl/thread.h>
#include <debug.h>
NTSTATUS NTAPI NTSTATUS NTAPI
RtlRosInitializeContext RtlRosInitializeContext
@ -39,7 +38,7 @@ RtlRosInitializeContext
/* validate the stack */ /* validate the stack */
nErrCode = RtlpRosValidateTopDownUserStack(pStackBase, pStackLimit); nErrCode = RtlpRosValidateTopDownUserStack(pStackBase, pStackLimit);
/* failure */ /* failure */
if(!NT_SUCCESS(nErrCode)) return nErrCode; if(!NT_SUCCESS(nErrCode)) return nErrCode;

View file

@ -29,12 +29,11 @@ NTSTATUS NTAPI RtlRosCreateStack
ULONG_PTR nStackCommit = 0x100000; ULONG_PTR nStackCommit = 0x100000;
NTSTATUS nErrCode; NTSTATUS nErrCode;
if(StackReserve == NULL) StackReserve = &nStackReserve; if(*StackReserve == 0) StackReserve = &nStackReserve;
else *StackReserve = ROUNDUP(*StackReserve, PAGE_SIZE); else *StackReserve = ROUNDUP(*StackReserve, PAGE_SIZE);
if(StackCommit == NULL) StackCommit = &nStackCommit; if(*StackCommit == 0) StackCommit = &nStackCommit;
else *StackCommit = ROUNDUP(*StackCommit, PAGE_SIZE); else *StackCommit = ROUNDUP(*StackCommit, PAGE_SIZE);
#if 0 #if 0
/* the stack commit size must be equal to or less than the reserve size */ /* the stack commit size must be equal to or less than the reserve size */
if(*StackCommit > *StackReserve) *StackCommit = *StackReserve; if(*StackCommit > *StackReserve) *StackCommit = *StackReserve;
@ -47,17 +46,17 @@ NTSTATUS NTAPI RtlRosCreateStack
/* fixed stack */ /* fixed stack */
if(*StackCommit == *StackReserve) if(*StackCommit == *StackReserve)
{ {
InitialTeb->StackCommit = NULL; InitialTeb->StackBase = NULL;
InitialTeb->StackCommitMax = NULL;
InitialTeb->StackReserved = NULL;
InitialTeb->StackLimit = NULL; InitialTeb->StackLimit = NULL;
InitialTeb->AllocatedStackBase = NULL;
InitialTeb->PreviousStackLimit = NULL;
/* allocate the stack */ /* allocate the stack */
nErrCode = NtAllocateVirtualMemory nErrCode = NtAllocateVirtualMemory
( (
ProcessHandle, ProcessHandle,
&(InitialTeb->StackLimit), &(InitialTeb->PreviousStackLimit),
StackZeroBits, StackZeroBits,
StackReserve, StackReserve,
MEM_RESERVE | MEM_COMMIT, MEM_RESERVE | MEM_COMMIT,
@ -68,8 +67,8 @@ NTSTATUS NTAPI RtlRosCreateStack
if(!NT_SUCCESS(nErrCode)) goto l_Fail; if(!NT_SUCCESS(nErrCode)) goto l_Fail;
/* store the highest (first) address of the stack */ /* store the highest (first) address of the stack */
InitialTeb->StackBase = InitialTeb->PreviousStackBase =
(PUCHAR)(InitialTeb->StackLimit) + *StackReserve; (PUCHAR)(InitialTeb->PreviousStackLimit) + *StackReserve;
*StackCommit = *StackReserve; *StackCommit = *StackReserve;
} }
@ -81,16 +80,16 @@ NTSTATUS NTAPI RtlRosCreateStack
DPRINT("Expandable stack\n"); DPRINT("Expandable stack\n");
InitialTeb->StackBase = NULL; InitialTeb->PreviousStackBase = NULL;
InitialTeb->StackLimit = NULL; InitialTeb->PreviousStackLimit = NULL;
InitialTeb->StackReserved = NULL; InitialTeb->AllocatedStackBase = NULL;
/* reserve the stack */ /* reserve the stack */
nErrCode = NtAllocateVirtualMemory nErrCode = NtAllocateVirtualMemory
( (
ProcessHandle, ProcessHandle,
&(InitialTeb->StackReserved), &(InitialTeb->AllocatedStackBase),
StackZeroBits, StackZeroBits,
StackReserve, StackReserve,
MEM_RESERVE, MEM_RESERVE,
@ -103,22 +102,22 @@ NTSTATUS NTAPI RtlRosCreateStack
DPRINT("Reserved %08X bytes\n", *StackReserve); DPRINT("Reserved %08X bytes\n", *StackReserve);
/* expandable stack base - the highest address of the stack */ /* expandable stack base - the highest address of the stack */
InitialTeb->StackCommit = InitialTeb->StackBase =
(PUCHAR)(InitialTeb->StackReserved) + *StackReserve; (PUCHAR)(InitialTeb->AllocatedStackBase) + *StackReserve;
/* expandable stack limit - the lowest committed address of the stack */ /* expandable stack limit - the lowest committed address of the stack */
InitialTeb->StackCommitMax = InitialTeb->StackLimit =
(PUCHAR)(InitialTeb->StackCommit) - *StackCommit; (PUCHAR)(InitialTeb->StackBase) - *StackCommit;
DPRINT("Stack commit %p\n", InitialTeb->StackCommit); DPRINT("Stack commit %p\n", InitialTeb->StackBase);
DPRINT("Stack commit max %p\n", InitialTeb->StackCommitMax); DPRINT("Stack commit max %p\n", InitialTeb->StackLimit);
DPRINT("Stack reserved %p\n", InitialTeb->StackReserved); DPRINT("Stack reserved %p\n", InitialTeb->AllocatedStackBase);
/* commit as much stack as requested */ /* commit as much stack as requested */
nErrCode = NtAllocateVirtualMemory nErrCode = NtAllocateVirtualMemory
( (
ProcessHandle, ProcessHandle,
&(InitialTeb->StackCommitMax), &(InitialTeb->StackLimit),
0, 0,
StackCommit, StackCommit,
MEM_COMMIT, MEM_COMMIT,
@ -131,9 +130,9 @@ NTSTATUS NTAPI RtlRosCreateStack
ASSERT((*StackReserve - *StackCommit) >= PAGE_SIZE); ASSERT((*StackReserve - *StackCommit) >= PAGE_SIZE);
ASSERT((*StackReserve - *StackCommit) % PAGE_SIZE == 0); ASSERT((*StackReserve - *StackCommit) % PAGE_SIZE == 0);
pGuardBase = (PUCHAR)(InitialTeb->StackCommitMax) - PAGE_SIZE; pGuardBase = (PUCHAR)(InitialTeb->StackLimit) - PAGE_SIZE;
DPRINT("Guard base %p\n", InitialTeb->StackCommit); DPRINT("Guard base %p\n", InitialTeb->StackBase);
/* set up the guard page */ /* set up the guard page */
nErrCode = NtAllocateVirtualMemory nErrCode = NtAllocateVirtualMemory
@ -149,7 +148,7 @@ NTSTATUS NTAPI RtlRosCreateStack
/* failure */ /* failure */
if(!NT_SUCCESS(nErrCode)) goto l_Cleanup; if(!NT_SUCCESS(nErrCode)) goto l_Cleanup;
DPRINT("Guard base %p\n", InitialTeb->StackCommit); DPRINT("Guard base %p\n", InitialTeb->StackBase);
} }
@ -176,9 +175,9 @@ NTSTATUS NTAPI RtlRosDeleteStack
ULONG_PTR nSize; ULONG_PTR nSize;
if(InitialTeb->StackLimit) if(InitialTeb->StackLimit)
pStackLowest = InitialTeb->StackLimit; pStackLowest = InitialTeb->PreviousStackLimit;
else if(InitialTeb->StackReserved) else if(InitialTeb->AllocatedStackBase)
pStackLowest = InitialTeb->StackReserved; pStackLowest = InitialTeb->AllocatedStackBase;
/* free the stack, if it was allocated */ /* free the stack, if it was allocated */
if(pStackLowest != NULL) if(pStackLowest != NULL)
@ -247,17 +246,17 @@ NTSTATUS NTAPI RtlpRosGetStackLimits
) )
{ {
/* fixed-size stack */ /* fixed-size stack */
if(InitialTeb->StackBase && InitialTeb->StackLimit) if(InitialTeb->PreviousStackBase && InitialTeb->PreviousStackLimit)
{
*StackBase = InitialTeb->PreviousStackBase;
*StackLimit = InitialTeb->PreviousStackLimit;
}
/* expandable stack */
else if(InitialTeb->StackBase && InitialTeb->StackLimit)
{ {
*StackBase = InitialTeb->StackBase; *StackBase = InitialTeb->StackBase;
*StackLimit = InitialTeb->StackLimit; *StackLimit = InitialTeb->StackLimit;
} }
/* expandable stack */
else if(InitialTeb->StackCommit && InitialTeb->StackCommitMax)
{
*StackBase = InitialTeb->StackCommit;
*StackLimit = InitialTeb->StackCommitMax;
}
/* can't determine the type of stack: failure */ /* can't determine the type of stack: failure */
else else
{ {

View file

@ -516,13 +516,16 @@ RtlQueryEnvironmentVariable_U(PWSTR Environment,
} }
if (Environment == NULL) if (Environment == NULL)
{
return(STATUS_VARIABLE_NOT_FOUND); return(STATUS_VARIABLE_NOT_FOUND);
}
Value->Length = 0; Value->Length = 0;
if (SysEnvUsed == TRUE) if (SysEnvUsed == TRUE)
RtlAcquirePebLock(); RtlAcquirePebLock();
wcs = Environment; wcs = Environment;
DPRINT("Starting search at :%p\n", wcs);
while (*wcs) while (*wcs)
{ {
var.Buffer = wcs++; var.Buffer = wcs++;
@ -530,12 +533,14 @@ RtlQueryEnvironmentVariable_U(PWSTR Environment,
if (wcs == NULL) if (wcs == NULL)
{ {
wcs = var.Buffer + wcslen(var.Buffer); wcs = var.Buffer + wcslen(var.Buffer);
DPRINT("Search at :%S\n", wcs);
} }
if (*wcs) if (*wcs)
{ {
var.Length = var.MaximumLength = (wcs - var.Buffer) * sizeof(WCHAR); var.Length = var.MaximumLength = (wcs - var.Buffer) * sizeof(WCHAR);
val = ++wcs; val = ++wcs;
wcs += wcslen(wcs); wcs += wcslen(wcs);
DPRINT("Search at :%S\n", wcs);
if (RtlEqualUnicodeString(&var, Name, TRUE)) if (RtlEqualUnicodeString(&var, Name, TRUE))
{ {
@ -566,7 +571,7 @@ RtlQueryEnvironmentVariable_U(PWSTR Environment,
if (SysEnvUsed == TRUE) if (SysEnvUsed == TRUE)
RtlReleasePebLock(); RtlReleasePebLock();
DPRINT("Return STATUS_VARIABLE_NOT_FOUND\n"); DPRINT1("Return STATUS_VARIABLE_NOT_FOUND: %wZ\n", Name);
return(STATUS_VARIABLE_NOT_FOUND); return(STATUS_VARIABLE_NOT_FOUND);
} }

View file

@ -59,7 +59,7 @@ RtlCreateProcessParameters(PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
PUNICODE_STRING WindowTitle, PUNICODE_STRING WindowTitle,
PUNICODE_STRING DesktopInfo, PUNICODE_STRING DesktopInfo,
PUNICODE_STRING ShellInfo, PUNICODE_STRING ShellInfo,
PUNICODE_STRING RuntimeInfo) PUNICODE_STRING RuntimeData)
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
PRTL_USER_PROCESS_PARAMETERS Param = NULL; PRTL_USER_PROCESS_PARAMETERS Param = NULL;
@ -86,10 +86,10 @@ RtlCreateProcessParameters(PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
if (Environment == NULL) if (Environment == NULL)
Environment = NtCurrentPeb()->ProcessParameters->Environment; Environment = NtCurrentPeb()->ProcessParameters->Environment;
if (CurrentDirectory == NULL) if (CurrentDirectory == NULL)
CurrentDirectory = &NtCurrentPeb()->ProcessParameters->CurrentDirectoryName; CurrentDirectory = &NtCurrentPeb()->ProcessParameters->CurrentDirectory.DosPath;
CurrentDirectoryHandle = NtCurrentPeb()->ProcessParameters->CurrentDirectoryHandle; CurrentDirectoryHandle = NtCurrentPeb()->ProcessParameters->CurrentDirectory.Handle;
ConsoleHandle = NtCurrentPeb()->ProcessParameters->hConsole; ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
ConsoleFlags = NtCurrentPeb()->ProcessParameters->ProcessGroup; ConsoleFlags = NtCurrentPeb()->ProcessParameters->ConsoleFlags;
} }
else else
{ {
@ -110,8 +110,8 @@ RtlCreateProcessParameters(PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
DesktopInfo = &EmptyString; DesktopInfo = &EmptyString;
if (ShellInfo == NULL) if (ShellInfo == NULL)
ShellInfo = &EmptyString; ShellInfo = &EmptyString;
if (RuntimeInfo == NULL) if (RuntimeData == NULL)
RuntimeInfo = &EmptyString; RuntimeData = &EmptyString;
/* size of process parameter block */ /* size of process parameter block */
Length = sizeof(RTL_USER_PROCESS_PARAMETERS); Length = sizeof(RTL_USER_PROCESS_PARAMETERS);
@ -126,7 +126,7 @@ RtlCreateProcessParameters(PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
Length += ALIGN(WindowTitle->MaximumLength, sizeof(ULONG)); Length += ALIGN(WindowTitle->MaximumLength, sizeof(ULONG));
Length += ALIGN(DesktopInfo->MaximumLength, sizeof(ULONG)); Length += ALIGN(DesktopInfo->MaximumLength, sizeof(ULONG));
Length += ALIGN(ShellInfo->MaximumLength, sizeof(ULONG)); Length += ALIGN(ShellInfo->MaximumLength, sizeof(ULONG));
Length += ALIGN(RuntimeInfo->MaximumLength, sizeof(ULONG)); Length += ALIGN(RuntimeData->MaximumLength, sizeof(ULONG));
/* Calculate the required block size */ /* Calculate the required block size */
RegionSize = ROUNDUP(Length, PAGE_SIZE); RegionSize = ROUNDUP(Length, PAGE_SIZE);
@ -145,33 +145,33 @@ RtlCreateProcessParameters(PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
DPRINT ("Process parameters allocated\n"); DPRINT ("Process parameters allocated\n");
Param->AllocationSize = RegionSize; Param->MaximumLength = RegionSize;
Param->Size = Length; Param->Length = Length;
Param->Flags = PPF_NORMALIZED; Param->Flags = PPF_NORMALIZED;
Param->Environment = Environment; Param->Environment = Environment;
Param->CurrentDirectoryHandle = CurrentDirectoryHandle; Param->CurrentDirectory.Handle = CurrentDirectoryHandle;
Param->hConsole = ConsoleHandle; Param->ConsoleHandle = ConsoleHandle;
Param->ProcessGroup = ConsoleFlags; Param->ConsoleFlags = ConsoleFlags;
Dest = (PWCHAR)(((PBYTE)Param) + sizeof(RTL_USER_PROCESS_PARAMETERS)); Dest = (PWCHAR)(((PBYTE)Param) + sizeof(RTL_USER_PROCESS_PARAMETERS));
/* copy current directory */ /* copy current directory */
RtlpCopyParameterString(&Dest, RtlpCopyParameterString(&Dest,
&Param->CurrentDirectoryName, &Param->CurrentDirectory.DosPath,
CurrentDirectory, CurrentDirectory,
MAX_PATH * sizeof(WCHAR)); MAX_PATH * sizeof(WCHAR));
/* make sure the current directory has a trailing backslash */ /* make sure the current directory has a trailing backslash */
if (Param->CurrentDirectoryName.Length > 0) if (Param->CurrentDirectory.DosPath.Length > 0)
{ {
ULONG Length; ULONG Length;
Length = Param->CurrentDirectoryName.Length / sizeof(WCHAR); Length = Param->CurrentDirectory.DosPath.Length / sizeof(WCHAR);
if (Param->CurrentDirectoryName.Buffer[Length-1] != L'\\') if (Param->CurrentDirectory.DosPath.Buffer[Length-1] != L'\\')
{ {
Param->CurrentDirectoryName.Buffer[Length] = L'\\'; Param->CurrentDirectory.DosPath.Buffer[Length] = L'\\';
Param->CurrentDirectoryName.Buffer[Length + 1] = 0; Param->CurrentDirectory.DosPath.Buffer[Length + 1] = 0;
Param->CurrentDirectoryName.Length += sizeof(WCHAR); Param->CurrentDirectory.DosPath.Length += sizeof(WCHAR);
} }
} }
@ -213,8 +213,8 @@ RtlCreateProcessParameters(PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
/* copy runtime info */ /* copy runtime info */
RtlpCopyParameterString(&Dest, RtlpCopyParameterString(&Dest,
&Param->RuntimeInfo, &Param->RuntimeData,
RuntimeInfo, RuntimeData,
0); 0);
RtlDeNormalizeProcessParams(Param); RtlDeNormalizeProcessParams(Param);
@ -248,14 +248,14 @@ RtlDeNormalizeProcessParams(PRTL_USER_PROCESS_PARAMETERS Params)
{ {
if (Params && (Params->Flags & PPF_NORMALIZED)) if (Params && (Params->Flags & PPF_NORMALIZED))
{ {
DENORMALIZE(Params->CurrentDirectoryName.Buffer, Params); DENORMALIZE(Params->CurrentDirectory.DosPath.Buffer, Params);
DENORMALIZE(Params->DllPath.Buffer, Params); DENORMALIZE(Params->DllPath.Buffer, Params);
DENORMALIZE(Params->ImagePathName.Buffer, Params); DENORMALIZE(Params->ImagePathName.Buffer, Params);
DENORMALIZE(Params->CommandLine.Buffer, Params); DENORMALIZE(Params->CommandLine.Buffer, Params);
DENORMALIZE(Params->WindowTitle.Buffer, Params); DENORMALIZE(Params->WindowTitle.Buffer, Params);
DENORMALIZE(Params->DesktopInfo.Buffer, Params); DENORMALIZE(Params->DesktopInfo.Buffer, Params);
DENORMALIZE(Params->ShellInfo.Buffer, Params); DENORMALIZE(Params->ShellInfo.Buffer, Params);
DENORMALIZE(Params->RuntimeInfo.Buffer, Params); DENORMALIZE(Params->RuntimeData.Buffer, Params);
Params->Flags &= ~PPF_NORMALIZED; Params->Flags &= ~PPF_NORMALIZED;
} }
@ -273,14 +273,14 @@ RtlNormalizeProcessParams(PRTL_USER_PROCESS_PARAMETERS Params)
{ {
if (Params && !(Params->Flags & PPF_NORMALIZED)) if (Params && !(Params->Flags & PPF_NORMALIZED))
{ {
NORMALIZE(Params->CurrentDirectoryName.Buffer, Params); NORMALIZE(Params->CurrentDirectory.DosPath.Buffer, Params);
NORMALIZE(Params->DllPath.Buffer, Params); NORMALIZE(Params->DllPath.Buffer, Params);
NORMALIZE(Params->ImagePathName.Buffer, Params); NORMALIZE(Params->ImagePathName.Buffer, Params);
NORMALIZE(Params->CommandLine.Buffer, Params); NORMALIZE(Params->CommandLine.Buffer, Params);
NORMALIZE(Params->WindowTitle.Buffer, Params); NORMALIZE(Params->WindowTitle.Buffer, Params);
NORMALIZE(Params->DesktopInfo.Buffer, Params); NORMALIZE(Params->DesktopInfo.Buffer, Params);
NORMALIZE(Params->ShellInfo.Buffer, Params); NORMALIZE(Params->ShellInfo.Buffer, Params);
NORMALIZE(Params->RuntimeInfo.Buffer, Params); NORMALIZE(Params->RuntimeData.Buffer, Params);
Params->Flags |= PPF_NORMALIZED; Params->Flags |= PPF_NORMALIZED;
} }

View file

@ -133,7 +133,7 @@ static NTSTATUS KlInitPeb (HANDLE ProcessHandle,
/* create the PPB */ /* create the PPB */
PpbBase = NULL; PpbBase = NULL;
PpbSize = Ppb->AllocationSize; PpbSize = Ppb->MaximumLength;
Status = ZwAllocateVirtualMemory(ProcessHandle, Status = ZwAllocateVirtualMemory(ProcessHandle,
&PpbBase, &PpbBase,
@ -146,14 +146,14 @@ static NTSTATUS KlInitPeb (HANDLE ProcessHandle,
return(Status); return(Status);
} }
DPRINT("Ppb->MaximumLength %x\n", Ppb->AllocationSize); DPRINT("Ppb->MaximumLength %x\n", Ppb->MaximumLength);
/* write process parameters block*/ /* write process parameters block*/
RtlDeNormalizeProcessParams (Ppb); RtlDeNormalizeProcessParams (Ppb);
ZwWriteVirtualMemory(ProcessHandle, ZwWriteVirtualMemory(ProcessHandle,
PpbBase, PpbBase,
Ppb, Ppb,
Ppb->AllocationSize, Ppb->MaximumLength,
&BytesWritten); &BytesWritten);
RtlNormalizeProcessParams (Ppb); RtlNormalizeProcessParams (Ppb);
@ -211,7 +211,7 @@ RtlCreateUserProcess(
IN BOOLEAN InheritHandles, IN BOOLEAN InheritHandles,
IN HANDLE DebugPort OPTIONAL, IN HANDLE DebugPort OPTIONAL,
IN HANDLE ExceptionPort OPTIONAL, IN HANDLE ExceptionPort OPTIONAL,
OUT PRTL_PROCESS_INFO ProcessInfo OUT PRTL_USER_PROCESS_INFORMATION ProcessInfo
) )
{ {
HANDLE hSection; HANDLE hSection;
@ -289,9 +289,9 @@ RtlCreateUserProcess(
NULL, NULL,
TRUE, /* CreateSuspended? */ TRUE, /* CreateSuspended? */
0, 0,
&Sii.StackReserve, Sii.MaximumStackSize,
&Sii.StackCommit, Sii.CommittedStackSize,
(PVOID)((ULONG_PTR)ImageBaseAddress + (ULONG_PTR)Sii.EntryPoint), (PVOID)((ULONG_PTR)ImageBaseAddress + (ULONG_PTR)Sii.TransferAddress),
(PVOID)PEB_BASE, (PVOID)PEB_BASE,
&ProcessInfo->ThreadHandle, &ProcessInfo->ThreadHandle,
&ProcessInfo->ClientId &ProcessInfo->ClientId

View file

@ -35,8 +35,8 @@ NTSTATUS STDCALL RtlCreateUserThread
PSECURITY_DESCRIPTOR SecurityDescriptor, PSECURITY_DESCRIPTOR SecurityDescriptor,
BOOLEAN CreateSuspended, BOOLEAN CreateSuspended,
LONG StackZeroBits, LONG StackZeroBits,
PULONG StackReserve, ULONG StackReserve,
PULONG StackCommit, ULONG StackCommit,
PTHREAD_START_ROUTINE StartAddress, PTHREAD_START_ROUTINE StartAddress,
PVOID Parameter, PVOID Parameter,
PHANDLE ThreadHandle, PHANDLE ThreadHandle,
@ -60,8 +60,8 @@ NTSTATUS STDCALL RtlCreateUserThread
&oaThreadAttribs, &oaThreadAttribs,
CreateSuspended, CreateSuspended,
StackZeroBits, StackZeroBits,
StackReserve, &StackReserve,
StackCommit, &StackCommit,
StartAddress, StartAddress,
ThreadHandle, ThreadHandle,
ClientId, ClientId,
@ -73,7 +73,7 @@ NTSTATUS STDCALL RtlCreateUserThread
/* /*
@implemented @implemented
*/ */
NTSTATUS STDCALL VOID STDCALL
RtlInitializeContext( RtlInitializeContext(
IN HANDLE ProcessHandle, IN HANDLE ProcessHandle,
OUT PCONTEXT ThreadContext, OUT PCONTEXT ThreadContext,
@ -81,7 +81,7 @@ RtlInitializeContext(
IN PTHREAD_START_ROUTINE ThreadStartAddress, IN PTHREAD_START_ROUTINE ThreadStartAddress,
IN PINITIAL_TEB InitialTeb) IN PINITIAL_TEB InitialTeb)
{ {
return RtlRosInitializeContext RtlRosInitializeContext
( (
ProcessHandle, ProcessHandle,
ThreadContext, ThreadContext,
@ -107,7 +107,7 @@ NTSTATUS STDCALL RtlFreeUserThreadStack
/* /*
@implemented @implemented
*/ */
NTSTATUS STDCALL RtlExitUserThread(NTSTATUS Status) VOID STDCALL RtlExitUserThread(NTSTATUS Status)
{ {
RtlRosExitUserThread(Status); RtlRosExitUserThread(Status);
} }

View file

@ -84,11 +84,12 @@ RunVMWInstall(VOID)
{ {
PROCESS_INFORMATION ProcInfo; PROCESS_INFORMATION ProcInfo;
STARTUPINFO si; STARTUPINFO si;
WCHAR InstallName[] = L"vmwinst.exe";
ZeroMemory(&si, sizeof(STARTUPINFO)); ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO); si.cb = sizeof(STARTUPINFO);
if(CreateProcess(NULL, _T("vmwinst.exe"), NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, if(CreateProcess(NULL, InstallName, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS,
NULL, NULL, &si, &ProcInfo)) NULL, NULL, &si, &ProcInfo))
{ {
WaitForSingleObject(ProcInfo.hProcess, INFINITE); WaitForSingleObject(ProcInfo.hProcess, INFINITE);

View file

@ -47,15 +47,15 @@ VOID
Init(VOID) Init(VOID)
{ {
/* Set up the kernel callbacks. */ /* Set up the kernel callbacks. */
NtCurrentTeb()->Peb->KernelCallbackTable[USER32_CALLBACK_WINDOWPROC] = NtCurrentTeb()->ProcessEnvironmentBlock->KernelCallbackTable[USER32_CALLBACK_WINDOWPROC] =
(PVOID)User32CallWindowProcFromKernel; (PVOID)User32CallWindowProcFromKernel;
NtCurrentTeb()->Peb->KernelCallbackTable[USER32_CALLBACK_SENDASYNCPROC] = NtCurrentTeb()->ProcessEnvironmentBlock->KernelCallbackTable[USER32_CALLBACK_SENDASYNCPROC] =
(PVOID)User32CallSendAsyncProcForKernel; (PVOID)User32CallSendAsyncProcForKernel;
NtCurrentTeb()->Peb->KernelCallbackTable[USER32_CALLBACK_LOADSYSMENUTEMPLATE] = NtCurrentTeb()->ProcessEnvironmentBlock->KernelCallbackTable[USER32_CALLBACK_LOADSYSMENUTEMPLATE] =
(PVOID)User32LoadSysMenuTemplateForKernel; (PVOID)User32LoadSysMenuTemplateForKernel;
NtCurrentTeb()->Peb->KernelCallbackTable[USER32_CALLBACK_LOADDEFAULTCURSORS] = NtCurrentTeb()->ProcessEnvironmentBlock->KernelCallbackTable[USER32_CALLBACK_LOADDEFAULTCURSORS] =
(PVOID)User32SetupDefaultCursors; (PVOID)User32SetupDefaultCursors;
NtCurrentTeb()->Peb->KernelCallbackTable[USER32_CALLBACK_HOOKPROC] = NtCurrentTeb()->ProcessEnvironmentBlock->KernelCallbackTable[USER32_CALLBACK_HOOKPROC] =
(PVOID)User32CallHookProcFromKernel; (PVOID)User32CallHookProcFromKernel;
/* Allocate an index for user32 thread local data. */ /* Allocate an index for user32 thread local data. */

View file

@ -77,7 +77,7 @@ IoConnectInterrupt(PKINTERRUPT* InterruptObject,
PAGED_CODE(); PAGED_CODE();
DPRINT1("IoConnectInterrupt(Vector %x)\n",Vector); DPRINT("IoConnectInterrupt(Vector %x)\n",Vector);
/* Convert the Mask */ /* Convert the Mask */
ProcessorEnableMask &= ((1 << KeNumberProcessors) - 1); ProcessorEnableMask &= ((1 << KeNumberProcessors) - 1);

View file

@ -436,7 +436,8 @@ KeResumeThread(PKTHREAD Thread)
ULONG PreviousCount; ULONG PreviousCount;
KIRQL OldIrql; KIRQL OldIrql;
DPRINT("KeResumeThread (Thread %p called). %x, %x\n", Thread, Thread->SuspendCount, Thread->FreezeCount); DPRINT("KeResumeThread (Thread %p called). %x, %x\n", Thread,
Thread->SuspendCount, Thread->FreezeCount);
/* Lock the Dispatcher */ /* Lock the Dispatcher */
OldIrql = KeAcquireDispatcherDatabaseLock(); OldIrql = KeAcquireDispatcherDatabaseLock();

View file

@ -28,7 +28,7 @@ LdrLoadInitialProcess(PHANDLE ProcessHandle,
HANDLE SystemProcessHandle; HANDLE SystemProcessHandle;
NTSTATUS Status; NTSTATUS Status;
PRTL_USER_PROCESS_PARAMETERS Params=NULL; PRTL_USER_PROCESS_PARAMETERS Params=NULL;
RTL_PROCESS_INFO Info; RTL_USER_PROCESS_INFORMATION Info;
Status = ObpCreateHandle( Status = ObpCreateHandle(
PsGetCurrentProcess(), PsGetCurrentProcess(),

View file

@ -307,25 +307,25 @@ MmCreateTeb(PEPROCESS Process,
/* Set TEB Data */ /* Set TEB Data */
Teb->Cid = *ClientId; Teb->Cid = *ClientId;
Teb->RealClientId = *ClientId; Teb->RealClientId = *ClientId;
Teb->Peb = Process->Peb; Teb->ProcessEnvironmentBlock = Process->Peb;
Teb->CurrentLocale = PsDefaultThreadLocaleId; Teb->CurrentLocale = PsDefaultThreadLocaleId;
/* Store stack information from InitialTeb */ /* Store stack information from InitialTeb */
if(InitialTeb != NULL) if(InitialTeb != NULL)
{ {
/* fixed-size stack */ /* fixed-size stack */
if(InitialTeb->StackBase && InitialTeb->StackLimit) if(InitialTeb->PreviousStackBase && InitialTeb->PreviousStackLimit)
{ {
Teb->Tib.StackBase = InitialTeb->StackBase; Teb->Tib.StackBase = InitialTeb->PreviousStackBase;
Teb->Tib.StackLimit = InitialTeb->StackLimit; Teb->Tib.StackLimit = InitialTeb->PreviousStackLimit;
Teb->DeallocationStack = InitialTeb->StackLimit; Teb->DeallocationStack = InitialTeb->PreviousStackLimit;
} }
/* expandable stack */ /* expandable stack */
else else
{ {
Teb->Tib.StackBase = InitialTeb->StackCommit; Teb->Tib.StackBase = InitialTeb->StackBase;
Teb->Tib.StackLimit = InitialTeb->StackCommitMax; Teb->Tib.StackLimit = InitialTeb->StackLimit;
Teb->DeallocationStack = InitialTeb->StackReserved; Teb->DeallocationStack = InitialTeb->AllocatedStackBase;
} }
} }

View file

@ -4071,15 +4071,15 @@ NtQuerySection(IN HANDLE SectionHandle,
PMM_IMAGE_SECTION_OBJECT ImageSectionObject; PMM_IMAGE_SECTION_OBJECT ImageSectionObject;
ImageSectionObject = Section->ImageSection; ImageSectionObject = Section->ImageSection;
Sii->EntryPoint = ImageSectionObject->EntryPoint; Sii->TransferAddress = (PVOID)ImageSectionObject->EntryPoint;
Sii->StackReserve = ImageSectionObject->StackReserve; Sii->MaximumStackSize = ImageSectionObject->StackReserve;
Sii->StackCommit = ImageSectionObject->StackCommit; Sii->CommittedStackSize = ImageSectionObject->StackCommit;
Sii->Subsystem = ImageSectionObject->Subsystem; Sii->SubsystemType = ImageSectionObject->Subsystem;
Sii->MinorSubsystemVersion = ImageSectionObject->MinorSubsystemVersion; Sii->SubSystemMinorVersion = ImageSectionObject->MinorSubsystemVersion;
Sii->MajorSubsystemVersion = ImageSectionObject->MajorSubsystemVersion; Sii->SubSystemMajorVersion = ImageSectionObject->MajorSubsystemVersion;
Sii->Characteristics = ImageSectionObject->ImageCharacteristics; Sii->ImageCharacteristics = ImageSectionObject->ImageCharacteristics;
Sii->ImageNumber = ImageSectionObject->Machine; Sii->Machine = ImageSectionObject->Machine;
Sii->Executable = ImageSectionObject->Executable; Sii->ImageContainsCode = ImageSectionObject->Executable;
} }
if (ResultLength != NULL) if (ResultLength != NULL)

View file

@ -288,8 +288,18 @@ PspExitThread(NTSTATUS ExitStatus)
//CmNotifyRunDown(CurrentThread); //CmNotifyRunDown(CurrentThread);
/* Free the TEB */ /* Free the TEB */
if((Teb = CurrentThread->Tcb.Teb)) { if((Teb = CurrentThread->Tcb.Teb))
{
/* Clean up the stack first, if requested */
if (Teb->FreeStackOnTermination)
{
ULONG Dummy = 0;
ZwFreeVirtualMemory(NtCurrentProcess(),
&Teb->DeallocationStack,
&Dummy,
MEM_RELEASE);
}
DPRINT("Decommit teb at %p\n", Teb); DPRINT("Decommit teb at %p\n", Teb);
MmDeleteTeb(CurrentProcess, Teb); MmDeleteTeb(CurrentProcess, Teb);
CurrentThread->Tcb.Teb = NULL; CurrentThread->Tcb.Teb = NULL;
@ -518,6 +528,23 @@ NtTerminateThread(IN HANDLE ThreadHandle,
NTSTATUS Status; NTSTATUS Status;
PAGED_CODE(); PAGED_CODE();
/* Handle the special NULL case */
if (!ThreadHandle)
{
/* Check if we're the only thread left */
if (IsListEmpty(&PsGetCurrentProcess()->Pcb.ThreadListHead))
{
/* This is invalid */
DPRINT1("Can't terminate self\n");
return STATUS_CANT_TERMINATE_SELF;
}
else
{
/* Use current handle */
ThreadHandle = NtCurrentThread();
}
}
/* Get the Thread Object */ /* Get the Thread Object */
Status = ObReferenceObjectByHandle(ThreadHandle, Status = ObReferenceObjectByHandle(ThreadHandle,

View file

@ -237,8 +237,8 @@ ServerApiPortThread (PVOID PortHandle)
NULL, NULL,
FALSE, FALSE,
0, 0,
NULL, 0,
NULL, 0,
(PTHREAD_START_ROUTINE)ClientConnectionThread, (PTHREAD_START_ROUTINE)ClientConnectionThread,
ServerPort, ServerPort,
& ServerThread, & ServerThread,

View file

@ -284,8 +284,8 @@ CsrpCreateListenPort (IN LPWSTR Name,
NULL, NULL,
FALSE, FALSE,
0, 0,
NULL, 0,
NULL, 0,
(PTHREAD_START_ROUTINE) ListenThread, (PTHREAD_START_ROUTINE) ListenThread,
Port, Port,
NULL, NULL,
@ -476,7 +476,7 @@ CsrpRunWinlogon (ULONG argc, PWSTR* argv)
UNICODE_STRING ImagePath; UNICODE_STRING ImagePath;
UNICODE_STRING CommandLine; UNICODE_STRING CommandLine;
PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL; PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL;
RTL_PROCESS_INFO ProcessInfo; RTL_USER_PROCESS_INFORMATION ProcessInfo;
DPRINT("CSR: %s called\n", __FUNCTION__); DPRINT("CSR: %s called\n", __FUNCTION__);

View file

@ -283,7 +283,7 @@ SmCompleteClientInitialization (ULONG ProcessId)
* NTSTATUS: * NTSTATUS:
*/ */
NTSTATUS STDCALL NTSTATUS STDCALL
SmCreateClient (PRTL_PROCESS_INFO ProcessInfo, PWSTR ProgramName) SmCreateClient (PRTL_USER_PROCESS_INFORMATION ProcessInfo, PWSTR ProgramName)
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;

View file

@ -109,8 +109,8 @@ SmpCreatePT (IN OUT PHANDLE hPort,
NULL, NULL,
FALSE, FALSE,
0, 0,
NULL, 0,
NULL, 0,
(PTHREAD_START_ROUTINE) procServingThread, (PTHREAD_START_ROUTINE) procServingThread,
hPort, hPort,
& Thread, & Thread,

View file

@ -51,7 +51,7 @@ static NTSTATUS
SmpRegisterSmss(VOID) SmpRegisterSmss(VOID)
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
RTL_PROCESS_INFO ProcessInfo; RTL_USER_PROCESS_INFORMATION ProcessInfo;
DPRINT("SM: %s called\n",__FUNCTION__); DPRINT("SM: %s called\n",__FUNCTION__);

View file

@ -282,8 +282,8 @@ SmpHandleConnectionRequest (PSM_PORT_MESSAGE Request)
NULL, NULL,
FALSE, FALSE,
0, 0,
NULL, 0,
NULL, 0,
(PTHREAD_START_ROUTINE) SmpApiConnectedThread, (PTHREAD_START_ROUTINE) SmpApiConnectedThread,
ClientDataApiPort, ClientDataApiPort,
ClientDataApiPortThread, ClientDataApiPortThread,
@ -383,8 +383,8 @@ SmCreateApiPort(VOID)
NULL, NULL,
FALSE, FALSE,
0, 0,
NULL, 0,
NULL, 0,
(PTHREAD_START_ROUTINE)SmpApiThread, (PTHREAD_START_ROUTINE)SmpApiThread,
(PVOID)SmApiPort, (PVOID)SmApiPort,
NULL, NULL,

View file

@ -51,13 +51,13 @@ SmCreateUserProcess (LPWSTR ImagePath,
LPWSTR CommandLine, LPWSTR CommandLine,
BOOLEAN WaitForIt, BOOLEAN WaitForIt,
PLARGE_INTEGER Timeout OPTIONAL, PLARGE_INTEGER Timeout OPTIONAL,
PRTL_PROCESS_INFO UserProcessInfo OPTIONAL) PRTL_USER_PROCESS_INFORMATION UserProcessInfo OPTIONAL)
{ {
UNICODE_STRING ImagePathString = {0}; UNICODE_STRING ImagePathString = {0};
UNICODE_STRING CommandLineString = {0}; UNICODE_STRING CommandLineString = {0};
PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL; PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL;
RTL_PROCESS_INFO ProcessInfo = {0}; RTL_USER_PROCESS_INFORMATION ProcessInfo = {0};
PRTL_PROCESS_INFO pProcessInfo = & ProcessInfo; PRTL_USER_PROCESS_INFORMATION pProcessInfo = & ProcessInfo;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
DPRINT("SM: %s called\n", __FUNCTION__); DPRINT("SM: %s called\n", __FUNCTION__);
@ -184,7 +184,7 @@ SMAPI(SmExecPgm)
{ {
WCHAR ImagePath [MAX_PATH + 1] = {0}; WCHAR ImagePath [MAX_PATH + 1] = {0};
PWCHAR CommandLine = ImagePath; PWCHAR CommandLine = ImagePath;
RTL_PROCESS_INFO ProcessInfo = {0}; RTL_USER_PROCESS_INFORMATION ProcessInfo = {0};
wcscpy (ImagePath, L"\\??\\"); wcscpy (ImagePath, L"\\??\\");
wcscat (ImagePath, Data); wcscat (ImagePath, Data);

View file

@ -62,7 +62,7 @@ NTSTATUS STDCALL SmCreateUserProcess(LPWSTR ImagePath,
LPWSTR CommandLine, LPWSTR CommandLine,
BOOLEAN WaitForIt, BOOLEAN WaitForIt,
PLARGE_INTEGER Timeout OPTIONAL, PLARGE_INTEGER Timeout OPTIONAL,
PRTL_PROCESS_INFO UserProcessInfo OPTIONAL); PRTL_USER_PROCESS_INFORMATION UserProcessInfo OPTIONAL);
NTSTATUS FASTCALL SmExecPgm(PSM_PORT_MESSAGE); NTSTATUS FASTCALL SmExecPgm(PSM_PORT_MESSAGE);
/* smapicomp.c */ /* smapicomp.c */
@ -92,7 +92,7 @@ typedef struct _SM_CLIENT_DATA
} SM_CLIENT_DATA, *PSM_CLIENT_DATA; } SM_CLIENT_DATA, *PSM_CLIENT_DATA;
NTSTATUS SmInitializeClientManagement (VOID); NTSTATUS SmInitializeClientManagement (VOID);
NTSTATUS STDCALL SmCreateClient (PRTL_PROCESS_INFO,PWSTR); NTSTATUS STDCALL SmCreateClient (PRTL_USER_PROCESS_INFORMATION,PWSTR);
NTSTATUS STDCALL SmDestroyClient (ULONG); NTSTATUS STDCALL SmDestroyClient (ULONG);
NTSTATUS STDCALL SmBeginClientInitialization (PSM_PORT_MESSAGE,PSM_CLIENT_DATA*); NTSTATUS STDCALL SmBeginClientInitialization (PSM_PORT_MESSAGE,PSM_CLIENT_DATA*);
NTSTATUS STDCALL SmCompleteClientInitialization (ULONG); NTSTATUS STDCALL SmCompleteClientInitialization (ULONG);

View file

@ -90,6 +90,7 @@ StartServices (VOID)
STARTUPINFO StartupInfo; STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInformation; PROCESS_INFORMATION ProcessInformation;
DWORD Count; DWORD Count;
WCHAR ServiceString[] = L"services.exe";
/* Start the service control manager (services.exe) */ /* Start the service control manager (services.exe) */
@ -105,8 +106,8 @@ StartServices (VOID)
PrintString(L"WL: Creating new process - \"services.exe\".\n"); PrintString(L"WL: Creating new process - \"services.exe\".\n");
#endif #endif
Result = CreateProcess(L"services.exe", Result = CreateProcess(NULL,
NULL, ServiceString,
NULL, NULL,
NULL, NULL,
FALSE, FALSE,
@ -472,8 +473,8 @@ DoLogonUser (PWCHAR Name,
NULL, NULL,
NULL, NULL,
FALSE, FALSE,
CREATE_NEW_CONSOLE,// | CREATE_UNICODE_ENVIRONMENT, CREATE_UNICODE_ENVIRONMENT,
lpEnvironment, // NULL, lpEnvironment,
CurrentDirectory, CurrentDirectory,
&StartupInfo, &StartupInfo,
&ProcessInformation); &ProcessInformation);

View file

@ -1751,11 +1751,11 @@ IntCreateWindowEx(DWORD dwExStyle,
{ {
CalculatedDefPosSize = IntCalcDefPosSize(ParentWindow, WindowObject, &rc, TRUE); CalculatedDefPosSize = IntCalcDefPosSize(ParentWindow, WindowObject, &rc, TRUE);
if(ProcessParams->dwFlags & STARTF_USEPOSITION) if(ProcessParams->WindowFlags & STARTF_USEPOSITION)
{ {
ProcessParams->dwFlags &= ~STARTF_USEPOSITION; ProcessParams->WindowFlags &= ~STARTF_USEPOSITION;
Pos.x = WorkArea.left + ProcessParams->dwX; Pos.x = WorkArea.left + ProcessParams->StartingX;
Pos.y = WorkArea.top + ProcessParams->dwY; Pos.y = WorkArea.top + ProcessParams->StartingY;
} }
else else
{ {
@ -1776,11 +1776,11 @@ IntCreateWindowEx(DWORD dwExStyle,
{ {
IntCalcDefPosSize(ParentWindow, WindowObject, &rc, FALSE); IntCalcDefPosSize(ParentWindow, WindowObject, &rc, FALSE);
} }
if(ProcessParams->dwFlags & STARTF_USESIZE) if(ProcessParams->WindowFlags & STARTF_USESIZE)
{ {
ProcessParams->dwFlags &= ~STARTF_USESIZE; ProcessParams->WindowFlags &= ~STARTF_USESIZE;
Size.cx = ProcessParams->dwXSize; Size.cx = ProcessParams->CountX;
Size.cy = ProcessParams->dwYSize; Size.cy = ProcessParams->CountY;
} }
else else
{ {

View file

@ -508,6 +508,7 @@ extern "C" {
#define FIBER_FLAG_FLOAT_SWITCH 0x1 #define FIBER_FLAG_FLOAT_SWITCH 0x1
#endif #endif
#define FLS_OUT_OF_INDEXES 0xFFFFFFFF #define FLS_OUT_OF_INDEXES 0xFFFFFFFF
#define STACK_SIZE_PARAM_IS_A_RESERVATION 0x00010000
#ifndef RC_INVOKED #ifndef RC_INVOKED
typedef struct _FILETIME { typedef struct _FILETIME {