Check Server Version From Client Dlls (Try 2)
Robert Shearman
rob at codeweavers.com
Thu Jul 22 17:31:06 CDT 2004
Changelog:
Check server version from x11drv, kernel32 and user32 to prevent
mismatches of installed dlls.
-------------- next part --------------
Index: wine/include/wine/server.h
===================================================================
RCS file: /home/wine/wine/include/wine/server.h,v
retrieving revision 1.19
diff -u -r1.19 server.h
--- wine/include/wine/server.h 1 Dec 2003 23:01:12 -0000 1.19
+++ wine/include/wine/server.h 22 Jul 2004 22:27:08 -0000
@@ -56,6 +56,7 @@
extern int wine_server_handle_to_fd( obj_handle_t handle, unsigned int access, int *unix_fd,
enum fd_type *type, int *flags );
extern void wine_server_release_fd( obj_handle_t handle, int unix_fd );
+extern BOOL wine_server_check_version( const char * module, int ver );
/* do a server call and set the last error code */
inline static unsigned int wine_server_call_err( void *req_ptr )
Index: wine/dlls/ntdll/ntdll.spec
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/ntdll.spec,v
retrieving revision 1.157
diff -u -r1.157 ntdll.spec
--- wine/dlls/ntdll/ntdll.spec 15 Jul 2004 22:07:21 -0000 1.157
+++ wine/dlls/ntdll/ntdll.spec 22 Jul 2004 22:27:08 -0000
@@ -1118,6 +1118,7 @@
@ cdecl wine_server_handle_to_fd(long long ptr ptr ptr)
@ cdecl wine_server_release_fd(long long)
@ cdecl wine_server_send_fd(long)
+@ cdecl wine_server_check_version(str long)
# Codepages
@ cdecl __wine_init_codepages(ptr ptr ptr)
Index: wine/dlls/ntdll/server.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/server.c,v
retrieving revision 1.14
diff -u -r1.14 server.c
--- wine/dlls/ntdll/server.c 30 May 2004 03:11:10 -0000 1.14
+++ wine/dlls/ntdll/server.c 22 Jul 2004 22:27:08 -0000
@@ -236,6 +236,23 @@
* wine_server_call (NTDLL.@)
*
* Perform a server call.
+ *
+ * PARAMS
+ * req_ptr [I/O] Function dependent data
+ *
+ * RETURNS
+ * Depends on server function being called, but usually an NTSTATUS code.
+ *
+ * NOTES
+ * Use the SERVER_START_REQ and SERVER_END_REQ to help you fill out the
+ * server request structure for the particular call. E.g:
+ *| SERVER_START_REQ( event_op )
+ *| {
+ *| req->handle = handle;
+ *| req->op = SET_EVENT;
+ *| ret = wine_server_call( req );
+ *| }
+ *| SERVER_END_REQ;
*/
unsigned int wine_server_call( void *req_ptr )
{
@@ -254,6 +271,12 @@
* wine_server_send_fd
*
* Send a file descriptor to the server.
+ *
+ * PARAMS
+ * fd [I] file descriptor to send
+ *
+ * RETURNS
+ * nothing
*/
void wine_server_send_fd( int fd )
{
@@ -397,7 +420,16 @@
/***********************************************************************
* wine_server_fd_to_handle (NTDLL.@)
*
- * Allocate a file handle for a Unix fd.
+ * Allocate a file handle for a Unix file descriptor.
+ *
+ * PARAMS
+ * fd [I] file descriptor
+ * access [I] Win32 access flags
+ * inherit [I] indicates whether this handle is inherited by child processes
+ * handle [O] file handle
+ *
+ * RETURNS
+ * NTSTATUS code
*/
int wine_server_fd_to_handle( int fd, unsigned int access, int inherit, obj_handle_t *handle )
{
@@ -467,7 +499,14 @@
/***********************************************************************
* wine_server_release_fd (NTDLL.@)
*
- * Release the Unix fd returned by wine_server_handle_to_fd.
+ * Release the Unix file descriptor returned by wine_server_handle_to_fd.
+ *
+ * PARAMS
+ * handle [I] Wine file handle.
+ * unix_fd [I] Unix file descriptor to release.
+ *
+ * RETURNS
+ * nothing
*/
void wine_server_release_fd( obj_handle_t handle, int unix_fd )
{
@@ -845,4 +884,30 @@
"Or maybe the wrong wineserver is still running?\n",
version, SERVER_PROTOCOL_VERSION,
(version > SERVER_PROTOCOL_VERSION) ? "wine" : "wineserver" );
+}
+
+/***********************************************************************
+ * wine_server_check_version (NTDLL.@)
+ *
+ * Checks whether the server is of the specified version.
+ *
+ * PARAMS
+ * module [I] The module that is performing the version check.
+ * ver [I] Expected server version.
+ *
+ * RETURNS
+ * TRUE if the server version matches.
+ * FALSE otherwise.
+ */
+BOOL wine_server_check_version( const char *module, int ver )
+{
+ if (ver != SERVER_PROTOCOL_VERSION)
+ {
+ MESSAGE( "Error: server version mismatch (client: %d, server: %d).\n"
+ "Your %s binary was not upgraded correctly\n"
+ "or the wrong wineserver is still running.\n",
+ ver, SERVER_PROTOCOL_VERSION, module );
+ return FALSE;
+ }
+ return TRUE;
}
Index: wine/dlls/user/user_main.c
===================================================================
RCS file: /home/wine/wine/dlls/user/user_main.c,v
retrieving revision 1.69
diff -u -r1.69 user_main.c
--- wine/dlls/user/user_main.c 13 Jul 2004 03:53:55 -0000 1.69
+++ wine/dlls/user/user_main.c 22 Jul 2004 22:27:09 -0000
@@ -34,6 +34,7 @@
#include "user.h"
#include "win.h"
#include "wine/debug.h"
+#include "wine/server.h"
WINE_DEFAULT_DEBUG_CHANNEL(graphics);
@@ -164,6 +165,9 @@
static BOOL process_attach(void)
{
HINSTANCE16 instance;
+
+ if (!wine_server_check_version( "user32", SERVER_PROTOCOL_VERSION ))
+ return FALSE;
/* Create USER heap */
if ((instance = LoadLibrary16( "USER.EXE" )) >= 32) USER_HeapSel = instance | 7;
Index: wine/dlls/x11drv/x11drv_main.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/x11drv_main.c,v
retrieving revision 1.93
diff -u -r1.93 x11drv_main.c
--- wine/dlls/x11drv/x11drv_main.c 13 Jul 2004 03:49:52 -0000 1.93
+++ wine/dlls/x11drv/x11drv_main.c 22 Jul 2004 22:27:09 -0000
@@ -338,6 +338,9 @@
{
Display *display;
+ if (!wine_server_check_version( "x11drv", SERVER_PROTOCOL_VERSION ))
+ return FALSE;
+
get_server_startup();
setup_options();
Index: wine/dlls/kernel/kernel_main.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/kernel_main.c,v
retrieving revision 1.64
diff -u -r1.64 kernel_main.c
--- wine/dlls/kernel/kernel_main.c 15 Jun 2004 00:52:03 -0000 1.64
+++ wine/dlls/kernel/kernel_main.c 22 Jul 2004 22:27:09 -0000
@@ -36,6 +36,7 @@
#include "wine/winbase16.h"
#include "wine/library.h"
+#include "wine/server.h"
#include "miscemu.h"
#include "module.h"
#include "thread.h"
@@ -109,6 +110,9 @@
{
HMODULE16 hModule;
SYSTEM_INFO si;
+
+ if (!wine_server_check_version( "kernel32", SERVER_PROTOCOL_VERSION ))
+ return FALSE;
/* FIXME: should probably be done in ntdll */
GetSystemInfo( &si );
More information about the wine-patches
mailing list