2003-03-16 Casper S. Hornstrup <chorns@users.sourceforge.net>

* include/ntos/rtltypes.h (PRTL_BASE_PROCESS_START_ROUTINE): Define.
	* lib/kernel32/process/create.c (RtlBaseProcessStartRoutine): Import.
	(KlCreateFirstThread): Support images with native subsystem ID.
	* lib/ntdll/def/ntdll.def (RtlBaseProcessStartRoutine): Export.
	* lib/ntdll/def/ntdll.edf (RtlBaseProcessStartRoutine): Ditto.
	* lib/ntdll/rtl/exception.c (RtlBaseProcessStart): Forward declare.
	(RtlBaseProcessStartRoutine, RtlBaseProcessStart): Add.

svn path=/trunk/; revision=4317
This commit is contained in:
Casper Hornstrup 2003-03-16 14:16:54 +00:00
parent 4f23f4eae4
commit 77eee7ca44
6 changed files with 64 additions and 19 deletions

View file

@ -1,3 +1,13 @@
2003-03-16 Casper S. Hornstrup <chorns@users.sourceforge.net>
* include/ntos/rtltypes.h (PRTL_BASE_PROCESS_START_ROUTINE): Define.
* lib/kernel32/process/create.c (RtlBaseProcessStartRoutine): Import.
(KlCreateFirstThread): Support images with native subsystem ID.
* lib/ntdll/def/ntdll.def (RtlBaseProcessStartRoutine): Export.
* lib/ntdll/def/ntdll.edf (RtlBaseProcessStartRoutine): Ditto.
* lib/ntdll/rtl/exception.c (RtlBaseProcessStart): Forward declare.
(RtlBaseProcessStartRoutine, RtlBaseProcessStart): Add.
2003-03-16 Casper S. Hornstrup <chorns@users.sourceforge.net> 2003-03-16 Casper S. Hornstrup <chorns@users.sourceforge.net>
* include/defines.h (VS_FFI_SIGNATURE, VS_FFI_STRUCVERSION): Define. * include/defines.h (VS_FFI_SIGNATURE, VS_FFI_STRUCVERSION): Define.

View file

@ -1,4 +1,4 @@
/* $Id: rtltypes.h,v 1.3 2002/11/25 15:47:52 robd Exp $ /* $Id: rtltypes.h,v 1.4 2003/03/16 14:16:54 chorns Exp $
* *
*/ */
@ -220,4 +220,8 @@ typedef struct _RTL_MESSAGE_RESOURCE_DATA
RTL_MESSAGE_RESOURCE_BLOCK Blocks[1]; RTL_MESSAGE_RESOURCE_BLOCK Blocks[1];
} RTL_MESSAGE_RESOURCE_DATA, *PRTL_MESSAGE_RESOURCE_DATA; } RTL_MESSAGE_RESOURCE_DATA, *PRTL_MESSAGE_RESOURCE_DATA;
typedef VOID STDCALL
(*PRTL_BASE_PROCESS_START_ROUTINE)(PTHREAD_START_ROUTINE StartAddress,
PVOID Parameter);
#endif /* __DDK_RTLTYPES_H */ #endif /* __DDK_RTLTYPES_H */

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.62 2003/03/09 21:38:40 hbirr Exp $ /* $Id: create.c,v 1.63 2003/03/16 14:16:54 chorns Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -18,6 +18,9 @@
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
__declspec(dllimport)
PRTL_BASE_PROCESS_START_ROUTINE RtlBaseProcessStartRoutine;
WINBOOL STDCALL WINBOOL STDCALL
CreateProcessA (LPCSTR lpApplicationName, CreateProcessA (LPCSTR lpApplicationName,
LPSTR lpCommandLine, LPSTR lpCommandLine,
@ -217,8 +220,7 @@ BaseProcessStart(LPTHREAD_START_ROUTINE lpStartAddress,
HANDLE STDCALL HANDLE STDCALL
KlCreateFirstThread(HANDLE ProcessHandle, KlCreateFirstThread(HANDLE ProcessHandle,
LPSECURITY_ATTRIBUTES lpThreadAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes,
ULONG StackReserve, PSECTION_IMAGE_INFORMATION Sii,
ULONG StackCommit,
LPTHREAD_START_ROUTINE lpStartAddress, LPTHREAD_START_ROUTINE lpStartAddress,
DWORD dwCreationFlags, DWORD dwCreationFlags,
LPDWORD lpThreadId) LPDWORD lpThreadId)
@ -232,6 +234,7 @@ KlCreateFirstThread(HANDLE ProcessHandle,
BOOLEAN CreateSuspended = FALSE; BOOLEAN CreateSuspended = FALSE;
ULONG OldPageProtection; ULONG OldPageProtection;
ULONG ResultLength; ULONG ResultLength;
ULONG ThreadStartAddress;
ULONG InitialStack[6]; ULONG InitialStack[6];
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
@ -252,10 +255,10 @@ KlCreateFirstThread(HANDLE ProcessHandle,
else else
CreateSuspended = FALSE; CreateSuspended = FALSE;
InitialTeb.StackReserve = (StackReserve < 0x100000) ? 0x100000 : StackReserve; InitialTeb.StackReserve = (Sii->StackReserve < 0x100000) ? 0x100000 : Sii->StackReserve;
/* FIXME: use correct commit size */ /* FIXME: use correct commit size */
#if 0 #if 0
InitialTeb.StackCommit = (StackCommit < PAGE_SIZE) ? PAGE_SIZE : StackCommit; InitialTeb.StackCommit = (Sii->StackCommit < PAGE_SIZE) ? PAGE_SIZE : Sii->StackCommit;
#endif #endif
InitialTeb.StackCommit = InitialTeb.StackReserve - PAGE_SIZE; InitialTeb.StackCommit = InitialTeb.StackReserve - PAGE_SIZE;
@ -274,7 +277,7 @@ KlCreateFirstThread(HANDLE ProcessHandle,
{ {
DPRINT("Error reserving stack space!\n"); DPRINT("Error reserving stack space!\n");
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return(NULL); return(INVALID_HANDLE_VALUE);
} }
DPRINT("StackAllocate: %p ReserveSize: 0x%lX\n", DPRINT("StackAllocate: %p ReserveSize: 0x%lX\n",
@ -328,8 +331,17 @@ KlCreateFirstThread(HANDLE ProcessHandle,
return(INVALID_HANDLE_VALUE); return(INVALID_HANDLE_VALUE);
} }
if (Sii->Subsystem != IMAGE_SUBSYSTEM_NATIVE)
{
ThreadStartAddress = (ULONG) BaseProcessStart;
}
else
{
ThreadStartAddress = (ULONG) RtlBaseProcessStartRoutine;
}
memset(&ThreadContext,0,sizeof(CONTEXT)); memset(&ThreadContext,0,sizeof(CONTEXT));
ThreadContext.Eip = (ULONG)BaseProcessStart; ThreadContext.Eip = ThreadStartAddress;
ThreadContext.SegGs = USER_DS; ThreadContext.SegGs = USER_DS;
ThreadContext.SegFs = USER_DS; ThreadContext.SegFs = USER_DS;
ThreadContext.SegEs = USER_DS; ThreadContext.SegEs = USER_DS;
@ -738,7 +750,6 @@ CreateProcessW(LPCWSTR lpApplicationName,
TempCurrentDirectoryW); TempCurrentDirectoryW);
} }
/* /*
* Create a section for the executable * Create a section for the executable
*/ */
@ -1080,11 +1091,11 @@ CreateProcessW(LPCWSTR lpApplicationName,
/* /*
* Create the thread for the kernel * Create the thread for the kernel
*/ */
DPRINT("Creating thread for process\n"); DPRINT("Creating thread for process (EntryPoint = 0x%.08x)\n",
ImageBaseAddress + (ULONG)Sii.EntryPoint);
hThread = KlCreateFirstThread(hProcess, hThread = KlCreateFirstThread(hProcess,
lpThreadAttributes, lpThreadAttributes,
Sii.StackReserve, &Sii,
Sii.StackCommit,
ImageBaseAddress + (ULONG)Sii.EntryPoint, ImageBaseAddress + (ULONG)Sii.EntryPoint,
dwCreationFlags, dwCreationFlags,
&lpProcessInformation->dwThreadId); &lpProcessInformation->dwThreadId);

View file

@ -1,4 +1,4 @@
; $Id: ntdll.def,v 1.92 2003/02/16 18:54:26 hbirr Exp $ ; $Id: ntdll.def,v 1.93 2003/03/16 14:16:54 chorns Exp $
; ;
; ReactOS Operating System ; ReactOS Operating System
; ;
@ -302,6 +302,7 @@ RtlAreAnyAccessesGranted@8
RtlAreBitsClear@12 RtlAreBitsClear@12
RtlAreBitsSet@12 RtlAreBitsSet@12
RtlAssert@16 RtlAssert@16
RtlBaseProcessStartRoutine DATA
;RtlCaptureStackBackTrace ;RtlCaptureStackBackTrace
RtlCharToInteger@12 RtlCharToInteger@12
RtlCheckRegistryKey@8 RtlCheckRegistryKey@8

View file

@ -1,4 +1,4 @@
; $Id: ntdll.edf,v 1.81 2003/02/16 18:54:26 hbirr Exp $ ; $Id: ntdll.edf,v 1.82 2003/03/16 14:16:54 chorns Exp $
; ;
; ReactOS Operating System ; ReactOS Operating System
; ;
@ -302,6 +302,7 @@ RtlAreAnyAccessesGranted=RtlAreAnyAccessesGranted@8
RtlAreBitsClear=RtlAreBitsClear@12 RtlAreBitsClear=RtlAreBitsClear@12
RtlAreBitsSet=RtlAreBitsSet@12 RtlAreBitsSet=RtlAreBitsSet@12
RtlAssert=RtlAssert@16 RtlAssert=RtlAssert@16
RtlBaseProcessStartRoutine DATA
;RtlCaptureStackBackTrace ;RtlCaptureStackBackTrace
RtlCharToInteger=RtlCharToInteger@12 RtlCharToInteger=RtlCharToInteger@12
RtlCheckRegistryKey=RtlCheckRegistryKey@8 RtlCheckRegistryKey=RtlCheckRegistryKey@8

View file

@ -1,4 +1,4 @@
/* $Id: exception.c,v 1.11 2002/10/26 00:32:18 chorns Exp $ /* $Id: exception.c,v 1.12 2003/03/16 14:16:54 chorns Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -18,6 +18,13 @@
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
VOID STDCALL
RtlBaseProcessStart(PTHREAD_START_ROUTINE StartAddress,
PVOID Parameter);
__declspec(dllexport)
PRTL_BASE_PROCESS_START_ROUTINE RtlBaseProcessStartRoutine = RtlBaseProcessStart;
ULONG ULONG
RtlpDispatchException(IN PEXCEPTION_RECORD ExceptionRecord, RtlpDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
IN PCONTEXT Context); IN PCONTEXT Context);
@ -54,4 +61,15 @@ RtlRaiseException(PEXCEPTION_RECORD ExceptionRecord)
DbgPrint("RtlRaiseException()"); DbgPrint("RtlRaiseException()");
} }
VOID STDCALL
RtlBaseProcessStart(PTHREAD_START_ROUTINE StartAddress,
PVOID Parameter)
{
NTSTATUS ExitStatus = STATUS_SUCCESS;
ExitStatus = (NTSTATUS) (StartAddress)(Parameter);
NtTerminateProcess(NtCurrentProcess(), ExitStatus);
}
/* EOF */ /* EOF */