[Wine-patches] [eter-1.0.12] ntoskrnl.exe: Use etersoft_ioctl_* functions.

Alexander Morozov amorozov на etersoft.ru
Чт Мар 31 20:31:13 MSD 2011


----------- следующая часть -----------
From 44e64e7961e8d8cec770a03a2e68ba549e25fe8d Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Thu, 31 Mar 2011 16:04:19 +0400
Subject: [eter-1.0.12] ntoskrnl.exe: Use etersoft_ioctl_* functions.

---
 dlls/ntoskrnl.exe/ntoskrnl.c |   46 ++++++++---------------------------------
 include/wine/etersoft.h      |    7 ++++++
 2 files changed, 16 insertions(+), 37 deletions(-)

diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 03247cd..29188c7 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -45,6 +45,8 @@
 #include "wine/server.h"
 #include "wine/list.h"
 #include "wine/debug.h"
+#define ETERSOFT_IOCTL
+#include "wine/etersoft.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(ntoskrnl);
 WINE_DECLARE_DEBUG_CHANNEL(relay);
@@ -146,8 +148,6 @@ struct HandleInstance
 #define IOCTL_WINE_DRIVER_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x101, \
         METHOD_BUFFERED, FILE_ANY_ACCESS)
 
-#define UPKEY_NKEY_DATA_SIZE 65535
-
 #ifdef __i386__
 #define DEFINE_FASTCALL1_ENTRYPOINT( name ) \
     __ASM_GLOBAL_FUNC( name, \
@@ -529,38 +529,13 @@ static NTSTATUS process_ioctl( DEVICE_OBJECT *device, ULONG code, void *in_buff,
     HANDLE process = NULL;
     CHAR *data = NULL;
     void *saved_ptr = NULL;
-    ULONG offset = 0, offset2 = 0;
 
     TRACE( "ioctl %x device %p in_size %u out_size %u\n", code, device, in_size, *out_size );
 
-    /* HACK for UPKey.sys and NKey.sys */
-    if (0x3fc == code) offset = 2;
-    else if (0x222040 == code || 0x222044 == code || 0x222048 == code ||
-             0x22204c == code || 0x222050 == code || 0x222060 == code ||
-             0x222080 == code || 0x2220c0 == code || 0x222100 == code ||
-             0x222104 == code || 0x222108 == code || 0x222110 == code ||
-             0x222118 == code || 0x222120 == code ||
-             0x3e8 == code || 0x3e9 == code || 0x44c == code || 0x456 == code)
-        offset = 8;
-    else if (0x2220d8 == code)
-    {
-        offset = 14;
-        offset2 = 8;
-    }
-    if (offset && in_buff)
-    {
-        data = HeapAlloc( GetProcessHeap(), 0, UPKEY_NKEY_DATA_SIZE );
-        if (data == NULL) return STATUS_NO_MEMORY;
-        saved_ptr = *(void**)((char *)in_buff + offset);
-        *(void**)((char *)in_buff + offset) = data;
-        if (offset2)
-            *(void**)((char *)in_buff + offset2) = data +
-                    (*(char**)((char *)in_buff + offset2) - (char *)saved_ptr);
-        process = OpenProcess( PROCESS_ALL_ACCESS, FALSE, get_pid() );
-        if (process != NULL)
-            NtReadVirtualMemory( process, saved_ptr, data, UPKEY_NKEY_DATA_SIZE, NULL );
-    }
-
+    LOADETER_FUNC( etersoft_ioctl_pre );
+    if (etersoft_ioctl_pre && etersoft_ioctl_pre( code, in_buff, get_pid(),
+            &saved_ptr, &data, &process ))
+        return STATUS_UNSUCCESSFUL;
     file = ExAllocatePool( NonPagedPool, sizeof(*file) );
     if (file == NULL)
     {
@@ -587,12 +562,9 @@ static NTSTATUS process_ioctl( DEVICE_OBJECT *device, ULONG code, void *in_buff,
     KeQueryTickCount( &count );  /* update the global KeTickCount */
     status = IoCallDriver( device, irp );
 end:
-    if (process)
-    {
-        NtWriteVirtualMemory( process, saved_ptr, data, UPKEY_NKEY_DATA_SIZE, NULL );
-        CloseHandle( process );
-    }
-    if (data) HeapFree( GetProcessHeap(), 0, data );
+    LOADETER_FUNC( etersoft_ioctl_post );
+    if (etersoft_ioctl_post)
+        etersoft_ioctl_post( process, saved_ptr, data );
     *out_size = (status >= 0) ? iosb.Information : 0;
     return status;
 }
diff --git a/include/wine/etersoft.h b/include/wine/etersoft.h
index 7b6f051..706a6b4 100644
--- a/include/wine/etersoft.h
+++ b/include/wine/etersoft.h
@@ -193,4 +193,11 @@ static int (*etersoft_garant_fix)(void **handle);
 static int (*etersoft_get_dll_handle)(const void *wname, void **handle);
 #endif
 
+#ifdef ETERSOFT_IOCTL
+static int (*etersoft_ioctl_pre)(unsigned long code, void *in_buff,
+        unsigned int pid, void **saved_ptr, char **data, void **process);
+
+static void (*etersoft_ioctl_post)(void *process, void *saved_ptr, char *data);
+#endif
+
 #endif
-- 
1.7.4.2



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