[Wine-patches] [3/23] ntoskrnl.exe: Implement Io{Allocate, Get}DriverObjectExtension.

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пн Янв 19 18:22:43 MSK 2009


For eterhack branch
----------- следующая часть -----------
From 5c8fb0dee652311b62d80508440107060ad36918 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Thu, 15 Jan 2009 18:39:22 +0300
Subject: [PATCH] ntoskrnl.exe: Implement Io{Allocate,Get}DriverObjectExtension.

---
 dlls/ntoskrnl.exe/ntoskrnl.c |   52 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index cc885c1..bcd0c7f 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -84,6 +84,16 @@ struct MemoryRegion
     int release;
 };
 
+static struct list DriverObjExtensions = LIST_INIT(DriverObjExtensions);
+
+struct DriverObjExtension
+{
+    struct list entry;
+    void *ptr;
+    DRIVER_OBJECT *driver;
+    void *id_addr;
+};
+
 #ifdef __i386__
 #define mem_mask 0xffff
 #define mem_size 0x10000
@@ -400,9 +410,28 @@ NTSTATUS WINAPI IoAllocateDriverObjectExtension( PDRIVER_OBJECT DriverObject,
                                                  ULONG DriverObjectExtensionSize,
                                                  PVOID *DriverObjectExtension )
 {
-    FIXME( "stub: %p, %p, %u, %p\n", DriverObject, ClientIdentificationAddress,
+    struct DriverObjExtension *ext;
+
+    TRACE( "%p, %p, %u, %p\n", DriverObject, ClientIdentificationAddress,
             DriverObjectExtensionSize, DriverObjectExtension );
-    return STATUS_NOT_IMPLEMENTED;
+
+    *DriverObjectExtension = NULL;
+    if (IoGetDriverObjectExtension( DriverObject, ClientIdentificationAddress ))
+        return STATUS_OBJECT_NAME_COLLISION;
+    ext = ExAllocatePool( NonPagedPool, sizeof(*ext) );
+    if (ext == NULL)
+        return STATUS_INSUFFICIENT_RESOURCES;
+    ext->ptr = ExAllocatePool( NonPagedPool, DriverObjectExtensionSize );
+    if (ext->ptr == NULL)
+    {
+        ExFreePool( ext );
+        return STATUS_INSUFFICIENT_RESOURCES;
+    }
+    ext->driver = DriverObject;
+    ext->id_addr = ClientIdentificationAddress;
+    list_add_tail( &DriverObjExtensions, &ext->entry );
+    *DriverObjectExtension = ext->ptr;
+    return STATUS_SUCCESS;
 }
 
 /***********************************************************************
@@ -411,7 +440,16 @@ NTSTATUS WINAPI IoAllocateDriverObjectExtension( PDRIVER_OBJECT DriverObject,
 PVOID WINAPI IoGetDriverObjectExtension( PDRIVER_OBJECT DriverObject,
                                          PVOID ClientIdentificationAddress )
 {
-    FIXME( "stub: %p, %p\n", DriverObject, ClientIdentificationAddress );
+    struct DriverObjExtension *ext;
+
+    TRACE( "%p, %p\n", DriverObject, ClientIdentificationAddress );
+
+    LIST_FOR_EACH_ENTRY( ext, &DriverObjExtensions, struct DriverObjExtension, entry )
+    {
+        if (DriverObject == ext->driver &&
+            ClientIdentificationAddress == ext->id_addr)
+            return ext->ptr;
+    }
     return NULL;
 }
 
@@ -1803,6 +1841,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
 {
     LARGE_INTEGER count;
     static PVOID vectored_handler_added;
+    struct DriverObjExtension *ext, *ext2;
 
     switch(reason)
     {
@@ -1813,6 +1852,13 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
         break;
     case DLL_PROCESS_DETACH:
         RtlRemoveVectoredExceptionHandler(vectored_handler_added);
+        LIST_FOR_EACH_ENTRY_SAFE( ext, ext2, &DriverObjExtensions,
+                struct DriverObjExtension, entry )
+        {
+            list_remove( &ext->entry );
+            ExFreePool( ext->ptr );
+            ExFreePool( ext );
+        }
     }
     return TRUE;
 }
-- 
1.6.0.2.GIT



Подробная информация о списке рассылки Wine-patches