Commit 67a74999 authored by Alexandre Julliard's avatar Alexandre Julliard

New set of macros for server calls; makes requests without variable

part somewhat faster.
parent 505cf396
...@@ -33,13 +33,6 @@ static inline int is_string( DWORD type ) ...@@ -33,13 +33,6 @@ static inline int is_string( DWORD type )
return (type == REG_SZ) || (type == REG_EXPAND_SZ) || (type == REG_MULTI_SZ); return (type == REG_SZ) || (type == REG_EXPAND_SZ) || (type == REG_MULTI_SZ);
} }
/* do a server call without setting the last error code */
static inline int reg_server_call( enum request req )
{
unsigned int res = server_call_noerr( req );
if (res) res = RtlNtStatusToDosError(res);
return res;
}
/****************************************************************************** /******************************************************************************
* RegCreateKeyExW [ADVAPI32.@] * RegCreateKeyExW [ADVAPI32.@]
...@@ -1228,15 +1221,14 @@ LONG WINAPI RegLoadKeyW( HKEY hkey, LPCWSTR subkey, LPCWSTR filename ) ...@@ -1228,15 +1221,14 @@ LONG WINAPI RegLoadKeyW( HKEY hkey, LPCWSTR subkey, LPCWSTR filename )
goto done; goto done;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( load_registry, len )
{ {
struct load_registry_request *req = server_alloc_req( sizeof(*req), len );
req->hkey = hkey; req->hkey = hkey;
req->file = file; req->file = file;
memcpy( server_data_ptr(req), subkey, len ); memcpy( server_data_ptr(req), subkey, len );
ret = reg_server_call( REQ_LOAD_REGISTRY ); ret = RtlNtStatusToDosError( SERVER_CALL() );
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
CloseHandle( file ); CloseHandle( file );
done: done:
...@@ -1268,16 +1260,15 @@ LONG WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename ) ...@@ -1268,16 +1260,15 @@ LONG WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename )
goto done; goto done;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( load_registry, len )
{ {
struct load_registry_request *req = server_alloc_req( sizeof(*req), len );
req->hkey = hkey; req->hkey = hkey;
req->file = file; req->file = file;
MultiByteToWideChar( CP_ACP, 0, subkey, strlen(subkey), MultiByteToWideChar( CP_ACP, 0, subkey, strlen(subkey),
server_data_ptr(req), len/sizeof(WCHAR) ); server_data_ptr(req), len/sizeof(WCHAR) );
ret = reg_server_call( REQ_LOAD_REGISTRY ); ret = RtlNtStatusToDosError( SERVER_CALL() );
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
CloseHandle( file ); CloseHandle( file );
done: done:
...@@ -1321,12 +1312,11 @@ LONG WINAPI RegSaveKeyA( HKEY hkey, LPCSTR file, LPSECURITY_ATTRIBUTES sa ) ...@@ -1321,12 +1312,11 @@ LONG WINAPI RegSaveKeyA( HKEY hkey, LPCSTR file, LPSECURITY_ATTRIBUTES sa )
MESSAGE("Wow, we are already fiddling with a temp file %s with an ordinal as high as %d !\nYou might want to delete all corresponding temp files in that directory.\n", buffer, count); MESSAGE("Wow, we are already fiddling with a temp file %s with an ordinal as high as %d !\nYou might want to delete all corresponding temp files in that directory.\n", buffer, count);
} }
SERVER_START_REQ SERVER_START_REQ( save_registry )
{ {
struct save_registry_request *req = server_alloc_req( sizeof(*req), 0 );
req->hkey = hkey; req->hkey = hkey;
req->file = handle; req->file = handle;
ret = reg_server_call( REQ_SAVE_REGISTRY ); ret = RtlNtStatusToDosError( SERVER_CALL() );
} }
SERVER_END_REQ; SERVER_END_REQ;
......
...@@ -2072,11 +2072,10 @@ BOOL WINAPI GetCommMask( ...@@ -2072,11 +2072,10 @@ BOOL WINAPI GetCommMask(
TRACE("handle %d, mask %p\n", handle, evtmask); TRACE("handle %d, mask %p\n", handle, evtmask);
SERVER_START_REQ SERVER_START_REQ( get_serial_info )
{ {
struct get_serial_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
if ((ret = !server_call( REQ_GET_SERIAL_INFO ))) if ((ret = !SERVER_CALL_ERR()))
{ {
if (evtmask) *evtmask = req->eventmask; if (evtmask) *evtmask = req->eventmask;
} }
...@@ -2104,13 +2103,12 @@ BOOL WINAPI SetCommMask( ...@@ -2104,13 +2103,12 @@ BOOL WINAPI SetCommMask(
TRACE("handle %d, mask %lx\n", handle, evtmask); TRACE("handle %d, mask %lx\n", handle, evtmask);
SERVER_START_REQ SERVER_START_REQ( set_serial_info )
{ {
struct set_serial_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->flags = SERIALINFO_SET_MASK; req->flags = SERIALINFO_SET_MASK;
req->eventmask = evtmask; req->eventmask = evtmask;
ret = !server_call( REQ_SET_SERIAL_INFO ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -2677,11 +2675,10 @@ BOOL WINAPI GetCommTimeouts( ...@@ -2677,11 +2675,10 @@ BOOL WINAPI GetCommTimeouts(
return FALSE; return FALSE;
} }
SERVER_START_REQ SERVER_START_REQ( get_serial_info )
{ {
struct get_serial_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hComm; req->handle = hComm;
if ((ret = !server_call( REQ_GET_SERIAL_INFO ))) if ((ret = !SERVER_CALL_ERR()))
{ {
lptimeouts->ReadIntervalTimeout = req->readinterval; lptimeouts->ReadIntervalTimeout = req->readinterval;
lptimeouts->ReadTotalTimeoutMultiplier = req->readmult; lptimeouts->ReadTotalTimeoutMultiplier = req->readmult;
...@@ -2726,9 +2723,8 @@ BOOL WINAPI SetCommTimeouts( ...@@ -2726,9 +2723,8 @@ BOOL WINAPI SetCommTimeouts(
return FALSE; return FALSE;
} }
SERVER_START_REQ SERVER_START_REQ( set_serial_info )
{ {
struct set_serial_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hComm; req->handle = hComm;
req->flags = SERIALINFO_SET_TIMEOUTS; req->flags = SERIALINFO_SET_TIMEOUTS;
req->readinterval = lptimeouts->ReadIntervalTimeout ; req->readinterval = lptimeouts->ReadIntervalTimeout ;
...@@ -2736,7 +2732,7 @@ BOOL WINAPI SetCommTimeouts( ...@@ -2736,7 +2732,7 @@ BOOL WINAPI SetCommTimeouts(
req->readconst = lptimeouts->ReadTotalTimeoutConstant ; req->readconst = lptimeouts->ReadTotalTimeoutConstant ;
req->writemult = lptimeouts->WriteTotalTimeoutMultiplier ; req->writemult = lptimeouts->WriteTotalTimeoutMultiplier ;
req->writeconst = lptimeouts->WriteTotalTimeoutConstant ; req->writeconst = lptimeouts->WriteTotalTimeoutConstant ;
ret = !server_call( REQ_SET_SERIAL_INFO ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_REQ;
if (!ret) return FALSE; if (!ret) return FALSE;
...@@ -2886,10 +2882,8 @@ BOOL WINAPI WaitCommEvent( ...@@ -2886,10 +2882,8 @@ BOOL WINAPI WaitCommEvent(
lpov->OffsetHigh = 0; lpov->OffsetHigh = 0;
/* start an ASYNCHRONOUS WaitCommEvent */ /* start an ASYNCHRONOUS WaitCommEvent */
SERVER_START_REQ SERVER_START_REQ( create_async )
{ {
struct create_async_request *req = server_alloc_req( sizeof(*req), 0 );
req->file_handle = hFile; req->file_handle = hFile;
req->overlapped = lpov; req->overlapped = lpov;
req->buffer = lpdwEvents; req->buffer = lpdwEvents;
...@@ -2897,7 +2891,7 @@ BOOL WINAPI WaitCommEvent( ...@@ -2897,7 +2891,7 @@ BOOL WINAPI WaitCommEvent(
req->func = COMM_WaitCommEventService; req->func = COMM_WaitCommEventService;
req->type = ASYNC_TYPE_WAIT; req->type = ASYNC_TYPE_WAIT;
ret=server_call( REQ_CREATE_ASYNC ); ret=SERVER_CALL_ERR();
lpov->InternalHigh = req->ov_handle; lpov->InternalHigh = req->ov_handle;
} }
......
...@@ -36,13 +36,11 @@ BOOL WINAPI WaitForDebugEvent( ...@@ -36,13 +36,11 @@ BOOL WINAPI WaitForDebugEvent(
for (;;) for (;;)
{ {
HANDLE wait = 0; HANDLE wait = 0;
SERVER_START_REQ debug_event_t *data;
SERVER_START_VAR_REQ( wait_debug_event, sizeof(*data) )
{ {
debug_event_t *data;
struct wait_debug_event_request *req = server_alloc_req( sizeof(*req), sizeof(*data) );
req->get_handle = (timeout != 0); req->get_handle = (timeout != 0);
if (!(ret = !server_call( REQ_WAIT_DEBUG_EVENT ))) goto done; if (!(ret = !SERVER_CALL_ERR())) goto done;
if (!server_data_size(req)) /* timeout */ if (!server_data_size(req)) /* timeout */
{ {
...@@ -108,7 +106,7 @@ BOOL WINAPI WaitForDebugEvent( ...@@ -108,7 +106,7 @@ BOOL WINAPI WaitForDebugEvent(
} }
done: done:
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
if (ret) return TRUE; if (ret) return TRUE;
if (!wait) break; if (!wait) break;
res = WaitForSingleObject( wait, timeout ); res = WaitForSingleObject( wait, timeout );
...@@ -137,13 +135,12 @@ BOOL WINAPI ContinueDebugEvent( ...@@ -137,13 +135,12 @@ BOOL WINAPI ContinueDebugEvent(
DWORD status) /* [in] The rule to apply to unhandled exeptions. */ DWORD status) /* [in] The rule to apply to unhandled exeptions. */
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( continue_debug_event )
{ {
struct continue_debug_event_request *req = server_alloc_req( sizeof(*req), 0 );
req->pid = (void *)pid; req->pid = (void *)pid;
req->tid = (void *)tid; req->tid = (void *)tid;
req->status = status; req->status = status;
ret = !server_call( REQ_CONTINUE_DEBUG_EVENT ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -163,11 +160,10 @@ BOOL WINAPI DebugActiveProcess( ...@@ -163,11 +160,10 @@ BOOL WINAPI DebugActiveProcess(
DWORD pid) /* [in] The process to be debugged. */ DWORD pid) /* [in] The process to be debugged. */
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( debug_process )
{ {
struct debug_process_request *req = server_alloc_req( sizeof(*req), 0 );
req->pid = (void *)pid; req->pid = (void *)pid;
ret = !server_call( REQ_DEBUG_PROCESS ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -184,13 +180,12 @@ BOOL WINAPI DebugActiveProcess( ...@@ -184,13 +180,12 @@ BOOL WINAPI DebugActiveProcess(
void WINAPI OutputDebugStringA( void WINAPI OutputDebugStringA(
LPCSTR str) /* [in] The message to be logged and given to the debugger. */ LPCSTR str) /* [in] The message to be logged and given to the debugger. */
{ {
SERVER_START_REQ SERVER_START_REQ( output_debug_string )
{ {
struct output_debug_string_request *req = server_alloc_req( sizeof(*req), 0 );
req->string = (void *)str; req->string = (void *)str;
req->unicode = 0; req->unicode = 0;
req->length = strlen(str) + 1; req->length = strlen(str) + 1;
server_call_noerr( REQ_OUTPUT_DEBUG_STRING ); SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
WARN("%s\n", str); WARN("%s\n", str);
...@@ -206,13 +201,12 @@ void WINAPI OutputDebugStringA( ...@@ -206,13 +201,12 @@ void WINAPI OutputDebugStringA(
void WINAPI OutputDebugStringW( void WINAPI OutputDebugStringW(
LPCWSTR str) /* [in] The message to be logged and given to the debugger. */ LPCWSTR str) /* [in] The message to be logged and given to the debugger. */
{ {
SERVER_START_REQ SERVER_START_REQ( output_debug_string )
{ {
struct output_debug_string_request *req = server_alloc_req( sizeof(*req), 0 );
req->string = (void *)str; req->string = (void *)str;
req->unicode = 1; req->unicode = 1;
req->length = (lstrlenW(str) + 1) * sizeof(WCHAR); req->length = (lstrlenW(str) + 1) * sizeof(WCHAR);
server_call_noerr( REQ_OUTPUT_DEBUG_STRING ); SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
WARN("%s\n", debugstr_w(str)); WARN("%s\n", debugstr_w(str));
...@@ -282,11 +276,10 @@ void WINAPI DebugBreak16( ...@@ -282,11 +276,10 @@ void WINAPI DebugBreak16(
BOOL WINAPI IsDebuggerPresent(void) BOOL WINAPI IsDebuggerPresent(void)
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
SERVER_START_REQ SERVER_START_REQ( get_process_info )
{ {
struct get_process_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = GetCurrentProcess(); req->handle = GetCurrentProcess();
if (!server_call( REQ_GET_PROCESS_INFO )) ret = req->debugged; if (!SERVER_CALL_ERR()) ret = req->debugged;
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
......
...@@ -31,19 +31,17 @@ HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset, ...@@ -31,19 +31,17 @@ HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( create_event, len * sizeof(WCHAR) )
{ {
struct create_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->manual_reset = manual_reset; req->manual_reset = manual_reset;
req->initial_state = initial_state; req->initial_state = initial_state;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len ); if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0); SetLastError(0);
server_call( REQ_CREATE_EVENT ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -70,19 +68,17 @@ HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset, ...@@ -70,19 +68,17 @@ HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
SetLastError( ERROR_INVALID_PARAMETER); SetLastError( ERROR_INVALID_PARAMETER);
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( create_event, len * sizeof(WCHAR) )
{ {
struct create_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->manual_reset = manual_reset; req->manual_reset = manual_reset;
req->initial_state = initial_state; req->initial_state = initial_state;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) ); memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0); SetLastError(0);
server_call( REQ_CREATE_EVENT ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -108,17 +104,15 @@ HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name ) ...@@ -108,17 +104,15 @@ HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( open_event, len * sizeof(WCHAR) )
{ {
struct open_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access; req->access = access;
req->inherit = inherit; req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len ); if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_EVENT ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -135,17 +129,15 @@ HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name ) ...@@ -135,17 +129,15 @@ HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( open_event, len * sizeof(WCHAR) )
{ {
struct open_event_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access; req->access = access;
req->inherit = inherit; req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) ); memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_EVENT ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -158,12 +150,11 @@ HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name ) ...@@ -158,12 +150,11 @@ HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name )
static BOOL EVENT_Operation( HANDLE handle, enum event_op op ) static BOOL EVENT_Operation( HANDLE handle, enum event_op op )
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( event_op )
{ {
struct event_op_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->op = op; req->op = op;
ret = !server_call( REQ_EVENT_OP ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -257,18 +248,16 @@ HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name ) ...@@ -257,18 +248,16 @@ HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( create_mutex, len * sizeof(WCHAR) )
{ {
struct create_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->owned = owner; req->owned = owner;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len ); if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0); SetLastError(0);
server_call( REQ_CREATE_MUTEX ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -285,18 +274,16 @@ HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name ) ...@@ -285,18 +274,16 @@ HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( create_mutex, len * sizeof(WCHAR) )
{ {
struct create_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->owned = owner; req->owned = owner;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) ); memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0); SetLastError(0);
server_call( REQ_CREATE_MUTEX ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -318,17 +305,15 @@ HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name ) ...@@ -318,17 +305,15 @@ HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( open_mutex, len * sizeof(WCHAR) )
{ {
struct open_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access; req->access = access;
req->inherit = inherit; req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len ); if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_MUTEX ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -345,17 +330,15 @@ HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name ) ...@@ -345,17 +330,15 @@ HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( open_mutex, len * sizeof(WCHAR) )
{ {
struct open_mutex_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access; req->access = access;
req->inherit = inherit; req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) ); memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_MUTEX ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -366,11 +349,10 @@ HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name ) ...@@ -366,11 +349,10 @@ HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name )
BOOL WINAPI ReleaseMutex( HANDLE handle ) BOOL WINAPI ReleaseMutex( HANDLE handle )
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( release_mutex )
{ {
struct release_mutex_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
ret = !server_call( REQ_RELEASE_MUTEX ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -403,20 +385,17 @@ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, ...@@ -403,20 +385,17 @@ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max,
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( create_semaphore, len * sizeof(WCHAR) )
{ {
struct create_semaphore_request *req = server_alloc_req( sizeof(*req),
len * sizeof(WCHAR) );
req->initial = (unsigned int)initial; req->initial = (unsigned int)initial;
req->max = (unsigned int)max; req->max = (unsigned int)max;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len ); if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0); SetLastError(0);
server_call( REQ_CREATE_SEMAPHORE ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -443,20 +422,17 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial, ...@@ -443,20 +422,17 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( create_semaphore, len * sizeof(WCHAR) )
{ {
struct create_semaphore_request *req = server_alloc_req( sizeof(*req),
len * sizeof(WCHAR) );
req->initial = (unsigned int)initial; req->initial = (unsigned int)initial;
req->max = (unsigned int)max; req->max = (unsigned int)max;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) ); memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0); SetLastError(0);
server_call( REQ_CREATE_SEMAPHORE ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -473,17 +449,15 @@ HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name ) ...@@ -473,17 +449,15 @@ HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( open_semaphore, len * sizeof(WCHAR) )
{ {
struct open_semaphore_request *req = server_alloc_req( sizeof(*req),
len * sizeof(WCHAR) );
req->access = access; req->access = access;
req->inherit = inherit; req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len ); if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_SEMAPHORE ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -500,16 +474,15 @@ HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name ) ...@@ -500,16 +474,15 @@ HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( open_semaphore, len * sizeof(WCHAR) )
{ {
struct open_semaphore_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access; req->access = access;
req->inherit = inherit; req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) ); memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_SEMAPHORE ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
......
...@@ -202,13 +202,12 @@ HANDLE WINAPI CreateToolhelp32Snapshot( DWORD flags, DWORD process ) ...@@ -202,13 +202,12 @@ HANDLE WINAPI CreateToolhelp32Snapshot( DWORD flags, DWORD process )
} }
/* Now do the snapshot */ /* Now do the snapshot */
SERVER_START_REQ SERVER_START_REQ( create_snapshot )
{ {
struct create_snapshot_request *req = server_alloc_req( sizeof(*req), 0 );
req->flags = flags & ~TH32CS_INHERIT; req->flags = flags & ~TH32CS_INHERIT;
req->inherit = (flags & TH32CS_INHERIT) != 0; req->inherit = (flags & TH32CS_INHERIT) != 0;
req->pid = (void *)process; req->pid = (void *)process;
server_call( REQ_CREATE_SNAPSHOT ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_REQ;
...@@ -232,12 +231,11 @@ static BOOL TOOLHELP_Thread32Next( HANDLE handle, LPTHREADENTRY32 lpte, BOOL fir ...@@ -232,12 +231,11 @@ static BOOL TOOLHELP_Thread32Next( HANDLE handle, LPTHREADENTRY32 lpte, BOOL fir
ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(THREADENTRY32), lpte->dwSize); ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(THREADENTRY32), lpte->dwSize);
return FALSE; return FALSE;
} }
SERVER_START_REQ SERVER_START_REQ( next_thread )
{ {
struct next_thread_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->reset = first; req->reset = first;
if ((ret = !server_call( REQ_NEXT_THREAD ))) if ((ret = !SERVER_CALL_ERR()))
{ {
lpte->cntUsage = req->count; lpte->cntUsage = req->count;
lpte->th32ThreadID = (DWORD)req->tid; lpte->th32ThreadID = (DWORD)req->tid;
...@@ -286,12 +284,11 @@ static BOOL TOOLHELP_Process32Next( HANDLE handle, LPPROCESSENTRY32 lppe, BOOL f ...@@ -286,12 +284,11 @@ static BOOL TOOLHELP_Process32Next( HANDLE handle, LPPROCESSENTRY32 lppe, BOOL f
ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(PROCESSENTRY32), lppe->dwSize); ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(PROCESSENTRY32), lppe->dwSize);
return FALSE; return FALSE;
} }
SERVER_START_REQ SERVER_START_REQ( next_process )
{ {
struct next_process_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->reset = first; req->reset = first;
if ((ret = !server_call( REQ_NEXT_PROCESS ))) if ((ret = !SERVER_CALL_ERR()))
{ {
lppe->cntUsage = req->count; lppe->cntUsage = req->count;
lppe->th32ProcessID = (DWORD)req->pid; lppe->th32ProcessID = (DWORD)req->pid;
...@@ -345,12 +342,11 @@ static BOOL TOOLHELP_Module32Next( HANDLE handle, LPMODULEENTRY32 lpme, BOOL fir ...@@ -345,12 +342,11 @@ static BOOL TOOLHELP_Module32Next( HANDLE handle, LPMODULEENTRY32 lpme, BOOL fir
ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(MODULEENTRY32), lpme->dwSize); ERR("Result buffer too small (req: %d, was: %ld)\n", sizeof(MODULEENTRY32), lpme->dwSize);
return FALSE; return FALSE;
} }
SERVER_START_REQ SERVER_START_REQ( next_module )
{ {
struct next_module_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->reset = first; req->reset = first;
if ((ret = !server_call( REQ_NEXT_MODULE ))) if ((ret = !SERVER_CALL_ERR()))
{ {
lpme->th32ModuleID = 0; /* toolhelp internal id, never used */ lpme->th32ModuleID = 0; /* toolhelp internal id, never used */
lpme->th32ProcessID = (DWORD)req->pid; lpme->th32ProcessID = (DWORD)req->pid;
......
...@@ -112,33 +112,29 @@ static int send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *c ...@@ -112,33 +112,29 @@ static int send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *c
int ret; int ret;
HANDLE handle = 0; HANDLE handle = 0;
SERVER_START_REQ SERVER_START_VAR_REQ( queue_exception_event, sizeof(*rec)+sizeof(*context) )
{ {
struct queue_exception_event_request *req = server_alloc_req( sizeof(*req),
sizeof(*rec)+sizeof(*context) );
CONTEXT *context_ptr = server_data_ptr(req); CONTEXT *context_ptr = server_data_ptr(req);
EXCEPTION_RECORD *rec_ptr = (EXCEPTION_RECORD *)(context_ptr + 1); EXCEPTION_RECORD *rec_ptr = (EXCEPTION_RECORD *)(context_ptr + 1);
req->first = first_chance; req->first = first_chance;
*rec_ptr = *rec; *rec_ptr = *rec;
*context_ptr = *context; *context_ptr = *context;
if (!server_call_noerr( REQ_QUEUE_EXCEPTION_EVENT )) handle = req->handle; if (!SERVER_CALL()) handle = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
if (!handle) return 0; /* no debugger present or other error */ if (!handle) return 0; /* no debugger present or other error */
/* No need to wait on the handle since the process gets suspended /* No need to wait on the handle since the process gets suspended
* once the event is passed to the debugger, so when we get back * once the event is passed to the debugger, so when we get back
* here the event has been continued already. * here the event has been continued already.
*/ */
SERVER_START_REQ SERVER_START_VAR_REQ( get_exception_status, sizeof(*context) )
{ {
struct get_exception_status_request *req = server_alloc_req( sizeof(*req), sizeof(*context) );
req->handle = handle; req->handle = handle;
if (!server_call_noerr( REQ_GET_EXCEPTION_STATUS )) if (!SERVER_CALL()) *context = *(CONTEXT *)server_data_ptr(req);
*context = *(CONTEXT *)server_data_ptr(req);
ret = req->status; ret = req->status;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
NtClose( handle ); NtClose( handle );
return ret; return ret;
} }
......
...@@ -76,12 +76,11 @@ NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code ) ...@@ -76,12 +76,11 @@ NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
{ {
NTSTATUS ret; NTSTATUS ret;
BOOL self; BOOL self;
SERVER_START_REQ SERVER_START_REQ( terminate_process )
{ {
struct terminate_process_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->exit_code = exit_code; req->exit_code = exit_code;
ret = server_call_noerr( REQ_TERMINATE_PROCESS ); ret = SERVER_CALL();
self = !ret && req->self; self = !ret && req->self;
} }
SERVER_END_REQ; SERVER_END_REQ;
...@@ -150,12 +149,11 @@ NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code ) ...@@ -150,12 +149,11 @@ NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
NTSTATUS ret; NTSTATUS ret;
BOOL self, last; BOOL self, last;
SERVER_START_REQ SERVER_START_REQ( terminate_thread )
{ {
struct terminate_thread_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->exit_code = exit_code; req->exit_code = exit_code;
ret = server_call_noerr( REQ_TERMINATE_THREAD ); ret = SERVER_CALL();
self = !ret && req->self; self = !ret && req->self;
last = req->last; last = req->last;
} }
......
...@@ -1030,6 +1030,6 @@ debug_channels (aspi atom cdrom console ddraw debug delayhlp dll dosfs dosmem ...@@ -1030,6 +1030,6 @@ debug_channels (aspi atom cdrom console ddraw debug delayhlp dll dosfs dosmem
@ cdecl __wine_get_wmain_args(ptr) __wine_get_wmain_args @ cdecl __wine_get_wmain_args(ptr) __wine_get_wmain_args
# Server interface # Server interface
@ cdecl -norelay wine_server_call(long) wine_server_call @ cdecl -norelay wine_server_call(ptr long) wine_server_call
@ cdecl -norelay wine_server_alloc_req(long long) wine_server_alloc_req @ cdecl -norelay wine_server_alloc_req(ptr long) wine_server_alloc_req
@ cdecl -norelay __wine_server_exception_handler(ptr ptr ptr ptr) __wine_server_exception_handler @ cdecl -norelay __wine_server_exception_handler(ptr ptr ptr ptr) __wine_server_exception_handler
...@@ -217,11 +217,10 @@ NTSTATUS WINAPI NtDuplicateObject( ...@@ -217,11 +217,10 @@ NTSTATUS WINAPI NtDuplicateObject(
NTSTATUS WINAPI NtClose( HANDLE Handle ) NTSTATUS WINAPI NtClose( HANDLE Handle )
{ {
NTSTATUS ret; NTSTATUS ret;
SERVER_START_REQ SERVER_START_REQ( close_handle )
{ {
struct close_handle_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = Handle; req->handle = Handle;
ret = server_call_noerr( REQ_CLOSE_HANDLE ); ret = SERVER_CALL();
if (!ret && req->fd != -1) close( req->fd ); if (!ret && req->fd != -1) close( req->fd );
} }
SERVER_END_REQ; SERVER_END_REQ;
......
...@@ -67,9 +67,8 @@ NTSTATUS WINAPI NtCreateKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_AT ...@@ -67,9 +67,8 @@ NTSTATUS WINAPI NtCreateKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_AT
} }
if (!retkey) return STATUS_INVALID_PARAMETER; if (!retkey) return STATUS_INVALID_PARAMETER;
SERVER_START_REQ SERVER_START_VAR_REQ( create_key, len )
{ {
struct create_key_request *req = server_alloc_req( sizeof(*req), len );
WCHAR *data = server_data_ptr(req); WCHAR *data = server_data_ptr(req);
req->parent = attr->RootDirectory; req->parent = attr->RootDirectory;
...@@ -80,13 +79,13 @@ NTSTATUS WINAPI NtCreateKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_AT ...@@ -80,13 +79,13 @@ NTSTATUS WINAPI NtCreateKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_AT
*data++ = attr->ObjectName->Length; *data++ = attr->ObjectName->Length;
memcpy( data, attr->ObjectName->Buffer, attr->ObjectName->Length ); memcpy( data, attr->ObjectName->Buffer, attr->ObjectName->Length );
if (class) memcpy( (char *)data + attr->ObjectName->Length, class->Buffer, class->Length ); if (class) memcpy( (char *)data + attr->ObjectName->Length, class->Buffer, class->Length );
if (!(ret = server_call_noerr( REQ_CREATE_KEY ))) if (!(ret = SERVER_CALL()))
{ {
*retkey = req->hkey; *retkey = req->hkey;
if (dispos) *dispos = req->created ? REG_CREATED_NEW_KEY : REG_OPENED_EXISTING_KEY; if (dispos) *dispos = req->created ? REG_CREATED_NEW_KEY : REG_OPENED_EXISTING_KEY;
} }
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
TRACE("<- 0x%04x\n", *retkey); TRACE("<- 0x%04x\n", *retkey);
return ret; return ret;
} }
...@@ -110,16 +109,15 @@ NTSTATUS WINAPI NtOpenKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_ATTR ...@@ -110,16 +109,15 @@ NTSTATUS WINAPI NtOpenKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_ATTR
if (len > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW; if (len > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW;
if (!retkey) return STATUS_INVALID_PARAMETER; if (!retkey) return STATUS_INVALID_PARAMETER;
SERVER_START_REQ SERVER_START_VAR_REQ( open_key, len )
{ {
struct open_key_request *req = server_alloc_req( sizeof(*req), len );
req->parent = attr->RootDirectory; req->parent = attr->RootDirectory;
req->access = access; req->access = access;
memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len ); memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
ret = server_call_noerr( REQ_OPEN_KEY ); ret = SERVER_CALL();
*retkey = req->hkey; *retkey = req->hkey;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
TRACE("<- 0x%04x\n", *retkey); TRACE("<- 0x%04x\n", *retkey);
return ret; return ret;
} }
...@@ -135,11 +133,10 @@ NTSTATUS WINAPI NtDeleteKey( HANDLE hkey ) ...@@ -135,11 +133,10 @@ NTSTATUS WINAPI NtDeleteKey( HANDLE hkey )
TRACE( "(%x)\n", hkey ); TRACE( "(%x)\n", hkey );
SERVER_START_REQ SERVER_START_REQ( delete_key )
{ {
struct delete_key_request *req = server_alloc_req( sizeof(*req), 0 );
req->hkey = hkey; req->hkey = hkey;
ret = server_call_noerr( REQ_DELETE_KEY ); ret = SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -157,15 +154,13 @@ NTSTATUS WINAPI NtDeleteValueKey( HANDLE hkey, const UNICODE_STRING *name ) ...@@ -157,15 +154,13 @@ NTSTATUS WINAPI NtDeleteValueKey( HANDLE hkey, const UNICODE_STRING *name )
TRACE( "(0x%x,%s)\n", hkey, debugstr_us(name) ); TRACE( "(0x%x,%s)\n", hkey, debugstr_us(name) );
if (name->Length > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW; if (name->Length > MAX_NAME_LENGTH) return STATUS_BUFFER_OVERFLOW;
SERVER_START_REQ SERVER_START_VAR_REQ( delete_key_value, name->Length )
{ {
struct delete_key_value_request *req = server_alloc_req( sizeof(*req), name->Length );
req->hkey = hkey; req->hkey = hkey;
memcpy( server_data_ptr(req), name->Buffer, name->Length ); memcpy( server_data_ptr(req), name->Buffer, name->Length );
ret = server_call_noerr( REQ_DELETE_KEY_VALUE ); ret = SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -274,18 +269,17 @@ NTSTATUS WINAPI NtEnumerateKey( HANDLE handle, ULONG index, KEY_INFORMATION_CLAS ...@@ -274,18 +269,17 @@ NTSTATUS WINAPI NtEnumerateKey( HANDLE handle, ULONG index, KEY_INFORMATION_CLAS
/* -1 means query key, so avoid it here */ /* -1 means query key, so avoid it here */
if (index == (ULONG)-1) return STATUS_NO_MORE_ENTRIES; if (index == (ULONG)-1) return STATUS_NO_MORE_ENTRIES;
SERVER_START_REQ SERVER_START_VAR_REQ( enum_key, REQUEST_MAX_VAR_SIZE )
{ {
struct enum_key_request *req = server_alloc_req( sizeof(*req), REQUEST_MAX_VAR_SIZE );
req->hkey = handle; req->hkey = handle;
req->index = index; req->index = index;
req->full = (info_class == KeyFullInformation); req->full = (info_class == KeyFullInformation);
if (!(ret = server_call_noerr( REQ_ENUM_KEY ))) if (!(ret = SERVER_CALL()))
{ {
ret = fill_key_info( info_class, info, length, result_len, req ); ret = fill_key_info( info_class, info, length, result_len, req );
} }
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -299,18 +293,17 @@ NTSTATUS WINAPI NtQueryKey( HANDLE handle, KEY_INFORMATION_CLASS info_class, ...@@ -299,18 +293,17 @@ NTSTATUS WINAPI NtQueryKey( HANDLE handle, KEY_INFORMATION_CLASS info_class,
{ {
NTSTATUS ret; NTSTATUS ret;
SERVER_START_REQ SERVER_START_VAR_REQ( enum_key, REQUEST_MAX_VAR_SIZE )
{ {
struct enum_key_request *req = server_alloc_req( sizeof(*req), REQUEST_MAX_VAR_SIZE );
req->hkey = handle; req->hkey = handle;
req->index = -1; req->index = -1;
req->full = (info_class == KeyFullInformation); req->full = (info_class == KeyFullInformation);
if (!(ret = server_call_noerr( REQ_ENUM_KEY ))) if (!(ret = SERVER_CALL()))
{ {
ret = fill_key_info( info_class, info, length, result_len, req ); ret = fill_key_info( info_class, info, length, result_len, req );
} }
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -402,15 +395,13 @@ NTSTATUS WINAPI NtEnumerateValueKey( HANDLE handle, ULONG index, ...@@ -402,15 +395,13 @@ NTSTATUS WINAPI NtEnumerateValueKey( HANDLE handle, ULONG index,
if (name_ptr && !offset) reqlen += MAX_PATH*sizeof(WCHAR); if (name_ptr && !offset) reqlen += MAX_PATH*sizeof(WCHAR);
reqlen = min( reqlen, REQUEST_MAX_VAR_SIZE ); reqlen = min( reqlen, REQUEST_MAX_VAR_SIZE );
SERVER_START_REQ SERVER_START_VAR_REQ( enum_key_value, reqlen )
{ {
struct enum_key_value_request *req = server_alloc_req( sizeof(*req), reqlen );
req->hkey = handle; req->hkey = handle;
req->index = index; req->index = index;
req->offset = offset; req->offset = offset;
if (!(ret = server_call_noerr( REQ_ENUM_KEY_VALUE ))) if (!(ret = SERVER_CALL()))
{ {
size_t size = server_data_size(req) - sizeof(WCHAR); size_t size = server_data_size(req) - sizeof(WCHAR);
WCHAR *name = server_data_ptr(req); WCHAR *name = server_data_ptr(req);
...@@ -448,7 +439,7 @@ NTSTATUS WINAPI NtEnumerateValueKey( HANDLE handle, ULONG index, ...@@ -448,7 +439,7 @@ NTSTATUS WINAPI NtEnumerateValueKey( HANDLE handle, ULONG index,
total_len = req->len; total_len = req->len;
} }
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
if (ret) return ret; if (ret) return ret;
} while (data_len && data_ptr && offset < total_len); } while (data_len && data_ptr && offset < total_len);
...@@ -508,9 +499,8 @@ NTSTATUS WINAPI NtQueryValueKey( HANDLE handle, const UNICODE_STRING *name, ...@@ -508,9 +499,8 @@ NTSTATUS WINAPI NtQueryValueKey( HANDLE handle, const UNICODE_STRING *name,
size_t reqlen = min( data_len, REQUEST_MAX_VAR_SIZE ); size_t reqlen = min( data_len, REQUEST_MAX_VAR_SIZE );
reqlen = max( reqlen, name->Length + sizeof(WCHAR) ); reqlen = max( reqlen, name->Length + sizeof(WCHAR) );
SERVER_START_REQ SERVER_START_VAR_REQ( get_key_value, reqlen )
{ {
struct get_key_value_request *req = server_alloc_req( sizeof(*req), reqlen );
WCHAR *nameptr = server_data_ptr(req); WCHAR *nameptr = server_data_ptr(req);
req->hkey = handle; req->hkey = handle;
...@@ -518,7 +508,7 @@ NTSTATUS WINAPI NtQueryValueKey( HANDLE handle, const UNICODE_STRING *name, ...@@ -518,7 +508,7 @@ NTSTATUS WINAPI NtQueryValueKey( HANDLE handle, const UNICODE_STRING *name,
*nameptr++ = name->Length; *nameptr++ = name->Length;
memcpy( nameptr, name->Buffer, name->Length ); memcpy( nameptr, name->Buffer, name->Length );
if (!(ret = server_call_noerr( REQ_GET_KEY_VALUE ))) if (!(ret = SERVER_CALL()))
{ {
size_t size = min( server_data_size(req), data_len ); size_t size = min( server_data_size(req), data_len );
type = req->type; type = req->type;
...@@ -531,7 +521,7 @@ NTSTATUS WINAPI NtQueryValueKey( HANDLE handle, const UNICODE_STRING *name, ...@@ -531,7 +521,7 @@ NTSTATUS WINAPI NtQueryValueKey( HANDLE handle, const UNICODE_STRING *name,
} }
} }
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
if (ret) return ret; if (ret) return ret;
} while (data_len && offset < total_len); } while (data_len && offset < total_len);
...@@ -690,9 +680,8 @@ NTSTATUS WINAPI NtSetValueKey( HANDLE hkey, const UNICODE_STRING *name, ULONG Ti ...@@ -690,9 +680,8 @@ NTSTATUS WINAPI NtSetValueKey( HANDLE hkey, const UNICODE_STRING *name, ULONG Ti
ULONG len = count - pos; ULONG len = count - pos;
if (len > REQUEST_MAX_VAR_SIZE - namelen) len = REQUEST_MAX_VAR_SIZE - namelen; if (len > REQUEST_MAX_VAR_SIZE - namelen) len = REQUEST_MAX_VAR_SIZE - namelen;
SERVER_START_REQ SERVER_START_VAR_REQ( set_key_value, namelen + len )
{ {
struct set_key_value_request *req = server_alloc_req( sizeof(*req), namelen + len );
WCHAR *name_ptr = server_data_ptr(req); WCHAR *name_ptr = server_data_ptr(req);
req->hkey = hkey; req->hkey = hkey;
...@@ -703,9 +692,9 @@ NTSTATUS WINAPI NtSetValueKey( HANDLE hkey, const UNICODE_STRING *name, ULONG Ti ...@@ -703,9 +692,9 @@ NTSTATUS WINAPI NtSetValueKey( HANDLE hkey, const UNICODE_STRING *name, ULONG Ti
memcpy( name_ptr, name->Buffer, name->Length ); memcpy( name_ptr, name->Buffer, name->Length );
memcpy( (char *)name_ptr + name->Length, (char *)data + pos, len ); memcpy( (char *)name_ptr + name->Length, (char *)data + pos, len );
pos += len; pos += len;
ret = server_call_noerr( REQ_SET_KEY_VALUE ); ret = SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
} while (!ret && pos < count); } while (!ret && pos < count);
return ret; return ret;
} }
......
...@@ -36,17 +36,16 @@ NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle, ...@@ -36,17 +36,16 @@ NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle,
if ((MaximumCount <= 0) || (InitialCount < 0) || (InitialCount > MaximumCount)) if ((MaximumCount <= 0) || (InitialCount < 0) || (InitialCount > MaximumCount))
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
SERVER_START_REQ SERVER_START_VAR_REQ( create_semaphore, len )
{ {
struct create_semaphore_request *req = server_alloc_req( sizeof(*req), len );
req->initial = InitialCount; req->initial = InitialCount;
req->max = MaximumCount; req->max = MaximumCount;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT); req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len ); if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
ret = server_call_noerr( REQ_CREATE_SEMAPHORE ); ret = SERVER_CALL();
*SemaphoreHandle = req->handle; *SemaphoreHandle = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -60,16 +59,15 @@ NTSTATUS WINAPI NtOpenSemaphore( OUT PHANDLE SemaphoreHandle, ...@@ -60,16 +59,15 @@ NTSTATUS WINAPI NtOpenSemaphore( OUT PHANDLE SemaphoreHandle,
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0; DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS ret; NTSTATUS ret;
SERVER_START_REQ SERVER_START_VAR_REQ( open_semaphore, len )
{ {
struct open_semaphore_request *req = server_alloc_req( sizeof(*req), len );
req->access = access; req->access = access;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT); req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len ); if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
ret = server_call_noerr( REQ_OPEN_SEMAPHORE ); ret = SERVER_CALL();
*SemaphoreHandle = req->handle; *SemaphoreHandle = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -94,12 +92,11 @@ NTSTATUS WINAPI NtQuerySemaphore( ...@@ -94,12 +92,11 @@ NTSTATUS WINAPI NtQuerySemaphore(
NTSTATUS WINAPI NtReleaseSemaphore( HANDLE handle, ULONG count, PULONG previous ) NTSTATUS WINAPI NtReleaseSemaphore( HANDLE handle, ULONG count, PULONG previous )
{ {
NTSTATUS ret; NTSTATUS ret;
SERVER_START_REQ SERVER_START_REQ( release_semaphore )
{ {
struct release_semaphore_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->count = count; req->count = count;
if (!(ret = server_call_noerr( REQ_RELEASE_SEMAPHORE ))) if (!(ret = SERVER_CALL()))
{ {
if (previous) *previous = req->prev_count; if (previous) *previous = req->prev_count;
} }
...@@ -125,17 +122,16 @@ NTSTATUS WINAPI NtCreateEvent( ...@@ -125,17 +122,16 @@ NTSTATUS WINAPI NtCreateEvent(
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0; DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS ret; NTSTATUS ret;
SERVER_START_REQ SERVER_START_VAR_REQ( create_event, len )
{ {
struct create_event_request *req = server_alloc_req( sizeof(*req), len );
req->manual_reset = ManualReset; req->manual_reset = ManualReset;
req->initial_state = InitialState; req->initial_state = InitialState;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT); req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len ); if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
ret = server_call_noerr( REQ_CREATE_EVENT ); ret = SERVER_CALL();
*EventHandle = req->handle; *EventHandle = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -150,17 +146,15 @@ NTSTATUS WINAPI NtOpenEvent( ...@@ -150,17 +146,15 @@ NTSTATUS WINAPI NtOpenEvent(
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0; DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
NTSTATUS ret; NTSTATUS ret;
SERVER_START_REQ SERVER_START_VAR_REQ( open_event, len )
{ {
struct open_event_request *req = server_alloc_req( sizeof(*req), len );
req->access = DesiredAccess; req->access = DesiredAccess;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT); req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len ); if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
ret = server_call_noerr( REQ_OPEN_EVENT ); ret = SERVER_CALL();
*EventHandle = req->handle; *EventHandle = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -174,12 +168,11 @@ NTSTATUS WINAPI NtSetEvent( HANDLE handle, PULONG NumberOfThreadsReleased ) ...@@ -174,12 +168,11 @@ NTSTATUS WINAPI NtSetEvent( HANDLE handle, PULONG NumberOfThreadsReleased )
/* FIXME: set NumberOfThreadsReleased */ /* FIXME: set NumberOfThreadsReleased */
SERVER_START_REQ SERVER_START_REQ( event_op )
{ {
struct event_op_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->op = SET_EVENT; req->op = SET_EVENT;
ret = server_call_noerr( REQ_EVENT_OP ); ret = SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -195,12 +188,11 @@ NTSTATUS WINAPI NtResetEvent( HANDLE handle, PULONG NumberOfThreadsReleased ) ...@@ -195,12 +188,11 @@ NTSTATUS WINAPI NtResetEvent( HANDLE handle, PULONG NumberOfThreadsReleased )
/* resetting an event can't release any thread... */ /* resetting an event can't release any thread... */
if (NumberOfThreadsReleased) *NumberOfThreadsReleased = 0; if (NumberOfThreadsReleased) *NumberOfThreadsReleased = 0;
SERVER_START_REQ SERVER_START_REQ( event_op )
{ {
struct event_op_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->op = RESET_EVENT; req->op = RESET_EVENT;
ret = server_call_noerr( REQ_EVENT_OP ); ret = SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -227,12 +219,11 @@ NTSTATUS WINAPI NtPulseEvent( HANDLE handle, PULONG PulseCount ) ...@@ -227,12 +219,11 @@ NTSTATUS WINAPI NtPulseEvent( HANDLE handle, PULONG PulseCount )
{ {
NTSTATUS ret; NTSTATUS ret;
FIXME("(0x%08x,%p)\n", handle, PulseCount); FIXME("(0x%08x,%p)\n", handle, PulseCount);
SERVER_START_REQ SERVER_START_REQ( event_op )
{ {
struct event_op_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->op = PULSE_EVENT; req->op = PULSE_EVENT;
ret = server_call_noerr( REQ_EVENT_OP ); ret = SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
......
...@@ -206,17 +206,16 @@ static int _px_tcp_ops[] = { ...@@ -206,17 +206,16 @@ static int _px_tcp_ops[] = {
0 0
}; };
/* we need a special routine to handle WSA* errors */ /* set last error code from NT status without mapping WSA errors */
static inline int sock_server_call( enum request req ) inline static unsigned int set_error( unsigned int err )
{ {
unsigned int res = server_call_noerr( req ); if (err)
if (res)
{ {
/* do not map WSA errors */ /* do not map WSA errors */
if ((res < WSABASEERR) || (res >= 0x10000000)) res = RtlNtStatusToDosError(res); if ((err < WSABASEERR) || (err >= 0x10000000)) err = RtlNtStatusToDosError(err);
SetLastError( res ); SetLastError( err );
} }
return res; return err;
} }
static char* check_buffer(int size); static char* check_buffer(int size);
...@@ -232,15 +231,13 @@ static int _get_sock_fd(SOCKET s) ...@@ -232,15 +231,13 @@ static int _get_sock_fd(SOCKET s)
static void _enable_event(SOCKET s, unsigned int event, static void _enable_event(SOCKET s, unsigned int event,
unsigned int sstate, unsigned int cstate) unsigned int sstate, unsigned int cstate)
{ {
SERVER_START_REQ SERVER_START_REQ( enable_socket_event )
{ {
struct enable_socket_event_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = s; req->handle = s;
req->mask = event; req->mask = event;
req->sstate = sstate; req->sstate = sstate;
req->cstate = cstate; req->cstate = cstate;
sock_server_call( REQ_ENABLE_SOCKET_EVENT ); SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
} }
...@@ -248,15 +245,13 @@ static void _enable_event(SOCKET s, unsigned int event, ...@@ -248,15 +245,13 @@ static void _enable_event(SOCKET s, unsigned int event,
static int _is_blocking(SOCKET s) static int _is_blocking(SOCKET s)
{ {
int ret; int ret;
SERVER_START_REQ SERVER_START_REQ( get_socket_event )
{ {
struct get_socket_event_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = s; req->handle = s;
req->service = FALSE; req->service = FALSE;
req->s_event = 0; req->s_event = 0;
req->c_event = 0; req->c_event = 0;
sock_server_call( REQ_GET_SOCKET_EVENT ); SERVER_CALL();
ret = (req->state & WS_FD_NONBLOCKING) == 0; ret = (req->state & WS_FD_NONBLOCKING) == 0;
} }
SERVER_END_REQ; SERVER_END_REQ;
...@@ -266,15 +261,13 @@ static int _is_blocking(SOCKET s) ...@@ -266,15 +261,13 @@ static int _is_blocking(SOCKET s)
static unsigned int _get_sock_mask(SOCKET s) static unsigned int _get_sock_mask(SOCKET s)
{ {
unsigned int ret; unsigned int ret;
SERVER_START_REQ SERVER_START_REQ( get_socket_event )
{ {
struct get_socket_event_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = s; req->handle = s;
req->service = FALSE; req->service = FALSE;
req->s_event = 0; req->s_event = 0;
req->c_event = 0; req->c_event = 0;
sock_server_call( REQ_GET_SOCKET_EVENT ); SERVER_CALL();
ret = req->mask; ret = req->mask;
} }
SERVER_END_REQ; SERVER_END_REQ;
...@@ -291,18 +284,16 @@ static void _sync_sock_state(SOCKET s) ...@@ -291,18 +284,16 @@ static void _sync_sock_state(SOCKET s)
static int _get_sock_error(SOCKET s, unsigned int bit) static int _get_sock_error(SOCKET s, unsigned int bit)
{ {
int ret; int ret;
SERVER_START_REQ SERVER_START_VAR_REQ( get_socket_event, FD_MAX_EVENTS*sizeof(int) )
{ {
struct get_socket_event_request *req = server_alloc_req( sizeof(*req),
FD_MAX_EVENTS*sizeof(int) );
req->handle = s; req->handle = s;
req->service = FALSE; req->service = FALSE;
req->s_event = 0; req->s_event = 0;
req->c_event = 0; req->c_event = 0;
sock_server_call( REQ_GET_SOCKET_EVENT ); SERVER_CALL();
ret = *((int *)server_data_ptr(req) + bit); ret = *((int *)server_data_ptr(req) + bit);
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -777,14 +768,12 @@ SOCKET WINAPI WSOCK32_accept(SOCKET s, struct sockaddr *addr, ...@@ -777,14 +768,12 @@ SOCKET WINAPI WSOCK32_accept(SOCKET s, struct sockaddr *addr,
/* FIXME: care about the error? */ /* FIXME: care about the error? */
} }
close(fd); close(fd);
SERVER_START_REQ SERVER_START_REQ( accept_socket )
{ {
struct accept_socket_request *req = server_alloc_req( sizeof(*req), 0 );
req->lhandle = s; req->lhandle = s;
req->access = GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE; req->access = GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE;
req->inherit = TRUE; req->inherit = TRUE;
sock_server_call( REQ_ACCEPT_SOCKET ); set_error( SERVER_CALL() );
as = (SOCKET)req->handle; as = (SOCKET)req->handle;
} }
SERVER_END_REQ; SERVER_END_REQ;
...@@ -2138,15 +2127,14 @@ SOCKET WINAPI WSOCK32_socket(INT af, INT type, INT protocol) ...@@ -2138,15 +2127,14 @@ SOCKET WINAPI WSOCK32_socket(INT af, INT type, INT protocol)
default: SetLastError(WSAEPROTOTYPE); return INVALID_SOCKET; default: SetLastError(WSAEPROTOTYPE); return INVALID_SOCKET;
} }
SERVER_START_REQ SERVER_START_REQ( create_socket )
{ {
struct create_socket_request *req = server_alloc_req( sizeof(*req), 0 );
req->family = af; req->family = af;
req->type = type; req->type = type;
req->protocol = protocol; req->protocol = protocol;
req->access = GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE; req->access = GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE;
req->inherit = TRUE; req->inherit = TRUE;
sock_server_call( REQ_CREATE_SOCKET ); set_error( SERVER_CALL() );
ret = (SOCKET)req->handle; ret = (SOCKET)req->handle;
} }
SERVER_END_REQ; SERVER_END_REQ;
...@@ -2510,19 +2498,19 @@ int WINAPI WSAEnumNetworkEvents(SOCKET s, WSAEVENT hEvent, LPWSANETWORKEVENTS lp ...@@ -2510,19 +2498,19 @@ int WINAPI WSAEnumNetworkEvents(SOCKET s, WSAEVENT hEvent, LPWSANETWORKEVENTS lp
TRACE("%08x, hEvent %08x, lpEvent %08x\n", s, hEvent, (unsigned)lpEvent ); TRACE("%08x, hEvent %08x, lpEvent %08x\n", s, hEvent, (unsigned)lpEvent );
SERVER_START_REQ SERVER_START_VAR_REQ( get_socket_event, sizeof(lpEvent->iErrorCode) )
{ {
struct get_socket_event_request *req = server_alloc_req( sizeof(*req),
sizeof(lpEvent->iErrorCode) );
req->handle = s; req->handle = s;
req->service = TRUE; req->service = TRUE;
req->s_event = 0; req->s_event = 0;
req->c_event = hEvent; req->c_event = hEvent;
ret = sock_server_call( REQ_GET_SOCKET_EVENT ); if (!(ret = SERVER_CALL()))
lpEvent->lNetworkEvents = req->pmask; {
memcpy(lpEvent->iErrorCode, server_data_ptr(req), server_data_size(req) ); lpEvent->lNetworkEvents = req->pmask;
memcpy(lpEvent->iErrorCode, server_data_ptr(req), server_data_size(req) );
}
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
if (!ret) return 0; if (!ret) return 0;
SetLastError(WSAEINVAL); SetLastError(WSAEINVAL);
return SOCKET_ERROR; return SOCKET_ERROR;
...@@ -2537,13 +2525,12 @@ int WINAPI WSAEventSelect(SOCKET s, WSAEVENT hEvent, LONG lEvent) ...@@ -2537,13 +2525,12 @@ int WINAPI WSAEventSelect(SOCKET s, WSAEVENT hEvent, LONG lEvent)
TRACE("%08x, hEvent %08x, event %08x\n", s, hEvent, (unsigned)lEvent ); TRACE("%08x, hEvent %08x, event %08x\n", s, hEvent, (unsigned)lEvent );
SERVER_START_REQ SERVER_START_REQ( set_socket_event )
{ {
struct set_socket_event_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = s; req->handle = s;
req->mask = lEvent; req->mask = lEvent;
req->event = hEvent; req->event = hEvent;
ret = sock_server_call( REQ_SET_SOCKET_EVENT ); ret = SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
if (!ret) return 0; if (!ret) return 0;
...@@ -2563,18 +2550,17 @@ VOID CALLBACK WINSOCK_DoAsyncEvent( ULONG_PTR ptr ) ...@@ -2563,18 +2550,17 @@ VOID CALLBACK WINSOCK_DoAsyncEvent( ULONG_PTR ptr )
TRACE("socket %08x, event %08x\n", info->sock, info->event); TRACE("socket %08x, event %08x\n", info->sock, info->event);
SetLastError(0); SetLastError(0);
SERVER_START_REQ SERVER_START_VAR_REQ( get_socket_event, sizeof(errors) )
{ {
struct get_socket_event_request *req = server_alloc_req( sizeof(*req), sizeof(errors) );
req->handle = info->sock; req->handle = info->sock;
req->service = TRUE; req->service = TRUE;
req->s_event = info->event; /* <== avoid race conditions */ req->s_event = info->event; /* <== avoid race conditions */
req->c_event = info->event; req->c_event = info->event;
sock_server_call( REQ_GET_SOCKET_EVENT ); set_error( SERVER_CALL() );
pmask = req->pmask; pmask = req->pmask;
memcpy( errors, server_data_ptr(req), server_data_size(req) ); memcpy( errors, server_data_ptr(req), server_data_size(req) );
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
if ( (GetLastError() == WSAENOTSOCK) || (GetLastError() == WSAEINVAL) ) if ( (GetLastError() == WSAENOTSOCK) || (GetLastError() == WSAEINVAL) )
{ {
/* orphaned event (socket closed or something) */ /* orphaned event (socket closed or something) */
......
...@@ -32,12 +32,11 @@ HANDLE WINAPI FindFirstChangeNotificationA( LPCSTR lpPathName, BOOL bWatchSubtre ...@@ -32,12 +32,11 @@ HANDLE WINAPI FindFirstChangeNotificationA( LPCSTR lpPathName, BOOL bWatchSubtre
FIXME("this is not supported yet (non-trivial).\n"); FIXME("this is not supported yet (non-trivial).\n");
SERVER_START_REQ SERVER_START_REQ( create_change_notification )
{ {
struct create_change_notification_request *req = server_alloc_req( sizeof(*req), 0 );
req->subtree = bWatchSubtree; req->subtree = bWatchSubtree;
req->filter = dwNotifyFilter; req->filter = dwNotifyFilter;
if (!server_call( REQ_CREATE_CHANGE_NOTIFICATION )) ret = req->handle; if (!SERVER_CALL_ERR()) ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
......
...@@ -675,12 +675,10 @@ const DOS_DEVICE *DOSFS_GetDevice( const char *name ) ...@@ -675,12 +675,10 @@ const DOS_DEVICE *DOSFS_GetDevice( const char *name )
const DOS_DEVICE *DOSFS_GetDeviceByHandle( HFILE hFile ) const DOS_DEVICE *DOSFS_GetDeviceByHandle( HFILE hFile )
{ {
const DOS_DEVICE *ret = NULL; const DOS_DEVICE *ret = NULL;
SERVER_START_REQ SERVER_START_REQ( get_file_info )
{ {
struct get_file_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hFile; req->handle = hFile;
if (!server_call( REQ_GET_FILE_INFO ) && (req->type == FILE_TYPE_UNKNOWN)) if (!SERVER_CALL() && (req->type == FILE_TYPE_UNKNOWN))
{ {
if ((req->attr >= 0) && if ((req->attr >= 0) &&
(req->attr < sizeof(DOSFS_Devices)/sizeof(DOSFS_Devices[0]))) (req->attr < sizeof(DOSFS_Devices)/sizeof(DOSFS_Devices[0])))
...@@ -699,6 +697,7 @@ static HANDLE DOSFS_CreateCommPort(LPCSTR name, DWORD access) ...@@ -699,6 +697,7 @@ static HANDLE DOSFS_CreateCommPort(LPCSTR name, DWORD access)
{ {
HANDLE ret; HANDLE ret;
char devname[40]; char devname[40];
size_t len;
TRACE("%s %lx\n", name, access); TRACE("%s %lx\n", name, access);
...@@ -708,20 +707,18 @@ static HANDLE DOSFS_CreateCommPort(LPCSTR name, DWORD access) ...@@ -708,20 +707,18 @@ static HANDLE DOSFS_CreateCommPort(LPCSTR name, DWORD access)
TRACE("opening %s as %s\n", devname, name); TRACE("opening %s as %s\n", devname, name);
SERVER_START_REQ len = strlen(devname);
SERVER_START_VAR_REQ( create_serial, len )
{ {
size_t len = strlen(devname);
struct create_serial_request *req = server_alloc_req( sizeof(*req), len );
req->access = access; req->access = access;
req->inherit = 0; /*FIXME*/ req->inherit = 0; /*FIXME*/
req->sharing = FILE_SHARE_READ|FILE_SHARE_WRITE; req->sharing = FILE_SHARE_READ|FILE_SHARE_WRITE;
memcpy( server_data_ptr(req), devname, len ); memcpy( server_data_ptr(req), devname, len );
SetLastError(0); SetLastError(0);
server_call( REQ_CREATE_SERIAL ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
if(!ret) if(!ret)
ERR("Couldn't open %s ! (check permissions)\n",devname); ERR("Couldn't open %s ! (check permissions)\n",devname);
......
...@@ -1365,115 +1365,115 @@ struct async_result_request ...@@ -1365,115 +1365,115 @@ struct async_result_request
enum request enum request
{ {
REQ_NEW_PROCESS, REQ_new_process,
REQ_GET_NEW_PROCESS_INFO, REQ_get_new_process_info,
REQ_NEW_THREAD, REQ_new_thread,
REQ_BOOT_DONE, REQ_boot_done,
REQ_INIT_PROCESS, REQ_init_process,
REQ_INIT_PROCESS_DONE, REQ_init_process_done,
REQ_INIT_THREAD, REQ_init_thread,
REQ_GET_THREAD_BUFFER, REQ_get_thread_buffer,
REQ_TERMINATE_PROCESS, REQ_terminate_process,
REQ_TERMINATE_THREAD, REQ_terminate_thread,
REQ_GET_PROCESS_INFO, REQ_get_process_info,
REQ_SET_PROCESS_INFO, REQ_set_process_info,
REQ_GET_THREAD_INFO, REQ_get_thread_info,
REQ_SET_THREAD_INFO, REQ_set_thread_info,
REQ_SUSPEND_THREAD, REQ_suspend_thread,
REQ_RESUME_THREAD, REQ_resume_thread,
REQ_LOAD_DLL, REQ_load_dll,
REQ_UNLOAD_DLL, REQ_unload_dll,
REQ_QUEUE_APC, REQ_queue_apc,
REQ_GET_APC, REQ_get_apc,
REQ_CLOSE_HANDLE, REQ_close_handle,
REQ_SET_HANDLE_INFO, REQ_set_handle_info,
REQ_DUP_HANDLE, REQ_dup_handle,
REQ_OPEN_PROCESS, REQ_open_process,
REQ_SELECT, REQ_select,
REQ_CREATE_EVENT, REQ_create_event,
REQ_EVENT_OP, REQ_event_op,
REQ_OPEN_EVENT, REQ_open_event,
REQ_CREATE_MUTEX, REQ_create_mutex,
REQ_RELEASE_MUTEX, REQ_release_mutex,
REQ_OPEN_MUTEX, REQ_open_mutex,
REQ_CREATE_SEMAPHORE, REQ_create_semaphore,
REQ_RELEASE_SEMAPHORE, REQ_release_semaphore,
REQ_OPEN_SEMAPHORE, REQ_open_semaphore,
REQ_CREATE_FILE, REQ_create_file,
REQ_ALLOC_FILE_HANDLE, REQ_alloc_file_handle,
REQ_GET_HANDLE_FD, REQ_get_handle_fd,
REQ_SET_FILE_POINTER, REQ_set_file_pointer,
REQ_TRUNCATE_FILE, REQ_truncate_file,
REQ_SET_FILE_TIME, REQ_set_file_time,
REQ_FLUSH_FILE, REQ_flush_file,
REQ_GET_FILE_INFO, REQ_get_file_info,
REQ_LOCK_FILE, REQ_lock_file,
REQ_UNLOCK_FILE, REQ_unlock_file,
REQ_CREATE_PIPE, REQ_create_pipe,
REQ_CREATE_SOCKET, REQ_create_socket,
REQ_ACCEPT_SOCKET, REQ_accept_socket,
REQ_SET_SOCKET_EVENT, REQ_set_socket_event,
REQ_GET_SOCKET_EVENT, REQ_get_socket_event,
REQ_ENABLE_SOCKET_EVENT, REQ_enable_socket_event,
REQ_ALLOC_CONSOLE, REQ_alloc_console,
REQ_FREE_CONSOLE, REQ_free_console,
REQ_OPEN_CONSOLE, REQ_open_console,
REQ_SET_CONSOLE_FD, REQ_set_console_fd,
REQ_GET_CONSOLE_MODE, REQ_get_console_mode,
REQ_SET_CONSOLE_MODE, REQ_set_console_mode,
REQ_SET_CONSOLE_INFO, REQ_set_console_info,
REQ_GET_CONSOLE_INFO, REQ_get_console_info,
REQ_WRITE_CONSOLE_INPUT, REQ_write_console_input,
REQ_READ_CONSOLE_INPUT, REQ_read_console_input,
REQ_CREATE_CHANGE_NOTIFICATION, REQ_create_change_notification,
REQ_CREATE_MAPPING, REQ_create_mapping,
REQ_OPEN_MAPPING, REQ_open_mapping,
REQ_GET_MAPPING_INFO, REQ_get_mapping_info,
REQ_CREATE_DEVICE, REQ_create_device,
REQ_CREATE_SNAPSHOT, REQ_create_snapshot,
REQ_NEXT_PROCESS, REQ_next_process,
REQ_NEXT_THREAD, REQ_next_thread,
REQ_NEXT_MODULE, REQ_next_module,
REQ_WAIT_DEBUG_EVENT, REQ_wait_debug_event,
REQ_QUEUE_EXCEPTION_EVENT, REQ_queue_exception_event,
REQ_GET_EXCEPTION_STATUS, REQ_get_exception_status,
REQ_OUTPUT_DEBUG_STRING, REQ_output_debug_string,
REQ_CONTINUE_DEBUG_EVENT, REQ_continue_debug_event,
REQ_DEBUG_PROCESS, REQ_debug_process,
REQ_READ_PROCESS_MEMORY, REQ_read_process_memory,
REQ_WRITE_PROCESS_MEMORY, REQ_write_process_memory,
REQ_CREATE_KEY, REQ_create_key,
REQ_OPEN_KEY, REQ_open_key,
REQ_DELETE_KEY, REQ_delete_key,
REQ_ENUM_KEY, REQ_enum_key,
REQ_SET_KEY_VALUE, REQ_set_key_value,
REQ_GET_KEY_VALUE, REQ_get_key_value,
REQ_ENUM_KEY_VALUE, REQ_enum_key_value,
REQ_DELETE_KEY_VALUE, REQ_delete_key_value,
REQ_LOAD_REGISTRY, REQ_load_registry,
REQ_SAVE_REGISTRY, REQ_save_registry,
REQ_SAVE_REGISTRY_ATEXIT, REQ_save_registry_atexit,
REQ_SET_REGISTRY_LEVELS, REQ_set_registry_levels,
REQ_CREATE_TIMER, REQ_create_timer,
REQ_OPEN_TIMER, REQ_open_timer,
REQ_SET_TIMER, REQ_set_timer,
REQ_CANCEL_TIMER, REQ_cancel_timer,
REQ_GET_THREAD_CONTEXT, REQ_get_thread_context,
REQ_SET_THREAD_CONTEXT, REQ_set_thread_context,
REQ_GET_SELECTOR_ENTRY, REQ_get_selector_entry,
REQ_ADD_ATOM, REQ_add_atom,
REQ_DELETE_ATOM, REQ_delete_atom,
REQ_FIND_ATOM, REQ_find_atom,
REQ_GET_ATOM_NAME, REQ_get_atom_name,
REQ_INIT_ATOM_TABLE, REQ_init_atom_table,
REQ_GET_MSG_QUEUE, REQ_get_msg_queue,
REQ_WAKE_QUEUE, REQ_wake_queue,
REQ_WAIT_INPUT_IDLE, REQ_wait_input_idle,
REQ_CREATE_SERIAL, REQ_create_serial,
REQ_GET_SERIAL_INFO, REQ_get_serial_info,
REQ_SET_SERIAL_INFO, REQ_set_serial_info,
REQ_CREATE_ASYNC, REQ_create_async,
REQ_ASYNC_RESULT, REQ_async_result,
REQ_NB_REQUESTS REQ_NB_REQUESTS
}; };
...@@ -1600,13 +1600,6 @@ union generic_request ...@@ -1600,13 +1600,6 @@ union generic_request
#undef REQUEST_HEADER #undef REQUEST_HEADER
#undef VARARG #undef VARARG
/* format of the server buffer */
struct server_buffer_info
{
volatile unsigned int cur_req; /* offset of the current request */
volatile unsigned int cur_pos; /* first available position in buffer */
};
/* client-side functions */ /* client-side functions */
#ifndef __WINE_SERVER__ #ifndef __WINE_SERVER__
...@@ -1617,22 +1610,18 @@ struct server_buffer_info ...@@ -1617,22 +1610,18 @@ struct server_buffer_info
/* client communication functions */ /* client communication functions */
extern unsigned int wine_server_call( enum request req ); extern unsigned int wine_server_call( union generic_request *req, size_t size );
extern unsigned int server_call_fd( enum request req, int fd_out ); extern unsigned int wine_server_call_fd( union generic_request *req, size_t size, int fd );
extern void server_protocol_error( const char *err, ... ) WINE_NORETURN; extern void server_protocol_error( const char *err, ... ) WINE_NORETURN;
extern void server_protocol_perror( const char *err ) WINE_NORETURN; extern void server_protocol_perror( const char *err ) WINE_NORETURN;
extern void *wine_server_alloc_req( size_t fixed_size, size_t var_size ); extern void wine_server_alloc_req( union generic_request *req, size_t size );
extern int wine_server_recv_fd( int handle, int cache ); extern int wine_server_recv_fd( int handle, int cache );
extern const char *get_config_dir(void); extern const char *get_config_dir(void);
/* compatibility macros */
#define server_alloc_req(f,v) wine_server_alloc_req(f,v)
#define server_call_noerr(req) wine_server_call(req)
/* do a server call and set the last error code */ /* do a server call and set the last error code */
inline static unsigned int server_call( enum request req ) inline static unsigned int __server_call_err( union generic_request *req, size_t size )
{ {
unsigned int res = wine_server_call( req ); unsigned int res = wine_server_call( req, size );
if (res) SetLastError( RtlNtStatusToDosError(res) ); if (res) SetLastError( RtlNtStatusToDosError(res) );
return res; return res;
} }
...@@ -1640,7 +1629,7 @@ inline static unsigned int server_call( enum request req ) ...@@ -1640,7 +1629,7 @@ inline static unsigned int server_call( enum request req )
/* get a pointer to the variable part of the request */ /* get a pointer to the variable part of the request */
inline static void *server_data_ptr( const void *req ) inline static void *server_data_ptr( const void *req )
{ {
return (union generic_request *)req + 1; return (char *)NtCurrentTeb()->buffer + ((struct request_header *)req)->var_offset;
} }
/* get the size of the variable part of the request */ /* get the size of the variable part of the request */
...@@ -1657,23 +1646,47 @@ extern DWORD __wine_server_exception_handler( PEXCEPTION_RECORD record, EXCEPTIO ...@@ -1657,23 +1646,47 @@ extern DWORD __wine_server_exception_handler( PEXCEPTION_RECORD record, EXCEPTIO
struct __server_exception_frame struct __server_exception_frame
{ {
EXCEPTION_FRAME frame; EXCEPTION_FRAME frame;
struct server_buffer_info info; /* saved buffer information */ unsigned int buffer_pos; /* saved buffer position */
}; };
#define SERVER_START_REQ \
/* macros for server requests */
#define SERVER_START_REQ(type) \
do { \
union generic_request __req; \
struct type##_request * const req = &__req.type; \
__req.header.req = REQ_##type; \
__req.header.var_size = 0; \
do
#define SERVER_END_REQ \
while(0); \
} while(0)
#define SERVER_START_VAR_REQ(type,size) \
do { \ do { \
struct __server_exception_frame __f; \ struct __server_exception_frame __f; \
union generic_request __req; \
struct type##_request * const req = &__req.type; \
__f.frame.Handler = __wine_server_exception_handler; \ __f.frame.Handler = __wine_server_exception_handler; \
__f.info = *NtCurrentTeb()->buffer_info; \ __f.buffer_pos = NtCurrentTeb()->buffer_pos; \
__wine_push_frame( &__f.frame ); \ __wine_push_frame( &__f.frame ); \
do { __req.header.req = REQ_##type; \
wine_server_alloc_req( &__req, (size) ); \
do
#define SERVER_END_REQ \ #define SERVER_END_VAR_REQ \
} while(0); \ while(0); \
*NtCurrentTeb()->buffer_info = __f.info; \ NtCurrentTeb()->buffer_pos = __f.buffer_pos; \
__wine_pop_frame( &__f.frame ); \ __wine_pop_frame( &__f.frame ); \
} while(0); } while(0)
#define SERVER_CALL() (wine_server_call( &__req, sizeof(*req) ))
#define SERVER_CALL_ERR() (__server_call_err( &__req, sizeof(*req) ))
#define SERVER_CALL_FD(fd) (wine_server_call_fd( &__req, sizeof(*req), (fd) ))
extern int CLIENT_InitServer(void); extern int CLIENT_InitServer(void);
extern int CLIENT_BootDone( int debug_level ); extern int CLIENT_BootDone( int debug_level );
......
...@@ -94,16 +94,17 @@ typedef struct _TEB ...@@ -94,16 +94,17 @@ typedef struct _TEB
DWORD cleanup; /* --3 1fc Cleanup service handle */ DWORD cleanup; /* --3 1fc Cleanup service handle */
int socket; /* --3 200 Socket for server communication */ int socket; /* --3 200 Socket for server communication */
void *buffer; /* --3 204 Buffer shared with server */ void *buffer; /* --3 204 Buffer shared with server */
int request_fd; /* --3 208 fd for sending server requests */ unsigned int buffer_pos; /* --3 208 Buffer current position */
int reply_fd; /* --3 20c fd for receiving server replies */ unsigned int buffer_size; /* --3 20c Buffer size */
int wait_fd; /* --3 210 fd for sleeping server requests */ int request_fd; /* --3 210 fd for sending server requests */
struct server_buffer_info *buffer_info; /* --3 214 Buffer information */ int reply_fd; /* --3 214 fd for receiving server replies */
void *debug_info; /* --3 218 Info for debugstr functions */ int wait_fd; /* --3 218 fd for sleeping server requests */
void *pthread_data; /* --3 21c Data for pthread emulation */ void *debug_info; /* --3 21c Info for debugstr functions */
void *pthread_data; /* --3 220 Data for pthread emulation */
/* here is plenty space for wine specific fields (don't forget to change pad6!!) */ /* here is plenty space for wine specific fields (don't forget to change pad6!!) */
/* the following are nt specific fields */ /* the following are nt specific fields */
DWORD pad6[630]; /* --n 220 */ DWORD pad6[629]; /* --n 224 */
UNICODE_STRING StaticUnicodeString; /* -2- bf8 used by advapi32 */ UNICODE_STRING StaticUnicodeString; /* -2- bf8 used by advapi32 */
USHORT StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */ USHORT StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */
DWORD pad7; /* --n e0c */ DWORD pad7; /* --n e0c */
......
...@@ -1597,11 +1597,10 @@ BOOL MODULE_FreeLibrary( WINE_MODREF *wm ) ...@@ -1597,11 +1597,10 @@ BOOL MODULE_FreeLibrary( WINE_MODREF *wm )
if ( free_lib_count <= 1 ) if ( free_lib_count <= 1 )
{ {
MODULE_DllProcessDetach( FALSE, NULL ); MODULE_DllProcessDetach( FALSE, NULL );
SERVER_START_REQ SERVER_START_REQ( unload_dll )
{ {
struct unload_dll_request *req = server_alloc_req( sizeof(*req), 0 );
req->base = (void *)wm->module; req->base = (void *)wm->module;
server_call_noerr( REQ_UNLOAD_DLL ); SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
MODULE_FlushModrefs(); MODULE_FlushModrefs();
......
...@@ -990,12 +990,11 @@ static HINSTANCE16 NE_CreateThread( NE_MODULE *pModule, WORD cmdShow, LPCSTR cmd ...@@ -990,12 +990,11 @@ static HINSTANCE16 NE_CreateThread( NE_MODULE *pModule, WORD cmdShow, LPCSTR cmd
TDB *pTask; TDB *pTask;
HINSTANCE16 instance = 0; HINSTANCE16 instance = 0;
SERVER_START_REQ SERVER_START_REQ( new_thread )
{ {
struct new_thread_request *req = server_alloc_req( sizeof(*req), 0 );
req->suspend = 0; req->suspend = 0;
req->inherit = 0; req->inherit = 0;
if (!server_call( REQ_NEW_THREAD )) if (!SERVER_CALL_ERR())
{ {
hThread = req->handle; hThread = req->handle;
socket = wine_server_recv_fd( hThread, 0 ); socket = wine_server_recv_fd( hThread, 0 );
......
...@@ -664,15 +664,14 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags, ...@@ -664,15 +664,14 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
if (nt->FileHeader.Characteristics & IMAGE_FILE_DLL) if (nt->FileHeader.Characteristics & IMAGE_FILE_DLL)
{ {
SERVER_START_REQ SERVER_START_REQ( load_dll )
{ {
struct load_dll_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hFile; req->handle = hFile;
req->base = (void *)hModule; req->base = (void *)hModule;
req->dbg_offset = nt->FileHeader.PointerToSymbolTable; req->dbg_offset = nt->FileHeader.PointerToSymbolTable;
req->dbg_size = nt->FileHeader.NumberOfSymbols; req->dbg_size = nt->FileHeader.NumberOfSymbols;
req->name = &wm->filename; req->name = &wm->filename;
server_call_noerr( REQ_LOAD_DLL ); SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
} }
......
...@@ -402,11 +402,10 @@ UINT16 WINAPI GetAtomName16( ATOM atom, LPSTR buffer, INT16 count ) ...@@ -402,11 +402,10 @@ UINT16 WINAPI GetAtomName16( ATOM atom, LPSTR buffer, INT16 count )
BOOL WINAPI InitAtomTable( DWORD entries ) BOOL WINAPI InitAtomTable( DWORD entries )
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( init_atom_table )
{ {
struct init_atom_table_request *req = server_alloc_req( sizeof(*req), 0 );
req->entries = entries; req->entries = entries;
ret = !server_call( REQ_INIT_ATOM_TABLE ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -424,14 +423,13 @@ static ATOM ATOM_AddAtomA( LPCSTR str, BOOL local ) ...@@ -424,14 +423,13 @@ static ATOM ATOM_AddAtomA( LPCSTR str, BOOL local )
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( add_atom, len * sizeof(WCHAR) )
{ {
struct add_atom_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, str, strlen(str), server_data_ptr(req), len ); MultiByteToWideChar( CP_ACP, 0, str, strlen(str), server_data_ptr(req), len );
req->local = local; req->local = local;
if (!server_call( REQ_ADD_ATOM )) atom = req->atom + MIN_STR_ATOM; if (!SERVER_CALL_ERR()) atom = req->atom + MIN_STR_ATOM;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
} }
TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_a(str), atom ); TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_a(str), atom );
return atom; return atom;
...@@ -480,14 +478,13 @@ static ATOM ATOM_AddAtomW( LPCWSTR str, BOOL local ) ...@@ -480,14 +478,13 @@ static ATOM ATOM_AddAtomW( LPCWSTR str, BOOL local )
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( add_atom, len * sizeof(WCHAR) )
{ {
struct add_atom_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
memcpy( server_data_ptr(req), str, len * sizeof(WCHAR) ); memcpy( server_data_ptr(req), str, len * sizeof(WCHAR) );
req->local = local; req->local = local;
if (!server_call( REQ_ADD_ATOM )) atom = req->atom + MIN_STR_ATOM; if (!SERVER_CALL_ERR()) atom = req->atom + MIN_STR_ATOM;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
} }
TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_w(str), atom ); TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_w(str), atom );
return atom; return atom;
...@@ -518,12 +515,11 @@ static ATOM ATOM_DeleteAtom( ATOM atom, BOOL local) ...@@ -518,12 +515,11 @@ static ATOM ATOM_DeleteAtom( ATOM atom, BOOL local)
if (atom < MIN_STR_ATOM) atom = 0; if (atom < MIN_STR_ATOM) atom = 0;
else else
{ {
SERVER_START_REQ SERVER_START_REQ( delete_atom )
{ {
struct delete_atom_request *req = server_alloc_req( sizeof(*req), 0 );
req->atom = atom - MIN_STR_ATOM; req->atom = atom - MIN_STR_ATOM;
req->local = local; req->local = local;
if (!server_call( REQ_DELETE_ATOM )) atom = 0; if (!SERVER_CALL_ERR()) atom = 0;
} }
SERVER_END_REQ; SERVER_END_REQ;
} }
...@@ -572,14 +568,13 @@ static ATOM ATOM_FindAtomA( LPCSTR str, BOOL local ) ...@@ -572,14 +568,13 @@ static ATOM ATOM_FindAtomA( LPCSTR str, BOOL local )
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( find_atom, len * sizeof(WCHAR) )
{ {
struct find_atom_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, str, strlen(str), server_data_ptr(req), len ); MultiByteToWideChar( CP_ACP, 0, str, strlen(str), server_data_ptr(req), len );
req->local = local; req->local = local;
if (!server_call( REQ_FIND_ATOM )) atom = req->atom + MIN_STR_ATOM; if (!SERVER_CALL_ERR()) atom = req->atom + MIN_STR_ATOM;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
} }
TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_a(str), atom ); TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_a(str), atom );
return atom; return atom;
...@@ -627,14 +622,13 @@ static ATOM ATOM_FindAtomW( LPCWSTR str, BOOL local ) ...@@ -627,14 +622,13 @@ static ATOM ATOM_FindAtomW( LPCWSTR str, BOOL local )
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( find_atom, len * sizeof(WCHAR) )
{ {
struct find_atom_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
memcpy( server_data_ptr(req), str, len * sizeof(WCHAR) ); memcpy( server_data_ptr(req), str, len * sizeof(WCHAR) );
req->local = local; req->local = local;
if (!server_call( REQ_FIND_ATOM )) atom = req->atom + MIN_STR_ATOM; if (!SERVER_CALL_ERR()) atom = req->atom + MIN_STR_ATOM;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
} }
TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_w(str), atom ); TRACE( "(%s) %s -> %x\n", local ? "local" : "global", debugres_w(str), atom );
return atom; return atom;
...@@ -682,13 +676,11 @@ static UINT ATOM_GetAtomNameA( ATOM atom, LPSTR buffer, INT count, BOOL local ) ...@@ -682,13 +676,11 @@ static UINT ATOM_GetAtomNameA( ATOM atom, LPSTR buffer, INT count, BOOL local )
else else
{ {
len = 0; len = 0;
SERVER_START_REQ SERVER_START_VAR_REQ( get_atom_name, MAX_ATOM_LEN * sizeof(WCHAR) )
{ {
struct get_atom_name_request *req = server_alloc_req( sizeof(*req),
MAX_ATOM_LEN * sizeof(WCHAR) );
req->atom = atom - MIN_STR_ATOM; req->atom = atom - MIN_STR_ATOM;
req->local = local; req->local = local;
if (!server_call( REQ_GET_ATOM_NAME )) if (!SERVER_CALL_ERR())
{ {
len = WideCharToMultiByte( CP_ACP, 0, server_data_ptr(req), len = WideCharToMultiByte( CP_ACP, 0, server_data_ptr(req),
server_data_size(req) / sizeof(WCHAR), server_data_size(req) / sizeof(WCHAR),
...@@ -697,7 +689,7 @@ static UINT ATOM_GetAtomNameA( ATOM atom, LPSTR buffer, INT count, BOOL local ) ...@@ -697,7 +689,7 @@ static UINT ATOM_GetAtomNameA( ATOM atom, LPSTR buffer, INT count, BOOL local )
else buffer[len] = 0; else buffer[len] = 0;
} }
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
} }
if (len && count <= len) if (len && count <= len)
...@@ -770,13 +762,11 @@ static UINT ATOM_GetAtomNameW( ATOM atom, LPWSTR buffer, INT count, BOOL local ) ...@@ -770,13 +762,11 @@ static UINT ATOM_GetAtomNameW( ATOM atom, LPWSTR buffer, INT count, BOOL local )
else else
{ {
len = 0; len = 0;
SERVER_START_REQ SERVER_START_VAR_REQ( get_atom_name, MAX_ATOM_LEN * sizeof(WCHAR) )
{ {
struct get_atom_name_request *req = server_alloc_req( sizeof(*req),
MAX_ATOM_LEN * sizeof(WCHAR) );
req->atom = atom - MIN_STR_ATOM; req->atom = atom - MIN_STR_ATOM;
req->local = local; req->local = local;
if (!server_call( REQ_GET_ATOM_NAME )) if (!SERVER_CALL_ERR())
{ {
len = server_data_size(req) / sizeof(WCHAR); len = server_data_size(req) / sizeof(WCHAR);
if (count > len) count = len + 1; if (count > len) count = len + 1;
...@@ -784,7 +774,7 @@ static UINT ATOM_GetAtomNameW( ATOM atom, LPWSTR buffer, INT count, BOOL local ) ...@@ -784,7 +774,7 @@ static UINT ATOM_GetAtomNameW( ATOM atom, LPWSTR buffer, INT count, BOOL local )
buffer[count-1] = 0; buffer[count-1] = 0;
} }
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
if (!len) return 0; if (!len) return 0;
} }
if (count <= len) if (count <= len)
......
...@@ -34,13 +34,6 @@ static inline int is_string( DWORD type ) ...@@ -34,13 +34,6 @@ static inline int is_string( DWORD type )
return (type == REG_SZ) || (type == REG_EXPAND_SZ) || (type == REG_MULTI_SZ); return (type == REG_SZ) || (type == REG_EXPAND_SZ) || (type == REG_MULTI_SZ);
} }
/* do a server call without setting the last error code */
static inline int reg_server_call( enum request req )
{
unsigned int res = server_call_noerr( req );
if (res) res = RtlNtStatusToDosError(res);
return res;
}
/****************************************************************************** /******************************************************************************
* RegCreateKeyExA [ADVAPI32.130] * RegCreateKeyExA [ADVAPI32.130]
...@@ -631,16 +624,15 @@ LONG WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename ) ...@@ -631,16 +624,15 @@ LONG WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename )
goto done; goto done;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( load_registry, len )
{ {
struct load_registry_request *req = server_alloc_req( sizeof(*req), len );
req->hkey = hkey; req->hkey = hkey;
req->file = file; req->file = file;
MultiByteToWideChar( CP_ACP, 0, subkey, strlen(subkey), MultiByteToWideChar( CP_ACP, 0, subkey, strlen(subkey),
server_data_ptr(req), len/sizeof(WCHAR) ); server_data_ptr(req), len/sizeof(WCHAR) );
ret = reg_server_call( REQ_LOAD_REGISTRY ); ret = RtlNtStatusToDosError( SERVER_CALL() );
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
CloseHandle( file ); CloseHandle( file );
done: done:
...@@ -684,12 +676,11 @@ LONG WINAPI RegSaveKeyA( HKEY hkey, LPCSTR file, LPSECURITY_ATTRIBUTES sa ) ...@@ -684,12 +676,11 @@ LONG WINAPI RegSaveKeyA( HKEY hkey, LPCSTR file, LPSECURITY_ATTRIBUTES sa )
MESSAGE("Wow, we are already fiddling with a temp file %s with an ordinal as high as %d !\nYou might want to delete all corresponding temp files in that directory.\n", buffer, count); MESSAGE("Wow, we are already fiddling with a temp file %s with an ordinal as high as %d !\nYou might want to delete all corresponding temp files in that directory.\n", buffer, count);
} }
SERVER_START_REQ SERVER_START_REQ( save_registry )
{ {
struct save_registry_request *req = server_alloc_req( sizeof(*req), 0 );
req->hkey = hkey; req->hkey = hkey;
req->file = handle; req->file = handle;
ret = reg_server_call( REQ_SAVE_REGISTRY ); ret = RtlNtStatusToDosError( SERVER_CALL() );
} }
SERVER_END_REQ; SERVER_END_REQ;
......
...@@ -587,13 +587,11 @@ BOOL WINAPI GetThreadSelectorEntry( HANDLE hthread, DWORD sel, LPLDT_ENTRY ldten ...@@ -587,13 +587,11 @@ BOOL WINAPI GetThreadSelectorEntry( HANDLE hthread, DWORD sel, LPLDT_ENTRY ldten
return FALSE; return FALSE;
} }
SERVER_START_REQ SERVER_START_REQ( get_selector_entry )
{ {
struct get_selector_entry_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hthread; req->handle = hthread;
req->entry = sel >> __AHSHIFT; req->entry = sel >> __AHSHIFT;
if ((ret = !server_call( REQ_GET_SELECTOR_ENTRY ))) if ((ret = !SERVER_CALL_ERR()))
{ {
if (!(req->flags & WINE_LDT_FLAGS_ALLOCATED)) if (!(req->flags & WINE_LDT_FLAGS_ALLOCATED))
{ {
......
...@@ -1314,10 +1314,8 @@ HANDLE WINAPI CreateFileMappingA( ...@@ -1314,10 +1314,8 @@ HANDLE WINAPI CreateFileMappingA(
/* Create the server object */ /* Create the server object */
if (hFile == INVALID_HANDLE_VALUE) hFile = 0; if (hFile == INVALID_HANDLE_VALUE) hFile = 0;
SERVER_START_REQ SERVER_START_VAR_REQ( create_mapping, len * sizeof(WCHAR) )
{ {
struct create_mapping_request *req = server_alloc_req( sizeof(*req),
len * sizeof(WCHAR) );
req->file_handle = hFile; req->file_handle = hFile;
req->size_high = size_high; req->size_high = size_high;
req->size_low = size_low; req->size_low = size_low;
...@@ -1325,10 +1323,10 @@ HANDLE WINAPI CreateFileMappingA( ...@@ -1325,10 +1323,10 @@ HANDLE WINAPI CreateFileMappingA(
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len ); if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0); SetLastError(0);
server_call( REQ_CREATE_MAPPING ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -1372,10 +1370,8 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa, ...@@ -1372,10 +1370,8 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa,
/* Create the server object */ /* Create the server object */
if (hFile == INVALID_HANDLE_VALUE) hFile = 0; if (hFile == INVALID_HANDLE_VALUE) hFile = 0;
SERVER_START_REQ SERVER_START_VAR_REQ( create_mapping, len * sizeof(WCHAR) )
{ {
struct create_mapping_request *req = server_alloc_req( sizeof(*req),
len * sizeof(WCHAR) );
req->file_handle = hFile; req->file_handle = hFile;
req->size_high = size_high; req->size_high = size_high;
req->size_low = size_low; req->size_low = size_low;
...@@ -1383,10 +1379,10 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa, ...@@ -1383,10 +1379,10 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa,
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) ); memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0); SetLastError(0);
server_call( REQ_CREATE_MAPPING ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -1411,17 +1407,15 @@ HANDLE WINAPI OpenFileMappingA( ...@@ -1411,17 +1407,15 @@ HANDLE WINAPI OpenFileMappingA(
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( open_mapping, len * sizeof(WCHAR) )
{ {
struct open_mapping_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access; req->access = access;
req->inherit = inherit; req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len ); if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_MAPPING ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -1439,17 +1433,15 @@ HANDLE WINAPI OpenFileMappingW( DWORD access, BOOL inherit, LPCWSTR name) ...@@ -1439,17 +1433,15 @@ HANDLE WINAPI OpenFileMappingW( DWORD access, BOOL inherit, LPCWSTR name)
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( open_mapping, len * sizeof(WCHAR) )
{ {
struct open_mapping_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access; req->access = access;
req->inherit = inherit; req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) ); memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_MAPPING ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -1508,11 +1500,10 @@ LPVOID WINAPI MapViewOfFileEx( ...@@ -1508,11 +1500,10 @@ LPVOID WINAPI MapViewOfFileEx(
return NULL; return NULL;
} }
SERVER_START_REQ SERVER_START_REQ( get_mapping_info )
{ {
struct get_mapping_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
res = server_call( REQ_GET_MAPPING_INFO ); res = SERVER_CALL_ERR();
prot = req->protect; prot = req->protect;
base = req->base; base = req->base;
size_low = req->size_low; size_low = req->size_low;
......
...@@ -996,14 +996,12 @@ static int _nt_dump_nk(LPSTR key_name,char *base,nt_nk *nk,FILE *f,int level) ...@@ -996,14 +996,12 @@ static int _nt_dump_nk(LPSTR key_name,char *base,nt_nk *nk,FILE *f,int level)
*/ */
static void _set_registry_levels(int level,int saving,int period) static void _set_registry_levels(int level,int saving,int period)
{ {
SERVER_START_REQ SERVER_START_REQ( set_registry_levels )
{ {
struct set_registry_levels_request *req = server_alloc_req( sizeof(*req), 0 );
req->current = level; req->current = level;
req->saving = saving; req->saving = saving;
req->period = period; req->period = period;
server_call( REQ_SET_REGISTRY_LEVELS ); SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
} }
...@@ -1018,14 +1016,13 @@ static void _save_at_exit(HKEY hkey,LPCSTR path) ...@@ -1018,14 +1016,13 @@ static void _save_at_exit(HKEY hkey,LPCSTR path)
ERR( "config dir '%s' too long\n", confdir ); ERR( "config dir '%s' too long\n", confdir );
return; return;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( save_registry_atexit, len )
{ {
struct save_registry_atexit_request *req = server_alloc_req( sizeof(*req), len );
sprintf( server_data_ptr(req), "%s/%s", confdir, path ); sprintf( server_data_ptr(req), "%s/%s", confdir, path );
req->hkey = hkey; req->hkey = hkey;
server_call( REQ_SAVE_REGISTRY_ATEXIT ); SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
} }
/* configure save files and start the periodic saving timer [Internal] */ /* configure save files and start the periodic saving timer [Internal] */
...@@ -1186,12 +1183,11 @@ static void load_wine_registry(HKEY hkey,LPCSTR fn) ...@@ -1186,12 +1183,11 @@ static void load_wine_registry(HKEY hkey,LPCSTR fn)
if ((file = FILE_CreateFile( fn, GENERIC_READ, 0, NULL, OPEN_EXISTING, if ((file = FILE_CreateFile( fn, GENERIC_READ, 0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0, TRUE ))) FILE_ATTRIBUTE_NORMAL, 0, TRUE )))
{ {
SERVER_START_REQ SERVER_START_REQ( load_registry )
{ {
struct load_registry_request *req = server_alloc_req( sizeof(*req), 0 );
req->hkey = hkey; req->hkey = hkey;
req->file = file; req->file = file;
server_call( REQ_LOAD_REGISTRY ); SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
CloseHandle( file ); CloseHandle( file );
......
...@@ -45,8 +45,6 @@ ...@@ -45,8 +45,6 @@
#define SERVERDIR "/wineserver-" /* server socket directory (hostname appended) */ #define SERVERDIR "/wineserver-" /* server socket directory (hostname appended) */
#define SOCKETNAME "socket" /* name of the socket file */ #define SOCKETNAME "socket" /* name of the socket file */
#undef server_alloc_req
/* data structure used to pass an fd with sendmsg/recvmsg */ /* data structure used to pass an fd with sendmsg/recvmsg */
struct cmsg_fd struct cmsg_fd
{ {
...@@ -120,7 +118,7 @@ DWORD __wine_server_exception_handler( PEXCEPTION_RECORD record, EXCEPTION_FRAME ...@@ -120,7 +118,7 @@ DWORD __wine_server_exception_handler( PEXCEPTION_RECORD record, EXCEPTION_FRAME
{ {
struct __server_exception_frame *server_frame = (struct __server_exception_frame *)frame; struct __server_exception_frame *server_frame = (struct __server_exception_frame *)frame;
if ((record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND))) if ((record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)))
*NtCurrentTeb()->buffer_info = server_frame->info; NtCurrentTeb()->buffer_pos = server_frame->buffer_pos;
return ExceptionContinueSearch; return ExceptionContinueSearch;
} }
...@@ -128,22 +126,19 @@ DWORD __wine_server_exception_handler( PEXCEPTION_RECORD record, EXCEPTION_FRAME ...@@ -128,22 +126,19 @@ DWORD __wine_server_exception_handler( PEXCEPTION_RECORD record, EXCEPTION_FRAME
/*********************************************************************** /***********************************************************************
* wine_server_alloc_req (NTDLL.@) * wine_server_alloc_req (NTDLL.@)
*/ */
void *wine_server_alloc_req( size_t fixed_size, size_t var_size ) void wine_server_alloc_req( union generic_request *req, size_t size )
{ {
unsigned int pos = NtCurrentTeb()->buffer_info->cur_pos; unsigned int pos = NtCurrentTeb()->buffer_pos;
union generic_request *req = (union generic_request *)((char *)NtCurrentTeb()->buffer + pos);
size_t size = sizeof(*req) + var_size;
assert( fixed_size <= sizeof(*req) ); assert( size <= REQUEST_MAX_VAR_SIZE );
assert( var_size <= REQUEST_MAX_VAR_SIZE );
if ((char *)req + size > (char *)NtCurrentTeb()->buffer_info) if (pos + size > NtCurrentTeb()->buffer_size)
server_protocol_error( "buffer overflow %d bytes\n", server_protocol_error( "buffer overflow %d bytes\n",
(char *)req + size - (char *)NtCurrentTeb()->buffer_info ); pos + size - NtCurrentTeb()->buffer_pos );
NtCurrentTeb()->buffer_info->cur_pos = pos + size;
req->header.var_offset = pos + sizeof(*req); NtCurrentTeb()->buffer_pos = pos + size;
req->header.var_size = var_size; req->header.var_offset = pos;
return req; req->header.var_size = size;
} }
...@@ -152,12 +147,10 @@ void *wine_server_alloc_req( size_t fixed_size, size_t var_size ) ...@@ -152,12 +147,10 @@ void *wine_server_alloc_req( size_t fixed_size, size_t var_size )
* *
* Send a request to the server. * Send a request to the server.
*/ */
static void send_request( enum request req, union generic_request *request ) static void send_request( union generic_request *request )
{ {
int ret; int ret;
request->header.req = req;
NtCurrentTeb()->buffer_info->cur_req = (char *)request - (char *)NtCurrentTeb()->buffer;
if ((ret = write( NtCurrentTeb()->request_fd, request, sizeof(*request) )) == sizeof(*request)) if ((ret = write( NtCurrentTeb()->request_fd, request, sizeof(*request) )) == sizeof(*request))
return; return;
if (ret >= 0) server_protocol_error( "partial write %d\n", ret ); if (ret >= 0) server_protocol_error( "partial write %d\n", ret );
...@@ -170,7 +163,7 @@ static void send_request( enum request req, union generic_request *request ) ...@@ -170,7 +163,7 @@ static void send_request( enum request req, union generic_request *request )
* *
* Send a request to the server, passing a file descriptor. * Send a request to the server, passing a file descriptor.
*/ */
static void send_request_fd( enum request req, union generic_request *request, int fd ) static void send_request_fd( union generic_request *request, int fd )
{ {
#ifndef HAVE_MSGHDR_ACCRIGHTS #ifndef HAVE_MSGHDR_ACCRIGHTS
struct cmsg_fd cmsg; struct cmsg_fd cmsg;
...@@ -200,8 +193,6 @@ static void send_request_fd( enum request req, union generic_request *request, i ...@@ -200,8 +193,6 @@ static void send_request_fd( enum request req, union generic_request *request, i
msghdr.msg_flags = 0; msghdr.msg_flags = 0;
#endif /* HAVE_MSGHDR_ACCRIGHTS */ #endif /* HAVE_MSGHDR_ACCRIGHTS */
request->header.req = req;
if ((ret = sendmsg( NtCurrentTeb()->socket, &msghdr, 0 )) == sizeof(*request)) return; if ((ret = sendmsg( NtCurrentTeb()->socket, &msghdr, 0 )) == sizeof(*request)) return;
if (ret >= 0) server_protocol_error( "partial write %d\n", ret ); if (ret >= 0) server_protocol_error( "partial write %d\n", ret );
if (errno == EPIPE) SYSDEPS_ExitThread(0); if (errno == EPIPE) SYSDEPS_ExitThread(0);
...@@ -237,30 +228,26 @@ static void wait_reply( union generic_request *req ) ...@@ -237,30 +228,26 @@ static void wait_reply( union generic_request *req )
* *
* Perform a server call. * Perform a server call.
*/ */
unsigned int wine_server_call( enum request req ) unsigned int wine_server_call( union generic_request *req, size_t size )
{ {
union generic_request *req_ptr = NtCurrentTeb()->buffer; memset( (char *)req + size, 0, sizeof(*req) - size );
send_request( req, req_ptr ); send_request( req );
wait_reply( req_ptr ); wait_reply( req );
return req_ptr->header.error; return req->header.error;
} }
/*********************************************************************** /***********************************************************************
* server_call_fd * wine_server_call_fd
* *
* Perform a server call, passing a file descriptor. * Perform a server call, passing a file descriptor.
*/ */
unsigned int server_call_fd( enum request req, int fd_out ) unsigned int wine_server_call_fd( union generic_request *req, size_t size, int fd )
{ {
unsigned int res; memset( (char *)req + size, 0, sizeof(*req) - size );
union generic_request *req_ptr = NtCurrentTeb()->buffer; send_request_fd( req, fd );
wait_reply( req );
send_request_fd( req, req_ptr, fd_out ); return req->header.error;
wait_reply( req_ptr );
if ((res = req_ptr->header.error)) SetLastError( RtlNtStatusToDosError(res) );
return res; /* error code */
} }
...@@ -271,14 +258,13 @@ unsigned int server_call_fd( enum request req, int fd_out ) ...@@ -271,14 +258,13 @@ unsigned int server_call_fd( enum request req, int fd_out )
*/ */
static int set_handle_fd( int handle, int fd ) static int set_handle_fd( int handle, int fd )
{ {
SERVER_START_REQ SERVER_START_REQ( set_handle_info )
{ {
struct set_handle_info_request *req = wine_server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->flags = 0; req->flags = 0;
req->mask = 0; req->mask = 0;
req->fd = fd; req->fd = fd;
if (!server_call( REQ_SET_HANDLE_INFO )) if (!SERVER_CALL())
{ {
if (req->cur_fd != fd) if (req->cur_fd != fd)
{ {
...@@ -597,7 +583,7 @@ int CLIENT_InitThread(void) ...@@ -597,7 +583,7 @@ int CLIENT_InitThread(void)
{ {
struct get_thread_buffer_request *req; struct get_thread_buffer_request *req;
TEB *teb = NtCurrentTeb(); TEB *teb = NtCurrentTeb();
int fd, ret, size; int fd, ret;
/* ignore SIGPIPE so that we get a EPIPE error instead */ /* ignore SIGPIPE so that we get a EPIPE error instead */
signal( SIGPIPE, SIG_IGN ); signal( SIGPIPE, SIG_IGN );
...@@ -617,11 +603,11 @@ int CLIENT_InitThread(void) ...@@ -617,11 +603,11 @@ int CLIENT_InitThread(void)
fd = wine_server_recv_fd( 0, 0 ); fd = wine_server_recv_fd( 0, 0 );
if (fd == -1) server_protocol_error( "no fd received for thread buffer\n" ); if (fd == -1) server_protocol_error( "no fd received for thread buffer\n" );
if ((size = lseek( fd, 0, SEEK_END )) == -1) server_protocol_perror( "lseek" ); if ((teb->buffer_size = lseek( fd, 0, SEEK_END )) == -1) server_protocol_perror( "lseek" );
teb->buffer = mmap( 0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 ); teb->buffer = mmap( 0, teb->buffer_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
teb->buffer_pos = 0;
close( fd ); close( fd );
if (teb->buffer == (void*)-1) server_protocol_perror( "mmap" ); if (teb->buffer == (void*)-1) server_protocol_perror( "mmap" );
teb->buffer_info = (struct server_buffer_info *)((char *)teb->buffer + size) - 1;
req = (struct get_thread_buffer_request *)teb->buffer; req = (struct get_thread_buffer_request *)teb->buffer;
wait_reply( (union generic_request *)req ); wait_reply( (union generic_request *)req );
...@@ -638,13 +624,12 @@ int CLIENT_InitThread(void) ...@@ -638,13 +624,12 @@ int CLIENT_InitThread(void)
if (req->boot) boot_thread_id = teb->tid; if (req->boot) boot_thread_id = teb->tid;
else if (boot_thread_id == teb->tid) boot_thread_id = 0; else if (boot_thread_id == teb->tid) boot_thread_id = 0;
SERVER_START_REQ SERVER_START_REQ( init_thread )
{ {
struct init_thread_request *req = wine_server_alloc_req( sizeof(*req), 0 );
req->unix_pid = getpid(); req->unix_pid = getpid();
req->teb = teb; req->teb = teb;
req->entry = teb->entry_point; req->entry = teb->entry_point;
ret = wine_server_call( REQ_INIT_THREAD ); ret = SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -659,11 +644,10 @@ int CLIENT_InitThread(void) ...@@ -659,11 +644,10 @@ int CLIENT_InitThread(void)
int CLIENT_BootDone( int debug_level ) int CLIENT_BootDone( int debug_level )
{ {
int ret; int ret;
SERVER_START_REQ SERVER_START_REQ( boot_done )
{ {
struct boot_done_request *req = wine_server_alloc_req( sizeof(*req), 0 );
req->debug_level = debug_level; req->debug_level = debug_level;
ret = server_call( REQ_BOOT_DONE ); ret = SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
......
...@@ -41,14 +41,13 @@ BOOL WINAPI CloseHandle( HANDLE handle ) ...@@ -41,14 +41,13 @@ BOOL WINAPI CloseHandle( HANDLE handle )
BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags ) BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( set_handle_info )
{ {
struct set_handle_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->flags = 0; req->flags = 0;
req->mask = 0; req->mask = 0;
req->fd = -1; req->fd = -1;
ret = !server_call( REQ_SET_HANDLE_INFO ); ret = !SERVER_CALL_ERR();
if (ret && flags) *flags = req->old_flags; if (ret && flags) *flags = req->old_flags;
} }
SERVER_END_REQ; SERVER_END_REQ;
...@@ -62,14 +61,13 @@ BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags ) ...@@ -62,14 +61,13 @@ BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags ) BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( set_handle_info )
{ {
struct set_handle_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->flags = flags; req->flags = flags;
req->mask = mask; req->mask = mask;
req->fd = -1; req->fd = -1;
ret = !server_call( REQ_SET_HANDLE_INFO ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -84,10 +82,8 @@ BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source, ...@@ -84,10 +82,8 @@ BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
DWORD access, BOOL inherit, DWORD options ) DWORD access, BOOL inherit, DWORD options )
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( dup_handle )
{ {
struct dup_handle_request *req = server_alloc_req( sizeof(*req), 0 );
req->src_process = source_process; req->src_process = source_process;
req->src_handle = source; req->src_handle = source;
req->dst_process = dest_process; req->dst_process = dest_process;
...@@ -95,7 +91,7 @@ BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source, ...@@ -95,7 +91,7 @@ BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
req->inherit = inherit; req->inherit = inherit;
req->options = options; req->options = options;
ret = !server_call( REQ_DUP_HANDLE ); ret = !SERVER_CALL_ERR();
if (ret) if (ret)
{ {
if (dest) *dest = req->handle; if (dest) *dest = req->handle;
......
...@@ -17,12 +17,10 @@ BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe, ...@@ -17,12 +17,10 @@ BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
LPSECURITY_ATTRIBUTES sa, DWORD size ) LPSECURITY_ATTRIBUTES sa, DWORD size )
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( create_pipe )
{ {
struct create_pipe_request *req = server_alloc_req( sizeof(*req), 0 );
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if ((ret = !server_call( REQ_CREATE_PIPE ))) if ((ret = !SERVER_CALL_ERR()))
{ {
*hReadPipe = req->handle_read; *hReadPipe = req->handle_read;
*hWritePipe = req->handle_write; *hWritePipe = req->handle_write;
......
...@@ -72,18 +72,17 @@ static void call_apcs( BOOL alertable ) ...@@ -72,18 +72,17 @@ static void call_apcs( BOOL alertable )
for (;;) for (;;)
{ {
int type = APC_NONE; int type = APC_NONE;
SERVER_START_REQ SERVER_START_VAR_REQ( get_apc, sizeof(args) )
{ {
struct get_apc_request *req = server_alloc_req( sizeof(*req), sizeof(args) );
req->alertable = alertable; req->alertable = alertable;
if (!server_call( REQ_GET_APC )) if (!SERVER_CALL())
{ {
type = req->type; type = req->type;
proc = req->func; proc = req->func;
memcpy( args, server_data_ptr(req), server_data_size(req) ); memcpy( args, server_data_ptr(req), server_data_size(req) );
} }
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
switch(type) switch(type)
{ {
...@@ -176,9 +175,8 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, ...@@ -176,9 +175,8 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
for (;;) for (;;)
{ {
SERVER_START_REQ SERVER_START_VAR_REQ( select, count * sizeof(int) )
{ {
struct select_request *req = server_alloc_req( sizeof(*req), count * sizeof(int) );
int *data = server_data_ptr( req ); int *data = server_data_ptr( req );
req->flags = SELECT_INTERRUPTIBLE; req->flags = SELECT_INTERRUPTIBLE;
...@@ -190,9 +188,9 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, ...@@ -190,9 +188,9 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
if (alertable) req->flags |= SELECT_ALERTABLE; if (alertable) req->flags |= SELECT_ALERTABLE;
if (timeout != INFINITE) req->flags |= SELECT_TIMEOUT; if (timeout != INFINITE) req->flags |= SELECT_TIMEOUT;
ret = server_call_noerr( REQ_SELECT ); ret = SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
if (ret == STATUS_PENDING) ret = wait_reply(); if (ret == STATUS_PENDING) ret = wait_reply();
if (ret != STATUS_USER_APC) break; if (ret != STATUS_USER_APC) break;
call_apcs( alertable ); call_apcs( alertable );
......
...@@ -55,12 +55,11 @@ TEB *THREAD_IdToTEB( DWORD id ) ...@@ -55,12 +55,11 @@ TEB *THREAD_IdToTEB( DWORD id )
if (!id || id == GetCurrentThreadId()) return NtCurrentTeb(); if (!id || id == GetCurrentThreadId()) return NtCurrentTeb();
SERVER_START_REQ SERVER_START_REQ( get_thread_info )
{ {
struct get_thread_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = 0; req->handle = 0;
req->tid_in = (void *)id; req->tid_in = (void *)id;
if (!server_call_noerr( REQ_GET_THREAD_INFO )) ret = req->teb; if (!SERVER_CALL()) ret = req->teb;
} }
SERVER_END_REQ; SERVER_END_REQ;
...@@ -121,8 +120,7 @@ static void CALLBACK THREAD_FreeTEB( TEB *teb ) ...@@ -121,8 +120,7 @@ static void CALLBACK THREAD_FreeTEB( TEB *teb )
close( teb->wait_fd ); close( teb->wait_fd );
if (teb->stack_sel) FreeSelector16( teb->stack_sel ); if (teb->stack_sel) FreeSelector16( teb->stack_sel );
FreeSelector16( teb->teb_sel ); FreeSelector16( teb->teb_sel );
if (teb->buffer) munmap( (void *)teb->buffer, if (teb->buffer) munmap( (void *)teb->buffer, teb->buffer_size );
(char *)(teb->buffer_info+1) - (char *)teb->buffer );
if (teb->debug_info) HeapFree( GetProcessHeap(), 0, teb->debug_info ); if (teb->debug_info) HeapFree( GetProcessHeap(), 0, teb->debug_info );
VirtualFree( teb->stack_base, 0, MEM_RELEASE ); VirtualFree( teb->stack_base, 0, MEM_RELEASE );
} }
...@@ -313,13 +311,11 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack, ...@@ -313,13 +311,11 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
TEB *teb; TEB *teb;
void *tid = 0; void *tid = 0;
SERVER_START_REQ SERVER_START_REQ( new_thread )
{ {
struct new_thread_request *req = server_alloc_req( sizeof(*req), 0 );
req->suspend = ((flags & CREATE_SUSPENDED) != 0); req->suspend = ((flags & CREATE_SUSPENDED) != 0);
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (!server_call( REQ_NEW_THREAD )) if (!SERVER_CALL_ERR())
{ {
handle = req->handle; handle = req->handle;
tid = req->tid; tid = req->tid;
...@@ -382,14 +378,12 @@ HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack, ...@@ -382,14 +378,12 @@ HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack,
void WINAPI ExitThread( DWORD code ) /* [in] Exit code for this thread */ void WINAPI ExitThread( DWORD code ) /* [in] Exit code for this thread */
{ {
BOOL last; BOOL last;
SERVER_START_REQ SERVER_START_REQ( terminate_thread )
{ {
struct terminate_thread_request *req = server_alloc_req( sizeof(*req), 0 );
/* send the exit code to the server */ /* send the exit code to the server */
req->handle = GetCurrentThread(); req->handle = GetCurrentThread();
req->exit_code = code; req->exit_code = code;
server_call( REQ_TERMINATE_THREAD ); SERVER_CALL();
last = req->last; last = req->last;
} }
SERVER_END_REQ; SERVER_END_REQ;
...@@ -419,16 +413,14 @@ BOOL WINAPI SetThreadContext( HANDLE handle, /* [in] Handle to thread ...@@ -419,16 +413,14 @@ BOOL WINAPI SetThreadContext( HANDLE handle, /* [in] Handle to thread
const CONTEXT *context ) /* [in] Address of context structure */ const CONTEXT *context ) /* [in] Address of context structure */
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_VAR_REQ( set_thread_context, sizeof(*context) )
{ {
struct set_thread_context_request *req = server_alloc_req( sizeof(*req),
sizeof(*context) );
req->handle = handle; req->handle = handle;
req->flags = context->ContextFlags; req->flags = context->ContextFlags;
memcpy( server_data_ptr(req), context, sizeof(*context) ); memcpy( server_data_ptr(req), context, sizeof(*context) );
ret = !server_call( REQ_SET_THREAD_CONTEXT ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -444,17 +436,15 @@ BOOL WINAPI GetThreadContext( HANDLE handle, /* [in] Handle to thread with ...@@ -444,17 +436,15 @@ BOOL WINAPI GetThreadContext( HANDLE handle, /* [in] Handle to thread with
CONTEXT *context ) /* [out] Address of context structure */ CONTEXT *context ) /* [out] Address of context structure */
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_VAR_REQ( get_thread_context, sizeof(*context) )
{ {
struct get_thread_context_request *req = server_alloc_req( sizeof(*req),
sizeof(*context) );
req->handle = handle; req->handle = handle;
req->flags = context->ContextFlags; req->flags = context->ContextFlags;
memcpy( server_data_ptr(req), context, sizeof(*context) ); memcpy( server_data_ptr(req), context, sizeof(*context) );
if ((ret = !server_call( REQ_GET_THREAD_CONTEXT ))) if ((ret = !SERVER_CALL_ERR()))
memcpy( context, server_data_ptr(req), sizeof(*context) ); memcpy( context, server_data_ptr(req), sizeof(*context) );
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -470,12 +460,11 @@ INT WINAPI GetThreadPriority( ...@@ -470,12 +460,11 @@ INT WINAPI GetThreadPriority(
HANDLE hthread) /* [in] Handle to thread */ HANDLE hthread) /* [in] Handle to thread */
{ {
INT ret = THREAD_PRIORITY_ERROR_RETURN; INT ret = THREAD_PRIORITY_ERROR_RETURN;
SERVER_START_REQ SERVER_START_REQ( get_thread_info )
{ {
struct get_thread_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hthread; req->handle = hthread;
req->tid_in = 0; req->tid_in = 0;
if (!server_call( REQ_GET_THREAD_INFO )) ret = req->priority; if (!SERVER_CALL_ERR()) ret = req->priority;
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -494,13 +483,12 @@ BOOL WINAPI SetThreadPriority( ...@@ -494,13 +483,12 @@ BOOL WINAPI SetThreadPriority(
INT priority) /* [in] Thread priority level */ INT priority) /* [in] Thread priority level */
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( set_thread_info )
{ {
struct set_thread_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hthread; req->handle = hthread;
req->priority = priority; req->priority = priority;
req->mask = SET_THREAD_INFO_PRIORITY; req->mask = SET_THREAD_INFO_PRIORITY;
ret = !server_call( REQ_SET_THREAD_INFO ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -549,13 +537,12 @@ BOOL WINAPI SetThreadPriorityBoost( ...@@ -549,13 +537,12 @@ BOOL WINAPI SetThreadPriorityBoost(
DWORD WINAPI SetThreadAffinityMask( HANDLE hThread, DWORD dwThreadAffinityMask ) DWORD WINAPI SetThreadAffinityMask( HANDLE hThread, DWORD dwThreadAffinityMask )
{ {
DWORD ret; DWORD ret;
SERVER_START_REQ SERVER_START_REQ( set_thread_info )
{ {
struct set_thread_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hThread; req->handle = hThread;
req->affinity = dwThreadAffinityMask; req->affinity = dwThreadAffinityMask;
req->mask = SET_THREAD_INFO_AFFINITY; req->mask = SET_THREAD_INFO_AFFINITY;
ret = !server_call( REQ_SET_THREAD_INFO ); ret = !SERVER_CALL_ERR();
/* FIXME: should return previous value */ /* FIXME: should return previous value */
} }
SERVER_END_REQ; SERVER_END_REQ;
...@@ -594,12 +581,11 @@ BOOL WINAPI GetExitCodeThread( ...@@ -594,12 +581,11 @@ BOOL WINAPI GetExitCodeThread(
LPDWORD exitcode) /* [out] Address to receive termination status */ LPDWORD exitcode) /* [out] Address to receive termination status */
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( get_thread_info )
{ {
struct get_thread_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hthread; req->handle = hthread;
req->tid_in = 0; req->tid_in = 0;
ret = !server_call( REQ_GET_THREAD_INFO ); ret = !SERVER_CALL_ERR();
if (ret && exitcode) *exitcode = req->exit_code; if (ret && exitcode) *exitcode = req->exit_code;
} }
SERVER_END_REQ; SERVER_END_REQ;
...@@ -622,11 +608,10 @@ DWORD WINAPI ResumeThread( ...@@ -622,11 +608,10 @@ DWORD WINAPI ResumeThread(
HANDLE hthread) /* [in] Identifies thread to restart */ HANDLE hthread) /* [in] Identifies thread to restart */
{ {
DWORD ret = 0xffffffff; DWORD ret = 0xffffffff;
SERVER_START_REQ SERVER_START_REQ( resume_thread )
{ {
struct resume_thread_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hthread; req->handle = hthread;
if (!server_call( REQ_RESUME_THREAD )) ret = req->count; if (!SERVER_CALL_ERR()) ret = req->count;
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -644,11 +629,10 @@ DWORD WINAPI SuspendThread( ...@@ -644,11 +629,10 @@ DWORD WINAPI SuspendThread(
HANDLE hthread) /* [in] Handle to the thread */ HANDLE hthread) /* [in] Handle to the thread */
{ {
DWORD ret = 0xffffffff; DWORD ret = 0xffffffff;
SERVER_START_REQ SERVER_START_REQ( suspend_thread )
{ {
struct suspend_thread_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hthread; req->handle = hthread;
if (!server_call( REQ_SUSPEND_THREAD )) ret = req->count; if (!SERVER_CALL_ERR()) ret = req->count;
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -661,14 +645,13 @@ DWORD WINAPI SuspendThread( ...@@ -661,14 +645,13 @@ DWORD WINAPI SuspendThread(
DWORD WINAPI QueueUserAPC( PAPCFUNC func, HANDLE hthread, ULONG_PTR data ) DWORD WINAPI QueueUserAPC( PAPCFUNC func, HANDLE hthread, ULONG_PTR data )
{ {
DWORD ret; DWORD ret;
SERVER_START_REQ SERVER_START_REQ( queue_apc )
{ {
struct queue_apc_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hthread; req->handle = hthread;
req->user = 1; req->user = 1;
req->func = func; req->func = func;
req->param = (void *)data; req->param = (void *)data;
ret = !server_call( REQ_QUEUE_APC ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
......
...@@ -25,18 +25,16 @@ HANDLE WINAPI CreateWaitableTimerA( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCSTR ...@@ -25,18 +25,16 @@ HANDLE WINAPI CreateWaitableTimerA( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCSTR
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( create_timer, len * sizeof(WCHAR) )
{ {
struct create_timer_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->manual = manual; req->manual = manual;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len ); if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0); SetLastError(0);
server_call( REQ_CREATE_TIMER ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -53,18 +51,16 @@ HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWST ...@@ -53,18 +51,16 @@ HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWST
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( create_timer, len * sizeof(WCHAR) )
{ {
struct create_timer_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->manual = manual; req->manual = manual;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) ); memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0); SetLastError(0);
server_call( REQ_CREATE_TIMER ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -81,17 +77,15 @@ HANDLE WINAPI OpenWaitableTimerA( DWORD access, BOOL inherit, LPCSTR name ) ...@@ -81,17 +77,15 @@ HANDLE WINAPI OpenWaitableTimerA( DWORD access, BOOL inherit, LPCSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( open_timer, len * sizeof(WCHAR) )
{ {
struct open_timer_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access; req->access = access;
req->inherit = inherit; req->inherit = inherit;
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len ); if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
server_call( REQ_OPEN_TIMER ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -108,17 +102,15 @@ HANDLE WINAPI OpenWaitableTimerW( DWORD access, BOOL inherit, LPCWSTR name ) ...@@ -108,17 +102,15 @@ HANDLE WINAPI OpenWaitableTimerW( DWORD access, BOOL inherit, LPCWSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE ); SetLastError( ERROR_FILENAME_EXCED_RANGE );
return 0; return 0;
} }
SERVER_START_REQ SERVER_START_VAR_REQ( open_timer, len * sizeof(WCHAR) )
{ {
struct open_timer_request *req = server_alloc_req( sizeof(*req), len * sizeof(WCHAR) );
req->access = access; req->access = access;
req->inherit = inherit; req->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) ); memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_TIMER ); SERVER_CALL_ERR();
ret = req->handle; ret = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -139,10 +131,8 @@ BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG per ...@@ -139,10 +131,8 @@ BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG per
exp.QuadPart = RtlLargeIntegerSubtract( now.QuadPart, exp.QuadPart ); exp.QuadPart = RtlLargeIntegerSubtract( now.QuadPart, exp.QuadPart );
} }
SERVER_START_REQ SERVER_START_REQ( set_timer )
{ {
struct set_timer_request *req = server_alloc_req( sizeof(*req), 0 );
if (!exp.s.LowPart && !exp.s.HighPart) if (!exp.s.LowPart && !exp.s.HighPart)
{ {
/* special case to start timeout on now+period without too many calculations */ /* special case to start timeout on now+period without too many calculations */
...@@ -160,7 +150,7 @@ BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG per ...@@ -160,7 +150,7 @@ BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG per
req->callback = callback; req->callback = callback;
req->arg = arg; req->arg = arg;
if (resume) SetLastError( ERROR_NOT_SUPPORTED ); /* set error but can still succeed */ if (resume) SetLastError( ERROR_NOT_SUPPORTED ); /* set error but can still succeed */
ret = !server_call( REQ_SET_TIMER ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -173,11 +163,10 @@ BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG per ...@@ -173,11 +163,10 @@ BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG per
BOOL WINAPI CancelWaitableTimer( HANDLE handle ) BOOL WINAPI CancelWaitableTimer( HANDLE handle )
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( cancel_timer )
{ {
struct cancel_timer_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
ret = !server_call( REQ_CANCEL_TIMER ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
......
...@@ -178,12 +178,18 @@ static inline void call_req_handler( struct thread *thread, union generic_reques ...@@ -178,12 +178,18 @@ static inline void call_req_handler( struct thread *thread, union generic_reques
if (debug_level) trace_request( thread, request ); if (debug_level) trace_request( thread, request );
if ((unsigned int)request->header.var_offset + request->header.var_size > MAX_REQUEST_LENGTH) if (request->header.var_size)
{ {
fatal_protocol_error( current, "bad request offset/size %d/%d\n", if ((unsigned int)request->header.var_offset +
request->header.var_offset, request->header.var_size ); request->header.var_size > MAX_REQUEST_LENGTH)
{
fatal_protocol_error( current, "bad request offset/size %d/%d\n",
request->header.var_offset, request->header.var_size );
return;
}
} }
else if (req < REQ_NB_REQUESTS)
if (req < REQ_NB_REQUESTS)
{ {
req_handlers[req]( request ); req_handlers[req]( request );
if (current) send_reply( current, request ); if (current) send_reply( current, request );
......
...@@ -101,7 +101,6 @@ static int alloc_client_buffer( struct thread *thread ) ...@@ -101,7 +101,6 @@ static int alloc_client_buffer( struct thread *thread )
if (ftruncate( fd, MAX_REQUEST_LENGTH ) == -1) goto error; if (ftruncate( fd, MAX_REQUEST_LENGTH ) == -1) goto error;
if ((thread->buffer = mmap( 0, MAX_REQUEST_LENGTH, PROT_READ | PROT_WRITE, if ((thread->buffer = mmap( 0, MAX_REQUEST_LENGTH, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0 )) == (void*)-1) goto error; MAP_SHARED, fd, 0 )) == (void*)-1) goto error;
thread->buffer_info = (struct server_buffer_info *)((char *)thread->buffer + MAX_REQUEST_LENGTH) - 1;
if (!(thread->request_fd = create_request_socket( thread ))) goto error; if (!(thread->request_fd = create_request_socket( thread ))) goto error;
thread->reply_fd = fd_pipe[1]; thread->reply_fd = fd_pipe[1];
thread->wait_fd = wait_pipe[1]; thread->wait_fd = wait_pipe[1];
...@@ -177,7 +176,7 @@ struct thread *create_thread( int fd, struct process *process ) ...@@ -177,7 +176,7 @@ struct thread *create_thread( int fd, struct process *process )
thread->affinity = 1; thread->affinity = 1;
thread->suspend = 0; thread->suspend = 0;
thread->buffer = (void *)-1; thread->buffer = (void *)-1;
thread->last_req = REQ_GET_THREAD_BUFFER; thread->last_req = REQ_get_thread_buffer;
thread->process = (struct process *)grab_object( process ); thread->process = (struct process *)grab_object( process );
if (!current) current = thread; if (!current) current = thread;
...@@ -690,7 +689,7 @@ DECL_HANDLER(boot_done) ...@@ -690,7 +689,7 @@ DECL_HANDLER(boot_done)
{ {
debug_level = max( debug_level, req->debug_level ); debug_level = max( debug_level, req->debug_level );
/* Make sure last_req is initialized */ /* Make sure last_req is initialized */
current->last_req = REQ_BOOT_DONE; current->last_req = REQ_boot_done;
if (current == booting_thread) if (current == booting_thread)
{ {
booting_thread = (struct thread *)~0UL; /* make sure it doesn't match other threads */ booting_thread = (struct thread *)~0UL; /* make sure it doesn't match other threads */
......
...@@ -67,7 +67,6 @@ struct thread ...@@ -67,7 +67,6 @@ struct thread
int affinity; /* affinity mask */ int affinity; /* affinity mask */
int suspend; /* suspend count */ int suspend; /* suspend count */
void *buffer; /* buffer for communication with the client */ void *buffer; /* buffer for communication with the client */
struct server_buffer_info *buffer_info; /* buffer information structure */
enum request last_req; /* last request received (for debugging) */ enum request last_req; /* last request received (for debugging) */
}; };
......
...@@ -63,7 +63,7 @@ REPLACE_IN_FILE( "server/trace.c", @trace_lines ); ...@@ -63,7 +63,7 @@ REPLACE_IN_FILE( "server/trace.c", @trace_lines );
my @server_lines = (); my @server_lines = ();
push @server_lines, "enum request\n{\n"; push @server_lines, "enum request\n{\n";
foreach $req (@requests) { push @server_lines, " REQ_\U$req,\n"; } foreach $req (@requests) { push @server_lines, " REQ_$req,\n"; }
push @server_lines, " REQ_NB_REQUESTS\n};\n\n"; push @server_lines, " REQ_NB_REQUESTS\n};\n\n";
push @server_lines, "union generic_request\n{\n"; push @server_lines, "union generic_request\n{\n";
push @server_lines, " struct request_max_size max_size;\n"; push @server_lines, " struct request_max_size max_size;\n";
......
...@@ -101,11 +101,10 @@ extern int wine_openpty(int *master, int *slave, char *name, ...@@ -101,11 +101,10 @@ extern int wine_openpty(int *master, int *slave, char *name,
static int CONSOLE_GetPid( HANDLE handle ) static int CONSOLE_GetPid( HANDLE handle )
{ {
int ret = 0; int ret = 0;
SERVER_START_REQ SERVER_START_REQ( get_console_info )
{ {
struct get_console_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
if (!server_call( REQ_GET_CONSOLE_INFO )) ret = req->pid; if (!SERVER_CALL_ERR()) ret = req->pid;
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -333,19 +332,17 @@ static BOOL read_console_input( HANDLE handle, LPINPUT_RECORD buffer, DWORD coun ...@@ -333,19 +332,17 @@ static BOOL read_console_input( HANDLE handle, LPINPUT_RECORD buffer, DWORD coun
count = min( count, REQUEST_MAX_VAR_SIZE/sizeof(INPUT_RECORD) ); count = min( count, REQUEST_MAX_VAR_SIZE/sizeof(INPUT_RECORD) );
SERVER_START_REQ SERVER_START_VAR_REQ( read_console_input, count*sizeof(INPUT_RECORD) )
{ {
struct read_console_input_request *req = server_alloc_req( sizeof(*req),
count*sizeof(INPUT_RECORD) );
req->handle = handle; req->handle = handle;
req->flush = flush; req->flush = flush;
if ((ret = !server_call( REQ_READ_CONSOLE_INPUT ))) if ((ret = !SERVER_CALL_ERR()))
{ {
if (count) memcpy( buffer, server_data_ptr(req), server_data_size(req) ); if (count) memcpy( buffer, server_data_ptr(req), server_data_size(req) );
if (read) *read = req->read; if (read) *read = req->read;
} }
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
return ret; return ret;
} }
...@@ -554,10 +551,9 @@ COORD WINAPI GetLargestConsoleWindowSize( HANDLE hConsoleOutput ) ...@@ -554,10 +551,9 @@ COORD WINAPI GetLargestConsoleWindowSize( HANDLE hConsoleOutput )
BOOL WINAPI FreeConsole(VOID) BOOL WINAPI FreeConsole(VOID)
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( free_console )
{ {
struct free_console_request *req = server_alloc_req( sizeof(*req), 0 ); ret = !SERVER_CALL_ERR();
ret = !server_call( REQ_FREE_CONSOLE );
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -629,14 +625,13 @@ static BOOL CONSOLE_make_complex(HANDLE handle) ...@@ -629,14 +625,13 @@ static BOOL CONSOLE_make_complex(HANDLE handle)
CloseHandle( pty_handle ); CloseHandle( pty_handle );
return FALSE; return FALSE;
} }
SERVER_START_REQ SERVER_START_REQ( set_console_fd )
{ {
struct set_console_fd_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
req->handle_in = pty_handle; req->handle_in = pty_handle;
req->handle_out = pty_handle; req->handle_out = pty_handle;
req->pid = xpid; req->pid = xpid;
server_call( REQ_SET_CONSOLE_FD ); SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
CloseHandle( pty_handle ); CloseHandle( pty_handle );
...@@ -669,13 +664,11 @@ BOOL WINAPI AllocConsole(VOID) ...@@ -669,13 +664,11 @@ BOOL WINAPI AllocConsole(VOID)
TRACE("()\n"); TRACE("()\n");
SERVER_START_REQ SERVER_START_REQ( alloc_console )
{ {
struct alloc_console_request *req = server_alloc_req( sizeof(*req), 0 );
req->access = GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE; req->access = GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE;
req->inherit = FALSE; req->inherit = FALSE;
ret = !server_call( REQ_ALLOC_CONSOLE ); ret = !SERVER_CALL_ERR();
handle_in = req->handle_in; handle_in = req->handle_in;
handle_out = req->handle_out; handle_out = req->handle_out;
} }
...@@ -728,11 +721,10 @@ UINT WINAPI GetConsoleOutputCP(VOID) ...@@ -728,11 +721,10 @@ UINT WINAPI GetConsoleOutputCP(VOID)
BOOL WINAPI GetConsoleMode(HANDLE hcon,LPDWORD mode) BOOL WINAPI GetConsoleMode(HANDLE hcon,LPDWORD mode)
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( get_console_mode )
{ {
struct get_console_mode_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hcon; req->handle = hcon;
ret = !server_call( REQ_GET_CONSOLE_MODE ); ret = !SERVER_CALL_ERR();
if (ret && mode) *mode = req->mode; if (ret && mode) *mode = req->mode;
} }
SERVER_END_REQ; SERVER_END_REQ;
...@@ -754,12 +746,11 @@ BOOL WINAPI GetConsoleMode(HANDLE hcon,LPDWORD mode) ...@@ -754,12 +746,11 @@ BOOL WINAPI GetConsoleMode(HANDLE hcon,LPDWORD mode)
BOOL WINAPI SetConsoleMode( HANDLE hcon, DWORD mode ) BOOL WINAPI SetConsoleMode( HANDLE hcon, DWORD mode )
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( set_console_mode )
{ {
struct set_console_mode_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hcon; req->handle = hcon;
req->mode = mode; req->mode = mode;
ret = !server_call( REQ_SET_CONSOLE_MODE ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
...@@ -794,12 +785,10 @@ DWORD WINAPI GetConsoleTitleA(LPSTR title,DWORD size) ...@@ -794,12 +785,10 @@ DWORD WINAPI GetConsoleTitleA(LPSTR title,DWORD size)
if ((hcon = CreateFileA( "CONOUT$", GENERIC_READ, 0, NULL, if ((hcon = CreateFileA( "CONOUT$", GENERIC_READ, 0, NULL,
OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE) OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE)
return 0; return 0;
SERVER_START_REQ SERVER_START_VAR_REQ( get_console_info, REQUEST_MAX_VAR_SIZE )
{ {
struct get_console_info_request *req = server_alloc_req( sizeof(*req),
REQUEST_MAX_VAR_SIZE );
req->handle = hcon; req->handle = hcon;
if (!server_call( REQ_GET_CONSOLE_INFO )) if (!SERVER_CALL_ERR())
{ {
ret = server_data_size(req); ret = server_data_size(req);
size = min( size-1, ret ); size = min( size-1, ret );
...@@ -807,7 +796,7 @@ DWORD WINAPI GetConsoleTitleA(LPSTR title,DWORD size) ...@@ -807,7 +796,7 @@ DWORD WINAPI GetConsoleTitleA(LPSTR title,DWORD size)
title[size] = 0; title[size] = 0;
} }
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
CloseHandle( hcon ); CloseHandle( hcon );
return ret; return ret;
} }
...@@ -1184,20 +1173,18 @@ BOOL WINAPI WriteConsoleInputA( HANDLE handle, INPUT_RECORD *buffer, ...@@ -1184,20 +1173,18 @@ BOOL WINAPI WriteConsoleInputA( HANDLE handle, INPUT_RECORD *buffer,
while (count && ret) while (count && ret)
{ {
DWORD len = min( count, REQUEST_MAX_VAR_SIZE/sizeof(INPUT_RECORD) ); DWORD len = min( count, REQUEST_MAX_VAR_SIZE/sizeof(INPUT_RECORD) );
SERVER_START_REQ SERVER_START_VAR_REQ( write_console_input, len * sizeof(INPUT_RECORD) )
{ {
struct write_console_input_request *req = server_alloc_req( sizeof(*req),
len*sizeof(INPUT_RECORD) );
req->handle = handle; req->handle = handle;
memcpy( server_data_ptr(req), buffer, len * sizeof(INPUT_RECORD) ); memcpy( server_data_ptr(req), buffer, len * sizeof(INPUT_RECORD) );
if ((ret = !server_call( REQ_WRITE_CONSOLE_INPUT ))) if ((ret = !SERVER_CALL_ERR()))
{ {
if (written) *written += req->written; if (written) *written += req->written;
count -= len; count -= len;
buffer += len; buffer += len;
} }
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
} }
return ret; return ret;
} }
...@@ -1237,15 +1224,14 @@ BOOL WINAPI SetConsoleTitleA(LPCSTR title) ...@@ -1237,15 +1224,14 @@ BOOL WINAPI SetConsoleTitleA(LPCSTR title)
return FALSE; return FALSE;
len = min( len, REQUEST_MAX_VAR_SIZE ); len = min( len, REQUEST_MAX_VAR_SIZE );
SERVER_START_REQ SERVER_START_VAR_REQ( set_console_info, len )
{ {
struct set_console_info_request *req = server_alloc_req( sizeof(*req), len );
req->handle = hcon; req->handle = hcon;
req->mask = SET_CONSOLE_INFO_TITLE; req->mask = SET_CONSOLE_INFO_TITLE;
memcpy( server_data_ptr(req), title, len ); memcpy( server_data_ptr(req), title, len );
ret = !server_call( REQ_SET_CONSOLE_INFO ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
if (ret && CONSOLE_GetPid( hcon )) if (ret && CONSOLE_GetPid( hcon ))
{ {
...@@ -1349,11 +1335,10 @@ BOOL WINAPI GetConsoleCursorInfo( HANDLE hcon, LPCONSOLE_CURSOR_INFO cinfo ) ...@@ -1349,11 +1335,10 @@ BOOL WINAPI GetConsoleCursorInfo( HANDLE hcon, LPCONSOLE_CURSOR_INFO cinfo )
{ {
BOOL ret; BOOL ret;
SERVER_START_REQ SERVER_START_REQ( get_console_info )
{ {
struct get_console_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hcon; req->handle = hcon;
ret = !server_call( REQ_GET_CONSOLE_INFO ); ret = !SERVER_CALL_ERR();
if (ret && cinfo) if (ret && cinfo)
{ {
cinfo->dwSize = req->cursor_size; cinfo->dwSize = req->cursor_size;
...@@ -1384,14 +1369,13 @@ BOOL WINAPI SetConsoleCursorInfo( ...@@ -1384,14 +1369,13 @@ BOOL WINAPI SetConsoleCursorInfo(
sprintf(buf,"\033[?25%c",cinfo->bVisible?'h':'l'); sprintf(buf,"\033[?25%c",cinfo->bVisible?'h':'l');
WriteFile(hcon,buf,strlen(buf),&xlen,NULL); WriteFile(hcon,buf,strlen(buf),&xlen,NULL);
SERVER_START_REQ SERVER_START_REQ( set_console_info )
{ {
struct set_console_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hcon; req->handle = hcon;
req->cursor_size = cinfo->dwSize; req->cursor_size = cinfo->dwSize;
req->cursor_visible = cinfo->bVisible; req->cursor_visible = cinfo->bVisible;
req->mask = SET_CONSOLE_INFO_CURSOR; req->mask = SET_CONSOLE_INFO_CURSOR;
ret = !server_call( REQ_SET_CONSOLE_INFO ); ret = !SERVER_CALL_ERR();
} }
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
......
...@@ -337,12 +337,10 @@ HANDLE DEVICE_Open( LPCSTR filename, DWORD access, ...@@ -337,12 +337,10 @@ HANDLE DEVICE_Open( LPCSTR filename, DWORD access,
static const struct VxDInfo *DEVICE_GetInfo( HANDLE handle ) static const struct VxDInfo *DEVICE_GetInfo( HANDLE handle )
{ {
const struct VxDInfo *info = NULL; const struct VxDInfo *info = NULL;
SERVER_START_REQ SERVER_START_REQ( get_file_info )
{ {
struct get_file_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle; req->handle = handle;
if (!server_call( REQ_GET_FILE_INFO ) && if (!SERVER_CALL() &&
(req->type == FILE_TYPE_UNKNOWN) && (req->type == FILE_TYPE_UNKNOWN) &&
(req->attr & 0x10000)) (req->attr & 0x10000))
{ {
......
...@@ -151,33 +151,29 @@ static int send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *c ...@@ -151,33 +151,29 @@ static int send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *c
int ret; int ret;
HANDLE handle = 0; HANDLE handle = 0;
SERVER_START_REQ SERVER_START_VAR_REQ( queue_exception_event, sizeof(*rec) + sizeof(*context) )
{ {
struct queue_exception_event_request *req = server_alloc_req( sizeof(*req),
sizeof(*rec)+sizeof(*context) );
CONTEXT *context_ptr = server_data_ptr(req); CONTEXT *context_ptr = server_data_ptr(req);
EXCEPTION_RECORD *rec_ptr = (EXCEPTION_RECORD *)(context_ptr + 1); EXCEPTION_RECORD *rec_ptr = (EXCEPTION_RECORD *)(context_ptr + 1);
req->first = first_chance; req->first = first_chance;
*rec_ptr = *rec; *rec_ptr = *rec;
*context_ptr = *context; *context_ptr = *context;
if (!server_call_noerr( REQ_QUEUE_EXCEPTION_EVENT )) handle = req->handle; if (!SERVER_CALL()) handle = req->handle;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
if (!handle) return 0; /* no debugger present or other error */ if (!handle) return 0; /* no debugger present or other error */
/* No need to wait on the handle since the process gets suspended /* No need to wait on the handle since the process gets suspended
* once the event is passed to the debugger, so when we get back * once the event is passed to the debugger, so when we get back
* here the event has been continued already. * here the event has been continued already.
*/ */
SERVER_START_REQ SERVER_START_VAR_REQ( get_exception_status, sizeof(*context) )
{ {
struct get_exception_status_request *req = server_alloc_req( sizeof(*req), sizeof(*context) );
req->handle = handle; req->handle = handle;
if (!server_call_noerr( REQ_GET_EXCEPTION_STATUS )) if (!SERVER_CALL()) *context = *(CONTEXT *)server_data_ptr(req);
*context = *(CONTEXT *)server_data_ptr(req);
ret = req->status; ret = req->status;
} }
SERVER_END_REQ; SERVER_END_VAR_REQ;
NtClose( handle ); NtClose( handle );
return ret; return ret;
} }
......
...@@ -451,10 +451,9 @@ static HQUEUE16 QUEUE_CreateMsgQueue( BOOL16 bCreatePerQData ) ...@@ -451,10 +451,9 @@ static HQUEUE16 QUEUE_CreateMsgQueue( BOOL16 bCreatePerQData )
if ( !msgQueue ) if ( !msgQueue )
return 0; return 0;
SERVER_START_REQ SERVER_START_REQ( get_msg_queue )
{ {
struct get_msg_queue_request *req = server_alloc_req( sizeof(*req), 0 ); SERVER_CALL_ERR();
server_call( REQ_GET_MSG_QUEUE );
handle = req->handle; handle = req->handle;
} }
SERVER_END_REQ; SERVER_END_REQ;
...@@ -654,12 +653,11 @@ static BOOL QUEUE_TrySetWakeBit( MESSAGEQUEUE *queue, WORD bit, BOOL always ) ...@@ -654,12 +653,11 @@ static BOOL QUEUE_TrySetWakeBit( MESSAGEQUEUE *queue, WORD bit, BOOL always )
} }
else else
{ {
SERVER_START_REQ SERVER_START_REQ( wake_queue )
{ {
struct wake_queue_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = queue->server_queue; req->handle = queue->server_queue;
req->bits = bit; req->bits = bit;
server_call( REQ_WAKE_QUEUE ); SERVER_CALL();
} }
SERVER_END_REQ; SERVER_END_REQ;
} }
...@@ -1560,12 +1558,11 @@ DWORD WINAPI WaitForInputIdle (HANDLE hProcess, DWORD dwTimeOut) ...@@ -1560,12 +1558,11 @@ DWORD WINAPI WaitForInputIdle (HANDLE hProcess, DWORD dwTimeOut)
DWORD cur_time, ret; DWORD cur_time, ret;
HANDLE idle_event = -1; HANDLE idle_event = -1;
SERVER_START_REQ SERVER_START_REQ( wait_input_idle )
{ {
struct wait_input_idle_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hProcess; req->handle = hProcess;
req->timeout = dwTimeOut; req->timeout = dwTimeOut;
if (!(ret = server_call( REQ_WAIT_INPUT_IDLE ))) idle_event = req->event; if (!(ret = SERVER_CALL_ERR())) idle_event = req->event;
} }
SERVER_END_REQ; SERVER_END_REQ;
if (ret) return 0xffffffff; /* error */ if (ret) return 0xffffffff; /* error */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment