[PATCH] kernelbase: Implement ReOpenFile().
Zebediah Figura
z.figura12 at gmail.com
Mon Jan 27 11:07:17 CST 2020
On 1/27/20 9:28 AM, Alexandre Julliard wrote:
> Zebediah Figura <z.figura12 at gmail.com> writes:
>
>> @@ -2550,10 +2553,60 @@ HANDLE WINAPI DECLSPEC_HOTPATCH OpenFileById( HANDLE handle, LPFILE_ID_DESCRIPTO
>> /***********************************************************************
>> * ReOpenFile (kernelbase.@)
>> */
>> -HANDLE WINAPI /* DECLSPEC_HOTPATCH */ ReOpenFile( HANDLE handle, DWORD access, DWORD sharing, DWORD flags )
>> +HANDLE WINAPI DECLSPEC_HOTPATCH ReOpenFile( HANDLE handle, DWORD access, DWORD sharing, DWORD attributes )
>> {
>> - FIXME( "(%p, %d, %d, %d): stub\n", handle, access, sharing, flags );
>> - return INVALID_HANDLE_VALUE;
>> + SECURITY_QUALITY_OF_SERVICE qos;
>> + OBJECT_NAME_INFORMATION *name;
>> + OBJECT_ATTRIBUTES attr = {};
>> + IO_STATUS_BLOCK io;
>> + NTSTATUS status;
>> + HANDLE file;
>> + DWORD size;
>> +
>> + TRACE("handle %p, access %#x, sharing %#x, attributes %#x.\n", handle, access, sharing, attributes);
>> +
>> + if (attributes & 0x7ffff) /* FILE_ATTRIBUTE_* flags are invalid */
>> + {
>> + SetLastError(ERROR_INVALID_PARAMETER);
>> + return INVALID_HANDLE_VALUE;
>> + }
>> +
>> + status = NtQueryObject( handle, ObjectNameInformation, NULL, 0, &size );
>> + if (status != STATUS_INFO_LENGTH_MISMATCH && !set_ntstatus( status ))
>> + return INVALID_HANDLE_VALUE;
>> +
>> + if (!(name = RtlAllocateHeap( GetProcessHeap(), 0, size )))
>> + {
>> + SetLastError( ERROR_NOT_ENOUGH_MEMORY );
>> + return INVALID_HANDLE_VALUE;
>> + }
>> +
>> + status = NtQueryObject( handle, ObjectNameInformation, name, size, NULL );
>> + if (!set_ntstatus( status ))
>> + return INVALID_HANDLE_VALUE;
>> +
>> + if (attributes & FILE_FLAG_DELETE_ON_CLOSE)
>> + access |= DELETE;
>
> It should be possible to reopen the file by using the handle as a root
> directory with an empty name, so that you don't need to retrieve the
> full name (which may have changed).
>
Thanks, I hadn't thought of that. Resent.
More information about the wine-devel
mailing list