#define HIGH_PRIORITY 31
/* FUNCTIONS *****************************************************************/
-_SEH_FILTER(BaseThreadExceptionFilter)
+static
+LONG BaseThreadExceptionFilter(EXCEPTION_POINTERS * ExceptionInfo)
{
- EXCEPTION_POINTERS * ExceptionInfo = _SEH_GetExceptionPointers();
LONG ExceptionDisposition = EXCEPTION_EXECUTE_HANDLER;
if (GlobalTopLevelExceptionFilter != NULL)
{
- _SEH_TRY
+ _SEH2_TRY
{
ExceptionDisposition = GlobalTopLevelExceptionFilter(ExceptionInfo);
}
- _SEH_HANDLE
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
ExceptionDisposition = UnhandledExceptionFilter(ExceptionInfo);
}
- _SEH_END;
+ _SEH2_END;
}
return ExceptionDisposition;
__declspec(noreturn)
VOID
-STDCALL
+WINAPI
BaseThreadStartup(LPTHREAD_START_ROUTINE lpStartAddress,
LPVOID lpParameter)
{
volatile UINT uExitCode = 0;
/* Attempt to call the Thread Start Address */
- _SEH_TRY
+ _SEH2_TRY
{
/* Get the exit code from the Thread Start */
uExitCode = (lpStartAddress)((PVOID)lpParameter);
}
- _SEH_EXCEPT(BaseThreadExceptionFilter)
+ _SEH2_EXCEPT(BaseThreadExceptionFilter(_SEH2_GetExceptionInformation()))
{
/* Get the Exit code from the SEH Handler */
- uExitCode = _SEH_GetExceptionCode();
- } _SEH_END;
-
+ uExitCode = _SEH2_GetExceptionCode();
+ } _SEH2_END;
+
/* Exit the Thread */
ExitThread(uExitCode);
}
* @implemented
*/
HANDLE
-STDCALL
+WINAPI
CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes,
DWORD dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress,
* @implemented
*/
HANDLE
-STDCALL
+WINAPI
CreateRemoteThread(HANDLE hProcess,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
DWORD dwStackSize,
POBJECT_ATTRIBUTES ObjectAttributes;
HANDLE hThread;
ULONG Dummy;
-
+
DPRINT("CreateRemoteThread: hProcess: %ld dwStackSize: %ld lpStartAddress"
- ": %p lpParameter: %lx, dwCreationFlags: %lx\n", hProcess,
+ ": %p lpParameter: %lx, dwCreationFlags: %lx\n", hProcess,
dwStackSize, lpStartAddress, lpParameter, dwCreationFlags);
-
+
/* Clear the Context */
RtlZeroMemory(&Context, sizeof(CONTEXT));
-
+
/* Write PID */
ClientId.UniqueProcess = hProcess;
-
+
/* Create the Stack */
Status = BasepCreateStack(hProcess,
dwStackSize,
dwCreationFlags & STACK_SIZE_PARAM_IS_A_RESERVATION ?
dwStackSize : 0,
- &InitialTeb);
+ &InitialTeb);
if(!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return NULL;
}
-
+
/* Create Initial Context */
BasepInitializeContext(&Context,
lpParameter,
lpStartAddress,
InitialTeb.StackBase,
1);
-
+
/* initialize the attributes for the thread object */
ObjectAttributes = BasepConvertObjectAttributes(&LocalObjectAttributes,
lpThreadAttributes,
NULL);
-
+
/* Create the Kernel Thread Object */
Status = NtCreateThread(&hThread,
THREAD_ALL_ACCESS,
SetLastErrorByStatus(Status);
return NULL;
}
-
+
#ifdef SXS_SUPPORT_ENABLED
/* Are we in the same process? */
if (Process = NtCurrentProcess())
PTHREAD_BASIC_INFORMATION ThreadBasicInfo;
PACTIVATION_CONTEXT_BASIC_INFORMATION ActivationCtxInfo;
ULONG_PTR Cookie;
-
+
/* Get the TEB */
Status = NtQueryInformationThread(hThread,
ThreadBasicIformation,
&ThreadBasicInfo,
sizeof(ThreadBasicInfo),
NULL);
-
+
/* Allocate the Activation Context Stack */
Status = RtlAllocateActivationContextStack(&ActivationContextStack);
Teb = ThreadBasicInfo.TebBaseAddress;
-
+
/* Save it */
Teb->ActivationContextStackPointer = ActivationContextStack;
-
+
/* Query the Context */
Status = RtlQueryInformationActivationContext(1,
0,
&ActivationCtxInfo,
sizeof(ActivationCtxInfo),
NULL);
-
+
/* Does it need to be activated? */
if (!ActivationCtxInfo.hActCtx)
{
}
}
#endif
-
+
/* FIXME: Notify CSR */
/* Success */
if(lpThreadId) *lpThreadId = (DWORD)ClientId.UniqueThread;
-
+
/* Resume it if asked */
if (!(dwCreationFlags & CREATE_SUSPENDED))
{
NtResumeThread(hThread, &Dummy);
}
-
+
/* Return handle to thread */
return hThread;
}
* @implemented
*/
VOID
-STDCALL
+WINAPI
ExitThread(DWORD uExitCode)
{
NTSTATUS Status;
BOOLEAN LastThread;
-
+
/*
* Terminate process if this is the last thread
* of the current process
/* Notify DLLs and TLS Callbacks of termination */
LdrShutdownThread();
-
+
/* Tell the Kernel to free the Stack */
NtCurrentTeb()->FreeStackOnTermination = TRUE;
NtTerminateThread(NULL, uExitCode);
-
+
/* We will never reach this place. This silences the compiler */
ExitThread(uExitCode);
}
WINAPI
GetCurrentThreadId(VOID)
{
- return (DWORD)(NtCurrentTeb()->Cid).UniqueThread;
+ return (DWORD)(NtCurrentTeb()->ClientId).UniqueThread;
}
/*
SetThreadPriority(HANDLE hThread,
int nPriority)
{
- ULONG Prio = nPriority;
+ LONG Prio = nPriority;
NTSTATUS Status;
/* Check if values forcing saturation should be used */
Status = NtSetInformationThread(hThread,
ThreadBasePriority,
&Prio,
- sizeof(ULONG));
+ sizeof(LONG));
if (!NT_SUCCESS(Status))
{
/* Failure */
/*
* @implemented
*/
-BOOL STDCALL
+BOOL WINAPI
GetThreadSelectorEntry(IN HANDLE hThread,
IN DWORD dwSelector,
OUT LPLDT_ENTRY lpSelectorEntry)
/*
* @implemented
*/
-DWORD STDCALL
+DWORD WINAPI
GetProcessIdOfThread(HANDLE Thread)
{
THREAD_BASIC_INFORMATION ThreadBasic;
/*
* @implemented
*/
-DWORD STDCALL
+DWORD WINAPI
GetThreadId(HANDLE Thread)
{
THREAD_BASIC_INFORMATION ThreadBasic;
/*
* @unimplemented
*/
-LANGID STDCALL
+LANGID WINAPI
SetThreadUILanguage(WORD wReserved)
{
DPRINT1("SetThreadUILanguage(0x%4x) unimplemented!\n", wReserved);
/*
* @implemented
*/
-DWORD STDCALL
+DWORD WINAPI
QueueUserAPC(PAPCFUNC pfnAPC, HANDLE hThread, ULONG_PTR dwData)
{
NTSTATUS Status;
/*
* @implemented
*/
-BOOL STDCALL
+BOOL WINAPI
GetThreadIOPendingFlag(HANDLE hThread,
PBOOL lpIOIsPending)
{
/*
* @implemented
*/
-VOID STDCALL
+VOID WINAPI
Sleep(DWORD dwMilliseconds)
{
SleepEx(dwMilliseconds, FALSE);
/*
* @implemented
*/
-DWORD STDCALL
+DWORD WINAPI
SleepEx(DWORD dwMilliseconds,
BOOL bAlertable)
{
* @implemented
*/
BOOL
-STDCALL
+WINAPI
QueueUserWorkItem(
LPTHREAD_START_ROUTINE Function,
PVOID Context,
return TRUE;
}
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+RegisterWaitForSingleObject(
+ PHANDLE phNewWaitObject,
+ HANDLE hObject,
+ WAITORTIMERCALLBACK Callback,
+ PVOID Context,
+ ULONG dwMilliseconds,
+ ULONG dwFlags
+ )
+{
+ NTSTATUS Status = RtlRegisterWait( phNewWaitObject,
+ hObject,
+ Callback,
+ Context,
+ dwMilliseconds,
+ dwFlags );
+
+ if (Status != STATUS_SUCCESS)
+ {
+ SetLastError( RtlNtStatusToDosError(Status) );
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+/*
+ * @implemented
+ */
+HANDLE
+WINAPI
+RegisterWaitForSingleObjectEx(
+ HANDLE hObject,
+ WAITORTIMERCALLBACK Callback,
+ PVOID Context,
+ ULONG dwMilliseconds,
+ ULONG dwFlags
+ )
+{
+ NTSTATUS Status;
+ HANDLE hNewWaitObject;
+
+ Status = RtlRegisterWait( &hNewWaitObject,
+ hObject,
+ Callback,
+ Context,
+ dwMilliseconds,
+ dwFlags );
+
+ if (Status != STATUS_SUCCESS)
+ {
+ SetLastError( RtlNtStatusToDosError(Status) );
+ return NULL;
+ }
+ return hNewWaitObject;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+UnregisterWait(
+ HANDLE WaitHandle
+ )
+{
+ NTSTATUS Status = RtlDeregisterWaitEx( WaitHandle, NULL );
+ if (Status != STATUS_SUCCESS)
+ {
+ SetLastError( RtlNtStatusToDosError(Status) );
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+/*
+ * @implemented
+ */
+BOOL
+WINAPI
+UnregisterWaitEx(
+ HANDLE WaitHandle,
+ HANDLE CompletionEvent
+ )
+{
+ NTSTATUS Status = RtlDeregisterWaitEx( WaitHandle, CompletionEvent );
+ if (Status != STATUS_SUCCESS)
+ {
+ SetLastError( RtlNtStatusToDosError(Status) );
+ return FALSE;
+ }
+ return TRUE;
+}
+
/* EOF */