mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-01-28 22:04:43 -08:00
Added kernelbase-ReOpenFile patchset
This commit is contained in:
parent
356f228262
commit
69cf026375
@ -0,0 +1,144 @@
|
||||
From e42bb02d6f8feecac8b6c57a84ac90003ca99e79 Mon Sep 17 00:00:00 2001
|
||||
From: Louis Lenders <xerox.xerox2000x@gmail.com>
|
||||
Date: Fri, 4 Oct 2019 23:10:29 +0200
|
||||
Subject: [PATCH] kernelbase: Improve stub for ReOpenFile and add small test
|
||||
|
||||
Wine-bug: bug https://bugs.winehq.org/show_bug.cgi?id=47668
|
||||
|
||||
Signed-off-by: Louis Lenders <xerox.xerox2000x@gmail.com>
|
||||
---
|
||||
dlls/kernel32/tests/file.c | 47 ++++++++++++++++++++++++++++++++++++++
|
||||
dlls/kernelbase/file.c | 31 +++++++++++++++++++++++--
|
||||
2 files changed, 76 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
|
||||
index 5bd168276f..67e56e0950 100644
|
||||
--- a/dlls/kernel32/tests/file.c
|
||||
+++ b/dlls/kernel32/tests/file.c
|
||||
@@ -59,6 +59,7 @@ static BOOL (WINAPI *pRtlDosPathNameToNtPathName_U)(LPCWSTR, PUNICODE_STRING, PW
|
||||
static NTSTATUS (WINAPI *pRtlAnsiStringToUnicodeString)(PUNICODE_STRING, PCANSI_STRING, BOOLEAN);
|
||||
static BOOL (WINAPI *pSetFileInformationByHandle)(HANDLE, FILE_INFO_BY_HANDLE_CLASS, void*, DWORD);
|
||||
static BOOL (WINAPI *pGetQueuedCompletionStatusEx)(HANDLE, OVERLAPPED_ENTRY*, ULONG, ULONG*, DWORD, BOOL);
|
||||
+static HANDLE (WINAPI *pReOpenFile)(HANDLE, DWORD, DWORD, DWORD);
|
||||
static void (WINAPI *pRtlInitAnsiString)(PANSI_STRING,PCSZ);
|
||||
static void (WINAPI *pRtlFreeUnicodeString)(PUNICODE_STRING);
|
||||
static BOOL (WINAPI *pSetFileCompletionNotificationModes)(HANDLE, UCHAR);
|
||||
@@ -111,6 +112,7 @@ static void InitFunctionPointers(void)
|
||||
pGetFinalPathNameByHandleW = (void *) GetProcAddress(hkernel32, "GetFinalPathNameByHandleW");
|
||||
pSetFileInformationByHandle = (void *) GetProcAddress(hkernel32, "SetFileInformationByHandle");
|
||||
pGetQueuedCompletionStatusEx = (void *) GetProcAddress(hkernel32, "GetQueuedCompletionStatusEx");
|
||||
+ pReOpenFile = (void *) GetProcAddress(hkernel32, "ReOpenFile");
|
||||
pSetFileCompletionNotificationModes = (void *)GetProcAddress(hkernel32, "SetFileCompletionNotificationModes");
|
||||
pFindFirstStreamW = (void *)GetProcAddress(hkernel32, "FindFirstStreamW");
|
||||
}
|
||||
@@ -4410,6 +4412,50 @@ static void test_SetFileValidData(void)
|
||||
DeleteFileA(filename);
|
||||
}
|
||||
|
||||
+static void test_ReOpenFile(void)
|
||||
+{
|
||||
+ static WCHAR prefix[] = {'R','e','O','p','e','n','F','i','l','e','\0'};
|
||||
+ WCHAR temp_path[MAX_PATH], test_path[MAX_PATH];
|
||||
+ HANDLE file, h;
|
||||
+ DWORD count;
|
||||
+ UINT ret;
|
||||
+
|
||||
+ if (!pReOpenFile)
|
||||
+ {
|
||||
+ win_skip("ReOpenFile is missing\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* Test calling with invalid handle */
|
||||
+ SetLastError(0xcafecafe);
|
||||
+ h = pReOpenFile(0xfafa, GENERIC_WRITE, FILE_SHARE_WRITE, FILE_FLAG_DELETE_ON_CLOSE);
|
||||
+ ok(h == INVALID_HANDLE_VALUE, "Expected INVALID_HANDLE_VALUE, got %u\n", h);
|
||||
+ ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %u\n", GetLastError());
|
||||
+
|
||||
+ count = GetTempPathW(MAX_PATH, temp_path);
|
||||
+ ok(count, "Failed to get temp path, error %u\n", GetLastError());
|
||||
+ ret = GetTempFileNameW(temp_path, prefix, 0, test_path);
|
||||
+ ok(ret != 0, "GetTempFileNameW error %u\n", GetLastError());
|
||||
+
|
||||
+ file = CreateFileW(test_path, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
|
||||
+ CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
+ ok(file != INVALID_HANDLE_VALUE, "CreateFileW error %u\n", GetLastError());
|
||||
+ trace("Created file %s\n", wine_dbgstr_w(test_path));
|
||||
+
|
||||
+ SetLastError(0xcafecafe);
|
||||
+ h = pReOpenFile(file, GENERIC_WRITE, FILE_SHARE_WRITE, FILE_ATTRIBUTE_NORMAL);
|
||||
+ ok(h == INVALID_HANDLE_VALUE, "ReOpenFile returned unexpected handle %u\n",h);
|
||||
+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
|
||||
+
|
||||
+ /* Logos Bible calls ReOpenFile with flags being 0, what Flags/Attributes is that?????? */
|
||||
+ SetLastError(0xcafecafe);
|
||||
+ h = pReOpenFile(file, GENERIC_WRITE, FILE_SHARE_WRITE, 0);
|
||||
+ ok(h != INVALID_HANDLE_VALUE, "ReOpenFile returned unexpected INVALID_HANDLE_VALUE\n");
|
||||
+ ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", GetLastError());
|
||||
+
|
||||
+ CloseHandle(file);
|
||||
+}
|
||||
+
|
||||
static void test_WriteFileGather(void)
|
||||
{
|
||||
char temp_path[MAX_PATH], filename[MAX_PATH];
|
||||
@@ -5469,6 +5515,7 @@ START_TEST(file)
|
||||
test_RemoveDirectory();
|
||||
test_ReplaceFileA();
|
||||
test_ReplaceFileW();
|
||||
+ test_ReOpenFile();
|
||||
test_GetFileInformationByHandleEx();
|
||||
test_OpenFileById();
|
||||
test_SetFileValidData();
|
||||
diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c
|
||||
index aa2ebfcc69..5139913b8b 100644
|
||||
--- a/dlls/kernelbase/file.c
|
||||
+++ b/dlls/kernelbase/file.c
|
||||
@@ -43,6 +43,8 @@
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(file);
|
||||
|
||||
+extern DWORD WINAPI GetFinalPathNameByHandleW(HANDLE,LPWSTR,DWORD,DWORD);
|
||||
+
|
||||
const WCHAR windows_dir[] = {'C',':','\\','w','i','n','d','o','w','s',0};
|
||||
const WCHAR system_dir[] = {'C',':','\\','w','i','n','d','o','w','s','\\','s','y','s','t','e','m','3','2',0};
|
||||
|
||||
@@ -2127,8 +2129,33 @@ HANDLE WINAPI DECLSPEC_HOTPATCH OpenFileById( HANDLE handle, LPFILE_ID_DESCRIPTO
|
||||
*/
|
||||
HANDLE WINAPI /* DECLSPEC_HOTPATCH */ ReOpenFile( HANDLE handle, DWORD access, DWORD sharing, DWORD flags )
|
||||
{
|
||||
- FIXME( "(%p, %d, %d, %d): stub\n", handle, access, sharing, flags );
|
||||
- return INVALID_HANDLE_VALUE;
|
||||
+ WCHAR name[MAX_PATH];
|
||||
+ DWORD size = MAX_PATH;
|
||||
+ HANDLE h;
|
||||
+ DWORD ret;
|
||||
+ DWORD mask = 0xFFFFF;
|
||||
+
|
||||
+ FIXME("(%p, %d, %d, %d): mostly stub\n", handle, access, sharing, flags);
|
||||
+
|
||||
+ if(flags & mask) /* FILE_ATTRIBUTE_* flags are invalid */
|
||||
+ {
|
||||
+ SetLastError(ERROR_INVALID_PARAMETER);
|
||||
+ return INVALID_HANDLE_VALUE;
|
||||
+ }
|
||||
+
|
||||
+ ret = GetFinalPathNameByHandleW(handle, name, size, VOLUME_NAME_DOS);
|
||||
+
|
||||
+ if(ret)
|
||||
+ TRACE("Trying to reopen file %s\n", debugstr_w(name));
|
||||
+ else
|
||||
+ {
|
||||
+ SetLastError(ERROR_INVALID_HANDLE);
|
||||
+ return INVALID_HANDLE_VALUE;
|
||||
+ }
|
||||
+
|
||||
+ h = CreateFileW(name, access, sharing, NULL, OPEN_EXISTING, flags, NULL);
|
||||
+
|
||||
+ return h;
|
||||
}
|
||||
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
1
patches/kernelbase-ReOpenFile/definition
Normal file
1
patches/kernelbase-ReOpenFile/definition
Normal file
@ -0,0 +1 @@
|
||||
Fixes: [47668 ] kernelbase: Improve stub for ReOpenFile and add small test
|
@ -163,6 +163,7 @@ patch_enable_all ()
|
||||
enable_kernel32_Processor_Group="$1"
|
||||
enable_kernel32_SCSI_Sysfs="$1"
|
||||
enable_kernel32_SetProcessDEPPolicy="$1"
|
||||
enable_kernelbase_ReOpenFile="$1"
|
||||
enable_krnl386_exe16_GDT_LDT_Emulation="$1"
|
||||
enable_krnl386_exe16_Invalid_Console_Handles="$1"
|
||||
enable_libs_Debug_Channel="$1"
|
||||
@ -611,6 +612,9 @@ patch_enable ()
|
||||
kernel32-SetProcessDEPPolicy)
|
||||
enable_kernel32_SetProcessDEPPolicy="$2"
|
||||
;;
|
||||
kernelbase-ReOpenFile)
|
||||
enable_kernelbase_ReOpenFile="$2"
|
||||
;;
|
||||
krnl386.exe16-GDT_LDT_Emulation)
|
||||
enable_krnl386_exe16_GDT_LDT_Emulation="$2"
|
||||
;;
|
||||
@ -4292,6 +4296,21 @@ if test "$enable_kernel32_SetProcessDEPPolicy" -eq 1; then
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset kernelbase-ReOpenFile
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
# | * [#47668] kernelbase: Improve stub for ReOpenFile and add small test
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/kernel32/tests/file.c, dlls/kernelbase/file.c
|
||||
# |
|
||||
if test "$enable_kernelbase_ReOpenFile" -eq 1; then
|
||||
patch_apply kernelbase-ReOpenFile/0001-kernelbase-Improve-stub-for-ReOpenFile-and-add-small.patch
|
||||
(
|
||||
printf '%s\n' '+ { "Louis Lenders", "kernelbase: Improve stub for ReOpenFile and add small test.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset krnl386.exe16-GDT_LDT_Emulation
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
|
Loading…
x
Reference in New Issue
Block a user