Commit db692c8f authored by Alexandre Julliard's avatar Alexandre Julliard

Open a real file handle for drive devices, and get rid of the server

device hacks (based on a patch by Eric Pouech).
parent 05df86a3
......@@ -665,24 +665,12 @@ NTSTATUS WINAPI NtDeviceIoControlFile(HANDLE DeviceHandle, HANDLE hEvent,
PVOID OutputBuffer,
ULONG OutputBufferSize)
{
DWORD clientID = 0;
TRACE("(%p,%p,%p,%p,%p,0x%08lx,%p,0x%08lx,%p,0x%08lx)\n",
DeviceHandle, hEvent, UserApcRoutine, UserApcContext,
IoStatusBlock, IoControlCode,
InputBuffer, InputBufferSize, OutputBuffer, OutputBufferSize);
/* FIXME: clientID hack should disappear */
SERVER_START_REQ( get_device_id )
{
req->handle = DeviceHandle;
if (!wine_server_call( req )) clientID = reply->id;
}
SERVER_END_REQ;
if (!clientID) return STATUS_INVALID_PARAMETER;
if (CDROM_DeviceIoControl(clientID, DeviceHandle, hEvent,
if (CDROM_DeviceIoControl(DeviceHandle, hEvent,
UserApcRoutine, UserApcContext,
IoStatusBlock, IoControlCode,
InputBuffer, InputBufferSize,
......
......@@ -1084,7 +1084,7 @@
################################################################
# Wine dll separation hacks, these will go away, don't use them
#
@ cdecl CDROM_InitRegistry(long long str)
@ cdecl CDROM_InitRegistry(long)
@ cdecl MODULE_DllThreadAttach(ptr)
@ cdecl MODULE_GetLoadOrderW(ptr wstr wstr)
@ cdecl VERSION_Init(wstr)
......
......@@ -89,7 +89,7 @@ extern HANDLE (WINAPI *pCreateFileW)( LPCWSTR filename, DWORD access, DWORD shar
/* Device IO */
/* ntdll/cdrom.c.c */
extern NTSTATUS CDROM_DeviceIoControl(DWORD clientID, HANDLE hDevice,
extern NTSTATUS CDROM_DeviceIoControl(HANDLE hDevice,
HANDLE hEvent, PIO_APC_ROUTINE UserApcRoutine,
PVOID UserApcContext,
PIO_STATUS_BLOCK piosb,
......
......@@ -141,7 +141,7 @@ inline static char *heap_strdup( const char *str )
#define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
extern void CDROM_InitRegistry(int dev, int id, const char *device);
extern void CDROM_InitRegistry(int dev);
/***********************************************************************
* DRIVE_GetDriveType
......@@ -334,7 +334,7 @@ int DRIVE_Init(void)
int cd_fd;
if ((cd_fd = open(drive->device, O_RDONLY|O_NONBLOCK)) != -1)
{
CDROM_InitRegistry(cd_fd, i, drive->device);
CDROM_InitRegistry(cd_fd);
close(cd_fd);
}
}
......
......@@ -264,28 +264,6 @@ HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
}
/***********************************************************************
* FILE_CreateDevice
*
* Same as FILE_CreateFile but for a device
* Returns 0 on failure.
*/
HANDLE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa )
{
HANDLE ret;
SERVER_START_REQ( create_device )
{
req->access = access;
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
req->id = client_id;
SetLastError(0);
wine_server_call_err( req );
ret = reply->handle;
}
SERVER_END_REQ;
return ret;
}
static HANDLE FILE_OpenPipe(LPCWSTR name, DWORD access, LPSECURITY_ATTRIBUTES sa )
{
HANDLE ret;
......@@ -392,7 +370,17 @@ HANDLE WINAPI CreateFileW( LPCWSTR filename, DWORD access, DWORD sharing,
}
else if (isalphaW(filename[4]) && filename[5] == ':' && filename[6] == '\0')
{
ret = FILE_CreateDevice( (toupperW(filename[4]) - 'A') | 0x20000, access, sa );
const char *device = DRIVE_GetDevice( toupperW(filename[4]) - 'A' );
if (device)
{
ret = FILE_CreateFile( device, access, sharing, sa, creation,
attributes, template, TRUE, DRIVE_FIXED );
}
else
{
SetLastError( ERROR_ACCESS_DENIED );
ret = INVALID_HANDLE_VALUE;
}
goto done;
}
else if (!RtlIsDosDeviceName_U( filename ))
......
......@@ -63,12 +63,10 @@ extern int FILE_strcasecmp( const char *str1, const char *str2 );
extern int FILE_strncasecmp( const char *str1, const char *str2, int len );
extern void FILE_SetDosError(void);
extern BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info, BOOL *is_symlink );
extern HFILE16 FILE_Dup2( HFILE16 hFile1, HFILE16 hFile2 );
extern HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
LPSECURITY_ATTRIBUTES sa, DWORD creation,
DWORD attributes, HANDLE template, BOOL fail_read_only,
UINT drive_type );
extern HANDLE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa );
extern LONG WINAPI WIN16_hread(HFILE16,SEGPTR,LONG);
......
......@@ -1504,34 +1504,6 @@ struct get_mapping_info_reply
};
struct create_device_request
{
struct request_header __header;
unsigned int access;
int inherit;
int id;
};
struct create_device_reply
{
struct reply_header __header;
obj_handle_t handle;
};
struct get_device_id_request
{
struct request_header __header;
obj_handle_t handle;
};
struct get_device_id_reply
{
struct reply_header __header;
int id;
};
#define SNAP_HEAPLIST 0x00000001
#define SNAP_PROCESS 0x00000002
#define SNAP_THREAD 0x00000004
......@@ -3278,8 +3250,6 @@ enum request
REQ_create_mapping,
REQ_open_mapping,
REQ_get_mapping_info,
REQ_create_device,
REQ_get_device_id,
REQ_create_snapshot,
REQ_next_process,
REQ_next_thread,
......@@ -3468,8 +3438,6 @@ union generic_request
struct create_mapping_request create_mapping_request;
struct open_mapping_request open_mapping_request;
struct get_mapping_info_request get_mapping_info_request;
struct create_device_request create_device_request;
struct get_device_id_request get_device_id_request;
struct create_snapshot_request create_snapshot_request;
struct next_process_request next_process_request;
struct next_thread_request next_thread_request;
......@@ -3656,8 +3624,6 @@ union generic_reply
struct create_mapping_reply create_mapping_reply;
struct open_mapping_reply open_mapping_reply;
struct get_mapping_info_reply get_mapping_info_reply;
struct create_device_reply create_device_reply;
struct get_device_id_reply get_device_id_reply;
struct create_snapshot_reply create_snapshot_reply;
struct next_process_reply next_process_reply;
struct next_thread_reply next_thread_reply;
......@@ -3763,6 +3729,6 @@ union generic_reply
struct set_global_windows_reply set_global_windows_reply;
};
#define SERVER_PROTOCOL_VERSION 132
#define SERVER_PROTOCOL_VERSION 133
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
......@@ -16,7 +16,6 @@ C_SRCS = \
context_powerpc.c \
context_sparc.c \
debugger.c \
device.c \
event.c \
fd.c \
file.c \
......
/*
* Server-side device management
*
* Copyright (C) 1999 Alexandre Julliard
*
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* FIXME:
* all this stuff is a simple hack to avoid breaking
* client-side device support.
*/
#include <assert.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "handle.h"
#include "thread.h"
#include "request.h"
struct device
{
struct object obj; /* object header */
int id; /* client identifier */
};
static void device_dump( struct object *obj, int verbose );
static const struct object_ops device_ops =
{
sizeof(struct device), /* size */
device_dump, /* dump */
no_add_queue, /* add_queue */
NULL, /* remove_queue */
NULL, /* signaled */
NULL, /* satisfied */
no_get_fd, /* get_fd */
no_destroy /* destroy */
};
static struct device *create_device( int id )
{
struct device *dev;
if ((dev = alloc_object( &device_ops )))
{
dev->id = id;
}
return dev;
}
static void device_dump( struct object *obj, int verbose )
{
struct device *dev = (struct device *)obj;
assert( obj->ops == &device_ops );
fprintf( stderr, "Device id=%08x\n", dev->id );
}
/* create a device */
DECL_HANDLER(create_device)
{
struct device *dev;
reply->handle = 0;
if ((dev = create_device( req->id )))
{
reply->handle = alloc_handle( current->process, dev, req->access, req->inherit );
release_object( dev );
}
}
/* Retrieve the client private id for a device */
DECL_HANDLER(get_device_id)
{
struct device *dev;
if ((dev = (struct device *)get_handle_obj( current->process, req->handle, 0, &device_ops )))
{
reply->id = dev->id;
release_object( dev );
}
}
......@@ -1106,24 +1106,6 @@ enum char_info_mode
@END
/* Create a device */
@REQ(create_device)
unsigned int access; /* wanted access rights */
int inherit; /* inherit flag */
int id; /* client private id */
@REPLY
obj_handle_t handle; /* handle to the device */
@END
/* Retrieve the client private id for a device */
@REQ(get_device_id)
obj_handle_t handle; /* handle to the device */
@REPLY
int id; /* client private id */
@END
#define SNAP_HEAPLIST 0x00000001
#define SNAP_PROCESS 0x00000002
#define SNAP_THREAD 0x00000004
......
......@@ -181,8 +181,6 @@ DECL_HANDLER(next_change_notification);
DECL_HANDLER(create_mapping);
DECL_HANDLER(open_mapping);
DECL_HANDLER(get_mapping_info);
DECL_HANDLER(create_device);
DECL_HANDLER(get_device_id);
DECL_HANDLER(create_snapshot);
DECL_HANDLER(next_process);
DECL_HANDLER(next_thread);
......@@ -370,8 +368,6 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
(req_handler)req_create_mapping,
(req_handler)req_open_mapping,
(req_handler)req_get_mapping_info,
(req_handler)req_create_device,
(req_handler)req_get_device_id,
(req_handler)req_create_snapshot,
(req_handler)req_next_process,
(req_handler)req_next_thread,
......
......@@ -1346,28 +1346,6 @@ static void dump_get_mapping_info_reply( const struct get_mapping_info_reply *re
fprintf( stderr, " removable=%d", req->removable );
}
static void dump_create_device_request( const struct create_device_request *req )
{
fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " inherit=%d,", req->inherit );
fprintf( stderr, " id=%d", req->id );
}
static void dump_create_device_reply( const struct create_device_reply *req )
{
fprintf( stderr, " handle=%p", req->handle );
}
static void dump_get_device_id_request( const struct get_device_id_request *req )
{
fprintf( stderr, " handle=%p", req->handle );
}
static void dump_get_device_id_reply( const struct get_device_id_reply *req )
{
fprintf( stderr, " id=%d", req->id );
}
static void dump_create_snapshot_request( const struct create_snapshot_request *req )
{
fprintf( stderr, " inherit=%d,", req->inherit );
......@@ -2681,8 +2659,6 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_create_mapping_request,
(dump_func)dump_open_mapping_request,
(dump_func)dump_get_mapping_info_request,
(dump_func)dump_create_device_request,
(dump_func)dump_get_device_id_request,
(dump_func)dump_create_snapshot_request,
(dump_func)dump_next_process_request,
(dump_func)dump_next_thread_request,
......@@ -2867,8 +2843,6 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_create_mapping_reply,
(dump_func)dump_open_mapping_reply,
(dump_func)dump_get_mapping_info_reply,
(dump_func)dump_create_device_reply,
(dump_func)dump_get_device_id_reply,
(dump_func)dump_create_snapshot_reply,
(dump_func)dump_next_process_reply,
(dump_func)dump_next_thread_reply,
......@@ -3053,8 +3027,6 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
"create_mapping",
"open_mapping",
"get_mapping_info",
"create_device",
"get_device_id",
"create_snapshot",
"next_process",
"next_thread",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment