ntdll: Don't call NtClose directly in delete_view.
Hans Leidekker
hans at codeweavers.com
Thu Dec 2 04:33:03 CST 2010
The Everquest 2 / Pirates of the Burning Sea demo hooks a bunch of ntdll
exports but doesn't accept internal calls to these functions, or is not
prepared to handle them; it exits silently, right after an internal call
to NtClose.
This patch addresses the problem by moving the implementation of NtClose
to a separate function.
See http://bugs.winehq.org/show_bug.cgi?id=23755
---
dlls/ntdll/ntdll_misc.h | 2 ++
dlls/ntdll/om.c | 27 ++++++++++++++++-----------
dlls/ntdll/virtual.c | 2 +-
3 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 212edf5..edbdf10 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -39,6 +39,8 @@ struct drive_info
ino_t ino;
};
+extern NTSTATUS nt_close( HANDLE );
+
/* exceptions */
extern void wait_suspend( CONTEXT *context );
extern NTSTATUS send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *context );
diff --git a/dlls/ntdll/om.c b/dlls/ntdll/om.c
index 85ac0bf..644f091 100644
--- a/dlls/ntdll/om.c
+++ b/dlls/ntdll/om.c
@@ -348,6 +348,21 @@ NTSTATUS WINAPI NtDuplicateObject( HANDLE source_process, HANDLE source,
return ret;
}
+NTSTATUS nt_close( HANDLE handle )
+{
+ NTSTATUS ret;
+ int fd = server_remove_fd_from_cache( handle );
+
+ SERVER_START_REQ( close_handle )
+ {
+ req->handle = wine_server_obj_handle( handle );
+ ret = wine_server_call( req );
+ }
+ SERVER_END_REQ;
+ if (fd != -1) close( fd );
+ return ret;
+}
+
/**************************************************************************
* NtClose [NTDLL.@]
*
@@ -362,17 +377,7 @@ NTSTATUS WINAPI NtDuplicateObject( HANDLE source_process, HANDLE source,
*/
NTSTATUS WINAPI NtClose( HANDLE Handle )
{
- NTSTATUS ret;
- int fd = server_remove_fd_from_cache( Handle );
-
- SERVER_START_REQ( close_handle )
- {
- req->handle = wine_server_obj_handle( Handle );
- ret = wine_server_call( req );
- }
- SERVER_END_REQ;
- if (fd != -1) close( fd );
- return ret;
+ return nt_close( Handle );
}
/*
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 548c0fd..5c12ed4 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -444,7 +444,7 @@ static void delete_view( struct file_view *view ) /* [in] View */
{
if (!(view->protect & VPROT_SYSTEM)) unmap_area( view->base, view->size );
list_remove( &view->entry );
- if (view->mapping) NtClose( view->mapping );
+ if (view->mapping) nt_close( view->mapping );
RtlFreeHeap( virtual_heap, 0, view );
}
--
1.7.1
More information about the wine-patches
mailing list