mscoree: Detect if the current program is a GUI one and pop up a warning about not supporting .NET (4/4)

Paul Chitescu paulc at voip.null.ro
Mon Nov 13 19:41:09 CST 2006


Changelog: mscoree: Detect if the current program is a GUI one and pop up a 
warning about not supporting .NET (4/4)

Requires patches 1-3 applied.
-------------- next part --------------
--- ./dlls/mscoree/mscoree_main.c.orig	2006-11-14 02:19:05.000000000 +0200
+++ ./dlls/mscoree/mscoree_main.c	2006-11-14 02:18:58.000000000 +0200
@@ -29,10 +29,13 @@
 #include "winbase.h"
 #include "winreg.h"
 #include "winuser.h"
+#include "winternl.h"
 #include "ole2.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
 
+static const char warningMsg[] = {"Directly running .NET applications not supported."};
+
 static const WCHAR defaultCORversion[] = {'v','1','.','1','.','4','3','2','2',0};
 /*
   .NET 1.0: v1.0.3705
@@ -45,6 +48,13 @@
 static WCHAR currentCORversion[BUFFER_MAX];
 static int isCORinitialized = 0;
 
+/* check if the current process runs in a GUI subsystem */
+static BOOL isGUIapplication(void)
+{
+    HMODULE mod = GetModuleHandleA(0);
+    return RtlImageNtHeader(mod)->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI;
+}
+
 /* this helper is needed very often */
 static HRESULT copyToWBuffer(LPCWSTR str, LPWSTR pBuf, DWORD cchBuf, LPDWORD pBufLen)
 {
@@ -139,14 +149,20 @@
 
 int WINAPI _CorExeMain(void)
 {
-    FIXME("Directly running .NET applications not supported.\n");
+    FIXME("%s\n", warningMsg);
+    if (isGUIapplication()) {
+	MessageBoxA(0, warningMsg, NULL, MB_OK | MB_ICONSTOP);
+    }
     return -1;
 }
 
 int WINAPI _CorExeMain2(PBYTE ptrMemory, DWORD cntMemory, LPCWSTR imageName, LPCWSTR loaderName, LPCWSTR cmdLine)
 {
     TRACE("(%p, %u, %s, %s, %s)\n", ptrMemory, cntMemory, debugstr_w(imageName), debugstr_w(loaderName), debugstr_w(cmdLine));
-    FIXME("Directly running .NET applications not supported.\n");
+    FIXME("%s\n", warningMsg);
+    if (isGUIapplication()) {
+	MessageBoxA(0, warningMsg, NULL, MB_OK | MB_ICONSTOP);
+    }
     return -1;
 }
 
--- ./dlls/mscoree/Makefile.in.orig	2006-11-13 22:22:23.000000000 +0200
+++ ./dlls/mscoree/Makefile.in	2006-11-10 14:36:55.000000000 +0200
@@ -3,7 +3,7 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = mscoree.dll
-IMPORTS   = kernel32 advapi32
+IMPORTS   = kernel32 ntdll user32 advapi32
 
 C_SRCS = \
 	mscoree_main.c


More information about the wine-patches mailing list