[Wine-patches] [20/23] ntoskrnl.exe: Partially implement IoGetDeviceProperty.

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


For eterhack branch
----------- следующая часть -----------
From b9c992d5dacdecf7a31e1c3e29e18adfb2c3881c Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Mon, 19 Jan 2009 15:30:12 +0300
Subject: [PATCH] ntoskrnl.exe: Partially implement IoGetDeviceProperty.

---
 dlls/ntoskrnl.exe/ntoskrnl.c |   39 +++++++++++++++++++++++++++++++++++++--
 server/device.c              |   23 +++++++++++++++++++++++
 server/protocol.def          |    8 ++++++++
 3 files changed, 68 insertions(+), 2 deletions(-)

diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 2b4e091..4e194d7 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -1375,9 +1375,44 @@ NTSTATUS WINAPI IoGetDeviceProperty( PDEVICE_OBJECT DeviceObject,
                                      ULONG BufferLength, PVOID PropertyBuffer,
                                      PULONG ResultLength )
 {
-    FIXME( "stub: %p %u %u %p %p\n", DeviceObject, DeviceProperty, BufferLength,
+    NTSTATUS status;
+
+    TRACE( "%p %u %u %p %p\n", DeviceObject, DeviceProperty, BufferLength,
            PropertyBuffer, ResultLength );
-    return STATUS_NOT_IMPLEMENTED;
+
+    switch (DeviceProperty)
+    {
+    case DevicePropertyPhysicalDeviceObjectName:
+    {
+        static const WCHAR device[] = {'\\','D','e','v','i','c','e','\\',0};
+        WCHAR device_name[MAX_PATH];
+        data_size_t len;
+
+        SERVER_START_REQ( get_device_name )
+        {
+            req->handle = wine_server_obj_handle( DeviceObject->Reserved );
+            wine_server_set_reply( req, device_name,
+                    sizeof(device_name) - sizeof(WCHAR) );
+            status = wine_server_call( req );
+            len = wine_server_reply_size( reply );
+        }
+        SERVER_END_REQ;
+
+        *ResultLength = len + sizeof(device);
+        if (BufferLength >= *ResultLength)
+        {
+            strcpyW( PropertyBuffer, device );
+            device_name[len / sizeof(WCHAR)] = 0;
+            strcatW( PropertyBuffer, device_name );
+        }
+        break;
+    }
+    default:
+        FIXME( "device property %u is not supported\n", DeviceProperty );
+        status = STATUS_NOT_IMPLEMENTED;
+    }
+
+    return status;
 }
 
 
diff --git a/server/device.c b/server/device.c
index efeb0ee..a43c9b6 100644
--- a/server/device.c
+++ b/server/device.c
@@ -556,3 +556,26 @@ DECL_HANDLER(get_ioctl_result)
     }
     release_object( device );
 }
+
+
+/* get a device name */
+DECL_HANDLER(get_device_name)
+{
+    struct device *device;
+    const WCHAR *device_name;
+    data_size_t device_name_len;
+
+    if (!(device = (struct device *)get_handle_obj( current->process, req->handle, 0, &device_ops )))
+        return;
+
+    if (device_name = get_object_name( &device->obj, &device_name_len ))
+    {
+        if (device_name_len <= get_reply_max_size())
+            set_reply_data( device_name, device_name_len );
+        else
+            set_error( STATUS_BUFFER_TOO_SMALL );
+    }
+    else set_error( STATUS_INVALID_DEVICE_REQUEST );
+
+    release_object( device );
+}
diff --git a/server/protocol.def b/server/protocol.def
index 5a6e47f..7f907f4 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -3116,3 +3116,11 @@ enum message_type
     unsigned int   alpha;         /* alpha (0..255) */
     unsigned int   flags;         /* LWA_* flags */
 @END
+
+
+/* Get a device name */
+ на REQ(get_device_name)
+    obj_handle_t handle;          /* device handle */
+ на REPLY
+    VARARG(name,unicode_str);     /* device name */
+ на END
-- 
1.6.0.2.GIT



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