From 73a7cdac0b23129f6ba061022fe79cfe23c8183f Mon Sep 17 00:00:00 2001 From: Shachar Shemesh Date: Sat, 11 Jan 2003 21:02:50 +0000 Subject: [PATCH] Implemented the "pending rename" registry processing. --- programs/wineboot/Makefile.in | 2 +- programs/wineboot/wineboot.c | 161 +++++++++++++++++++++++++++++++++- 2 files changed, 159 insertions(+), 4 deletions(-) diff --git a/programs/wineboot/Makefile.in b/programs/wineboot/Makefile.in index 8f1f2f76e7c..9473580dc31 100644 --- a/programs/wineboot/Makefile.in +++ b/programs/wineboot/Makefile.in @@ -4,7 +4,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = wineboot.exe APPMODE = cui -IMPORTS = kernel32 +IMPORTS = advapi32 kernel32 C_SRCS = \ wineboot.c diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c index 03f9c761fa0..259f7cd5fb0 100644 --- a/programs/wineboot/wineboot.c +++ b/programs/wineboot/wineboot.c @@ -16,10 +16,18 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* Bugs: + * - If a pending rename registry does not start with \??\, the first four + * chars are still going to be skipped. + * - Need to check what is the windows behaviour when trying to delete files + * and directories that are read-only + * - In the pending rename registry processing - there are no traces of the files + * processed (requires translations from Unicode to Ansi). + */ #include -#include "winbase.h" -#include "wine/debug.h" +#include +#include WINE_DEFAULT_DEBUG_CHANNEL(wineboot); @@ -153,6 +161,151 @@ static BOOL wininit() return TRUE; } +static BOOL pendingRename() +{ + static const WCHAR ValueName[] = {'P','e','n','d','i','n','g', + 'F','i','l','e','R','e','n','a','m','e', + 'O','p','e','r','a','t','i','o','n','s',0}; + static const WCHAR SessionW[] = { 'S','y','s','t','e','m','\\', + 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\', + 'C','o','n','t','r','o','l','\\', + 'S','e','s','s','i','o','n',' ','M','a','n','a','g','e','r',0}; + const WCHAR *buffer=NULL; + const WCHAR *src=NULL, *dst=NULL; + DWORD dataLength=0; + HKEY hSession=NULL; + DWORD res; + + WINE_TRACE("Entered\n"); + + if( (res=RegOpenKeyExW( HKEY_LOCAL_MACHINE, SessionW, 0, KEY_ALL_ACCESS, &hSession )) + !=ERROR_SUCCESS ) + { + if( res==ERROR_FILE_NOT_FOUND ) + { + WINE_TRACE("The key was not found - skipping\n"); + res=TRUE; + } + else + { + WINE_ERR("Couldn't open key, error %ld\n", res ); + res=FALSE; + } + + goto end; + } + + res=RegQueryValueExW( hSession, ValueName, NULL, NULL /* The value type does not really interest us, as it is not + truely a REG_MULTI_SZ anyways */, + NULL, &dataLength ); + if( res==ERROR_FILE_NOT_FOUND ) + { + /* No value - nothing to do. Great! */ + WINE_TRACE("Value not present - nothing to rename\n"); + res=TRUE; + goto end; + } + + if( res!=ERROR_SUCCESS ) + { + WINE_ERR("Couldn't query value's length (%ld)\n", res ); + res=FALSE; + goto end; + } + + buffer=malloc( dataLength ); + if( buffer==NULL ) + { + WINE_ERR("Couldn't allocate %lu bytes for the value\n", dataLength ); + res=FALSE; + goto end; + } + + res=RegQueryValueExW( hSession, ValueName, NULL, NULL, (LPBYTE)buffer, &dataLength ); + if( res!=ERROR_SUCCESS ) + { + WINE_ERR("Couldn't query value after successfully querying before (%lu),\n" + "please report to wine-devel@winehq.org\n", res); + res=FALSE; + goto end; + } + + /* Make sure that the data is long enough and ends with two NULLs. This + * simplifies the code later on. + */ + if( dataLength<2*sizeof(buffer[0]) || + buffer[dataLength/sizeof(buffer[0])-1]!='\0' || + buffer[dataLength/sizeof(buffer[0])-2]!='\0' ) + { + WINE_ERR("Improper value format - doesn't end with NULL\n"); + res=FALSE; + goto end; + } + + for( src=buffer; (src-buffer)*sizeof(src[0])