Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
bf269501
Commit
bf269501
authored
Jul 08, 2015
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server: Pass the file instead of the device pointer in all IRP requests.
parent
13499a3d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
42 deletions
+70
-42
ntoskrnl.c
dlls/ntoskrnl.exe/ntoskrnl.c
+40
-16
server_protocol.h
include/wine/server_protocol.h
+5
-5
device.c
server/device.c
+17
-13
protocol.def
server/protocol.def
+4
-4
trace.c
server/trace.c
+4
-4
No files found.
dlls/ntoskrnl.exe/ntoskrnl.c
View file @
bf269501
...
...
@@ -131,14 +131,6 @@ static HANDLE get_device_manager(void)
static
NTSTATUS
dispatch_irp
(
DEVICE_OBJECT
*
device
,
IRP
*
irp
)
{
LARGE_INTEGER
count
;
FILE_OBJECT
file
;
irp
->
RequestorMode
=
UserMode
;
irp
->
Tail
.
Overlay
.
OriginalFileObject
=
&
file
;
memset
(
&
file
,
0x88
,
sizeof
(
file
)
);
file
.
FsContext
=
NULL
;
file
.
FsContext2
=
NULL
;
KeQueryTickCount
(
&
count
);
/* update the global KeTickCount */
...
...
@@ -185,6 +177,7 @@ static NTSTATUS dispatch_create( const irp_params_t *params, void *in_buff, ULON
irpsp
->
Parameters
.
Create
.
EaLength
=
0
;
irp
->
Tail
.
Overlay
.
OriginalFileObject
=
file
;
irp
->
RequestorMode
=
UserMode
;
irp
->
AssociatedIrp
.
SystemBuffer
=
NULL
;
irp
->
UserBuffer
=
NULL
;
irp
->
UserIosb
=
irp_handle
;
/* note: we abuse UserIosb to store the server irp handle */
...
...
@@ -227,6 +220,7 @@ static NTSTATUS dispatch_close( const irp_params_t *params, void *in_buff, ULONG
irpsp
->
Parameters
.
Create
.
EaLength
=
0
;
irp
->
Tail
.
Overlay
.
OriginalFileObject
=
file
;
irp
->
RequestorMode
=
UserMode
;
irp
->
AssociatedIrp
.
SystemBuffer
=
NULL
;
irp
->
UserBuffer
=
NULL
;
irp
->
UserIosb
=
irp_handle
;
/* note: we abuse UserIosb to store the server irp handle */
...
...
@@ -247,11 +241,15 @@ static NTSTATUS dispatch_read( const irp_params_t *params, void *in_buff, ULONG
void
*
out_buff
;
LARGE_INTEGER
offset
;
IO_STACK_LOCATION
*
irpsp
;
DEVICE_OBJECT
*
device
=
wine_server_get_ptr
(
params
->
read
.
device
);
DEVICE_OBJECT
*
device
;
FILE_OBJECT
*
file
=
wine_server_get_ptr
(
params
->
read
.
file
);
if
(
!
file
)
return
STATUS_INVALID_HANDLE
;
device
=
file
->
DeviceObject
;
if
(
!
device
->
DriverObject
->
MajorFunction
[
IRP_MJ_READ
])
return
STATUS_NOT_SUPPORTED
;
TRACE
(
"device %p
size %u
\n
"
,
devic
e
,
out_size
);
TRACE
(
"device %p
file %p size %u
\n
"
,
device
,
fil
e
,
out_size
);
if
(
!
(
out_buff
=
HeapAlloc
(
GetProcessHeap
(),
0
,
out_size
)))
return
STATUS_NO_MEMORY
;
...
...
@@ -265,6 +263,9 @@ static NTSTATUS dispatch_read( const irp_params_t *params, void *in_buff, ULONG
return
STATUS_NO_MEMORY
;
}
irp
->
Tail
.
Overlay
.
OriginalFileObject
=
file
;
irp
->
RequestorMode
=
UserMode
;
irpsp
=
IoGetNextIrpStackLocation
(
irp
);
irpsp
->
Parameters
.
Read
.
Key
=
params
->
read
.
key
;
...
...
@@ -278,11 +279,15 @@ static NTSTATUS dispatch_write( const irp_params_t *params, void *in_buff, ULONG
IRP
*
irp
;
LARGE_INTEGER
offset
;
IO_STACK_LOCATION
*
irpsp
;
DEVICE_OBJECT
*
device
=
wine_server_get_ptr
(
params
->
write
.
device
);
DEVICE_OBJECT
*
device
;
FILE_OBJECT
*
file
=
wine_server_get_ptr
(
params
->
write
.
file
);
if
(
!
file
)
return
STATUS_INVALID_HANDLE
;
device
=
file
->
DeviceObject
;
if
(
!
device
->
DriverObject
->
MajorFunction
[
IRP_MJ_WRITE
])
return
STATUS_NOT_SUPPORTED
;
TRACE
(
"device %p
size %u
\n
"
,
devic
e
,
in_size
);
TRACE
(
"device %p
file %p size %u
\n
"
,
device
,
fil
e
,
in_size
);
offset
.
QuadPart
=
params
->
write
.
pos
;
...
...
@@ -291,6 +296,9 @@ static NTSTATUS dispatch_write( const irp_params_t *params, void *in_buff, ULONG
&
offset
,
NULL
,
irp_handle
)))
return
STATUS_NO_MEMORY
;
irp
->
Tail
.
Overlay
.
OriginalFileObject
=
file
;
irp
->
RequestorMode
=
UserMode
;
irpsp
=
IoGetNextIrpStackLocation
(
irp
);
irpsp
->
Parameters
.
Write
.
Key
=
params
->
write
.
key
;
...
...
@@ -302,17 +310,24 @@ static NTSTATUS dispatch_flush( const irp_params_t *params, void *in_buff, ULONG
ULONG
out_size
,
HANDLE
irp_handle
)
{
IRP
*
irp
;
DEVICE_OBJECT
*
device
=
wine_server_get_ptr
(
params
->
flush
.
device
);
DEVICE_OBJECT
*
device
;
FILE_OBJECT
*
file
=
wine_server_get_ptr
(
params
->
flush
.
file
);
if
(
!
file
)
return
STATUS_INVALID_HANDLE
;
device
=
file
->
DeviceObject
;
if
(
!
device
->
DriverObject
->
MajorFunction
[
IRP_MJ_FLUSH_BUFFERS
])
return
STATUS_NOT_SUPPORTED
;
TRACE
(
"device %p
\n
"
,
devic
e
);
TRACE
(
"device %p
file %p
\n
"
,
device
,
fil
e
);
/* note: we abuse UserIosb to store the server irp handle */
if
(
!
(
irp
=
IoBuildSynchronousFsdRequest
(
IRP_MJ_FLUSH_BUFFERS
,
device
,
in_buff
,
in_size
,
NULL
,
NULL
,
irp_handle
)))
return
STATUS_NO_MEMORY
;
irp
->
Tail
.
Overlay
.
OriginalFileObject
=
file
;
irp
->
RequestorMode
=
UserMode
;
return
dispatch_irp
(
device
,
irp
);
}
...
...
@@ -322,11 +337,16 @@ static NTSTATUS dispatch_ioctl( const irp_params_t *params, void *in_buff, ULONG
{
IRP
*
irp
;
void
*
out_buff
=
NULL
;
DEVICE_OBJECT
*
device
=
wine_server_get_ptr
(
params
->
ioctl
.
device
);
DEVICE_OBJECT
*
device
;
FILE_OBJECT
*
file
=
wine_server_get_ptr
(
params
->
ioctl
.
file
);
if
(
!
file
)
return
STATUS_INVALID_HANDLE
;
device
=
file
->
DeviceObject
;
if
(
!
device
->
DriverObject
->
MajorFunction
[
IRP_MJ_DEVICE_CONTROL
])
return
STATUS_NOT_SUPPORTED
;
TRACE
(
"ioctl %x device %p in_size %u out_size %u
\n
"
,
params
->
ioctl
.
code
,
device
,
in_size
,
out_size
);
TRACE
(
"ioctl %x device %p file %p in_size %u out_size %u
\n
"
,
params
->
ioctl
.
code
,
device
,
file
,
in_size
,
out_size
);
if
((
params
->
ioctl
.
code
&
3
)
==
METHOD_BUFFERED
)
out_size
=
max
(
in_size
,
out_size
);
...
...
@@ -348,6 +368,10 @@ static NTSTATUS dispatch_ioctl( const irp_params_t *params, void *in_buff, ULONG
HeapFree
(
GetProcessHeap
(),
0
,
out_buff
);
return
STATUS_NO_MEMORY
;
}
irp
->
Tail
.
Overlay
.
OriginalFileObject
=
file
;
irp
->
RequestorMode
=
UserMode
;
return
dispatch_irp
(
device
,
irp
);
}
...
...
include/wine/server_protocol.h
View file @
bf269501
...
...
@@ -652,27 +652,27 @@ typedef union
{
unsigned
int
major
;
unsigned
int
key
;
client_ptr_t
devic
e
;
client_ptr_t
fil
e
;
file_pos_t
pos
;
}
read
;
struct
{
unsigned
int
major
;
unsigned
int
key
;
client_ptr_t
devic
e
;
client_ptr_t
fil
e
;
file_pos_t
pos
;
}
write
;
struct
{
unsigned
int
major
;
int
__pad
;
client_ptr_t
devic
e
;
client_ptr_t
fil
e
;
}
flush
;
struct
{
unsigned
int
major
;
ioctl_code_t
code
;
client_ptr_t
devic
e
;
client_ptr_t
fil
e
;
}
ioctl
;
}
irp_params_t
;
...
...
@@ -6096,6 +6096,6 @@ union generic_reply
struct
terminate_job_reply
terminate_job_reply
;
};
#define SERVER_PROTOCOL_VERSION 48
0
#define SERVER_PROTOCOL_VERSION 48
1
#endif
/* __WINE_WINE_SERVER_PROTOCOL_H */
server/device.c
View file @
bf269501
...
...
@@ -475,6 +475,10 @@ static void set_file_user_ptr( struct device_file *file, client_ptr_t ptr )
switch
(
irp
->
params
.
major
)
{
case
IRP_MJ_CLOSE
:
irp
->
params
.
close
.
file
=
ptr
;
break
;
case
IRP_MJ_READ
:
irp
->
params
.
read
.
file
=
ptr
;
break
;
case
IRP_MJ_WRITE
:
irp
->
params
.
write
.
file
=
ptr
;
break
;
case
IRP_MJ_FLUSH_BUFFERS
:
irp
->
params
.
flush
.
file
=
ptr
;
break
;
case
IRP_MJ_DEVICE_CONTROL
:
irp
->
params
.
ioctl
.
file
=
ptr
;
break
;
}
}
}
...
...
@@ -511,10 +515,10 @@ static obj_handle_t device_file_read( struct fd *fd, const async_data_t *async_d
obj_handle_t
handle
;
irp_params_t
params
;
params
.
read
.
major
=
IRP_MJ_READ
;
params
.
read
.
key
=
0
;
params
.
read
.
pos
=
pos
;
params
.
read
.
device
=
file
->
devic
e
->
user_ptr
;
params
.
read
.
major
=
IRP_MJ_READ
;
params
.
read
.
key
=
0
;
params
.
read
.
pos
=
pos
;
params
.
read
.
file
=
fil
e
->
user_ptr
;
irp
=
create_irp
(
file
,
&
params
,
NULL
,
0
,
get_reply_max_size
()
);
if
(
!
irp
)
return
0
;
...
...
@@ -532,10 +536,10 @@ static obj_handle_t device_file_write( struct fd *fd, const async_data_t *async_
obj_handle_t
handle
;
irp_params_t
params
;
params
.
write
.
major
=
IRP_MJ_WRITE
;
params
.
write
.
key
=
0
;
params
.
write
.
pos
=
pos
;
params
.
write
.
device
=
file
->
devic
e
->
user_ptr
;
params
.
write
.
major
=
IRP_MJ_WRITE
;
params
.
write
.
key
=
0
;
params
.
write
.
pos
=
pos
;
params
.
write
.
file
=
fil
e
->
user_ptr
;
irp
=
create_irp
(
file
,
&
params
,
get_req_data
(),
get_req_data_size
(),
0
);
if
(
!
irp
)
return
0
;
...
...
@@ -552,8 +556,8 @@ static obj_handle_t device_file_flush( struct fd *fd, const async_data_t *async_
obj_handle_t
handle
;
irp_params_t
params
;
params
.
flush
.
major
=
IRP_MJ_FLUSH_BUFFERS
;
params
.
flush
.
device
=
file
->
devic
e
->
user_ptr
;
params
.
flush
.
major
=
IRP_MJ_FLUSH_BUFFERS
;
params
.
flush
.
file
=
fil
e
->
user_ptr
;
irp
=
create_irp
(
file
,
&
params
,
NULL
,
0
,
0
);
if
(
!
irp
)
return
0
;
...
...
@@ -571,9 +575,9 @@ static obj_handle_t device_file_ioctl( struct fd *fd, ioctl_code_t code, const a
obj_handle_t
handle
;
irp_params_t
params
;
params
.
ioctl
.
major
=
IRP_MJ_DEVICE_CONTROL
;
params
.
ioctl
.
code
=
code
;
params
.
ioctl
.
device
=
file
->
devic
e
->
user_ptr
;
params
.
ioctl
.
major
=
IRP_MJ_DEVICE_CONTROL
;
params
.
ioctl
.
code
=
code
;
params
.
ioctl
.
file
=
fil
e
->
user_ptr
;
irp
=
create_irp
(
file
,
&
params
,
get_req_data
(),
get_req_data_size
(),
get_reply_max_size
()
);
...
...
server/protocol.def
View file @
bf269501
...
...
@@ -668,27 +668,27 @@ typedef union
{
unsigned int major; /* IRP_MJ_READ */
unsigned int key; /* driver key */
client_ptr_t
device; /* opaque ptr for the device
*/
client_ptr_t
file; /* opaque ptr for the file object
*/
file_pos_t pos; /* file position */
} read;
struct
{
unsigned int major; /* IRP_MJ_WRITE */
unsigned int key; /* driver key */
client_ptr_t
device; /* opaque ptr for the device
*/
client_ptr_t
file; /* opaque ptr for the file object
*/
file_pos_t pos; /* file position */
} write;
struct
{
unsigned int major; /* IRP_MJ_FLUSH_BUFFERS */
int __pad;
client_ptr_t
device; /* opaque ptr for the device
*/
client_ptr_t
file; /* opaque ptr for the file object
*/
} flush;
struct
{
unsigned int major; /* IRP_MJ_DEVICE_CONTROL */
ioctl_code_t code; /* ioctl code */
client_ptr_t
device; /* opaque ptr for the device
*/
client_ptr_t
file; /* opaque ptr for the file object
*/
} ioctl;
} irp_params_t;
...
...
server/trace.c
View file @
bf269501
...
...
@@ -330,24 +330,24 @@ static void dump_irp_params( const char *prefix, const irp_params_t *data )
case
IRP_MJ_READ
:
fprintf
(
stderr
,
"%s{major=READ,key=%08x"
,
prefix
,
data
->
read
.
key
);
dump_uint64
(
",pos="
,
&
data
->
read
.
pos
);
dump_uint64
(
",
device="
,
&
data
->
read
.
devic
e
);
dump_uint64
(
",
file="
,
&
data
->
read
.
fil
e
);
fputc
(
'}'
,
stderr
);
break
;
case
IRP_MJ_WRITE
:
fprintf
(
stderr
,
"%s{major=WRITE,key=%08x"
,
prefix
,
data
->
write
.
key
);
dump_uint64
(
",pos="
,
&
data
->
write
.
pos
);
dump_uint64
(
",
device="
,
&
data
->
write
.
devic
e
);
dump_uint64
(
",
file="
,
&
data
->
write
.
fil
e
);
fputc
(
'}'
,
stderr
);
break
;
case
IRP_MJ_FLUSH_BUFFERS
:
fprintf
(
stderr
,
"%s{major=FLUSH_BUFFERS"
,
prefix
);
dump_uint64
(
",
device="
,
&
data
->
flush
.
devic
e
);
dump_uint64
(
",
file="
,
&
data
->
flush
.
fil
e
);
fputc
(
'}'
,
stderr
);
break
;
case
IRP_MJ_DEVICE_CONTROL
:
fprintf
(
stderr
,
"%s{major=DEVICE_CONTROL"
,
prefix
);
dump_ioctl_code
(
",code="
,
&
data
->
ioctl
.
code
);
dump_uint64
(
",
device="
,
&
data
->
ioctl
.
devic
e
);
dump_uint64
(
",
file="
,
&
data
->
ioctl
.
fil
e
);
fputc
(
'}'
,
stderr
);
break
;
case
IRP_MJ_MAXIMUM_FUNCTION
+
1
:
/* invalid */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment