Moved a bunch of routines to kernel32.dll (with the help of
Dimitrie O. Paun).

diff --git a/scheduler/Makefile.in b/scheduler/Makefile.in
index b64b88a..a6f8003 100644
--- a/scheduler/Makefile.in
+++ b/scheduler/Makefile.in
@@ -8,14 +8,10 @@
 C_SRCS = \
 	client.c \
 	critsection.c \
-	debugger.c \
-	event.c \
 	handle.c \
-	mutex.c \
 	pipe.c \
 	process.c \
 	pthread.c \
-	semaphore.c \
 	services.c \
 	synchro.c \
 	sysdeps.c \
diff --git a/scheduler/critsection.c b/scheduler/critsection.c
index 9c223a7..dabc37c 100644
--- a/scheduler/critsection.c
+++ b/scheduler/critsection.c
@@ -34,7 +34,7 @@
 {
     /* let's assume that only one thread at a time will try to do this */
     HANDLE sem = crit->LockSemaphore;
-    if (!sem) sem = CreateSemaphoreA( NULL, 0, 1, NULL );
+    if (!sem) NtCreateSemaphore( &sem, SEMAPHORE_ALL_ACCESS, NULL, 0, 1 );
     crit->LockSemaphore = ConvertToGlobalHandle( sem );
 }
 
diff --git a/scheduler/debugger.c b/scheduler/debugger.c
deleted file mode 100644
index f3d5df6..0000000
--- a/scheduler/debugger.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Win32 debugger functions
- *
- * Copyright (C) 1999 Alexandre Julliard
- */
-
-#include <string.h>
-
-#include "winerror.h"
-#include "server.h"
-#include "debugtools.h"
-
-DEFAULT_DEBUG_CHANNEL(debugstr);
-
-
-/******************************************************************************
- *           WaitForDebugEvent   (KERNEL32.720)
- *
- * Waits for a debugging event to occur in a process being debugged
- *
- * PARAMS
- *    event   [I] Address of structure for event information
- *    timeout [I] Number of milliseconds to wait for event
- *
- * RETURNS STD
- */
-BOOL WINAPI WaitForDebugEvent( LPDEBUG_EVENT event, DWORD timeout )
-{
-    BOOL ret;
-    SERVER_START_REQ
-    {
-        debug_event_t *data;
-        struct wait_debug_event_request *req = server_alloc_req( sizeof(*req), sizeof(*data) );
-
-        req->timeout = timeout;
-        if (!(ret = !server_call( REQ_WAIT_DEBUG_EVENT ))) goto done;
-
-        if (!server_data_size(req))  /* timeout */
-        {
-            SetLastError( ERROR_SEM_TIMEOUT );
-            ret = FALSE;
-            goto done;
-        }
-        data = server_data_ptr(req);
-        event->dwDebugEventCode = data->code;
-        event->dwProcessId      = (DWORD)req->pid;
-        event->dwThreadId       = (DWORD)req->tid;
-        switch(data->code)
-        {
-        case EXCEPTION_DEBUG_EVENT:
-            event->u.Exception.ExceptionRecord = data->info.exception.record;
-            event->u.Exception.dwFirstChance   = data->info.exception.first;
-            break;
-        case CREATE_THREAD_DEBUG_EVENT:
-            event->u.CreateThread.hThread           = data->info.create_thread.handle;
-            event->u.CreateThread.lpThreadLocalBase = data->info.create_thread.teb;
-            event->u.CreateThread.lpStartAddress    = data->info.create_thread.start;
-            break;
-        case CREATE_PROCESS_DEBUG_EVENT:
-            event->u.CreateProcessInfo.hFile                 = data->info.create_process.file;
-            event->u.CreateProcessInfo.hProcess              = data->info.create_process.process;
-            event->u.CreateProcessInfo.hThread               = data->info.create_process.thread;
-            event->u.CreateProcessInfo.lpBaseOfImage         = data->info.create_process.base;
-            event->u.CreateProcessInfo.dwDebugInfoFileOffset = data->info.create_process.dbg_offset;
-            event->u.CreateProcessInfo.nDebugInfoSize        = data->info.create_process.dbg_size;
-            event->u.CreateProcessInfo.lpThreadLocalBase     = data->info.create_process.teb;
-            event->u.CreateProcessInfo.lpStartAddress        = data->info.create_process.start;
-            event->u.CreateProcessInfo.lpImageName           = data->info.create_process.name;
-            event->u.CreateProcessInfo.fUnicode              = data->info.create_process.unicode;
-            if (data->info.create_process.file == -1) event->u.CreateProcessInfo.hFile = 0;
-            break;
-        case EXIT_THREAD_DEBUG_EVENT:
-            event->u.ExitThread.dwExitCode = data->info.exit.exit_code;
-            break;
-        case EXIT_PROCESS_DEBUG_EVENT:
-            event->u.ExitProcess.dwExitCode = data->info.exit.exit_code;
-            break;
-        case LOAD_DLL_DEBUG_EVENT:
-            event->u.LoadDll.hFile                 = data->info.load_dll.handle;
-            event->u.LoadDll.lpBaseOfDll           = data->info.load_dll.base;
-            event->u.LoadDll.dwDebugInfoFileOffset = data->info.load_dll.dbg_offset;
-            event->u.LoadDll.nDebugInfoSize        = data->info.load_dll.dbg_size;
-            event->u.LoadDll.lpImageName           = data->info.load_dll.name;
-            event->u.LoadDll.fUnicode              = data->info.load_dll.unicode;
-            if (data->info.load_dll.handle == -1) event->u.LoadDll.hFile = 0;
-            break;
-        case UNLOAD_DLL_DEBUG_EVENT:
-            event->u.UnloadDll.lpBaseOfDll = data->info.unload_dll.base;
-            break;
-        case OUTPUT_DEBUG_STRING_EVENT:
-            event->u.DebugString.lpDebugStringData  = data->info.output_string.string;
-            event->u.DebugString.fUnicode           = data->info.output_string.unicode;
-            event->u.DebugString.nDebugStringLength = data->info.output_string.length;
-            break;
-        case RIP_EVENT:
-            event->u.RipInfo.dwError = data->info.rip_info.error;
-            event->u.RipInfo.dwType  = data->info.rip_info.type;
-            break;
-        default:
-            server_protocol_error( "WaitForDebugEvent: bad code %d\n", data->code );
-        }
-    done:
-    }
-    SERVER_END_REQ;
-    return ret;
-}
-
-
-/**********************************************************************
- *           ContinueDebugEvent   (KERNEL32.146)
- */
-BOOL WINAPI ContinueDebugEvent( DWORD pid, DWORD tid, DWORD status )
-{
-    BOOL ret;
-    SERVER_START_REQ
-    {
-        struct continue_debug_event_request *req = server_alloc_req( sizeof(*req), 0 );
-        req->pid    = (void *)pid;
-        req->tid    = (void *)tid;
-        req->status = status;
-        ret = !server_call( REQ_CONTINUE_DEBUG_EVENT );
-    }
-    SERVER_END_REQ;
-    return ret;
-}
-
-
-/**********************************************************************
- *           DebugActiveProcess   (KERNEL32.180)
- */
-BOOL WINAPI DebugActiveProcess( DWORD pid )
-{
-    BOOL ret;
-    SERVER_START_REQ
-    {
-        struct debug_process_request *req = server_alloc_req( sizeof(*req), 0 );
-        req->pid = (void *)pid;
-        ret = !server_call( REQ_DEBUG_PROCESS );
-    }
-    SERVER_END_REQ;
-    return ret;
-}
-
-
-/***********************************************************************
- *           OutputDebugStringA   (KERNEL32.548)
- */
-void WINAPI OutputDebugStringA( LPCSTR str )
-{
-    SERVER_START_REQ
-    {
-        struct output_debug_string_request *req = server_alloc_req( sizeof(*req), 0 );
-        req->string  = (void *)str;
-        req->unicode = 0;
-        req->length  = strlen(str) + 1;
-        server_call_noerr( REQ_OUTPUT_DEBUG_STRING );
-    }
-    SERVER_END_REQ;
-    WARN("%s\n", str);
-}
-
-
-/***********************************************************************
- *           OutputDebugStringW   (KERNEL32.549)
- */
-void WINAPI OutputDebugStringW( LPCWSTR str )
-{
-    SERVER_START_REQ
-    {
-        struct output_debug_string_request *req = server_alloc_req( sizeof(*req), 0 );
-        req->string  = (void *)str;
-        req->unicode = 1;
-        req->length  = (lstrlenW(str) + 1) * sizeof(WCHAR);
-        server_call_noerr( REQ_OUTPUT_DEBUG_STRING );
-    }
-    SERVER_END_REQ;
-    WARN("%s\n", debugstr_w(str));
-}
-
-
-/***********************************************************************
- *           OutputDebugString16   (KERNEL.115)
- */
-void WINAPI OutputDebugString16( LPCSTR str )
-{
-    OutputDebugStringA( str );
-}
-
-
-/***********************************************************************
- *           DebugBreak   (KERNEL32.181)
- */
-void WINAPI DebugBreak(void)
-{
-    DbgBreakPoint();
-}
-
-
-/***********************************************************************
- *           DebugBreak16   (KERNEL.203)
- */
-void WINAPI DebugBreak16( CONTEXT86 *context )
-{
-#ifdef __i386__
-    EXCEPTION_RECORD rec;
-
-    rec.ExceptionCode    = EXCEPTION_BREAKPOINT;
-    rec.ExceptionFlags   = 0;
-    rec.ExceptionRecord  = NULL;
-    rec.ExceptionAddress = GET_IP(context); 
-    rec.NumberParameters = 0;
-    NtRaiseException( &rec, context, TRUE );
-#endif  /* defined(__i386__) */
-}
-
-
-/***********************************************************************
- *           IsDebuggerPresent   (KERNEL32)
- */
-BOOL WINAPI IsDebuggerPresent(void)
-{
-    BOOL ret = FALSE;
-    SERVER_START_REQ
-    {
-        struct get_process_info_request *req = server_alloc_req( sizeof(*req), 0 );
-        req->handle = GetCurrentProcess();
-        if (!server_call( REQ_GET_PROCESS_INFO )) ret = req->debugged;
-    }
-    SERVER_END_REQ;
-    return ret;
-}
diff --git a/scheduler/event.c b/scheduler/event.c
deleted file mode 100644
index 7df111e..0000000
--- a/scheduler/event.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Win32 events
- *
- * Copyright 1998 Alexandre Julliard
- */
-
-#include <assert.h>
-#include <string.h>
-#include "winerror.h"
-#include "winnls.h"
-#include "wine/unicode.h"
-#include "syslevel.h"
-#include "server.h"
-
-
-/***********************************************************************
- *           CreateEventA    (KERNEL32.156)
- */
-HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
-                            BOOL initial_state, LPCSTR name )
-{
-    HANDLE ret;
-    DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
-    if (len >= MAX_PATH)
-    {
-        SetLastError( ERROR_FILENAME_EXCED_RANGE );
-        return 0;
-    }
-    SERVER_START_REQ
-    {
-        struct create_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
-
-        req->manual_reset = manual_reset;
-        req->initial_state = initial_state;
-        req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
-        if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
-        SetLastError(0);
-        server_call( REQ_CREATE_EVENT );
-        ret = req->handle;
-    }
-    SERVER_END_REQ;
-    if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
-    return ret;
-}
-
-
-/***********************************************************************
- *           CreateEventW    (KERNEL32.157)
- */
-HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
-                            BOOL initial_state, LPCWSTR name )
-{
-    HANDLE ret;
-    DWORD len = name ? strlenW(name) : 0;
-    if (len >= MAX_PATH)
-    {
-        SetLastError( ERROR_FILENAME_EXCED_RANGE );
-        return 0;
-    }
-    SERVER_START_REQ
-    {
-        struct create_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
-
-        req->manual_reset = manual_reset;
-        req->initial_state = initial_state;
-        req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
-        memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
-        SetLastError(0);
-        server_call( REQ_CREATE_EVENT );
-        ret = req->handle;
-    }
-    SERVER_END_REQ;
-    if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
-    return ret;
-}
-
-/***********************************************************************
- *           WIN16_CreateEvent    (KERNEL.457)
- */
-HANDLE WINAPI WIN16_CreateEvent( BOOL manual_reset, BOOL initial_state )
-{
-    return CreateEventA( NULL, manual_reset, initial_state, NULL );
-}
-
-
-/***********************************************************************
- *           OpenEventA    (KERNEL32.536)
- */
-HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name )
-{
-    HANDLE ret;
-    DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
-    if (len >= MAX_PATH)
-    {
-        SetLastError( ERROR_FILENAME_EXCED_RANGE );
-        return 0;
-    }
-    SERVER_START_REQ
-    {
-        struct open_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
-
-        req->access  = access;
-        req->inherit = inherit;
-        if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
-        server_call( REQ_OPEN_EVENT );
-        ret = req->handle;
-    }
-    SERVER_END_REQ;
-    if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
-    return ret;
-}
-
-
-/***********************************************************************
- *           OpenEventW    (KERNEL32.537)
- */
-HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name )
-{
-    HANDLE ret;
-    DWORD len = name ? strlenW(name) : 0;
-    if (len >= MAX_PATH)
-    {
-        SetLastError( ERROR_FILENAME_EXCED_RANGE );
-        return 0;
-    }
-    SERVER_START_REQ
-    {
-        struct open_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
-
-        req->access  = access;
-        req->inherit = inherit;
-        memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
-        server_call( REQ_OPEN_EVENT );
-        ret = req->handle;
-    }
-    SERVER_END_REQ;
-    if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
-    return ret;
-}
-
-
-/***********************************************************************
- *           EVENT_Operation
- *
- * Execute an event operation (set,reset,pulse).
- */
-static BOOL EVENT_Operation( HANDLE handle, enum event_op op )
-{
-    BOOL ret;
-    SERVER_START_REQ
-    {
-        struct event_op_request *req = server_alloc_req( sizeof(*req), 0 );
-        req->handle = handle;
-        req->op     = op;
-        ret = !server_call( REQ_EVENT_OP );
-    }
-    SERVER_END_REQ;
-    return ret;
-}
-
-
-/***********************************************************************
- *           PulseEvent    (KERNEL32.557)
- */
-BOOL WINAPI PulseEvent( HANDLE handle )
-{
-    return EVENT_Operation( handle, PULSE_EVENT );
-}
-
-
-/***********************************************************************
- *           SetEvent    (KERNEL32.644)
- */
-BOOL WINAPI SetEvent( HANDLE handle )
-{
-    return EVENT_Operation( handle, SET_EVENT );
-}
-
-
-/***********************************************************************
- *           ResetEvent    (KERNEL32.586)
- */
-BOOL WINAPI ResetEvent( HANDLE handle )
-{
-    return EVENT_Operation( handle, RESET_EVENT );
-}
-
-
-/***********************************************************************
- * NOTE: The Win95 VWin32_Event routines given below are really low-level
- *       routines implemented directly by VWin32. The user-mode libraries
- *       implement Win32 synchronisation routines on top of these low-level
- *       primitives. We do it the other way around here :-)
- */
-
-/***********************************************************************
- *       VWin32_EventCreate	(KERNEL.442)
- */
-HANDLE WINAPI VWin32_EventCreate(VOID)
-{
-    HANDLE hEvent = CreateEventA( NULL, FALSE, 0, NULL );
-    return ConvertToGlobalHandle( hEvent );
-}
-
-/***********************************************************************
- *       VWin32_EventDestroy	(KERNEL.443)
- */
-VOID WINAPI VWin32_EventDestroy(HANDLE event)
-{
-    CloseHandle( event );
-}
-
-/***********************************************************************
- *       VWin32_EventWait	(KERNEL.450) 
- */
-VOID WINAPI VWin32_EventWait(HANDLE event)
-{
-    SYSLEVEL_ReleaseWin16Lock();
-    WaitForSingleObject( event, INFINITE );
-    SYSLEVEL_RestoreWin16Lock();
-}
-
-/***********************************************************************
- *       VWin32_EventSet	(KERNEL.451)
- */
-VOID WINAPI VWin32_EventSet(HANDLE event)
-{
-    SetEvent( event );
-}
-
diff --git a/scheduler/mutex.c b/scheduler/mutex.c
deleted file mode 100644
index 0816d8d..0000000
--- a/scheduler/mutex.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Win32 mutexes
- *
- * Copyright 1998 Alexandre Julliard
- */
-
-#include <assert.h>
-#include <string.h>
-#include "winerror.h"
-#include "winnls.h"
-#include "wine/unicode.h"
-#include "server.h"
-
-
-/***********************************************************************
- *           CreateMutexA   (KERNEL32.166)
- */
-HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name )
-{
-    HANDLE ret;
-    DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
-    if (len >= MAX_PATH)
-    {
-        SetLastError( ERROR_FILENAME_EXCED_RANGE );
-        return 0;
-    }
-    SERVER_START_REQ
-    {
-        struct create_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
-
-        req->owned   = owner;
-        req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
-        if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
-        SetLastError(0);
-        server_call( REQ_CREATE_MUTEX );
-        ret = req->handle;
-    }
-    SERVER_END_REQ;
-    if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
-    return ret;
-}
-
-
-/***********************************************************************
- *           CreateMutexW   (KERNEL32.167)
- */
-HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name )
-{
-    HANDLE ret;
-    DWORD len = name ? strlenW(name) : 0;
-    if (len >= MAX_PATH)
-    {
-        SetLastError( ERROR_FILENAME_EXCED_RANGE );
-        return 0;
-    }
-    SERVER_START_REQ
-    {
-        struct create_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
-
-        req->owned   = owner;
-        req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
-        memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
-        SetLastError(0);
-        server_call( REQ_CREATE_MUTEX );
-        ret = req->handle;
-    }
-    SERVER_END_REQ;
-    if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
-    return ret;
-}
-
-
-/***********************************************************************
- *           OpenMutexA   (KERNEL32.541)
- */
-HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name )
-{
-    HANDLE ret;
-    DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
-    if (len >= MAX_PATH)
-    {
-        SetLastError( ERROR_FILENAME_EXCED_RANGE );
-        return 0;
-    }
-    SERVER_START_REQ
-    {
-        struct open_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
-
-        req->access  = access;
-        req->inherit = inherit;
-        if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
-        server_call( REQ_OPEN_MUTEX );
-        ret = req->handle;
-    }
-    SERVER_END_REQ;
-    if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
-    return ret;
-}
-
-
-/***********************************************************************
- *           OpenMutexW   (KERNEL32.542)
- */
-HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name )
-{
-    HANDLE ret;
-    DWORD len = name ? strlenW(name) : 0;
-    if (len >= MAX_PATH)
-    {
-        SetLastError( ERROR_FILENAME_EXCED_RANGE );
-        return 0;
-    }
-    SERVER_START_REQ
-    {
-        struct open_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
-
-        req->access  = access;
-        req->inherit = inherit;
-        memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
-        server_call( REQ_OPEN_MUTEX );
-        ret = req->handle;
-    }
-    SERVER_END_REQ;
-    if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
-    return ret;
-}
-
-
-/***********************************************************************
- *           ReleaseMutex   (KERNEL32.582)
- */
-BOOL WINAPI ReleaseMutex( HANDLE handle )
-{
-    BOOL ret;
-    SERVER_START_REQ
-    {
-        struct release_mutex_request *req = server_alloc_req( sizeof(*req), 0 );
-        req->handle = handle;
-        ret = !server_call( REQ_RELEASE_MUTEX );
-    }
-    SERVER_END_REQ;
-    return ret;
-}
diff --git a/scheduler/semaphore.c b/scheduler/semaphore.c
deleted file mode 100644
index 0a5fee4..0000000
--- a/scheduler/semaphore.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Win32 semaphores
- *
- * Copyright 1998 Alexandre Julliard
- */
-
-#include <assert.h>
-#include <string.h>
-#include "winerror.h"
-#include "winnls.h"
-#include "wine/unicode.h"
-#include "server.h"
-
-
-/***********************************************************************
- *           CreateSemaphoreA   (KERNEL32.174)
- */
-HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, LPCSTR name )
-{
-    HANDLE ret;
-    DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
-
-    /* Check parameters */
-
-    if ((max <= 0) || (initial < 0) || (initial > max))
-    {
-        SetLastError( ERROR_INVALID_PARAMETER );
-        return 0;
-    }
-    if (len >= MAX_PATH)
-    {
-        SetLastError( ERROR_FILENAME_EXCED_RANGE );
-        return 0;
-    }
-
-    SERVER_START_REQ
-    {
-        struct create_semaphore_request *req = server_alloc_req( sizeof(*req),
-                                                                 len * sizeof(WCHAR) );
-
-        req->initial = (unsigned int)initial;
-        req->max     = (unsigned int)max;
-        req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
-        if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
-        SetLastError(0);
-        server_call( REQ_CREATE_SEMAPHORE );
-        ret = req->handle;
-    }
-    SERVER_END_REQ;
-    if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
-    return ret;
-}
-
-
-/***********************************************************************
- *           CreateSemaphoreW   (KERNEL32.175)
- */
-HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
-                                    LONG max, LPCWSTR name )
-{
-    HANDLE ret;
-    DWORD len = name ? strlenW(name) : 0;
-
-    /* Check parameters */
-
-    if ((max <= 0) || (initial < 0) || (initial > max))
-    {
-        SetLastError( ERROR_INVALID_PARAMETER );
-        return 0;
-    }
-    if (len >= MAX_PATH)
-    {
-        SetLastError( ERROR_FILENAME_EXCED_RANGE );
-        return 0;
-    }
-
-    SERVER_START_REQ
-    {
-        struct create_semaphore_request *req = server_alloc_req( sizeof(*req),
-                                                                 len * sizeof(WCHAR) );
-
-        req->initial = (unsigned int)initial;
-        req->max     = (unsigned int)max;
-        req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
-        memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
-        SetLastError(0);
-        server_call( REQ_CREATE_SEMAPHORE );
-        ret = req->handle;
-    }
-    SERVER_END_REQ;
-    if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
-    return ret;
-}
-
-
-/***********************************************************************
- *           OpenSemaphoreA   (KERNEL32.545)
- */
-HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name )
-{
-    HANDLE ret;
-    DWORD len = name ? MultiByteToWideChar( CP_ACP, 0, name, strlen(name), NULL, 0 ) : 0;
-    if (len >= MAX_PATH)
-    {
-        SetLastError( ERROR_FILENAME_EXCED_RANGE );
-        return 0;
-    }
-    SERVER_START_REQ
-    {
-        struct open_semaphore_request *req = server_alloc_req( sizeof(*req),
-                                                               len * sizeof(WCHAR) );
-        req->access  = access;
-        req->inherit = inherit;
-        if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
-        server_call( REQ_OPEN_SEMAPHORE );
-        ret = req->handle;
-    }
-    SERVER_END_REQ;
-    if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
-    return ret;
-}
-
-
-/***********************************************************************
- *           OpenSemaphoreW   (KERNEL32.546)
- */
-HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name )
-{
-    HANDLE ret;
-    DWORD len = name ? strlenW(name) : 0;
-    if (len >= MAX_PATH)
-    {
-        SetLastError( ERROR_FILENAME_EXCED_RANGE );
-        return 0;
-    }
-    SERVER_START_REQ
-    {
-        struct open_semaphore_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
-        req->access  = access;
-        req->inherit = inherit;
-        memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
-        server_call( REQ_OPEN_SEMAPHORE );
-        ret = req->handle;
-    }
-    SERVER_END_REQ;
-    if (ret == -1) ret = 0; /* must return 0 on failure, not -1 */
-    return ret;
-}
-
-
-/***********************************************************************
- *           ReleaseSemaphore   (KERNEL32.583)
- */
-BOOL WINAPI ReleaseSemaphore( HANDLE handle, LONG count, LONG *previous )
-{
-    NTSTATUS status = NtReleaseSemaphore( handle, count, previous );
-    if (status) SetLastError( RtlNtStatusToDosError(status) );
-    return !status;
-}
diff --git a/scheduler/syslevel.c b/scheduler/syslevel.c
index 5a7523e..e6bb112 100644
--- a/scheduler/syslevel.c
+++ b/scheduler/syslevel.c
@@ -6,13 +6,14 @@
 
 #include <unistd.h>
 #include <sys/types.h>
+#include "ntddk.h"
 #include "syslevel.h"
 #include "heap.h"
 #include "selectors.h"
 #include "stackframe.h"
 #include "debugtools.h"
 
-DEFAULT_DEBUG_CHANNEL(win32)
+DEFAULT_DEBUG_CHANNEL(win32);
 
 static SYSLEVEL Win16Mutex;
 static SEGPTR segpWin16Mutex;
@@ -230,7 +231,7 @@
         {
             ERR("(%d): Holding lock of level %d!\n", 
                        level, i );
-            DebugBreak();
+            DbgBreakPoint();
             break;
         }
 }