Module: wine Branch: master Commit: 5c65471681cad45c21fd80b8bb243590dc032470 URL: http://source.winehq.org/git/wine.git/?a=commit;h=5c65471681cad45c21fd80b8bb...
Author: Christian Costa titan.costa@gmail.com Date: Tue Oct 2 00:09:51 2012 +0200
ntoskrnl.exe: Implement IoAllocateMdl.
---
dlls/ntoskrnl.exe/ntoskrnl.c | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 2cf7983..ba2034d 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -415,13 +415,34 @@ PVOID WINAPI IoAllocateErrorLogEntry( PVOID IoObject, UCHAR EntrySize ) PMDL WINAPI IoAllocateMdl( PVOID VirtualAddress, ULONG Length, BOOLEAN SecondaryBuffer, BOOLEAN ChargeQuota, PIRP Irp ) { PMDL mdl; + ULONG_PTR address = (ULONG_PTR)VirtualAddress; + ULONG_PTR page_address; + SIZE_T nb_pages, mdl_size;
- FIXME("partial stub: %p, %u, %i, %i, %p\n", VirtualAddress, Length, SecondaryBuffer, ChargeQuota, Irp); + TRACE("(%p, %u, %i, %i, %p)\n", VirtualAddress, Length, SecondaryBuffer, ChargeQuota, Irp);
- mdl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(MDL)); + if (Irp) + FIXME("Attaching the MDL to an IRP is not yet supported\n"); + + if (ChargeQuota) + FIXME("Charge quota is not yet supported\n"); + + /* FIXME: We suppose that page size is 4096 */ + page_address = address & ~(4096 - 1); + nb_pages = (((address + Length - 1) & ~(4096 - 1)) - page_address) / 4096 + 1; + + mdl_size = sizeof(MDL) + nb_pages * sizeof(PVOID); + + mdl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mdl_size); if (!mdl) return NULL;
+ mdl->Size = mdl_size; + mdl->Process = IoGetCurrentProcess(); + mdl->StartVa = (PVOID)page_address; + mdl->ByteCount = Length; + mdl->ByteOffset = address - page_address; + return mdl; }