[RFC][HELP][PATCH v6] kernel32: Correct ReplaceFileW behaviour

Dmitry Timoshkov dmitry at baikal.ru
Mon Oct 1 22:33:20 CDT 2018


Brock York <twunknown at gmail.com> wrote:

> -    /* Open the "replaced" file for reading and writing */
> +    /* Open the "replaced" file for reading and writing to check for READ_ONLY attribute */
>      if (!(RtlDosPathNameToNtPathName_U(lpReplacedFileName, &nt_replaced_name, NULL, NULL)))
>      {
>          error = ERROR_PATH_NOT_FOUND;
> @@ -1776,6 +1776,12 @@ BOOL WINAPI ReplaceFileW(LPCWSTR lpReplacedFileName, LPCWSTR lpReplacementFileNa
>                          &attr, &io,
>                          FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
>                          FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE);
> +    /*If we didn't get ACCESS_DENIED, then open the file for reading and delete ready for the replacement*/
> +    if (status == STATUS_SHARING_VIOLATION)
> +	status = NtOpenFile(&hReplaced, GENERIC_READ|DELETE|SYNCHRONIZE,
> +			&attr, &io,
> +			FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
> +			FILE_SYNCHRONOUS_IO_NONALERT|FILE_NON_DIRECTORY_FILE);

This is a hack, read-only attribute should be checked on wineserver side.

-- 
Dmitry.



More information about the wine-devel mailing list