Release 980601

Sun May 31 13:40:13 1998  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [if1632/signal.c]
	Added display of exception name.

	* [loader/task.c]
	Yet another attempt at fixing SwitchStackTo/SwitchStackBack.

	* [memory/selector.c] [relay32/builtin32.c] [tools/build.c]
	  [win32/kernel32.c]
	Generate an assembly stub for Win32 register functions to make
	their names available at link time.

	* [programs/*/Makefile.in]
	Added hacks to support old resource compiler.

Fri May 29 16:27:14 1998  Marcus Meissner <marcus@jet.franken.de>

	* [tools/testrun]
	Merge of my testscripts at home into one single perl program
	(tested with perl5). Works only on Linux due to 'ps' and 'ipcs'
	magic.

	* [controls/menu.c]
	Added some DefaultMenuItem stubs.

	* [debugger/stabs.c]
	Fixed stabs loading, now supports (int,int) typeinfo format used
	by gcc-2.8 and egcs-1. If it still crashes, please mail me.

	* [if1632/][relay32/]
	Added msvideo.dll (stubs only)
	Replaced some ptr by str for stringcases
	Added some new stubs (VxDCall, FindCloseNotif....)

	* [misc/network.c]
	Some argument fixes.

	* [misc/registry.c][misc/cpu.c]
	Registry initialization partially rewritten and enhanced.

	* [scheduler/*.c]
	Some additions so we don't do kill(0,SIGUSR1) (kill processgroup
	instead of targeted thread)
	Added SetThreadContext.

Thu May 28 23:59:59 1998  Bertho Stultiens <bertho@akhphd.au.dk>

	* [tools/wrc/*]
	New resource compiler version 1.0.0 (28-May-1998)

	* [Make.rules.in] [Makefile.in]
	Changed and added rc rules to point to tools/wrc/wrc.

	* [configure.in] [include/config.h.in]
	Added check for function 'stricmp'.

	* [include/resource.h]
	Commented out the old resource structure to catch references.
	It also includes wrc_rsc.h.

	* [include/wrc_rsc.h]
	New file. Definitions for the resources generated with wrc.

	* [include/windows.h]
	Added #ifdef RC_INVOKED to exclude stdarg.h.
	Added SS_NOTIFY flag.

	* [include/winnls.h]
	Added SUBLANG_* definitions and corrected some defaults.

	* [loader/libres.c]
	Changed the sysres load functions to support wrc generated
	resources.

	* [resource/sysres_*.rc]
	Added #include <windows.h>

	* [resource/sysres.c]
	Changed declarations to match wrc's output

	* [resource/Makefile.in]
	Changed rules to work with wrc.

	* [tools/makedep.c]
	Changed generation of .rc file dependencies to .s target.

Thu May 28 22:28:39 1998  Eric Kohl <ekohl@abo.rhein-zeitung.de>

	* [files/file.c][include/windows.c][relay32/kernel32.spec]
	Implemented GetFileAttributesEx32A/W.

	* [misc/imagelist.h][include/commctrl.h][relay32/comctl32.spec]
	Added ImageList_Read and ImageList_Write stubs.
	Added ImageList_AddIcon function.
	Added ImageList_LoadImage. It is the same as ImageList_LoadImage32A.

	* [controls/header.c]
	Fixed bitmap drawing bug.
	Added full bitmap support.

	* [include/commctrl.h]
	Added missing header macros.

	* [controls/toolbar.c][include/toolbar.h][include/commctrl.h]
	  [controls/commctrl.c] [relay32/comctl32.spec]
	First implementation of toolbar control.
	Implemented CreateToolbar, CreateToolbarEx and CreateMappedBitmap.

	* [controls/progress.c][controls/status.c]
	Some code cleanup.

	* [controls/commctrl.c][include/commctrl.h][relay32/comctl32.spec]
	Removed CreateStatusWindow16 and DrawStatusText16.
	CreateStatusWindow is the same as CreateStatusWindow32A.
	DrawStatusText is the same as DrawStatusText32A.

Thu May 28 16:01:28 1998  Matthew J. Francis  <asbel@dial.pipex.com>

	* [objects/bitmap.c] [objects/bitmap.h] [objects/oembitmap.c]
	  [objects/dc.c] [graphics/x11drv/bitblt.c]
	Added partial implementation of CreateDIBSection, with great thanks
	to Ulrich Weigand <weigand@informatik.uni-erlangen.de> for
	contributing the bulk of the patch.

Wed May 27 19:04:31 1998  Ulrich Weigand <weigand@informatik.uni-erlangen.de>

	* [win32/kernel32.c] [if1632/thunk.c] [include/flatthunk.h]
	ThunkConnect16 and related functions moved to emulator.

	* [loader/ne/segment.c]
	Call DllEntryPoint with correct arguments.

	* [relay32/builtin32.c]
	Bugfix: Relay debugging did not work for multiple processes.

	* [controls/menu.c]
	Bugfix: dwItemData was not set for MF_OWNERDRAW menus.

	* [if1632/relay.c] [relay32/relay386.c]
	Relay messages converted to use DPRINTF.

	* [controls/desktop.c] [relay32/user32.spec]
	Implemented PaintDesktop.

	* [files/profile.c] [if1632/kernel.spec] [misc/network.c]
	  [misc/printdrv.c] [relay32/winspool.spec] 
	  [win32/ordinals.c] [relay32/kernel32.spec]
	Some stubs added.

	* [relay32/mpr.spec]
	All ordinals were off by one.

Tue May 26 13:32:57 1998  Bill Hawes <whawes@star.net>

	* [misc/lstr.c] [include/casemap.h] [tools/unimap.pl]
	Added Unicode case conversion routines towupper/towlower,
	with mapping tables casemap.h created by tools/unimap.pl.

	* [misc/ntdll.c] [include/winnls.h] [relay32/ntdll.spec]
	  [relay32/advapi.spec]
	Minimal implementation of IsTextUnicode, just enough to get
	NT4 notepad to open ascii/unicode files.

	* [Make.rules.in] [resources/sysres_En.rc]
	Added include file dlgs.h for building resource files, so that
	resources can refer to defined values (e.g. pshHelp).

	* [misc/crtdll.c] [relay32/crtdll.spec]
	Use towupper/towlower for 32W case conversions.

	* [memory/string.c]
	Use towupper for 32W case conversions.

	* [ole/ole2nls.c]
	Use towupper for 32W case conversions; fix mem leak; minor cleanup

	* [controls/edit.c]
	Added soft break flag to edit state. Print unknown action values
	for WM_VSCROLL (action 190 occurs when running NT4 notepad.)

Mon May 25 22:42:40 1998  Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>

	* [files/file.c]
	Care for a pathological case in SetFilePointer.

	* [graphics/x11drv/xfont.c]
	Handle longer Font names in LFD_ComposeLFD and try to catch errors.

	* [loader/pe_image.c]
	Unload Dummymodule when PE_LoadLibraryEx32A fails with
	PE_LoadImage (makes Encarta 98 installer proceed).

	* [misc/registry.c]
	Move a check for a special case in RegCreateKeyEx32W after the
	check for existence.

Tue May 25 20:18:26 1998  Matthew Becker <mbecker@glasscity.net>

	* [misc/ntdll.c]
	Added some stubs, just guessing at the size of their param lists.

	* [misc/registry.c]
	Added stubs for RegUnLoadKey, RegSetKeySecurity, RegSaveKey,
	RegRestoreKey, and RegReplaceKey

	* [programs/regtest/regtest.c]
	Updated registry testing program.

Sun May 24 18:11:40 1998  Alex Priem <alexp@sci.kun.nl>

	* [file/profile.c]
	Added flag 'return_values' to PROFILE_GetSection.

Sun May 24 13:41:10 1998  James Juran <jrj120@psu.edu>

	* [misc/shell.c] [files/directory.c]
	Documentation/debugging info additions.

	* [*/*.c] [include/*.h]
	Moved many extern function definitions to appropriate header files.
	Cleaned up a few compile warnings.
	If #include "debug.h" is present, removed #include <stdio.h>.
	debug.h includes stdio.h, so it is not necessary to include both.

	* [graphics/*.c] [if1632/signal.c] [ipc/*.c] [scheduler/*.c]
	  [win32/*.c] [windows/*.c]
	Final patch to convert fprintf statements to new debugging interface.
	Some fprintfs are still left, especially in the debugger/ directory.
	However, IMHO, it's not worth the effort to change the rest.

Fri May 22 21:58:35 1998  Morten Welinder  <terra@diku.dk>

	* [windows/keyboard.c]
	Correct handling of keys "`-=[]\;',./".

Fri May 22 12:06:00 1998  Per Lindström <pelinstr@algonet.se>

	* [include/windows.h] [relay32/kernel32.spec] [win32/console.c]
	Added stub for ReadConsoleOutputCharacter32A.

Thu May 21 16:45:48 1998  Pascal Cuoq <pcuoq@ens-lyon.fr>

	* [ole/ole2nls.c]
	Began better implementation of LCMapString32A.
	Not very well tested yet, and still need improvements.

	* [controls/scroll.c]
	Documented functions.

Wed May 20 21:37:56 1998  Peter Hunnisett <hunnise@nortel.ca>

	* [include/windows.h][misc/main.c]
	Change SystemParameterInfo to support SPI_GETHIGHCONTRAST. Also
	include some missing SPI_ definitions.

	* [include/dsound.h][multimedia/dsound.c][relay32/dplayx.spec]
	Added stubs for DirectPlayLobbyCreate[AW]. Not sure if these
	should go into a new files dplayx.c? Anyone care?

	* [include/winnls.h]
	Added two missing flags for the CompareString32 functions.
diff --git a/misc/registry.c b/misc/registry.c
index d4569e6..55307e5 100644
--- a/misc/registry.c
+++ b/misc/registry.c
@@ -20,7 +20,6 @@
  */
 
 #include <stdlib.h>
-#include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 #include <ctype.h>
@@ -40,11 +39,7 @@
 #include "xmalloc.h"
 #include "winreg.h"
 
-void SHELL_StartupRegistry();
-
-/* This is not used anywhere */
-#define	DEBUG_W95_LOADREG	0
-
+static void REGISTRY_Init();
 /* FIXME: following defines should be configured global ... */
 
 /* NOTE: do not append a /. linux' mkdir() WILL FAIL if you do that */
@@ -102,6 +97,10 @@
  * FIXME
  *   Are these doing the same as HEAP_strdupAtoW and HEAP_strdupWtoA?
  *   If so, can we remove them?
+ * ANSWER
+ *   No, the memory handling functions are called very often in here, 
+ *   just replacing them by HeapAlloc(SystemHeap,...) makes registry
+ *   loading 100 times slower. -MM
  */
 static LPWSTR strdupA2W(LPCSTR src)
 {
@@ -214,59 +213,101 @@
 }
 
 
-/* debug function, converts a unicode into a static memory area 
- * (sub for using two static strings, in case we need them in a single call)
- *
- * FIXME
- *    This seems to be used the same as debugstr_w.
- *    If so, can this one go away?
- */
-LPSTR
-W2C(LPCWSTR x,int sub) {
-	static	LPSTR	unicodedebug[2]={NULL,NULL};
-	if (x==NULL)
-		return "<NULL>";
-	if (sub!=0 && sub!=1)
-		return "<W2C:bad sub>";
-	if (unicodedebug[sub]) HeapFree( SystemHeap, 0, unicodedebug[sub] );
-	unicodedebug[sub] = HEAP_strdupWtoA( SystemHeap, 0, x );
-	return unicodedebug[sub];
-}
-
-
 /******************************************************************************
  * lookup_hkey [Internal]
+ * 
+ * Just as the name says. Creates the root keys on demand, so we can call the
+ * Reg* functions at any time.
  *
  * RETURNS
  *    Success: Pointer to key structure
  *    Failure: NULL
  */
+#define ADD_ROOT_KEY(xx) \
+	xx = (LPKEYSTRUCT)xmalloc(sizeof(KEYSTRUCT));\
+	memset(xx,'\0',sizeof(KEYSTRUCT));\
+	xx->keyname= strdupA2W("<should_not_appear_anywhere>");
+
 static LPKEYSTRUCT lookup_hkey( HKEY hkey )
 {
 	switch (hkey) {
-    /* These seem erroneous */
-    /*	case 0x00000000: */
-    /*	case 0x00000001: */
-	case HKEY_CLASSES_ROOT:
+	/* 0 and 1 are valid rootkeys in win16 shell.dll and are used by
+	 * some programs. Do not remove those cases. -MM
+	 */
+    	case 0x00000000:
+	case 0x00000001:
+	case HKEY_CLASSES_ROOT: {
+		if (!key_classes_root) {
+			HKEY	cl_r_hkey;
+
+			/* calls lookup_hkey recursively, TWICE */
+			if (RegCreateKey16(HKEY_LOCAL_MACHINE,"SOFTWARE\\Classes",&cl_r_hkey)!=ERROR_SUCCESS) {
+				ERR(reg,"Could not create HKLM\\SOFTWARE\\Classes. This is impossible.\n");
+				exit(1);
+			}
+			key_classes_root = lookup_hkey(cl_r_hkey);
+		}
 		return key_classes_root;
+	}
 	case HKEY_CURRENT_USER:
+		if (!key_current_user) {
+			HKEY	c_u_hkey;
+			struct	passwd	*pwd;
+
+			pwd=getpwuid(getuid());
+			/* calls lookup_hkey recursively, TWICE */
+			if (pwd && pwd->pw_name) {
+				if (RegCreateKey16(HKEY_USERS,pwd->pw_name,&c_u_hkey)!=ERROR_SUCCESS) {
+					ERR(reg,"Could not create HU\\%s. This is impossible.\n",pwd->pw_name);
+					exit(1);
+				}
+				key_current_user = lookup_hkey(c_u_hkey);
+			} else {
+				/* nothing found, use standalone */
+				ADD_ROOT_KEY(key_current_user);
+			}
+		}
 		return key_current_user;
 	case HKEY_LOCAL_MACHINE:
+		if (!key_local_machine) {
+			ADD_ROOT_KEY(key_local_machine);
+			REGISTRY_Init();
+		}
 		return key_local_machine;
 	case HKEY_USERS:
+		if (!key_users) {
+			ADD_ROOT_KEY(key_users);
+		}
 		return key_users;
 	case HKEY_PERFORMANCE_DATA:
+		if (!key_performance_data) {
+			ADD_ROOT_KEY(key_performance_data);
+		}
 		return key_performance_data;
 	case HKEY_DYN_DATA:
+		if (!key_dyn_data) {
+			ADD_ROOT_KEY(key_dyn_data);
+		}
 		return key_dyn_data;
 	case HKEY_CURRENT_CONFIG:
+		if (!key_current_config) {
+			ADD_ROOT_KEY(key_current_config);
+		}
 		return key_current_config;
 	default:
 		return get_handle(hkey);
 	}
 	/*NOTREACHED*/
 }
-
+#undef ADD_ROOT_KEY
+/* so we don't accidently access them ... */
+#define key_current_config NULL NULL
+#define key_current_user NULL NULL
+#define key_users NULL NULL
+#define key_local_machine NULL NULL
+#define key_classes_root NULL NULL
+#define key_dyn_data NULL NULL
+#define key_performance_data NULL NULL
 
 /******************************************************************************
  * split_keypath [Internal]
@@ -322,62 +363,14 @@
 
 
 /******************************************************************************
- * SHELL_Init [Internal]
- * Shell initialisation, allocates keys. 
+ * REGISTRY_Init [Internal]
+ * Registry initialisation, allocates some default keys. 
  */
-void SHELL_Init() {
-	struct	passwd	*pwd;
-
-	HKEY	cl_r_hkey,c_u_hkey;
-#define ADD_ROOT_KEY(xx) \
-	xx = (LPKEYSTRUCT)xmalloc(sizeof(KEYSTRUCT));\
-	memset(xx,'\0',sizeof(KEYSTRUCT));\
-	xx->keyname= strdupA2W("<should_not_appear_anywhere>");
-
-	ADD_ROOT_KEY(key_local_machine);
-	if (RegCreateKey16(HKEY_LOCAL_MACHINE,"SOFTWARE\\Classes",&cl_r_hkey)!=ERROR_SUCCESS) {
-		ERR(reg,"Could not create HKLM\\SOFTWARE\\Classes. This is impossible.\n");
-		exit(1);
-	}
-	key_classes_root = lookup_hkey(cl_r_hkey);
-
-	ADD_ROOT_KEY(key_users);
-
-#if 0
-	/* FIXME: load all users and their resp. pwd->pw_dir/.wine/user.reg 
-	 *	  (later, when a win32 registry editing tool becomes avail.)
-	 */
-	while (pwd=getpwent()) {
-		if (pwd->pw_name == NULL)
-			continue;
-		RegCreateKey16(HKEY_USERS,pwd->pw_name,&c_u_hkey);
-		RegCloseKey(c_u_hkey);
-	}
-#endif
-	pwd=getpwuid(getuid());
-	if (pwd && pwd->pw_name) {
-		RegCreateKey16(HKEY_USERS,pwd->pw_name,&c_u_hkey);
-		key_current_user = lookup_hkey(c_u_hkey);
-	} else {
-		ADD_ROOT_KEY(key_current_user);
-	}
-	ADD_ROOT_KEY(key_performance_data);
-	ADD_ROOT_KEY(key_current_config);
-	ADD_ROOT_KEY(key_dyn_data);
-#undef ADD_ROOT_KEY
-	SHELL_StartupRegistry();
-}
-
-
-/******************************************************************************
- * SHELL_StartupRegistry [Internal]
- */
-void SHELL_StartupRegistry( void )
-{
+static void REGISTRY_Init() {
 	HKEY	hkey;
 	char	buf[200];
 
-    TRACE(reg,"(void)\n");
+	TRACE(reg,"(void)\n");
 
 	RegCreateKey16(HKEY_DYN_DATA,"PerfStats\\StatData",&hkey);
 	RegCloseKey(hkey);
@@ -599,7 +592,7 @@
 		strcat(fn,"/"SAVE_CURRENT_USER);
 		tmp = (char*)xmalloc(strlen(fn)+strlen(".tmp")+1);
 		strcpy(tmp,fn);strcat(tmp,".tmp");
-		if (_savereg(key_current_user,tmp,all)) {
+		if (_savereg(lookup_hkey(HKEY_CURRENT_USER),tmp,all)) {
 			if (-1==rename(tmp,fn)) {
 				perror("rename tmp registry");
 				unlink(tmp);
@@ -612,7 +605,7 @@
 		strcat(fn,WINE_PREFIX"/"SAVE_LOCAL_MACHINE);
 		tmp = (char*)xmalloc(strlen(fn)+strlen(".tmp")+1);
 		strcpy(tmp,fn);strcat(tmp,".tmp");
-		if (_savereg(key_local_machine,tmp,all)) {
+		if (_savereg(lookup_hkey(HKEY_LOCAL_MACHINE),tmp,all)) {
 			if (-1==rename(tmp,fn)) {
 				perror("rename tmp registry");
 				unlink(tmp);
@@ -1508,10 +1501,9 @@
 	OFSTRUCT		ofs;
 	BY_HANDLE_FILE_INFORMATION hfinfo;
 	time_t			lastmodified;
-	HKEY			hkey;
 	LPKEYSTRUCT		lpkey;
 
-    TRACE(reg,"(void)\n");
+	TRACE(reg,"(void)\n");
 
 	hf = OpenFile32("reg.dat",&ofs,OF_READ);
 	if (hf==HFILE_ERROR32)
@@ -1564,10 +1556,7 @@
 		return;
 	}
 	lastmodified = DOSFS_FileTimeToUnixTime(&hfinfo.ftLastWriteTime,NULL);
-
-	if (RegCreateKey16(HKEY_LOCAL_MACHINE,"SOFTWARE\\Classes",&hkey)!=ERROR_SUCCESS)
-		return;
-	lpkey = lookup_hkey(hkey);
+	lpkey = lookup_hkey(HKEY_CLASSES_ROOT);
 	__w31_dumptree(tab[0].w1,txt,tab,&head,lpkey,lastmodified,0);
 	free(tab);
 	free(txt);
@@ -1586,17 +1575,14 @@
 	LPKEYSTRUCT	lpkey;
 	HKEY		hkey;
 
-    TRACE(reg,"(void)\n");
-
-	if (key_classes_root==NULL)
-		SHELL_Init();
+	TRACE(reg,"(void)\n");
 
 	/* Load windows 3.1 entries */
 	_w31_loadreg();
 	/* Load windows 95 entries */
-	_w95_loadreg("C:\\system.1st",	key_local_machine);
-	_w95_loadreg("system.dat",	key_local_machine);
-	_w95_loadreg("user.dat",	key_users);
+	_w95_loadreg("C:\\system.1st",	lookup_hkey(HKEY_LOCAL_MACHINE));
+	_w95_loadreg("system.dat",	lookup_hkey(HKEY_LOCAL_MACHINE));
+	_w95_loadreg("user.dat",	lookup_hkey(HKEY_USERS));
 
 	/* the global user default is loaded under HKEY_USERS\\.Default */
 	RegCreateKey16(HKEY_USERS,".Default",&hkey);
@@ -1606,11 +1592,11 @@
 	_wine_loadreg(lpkey,SAVE_USERS_DEFAULT,0);
 
 	/* HKEY_USERS\\.Default is copied to HKEY_CURRENT_USER */
-	_copy_registry(lpkey,key_current_user);
+	_copy_registry(lpkey,lookup_hkey(HKEY_CURRENT_USER));
 	RegCloseKey(hkey);
 
 	/* the global machine defaults */
-	_wine_loadreg(key_local_machine,SAVE_LOCAL_MACHINE_DEFAULT,0);
+	_wine_loadreg(lookup_hkey(HKEY_LOCAL_MACHINE),SAVE_LOCAL_MACHINE_DEFAULT,0);
 
 	/* load the user saved registries */
 
@@ -1621,12 +1607,12 @@
 		fn=(char*)xmalloc(strlen(pwd->pw_dir)+strlen(WINE_PREFIX)+strlen(SAVE_CURRENT_USER)+2);
 		strcpy(fn,pwd->pw_dir);
 		strcat(fn,WINE_PREFIX"/"SAVE_CURRENT_USER);
-		_wine_loadreg(key_current_user,fn,REG_OPTION_TAINTED);
+		_wine_loadreg(lookup_hkey(HKEY_CURRENT_USER),fn,REG_OPTION_TAINTED);
 		free(fn);
 		fn=(char*)xmalloc(strlen(pwd->pw_dir)+strlen(WINE_PREFIX)+strlen(SAVE_LOCAL_MACHINE)+2);
 		strcpy(fn,pwd->pw_dir);
 		strcat(fn,WINE_PREFIX"/"SAVE_LOCAL_MACHINE);
-		_wine_loadreg(key_local_machine,fn,REG_OPTION_TAINTED);
+		_wine_loadreg(lookup_hkey(HKEY_LOCAL_MACHINE),fn,REG_OPTION_TAINTED);
 		free(fn);
 	} else
 		WARN(reg,"Failed to get homedirectory of UID %d.\n",getuid());
@@ -1828,11 +1814,6 @@
     if (!lpNextKey)
         return ERROR_BADKEY;
 
-    if (lpszSubKey[0] == '\\') {
-        WARN(reg,"Subkey %s must not begin with backslash.\n",debugstr_w(lpszSubKey));
-        return ERROR_BAD_PATHNAME;
-    }
-
 	if (!lpszSubKey || !*lpszSubKey) {
 		add_handle(++currenthandle,lpNextKey,samDesired);
 		*retkey=currenthandle;
@@ -1841,6 +1822,11 @@
 		return ERROR_SUCCESS;
 	}
 
+    if (lpszSubKey[0] == '\\') {
+        WARN(reg,"Subkey %s must not begin with backslash.\n",debugstr_w(lpszSubKey));
+        return ERROR_BAD_PATHNAME;
+    }
+
 	split_keypath(lpszSubKey,&wps,&wpc);
 	i 	= 0;
 	while ((i<wpc) && (wps[i][0]=='\0')) i++;
@@ -2388,7 +2374,7 @@
             TRACE(reg," Data(binary)\n");
             break;
         case REG_DWORD:
-            TRACE(reg," Data(dword)=%lx\n", (DWORD)*lpbData);
+            TRACE(reg," Data(dword)=%lx\n", (DWORD)lpbData);
             break;
         default:
             TRACE(reg,"Unknown type: %ld\n", dwType);
@@ -2500,7 +2486,7 @@
 	DWORD	ret;
 
 	TRACE(reg,"(%x,%s,%ld,%s,%ld)\n",
-		hkey,W2C(lpszSubKey,0),dwType,W2C(lpszData,0),cbData
+		hkey,debugstr_w(lpszSubKey),dwType,debugstr_w(lpszData),cbData
 	);
 	if (lpszSubKey && *lpszSubKey) {
 		ret=RegCreateKey32W(hkey,lpszSubKey,&xhkey);
@@ -2514,7 +2500,7 @@
 	}
 	if (cbData!=2*lstrlen32W(lpszData)+2) {
 		TRACE(reg,"RegSetValueX called with len=%ld != strlen(%s)+1=%d!\n",
-			cbData,W2C(lpszData,0),2*lstrlen32W(lpszData)+2
+			cbData,debugstr_w(lpszData),2*lstrlen32W(lpszData)+2
 		);
 		cbData=2*lstrlen32W(lpszData)+2;
 	}
@@ -2913,7 +2899,7 @@
 		lpxkey=lpNextKey->nextsub;
 		while (lpxkey) {
 			TRACE(reg, "  Scanning [%s]\n",
-				     W2C (lpxkey->keyname, 0));
+				     debugstr_w(lpxkey->keyname));
 			if (!lstrcmpi32W(wps[i],lpxkey->keyname))
 				break;
 			lpxkey=lpxkey->next;
@@ -2931,7 +2917,7 @@
 	lplpPrevKey = &(lpNextKey->nextsub);
 	while (lpxkey) {
 		TRACE(reg, "  Scanning [%s]\n",
-			     W2C (lpxkey->keyname, 0));
+			     debugstr_w(lpxkey->keyname));
 		if (!lstrcmpi32W(wps[i],lpxkey->keyname))
 			break;
 		lplpPrevKey	= &(lpxkey->next);
@@ -3312,3 +3298,115 @@
     return ERROR_SUCCESS;
 }
 
+
+/******************************************************************************
+ * RegUnLoadKey32W [ADVAPI32.173]
+ */
+LONG WINAPI RegUnLoadKey32W( HKEY hkey, LPCWSTR lpSubKey )
+{
+    FIXME(reg,"(%x,%s): stub\n",hkey, debugstr_w(lpSubKey));
+    return ERROR_SUCCESS;
+}
+
+
+/******************************************************************************
+ * RegUnLoadKey32A [ADVAPI32.172]
+ */
+LONG WINAPI RegUnLoadKey32A( HKEY hkey, LPCSTR lpSubKey )
+{
+    LONG ret;
+    LPWSTR lpSubKeyW = HEAP_strdupAtoW( GetProcessHeap(), 0, lpSubKey );
+    ret = RegUnLoadKey32W( hkey, lpSubKeyW );
+    HeapFree( GetProcessHeap(), 0, lpSubKeyW );
+    return ret;
+}
+
+
+/******************************************************************************
+ * RegSetKeySecurity [ADVAPI32.167]
+ */
+LONG WINAPI RegSetKeySecurity( HKEY hkey, SECURITY_INFORMATION SecurityInfo,
+                               LPSECURITY_DESCRIPTOR pSecurityDesc )
+{
+    FIXME(reg, "%x,%ld,%p): stub\n", hkey, SecurityInfo, pSecurityDesc);
+    return ERROR_SUCCESS;
+}
+
+
+/******************************************************************************
+ * RegSaveKey32W [ADVAPI32.166]
+ */
+LONG WINAPI RegSaveKey32W( HKEY hkey, LPCWSTR lpFile, 
+                           LPSECURITY_ATTRIBUTES sa )
+{
+    FIXME(reg, "%x,%s,%p): stub\n", hkey, debugstr_w(lpFile), sa);
+    return ERROR_SUCCESS;
+}
+
+
+/******************************************************************************
+ * RegSaveKey32A [ADVAPI32.165]
+ */
+LONG WINAPI RegSaveKey32A( HKEY hkey, LPCSTR lpFile, 
+                           LPSECURITY_ATTRIBUTES sa )
+{
+    LONG ret;
+    LPWSTR lpFileW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpFile);
+    ret = RegSaveKey32W( hkey, lpFileW, sa );
+    HeapFree( GetProcessHeap(), 0, lpFileW );
+    return ret;
+}
+
+
+/******************************************************************************
+ * RegRestoreKey32W [ADVAPI32.164]
+ */
+LONG WINAPI RegRestoreKey32W( HKEY hkey, LPCWSTR lpFile, DWORD dwFlags )
+{
+    FIXME(reg, "%x,%s,%ld): stub\n", hkey, debugstr_w(lpFile), dwFlags);
+    return ERROR_SUCCESS;
+}
+
+
+/******************************************************************************
+ * RegRestoreKey32A [ADVAPI32.163]
+ */
+LONG WINAPI RegRestoreKey32A( HKEY hkey, LPCSTR lpFile, DWORD dwFlags )
+{
+    LONG ret;
+    LPWSTR lpFileW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpFile);
+    ret = RegRestoreKey32W( hkey, lpFileW, dwFlags );
+    HeapFree( GetProcessHeap(), 0, lpFileW );
+    return ret;
+}
+
+
+/******************************************************************************
+ * RegReplaceKey32W [ADVAPI32.162]
+ */
+LONG WINAPI RegReplaceKey32W( HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpNewFile,
+                              LPCWSTR lpOldFile )
+{
+    FIXME(reg, "%x,%s,%s,%s): stub\n", hkey, debugstr_w(lpSubKey), 
+          debugstr_w(lpNewFile),debugstr_w(lpOldFile));
+    return ERROR_SUCCESS;
+}
+
+
+/******************************************************************************
+ * RegReplaceKey32A [ADVAPI32.161]
+ */
+LONG WINAPI RegReplaceKey32A( HKEY hkey, LPCSTR lpSubKey, LPCSTR lpNewFile,
+                              LPCSTR lpOldFile )
+{
+    LONG ret;
+    LPWSTR lpSubKeyW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpSubKey);
+    LPWSTR lpNewFileW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpNewFile);
+    LPWSTR lpOldFileW = HEAP_strdupAtoW(GetProcessHeap(), 0, lpOldFile);
+    ret = RegReplaceKey32W( hkey, lpSubKeyW, lpNewFileW, lpOldFileW );
+    HeapFree( GetProcessHeap(), 0, lpOldFileW );
+    HeapFree( GetProcessHeap(), 0, lpNewFileW );
+    HeapFree( GetProcessHeap(), 0, lpSubKeyW );
+    return ret;
+}
+