Driver critical section changes from CW

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Modified files:
	dlls/gdi		: driver.c
	loader			: module.c

Log message:
	Codeweavers
	Replace Rtl...PebLock with Rtl...CriticalSection.
	Slight change to library loading.



Index: dlls/gdi/driver.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/driver.c,v
retrieving revision 1.6
diff -u -r1.6 driver.c
--- dlls/gdi/driver.c	2001/09/14 01:00:57	1.6
+++ dlls/gdi/driver.c	2002/01/26 15:02:42
@@ -27,8 +27,8 @@
 static struct graphics_driver *first_driver;
 static struct graphics_driver *display_driver;
 static const DC_FUNCTIONS *win16_driver;
+static CRITICAL_SECTION driver_section = CRITICAL_SECTION_INIT( "driver_section" );
 
-
 /**********************************************************************
  *	     create_driver
  *
@@ -207,13 +207,13 @@
     HMODULE module;
     struct graphics_driver *driver;
 
-    RtlAcquirePebLock();
+    RtlEnterCriticalSection( &driver_section );
 
     /* display driver is a special case */
     if (!strcasecmp( name, "display" ))
     {
         driver = load_display_driver();
-        RtlReleasePebLock();
+        RtlLeaveCriticalSection( &driver_section );
         return &driver->funcs;
     }
 
@@ -224,7 +224,7 @@
             if (driver->module == module)
             {
                 driver->count++;
-                RtlReleasePebLock();
+                RtlLeaveCriticalSection( &driver_section );
                 return &driver->funcs;
             }
         }
@@ -233,19 +233,19 @@
     if (!(module = LoadLibraryA( name )))
     {
         if (!win16_driver) win16_driver = WIN16DRV_Init();
-        RtlReleasePebLock();
+        RtlLeaveCriticalSection( &driver_section );
         return win16_driver;
     }
 
     if (!(driver = create_driver( module )))
     {
         FreeLibrary( module );
-        RtlReleasePebLock();
+        RtlLeaveCriticalSection( &driver_section );
         return NULL;
     }
 
     TRACE( "loaded driver %p for %s\n", driver, name );
-    RtlReleasePebLock();
+    RtlLeaveCriticalSection( &driver_section );
     return &driver->funcs;
 }
 
@@ -259,7 +259,7 @@
 {
     struct graphics_driver *driver;
 
-    RtlAcquirePebLock();
+    RtlEnterCriticalSection( &driver_section );
     if (funcs != win16_driver)
     {
         for (driver = first_driver; driver; driver = driver->next)
@@ -267,7 +267,7 @@
         if (!driver) ERR( "driver not found, trouble ahead\n" );
         driver->count++;
     }
-    RtlReleasePebLock();
+    RtlLeaveCriticalSection( &driver_section );
     return funcs;
 }
 
@@ -281,7 +281,7 @@
 {
     struct graphics_driver *driver;
 
-    RtlAcquirePebLock();
+    RtlEnterCriticalSection( &driver_section );
 
     if (funcs == win16_driver) goto done;
 
@@ -300,7 +300,7 @@
     FreeLibrary( driver->module );
     HeapFree( GetProcessHeap(), 0, driver );
  done:
-    RtlReleasePebLock();
+    RtlLeaveCriticalSection( &driver_section );
 }
 
 
Index: loader/module.c
===================================================================
RCS file: /home/wine/wine/loader/module.c,v
retrieving revision 1.145
diff -u -r1.145 module.c
--- loader/module.c	2002/01/18 18:58:08	1.145
+++ loader/module.c	2002/01/26 15:02:43
@@ -29,6 +29,8 @@
 static int free_lib_count;   /* recursion depth of FreeLibrary calls */
 static int process_detaching;  /* set on process detach to avoid deadlocks with thread detach */
 
+static CRITICAL_SECTION loader_section = CRITICAL_SECTION_INIT( "loader_section" );
+
 /***********************************************************************
  *           wait_input_idle
  *
@@ -176,9 +178,13 @@
     BOOL retv = TRUE;
     int i;
 
-    RtlAcquirePebLock();
+    RtlEnterCriticalSection( &loader_section );
 
-    if (!wm) wm = exe_modref;
+    if (!wm)
+    {
+        wm = exe_modref;
+        PE_InitTls();
+    }
     assert( wm );
 
     /* prevent infinite recursion in case of cyclical dependencies */
@@ -221,7 +227,7 @@
     TRACE("(%s,%p) - END\n", wm->modname, lpReserved );
 
  done:
-    RtlReleasePebLock();
+    RtlLeaveCriticalSection( &loader_section );
     return retv;
 }
 
@@ -236,7 +242,7 @@
 {
     WINE_MODREF *wm;
 
-    RtlAcquirePebLock();
+    RtlEnterCriticalSection( &loader_section );
     if (bForceDetach) process_detaching = 1;
     do
     {
@@ -258,7 +264,7 @@
         }
     } while ( wm );
 
-    RtlReleasePebLock();
+    RtlLeaveCriticalSection( &loader_section );
 }
 
 /*************************************************************************
@@ -276,8 +282,10 @@
     if (process_detaching) return;
     /* FIXME: there is still a race here */
 
-    RtlAcquirePebLock();
+    RtlEnterCriticalSection( &loader_section );
 
+    PE_InitTls();
+
     for ( wm = MODULE_modref_list; wm; wm = wm->next )
         if ( !wm->next )
             break;
@@ -292,7 +300,7 @@
         MODULE_InitDLL( wm, DLL_THREAD_ATTACH, lpReserved );
     }
 
-    RtlReleasePebLock();
+    RtlLeaveCriticalSection( &loader_section );
 }
 
 /*************************************************************************
@@ -310,7 +318,7 @@
     if (process_detaching) return;
     /* FIXME: there is still a race here */
 
-    RtlAcquirePebLock();
+    RtlEnterCriticalSection( &loader_section );
 
     for ( wm = MODULE_modref_list; wm; wm = wm->next )
     {
@@ -322,7 +330,7 @@
         MODULE_InitDLL( wm, DLL_THREAD_DETACH, lpReserved );
     }
 
-    RtlReleasePebLock();
+    RtlLeaveCriticalSection( &loader_section );
 }
 
 /****************************************************************************
@@ -335,7 +343,7 @@
     WINE_MODREF *wm;
     BOOL retval = TRUE;
 
-    RtlAcquirePebLock();
+    RtlEnterCriticalSection( &loader_section );
 
     wm = MODULE32_LookupHMODULE( hModule );
     if ( !wm )
@@ -343,7 +351,7 @@
     else
         wm->flags |= WINE_MODREF_NO_DLL_CALLS;
 
-    RtlReleasePebLock();
+    RtlLeaveCriticalSection( &loader_section );
 
     return retval;
 }
@@ -1231,13 +1239,13 @@
 {
     WINE_MODREF *wm;
 
-    RtlAcquirePebLock();
+    RtlEnterCriticalSection( &loader_section );
 
     lpFileName[0] = 0;
     if ((wm = MODULE32_LookupHMODULE( hModule )))
         lstrcpynA( lpFileName, wm->filename, size );
 
-    RtlReleasePebLock();
+    RtlLeaveCriticalSection( &loader_section );
     TRACE("%s\n", lpFileName );
     return strlen(lpFileName);
 }                   
@@ -1284,7 +1292,18 @@
                                             NULL, OPEN_EXISTING, 0, 0 );
                 if (hFile != INVALID_HANDLE_VALUE)
                 {
-                    hmod = PE_LoadImage( hFile, filename, flags );
+                    DWORD type;
+                    MODULE_GetBinaryType( hFile, filename, &type );
+                    if (type == SCS_32BIT_BINARY)
+                    {
+                        HANDLE mapping = CreateFileMappingA( hFile, NULL, PAGE_READONLY,
+                                                             0, 0, NULL );
+                        if (mapping)
+                        {
+                            hmod = (HMODULE)MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
+                            CloseHandle( mapping );
+                        }
+                    }
                     CloseHandle( hFile );
                 }
                 if (hmod) return (HMODULE)((ULONG_PTR)hmod + 1);
@@ -1293,7 +1312,7 @@
             /* Fallback to normal behaviour */
         }
 
-        RtlAcquirePebLock();
+        RtlEnterCriticalSection( &loader_section );
 
 	wm = MODULE_LoadLibraryExA( libname, hfile, flags );
 	if ( wm )
@@ -1307,7 +1326,7 @@
 		}
 	}
 
-        RtlReleasePebLock();
+        RtlLeaveCriticalSection( &loader_section );
 	return wm ? wm->module : 0;
 }
 
@@ -1381,7 +1400,7 @@
 	if ( !filename ) return NULL;
         *filename = 0; /* Just in case we don't set it before goto error */
 
-        RtlAcquirePebLock();
+        RtlEnterCriticalSection( &loader_section );
 
         if ((flags & LOAD_WITH_ALTERED_SEARCH_PATH) && FILE_contains_path(libname))
         {
@@ -1459,7 +1478,7 @@
                     HeapFree ( GetProcessHeap(), 0, (LPSTR)libdir );
                     libdir = NULL;
                 }
-                RtlReleasePebLock();
+                RtlLeaveCriticalSection( &loader_section );
 		HeapFree ( GetProcessHeap(), 0, filename );
 		return pwm;
 	}
@@ -1511,7 +1530,7 @@
                             HeapFree ( GetProcessHeap(), 0, (LPSTR)libdir );
                             libdir = NULL;
                         }
-                        RtlReleasePebLock();
+                        RtlLeaveCriticalSection( &loader_section );
                         SetLastError( err );  /* restore last error */
 			HeapFree ( GetProcessHeap(), 0, filename );
 			return pwm;
@@ -1527,7 +1546,7 @@
             HeapFree ( GetProcessHeap(), 0, (LPSTR)libdir );
             libdir = NULL;
         }
-        RtlReleasePebLock();
+        RtlLeaveCriticalSection( &loader_section );
 	WARN("Failed to load module '%s'; error=0x%08lx\n", filename, GetLastError());
 	HeapFree ( GetProcessHeap(), 0, filename );
 	return NULL;
@@ -1634,13 +1653,13 @@
         return TRUE;
     }
 
-    RtlAcquirePebLock();
+    RtlEnterCriticalSection( &loader_section );
     free_lib_count++;
 
     if ((wm = MODULE32_LookupHMODULE( hLibModule ))) retv = MODULE_FreeLibrary( wm );
 
     free_lib_count--;
-    RtlReleasePebLock();
+    RtlLeaveCriticalSection( &loader_section );
 
     return retv;
 }
@@ -1818,13 +1837,13 @@
     else
 	TRACE_(win32)("(%08lx,%p)\n",(DWORD)hModule,function);
 
-    RtlAcquirePebLock();
+    RtlEnterCriticalSection( &loader_section );
     if ((wm = MODULE32_LookupHMODULE( hModule )))
     {
         retproc = wm->find_export( wm, function, snoop );
         if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
     }
-    RtlReleasePebLock();
+    RtlLeaveCriticalSection( &loader_section );
     return retproc;
 }
 

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux