PATCH: kernel stuff / resubmit again

Marcus Meissner marcus at jet.franken.de
Sun Feb 15 16:12:41 CST 2004


Hi,

Resubmit of the dr7 stuff again. Oh, and one additional small piece 
to actually enable to first working kernel driver.

Ciao, Marcus

Changelog:
	Bad hack to register secdrv.sys as first working driver.
	Emulate privileged instructions in 32bit mode again.
	Emulate mov dr7,eax by returning the default reset mode
	state 0x400.

Index: dlls/kernel/device.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/device.c,v
retrieving revision 1.8
diff -u -r1.8 device.c
--- dlls/kernel/device.c	15 Jan 2004 00:25:41 -0000	1.8
+++ dlls/kernel/device.c	15 Feb 2004 22:09:37 -0000
@@ -288,6 +287,17 @@
         if (!strncasecmp( info->name, filename, strlen(info->name) ))
             return FILE_CreateDevice( info->id | 0x10000, access, sa );
 
+    if (!strncasecmp( "Secdrv", filename, 6)) {
+	static int secdrvloaded = 0;
+	UNICODE_STRING ustr;
+
+	if (!secdrvloaded) {
+	    secdrvloaded = 1;
+	    RtlCreateUnicodeStringFromAsciiz(&ustr,"secdrv.sys");
+	    NtLoadDriver(&ustr);
+	}
+        return FILE_CreateDevice( 0x4243 | 0x10000, access, sa );
+    }
     FIXME( "Unknown/unsupported VxD %s. Try setting Windows version to 'nt40' or 'win31'.\n",
            filename);
 
Index: dlls/kernel/except.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/except.c,v
retrieving revision 1.3
diff -u -r1.3 except.c
--- dlls/kernel/except.c	28 Jan 2004 21:40:01 -0000	1.3
+++ dlls/kernel/except.c	15 Feb 2004 22:09:38 -0000
@@ -446,6 +446,8 @@
             TerminateProcess( GetCurrentProcess(), 1 );
         }
 
+        if (INSTR_EmulateInstruction( epointers->ExceptionRecord, epointers->ContextRecord) == ExceptionContinueExecution)
+		return EXCEPTION_CONTINUE_EXECUTION;
         if (top_filter)
         {
             DWORD ret = top_filter( epointers );
Index: dlls/kernel/instr.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/instr.c,v
retrieving revision 1.11
diff -u -r1.11 instr.c
--- dlls/kernel/instr.c	27 Nov 2003 00:59:36 -0000	1.11
+++ dlls/kernel/instr.c	15 Feb 2004 22:09:38 -0000
@@ -559,6 +559,20 @@
 		}
 		/* fallthrough to illegal instruction */
 		break;
+	    case 0x21: /* mov drX, eax */
+                switch (instr[2])
+                {
+		case 0xf8: /* mov dr7, eax */
+                    TRACE("mov dr7,eax at 0x%08lx\n",context->Eip);
+                    context->Eax = 0x400;
+                    context->Eip += prefixlen+3;
+		    return ExceptionContinueExecution;
+		default: /* fallthrough to illegal instruction */
+		    ERR("Unknown DR register, eip+2 is %02x\n", instr[2]);
+		    break;
+		}
+		/* fallthrough to illegal instruction */
+		break;
             case 0xa1: /* pop fs */
                 {
                     WORD seg = *(WORD *)get_stack( context );
Index: dlls/kernel/kernel_private.h
===================================================================
RCS file: /home/wine/wine/dlls/kernel/kernel_private.h,v
retrieving revision 1.11
diff -u -r1.11 kernel_private.h
--- dlls/kernel/kernel_private.h	12 Feb 2004 00:00:55 -0000	1.11
+++ dlls/kernel/kernel_private.h	15 Feb 2004 22:09:38 -0000
@@ -58,6 +58,7 @@
 
 extern DWORD INSTR_EmulateInstruction( EXCEPTION_RECORD *rec, CONTEXT86 *context );
 extern void INSTR_CallBuiltinHandler( CONTEXT86 *context, BYTE intnum );
+extern DWORD INSTR_EmulateInstruction( EXCEPTION_RECORD *rec, CONTEXT86 *context );
 
 extern BOOL NLS_IsUnicodeOnlyLcid(LCID);
 
Index: include/winternl.h
===================================================================
RCS file: /home/wine/wine/include/winternl.h,v
retrieving revision 1.67
diff -u -r1.67 winternl.h
--- include/winternl.h	7 Feb 2004 01:11:54 -0000	1.67
+++ include/winternl.h	15 Feb 2004 22:12:04 -0000
@@ -1437,6 +1437,8 @@
 NTSTATUS WINAPI LdrUnloadDll(HMODULE);
 NTSTATUS WINAPI LdrUnlockLoaderLock(ULONG,ULONG);
 
+NTSTATUS WINAPI NtLoadDriver(const UNICODE_STRING*);
+
 /* list manipulation macros */
 #define InitializeListHead(le)  (void)((le)->Flink = (le)->Blink = (le))
 #define InsertHeadList(le,e)    do { PLIST_ENTRY f = (le)->Flink; (e)->Flink = f; (e)->Blink = (le); f->Blink = (e); (le)->Flink = (e); } while (0)



More information about the wine-patches mailing list