[Wine-patches] [eterhack] [TRY 2] ntoskrnl.exe: Fix hack for Katran key driver (eterbug #3834).

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Чт Май 28 16:55:34 MSD 2009


----------- следующая часть -----------
From 84b2946ac64c62a5e5b6272768bd3297b4d8953d Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Thu, 28 May 2009 16:24:36 +0400
Subject: [eterhack] ntoskrnl.exe: Fix hack for Katran key driver (eterbug #3834).

---
 dlls/ntoskrnl.exe/ntoskrnl.c |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 16cfb28..9a32172 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -522,14 +522,33 @@ static NTSTATUS process_ioctl( DEVICE_OBJECT *device, ULONG code, void *in_buff,
 
     TRACE( "ioctl %x device %p in_size %u out_size %u\n", code, device, in_size, *out_size );
 
+    /* HACK for UPKey.sys */
+    if (0x3fc == code) offset = 2;
+    if (0x222044 == code || 0x44c == code || 0x456 == code) offset = 8;
+    if (offset && in_buff)
+    {
+        saved_ptr = *(void**)((char *)in_buff + offset);
+        if (saved_ptr)
+        {
+            *(void**)((char *)in_buff + offset) = &data;
+            process = OpenProcess( PROCESS_ALL_ACCESS, FALSE, get_pid() );
+            if (process != NULL)
+                NtReadVirtualMemory( process, saved_ptr, data, sizeof(data), NULL );
+        }
+    }
+
     file = ExAllocatePool( NonPagedPool, sizeof(*file) );
     if (file == NULL)
+    {
+        if (process) CloseHandle( process );
         return STATUS_NO_MEMORY;
+    }
     irp = IoBuildDeviceIoControlRequest( code, device, in_buff, in_size,
             out_buff, *out_size, FALSE, NULL, &iosb );
     if (irp == NULL)
     {
         ExFreePool( file );
+        if (process) CloseHandle( process );
         return STATUS_NO_MEMORY;
     }
     irpsp = irp->Tail.Overlay.s.u.CurrentStackLocation - 1;
@@ -541,21 +560,6 @@ static NTSTATUS process_ioctl( DEVICE_OBJECT *device, ULONG code, void *in_buff,
     file->Size = sizeof(*file);
     file->DeviceObject = device;
 
-    /* HACK for UPKey.sys */
-    if (0x3fc == code) offset = 2;
-    if (0x222044 == code || 0x44c == code || 0x456 == code) offset = 8;
-    if (offset && in_buff)
-    {
-        saved_ptr = *(void**)((char *)in_buff + offset);
-        if (saved_ptr)
-        {
-            *(void**)((char *)in_buff + offset) = &data;
-            process = OpenProcess( PROCESS_ALL_ACCESS, FALSE, get_pid() );
-            if (process != NULL)
-                NtReadVirtualMemory( process, saved_ptr, data, sizeof(data), NULL );
-        }
-    }
-
     KeQueryTickCount( &count );  /* update the global KeTickCount */
     status = IoCallDriver( device, irp );
     if (process)
-- 
1.6.3.1



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