CVS: winex/dlls/kernel iocompport.c, 1.1, 1.2 kernel_main.c, 1.4, 1.5

[email protected] 1 Aug 2007 12:23:36 -0000
Newsgroups gmane.comp.emulators.winex.cvs
Message-ID <[email protected]>
Subject: winex/dlls/kernel iocompport.c,1.1,1.2 kernel_main.c,1.4,1.5Update of /var/lib/cvsd/cvsroot/winex/dlls/kernel
In directory agravaine:/tmp/cvs-serv27656/dlls/kernel

Modified Files:
	iocompport.c kernel_main.c 
Log Message:
Add a registry entry for whether or not to enable CreateIoCompletionPort.



Index: iocompport.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/kernel/iocompport.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- iocompport.c	31 Jul 2007 17:57:51 -0000	1.1
+++ iocompport.c	1 Aug 2007 12:23:34 -0000	1.2
@@ -14,6 +14,7 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(iocomp);
 
+extern int use_io_completion_ports;
 
 /******************************************************************************
  *		CreateIoCompletionPort (KERNEL32.@)
@@ -26,6 +27,12 @@
           hExistingCompletionPort, dwCompletionKey,
           dwNumberOfConcurrentThreads);
 
+   if (!use_io_completion_ports) {
+      WARN("User has disabled IoCompletionPorts - returning NULL\n");
+      SetLastError (ERROR_INVALID_PARAMETER);
+      return (HANDLE)NULL;
+   }
+
    /* If given a completion port, must also be given a file handle with
       which we are to associate it */
    if ((hExistingCompletionPort != (HANDLE)NULL) &&

Index: kernel_main.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/kernel/kernel_main.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- kernel_main.c	27 Mar 2007 17:24:24 -0000	1.4
+++ kernel_main.c	1 Aug 2007 12:23:34 -0000	1.5
@@ -16,6 +16,10 @@
 #include "module.h"
 #include "task.h"
 #include "wine/hardware.h"
+#include "wine/debug.h"
+#include "winreg.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(iocomp);
 
 extern void CODEPAGE_Init(void);
 extern BOOL RELAY_Init(void);
@@ -24,6 +28,69 @@
 extern void create_profile_cs(void);
 extern void create_file_cs(void);
 
+/* Some apps expect our IoCompletion support to be complete if a call to
+ * CreateIoCompletionPort() returns successfully, even though it's currently
+ * lacking.  So, until we get around to finishing the implementation, we
+ * will make this a config option
+ */
+int use_io_completion_ports = 1;    /* Defaults to true */
+
+#define IS_OPTION_TRUE(ch) \
+    ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
+
+/***********************************************************************
+ * get_config_key
+ *
+ * Get a config key from either the app-specific or the default config
+ */
+inline static DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name,
+                                    char *buffer, DWORD size )
+{
+    if (appkey && !RegQueryValueExA( appkey, name, 0, NULL, (LPBYTE)buffer, &size )) return 0;
+    return RegQueryValueExA( defkey, name, 0, NULL, (LPBYTE)buffer, &size );
+}
+
+/***********************************************************************
+ * setup_options
+ *
+ * setup kernel specific options
+ */
+static void setup_options(void)
+{
+    char buffer[MAX_PATH+16];
+    HKEY hkey, appkey = 0;
+
+    if (RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\kernel", 0, NULL,
+                       REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL )) {
+        ERR("Cannot create config registry key\n");
+        return;
+    }
+
+    /* open the app-specific key */
+    if (GetModuleFileName16( GetCurrentTask(), buffer, MAX_PATH ) ||
+        GetModuleFileNameA( 0, buffer, MAX_PATH ))
+    {
+        HKEY tmpkey;
+        char *p, *appname = buffer;
+        if ((p = strrchr( appname, '/' ))) appname = p + 1;
+        if ((p = strrchr( appname, '\\' ))) appname = p + 1;
+
+        strcat( appname, "\\kernel" );
+        if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\AppDefaults", &tmpkey ))
+        {
+            if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0;
+            RegCloseKey( tmpkey );
+        }
+    }
+
+    if (!get_config_key( hkey, appkey, "UseIoCompletionPorts", buffer, sizeof(buffer) ))
+        use_io_completion_ports = IS_OPTION_TRUE( buffer[0] );
+    TRACE("UseIoCompletionPorts=(%d)\n", use_io_completion_ports);
+
+    if (appkey) RegCloseKey( appkey );
+    RegCloseKey( hkey );
+}
+
 /***********************************************************************
  *           KERNEL process initialisation routine
  */
@@ -93,6 +160,9 @@
     /* Create the shared heap for broken win95 native dlls */
     HeapCreate( HEAP_SHARED, 0, 0 );
 
+    /* Load any runtime registry configuration options the user may have set */
+    setup_options();
+
     return TRUE;
 }