kernel32: return error code if WOWCallback16Ex of a real-mode function failed (e.g. because we are running a x64 kernel)

Mikolaj Zalewski mikolaj at zalewski.pl
Tue Aug 14 14:19:51 CDT 2007


  With a x64 kernels a switch to VM86 mode will fail because the 
processor doesn't support it. This patch will output an ERR if that 
happens. The error code is invented by me as AFAIK Win64 doesn't ship 
the wow32.dll at all (Wine differs from Windows as it supports Win16 on 
x64 while Windows drops the support for both Win16 and DOS)
  I will try to add some code to write a more readable message to the 
user but I'm still thinking if that should be done in winedos.dll or 
winevdm.exe
-------------- next part --------------
>From 8a3bdf84eed327326909cba7b875fb39a0073970 Mon Sep 17 00:00:00 2001
From: Mikolaj Zalewski <mikolajz at mikolajz.smo.corp.google.com>
Date: Tue, 14 Aug 2007 11:47:56 -0700
Subject: [PATCH] kernel32: return error code if WOWCallback16Ex of a real-mode function failed (e.g. because we are running a x64 kernel)
---
 dlls/kernel32/wowthunk.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/dlls/kernel32/wowthunk.c b/dlls/kernel32/wowthunk.c
index 4f714ab..2ccfddf 100644
--- a/dlls/kernel32/wowthunk.c
+++ b/dlls/kernel32/wowthunk.c
@@ -23,6 +23,7 @@ #include "wine/port.h"
 
 #include <assert.h>
 #include <stdarg.h>
+#include <errno.h>
 
 #include "wine/winbase16.h"
 #include "windef.h"
@@ -587,9 +588,19 @@ #ifdef __i386__
         {
             EXCEPTION_REGISTRATION_RECORD frame;
             frame.Handler = vm86_handler;
+            errno = 0;
             __wine_push_frame( &frame );
             __wine_enter_vm86( context );
             __wine_pop_frame( &frame );
+            if (errno != 0)  /* enter_vm86 will fall with ENOSYS on x64 kernels */
+            {
+                ERR("__wine_enter_vm86 failed (errno=%d)\n", errno);
+                if (errno == ENOSYS)
+                    SetLastError(ERROR_NOT_SUPPORTED);
+                else
+                    SetLastError(ERROR_GEN_FAILURE);
+                return FALSE;
+            }
         }
         else
         {
-- 
1.4.1



More information about the wine-patches mailing list