[Wine-patches] [1/10] ntoskrnl.exe: Implement IoAllocateMdl and IoFreeMdl.
Alexander Morozov
=?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пн Ноя 24 18:58:26 MSK 2008
----------- следующая часть -----------
From 3dec8f96b8f3dbad0223da5c4f16854f44c071b8 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Wed, 19 Nov 2008 19:54:03 +0300
Subject: [PATCH] ntoskrnl.exe: Implement IoAllocateMdl and IoFreeMdl.
---
dlls/ntoskrnl.exe/ntoskrnl.c | 63 +++++++++++++++++++++++++++++++++-
dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 2 +-
2 files changed, 62 insertions(+), 3 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 7e6ee81..71da10a 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -478,8 +478,67 @@ void WINAPI IoFreeIrp( IRP *irp )
*/
PMDL WINAPI IoAllocateMdl( PVOID VirtualAddress, ULONG Length, BOOLEAN SecondaryBuffer, BOOLEAN ChargeQuota, PIRP Irp )
{
- FIXME( "stub: %p, %u, %i, %i, %p\n", VirtualAddress, Length, SecondaryBuffer, ChargeQuota, Irp );
- return NULL;
+ HANDLE process;
+ PMDL mdl;
+ PVOID ptr;
+ SIZE_T bytes_read;
+
+ TRACE( "%p, %u, %i, %i, %p\n", VirtualAddress, Length, SecondaryBuffer,
+ ChargeQuota, Irp );
+
+ ptr = ExAllocatePool( NonPagedPool, Length );
+ if (NULL == ptr)
+ return NULL;
+
+ mdl = ExAllocatePool( NonPagedPool, sizeof(*mdl) );
+ if (NULL == mdl)
+ {
+ ExFreePool(ptr);
+ return NULL;
+ }
+
+ RtlZeroMemory( mdl, sizeof(*mdl) );
+ mdl->ByteCount = Length;
+ mdl->MappedSystemVa = ptr;
+ mdl->StartVa = VirtualAddress;
+
+ process = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pid );
+ if (NULL == process)
+ {
+ ExFreePool( mdl );
+ ExFreePool( ptr );
+ return NULL;
+ }
+
+ NtReadVirtualMemory( process, VirtualAddress, ptr, Length, &bytes_read );
+
+ CloseHandle( process );
+
+ return mdl;
+}
+
+
+/***********************************************************************
+ * IoFreeMdl (NTOSKRNL.EXE.@)
+ */
+void WINAPI IoFreeMdl( MDL *mdl )
+{
+ HANDLE process;
+ SIZE_T bytes_written;
+
+ TRACE( "%p\n", mdl );
+
+ process = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pid );
+ if (NULL != process)
+ {
+ NtWriteVirtualMemory( process, mdl->StartVa, mdl->MappedSystemVa,
+ mdl->ByteCount, &bytes_written );
+
+ CloseHandle( process );
+ }
+
+ ExFreePool( mdl->MappedSystemVa );
+ ExFreePool( mdl );
}
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
index efdd8c6..11a5523 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
+++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec
@@ -371,7 +371,7 @@
@ stub IoFreeController
@ stub IoFreeErrorLogEntry
@ stdcall IoFreeIrp(ptr)
-@ stub IoFreeMdl
+@ stdcall IoFreeMdl(ptr)
@ stub IoFreeWorkItem
@ stub IoGetAttachedDevice
@ stub IoGetAttachedDeviceReference
--
1.6.0.2.GIT
Подробная информация о списке рассылки Wine-patches