2001-07-19 02:39:09 +02:00
|
|
|
/*
|
|
|
|
* Definitions for the client side of the Wine server communication
|
|
|
|
*
|
|
|
|
* Copyright (C) 1998 Alexandre Julliard
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2001-07-19 02:39:09 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __WINE_WINE_SERVER_H
|
|
|
|
#define __WINE_WINE_SERVER_H
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
2003-08-28 23:43:34 +02:00
|
|
|
#include <winternl.h>
|
|
|
|
#include <wine/server_protocol.h>
|
2001-07-19 02:39:09 +02:00
|
|
|
|
|
|
|
/* client communication functions */
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
struct __server_iovec
|
|
|
|
{
|
|
|
|
const void *ptr;
|
2006-07-26 10:43:25 +02:00
|
|
|
data_size_t size;
|
2001-11-30 19:46:42 +01:00
|
|
|
};
|
|
|
|
|
2002-03-29 19:28:56 +01:00
|
|
|
#define __SERVER_MAX_DATA 5
|
2001-11-30 19:46:42 +01:00
|
|
|
|
|
|
|
struct __server_request_info
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
union generic_request req; /* request structure */
|
|
|
|
union generic_reply reply; /* reply structure */
|
|
|
|
} u;
|
|
|
|
unsigned int data_count; /* count of request data pointers */
|
|
|
|
void *reply_data; /* reply data pointer */
|
|
|
|
struct __server_iovec data[__SERVER_MAX_DATA]; /* request variable size data */
|
|
|
|
};
|
|
|
|
|
2019-06-18 11:33:16 +02:00
|
|
|
extern unsigned int CDECL wine_server_call( void *req_ptr );
|
2008-12-16 16:37:46 +01:00
|
|
|
extern void CDECL wine_server_send_fd( int fd );
|
|
|
|
extern int CDECL wine_server_fd_to_handle( int fd, unsigned int access, unsigned int attributes, HANDLE *handle );
|
|
|
|
extern int CDECL wine_server_handle_to_fd( HANDLE handle, unsigned int access, int *unix_fd, unsigned int *options );
|
|
|
|
extern void CDECL wine_server_release_fd( HANDLE handle, int unix_fd );
|
2001-07-19 02:39:09 +02:00
|
|
|
|
|
|
|
/* do a server call and set the last error code */
|
2007-03-26 21:26:29 +02:00
|
|
|
static inline unsigned int wine_server_call_err( void *req_ptr )
|
2001-07-19 02:39:09 +02:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
unsigned int res = wine_server_call( req_ptr );
|
2001-07-19 02:39:09 +02:00
|
|
|
if (res) SetLastError( RtlNtStatusToDosError(res) );
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
/* get the size of the variable part of the returned reply */
|
2007-03-26 21:26:29 +02:00
|
|
|
static inline data_size_t wine_server_reply_size( const void *reply )
|
2001-07-19 02:39:09 +02:00
|
|
|
{
|
2004-11-30 22:38:57 +01:00
|
|
|
return ((const struct reply_header *)reply)->reply_size;
|
2001-07-19 02:39:09 +02:00
|
|
|
}
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
/* add some data to be sent along with the request */
|
2007-03-26 21:26:29 +02:00
|
|
|
static inline void wine_server_add_data( void *req_ptr, const void *ptr, data_size_t size )
|
2001-07-19 02:39:09 +02:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
struct __server_request_info * const req = req_ptr;
|
|
|
|
if (size)
|
|
|
|
{
|
|
|
|
req->data[req->data_count].ptr = ptr;
|
|
|
|
req->data[req->data_count++].size = size;
|
|
|
|
req->u.req.request_header.request_size += size;
|
|
|
|
}
|
2001-07-19 02:39:09 +02:00
|
|
|
}
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
/* set the pointer and max size for the reply var data */
|
2007-03-26 21:26:29 +02:00
|
|
|
static inline void wine_server_set_reply( void *req_ptr, void *ptr, data_size_t max_size )
|
2001-07-19 02:39:09 +02:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
struct __server_request_info * const req = req_ptr;
|
|
|
|
req->reply_data = ptr;
|
|
|
|
req->u.req.request_header.reply_size = max_size;
|
|
|
|
}
|
2001-07-19 02:39:09 +02:00
|
|
|
|
2008-12-08 16:05:17 +01:00
|
|
|
/* convert an object handle to a server handle */
|
|
|
|
static inline obj_handle_t wine_server_obj_handle( HANDLE handle )
|
|
|
|
{
|
|
|
|
if ((int)(INT_PTR)handle != (INT_PTR)handle) return 0xfffffff0; /* some invalid handle */
|
|
|
|
return (INT_PTR)handle;
|
|
|
|
}
|
|
|
|
|
2008-12-08 16:58:20 +01:00
|
|
|
/* convert a user handle to a server handle */
|
|
|
|
static inline user_handle_t wine_server_user_handle( HANDLE handle )
|
|
|
|
{
|
|
|
|
return (UINT_PTR)handle;
|
|
|
|
}
|
|
|
|
|
2008-12-08 16:05:17 +01:00
|
|
|
/* convert a server handle to a generic handle */
|
|
|
|
static inline HANDLE wine_server_ptr_handle( obj_handle_t handle )
|
|
|
|
{
|
|
|
|
return (HANDLE)(INT_PTR)(int)handle;
|
|
|
|
}
|
|
|
|
|
2008-12-29 16:47:51 +01:00
|
|
|
/* convert a client pointer to a server client_ptr_t */
|
|
|
|
static inline client_ptr_t wine_server_client_ptr( const void *ptr )
|
|
|
|
{
|
|
|
|
return (client_ptr_t)(ULONG_PTR)ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert a server client_ptr_t to a real pointer */
|
|
|
|
static inline void *wine_server_get_ptr( client_ptr_t ptr )
|
|
|
|
{
|
|
|
|
return (void *)(ULONG_PTR)ptr;
|
|
|
|
}
|
|
|
|
|
2001-07-19 02:39:09 +02:00
|
|
|
|
|
|
|
/* macros for server requests */
|
|
|
|
|
|
|
|
#define SERVER_START_REQ(type) \
|
|
|
|
do { \
|
2001-11-30 19:46:42 +01:00
|
|
|
struct __server_request_info __req; \
|
|
|
|
struct type##_request * const req = &__req.u.req.type##_request; \
|
|
|
|
const struct type##_reply * const reply = &__req.u.reply.type##_reply; \
|
2003-03-30 05:08:52 +02:00
|
|
|
memset( &__req.u.req, 0, sizeof(__req.u.req) ); \
|
2001-11-30 19:46:42 +01:00
|
|
|
__req.u.req.request_header.req = REQ_##type; \
|
|
|
|
__req.data_count = 0; \
|
|
|
|
(void)reply; \
|
2001-07-19 02:39:09 +02:00
|
|
|
do
|
|
|
|
|
|
|
|
#define SERVER_END_REQ \
|
|
|
|
while(0); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* __WINE_WINE_SERVER_H */
|