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]
Priority 3:
- Some RTL Structures need review (Alex) [rtltypes.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]
Priority 4:
- 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:
- LPC Types are totally wrong. [lpctypes.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;
typedef struct _CURDIR
{
UNICODE_STRING DosPath;
PVOID Handle;
} CURDIR, *PCURDIR;
typedef struct _DESCRIPTOR_TABLE_ENTRY
{
ULONG Selector;
@ -181,75 +175,101 @@ typedef struct _GDI_TEB_BATCH
typedef struct _INITIAL_TEB
{
PVOID PreviousStackBase;
PVOID PreviousStackLimit;
PVOID StackBase;
PVOID StackLimit;
PVOID StackCommit;
PVOID StackCommitMax;
PVOID StackReserved;
PVOID AllocatedStackBase;
} 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
{
NT_TIB Tib; /* 00h */
PVOID EnvironmentPointer; /* 1Ch */
CLIENT_ID Cid; /* 20h */
PVOID ActiveRpcInfo; /* 28h */
PVOID ThreadLocalStoragePointer; /* 2Ch */
struct _PEB *Peb; /* 30h */
ULONG LastErrorValue; /* 34h */
ULONG CountOfOwnedCriticalSections; /* 38h */
PVOID CsrClientThread; /* 3Ch */
struct _W32THREAD* Win32ThreadInfo; /* 40h */
ULONG Win32ClientInfo[0x1F]; /* 44h */
PVOID WOW32Reserved; /* C0h */
LCID CurrentLocale; /* C4h */
ULONG FpSoftwareStatusRegister; /* C8h */
PVOID SystemReserved1[0x36]; /* CCh */
PVOID Spare1; /* 1A4h */
LONG ExceptionCode; /* 1A8h */
UCHAR SpareBytes1[0x28]; /* 1ACh */
PVOID SystemReserved2[0xA]; /* 1D4h */
GDI_TEB_BATCH GdiTebBatch; /* 1FCh */
ULONG gdiRgn; /* 6DCh */
ULONG gdiPen; /* 6E0h */
ULONG gdiBrush; /* 6E4h */
CLIENT_ID RealClientId; /* 6E8h */
PVOID GdiCachedProcessHandle; /* 6F0h */
ULONG GdiClientPID; /* 6F4h */
ULONG GdiClientTID; /* 6F8h */
PVOID GdiThreadLocaleInfo; /* 6FCh */
PVOID UserReserved[5]; /* 700h */
PVOID glDispatchTable[0x118]; /* 714h */
ULONG glReserved1[0x1A]; /* B74h */
PVOID glReserved2; /* BDCh */
PVOID glSectionInfo; /* BE0h */
PVOID glSection; /* BE4h */
PVOID glTable; /* BE8h */
PVOID glCurrentRC; /* BECh */
PVOID glContext; /* BF0h */
NTSTATUS LastStatusValue; /* BF4h */
UNICODE_STRING StaticUnicodeString; /* BF8h */
WCHAR StaticUnicodeBuffer[0x105]; /* C00h */
PVOID DeallocationStack; /* E0Ch */
PVOID TlsSlots[0x40]; /* E10h */
LIST_ENTRY TlsLinks; /* F10h */
PVOID Vdm; /* F18h */
PVOID ReservedForNtRpc; /* F1Ch */
PVOID DbgSsReserved[0x2]; /* F20h */
ULONG HardErrorDisabled; /* F28h */
PVOID Instrumentation[0x10]; /* F2Ch */
PVOID WinSockData; /* F6Ch */
ULONG GdiBatchCount; /* F70h */
USHORT _Spare2; /* F74h */
BOOLEAN IsFiber; /* F76h */
UCHAR Spare3; /* F77h */
ULONG _Spare4; /* F78h */
ULONG _Spare5; /* F7Ch */
PVOID ReservedForOle; /* F80h */
ULONG WaitingOnLoaderLock; /* F84h */
ULONG _Unknown[11]; /* F88h */
PVOID FlsSlots; /* FB4h */
PVOID WineDebugInfo; /* Needed for WINE DLL's */
NT_TIB Tib; /* 00h */
PVOID EnvironmentPointer; /* 1Ch */
CLIENT_ID Cid; /* 20h */
PVOID ActiveRpcHandle; /* 28h */
PVOID ThreadLocalStoragePointer; /* 2Ch */
struct _PEB *ProcessEnvironmentBlock; /* 30h */
ULONG LastErrorValue; /* 34h */
ULONG CountOfOwnedCriticalSections; /* 38h */
PVOID CsrClientThread; /* 3Ch */
struct _W32THREAD* Win32ThreadInfo; /* 40h */
ULONG User32Reserved[0x1A]; /* 44h */
ULONG UserReserved[5]; /* ACh */
PVOID WOW32Reserved; /* C0h */
LCID CurrentLocale; /* C4h */
ULONG FpSoftwareStatusRegister; /* C8h */
PVOID SystemReserved1[0x36]; /* CCh */
LONG ExceptionCode; /* 1A4h */
struct _ACTIVATION_CONTEXT_STACK *ActivationContextStackPointer; /* 1A8h */
UCHAR SpareBytes1[0x28]; /* 1ACh */
GDI_TEB_BATCH GdiTebBatch; /* 1D4h */
CLIENT_ID RealClientId; /* 6B4h */
PVOID GdiCachedProcessHandle; /* 6BCh */
ULONG GdiClientPID; /* 6C0h */
ULONG GdiClientTID; /* 6C4h */
PVOID GdiThreadLocalInfo; /* 6C8h */
ULONG Win32ClientInfo[62]; /* 6CCh */
PVOID glDispatchTable[0xE9]; /* 7C4h */
ULONG glReserved1[0x1D]; /* B68h */
PVOID glReserved2; /* BDCh */
PVOID glSectionInfo; /* BE0h */
PVOID glSection; /* BE4h */
PVOID glTable; /* BE8h */
PVOID glCurrentRC; /* BECh */
PVOID glContext; /* BF0h */
NTSTATUS LastStatusValue; /* BF4h */
UNICODE_STRING StaticUnicodeString; /* BF8h */
WCHAR StaticUnicodeBuffer[0x105]; /* C00h */
PVOID DeallocationStack; /* E0Ch */
PVOID TlsSlots[0x40]; /* E10h */
LIST_ENTRY TlsLinks; /* F10h */
PVOID Vdm; /* F18h */
PVOID ReservedForNtRpc; /* F1Ch */
PVOID DbgSsReserved[0x2]; /* F20h */
ULONG HardErrorDisabled; /* F28h */
PVOID Instrumentation[14]; /* F2Ch */
PVOID SubProcessTag; /* F64h */
PVOID EtwTraceData; /* F68h */
PVOID WinSockData; /* F6Ch */
ULONG GdiBatchCount; /* F70h */
BOOLEAN InDbgPrint; /* F74h */
BOOLEAN FreeStackOnTermination; /* F75h */
BOOLEAN HasFiberData; /* F76h */
UCHAR IdealProcessor; /* F77h */
ULONG GuaranteedStackBytes; /* F78h */
PVOID ReservedForPerf; /* F7Ch */
PVOID ReservedForOle; /* F80h */
ULONG WaitingOnLoaderLock; /* F84h */
ULONG SparePointer1; /* F88h */
ULONG SoftPatchPtr1; /* F8Ch */
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;
/* KERNEL MODE ONLY **********************************************************/

View file

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

View file

@ -17,9 +17,17 @@
/* CONSTANTS *****************************************************************/
#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_EXECUTE_HANDLER 1
@ -218,6 +226,12 @@ typedef struct _MODULE_INFORMATION
ULONG ModuleCount;
DEBUG_MODULE_INFORMATION ModuleEntry[1];
} MODULE_INFORMATION, *PMODULE_INFORMATION;
typedef struct _RTL_HEAP_DEFINITION
{
ULONG Length;
ULONG Unknown[11];
} RTL_HEAP_DEFINITION, *PRTL_HEAP_DEFINITION;
/* END REVIEW AREA */
typedef struct _EXCEPTION_REGISTRATION
@ -229,6 +243,12 @@ typedef struct _EXCEPTION_REGISTRATION
typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD;
typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD;
typedef struct _CURDIR
{
UNICODE_STRING DosPath;
HANDLE Handle;
} CURDIR, *PCURDIR;
typedef struct RTL_DRIVE_LETTER_CURDIR
{
USHORT Flags;
@ -237,12 +257,6 @@ typedef struct RTL_DRIVE_LETTER_CURDIR
UNICODE_STRING DosPath;
} 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
{
LIST_ENTRY ListHead;
@ -323,44 +337,44 @@ typedef struct _NLS_FILE_HEADER
typedef struct _RTL_USER_PROCESS_PARAMETERS
{
ULONG AllocationSize;
ULONG Size;
ULONG Flags;
ULONG DebugFlags;
HANDLE hConsole;
ULONG ProcessGroup;
HANDLE hStdInput;
HANDLE hStdOutput;
HANDLE hStdError;
UNICODE_STRING CurrentDirectoryName;
HANDLE CurrentDirectoryHandle;
UNICODE_STRING DllPath;
UNICODE_STRING ImagePathName;
UNICODE_STRING CommandLine;
PWSTR Environment;
ULONG dwX;
ULONG dwY;
ULONG dwXSize;
ULONG dwYSize;
ULONG dwXCountChars;
ULONG dwYCountChars;
ULONG dwFillAttribute;
ULONG dwFlags;
ULONG wShowWindow;
UNICODE_STRING WindowTitle;
UNICODE_STRING DesktopInfo;
UNICODE_STRING ShellInfo;
UNICODE_STRING RuntimeInfo;
ULONG MaximumLength;
ULONG Length;
ULONG Flags;
ULONG DebugFlags;
HANDLE ConsoleHandle;
ULONG ConsoleFlags;
HANDLE StandardInput;
HANDLE StandardOutput;
HANDLE StandardError;
CURDIR CurrentDirectory;
UNICODE_STRING DllPath;
UNICODE_STRING ImagePathName;
UNICODE_STRING CommandLine;
PWSTR Environment;
ULONG StartingX;
ULONG StartingY;
ULONG CountX;
ULONG CountY;
ULONG CountCharsX;
ULONG CountCharsY;
ULONG FillAttribute;;
ULONG WindowFlags;
ULONG ShowWindowFlags;
UNICODE_STRING WindowTitle;
UNICODE_STRING DesktopInfo;
UNICODE_STRING ShellInfo;
UNICODE_STRING RuntimeData;
RTL_DRIVE_LETTER_CURDIR CurrentDirectories[32];
} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
typedef struct _RTL_PROCESS_INFO
typedef struct _RTL_USER_PROCESS_INFORMATION
{
ULONG Size;
HANDLE ProcessHandle;
HANDLE ThreadHandle;
CLIENT_ID ClientId;
SECTION_IMAGE_INFORMATION ImageInfo;
} RTL_PROCESS_INFO, *PRTL_PROCESS_INFO;
ULONG Size;
HANDLE ProcessHandle;
HANDLE ThreadHandle;
CLIENT_ID ClientId;
SECTION_IMAGE_INFORMATION ImageInformation;
} RTL_USER_PROCESS_INFORMATION, *PRTL_USER_PROCESS_INFORMATION;
typedef struct _RTL_ATOM_TABLE_ENTRY
{

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -84,11 +84,12 @@ RunVMWInstall(VOID)
{
PROCESS_INFORMATION ProcInfo;
STARTUPINFO si;
WCHAR InstallName[] = L"vmwinst.exe";
ZeroMemory(&si, 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))
{
WaitForSingleObject(ProcInfo.hProcess, INFINITE);

View file

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

View file

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

View file

@ -436,7 +436,8 @@ KeResumeThread(PKTHREAD Thread)
ULONG PreviousCount;
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 */
OldIrql = KeAcquireDispatcherDatabaseLock();

View file

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

View file

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

View file

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

View file

@ -288,8 +288,18 @@ PspExitThread(NTSTATUS ExitStatus)
//CmNotifyRunDown(CurrentThread);
/* 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);
MmDeleteTeb(CurrentProcess, Teb);
CurrentThread->Tcb.Teb = NULL;
@ -518,6 +528,23 @@ NtTerminateThread(IN HANDLE ThreadHandle,
NTSTATUS Status;
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 */
Status = ObReferenceObjectByHandle(ThreadHandle,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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