Commit bc854efd authored by Jinoh Kang's avatar Jinoh Kang Committed by Alexandre Julliard

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.
parent 6cabfcc1
......@@ -2917,7 +2917,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);
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment