From 9515336378e0ca63d3214eb111f0a22dce7d8ea3 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 23 Mar 2001 19:13:23 +0000 Subject: [PATCH] Small dll separation fixes. --- dlls/user/user_main.c | 20 ++++----- files/profile.c | 118 +++++++++++++++----------------------------------- memory/local.c | 2 - objects/gdiobj.c | 2 +- objects/metafile.c | 2 +- windows/user.c | 2 +- 6 files changed, 46 insertions(+), 100 deletions(-) diff --git a/dlls/user/user_main.c b/dlls/user/user_main.c index 52c094da9c0..684edffb8f9 100644 --- a/dlls/user/user_main.c +++ b/dlls/user/user_main.c @@ -30,6 +30,8 @@ USER_DRIVER USER_Driver; WINE_LOOK TWEAK_WineLook = WIN31_LOOK; +WORD USER_HeapSel = 0; /* USER heap selector */ + static HMODULE graphics_driver; #define GET_USER_FUNC(name) \ @@ -43,16 +45,13 @@ static BOOL load_driver(void) HKEY hkey; DWORD type, count; - if (RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Wine", 0, NULL, - REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL )) + strcpy( buffer, "x11drv" ); /* default value */ + if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Wine", &hkey )) { - MESSAGE("load_driver: Cannot create config registry key\n" ); - return FALSE; + count = sizeof(buffer); + RegQueryValueExA( hkey, "GraphicsDriver", 0, &type, buffer, &count ); + RegCloseKey( hkey ); } - count = sizeof(buffer); - if (RegQueryValueExA( hkey, "GraphicsDriver", 0, &type, buffer, &count )) - strcpy( buffer, "x11drv" ); /* default value */ - RegCloseKey( hkey ); if (!(graphics_driver = LoadLibraryA( buffer ))) { @@ -163,8 +162,7 @@ static void tweak_init(void) HKEY hkey; DWORD type, count = sizeof(buffer); - if (RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Tweak.Layout", 0, NULL, - REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL )) + if (RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Tweak.Layout", &hkey )) return; if (RegQueryValueExA( hkey, "WineLook", 0, &type, buffer, &count )) strcpy( buffer, "Win31" ); /* default value */ @@ -197,7 +195,7 @@ BOOL WINAPI USER_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) /* Create USER heap */ if ((instance = LoadLibrary16( "USER.EXE" )) < 32) return FALSE; - USER_HeapSel = GlobalHandleToSel16( instance ); + USER_HeapSel = instance | 7; /* Global atom table initialisation */ if (!ATOM_Init( USER_HeapSel )) return FALSE; diff --git a/files/profile.c b/files/profile.c index aec6153eac9..b198dca43da 100644 --- a/files/profile.c +++ b/files/profile.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -271,7 +272,7 @@ static PROFILESECTION *PROFILE_Load( FILE *file ) } /* convert the .winerc file to the new format */ -static int convert_config( FILE *in, const char *output_name ) +static void convert_config( FILE *in, const char *output_name ) { char buffer[PROFILE_MAX_LINE_LEN]; char *p, *p2; @@ -279,7 +280,11 @@ static int convert_config( FILE *in, const char *output_name ) /* create the output file, only if it doesn't exist already */ int fd = open( output_name, O_WRONLY|O_CREAT|O_EXCL, 0666 ); - if (fd == -1) return 0; + if (fd == -1) + { + MESSAGE( "Could not create new config file '%s': %s\n", output_name, strerror(errno) ); + ExitProcess(1); + } out = fdopen( fd, "w" ); fprintf( out, "WINE REGISTRY Version 2\n" ); @@ -342,71 +347,6 @@ static int convert_config( FILE *in, const char *output_name ) fprintf( out, "\"\n" ); } fclose( out ); - return 1; -} - - -/*********************************************************************** - * PROFILE_RegistryLoad - * - * Load a profile tree from a file into a registry key. - */ -static DWORD PROFILE_RegistryLoad( HKEY root, FILE *file ) -{ - HKEY hkey = 0; - DWORD err = 0; - char buffer[PROFILE_MAX_LINE_LEN]; - char *p, *p2; - int line = 0; - - while (fgets( buffer, PROFILE_MAX_LINE_LEN, file )) - { - line++; - p = buffer; - while (*p && PROFILE_isspace(*p)) p++; - if (*p == '[') /* section start */ - { - if (!(p2 = strrchr( p, ']' ))) - { - WARN("Invalid section header at line %d: '%s'\n", - line, p ); - } - else - { - *p2 = '\0'; - p++; - if (hkey) RegCloseKey( hkey ); - if ((err = RegCreateKeyExA( root, p, 0, NULL, REG_OPTION_VOLATILE, - KEY_ALL_ACCESS, NULL, &hkey, NULL ))) return err; - TRACE("New section: '%s'\n",p); - continue; - } - } - - p2=p+strlen(p) - 1; - while ((p2 > p) && ((*p2 == '\n') || PROFILE_isspace(*p2))) *p2--='\0'; - - if ((p2 = strchr( p, '=' )) != NULL) - { - char *p3 = p2 - 1; - while ((p3 > p) && PROFILE_isspace(*p3)) *p3-- = '\0'; - *p2++ = '\0'; - while (*p2 && PROFILE_isspace(*p2)) p2++; - } - - if (*p && hkey && !IS_ENTRY_COMMENT(p)) - { - if (!p2) p2 = ""; - if ((err = RegSetValueExA( hkey, p, 0, REG_SZ, p2, strlen(p2)+1 ))) - { - RegCloseKey( hkey ); - return err; - } - TRACE("New key: name='%s', value='%s'\n",p,p2); - } - } - if (hkey) RegCloseKey( hkey ); - return 0; } @@ -1067,25 +1007,39 @@ int PROFILE_GetWineIniBool( */ int PROFILE_LoadWineIni(void) { + OBJECT_ATTRIBUTES attr; + UNICODE_STRING nameW; char buffer[MAX_PATHNAME_LEN]; const char *p; FILE *f; HKEY hKeySW; DWORD disp; + attr.Length = sizeof(attr); + attr.RootDirectory = 0; + attr.ObjectName = &nameW; + attr.Attributes = 0; + attr.SecurityDescriptor = NULL; + attr.SecurityQualityOfService = NULL; + /* make sure HKLM\\Software\\Wine\\Wine exists as non-volatile key */ - if (RegCreateKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine", &hKeySW )) + if (!RtlCreateUnicodeStringFromAsciiz( &nameW, "Machine\\Software\\Wine\\Wine" ) || + NtCreateKey( &hKeySW, KEY_ALL_ACCESS, &attr, 0, NULL, 0, &disp )) { ERR("Cannot create config registry key\n" ); - return 0; + ExitProcess( 1 ); } - RegCloseKey( hKeySW ); - if (RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config", 0, NULL, - REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &wine_profile_key, &disp )) + RtlFreeUnicodeString( &nameW ); + NtClose( hKeySW ); + + if (!RtlCreateUnicodeStringFromAsciiz( &nameW, "Machine\\Software\\Wine\\Wine\\Config" ) || + NtCreateKey( &wine_profile_key, KEY_ALL_ACCESS, &attr, 0, + NULL, REG_OPTION_VOLATILE, &disp )) { ERR("Cannot create config registry key\n" ); - return 0; + ExitProcess( 1 ); } + RtlFreeUnicodeString( &nameW ); if (!CLIENT_IsBootThread()) return 1; /* already loaded */ @@ -1118,18 +1072,14 @@ int PROFILE_LoadWineIni(void) /* convert to the new format */ sprintf( buffer, "%s/config", get_config_dir() ); - if (convert_config( f, buffer )) - { - MESSAGE( "The '%s' configuration file has been converted\n" - "to the new format and saved as '%s'.\n", PROFILE_WineIniUsed, buffer ); - MESSAGE( "You should verify that the contents of the new file are correct,\n" - "and then remove the old one and restart Wine.\n" ); - ExitProcess(0); - } - - PROFILE_RegistryLoad( wine_profile_key, f ); + convert_config( f, buffer ); fclose( f ); - return 1; + + MESSAGE( "The '%s' configuration file has been converted\n" + "to the new format and saved as '%s'.\n", PROFILE_WineIniUsed, buffer ); + MESSAGE( "You should verify that the contents of the new file are correct,\n" + "and then remove the old one and restart Wine.\n" ); + ExitProcess(0); } diff --git a/memory/local.c b/memory/local.c index b9f025d3ea9..b43ff4e2222 100644 --- a/memory/local.c +++ b/memory/local.c @@ -116,8 +116,6 @@ typedef struct #define LOCAL_HEAP_MAGIC 0x484c /* 'LH' */ -WORD USER_HeapSel = 0; /* USER heap selector */ - /* All local heap allocations are aligned on 4-byte boundaries */ #define LALIGN(word) (((word) + 3) & ~3) diff --git a/objects/gdiobj.c b/objects/gdiobj.c index 73730af9488..cdd7f393af1 100644 --- a/objects/gdiobj.c +++ b/objects/gdiobj.c @@ -320,7 +320,7 @@ BOOL GDI_Init(void) /* create GDI heap */ if ((instance = LoadLibrary16( "GDI.EXE" )) < 32) return FALSE; - GDI_HeapSel = GlobalHandleToSel16( instance ); + GDI_HeapSel = instance | 7; /* TWEAK: Initialize font hints */ ReadFontInformation("OEMFixed", &OEMFixedFont, 0, 0, 0, 0, 0); diff --git a/objects/metafile.c b/objects/metafile.c index 330cd86f391..2e1c2cadd8d 100644 --- a/objects/metafile.c +++ b/objects/metafile.c @@ -599,7 +599,7 @@ BOOL16 WINAPI EnumMetaFile16( HDC16 hdc, HMETAFILE16 hmf, sizeof(HANDLETABLE16) * mh->mtNoObjects); spht = K32WOWGlobalLock16(hHT); - seg = GlobalHandleToSel16(hmf); + seg = hmf | 7; offset = mh->mtHeaderSize * 2; /* loop through metafile records */ diff --git a/windows/user.c b/windows/user.c index beeb644ed19..053eb161659 100644 --- a/windows/user.c +++ b/windows/user.c @@ -44,7 +44,7 @@ WORD WINAPI GetFreeSystemResources16( WORD resType ) int userPercent, gdiPercent; if ((gdi_inst = LoadLibrary16( "GDI" )) < 32) return 0; - gdi_heap = GlobalHandleToSel16( gdi_inst ); + gdi_heap = gdi_inst | 7; switch(resType) { -- 2.11.4.GIT