11 #include <ntdll/ntdll.h>
13 #include <rosrtl/thread.h>
16 RtlRosCreateUserThread
18 IN HANDLE ProcessHandle,
19 IN POBJECT_ATTRIBUTES ObjectAttributes,
20 IN BOOLEAN CreateSuspended,
21 IN LONG StackZeroBits,
22 IN OUT PULONG StackReserve OPTIONAL,
23 IN OUT PULONG StackCommit OPTIONAL,
24 IN PVOID StartAddress,
25 OUT PHANDLE ThreadHandle OPTIONAL,
26 OUT PCLIENT_ID ClientId OPTIONAL,
27 IN ULONG ParameterCount,
28 IN ULONG_PTR * Parameters
31 USER_STACK usUserStack;
32 CONTEXT ctxInitialContext;
35 CLIENT_ID cidClientId;
37 if(ThreadHandle == NULL) ThreadHandle = &hThread;
38 if(ClientId == NULL) ClientId = &cidClientId;
40 /* allocate the stack for the thread */
41 nErrCode = RtlRosCreateStack
51 if(!NT_SUCCESS(nErrCode)) goto l_Fail;
53 /* initialize the registers and stack for the thread */
54 nErrCode = RtlRosInitializeContext
65 if(!NT_SUCCESS(nErrCode)) goto l_Fail;
67 /* create the thread object */
68 nErrCode = NtCreateThread
81 if(!NT_SUCCESS(nErrCode)) goto l_Fail;
84 return STATUS_SUCCESS;
88 assert(!NT_SUCCESS(nErrCode));
90 /* deallocate the stack */
91 RtlRosDeleteStack(ProcessHandle, &usUserStack);
97 RtlRosCreateUserThreadVa
99 IN HANDLE ProcessHandle,
100 IN POBJECT_ATTRIBUTES ObjectAttributes,
101 IN BOOLEAN CreateSuspended,
102 IN LONG StackZeroBits,
103 IN OUT PULONG StackReserve OPTIONAL,
104 IN OUT PULONG StackCommit OPTIONAL,
105 IN PVOID StartAddress,
106 OUT PHANDLE ThreadHandle OPTIONAL,
107 OUT PCLIENT_ID ClientId OPTIONAL,
108 IN ULONG ParameterCount,
115 va_start(vaArgs, ParameterCount);
118 FIXME: this code makes several non-portable assumptions:
119 - all parameters are passed on the stack
120 - the stack is a contiguous array of cells as large as an ULONG_PTR
121 - the stack grows downwards
123 This happens to work on the Intel x86, but is likely to bomb horribly on most
126 nErrCode = RtlRosCreateUserThread