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

part somewhat faster.
This commit is contained in:
Alexandre Julliard 2001-02-27 02:09:16 +00:00
parent 505cf3965c
commit 67a749999a
40 changed files with 612 additions and 849 deletions

View File

@ -33,13 +33,6 @@ static inline int is_string( DWORD type )
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.@]
@ -1228,15 +1221,14 @@ LONG WINAPI RegLoadKeyW( HKEY hkey, LPCWSTR subkey, LPCWSTR filename )
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->file = file;
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 );
done:
@ -1268,16 +1260,15 @@ LONG WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename )
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->file = file;
MultiByteToWideChar( CP_ACP, 0, subkey, strlen(subkey),
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 );
done:
@ -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);
}
SERVER_START_REQ
SERVER_START_REQ( save_registry )
{
struct save_registry_request *req = server_alloc_req( sizeof(*req), 0 );
req->hkey = hkey;
req->file = handle;
ret = reg_server_call( REQ_SAVE_REGISTRY );
ret = RtlNtStatusToDosError( SERVER_CALL() );
}
SERVER_END_REQ;

View File

@ -2072,11 +2072,10 @@ BOOL WINAPI GetCommMask(
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;
if ((ret = !server_call( REQ_GET_SERIAL_INFO )))
if ((ret = !SERVER_CALL_ERR()))
{
if (evtmask) *evtmask = req->eventmask;
}
@ -2104,13 +2103,12 @@ BOOL WINAPI SetCommMask(
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->flags = SERIALINFO_SET_MASK;
req->eventmask = evtmask;
ret = !server_call( REQ_SET_SERIAL_INFO );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -2677,11 +2675,10 @@ BOOL WINAPI GetCommTimeouts(
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;
if ((ret = !server_call( REQ_GET_SERIAL_INFO )))
if ((ret = !SERVER_CALL_ERR()))
{
lptimeouts->ReadIntervalTimeout = req->readinterval;
lptimeouts->ReadTotalTimeoutMultiplier = req->readmult;
@ -2726,9 +2723,8 @@ BOOL WINAPI SetCommTimeouts(
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->flags = SERIALINFO_SET_TIMEOUTS;
req->readinterval = lptimeouts->ReadIntervalTimeout ;
@ -2736,7 +2732,7 @@ BOOL WINAPI SetCommTimeouts(
req->readconst = lptimeouts->ReadTotalTimeoutConstant ;
req->writemult = lptimeouts->WriteTotalTimeoutMultiplier ;
req->writeconst = lptimeouts->WriteTotalTimeoutConstant ;
ret = !server_call( REQ_SET_SERIAL_INFO );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
if (!ret) return FALSE;
@ -2886,10 +2882,8 @@ BOOL WINAPI WaitCommEvent(
lpov->OffsetHigh = 0;
/* 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->overlapped = lpov;
req->buffer = lpdwEvents;
@ -2897,7 +2891,7 @@ BOOL WINAPI WaitCommEvent(
req->func = COMM_WaitCommEventService;
req->type = ASYNC_TYPE_WAIT;
ret=server_call( REQ_CREATE_ASYNC );
ret=SERVER_CALL_ERR();
lpov->InternalHigh = req->ov_handle;
}

View File

@ -36,13 +36,11 @@ BOOL WINAPI WaitForDebugEvent(
for (;;)
{
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);
if (!(ret = !server_call( REQ_WAIT_DEBUG_EVENT ))) goto done;
if (!(ret = !SERVER_CALL_ERR())) goto done;
if (!server_data_size(req)) /* timeout */
{
@ -108,7 +106,7 @@ BOOL WINAPI WaitForDebugEvent(
}
done:
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
if (ret) return TRUE;
if (!wait) break;
res = WaitForSingleObject( wait, timeout );
@ -137,13 +135,12 @@ BOOL WINAPI ContinueDebugEvent(
DWORD status) /* [in] The rule to apply to unhandled exeptions. */
{
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->tid = (void *)tid;
req->status = status;
ret = !server_call( REQ_CONTINUE_DEBUG_EVENT );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -163,11 +160,10 @@ BOOL WINAPI DebugActiveProcess(
DWORD pid) /* [in] The process to be debugged. */
{
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;
ret = !server_call( REQ_DEBUG_PROCESS );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -184,13 +180,12 @@ BOOL WINAPI DebugActiveProcess(
void WINAPI OutputDebugStringA(
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->unicode = 0;
req->length = strlen(str) + 1;
server_call_noerr( REQ_OUTPUT_DEBUG_STRING );
SERVER_CALL();
}
SERVER_END_REQ;
WARN("%s\n", str);
@ -206,13 +201,12 @@ void WINAPI OutputDebugStringA(
void WINAPI OutputDebugStringW(
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->unicode = 1;
req->length = (lstrlenW(str) + 1) * sizeof(WCHAR);
server_call_noerr( REQ_OUTPUT_DEBUG_STRING );
SERVER_CALL();
}
SERVER_END_REQ;
WARN("%s\n", debugstr_w(str));
@ -282,11 +276,10 @@ void WINAPI DebugBreak16(
BOOL WINAPI IsDebuggerPresent(void)
{
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();
if (!server_call( REQ_GET_PROCESS_INFO )) ret = req->debugged;
if (!SERVER_CALL_ERR()) ret = req->debugged;
}
SERVER_END_REQ;
return ret;

View File

@ -31,19 +31,17 @@ HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->initial_state = initial_state;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_EVENT );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -70,19 +68,17 @@ HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
SetLastError( ERROR_INVALID_PARAMETER);
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->initial_state = initial_state;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_EVENT );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -108,17 +104,15 @@ HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->inherit = inherit;
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;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -135,17 +129,15 @@ HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_EVENT );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -158,12 +150,11 @@ HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name )
static BOOL EVENT_Operation( HANDLE handle, enum event_op op )
{
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->op = op;
ret = !server_call( REQ_EVENT_OP );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -257,18 +248,16 @@ HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_MUTEX );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -285,18 +274,16 @@ HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_MUTEX );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -318,17 +305,15 @@ HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->inherit = inherit;
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;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -345,17 +330,15 @@ HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_MUTEX );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -366,11 +349,10 @@ HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name )
BOOL WINAPI ReleaseMutex( HANDLE handle )
{
BOOL ret;
SERVER_START_REQ
SERVER_START_REQ( release_mutex )
{
struct release_mutex_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle;
ret = !server_call( REQ_RELEASE_MUTEX );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -403,20 +385,17 @@ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max,
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->max = (unsigned int)max;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_SEMAPHORE );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -443,20 +422,17 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
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->max = (unsigned int)max;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_SEMAPHORE );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -473,17 +449,15 @@ HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->inherit = inherit;
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;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -500,16 +474,15 @@ HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_SEMAPHORE );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}

View File

@ -202,13 +202,12 @@ HANDLE WINAPI CreateToolhelp32Snapshot( DWORD flags, DWORD process )
}
/* 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->inherit = (flags & TH32CS_INHERIT) != 0;
req->pid = (void *)process;
server_call( REQ_CREATE_SNAPSHOT );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
@ -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);
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->reset = first;
if ((ret = !server_call( REQ_NEXT_THREAD )))
if ((ret = !SERVER_CALL_ERR()))
{
lpte->cntUsage = req->count;
lpte->th32ThreadID = (DWORD)req->tid;
@ -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);
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->reset = first;
if ((ret = !server_call( REQ_NEXT_PROCESS )))
if ((ret = !SERVER_CALL_ERR()))
{
lppe->cntUsage = req->count;
lppe->th32ProcessID = (DWORD)req->pid;
@ -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);
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->reset = first;
if ((ret = !server_call( REQ_NEXT_MODULE )))
if ((ret = !SERVER_CALL_ERR()))
{
lpme->th32ModuleID = 0; /* toolhelp internal id, never used */
lpme->th32ProcessID = (DWORD)req->pid;

View File

@ -112,33 +112,29 @@ static int send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *c
int ret;
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);
EXCEPTION_RECORD *rec_ptr = (EXCEPTION_RECORD *)(context_ptr + 1);
req->first = first_chance;
*rec_ptr = *rec;
*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 */
/* 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
* 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;
if (!server_call_noerr( REQ_GET_EXCEPTION_STATUS ))
*context = *(CONTEXT *)server_data_ptr(req);
if (!SERVER_CALL()) *context = *(CONTEXT *)server_data_ptr(req);
ret = req->status;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
NtClose( handle );
return ret;
}

View File

@ -76,12 +76,11 @@ NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code )
{
NTSTATUS ret;
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->exit_code = exit_code;
ret = server_call_noerr( REQ_TERMINATE_PROCESS );
ret = SERVER_CALL();
self = !ret && req->self;
}
SERVER_END_REQ;
@ -150,12 +149,11 @@ NTSTATUS WINAPI NtTerminateThread( HANDLE handle, LONG exit_code )
NTSTATUS ret;
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->exit_code = exit_code;
ret = server_call_noerr( REQ_TERMINATE_THREAD );
ret = SERVER_CALL();
self = !ret && req->self;
last = req->last;
}

View File

@ -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
# Server interface
@ cdecl -norelay wine_server_call(long) wine_server_call
@ cdecl -norelay wine_server_alloc_req(long long) wine_server_alloc_req
@ cdecl -norelay wine_server_call(ptr long) wine_server_call
@ 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

View File

@ -217,11 +217,10 @@ NTSTATUS WINAPI NtDuplicateObject(
NTSTATUS WINAPI NtClose( HANDLE Handle )
{
NTSTATUS ret;
SERVER_START_REQ
SERVER_START_REQ( close_handle )
{
struct close_handle_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = Handle;
ret = server_call_noerr( REQ_CLOSE_HANDLE );
ret = SERVER_CALL();
if (!ret && req->fd != -1) close( req->fd );
}
SERVER_END_REQ;

View File

@ -67,9 +67,8 @@ NTSTATUS WINAPI NtCreateKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_AT
}
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);
req->parent = attr->RootDirectory;
@ -80,13 +79,13 @@ NTSTATUS WINAPI NtCreateKey( PHANDLE retkey, ACCESS_MASK access, const OBJECT_AT
*data++ = attr->ObjectName->Length;
memcpy( data, attr->ObjectName->Buffer, attr->ObjectName->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;
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);
return ret;
}
@ -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 (!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->access = access;
memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
ret = server_call_noerr( REQ_OPEN_KEY );
ret = SERVER_CALL();
*retkey = req->hkey;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
TRACE("<- 0x%04x\n", *retkey);
return ret;
}
@ -135,11 +133,10 @@ NTSTATUS WINAPI NtDeleteKey( HANDLE 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;
ret = server_call_noerr( REQ_DELETE_KEY );
ret = SERVER_CALL();
}
SERVER_END_REQ;
return ret;
@ -157,15 +154,13 @@ NTSTATUS WINAPI NtDeleteValueKey( HANDLE hkey, const UNICODE_STRING *name )
TRACE( "(0x%x,%s)\n", hkey, debugstr_us(name) );
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;
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;
}
@ -274,18 +269,17 @@ NTSTATUS WINAPI NtEnumerateKey( HANDLE handle, ULONG index, KEY_INFORMATION_CLAS
/* -1 means query key, so avoid it here */
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->index = index;
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 );
}
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -299,18 +293,17 @@ NTSTATUS WINAPI NtQueryKey( HANDLE handle, KEY_INFORMATION_CLASS info_class,
{
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->index = -1;
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 );
}
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -402,15 +395,13 @@ NTSTATUS WINAPI NtEnumerateValueKey( HANDLE handle, ULONG index,
if (name_ptr && !offset) reqlen += MAX_PATH*sizeof(WCHAR);
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->index = index;
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);
WCHAR *name = server_data_ptr(req);
@ -448,7 +439,7 @@ NTSTATUS WINAPI NtEnumerateValueKey( HANDLE handle, ULONG index,
total_len = req->len;
}
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
if (ret) return ret;
} while (data_len && data_ptr && offset < total_len);
@ -508,9 +499,8 @@ NTSTATUS WINAPI NtQueryValueKey( HANDLE handle, const UNICODE_STRING *name,
size_t reqlen = min( data_len, REQUEST_MAX_VAR_SIZE );
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);
req->hkey = handle;
@ -518,7 +508,7 @@ NTSTATUS WINAPI NtQueryValueKey( HANDLE handle, const UNICODE_STRING *name,
*nameptr++ = 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 );
type = req->type;
@ -531,7 +521,7 @@ NTSTATUS WINAPI NtQueryValueKey( HANDLE handle, const UNICODE_STRING *name,
}
}
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
if (ret) return ret;
} while (data_len && offset < total_len);
@ -690,9 +680,8 @@ NTSTATUS WINAPI NtSetValueKey( HANDLE hkey, const UNICODE_STRING *name, ULONG Ti
ULONG len = count - pos;
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);
req->hkey = hkey;
@ -703,9 +692,9 @@ NTSTATUS WINAPI NtSetValueKey( HANDLE hkey, const UNICODE_STRING *name, ULONG Ti
memcpy( name_ptr, name->Buffer, name->Length );
memcpy( (char *)name_ptr + name->Length, (char *)data + 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);
return ret;
}

View File

@ -36,17 +36,16 @@ NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle,
if ((MaximumCount <= 0) || (InitialCount < 0) || (InitialCount > MaximumCount))
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->max = MaximumCount;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
ret = server_call_noerr( REQ_CREATE_SEMAPHORE );
ret = SERVER_CALL();
*SemaphoreHandle = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -60,16 +59,15 @@ NTSTATUS WINAPI NtOpenSemaphore( OUT PHANDLE SemaphoreHandle,
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
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->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
ret = server_call_noerr( REQ_OPEN_SEMAPHORE );
ret = SERVER_CALL();
*SemaphoreHandle = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -94,12 +92,11 @@ NTSTATUS WINAPI NtQuerySemaphore(
NTSTATUS WINAPI NtReleaseSemaphore( HANDLE handle, ULONG count, PULONG previous )
{
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->count = count;
if (!(ret = server_call_noerr( REQ_RELEASE_SEMAPHORE )))
if (!(ret = SERVER_CALL()))
{
if (previous) *previous = req->prev_count;
}
@ -125,17 +122,16 @@ NTSTATUS WINAPI NtCreateEvent(
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
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->initial_state = InitialState;
req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
ret = server_call_noerr( REQ_CREATE_EVENT );
ret = SERVER_CALL();
*EventHandle = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -150,17 +146,15 @@ NTSTATUS WINAPI NtOpenEvent(
DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
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->inherit = attr && (attr->Attributes & OBJ_INHERIT);
if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
ret = server_call_noerr( REQ_OPEN_EVENT );
ret = SERVER_CALL();
*EventHandle = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -174,12 +168,11 @@ NTSTATUS WINAPI NtSetEvent( HANDLE handle, PULONG 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->op = SET_EVENT;
ret = server_call_noerr( REQ_EVENT_OP );
ret = SERVER_CALL();
}
SERVER_END_REQ;
return ret;
@ -195,12 +188,11 @@ NTSTATUS WINAPI NtResetEvent( HANDLE handle, PULONG NumberOfThreadsReleased )
/* resetting an event can't release any thread... */
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->op = RESET_EVENT;
ret = server_call_noerr( REQ_EVENT_OP );
ret = SERVER_CALL();
}
SERVER_END_REQ;
return ret;
@ -227,12 +219,11 @@ NTSTATUS WINAPI NtPulseEvent( HANDLE handle, PULONG PulseCount )
{
NTSTATUS ret;
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->op = PULSE_EVENT;
ret = server_call_noerr( REQ_EVENT_OP );
ret = SERVER_CALL();
}
SERVER_END_REQ;
return ret;

View File

@ -206,17 +206,16 @@ static int _px_tcp_ops[] = {
0
};
/* we need a special routine to handle WSA* errors */
static inline int sock_server_call( enum request req )
/* set last error code from NT status without mapping WSA errors */
inline static unsigned int set_error( unsigned int err )
{
unsigned int res = server_call_noerr( req );
if (res)
if (err)
{
/* do not map WSA errors */
if ((res < WSABASEERR) || (res >= 0x10000000)) res = RtlNtStatusToDosError(res);
SetLastError( res );
if ((err < WSABASEERR) || (err >= 0x10000000)) err = RtlNtStatusToDosError(err);
SetLastError( err );
}
return res;
return err;
}
static char* check_buffer(int size);
@ -232,15 +231,13 @@ static int _get_sock_fd(SOCKET s)
static void _enable_event(SOCKET s, unsigned int event,
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->mask = event;
req->sstate = sstate;
req->cstate = cstate;
sock_server_call( REQ_ENABLE_SOCKET_EVENT );
SERVER_CALL();
}
SERVER_END_REQ;
}
@ -248,15 +245,13 @@ static void _enable_event(SOCKET s, unsigned int event,
static int _is_blocking(SOCKET s)
{
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->service = FALSE;
req->s_event = 0;
req->c_event = 0;
sock_server_call( REQ_GET_SOCKET_EVENT );
SERVER_CALL();
ret = (req->state & WS_FD_NONBLOCKING) == 0;
}
SERVER_END_REQ;
@ -266,15 +261,13 @@ static int _is_blocking(SOCKET s)
static unsigned int _get_sock_mask(SOCKET s)
{
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->service = FALSE;
req->s_event = 0;
req->c_event = 0;
sock_server_call( REQ_GET_SOCKET_EVENT );
SERVER_CALL();
ret = req->mask;
}
SERVER_END_REQ;
@ -291,18 +284,16 @@ static void _sync_sock_state(SOCKET s)
static int _get_sock_error(SOCKET s, unsigned int bit)
{
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->service = FALSE;
req->s_event = 0;
req->c_event = 0;
sock_server_call( REQ_GET_SOCKET_EVENT );
SERVER_CALL();
ret = *((int *)server_data_ptr(req) + bit);
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -777,14 +768,12 @@ SOCKET WINAPI WSOCK32_accept(SOCKET s, struct sockaddr *addr,
/* FIXME: care about the error? */
}
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->access = GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE;
req->inherit = TRUE;
sock_server_call( REQ_ACCEPT_SOCKET );
set_error( SERVER_CALL() );
as = (SOCKET)req->handle;
}
SERVER_END_REQ;
@ -2138,15 +2127,14 @@ SOCKET WINAPI WSOCK32_socket(INT af, INT type, INT protocol)
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->type = type;
req->protocol = protocol;
req->access = GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE;
req->inherit = TRUE;
sock_server_call( REQ_CREATE_SOCKET );
set_error( SERVER_CALL() );
ret = (SOCKET)req->handle;
}
SERVER_END_REQ;
@ -2510,19 +2498,19 @@ int WINAPI WSAEnumNetworkEvents(SOCKET s, WSAEVENT hEvent, LPWSANETWORKEVENTS lp
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->service = TRUE;
req->s_event = 0;
req->c_event = hEvent;
ret = sock_server_call( REQ_GET_SOCKET_EVENT );
lpEvent->lNetworkEvents = req->pmask;
memcpy(lpEvent->iErrorCode, server_data_ptr(req), server_data_size(req) );
if (!(ret = SERVER_CALL()))
{
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;
SetLastError(WSAEINVAL);
return SOCKET_ERROR;
@ -2537,13 +2525,12 @@ int WINAPI WSAEventSelect(SOCKET s, WSAEVENT hEvent, LONG 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->mask = lEvent;
req->event = hEvent;
ret = sock_server_call( REQ_SET_SOCKET_EVENT );
ret = SERVER_CALL();
}
SERVER_END_REQ;
if (!ret) return 0;
@ -2563,18 +2550,17 @@ VOID CALLBACK WINSOCK_DoAsyncEvent( ULONG_PTR ptr )
TRACE("socket %08x, event %08x\n", info->sock, info->event);
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->service = TRUE;
req->s_event = info->event; /* <== avoid race conditions */
req->c_event = info->event;
sock_server_call( REQ_GET_SOCKET_EVENT );
set_error( SERVER_CALL() );
pmask = req->pmask;
memcpy( errors, server_data_ptr(req), server_data_size(req) );
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
if ( (GetLastError() == WSAENOTSOCK) || (GetLastError() == WSAEINVAL) )
{
/* orphaned event (socket closed or something) */

View File

@ -32,12 +32,11 @@ HANDLE WINAPI FindFirstChangeNotificationA( LPCSTR lpPathName, BOOL bWatchSubtre
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->filter = dwNotifyFilter;
if (!server_call( REQ_CREATE_CHANGE_NOTIFICATION )) ret = req->handle;
if (!SERVER_CALL_ERR()) ret = req->handle;
}
SERVER_END_REQ;
return ret;

View File

@ -675,12 +675,10 @@ const DOS_DEVICE *DOSFS_GetDevice( const char *name )
const DOS_DEVICE *DOSFS_GetDeviceByHandle( HFILE hFile )
{
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;
if (!server_call( REQ_GET_FILE_INFO ) && (req->type == FILE_TYPE_UNKNOWN))
if (!SERVER_CALL() && (req->type == FILE_TYPE_UNKNOWN))
{
if ((req->attr >= 0) &&
(req->attr < sizeof(DOSFS_Devices)/sizeof(DOSFS_Devices[0])))
@ -699,6 +697,7 @@ static HANDLE DOSFS_CreateCommPort(LPCSTR name, DWORD access)
{
HANDLE ret;
char devname[40];
size_t len;
TRACE("%s %lx\n", name, access);
@ -708,20 +707,18 @@ static HANDLE DOSFS_CreateCommPort(LPCSTR name, DWORD access)
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->inherit = 0; /*FIXME*/
req->sharing = FILE_SHARE_READ|FILE_SHARE_WRITE;
memcpy( server_data_ptr(req), devname, len );
SetLastError(0);
server_call( REQ_CREATE_SERIAL );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
if(!ret)
ERR("Couldn't open %s ! (check permissions)\n",devname);

View File

@ -184,11 +184,10 @@ void FILE_SetDosError(void)
HANDLE FILE_DupUnixHandle( int fd, DWORD access )
{
HANDLE ret;
SERVER_START_REQ
SERVER_START_REQ( alloc_file_handle )
{
struct alloc_file_handle_request *req = server_alloc_req( sizeof(*req), 0 );
req->access = access;
server_call_fd( REQ_ALLOC_FILE_HANDLE, fd );
SERVER_CALL_FD( fd );
ret = req->handle;
}
SERVER_END_REQ;
@ -205,12 +204,11 @@ HANDLE FILE_DupUnixHandle( int fd, DWORD access )
int FILE_GetUnixHandle( HANDLE handle, DWORD access )
{
int ret, fd = -1;
SERVER_START_REQ
SERVER_START_REQ( get_handle_fd )
{
struct get_handle_fd_request *req = wine_server_alloc_req( sizeof(*req), 0 );
req->handle = handle;
req->access = access;
if (!(ret = server_call( REQ_GET_HANDLE_FD ))) fd = req->fd;
if (!(ret = SERVER_CALL_ERR())) fd = req->fd;
}
SERVER_END_REQ;
if (!ret)
@ -232,15 +230,13 @@ static HANDLE FILE_OpenConsole( BOOL output, DWORD access, LPSECURITY_ATTRIBUTES
{
HANDLE ret;
SERVER_START_REQ
SERVER_START_REQ( open_console )
{
struct open_console_request *req = server_alloc_req( sizeof(*req), 0 );
req->output = output;
req->access = access;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
SetLastError(0);
server_call( REQ_OPEN_CONSOLE );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
@ -270,9 +266,8 @@ HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
}
restart:
SERVER_START_REQ
SERVER_START_VAR_REQ( create_file, len )
{
struct create_file_request *req = server_alloc_req( sizeof(*req), len );
req->access = access;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
req->sharing = sharing;
@ -280,10 +275,10 @@ HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
req->attrs = attributes;
memcpy( server_data_ptr(req), filename, len );
SetLastError(0);
err = server_call( REQ_CREATE_FILE );
err = SERVER_CALL();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
/* If write access failed, retry without GENERIC_WRITE */
@ -298,9 +293,10 @@ HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
}
}
if (err) SetLastError( RtlNtStatusToDosError(err) );
if (!ret)
WARN("Unable to create file '%s' (GLE %ld)\n", filename,
GetLastError());
WARN("Unable to create file '%s' (GLE %ld)\n", filename, GetLastError());
return ret;
}
@ -315,15 +311,13 @@ HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
HANDLE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa )
{
HANDLE ret;
SERVER_START_REQ
SERVER_START_REQ( create_device )
{
struct create_device_request *req = server_alloc_req( sizeof(*req), 0 );
req->access = access;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
req->id = client_id;
SetLastError(0);
server_call( REQ_CREATE_DEVICE );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
@ -544,11 +538,10 @@ DWORD WINAPI GetFileInformationByHandle( HANDLE hFile,
DWORD ret;
if (!info) return 0;
SERVER_START_REQ
SERVER_START_REQ( get_file_info )
{
struct get_file_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hFile;
if ((ret = !server_call( REQ_GET_FILE_INFO )))
if ((ret = !SERVER_CALL_ERR()))
{
RtlSecondsSince1970ToTime( req->write_time, &info->ftCreationTime );
RtlSecondsSince1970ToTime( req->write_time, &info->ftLastWriteTime );
@ -1186,17 +1179,13 @@ static int FILE_AsyncResult(HANDLE hAsync, int result)
{
int r;
SERVER_START_REQ
SERVER_START_REQ( async_result )
{
struct async_result_request *req = server_alloc_req(sizeof *req,0);
req->ov_handle = hAsync;
req->result = result;
r = server_call( REQ_ASYNC_RESULT);
r = SERVER_CALL_ERR();
}
SERVER_END_REQ
SERVER_END_REQ;
return !r;
}
@ -1279,10 +1268,8 @@ static BOOL FILE_StartAsyncRead( HANDLE hFile, LPOVERLAPPED overlapped, LPVOID b
{
int r;
SERVER_START_REQ
SERVER_START_REQ( create_async )
{
struct create_async_request *req = server_alloc_req(sizeof *req,0);
req->file_handle = hFile;
req->overlapped = overlapped;
req->buffer = buffer;
@ -1290,11 +1277,11 @@ static BOOL FILE_StartAsyncRead( HANDLE hFile, LPOVERLAPPED overlapped, LPVOID b
req->func = FILE_AsyncReadService;
req->type = ASYNC_TYPE_READ;
r=server_call( REQ_CREATE_ASYNC );
r=SERVER_CALL_ERR();
overlapped->Offset = req->ov_handle;
}
SERVER_END_REQ
SERVER_END_REQ;
if(!r)
{
@ -1435,10 +1422,8 @@ static BOOL FILE_StartAsyncWrite(HANDLE hFile, LPOVERLAPPED overlapped, LPCVOID
{
int r;
SERVER_START_REQ
SERVER_START_REQ( create_async )
{
struct create_async_request *req = server_alloc_req( sizeof(*req), 0 );
req->file_handle = hFile;
req->buffer = (LPVOID)buffer;
req->overlapped = overlapped;
@ -1446,11 +1431,11 @@ static BOOL FILE_StartAsyncWrite(HANDLE hFile, LPOVERLAPPED overlapped, LPCVOID
req->func = FILE_AsyncWriteService;
req->type = ASYNC_TYPE_WRITE;
r = server_call( REQ_CREATE_ASYNC );
r = SERVER_CALL_ERR();
overlapped->Offset = req->ov_handle;
}
SERVER_END_REQ
SERVER_END_REQ;
if(!r)
{
@ -1607,16 +1592,15 @@ DWORD WINAPI SetFilePointer( HANDLE hFile, LONG distance, LONG *highword,
TRACE("handle %d offset %ld origin %ld\n",
hFile, distance, method );
SERVER_START_REQ
SERVER_START_REQ( set_file_pointer )
{
struct set_file_pointer_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hFile;
req->low = distance;
req->high = highword ? *highword : (distance >= 0) ? 0 : -1;
/* FIXME: assumes 1:1 mapping between Windows and Unix seek constants */
req->whence = method;
SetLastError( 0 );
if (!server_call( REQ_SET_FILE_POINTER ))
if (!SERVER_CALL_ERR())
{
ret = req->new_low;
if (highword) *highword = req->new_high;
@ -1768,11 +1752,10 @@ UINT WINAPI SetHandleCount( UINT count )
BOOL WINAPI FlushFileBuffers( HANDLE hFile )
{
BOOL ret;
SERVER_START_REQ
SERVER_START_REQ( flush_file )
{
struct flush_file_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hFile;
ret = !server_call( REQ_FLUSH_FILE );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -1785,11 +1768,10 @@ BOOL WINAPI FlushFileBuffers( HANDLE hFile )
BOOL WINAPI SetEndOfFile( HANDLE hFile )
{
BOOL ret;
SERVER_START_REQ
SERVER_START_REQ( truncate_file )
{
struct truncate_file_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hFile;
ret = !server_call( REQ_TRUNCATE_FILE );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -1854,11 +1836,10 @@ BOOL WINAPI DeleteFileW( LPCWSTR path )
DWORD WINAPI GetFileType( HANDLE hFile )
{
DWORD ret = FILE_TYPE_UNKNOWN;
SERVER_START_REQ
SERVER_START_REQ( get_file_info )
{
struct get_file_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hFile;
if (!server_call( REQ_GET_FILE_INFO )) ret = req->type;
if (!SERVER_CALL_ERR()) ret = req->type;
}
SERVER_END_REQ;
return ret;
@ -2145,9 +2126,8 @@ BOOL WINAPI SetFileTime( HANDLE hFile,
const FILETIME *lpLastWriteTime )
{
BOOL ret;
SERVER_START_REQ
SERVER_START_REQ( set_file_time )
{
struct set_file_time_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hFile;
if (lpLastAccessTime)
RtlTimeToSecondsSince1970( lpLastAccessTime, (DWORD *)&req->access_time );
@ -2157,7 +2137,7 @@ BOOL WINAPI SetFileTime( HANDLE hFile,
RtlTimeToSecondsSince1970( lpLastWriteTime, (DWORD *)&req->write_time );
else
req->write_time = 0; /* FIXME */
ret = !server_call( REQ_SET_FILE_TIME );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -2171,16 +2151,14 @@ BOOL WINAPI LockFile( HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHig
DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh )
{
BOOL ret;
SERVER_START_REQ
SERVER_START_REQ( lock_file )
{
struct lock_file_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hFile;
req->offset_low = dwFileOffsetLow;
req->offset_high = dwFileOffsetHigh;
req->count_low = nNumberOfBytesToLockLow;
req->count_high = nNumberOfBytesToLockHigh;
ret = !server_call( REQ_LOCK_FILE );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -2224,16 +2202,14 @@ BOOL WINAPI UnlockFile( HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetH
DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh )
{
BOOL ret;
SERVER_START_REQ
SERVER_START_REQ( unlock_file )
{
struct unlock_file_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hFile;
req->offset_low = dwFileOffsetLow;
req->offset_high = dwFileOffsetHigh;
req->count_low = nNumberOfBytesToUnlockLow;
req->count_high = nNumberOfBytesToUnlockHigh;
ret = !server_call( REQ_UNLOCK_FILE );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;

View File

@ -1365,115 +1365,115 @@ struct async_result_request
enum request
{
REQ_NEW_PROCESS,
REQ_GET_NEW_PROCESS_INFO,
REQ_NEW_THREAD,
REQ_BOOT_DONE,
REQ_INIT_PROCESS,
REQ_INIT_PROCESS_DONE,
REQ_INIT_THREAD,
REQ_GET_THREAD_BUFFER,
REQ_TERMINATE_PROCESS,
REQ_TERMINATE_THREAD,
REQ_GET_PROCESS_INFO,
REQ_SET_PROCESS_INFO,
REQ_GET_THREAD_INFO,
REQ_SET_THREAD_INFO,
REQ_SUSPEND_THREAD,
REQ_RESUME_THREAD,
REQ_LOAD_DLL,
REQ_UNLOAD_DLL,
REQ_QUEUE_APC,
REQ_GET_APC,
REQ_CLOSE_HANDLE,
REQ_SET_HANDLE_INFO,
REQ_DUP_HANDLE,
REQ_OPEN_PROCESS,
REQ_SELECT,
REQ_CREATE_EVENT,
REQ_EVENT_OP,
REQ_OPEN_EVENT,
REQ_CREATE_MUTEX,
REQ_RELEASE_MUTEX,
REQ_OPEN_MUTEX,
REQ_CREATE_SEMAPHORE,
REQ_RELEASE_SEMAPHORE,
REQ_OPEN_SEMAPHORE,
REQ_CREATE_FILE,
REQ_ALLOC_FILE_HANDLE,
REQ_GET_HANDLE_FD,
REQ_SET_FILE_POINTER,
REQ_TRUNCATE_FILE,
REQ_SET_FILE_TIME,
REQ_FLUSH_FILE,
REQ_GET_FILE_INFO,
REQ_LOCK_FILE,
REQ_UNLOCK_FILE,
REQ_CREATE_PIPE,
REQ_CREATE_SOCKET,
REQ_ACCEPT_SOCKET,
REQ_SET_SOCKET_EVENT,
REQ_GET_SOCKET_EVENT,
REQ_ENABLE_SOCKET_EVENT,
REQ_ALLOC_CONSOLE,
REQ_FREE_CONSOLE,
REQ_OPEN_CONSOLE,
REQ_SET_CONSOLE_FD,
REQ_GET_CONSOLE_MODE,
REQ_SET_CONSOLE_MODE,
REQ_SET_CONSOLE_INFO,
REQ_GET_CONSOLE_INFO,
REQ_WRITE_CONSOLE_INPUT,
REQ_READ_CONSOLE_INPUT,
REQ_CREATE_CHANGE_NOTIFICATION,
REQ_CREATE_MAPPING,
REQ_OPEN_MAPPING,
REQ_GET_MAPPING_INFO,
REQ_CREATE_DEVICE,
REQ_CREATE_SNAPSHOT,
REQ_NEXT_PROCESS,
REQ_NEXT_THREAD,
REQ_NEXT_MODULE,
REQ_WAIT_DEBUG_EVENT,
REQ_QUEUE_EXCEPTION_EVENT,
REQ_GET_EXCEPTION_STATUS,
REQ_OUTPUT_DEBUG_STRING,
REQ_CONTINUE_DEBUG_EVENT,
REQ_DEBUG_PROCESS,
REQ_READ_PROCESS_MEMORY,
REQ_WRITE_PROCESS_MEMORY,
REQ_CREATE_KEY,
REQ_OPEN_KEY,
REQ_DELETE_KEY,
REQ_ENUM_KEY,
REQ_SET_KEY_VALUE,
REQ_GET_KEY_VALUE,
REQ_ENUM_KEY_VALUE,
REQ_DELETE_KEY_VALUE,
REQ_LOAD_REGISTRY,
REQ_SAVE_REGISTRY,
REQ_SAVE_REGISTRY_ATEXIT,
REQ_SET_REGISTRY_LEVELS,
REQ_CREATE_TIMER,
REQ_OPEN_TIMER,
REQ_SET_TIMER,
REQ_CANCEL_TIMER,
REQ_GET_THREAD_CONTEXT,
REQ_SET_THREAD_CONTEXT,
REQ_GET_SELECTOR_ENTRY,
REQ_ADD_ATOM,
REQ_DELETE_ATOM,
REQ_FIND_ATOM,
REQ_GET_ATOM_NAME,
REQ_INIT_ATOM_TABLE,
REQ_GET_MSG_QUEUE,
REQ_WAKE_QUEUE,
REQ_WAIT_INPUT_IDLE,
REQ_CREATE_SERIAL,
REQ_GET_SERIAL_INFO,
REQ_SET_SERIAL_INFO,
REQ_CREATE_ASYNC,
REQ_ASYNC_RESULT,
REQ_new_process,
REQ_get_new_process_info,
REQ_new_thread,
REQ_boot_done,
REQ_init_process,
REQ_init_process_done,
REQ_init_thread,
REQ_get_thread_buffer,
REQ_terminate_process,
REQ_terminate_thread,
REQ_get_process_info,
REQ_set_process_info,
REQ_get_thread_info,
REQ_set_thread_info,
REQ_suspend_thread,
REQ_resume_thread,
REQ_load_dll,
REQ_unload_dll,
REQ_queue_apc,
REQ_get_apc,
REQ_close_handle,
REQ_set_handle_info,
REQ_dup_handle,
REQ_open_process,
REQ_select,
REQ_create_event,
REQ_event_op,
REQ_open_event,
REQ_create_mutex,
REQ_release_mutex,
REQ_open_mutex,
REQ_create_semaphore,
REQ_release_semaphore,
REQ_open_semaphore,
REQ_create_file,
REQ_alloc_file_handle,
REQ_get_handle_fd,
REQ_set_file_pointer,
REQ_truncate_file,
REQ_set_file_time,
REQ_flush_file,
REQ_get_file_info,
REQ_lock_file,
REQ_unlock_file,
REQ_create_pipe,
REQ_create_socket,
REQ_accept_socket,
REQ_set_socket_event,
REQ_get_socket_event,
REQ_enable_socket_event,
REQ_alloc_console,
REQ_free_console,
REQ_open_console,
REQ_set_console_fd,
REQ_get_console_mode,
REQ_set_console_mode,
REQ_set_console_info,
REQ_get_console_info,
REQ_write_console_input,
REQ_read_console_input,
REQ_create_change_notification,
REQ_create_mapping,
REQ_open_mapping,
REQ_get_mapping_info,
REQ_create_device,
REQ_create_snapshot,
REQ_next_process,
REQ_next_thread,
REQ_next_module,
REQ_wait_debug_event,
REQ_queue_exception_event,
REQ_get_exception_status,
REQ_output_debug_string,
REQ_continue_debug_event,
REQ_debug_process,
REQ_read_process_memory,
REQ_write_process_memory,
REQ_create_key,
REQ_open_key,
REQ_delete_key,
REQ_enum_key,
REQ_set_key_value,
REQ_get_key_value,
REQ_enum_key_value,
REQ_delete_key_value,
REQ_load_registry,
REQ_save_registry,
REQ_save_registry_atexit,
REQ_set_registry_levels,
REQ_create_timer,
REQ_open_timer,
REQ_set_timer,
REQ_cancel_timer,
REQ_get_thread_context,
REQ_set_thread_context,
REQ_get_selector_entry,
REQ_add_atom,
REQ_delete_atom,
REQ_find_atom,
REQ_get_atom_name,
REQ_init_atom_table,
REQ_get_msg_queue,
REQ_wake_queue,
REQ_wait_input_idle,
REQ_create_serial,
REQ_get_serial_info,
REQ_set_serial_info,
REQ_create_async,
REQ_async_result,
REQ_NB_REQUESTS
};
@ -1600,13 +1600,6 @@ union generic_request
#undef REQUEST_HEADER
#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 */
#ifndef __WINE_SERVER__
@ -1617,22 +1610,18 @@ struct server_buffer_info
/* client communication functions */
extern unsigned int wine_server_call( enum request req );
extern unsigned int server_call_fd( enum request req, int fd_out );
extern unsigned int wine_server_call( union generic_request *req, size_t size );
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_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 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 */
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) );
return res;
}
@ -1640,7 +1629,7 @@ inline static unsigned int server_call( enum request req )
/* get a pointer to the variable part of the request */
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 */
@ -1657,23 +1646,47 @@ extern DWORD __wine_server_exception_handler( PEXCEPTION_RECORD record, EXCEPTIO
struct __server_exception_frame
{
EXCEPTION_FRAME frame;
struct server_buffer_info info; /* saved buffer information */
EXCEPTION_FRAME frame;
unsigned int buffer_pos; /* saved buffer position */
};
#define SERVER_START_REQ \
/* macros for server requests */
#define SERVER_START_REQ(type) \
do { \
struct __server_exception_frame __f; \
__f.frame.Handler = __wine_server_exception_handler; \
__f.info = *NtCurrentTeb()->buffer_info; \
__wine_push_frame( &__f.frame ); \
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); \
*NtCurrentTeb()->buffer_info = __f.info; \
while(0); \
} while(0)
#define SERVER_START_VAR_REQ(type,size) \
do { \
struct __server_exception_frame __f; \
union generic_request __req; \
struct type##_request * const req = &__req.type; \
__f.frame.Handler = __wine_server_exception_handler; \
__f.buffer_pos = NtCurrentTeb()->buffer_pos; \
__wine_push_frame( &__f.frame ); \
__req.header.req = REQ_##type; \
wine_server_alloc_req( &__req, (size) ); \
do
#define SERVER_END_VAR_REQ \
while(0); \
NtCurrentTeb()->buffer_pos = __f.buffer_pos; \
__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_BootDone( int debug_level );

View File

@ -94,16 +94,17 @@ typedef struct _TEB
DWORD cleanup; /* --3 1fc Cleanup service handle */
int socket; /* --3 200 Socket for server communication */
void *buffer; /* --3 204 Buffer shared with server */
int request_fd; /* --3 208 fd for sending server requests */
int reply_fd; /* --3 20c fd for receiving server replies */
int wait_fd; /* --3 210 fd for sleeping server requests */
struct server_buffer_info *buffer_info; /* --3 214 Buffer information */
void *debug_info; /* --3 218 Info for debugstr functions */
void *pthread_data; /* --3 21c Data for pthread emulation */
unsigned int buffer_pos; /* --3 208 Buffer current position */
unsigned int buffer_size; /* --3 20c Buffer size */
int request_fd; /* --3 210 fd for sending server requests */
int reply_fd; /* --3 214 fd for receiving server replies */
int wait_fd; /* --3 218 fd for sleeping server requests */
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!!) */
/* the following are nt specific fields */
DWORD pad6[630]; /* --n 220 */
DWORD pad6[629]; /* --n 224 */
UNICODE_STRING StaticUnicodeString; /* -2- bf8 used by advapi32 */
USHORT StaticUnicodeBuffer[261]; /* -2- c00 used by advapi32 */
DWORD pad7; /* --n e0c */

View File

@ -1597,11 +1597,10 @@ BOOL MODULE_FreeLibrary( WINE_MODREF *wm )
if ( free_lib_count <= 1 )
{
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;
server_call_noerr( REQ_UNLOAD_DLL );
SERVER_CALL();
}
SERVER_END_REQ;
MODULE_FlushModrefs();

View File

@ -990,12 +990,11 @@ static HINSTANCE16 NE_CreateThread( NE_MODULE *pModule, WORD cmdShow, LPCSTR cmd
TDB *pTask;
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->inherit = 0;
if (!server_call( REQ_NEW_THREAD ))
if (!SERVER_CALL_ERR())
{
hThread = req->handle;
socket = wine_server_recv_fd( hThread, 0 );

View File

@ -664,15 +664,14 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
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->base = (void *)hModule;
req->dbg_offset = nt->FileHeader.PointerToSymbolTable;
req->dbg_size = nt->FileHeader.NumberOfSymbols;
req->name = &wm->filename;
server_call_noerr( REQ_LOAD_DLL );
SERVER_CALL();
}
SERVER_END_REQ;
}

View File

@ -402,11 +402,10 @@ UINT16 WINAPI GetAtomName16( ATOM atom, LPSTR buffer, INT16 count )
BOOL WINAPI InitAtomTable( DWORD entries )
{
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;
ret = !server_call( REQ_INIT_ATOM_TABLE );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -424,14 +423,13 @@ static ATOM ATOM_AddAtomA( LPCSTR str, BOOL local )
SetLastError( ERROR_INVALID_PARAMETER );
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 );
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 );
return atom;
@ -480,14 +478,13 @@ static ATOM ATOM_AddAtomW( LPCWSTR str, BOOL local )
SetLastError( ERROR_INVALID_PARAMETER );
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) );
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 );
return atom;
@ -518,12 +515,11 @@ static ATOM ATOM_DeleteAtom( ATOM atom, BOOL local)
if (atom < MIN_STR_ATOM) atom = 0;
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->local = local;
if (!server_call( REQ_DELETE_ATOM )) atom = 0;
if (!SERVER_CALL_ERR()) atom = 0;
}
SERVER_END_REQ;
}
@ -572,14 +568,13 @@ static ATOM ATOM_FindAtomA( LPCSTR str, BOOL local )
SetLastError( ERROR_INVALID_PARAMETER );
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 );
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 );
return atom;
@ -627,14 +622,13 @@ static ATOM ATOM_FindAtomW( LPCWSTR str, BOOL local )
SetLastError( ERROR_INVALID_PARAMETER );
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) );
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 );
return atom;
@ -682,13 +676,11 @@ static UINT ATOM_GetAtomNameA( ATOM atom, LPSTR buffer, INT count, BOOL local )
else
{
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->local = local;
if (!server_call( REQ_GET_ATOM_NAME ))
if (!SERVER_CALL_ERR())
{
len = WideCharToMultiByte( CP_ACP, 0, server_data_ptr(req),
server_data_size(req) / sizeof(WCHAR),
@ -697,7 +689,7 @@ static UINT ATOM_GetAtomNameA( ATOM atom, LPSTR buffer, INT count, BOOL local )
else buffer[len] = 0;
}
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
}
if (len && count <= len)
@ -770,13 +762,11 @@ static UINT ATOM_GetAtomNameW( ATOM atom, LPWSTR buffer, INT count, BOOL local )
else
{
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->local = local;
if (!server_call( REQ_GET_ATOM_NAME ))
if (!SERVER_CALL_ERR())
{
len = server_data_size(req) / sizeof(WCHAR);
if (count > len) count = len + 1;
@ -784,7 +774,7 @@ static UINT ATOM_GetAtomNameW( ATOM atom, LPWSTR buffer, INT count, BOOL local )
buffer[count-1] = 0;
}
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
if (!len) return 0;
}
if (count <= len)

View File

@ -34,13 +34,6 @@ static inline int is_string( DWORD type )
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]
@ -631,16 +624,15 @@ LONG WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename )
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->file = file;
MultiByteToWideChar( CP_ACP, 0, subkey, strlen(subkey),
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 );
done:
@ -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);
}
SERVER_START_REQ
SERVER_START_REQ( save_registry )
{
struct save_registry_request *req = server_alloc_req( sizeof(*req), 0 );
req->hkey = hkey;
req->file = handle;
ret = reg_server_call( REQ_SAVE_REGISTRY );
ret = RtlNtStatusToDosError( SERVER_CALL() );
}
SERVER_END_REQ;

View File

@ -587,13 +587,11 @@ BOOL WINAPI GetThreadSelectorEntry( HANDLE hthread, DWORD sel, LPLDT_ENTRY ldten
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->entry = sel >> __AHSHIFT;
if ((ret = !server_call( REQ_GET_SELECTOR_ENTRY )))
if ((ret = !SERVER_CALL_ERR()))
{
if (!(req->flags & WINE_LDT_FLAGS_ALLOCATED))
{

View File

@ -1314,10 +1314,8 @@ HANDLE WINAPI CreateFileMappingA(
/* Create the server object */
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->size_high = size_high;
req->size_low = size_low;
@ -1325,10 +1323,10 @@ HANDLE WINAPI CreateFileMappingA(
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_MAPPING );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -1372,10 +1370,8 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa,
/* Create the server object */
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->size_high = size_high;
req->size_low = size_low;
@ -1383,10 +1379,10 @@ HANDLE WINAPI CreateFileMappingW( HANDLE hFile, LPSECURITY_ATTRIBUTES sa,
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_MAPPING );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -1411,17 +1407,15 @@ HANDLE WINAPI OpenFileMappingA(
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->inherit = inherit;
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;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -1439,17 +1433,15 @@ HANDLE WINAPI OpenFileMappingW( DWORD access, BOOL inherit, LPCWSTR name)
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_MAPPING );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -1508,11 +1500,10 @@ LPVOID WINAPI MapViewOfFileEx(
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;
res = server_call( REQ_GET_MAPPING_INFO );
res = SERVER_CALL_ERR();
prot = req->protect;
base = req->base;
size_low = req->size_low;

View File

@ -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)
{
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->saving = saving;
req->period = period;
server_call( REQ_SET_REGISTRY_LEVELS );
SERVER_CALL();
}
SERVER_END_REQ;
}
@ -1018,14 +1016,13 @@ static void _save_at_exit(HKEY hkey,LPCSTR path)
ERR( "config dir '%s' too long\n", confdir );
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 );
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] */
@ -1186,12 +1183,11 @@ static void load_wine_registry(HKEY hkey,LPCSTR fn)
if ((file = FILE_CreateFile( fn, GENERIC_READ, 0, NULL, OPEN_EXISTING,
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->file = file;
server_call( REQ_LOAD_REGISTRY );
SERVER_CALL();
}
SERVER_END_REQ;
CloseHandle( file );

View File

@ -45,8 +45,6 @@
#define SERVERDIR "/wineserver-" /* server socket directory (hostname appended) */
#define SOCKETNAME "socket" /* name of the socket file */
#undef server_alloc_req
/* data structure used to pass an fd with sendmsg/recvmsg */
struct cmsg_fd
{
@ -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;
if ((record->ExceptionFlags & (EH_UNWINDING | EH_EXIT_UNWIND)))
*NtCurrentTeb()->buffer_info = server_frame->info;
NtCurrentTeb()->buffer_pos = server_frame->buffer_pos;
return ExceptionContinueSearch;
}
@ -128,22 +126,19 @@ DWORD __wine_server_exception_handler( PEXCEPTION_RECORD record, EXCEPTION_FRAME
/***********************************************************************
* 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;
union generic_request *req = (union generic_request *)((char *)NtCurrentTeb()->buffer + pos);
size_t size = sizeof(*req) + var_size;
unsigned int pos = NtCurrentTeb()->buffer_pos;
assert( fixed_size <= sizeof(*req) );
assert( var_size <= REQUEST_MAX_VAR_SIZE );
assert( 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",
(char *)req + size - (char *)NtCurrentTeb()->buffer_info );
NtCurrentTeb()->buffer_info->cur_pos = pos + size;
req->header.var_offset = pos + sizeof(*req);
req->header.var_size = var_size;
return req;
pos + size - NtCurrentTeb()->buffer_pos );
NtCurrentTeb()->buffer_pos = pos + size;
req->header.var_offset = pos;
req->header.var_size = size;
}
@ -152,12 +147,10 @@ void *wine_server_alloc_req( size_t fixed_size, size_t var_size )
*
* 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;
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))
return;
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 )
*
* 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
struct cmsg_fd cmsg;
@ -200,8 +193,6 @@ static void send_request_fd( enum request req, union generic_request *request, i
msghdr.msg_flags = 0;
#endif /* HAVE_MSGHDR_ACCRIGHTS */
request->header.req = req;
if ((ret = sendmsg( NtCurrentTeb()->socket, &msghdr, 0 )) == sizeof(*request)) return;
if (ret >= 0) server_protocol_error( "partial write %d\n", ret );
if (errno == EPIPE) SYSDEPS_ExitThread(0);
@ -237,30 +228,26 @@ static void wait_reply( union generic_request *req )
*
* 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;
send_request( req, req_ptr );
wait_reply( req_ptr );
return req_ptr->header.error;
memset( (char *)req + size, 0, sizeof(*req) - size );
send_request( req );
wait_reply( req );
return req->header.error;
}
/***********************************************************************
* server_call_fd
* wine_server_call_fd
*
* 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;
union generic_request *req_ptr = NtCurrentTeb()->buffer;
send_request_fd( req, req_ptr, fd_out );
wait_reply( req_ptr );
if ((res = req_ptr->header.error)) SetLastError( RtlNtStatusToDosError(res) );
return res; /* error code */
memset( (char *)req + size, 0, sizeof(*req) - size );
send_request_fd( req, fd );
wait_reply( req );
return req->header.error;
}
@ -271,14 +258,13 @@ unsigned int server_call_fd( enum request req, int fd_out )
*/
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->flags = 0;
req->mask = 0;
req->fd = fd;
if (!server_call( REQ_SET_HANDLE_INFO ))
if (!SERVER_CALL())
{
if (req->cur_fd != fd)
{
@ -597,7 +583,7 @@ int CLIENT_InitThread(void)
{
struct get_thread_buffer_request *req;
TEB *teb = NtCurrentTeb();
int fd, ret, size;
int fd, ret;
/* ignore SIGPIPE so that we get a EPIPE error instead */
signal( SIGPIPE, SIG_IGN );
@ -617,11 +603,11 @@ int CLIENT_InitThread(void)
fd = wine_server_recv_fd( 0, 0 );
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" );
teb->buffer = mmap( 0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
if ((teb->buffer_size = lseek( fd, 0, SEEK_END )) == -1) server_protocol_perror( "lseek" );
teb->buffer = mmap( 0, teb->buffer_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 );
teb->buffer_pos = 0;
close( fd );
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;
wait_reply( (union generic_request *)req );
@ -638,13 +624,12 @@ int CLIENT_InitThread(void)
if (req->boot) boot_thread_id = teb->tid;
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->teb = teb;
req->entry = teb->entry_point;
ret = wine_server_call( REQ_INIT_THREAD );
ret = SERVER_CALL();
}
SERVER_END_REQ;
return ret;
@ -659,11 +644,10 @@ int CLIENT_InitThread(void)
int CLIENT_BootDone( int debug_level )
{
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;
ret = server_call( REQ_BOOT_DONE );
ret = SERVER_CALL();
}
SERVER_END_REQ;
return ret;

View File

@ -41,14 +41,13 @@ BOOL WINAPI CloseHandle( HANDLE handle )
BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
{
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->flags = 0;
req->mask = 0;
req->fd = -1;
ret = !server_call( REQ_SET_HANDLE_INFO );
ret = !SERVER_CALL_ERR();
if (ret && flags) *flags = req->old_flags;
}
SERVER_END_REQ;
@ -62,14 +61,13 @@ BOOL WINAPI GetHandleInformation( HANDLE handle, LPDWORD flags )
BOOL WINAPI SetHandleInformation( HANDLE handle, DWORD mask, DWORD flags )
{
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->flags = flags;
req->mask = mask;
req->fd = -1;
ret = !server_call( REQ_SET_HANDLE_INFO );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -84,10 +82,8 @@ BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
DWORD access, BOOL inherit, DWORD options )
{
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_handle = source;
req->dst_process = dest_process;
@ -95,7 +91,7 @@ BOOL WINAPI DuplicateHandle( HANDLE source_process, HANDLE source,
req->inherit = inherit;
req->options = options;
ret = !server_call( REQ_DUP_HANDLE );
ret = !SERVER_CALL_ERR();
if (ret)
{
if (dest) *dest = req->handle;

View File

@ -17,12 +17,10 @@ BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
LPSECURITY_ATTRIBUTES sa, DWORD size )
{
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);
if ((ret = !server_call( REQ_CREATE_PIPE )))
if ((ret = !SERVER_CALL_ERR()))
{
*hReadPipe = req->handle_read;
*hWritePipe = req->handle_write;

View File

@ -232,14 +232,13 @@ static void set_console_handles( HANDLE console )
HANDLE in = FILE_DupUnixHandle( 0, GENERIC_READ );
HANDLE out = FILE_DupUnixHandle( 1, GENERIC_WRITE );
SERVER_START_REQ
SERVER_START_REQ( set_console_fd )
{
struct set_console_fd_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = console;
req->handle_in = in;
req->handle_out = out;
req->pid = 0;
server_call( REQ_SET_CONSOLE_FD );
SERVER_CALL();
}
SERVER_END_REQ;
NtClose( in );
@ -274,14 +273,11 @@ static BOOL process_init( char *argv[] )
if (CLIENT_InitThread()) return FALSE;
/* Retrieve startup info from the server */
SERVER_START_REQ
SERVER_START_VAR_REQ( init_process, sizeof(main_exe_name)-1 )
{
struct init_process_request *req = server_alloc_req( sizeof(*req),
sizeof(main_exe_name)-1 );
req->ldt_copy = &wine_ldt_copy;
req->ppid = getppid();
if ((ret = !server_call( REQ_INIT_PROCESS )))
if ((ret = !SERVER_CALL_ERR()))
{
size_t len = server_data_size( req );
memcpy( main_exe_name, server_data_ptr(req), len );
@ -296,7 +292,7 @@ static BOOL process_init( char *argv[] )
current_startupinfo.hStdError = req->hstderr;
}
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
if (!ret) return FALSE;
SetStdHandle( STD_INPUT_HANDLE, current_startupinfo.hStdInput );
@ -352,15 +348,14 @@ static void start_process(void)
if (console_app) current_process.flags |= PDB32_CONSOLE_PROC;
/* Signal the parent process to continue */
SERVER_START_REQ
SERVER_START_REQ( init_process_done )
{
struct init_process_done_request *req = server_alloc_req( sizeof(*req), 0 );
req->module = (void *)current_process.module;
req->entry = entry;
req->name = main_exe_name;
req->exe_file = main_exe_file;
req->gui = !console_app;
server_call( REQ_INIT_PROCESS_DONE );
SERVER_CALL();
debugged = req->debugged;
}
SERVER_END_REQ;
@ -799,9 +794,8 @@ BOOL PROCESS_Create( HANDLE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env,
/* create the process on the server side */
SERVER_START_REQ
SERVER_START_VAR_REQ( new_process, MAX_PATH )
{
struct new_process_request *req = server_alloc_req( sizeof(*req), MAX_PATH );
req->inherit_all = inherit;
req->create_flags = flags;
req->start_flags = startup->dwFlags;
@ -832,10 +826,10 @@ BOOL PROCESS_Create( HANDLE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env,
if (!GetLongPathNameA( filename, server_data_ptr(req), MAX_PATH ))
lstrcpynA( server_data_ptr(req), filename, MAX_PATH );
}
ret = !server_call( REQ_NEW_PROCESS );
ret = !SERVER_CALL_ERR();
process_info = req->info;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
if (!ret) return FALSE;
/* fork and execute */
@ -847,13 +841,12 @@ BOOL PROCESS_Create( HANDLE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env,
ret = FALSE;
if ((pid != -1) && (WaitForSingleObject( process_info, 2000 ) == STATUS_WAIT_0))
{
SERVER_START_REQ
SERVER_START_REQ( get_new_process_info )
{
struct get_new_process_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->info = process_info;
req->pinherit = (psa && (psa->nLength >= sizeof(*psa)) && psa->bInheritHandle);
req->tinherit = (tsa && (tsa->nLength >= sizeof(*tsa)) && tsa->bInheritHandle);
if ((ret = !server_call( REQ_GET_NEW_PROCESS_INFO )))
if ((ret = !SERVER_CALL_ERR()))
{
info->dwProcessId = (DWORD)req->pid;
info->dwThreadId = (DWORD)req->tid;
@ -902,13 +895,12 @@ error:
void WINAPI ExitProcess( DWORD status )
{
MODULE_DllProcessDetach( TRUE, (LPVOID)1 );
SERVER_START_REQ
SERVER_START_REQ( terminate_process )
{
struct terminate_process_request *req = server_alloc_req( sizeof(*req), 0 );
/* send the exit code to the server */
req->handle = GetCurrentProcess();
req->exit_code = status;
server_call( REQ_TERMINATE_PROCESS );
SERVER_CALL();
}
SERVER_END_REQ;
exit( status );
@ -1062,14 +1054,12 @@ void WINAPI SetProcessDword( DWORD dwProcessID, INT offset, DWORD value )
HANDLE WINAPI OpenProcess( DWORD access, BOOL inherit, DWORD id )
{
HANDLE ret = 0;
SERVER_START_REQ
SERVER_START_REQ( open_process )
{
struct open_process_request *req = server_alloc_req( sizeof(*req), 0 );
req->pid = (void *)id;
req->access = access;
req->inherit = inherit;
if (!server_call( REQ_OPEN_PROCESS )) ret = req->handle;
if (!SERVER_CALL_ERR()) ret = req->handle;
}
SERVER_END_REQ;
return ret;
@ -1081,11 +1071,10 @@ HANDLE WINAPI OpenProcess( DWORD access, BOOL inherit, DWORD id )
DWORD WINAPI MapProcessHandle( HANDLE handle )
{
DWORD ret = 0;
SERVER_START_REQ
SERVER_START_REQ( get_process_info )
{
struct get_process_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle;
if (!server_call( REQ_GET_PROCESS_INFO )) ret = (DWORD)req->pid;
if (!SERVER_CALL_ERR()) ret = (DWORD)req->pid;
}
SERVER_END_REQ;
return ret;
@ -1097,13 +1086,12 @@ DWORD WINAPI MapProcessHandle( HANDLE handle )
BOOL WINAPI SetPriorityClass( HANDLE hprocess, DWORD priorityclass )
{
BOOL ret;
SERVER_START_REQ
SERVER_START_REQ( set_process_info )
{
struct set_process_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hprocess;
req->priority = priorityclass;
req->mask = SET_PROCESS_INFO_PRIORITY;
ret = !server_call( REQ_SET_PROCESS_INFO );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -1116,11 +1104,10 @@ BOOL WINAPI SetPriorityClass( HANDLE hprocess, DWORD priorityclass )
DWORD WINAPI GetPriorityClass(HANDLE hprocess)
{
DWORD ret = 0;
SERVER_START_REQ
SERVER_START_REQ( get_process_info )
{
struct get_process_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hprocess;
if (!server_call( REQ_GET_PROCESS_INFO )) ret = req->priority;
if (!SERVER_CALL_ERR()) ret = req->priority;
}
SERVER_END_REQ;
return ret;
@ -1133,13 +1120,12 @@ DWORD WINAPI GetPriorityClass(HANDLE hprocess)
BOOL WINAPI SetProcessAffinityMask( HANDLE hProcess, DWORD affmask )
{
BOOL ret;
SERVER_START_REQ
SERVER_START_REQ( set_process_info )
{
struct set_process_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hProcess;
req->affinity = affmask;
req->mask = SET_PROCESS_INFO_AFFINITY;
ret = !server_call( REQ_SET_PROCESS_INFO );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -1153,11 +1139,10 @@ BOOL WINAPI GetProcessAffinityMask( HANDLE hProcess,
LPDWORD lpSystemAffinityMask )
{
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 = hProcess;
if (!server_call( REQ_GET_PROCESS_INFO ))
if (!SERVER_CALL_ERR())
{
if (lpProcessAffinityMask) *lpProcessAffinityMask = req->process_affinity;
if (lpSystemAffinityMask) *lpSystemAffinityMask = req->system_affinity;
@ -1292,13 +1277,12 @@ BOOL WINAPI ReadProcessMemory( HANDLE process, LPCVOID addr, LPVOID buffer, DWOR
for (;;)
{
SERVER_START_REQ
SERVER_START_VAR_REQ( read_process_memory, max )
{
struct read_process_memory_request *req = server_alloc_req( sizeof(*req), max );
req->handle = process;
req->addr = (char *)addr + pos - offset;
req->len = len;
if (!(res = server_call( REQ_READ_PROCESS_MEMORY )))
if (!(res = SERVER_CALL_ERR()))
{
size_t result = server_data_size( req );
if (result > size + offset) result = size + offset;
@ -1307,7 +1291,7 @@ BOOL WINAPI ReadProcessMemory( HANDLE process, LPCVOID addr, LPVOID buffer, DWOR
pos += result - offset;
}
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
if (res)
{
if (bytes_read) *bytes_read = 0;
@ -1354,9 +1338,8 @@ BOOL WINAPI WriteProcessMemory( HANDLE process, LPVOID addr, LPVOID buffer, DWOR
for (;;)
{
SERVER_START_REQ
SERVER_START_VAR_REQ( write_process_memory, max )
{
struct write_process_memory_request *req = server_alloc_req( sizeof(*req), max );
req->handle = process;
req->addr = (char *)addr - first_offset + pos;
req->len = len;
@ -1370,13 +1353,13 @@ BOOL WINAPI WriteProcessMemory( HANDLE process, LPVOID addr, LPVOID buffer, DWOR
memcpy( (char *)server_data_ptr(req) + first_offset, (char *)buffer + pos,
max - first_offset );
if (!(res = server_call( REQ_WRITE_PROCESS_MEMORY )))
if (!(res = SERVER_CALL_ERR()))
{
pos += max - first_offset;
size -= max - first_offset;
}
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
if (res)
{
if (bytes_written) *bytes_written = 0;
@ -1417,11 +1400,10 @@ BOOL WINAPI GetExitCodeProcess(
LPDWORD lpExitCode) /* [out] address to receive termination status */
{
BOOL ret;
SERVER_START_REQ
SERVER_START_REQ( get_process_info )
{
struct get_process_info_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = hProcess;
ret = !server_call( REQ_GET_PROCESS_INFO );
ret = !SERVER_CALL_ERR();
if (ret && lpExitCode) *lpExitCode = req->exit_code;
}
SERVER_END_REQ;

View File

@ -72,18 +72,17 @@ static void call_apcs( BOOL alertable )
for (;;)
{
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;
if (!server_call( REQ_GET_APC ))
if (!SERVER_CALL())
{
type = req->type;
proc = req->func;
memcpy( args, server_data_ptr(req), server_data_size(req) );
}
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
switch(type)
{
@ -176,9 +175,8 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
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 );
req->flags = SELECT_INTERRUPTIBLE;
@ -190,9 +188,9 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
if (alertable) req->flags |= SELECT_ALERTABLE;
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_USER_APC) break;
call_apcs( alertable );

View File

@ -55,12 +55,11 @@ TEB *THREAD_IdToTEB( DWORD id )
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->tid_in = (void *)id;
if (!server_call_noerr( REQ_GET_THREAD_INFO )) ret = req->teb;
if (!SERVER_CALL()) ret = req->teb;
}
SERVER_END_REQ;
@ -121,8 +120,7 @@ static void CALLBACK THREAD_FreeTEB( TEB *teb )
close( teb->wait_fd );
if (teb->stack_sel) FreeSelector16( teb->stack_sel );
FreeSelector16( teb->teb_sel );
if (teb->buffer) munmap( (void *)teb->buffer,
(char *)(teb->buffer_info+1) - (char *)teb->buffer );
if (teb->buffer) munmap( (void *)teb->buffer, teb->buffer_size );
if (teb->debug_info) HeapFree( GetProcessHeap(), 0, teb->debug_info );
VirtualFree( teb->stack_base, 0, MEM_RELEASE );
}
@ -313,13 +311,11 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
TEB *teb;
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->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (!server_call( REQ_NEW_THREAD ))
if (!SERVER_CALL_ERR())
{
handle = req->handle;
tid = req->tid;
@ -382,14 +378,12 @@ HANDLE WINAPI CreateThread16( SECURITY_ATTRIBUTES *sa, DWORD stack,
void WINAPI ExitThread( DWORD code ) /* [in] Exit code for this thread */
{
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 */
req->handle = GetCurrentThread();
req->exit_code = code;
server_call( REQ_TERMINATE_THREAD );
SERVER_CALL();
last = req->last;
}
SERVER_END_REQ;
@ -419,16 +413,14 @@ BOOL WINAPI SetThreadContext( HANDLE handle, /* [in] Handle to thread
const CONTEXT *context ) /* [in] Address of context structure */
{
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->flags = context->ContextFlags;
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;
}
@ -444,17 +436,15 @@ BOOL WINAPI GetThreadContext( HANDLE handle, /* [in] Handle to thread with
CONTEXT *context ) /* [out] Address of context structure */
{
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->flags = context->ContextFlags;
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) );
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -470,12 +460,11 @@ INT WINAPI GetThreadPriority(
HANDLE hthread) /* [in] Handle to thread */
{
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->tid_in = 0;
if (!server_call( REQ_GET_THREAD_INFO )) ret = req->priority;
if (!SERVER_CALL_ERR()) ret = req->priority;
}
SERVER_END_REQ;
return ret;
@ -494,13 +483,12 @@ BOOL WINAPI SetThreadPriority(
INT priority) /* [in] Thread priority level */
{
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->priority = priority;
req->mask = SET_THREAD_INFO_PRIORITY;
ret = !server_call( REQ_SET_THREAD_INFO );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -549,13 +537,12 @@ BOOL WINAPI SetThreadPriorityBoost(
DWORD WINAPI SetThreadAffinityMask( HANDLE hThread, DWORD dwThreadAffinityMask )
{
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->affinity = dwThreadAffinityMask;
req->mask = SET_THREAD_INFO_AFFINITY;
ret = !server_call( REQ_SET_THREAD_INFO );
ret = !SERVER_CALL_ERR();
/* FIXME: should return previous value */
}
SERVER_END_REQ;
@ -594,12 +581,11 @@ BOOL WINAPI GetExitCodeThread(
LPDWORD exitcode) /* [out] Address to receive termination status */
{
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->tid_in = 0;
ret = !server_call( REQ_GET_THREAD_INFO );
ret = !SERVER_CALL_ERR();
if (ret && exitcode) *exitcode = req->exit_code;
}
SERVER_END_REQ;
@ -622,11 +608,10 @@ DWORD WINAPI ResumeThread(
HANDLE hthread) /* [in] Identifies thread to restart */
{
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;
if (!server_call( REQ_RESUME_THREAD )) ret = req->count;
if (!SERVER_CALL_ERR()) ret = req->count;
}
SERVER_END_REQ;
return ret;
@ -644,11 +629,10 @@ DWORD WINAPI SuspendThread(
HANDLE hthread) /* [in] Handle to the thread */
{
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;
if (!server_call( REQ_SUSPEND_THREAD )) ret = req->count;
if (!SERVER_CALL_ERR()) ret = req->count;
}
SERVER_END_REQ;
return ret;
@ -661,14 +645,13 @@ DWORD WINAPI SuspendThread(
DWORD WINAPI QueueUserAPC( PAPCFUNC func, HANDLE hthread, ULONG_PTR data )
{
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->user = 1;
req->func = func;
req->param = (void *)data;
ret = !server_call( REQ_QUEUE_APC );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;

View File

@ -25,18 +25,16 @@ HANDLE WINAPI CreateWaitableTimerA( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCSTR
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
if (len) MultiByteToWideChar( CP_ACP, 0, name, strlen(name), server_data_ptr(req), len );
SetLastError(0);
server_call( REQ_CREATE_TIMER );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -53,18 +51,16 @@ HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWST
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
SetLastError(0);
server_call( REQ_CREATE_TIMER );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -81,17 +77,15 @@ HANDLE WINAPI OpenWaitableTimerA( DWORD access, BOOL inherit, LPCSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->inherit = inherit;
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;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -108,17 +102,15 @@ HANDLE WINAPI OpenWaitableTimerW( DWORD access, BOOL inherit, LPCWSTR name )
SetLastError( ERROR_FILENAME_EXCED_RANGE );
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->inherit = inherit;
memcpy( server_data_ptr(req), name, len * sizeof(WCHAR) );
server_call( REQ_OPEN_TIMER );
SERVER_CALL_ERR();
ret = req->handle;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -139,10 +131,8 @@ BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG per
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)
{
/* 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
req->callback = callback;
req->arg = arg;
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;
return ret;
@ -173,11 +163,10 @@ BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG per
BOOL WINAPI CancelWaitableTimer( HANDLE handle )
{
BOOL ret;
SERVER_START_REQ
SERVER_START_REQ( cancel_timer )
{
struct cancel_timer_request *req = server_alloc_req( sizeof(*req), 0 );
req->handle = handle;
ret = !server_call( REQ_CANCEL_TIMER );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;

View File

@ -178,12 +178,18 @@ static inline void call_req_handler( struct thread *thread, union generic_reques
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",
request->header.var_offset, request->header.var_size );
if ((unsigned int)request->header.var_offset +
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 );
if (current) send_reply( current, request );

View File

@ -101,7 +101,6 @@ static int alloc_client_buffer( struct thread *thread )
if (ftruncate( fd, MAX_REQUEST_LENGTH ) == -1) goto error;
if ((thread->buffer = mmap( 0, MAX_REQUEST_LENGTH, PROT_READ | PROT_WRITE,
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;
thread->reply_fd = fd_pipe[1];
thread->wait_fd = wait_pipe[1];
@ -177,7 +176,7 @@ struct thread *create_thread( int fd, struct process *process )
thread->affinity = 1;
thread->suspend = 0;
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 );
if (!current) current = thread;
@ -690,7 +689,7 @@ DECL_HANDLER(boot_done)
{
debug_level = max( debug_level, req->debug_level );
/* Make sure last_req is initialized */
current->last_req = REQ_BOOT_DONE;
current->last_req = REQ_boot_done;
if (current == booting_thread)
{
booting_thread = (struct thread *)~0UL; /* make sure it doesn't match other threads */

View File

@ -67,7 +67,6 @@ struct thread
int affinity; /* affinity mask */
int suspend; /* suspend count */
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) */
};

View File

@ -63,7 +63,7 @@ REPLACE_IN_FILE( "server/trace.c", @trace_lines );
my @server_lines = ();
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, "union generic_request\n{\n";
push @server_lines, " struct request_max_size max_size;\n";

View File

@ -101,11 +101,10 @@ extern int wine_openpty(int *master, int *slave, char *name,
static int CONSOLE_GetPid( HANDLE handle )
{
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;
if (!server_call( REQ_GET_CONSOLE_INFO )) ret = req->pid;
if (!SERVER_CALL_ERR()) ret = req->pid;
}
SERVER_END_REQ;
return ret;
@ -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) );
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->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 (read) *read = req->read;
}
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
return ret;
}
@ -554,10 +551,9 @@ COORD WINAPI GetLargestConsoleWindowSize( HANDLE hConsoleOutput )
BOOL WINAPI FreeConsole(VOID)
{
BOOL ret;
SERVER_START_REQ
SERVER_START_REQ( free_console )
{
struct free_console_request *req = server_alloc_req( sizeof(*req), 0 );
ret = !server_call( REQ_FREE_CONSOLE );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -629,14 +625,13 @@ static BOOL CONSOLE_make_complex(HANDLE handle)
CloseHandle( pty_handle );
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_in = pty_handle;
req->handle_out = pty_handle;
req->pid = xpid;
server_call( REQ_SET_CONSOLE_FD );
SERVER_CALL();
}
SERVER_END_REQ;
CloseHandle( pty_handle );
@ -669,13 +664,11 @@ BOOL WINAPI AllocConsole(VOID)
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->inherit = FALSE;
ret = !server_call( REQ_ALLOC_CONSOLE );
ret = !SERVER_CALL_ERR();
handle_in = req->handle_in;
handle_out = req->handle_out;
}
@ -728,11 +721,10 @@ UINT WINAPI GetConsoleOutputCP(VOID)
BOOL WINAPI GetConsoleMode(HANDLE hcon,LPDWORD mode)
{
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;
ret = !server_call( REQ_GET_CONSOLE_MODE );
ret = !SERVER_CALL_ERR();
if (ret && mode) *mode = req->mode;
}
SERVER_END_REQ;
@ -754,12 +746,11 @@ BOOL WINAPI GetConsoleMode(HANDLE hcon,LPDWORD mode)
BOOL WINAPI SetConsoleMode( HANDLE hcon, DWORD mode )
{
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->mode = mode;
ret = !server_call( REQ_SET_CONSOLE_MODE );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;
@ -794,12 +785,10 @@ DWORD WINAPI GetConsoleTitleA(LPSTR title,DWORD size)
if ((hcon = CreateFileA( "CONOUT$", GENERIC_READ, 0, NULL,
OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE)
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;
if (!server_call( REQ_GET_CONSOLE_INFO ))
if (!SERVER_CALL_ERR())
{
ret = server_data_size(req);
size = min( size-1, ret );
@ -807,7 +796,7 @@ DWORD WINAPI GetConsoleTitleA(LPSTR title,DWORD size)
title[size] = 0;
}
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
CloseHandle( hcon );
return ret;
}
@ -1184,20 +1173,18 @@ BOOL WINAPI WriteConsoleInputA( HANDLE handle, INPUT_RECORD *buffer,
while (count && ret)
{
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;
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;
count -= len;
buffer += len;
}
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
}
return ret;
}
@ -1237,15 +1224,14 @@ BOOL WINAPI SetConsoleTitleA(LPCSTR title)
return FALSE;
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->mask = SET_CONSOLE_INFO_TITLE;
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 ))
{
@ -1349,11 +1335,10 @@ BOOL WINAPI GetConsoleCursorInfo( HANDLE hcon, LPCONSOLE_CURSOR_INFO cinfo )
{
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;
ret = !server_call( REQ_GET_CONSOLE_INFO );
ret = !SERVER_CALL_ERR();
if (ret && cinfo)
{
cinfo->dwSize = req->cursor_size;
@ -1384,14 +1369,13 @@ BOOL WINAPI SetConsoleCursorInfo(
sprintf(buf,"\033[?25%c",cinfo->bVisible?'h':'l');
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->cursor_size = cinfo->dwSize;
req->cursor_visible = cinfo->bVisible;
req->mask = SET_CONSOLE_INFO_CURSOR;
ret = !server_call( REQ_SET_CONSOLE_INFO );
ret = !SERVER_CALL_ERR();
}
SERVER_END_REQ;
return ret;

View File

@ -337,12 +337,10 @@ HANDLE DEVICE_Open( LPCSTR filename, DWORD access,
static const struct VxDInfo *DEVICE_GetInfo( HANDLE handle )
{
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;
if (!server_call( REQ_GET_FILE_INFO ) &&
if (!SERVER_CALL() &&
(req->type == FILE_TYPE_UNKNOWN) &&
(req->attr & 0x10000))
{

View File

@ -151,33 +151,29 @@ static int send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *c
int ret;
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);
EXCEPTION_RECORD *rec_ptr = (EXCEPTION_RECORD *)(context_ptr + 1);
req->first = first_chance;
*rec_ptr = *rec;
*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 */
/* 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
* 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;
if (!server_call_noerr( REQ_GET_EXCEPTION_STATUS ))
*context = *(CONTEXT *)server_data_ptr(req);
if (!SERVER_CALL()) *context = *(CONTEXT *)server_data_ptr(req);
ret = req->status;
}
SERVER_END_REQ;
SERVER_END_VAR_REQ;
NtClose( handle );
return ret;
}

View File

@ -451,10 +451,9 @@ static HQUEUE16 QUEUE_CreateMsgQueue( BOOL16 bCreatePerQData )
if ( !msgQueue )
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( REQ_GET_MSG_QUEUE );
SERVER_CALL_ERR();
handle = req->handle;
}
SERVER_END_REQ;
@ -654,12 +653,11 @@ static BOOL QUEUE_TrySetWakeBit( MESSAGEQUEUE *queue, WORD bit, BOOL always )
}
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->bits = bit;
server_call( REQ_WAKE_QUEUE );
SERVER_CALL();
}
SERVER_END_REQ;
}
@ -1560,12 +1558,11 @@ DWORD WINAPI WaitForInputIdle (HANDLE hProcess, DWORD dwTimeOut)
DWORD cur_time, ret;
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->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;
if (ret) return 0xffffffff; /* error */