Added patch to call DriverUnload during driver unload.

This commit is contained in:
Michael Müller 2015-01-26 04:39:12 +01:00
parent 0c2b776e83
commit a3813c45a0
4 changed files with 105 additions and 0 deletions

View File

@ -38,6 +38,11 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
===================================
**Bugfixes and features included in the next upcoming release [1]:**
* Call DriverUnload function when unloading a driver.
**Bugs fixed in Wine Staging 1.7.35 [146]:**
* Add Dynamic DST exceptions for Israel Standard Time ([Wine Bug #36374](https://bugs.winehq.org/show_bug.cgi?id=36374))

View File

@ -181,6 +181,7 @@ patch_enable_all ()
enable_wined3d_CSMT_Main="$1"
enable_wined3d_DXTn="$1"
enable_wined3d_Revert_PixelFormat="$1"
enable_winedevice_DriverUnload="$1"
enable_winedevice_Fix_Relocation="$1"
enable_winemenubuilder_Desktop_Icon_Path="$1"
enable_winepulse_PulseAudio_Support="$1"
@ -560,6 +561,9 @@ patch_enable ()
wined3d-Revert_PixelFormat)
enable_wined3d_Revert_PixelFormat="$2"
;;
winedevice-DriverUnload)
enable_winedevice_DriverUnload="$2"
;;
winedevice-Fix_Relocation)
enable_winedevice_Fix_Relocation="$2"
;;
@ -3363,6 +3367,18 @@ if test "$enable_wined3d_Revert_PixelFormat" -eq 1; then
) >> "$patchlist"
fi
# Patchset winedevice-DriverUnload
# |
# | Modified files:
# | * programs/winedevice/device.c
# |
if test "$enable_winedevice_DriverUnload" -eq 1; then
patch_apply winedevice-DriverUnload/0001-winedevice-Call-DriverUnload-function-when-unloading.patch
(
echo '+ { "Michael Müller", "winedevice: Call DriverUnload function when unloading a driver.", 1 },';
) >> "$patchlist"
fi
# Patchset winedevice-Fix_Relocation
# |
# | This patchset fixes the following Wine bugs:

View File

@ -0,0 +1,83 @@
From 2ccb50c0dd04ae77d39dac6406f8cfa6e102aa91 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Mon, 26 Jan 2015 04:31:10 +0100
Subject: winedevice: Call DriverUnload function when unloading a driver.
Based on a patch by Alexander Morozov.
---
programs/winedevice/device.c | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/programs/winedevice/device.c b/programs/winedevice/device.c
index 72bc124..edd7c83 100644
--- a/programs/winedevice/device.c
+++ b/programs/winedevice/device.c
@@ -45,6 +45,7 @@ static SERVICE_STATUS_HANDLE service_handle;
static HKEY driver_hkey;
static HANDLE stop_event;
static DRIVER_OBJECT driver_obj;
+static HMODULE driver_module;
static DRIVER_EXTENSION driver_extension;
/* find the LDR_MODULE corresponding to the driver module */
@@ -167,8 +168,26 @@ static NTSTATUS init_driver( HMODULE module, UNICODE_STRING *keyname )
return status;
}
+/* call the driver unload function */
+static void unload_driver( HMODULE module, DRIVER_OBJECT *driver_obj )
+{
+ if (driver_obj->DriverUnload)
+ {
+ if (WINE_TRACE_ON(relay))
+ WINE_DPRINTF( "%04x:Call driver unload %p (obj=%p)\n", GetCurrentThreadId(),
+ driver_obj->DriverUnload, driver_obj );
+
+ driver_obj->DriverUnload( driver_obj );
+
+ if (WINE_TRACE_ON(relay))
+ WINE_DPRINTF( "%04x:Ret driver unload %p (obj=%p)\n", GetCurrentThreadId(),
+ driver_obj->DriverUnload, driver_obj );
+ }
+ FreeLibrary( module );
+}
+
/* load the .sys module for a device driver */
-static BOOL load_driver(void)
+static HMODULE load_driver(void)
{
static const WCHAR driversW[] = {'\\','d','r','i','v','e','r','s','\\',0};
static const WCHAR systemrootW[] = {'\\','S','y','s','t','e','m','R','o','o','t','\\',0};
@@ -249,10 +268,10 @@ static BOOL load_driver(void)
module = load_driver_module( str );
HeapFree( GetProcessHeap(), 0, path );
- if (!module) return FALSE;
+ if (!module) return NULL;
init_driver( module, &keypath );
- return TRUE;
+ return module;
}
static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context )
@@ -305,13 +324,15 @@ static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
status.dwWaitHint = 10000;
SetServiceStatus( service_handle, &status );
- if (load_driver())
+ driver_module = load_driver();
+ if (driver_module)
{
status.dwCurrentState = SERVICE_RUNNING;
status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
SetServiceStatus( service_handle, &status );
wine_ntoskrnl_main_loop( stop_event );
+ unload_driver( driver_module, &driver_obj );
}
else WINE_ERR( "driver %s failed to load\n", wine_dbgstr_w(driver_name) );
--
1.9.1

View File

@ -0,0 +1 @@
Fixes: Call DriverUnload function when unloading a driver.