[Wine-patches] [eterhack 02/24] ntoskrnl.exe: Add hack for hardlock.sys.

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Ср Мар 4 12:25:11 MSK 2009


---
 dlls/ntoskrnl.exe/ntoskrnl.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c
index 688e935..197f4ba 100644
--- a/dlls/ntoskrnl.exe/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/ntoskrnl.c
@@ -330,6 +330,45 @@ static LONG CALLBACK vectored_handler( EXCEPTION_POINTERS *ptrs )
     return EXCEPTION_CONTINUE_SEARCH;
 }
 
+/* HACK for hardlock.sys */
+static void hardlock_hack(void)
+{
+    static const WCHAR ntoskrnlW[] = {'n','t','o','s','k','r','n','l','.','e','x','e',0};
+    static const WCHAR ntdllW[] = {'n','t','d','l','l','.','d','l','l',0};
+    static const WCHAR msvcrtW[] = {'m','s','v','c','r','t','.','d','l','l',0};
+
+    HANDLE ntoskrnl = GetModuleHandleW( ntoskrnlW );
+    HANDLE ntdll = LoadLibraryW( ntdllW );
+    HANDLE msvcrt = LoadLibraryW( msvcrtW );
+    IMAGE_NT_HEADERS *nt;
+    IMAGE_EXPORT_DIRECTORY *exports;
+    DWORD *func_addr, fptr, size, k;
+
+    nt = RtlImageNtHeader( ntoskrnl );
+    exports = RtlImageDirectoryEntryToData( ntoskrnl, TRUE,
+            IMAGE_DIRECTORY_ENTRY_EXPORT, &size );
+    func_addr = (DWORD *)((char *)ntoskrnl + exports->AddressOfFunctions);
+    for (k = 0; k < exports->NumberOfFunctions; ++k)
+    {
+        if (func_addr[k] + (DWORD)ntoskrnl > (DWORD)exports &&
+            func_addr[k] + (DWORD)ntoskrnl < (DWORD)exports + size)
+        {
+            if (!strncasecmp( (char *)ntoskrnl + func_addr[k], "ntdll.", 6 ))
+            {
+                fptr = (DWORD)GetProcAddress( ntdll,
+                        (char *)ntoskrnl + func_addr[k] + 6 );
+                func_addr[k] = fptr - (DWORD)ntoskrnl;
+            }
+            else if (!strncasecmp( (char *)ntoskrnl + func_addr[k], "msvcrt.", 7 ))
+            {
+                fptr = (DWORD)GetProcAddress( msvcrt,
+                        (char *)ntoskrnl + func_addr[k] + 7 );
+                func_addr[k] = fptr - (DWORD)ntoskrnl;
+            }
+        }
+    }
+}
+
 /* get id of the process whose request is being handled */
 static DWORD get_pid(void)
 {
@@ -2361,6 +2400,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
     switch(reason)
     {
     case DLL_PROCESS_ATTACH:
+        hardlock_hack();
         DisableThreadLibraryCalls( inst );
         handler = RtlAddVectoredExceptionHandler( TRUE, vectored_handler );
         KeQueryTickCount( &count );  /* initialize the global KeTickCount */
-- 
1.6.1.3.GIT



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