[PATCH 2/2] mscoree: add stub for CorGetSvc to hint user at broken .Net installation, and show some tips to correct this.

Louis Lenders xerox.xerox2000x at gmail.com
Mon Jul 9 15:48:57 CDT 2018


See bug https://www.winehq.org/pipermail/wine-bugs/2018-July/494631.html.
This patch shows users some hints to fix broken .Net installation, instead of crashing and leaving user in the dark

Signed-off-by: Louis Lenders <xerox.xerox2000x at gmail.com>
---
 dlls/mscoree/mscoree.spec    |  2 +-
 dlls/mscoree/mscoree_main.c  | 22 ++++++++++++++++++++++
 dlls/mscoree/tests/mscoree.c | 10 +++++++++-
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/dlls/mscoree/mscoree.spec b/dlls/mscoree/mscoree.spec
index ec4668bc3c..7fa68bf8b1 100644
--- a/dlls/mscoree/mscoree.spec
+++ b/dlls/mscoree/mscoree.spec
@@ -24,7 +24,7 @@
 @ stdcall CorBindToRuntimeHost(wstr wstr wstr ptr long ptr ptr ptr)
 @ stub CorDllMainWorker
 @ stdcall CorExitProcess(long)
-@ stub CorGetSvc
+@ stdcall CorGetSvc(ptr)
 @ stdcall CorIsLatestSvc(ptr ptr)
 @ stub CorMarkThreadInThreadPool
 @ stub CorTickleSvc
diff --git a/dlls/mscoree/mscoree_main.c b/dlls/mscoree/mscoree_main.c
index 519f918223..29fe23bf7c 100644
--- a/dlls/mscoree/mscoree_main.c
+++ b/dlls/mscoree/mscoree_main.c
@@ -315,6 +315,28 @@ HRESULT WINAPI CorIsLatestSvc(int *unk1, int *unk2)
     return S_OK;
 }
 
+HRESULT WINAPI CorGetSvc(IUnknown **pIUnknown)
+{
+    typedef INT (WINAPI *MessageBoxA)(HWND,LPCSTR,LPCSTR,UINT);
+    HMODULE hUser32 = LoadLibraryA("user32");
+    MessageBoxA pMessageBoxA = (void *)GetProcAddress(hUser32, "MessageBoxA");
+
+    FIXME("%p stub\n",pIUnknown);
+    if (pMessageBoxA)
+    {
+        pMessageBoxA(NULL,
+            "Something is broken in your .Net installation.\n"
+            "Apparently you try to run an app with MS .NET Framework but have Wine-Mono installed. "
+            "Please use 'winetricks' to install .NET Frameworks "
+            "and redo the installation in a new WINEPREFIX.\n",
+            "Wine: Unimplemented CorGetSvc",
+            0x10);
+        ExitProcess(1);
+
+    }
+    return S_OK;
+}
+
 HRESULT WINAPI GetRequestedRuntimeInfo(LPCWSTR pExe, LPCWSTR pwszVersion, LPCWSTR pConfigurationFile,
     DWORD startupFlags, DWORD runtimeInfoFlags, LPWSTR pDirectory, DWORD dwDirectory, DWORD *dwDirectoryLength,
     LPWSTR pVersion, DWORD cchBuffer, DWORD *dwlength)
diff --git a/dlls/mscoree/tests/mscoree.c b/dlls/mscoree/tests/mscoree.c
index b45c814904..d84e0add41 100644
--- a/dlls/mscoree/tests/mscoree.c
+++ b/dlls/mscoree/tests/mscoree.c
@@ -36,6 +36,7 @@ static HMODULE hmscoree;
 
 static HRESULT (WINAPI *pGetCORVersion)(LPWSTR, DWORD, DWORD*);
 static HRESULT (WINAPI *pCorIsLatestSvc)(INT*, INT*);
+static HRESULT (WINAPI *pCorGetSvc)(IUnknown**);
 static HRESULT (WINAPI *pGetCORSystemDirectory)(LPWSTR, DWORD, DWORD*);
 static HRESULT (WINAPI *pGetRequestedRuntimeInfo)(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, DWORD, LPWSTR, DWORD, DWORD*, LPWSTR, DWORD, DWORD*);
 static HRESULT (WINAPI *pLoadLibraryShim)(LPCWSTR, LPCWSTR, LPVOID, HMODULE*);
@@ -57,6 +58,7 @@ static BOOL init_functionpointers(void)
 
     pGetCORVersion = (void *)GetProcAddress(hmscoree, "GetCORVersion");
     pCorIsLatestSvc = (void *)GetProcAddress(hmscoree, "CorIsLatestSvc");
+    pCorGetSvc = (void *)GetProcAddress(hmscoree, "CorGetSvc");
     pGetCORSystemDirectory = (void *)GetProcAddress(hmscoree, "GetCORSystemDirectory");
     pGetRequestedRuntimeInfo = (void *)GetProcAddress(hmscoree, "GetRequestedRuntimeInfo");
     pLoadLibraryShim = (void *)GetProcAddress(hmscoree, "LoadLibraryShim");
@@ -65,7 +67,7 @@ static BOOL init_functionpointers(void)
     pCLRCreateInstance = (void *)GetProcAddress(hmscoree, "CLRCreateInstance");
 
     if (!pGetCORVersion || !pGetCORSystemDirectory || !pGetRequestedRuntimeInfo || !pLoadLibraryShim ||
-        !pCreateInterface || !pCLRCreateInstance || !pCorIsLatestSvc
+        !pCreateInterface || !pCLRCreateInstance || !pCorIsLatestSvc || !pCorGetSvc
         )
     {
         win_skip("functions not available\n");
@@ -178,6 +180,7 @@ static void test_versioninfo(void)
     DWORD size, path_len;
     HRESULT hr;
     int unk1,unk2;
+    IUnknown *pIUnknown;
 
     if (0)  /* crashes on <= w2k3 */
     {
@@ -298,6 +301,11 @@ static void test_versioninfo(void)
 
     hr =  pCorIsLatestSvc(&unk1, &unk2);
     ok(hr == S_OK, "CorIsLatestSvc returned %08x\n", hr);
+
+    pIUnknown = NULL;
+    hr =  pCorGetSvc(&pIUnknown);
+    ok(hr == S_OK, "CorGetSvc returned %08x\n", hr);
+    ok(pIUnknown != NULL, "pIUnknown is unexpectedly NULL\n");
 }
 
 static void test_loadlibraryshim(void)
-- 
2.17.1




More information about the wine-devel mailing list