mscoree: Load settings (for now only reported version) from
Registry on initialization (2/4)
Paul Chitescu
paulc at voip.null.ro
Mon Nov 13 19:41:28 CST 2006
Changelog: mscoree: Load settings (for now only reported version) from
Registry on initialization (2/4)
Requires patch 1 applied.
-------------- next part --------------
--- ./dlls/mscoree/mscoree_main.c.orig 2006-11-13 23:01:55.000000000 +0200
+++ ./dlls/mscoree/mscoree_main.c 2006-11-14 02:19:11.000000000 +0200
@@ -22,10 +22,12 @@
#include "config.h"
#include "wine/port.h"
#include "wine/library.h"
+#include "wine/unicode.h"
#include "wine/debug.h"
#include "windef.h"
#include "winbase.h"
+#include "winreg.h"
#include "winuser.h"
#include "ole2.h"
@@ -38,6 +40,11 @@
.NET 2.0: v2.0.50727
*/
+#define BUFFER_MAX 256
+
+static WCHAR currentCORversion[BUFFER_MAX];
+static int isCORinitialized = 0;
+
/* this helper is needed very often */
static HRESULT copyToWBuffer(LPCWSTR str, LPWSTR pBuf, DWORD cchBuf, LPDWORD pBufLen)
{
@@ -53,6 +60,39 @@
return S_OK;
}
+/* actual one-time initialization, pick settings from Registry */
+static void loadWineVariables(void)
+{
+ HKEY key = 0;
+ /* @@ Wine registry key: HKCU\Software\Wine\CLR */
+ if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Wine\\CLR", 0, KEY_READ, &key) == ERROR_SUCCESS) {
+ char buffer[BUFFER_MAX];
+ DWORD type = 0;
+ DWORD length = sizeof(buffer);
+ if (RegQueryValueExA(key, "RuntimeVersion", 0, &type, (LPBYTE)buffer, &length) == ERROR_SUCCESS)
+ wine_utf8_mbstowcs(0, buffer, length, currentCORversion, BUFFER_MAX);
+ else
+ lstrcpyW(currentCORversion,defaultCORversion);
+ RegCloseKey(key);
+ }
+ else {
+ lstrcpyW(currentCORversion,defaultCORversion);
+ }
+}
+
+/* helper that makes sure one-time initialization was performed */
+static BOOL initCORemulation(void)
+{
+ if (!isCORinitialized) {
+ isCORinitialized = -1;
+ TRACE("\n");
+ loadWineVariables();
+ if (currentCORversion[0])
+ isCORinitialized = 1;
+ }
+ return (isCORinitialized > 0);
+}
+
HRESULT WINAPI CorBindToRuntimeHost(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor,
LPCWSTR pwszHostConfigFile, VOID *pReserved,
DWORD startupFlags, REFCLSID rclsid,
@@ -124,11 +164,15 @@
HRESULT WINAPI GetCORVersion(LPWSTR pBuffer, DWORD cchBuffer, DWORD *dwLength)
{
WARN("(%p, %d, %p): semi-stub\n", pBuffer, cchBuffer, dwLength);
- return copyToWBuffer(defaultCORversion, pBuffer, cchBuffer, dwLength);
+ if (!initCORemulation())
+ return E_FAIL;
+ return copyToWBuffer(currentCORversion, pBuffer, cchBuffer, dwLength);
}
HRESULT WINAPI LoadLibraryShim(LPCWSTR szDllName, LPCWSTR szVersion, LPVOID pvReserved, HMODULE * phModDll)
{
+ if (!initCORemulation())
+ return E_FAIL;
*phModDll = LoadLibraryW(szDllName);
FIXME("(%s, %p, %p, %p): semi-stub\n", debugstr_w(szDllName), szVersion, pvReserved, phModDll);
return S_OK;
@@ -136,8 +180,8 @@
HRESULT WINAPI CoInitializeCor(DWORD fFlags)
{
- FIXME("(0x%08x): stub\n", fFlags);
- return S_OK;
+ WARN("(0x%08x): semi-stub\n", fFlags);
+ return initCORemulation() ? S_OK : E_FAIL;
}
HRESULT WINAPI GetAssemblyMDImport(LPCWSTR szFileName, REFIID riid, IUnknown **ppIUnk)
--- ./dlls/mscoree/Makefile.in.orig 2006-11-13 23:00:49.000000000 +0200
+++ ./dlls/mscoree/Makefile.in 2006-11-13 22:22:23.000000000 +0200
@@ -3,7 +3,7 @@
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = mscoree.dll
-IMPORTS = kernel32
+IMPORTS = kernel32 advapi32
C_SRCS = \
mscoree_main.c
More information about the wine-patches
mailing list