Module: wine Branch: stable Commit: 7f0b6167ceb6e292ba219ea2e84f4348b791c94c URL: https://gitlab.winehq.org/wine/wine/-/commit/7f0b6167ceb6e292ba219ea2e84f434...
Author: Jinoh Kang jinoh.kang.kr@gmail.com Date: Sat Mar 18 17:02:22 2023 +0900
ntdll: Open application manifest files with FILE_SHARE_DELETE.
Today, RtlCreateActivationContext (CreateActCtxW) opens the source manifest file via NtOpenFile without the FILE_SHARE_DELETE sharing mode.
This causes CreateActCtxW to fail if the source manifest file was created with the FILE_DELETE_ON_CLOSE flag. FILE_DELETE_ON_CLOSE is often used for temporary files that should be automatically deleted after use, even if the creator process crashes.
Fix this by specifying FILE_SHARE_DELETE for sharing mode when opening the source manifest or module file. This allows the source manifest or module file to be marked as deleted while it is open.
Note that concurrent deletion is not an issue for the following reasons:
- The ability to read from an open file handle is unaffected by deletion of the corresponding file's name.
- RtlCreateActivationContext does not open the source manifest or module file by the given filename (lpSource) more than once.
(cherry picked from commit bc854efd7c20802a28499779dc35e3394ff9ac5e)
---
dlls/kernel32/tests/actctx.c | 1 - dlls/ntdll/actctx.c | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/actctx.c b/dlls/kernel32/tests/actctx.c index 1a3f06835a5..2225215be8a 100644 --- a/dlls/kernel32/tests/actctx.c +++ b/dlls/kernel32/tests/actctx.c @@ -2953,7 +2953,6 @@ static void test_CreateActCtx_share_mode(void) actctx.lpSource = tmp_manifest_pathname;
handle = CreateActCtxW(&actctx); - todo_wine ok(handle != INVALID_HANDLE_VALUE, "CreateActCtxW returned error %lu\n", GetLastError()); ok(handle != NULL, "CreateActCtxW returned %p\n", handle);
diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c index d8597e5c7fb..3fcf5196339 100644 --- a/dlls/ntdll/actctx.c +++ b/dlls/ntdll/actctx.c @@ -2925,7 +2925,8 @@ static NTSTATUS open_nt_file( HANDLE *handle, UNICODE_STRING *name ) attr.ObjectName = name; attr.SecurityDescriptor = NULL; attr.SecurityQualityOfService = NULL; - return NtOpenFile( handle, GENERIC_READ | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ, FILE_SYNCHRONOUS_IO_ALERT ); + return NtOpenFile( handle, GENERIC_READ | SYNCHRONIZE, &attr, &io, + FILE_SHARE_READ | FILE_SHARE_DELETE, FILE_SYNCHRONOUS_IO_ALERT ); }
static NTSTATUS get_manifest_in_module( struct actctx_loader* acl, struct assembly_identity* ai,