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
1895a425
Commit
1895a425
authored
Mar 04, 2015
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntoskrnl: Use the MDL allocation routines for standard ioctl processing.
parent
5fc369ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
22 deletions
+36
-22
ntoskrnl.c
dlls/ntoskrnl.exe/ntoskrnl.c
+34
-22
wdm.h
include/ddk/wdm.h
+2
-0
No files found.
dlls/ntoskrnl.exe/ntoskrnl.c
View file @
1895a425
...
...
@@ -140,7 +140,6 @@ static HANDLE get_device_manager(void)
static
NTSTATUS
process_ioctl
(
DEVICE_OBJECT
*
device
,
ULONG
code
,
void
*
in_buff
,
ULONG
in_size
,
void
*
out_buff
,
ULONG
*
out_size
)
{
MDL
mdl
;
IRP
*
irp
;
void
*
sys_buff
=
NULL
;
FILE_OBJECT
file
;
...
...
@@ -150,7 +149,6 @@ static NTSTATUS process_ioctl( DEVICE_OBJECT *device, ULONG code, void *in_buff,
TRACE
(
"ioctl %x device %p in_size %u out_size %u
\n
"
,
code
,
device
,
in_size
,
*
out_size
);
/* so we can spot things that we should initialize */
memset
(
&
mdl
,
0x77
,
sizeof
(
mdl
)
);
memset
(
&
file
,
0x88
,
sizeof
(
file
)
);
if
((
code
&
3
)
==
METHOD_BUFFERED
)
...
...
@@ -170,18 +168,13 @@ static NTSTATUS process_ioctl( DEVICE_OBJECT *device, ULONG code, void *in_buff,
irp
->
RequestorMode
=
UserMode
;
irp
->
AssociatedIrp
.
SystemBuffer
=
((
code
&
3
)
==
METHOD_BUFFERED
)
?
sys_buff
:
in_buff
;
irp
->
UserBuffer
=
out_buff
;
irp
->
MdlAddress
=
&
mdl
;
irp
->
Tail
.
Overlay
.
OriginalFileObject
=
&
file
;
mdl
.
Next
=
NULL
;
mdl
.
Size
=
0
;
mdl
.
StartVa
=
out_buff
;
mdl
.
ByteCount
=
*
out_size
;
mdl
.
ByteOffset
=
0
;
file
.
FsContext
=
NULL
;
file
.
FsContext2
=
NULL
;
IoAllocateMdl
(
out_buff
,
*
out_size
,
FALSE
,
FALSE
,
irp
);
device
->
CurrentIrp
=
irp
;
KeQueryTickCount
(
&
count
);
/* update the global KeTickCount */
...
...
@@ -385,8 +378,18 @@ PIRP WINAPI IoAllocateIrp( CCHAR stack_size, BOOLEAN charge_quota )
*/
void
WINAPI
IoFreeIrp
(
IRP
*
irp
)
{
MDL
*
mdl
;
TRACE
(
"%p
\n
"
,
irp
);
mdl
=
irp
->
MdlAddress
;
while
(
mdl
)
{
MDL
*
next
=
mdl
->
Next
;
IoFreeMdl
(
mdl
);
mdl
=
next
;
}
ExFreePool
(
irp
);
}
...
...
@@ -404,24 +407,21 @@ PVOID WINAPI IoAllocateErrorLogEntry( PVOID IoObject, UCHAR EntrySize )
/***********************************************************************
* IoAllocateMdl (NTOSKRNL.EXE.@)
*/
PMDL
WINAPI
IoAllocateMdl
(
PVOID
VirtualAddress
,
ULONG
Length
,
BOOLEAN
SecondaryBuffer
,
BOOLEAN
ChargeQuota
,
PIRP
I
rp
)
PMDL
WINAPI
IoAllocateMdl
(
PVOID
va
,
ULONG
length
,
BOOLEAN
secondary
,
BOOLEAN
charge_quota
,
IRP
*
i
rp
)
{
PMDL
mdl
;
ULONG_PTR
address
=
(
ULONG_PTR
)
VirtualAddress
;
ULONG_PTR
address
=
(
ULONG_PTR
)
va
;
ULONG_PTR
page_address
;
SIZE_T
nb_pages
,
mdl_size
;
TRACE
(
"(%p, %u, %i, %i, %p)
\n
"
,
VirtualAddress
,
Length
,
SecondaryBuffer
,
ChargeQuota
,
I
rp
);
TRACE
(
"(%p, %u, %i, %i, %p)
\n
"
,
va
,
length
,
secondary
,
charge_quota
,
i
rp
);
if
(
Irp
)
FIXME
(
"Attaching the MDL to an IRP is not yet supported
\n
"
);
if
(
ChargeQuota
)
if
(
charge_quota
)
FIXME
(
"Charge quota is not yet supported
\n
"
);
/* FIXME: We suppose that page size is 4096 */
page_address
=
address
&
~
(
4096
-
1
);
nb_pages
=
(((
address
+
L
ength
-
1
)
&
~
(
4096
-
1
))
-
page_address
)
/
4096
+
1
;
nb_pages
=
(((
address
+
l
ength
-
1
)
&
~
(
4096
-
1
))
-
page_address
)
/
4096
+
1
;
mdl_size
=
sizeof
(
MDL
)
+
nb_pages
*
sizeof
(
PVOID
);
...
...
@@ -430,11 +430,24 @@ PMDL WINAPI IoAllocateMdl( PVOID VirtualAddress, ULONG Length, BOOLEAN Secondary
return
NULL
;
mdl
->
Size
=
mdl_size
;
mdl
->
Process
=
IoGetCurrentProcess
();
mdl
->
Process
=
NULL
;
/* FIXME: IoGetCurrentProcess */
mdl
->
StartVa
=
(
PVOID
)
page_address
;
mdl
->
ByteCount
=
L
ength
;
mdl
->
ByteCount
=
l
ength
;
mdl
->
ByteOffset
=
address
-
page_address
;
if
(
!
irp
)
return
mdl
;
if
(
secondary
)
/* add it at the end */
{
MDL
**
pmdl
=
&
irp
->
MdlAddress
;
while
(
*
pmdl
)
pmdl
=
&
(
*
pmdl
)
->
Next
;
*
pmdl
=
mdl
;
}
else
{
mdl
->
Next
=
irp
->
MdlAddress
;
irp
->
MdlAddress
=
mdl
;
}
return
mdl
;
}
...
...
@@ -442,10 +455,9 @@ PMDL WINAPI IoAllocateMdl( PVOID VirtualAddress, ULONG Length, BOOLEAN Secondary
/***********************************************************************
* IoFreeMdl (NTOSKRNL.EXE.@)
*/
VOID
WINAPI
IoFreeMdl
(
PMDL
mdl
)
void
WINAPI
IoFreeMdl
(
PMDL
mdl
)
{
FIXME
(
"partial stub: %p
\n
"
,
mdl
);
TRACE
(
"%p
\n
"
,
mdl
);
HeapFree
(
GetProcessHeap
(),
0
,
mdl
);
}
...
...
include/ddk/wdm.h
View file @
1895a425
...
...
@@ -1199,6 +1199,7 @@ void WINAPI ExFreePoolWithTag(PVOID,ULONG);
NTSTATUS
WINAPI
IoAllocateDriverObjectExtension
(
PDRIVER_OBJECT
,
PVOID
,
ULONG
,
PVOID
*
);
PVOID
WINAPI
IoAllocateErrorLogEntry
(
PVOID
,
UCHAR
);
PIRP
WINAPI
IoAllocateIrp
(
CCHAR
,
BOOLEAN
);
PMDL
WINAPI
IoAllocateMdl
(
PVOID
,
ULONG
,
BOOLEAN
,
BOOLEAN
,
IRP
*
);
PIRP
WINAPI
IoBuildDeviceIoControlRequest
(
ULONG
,
DEVICE_OBJECT
*
,
PVOID
,
ULONG
,
PVOID
,
ULONG
,
BOOLEAN
,
PKEVENT
,
IO_STATUS_BLOCK
*
);
NTSTATUS
WINAPI
IoCallDriver
(
DEVICE_OBJECT
*
,
IRP
*
);
VOID
WINAPI
IoCompleteRequest
(
IRP
*
,
UCHAR
);
...
...
@@ -1209,6 +1210,7 @@ void WINAPI IoDeleteDevice(DEVICE_OBJECT*);
void
WINAPI
IoDeleteDriver
(
DRIVER_OBJECT
*
);
NTSTATUS
WINAPI
IoDeleteSymbolicLink
(
UNICODE_STRING
*
);
void
WINAPI
IoFreeIrp
(
IRP
*
);
void
WINAPI
IoFreeMdl
(
MDL
*
);
PEPROCESS
WINAPI
IoGetCurrentProcess
(
void
);
NTSTATUS
WINAPI
IoGetDeviceInterfaces
(
const
GUID
*
,
PDEVICE_OBJECT
,
ULONG
,
PWSTR
*
);
NTSTATUS
WINAPI
IoGetDeviceObjectPointer
(
UNICODE_STRING
*
,
ACCESS_MASK
,
PFILE_OBJECT
*
,
PDEVICE_OBJECT
*
);
...
...
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