mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-01-28 22:04:43 -08:00
Rebase against 0cb79db12ac7c48477518dcff269ccc5d6b745e0
This commit is contained in:
parent
d0190e3ade
commit
8f56ffcf57
@ -1,100 +0,0 @@
|
||||
From 679a02527fb9051d20940072ab49cc1fa3fc7319 Mon Sep 17 00:00:00 2001
|
||||
From: Brock York <twunknown@gmail.com>
|
||||
Date: Wed, 3 Apr 2019 17:00:22 +1100
|
||||
Subject: [PATCH] kernel32: Correct ReplaceFileW behaviour
|
||||
|
||||
ReplaceFileW should fail with ERROR_ACCESS_DENIED when either the replaced
|
||||
or replacement file is set to read only using SetFileAttributes.
|
||||
Testing for the return values of ReplaceFileW was performed on a
|
||||
Windows XP SP3 and Windows 10 vm.
|
||||
|
||||
Open replaced file without GENERIC_WRITE flag if a sharing violation is
|
||||
returned on the first call checking for the READ_ONLY attribute.
|
||||
ReplaceFileW should not fail when called to replace the current executable which
|
||||
is the case as tested on Windows 7, 10 and XP this is because the
|
||||
"replaced" file is opened with the GENERIC_WRITE flag.
|
||||
The MSDN also mentions that the replaced file is only opened with
|
||||
GENERIC_READ, DELETE and SYNCHRONIZE.
|
||||
|
||||
This patch will fix the following bug once it is
|
||||
merged into Wine-Staging as the WarFrame launcher
|
||||
requires patches from Wine-Staging to work.
|
||||
|
||||
Wine-Bug:https://bugs.winehq.org/show_bug.cgi?id=33845
|
||||
---
|
||||
dlls/kernel32/file.c | 15 +++++++++++++--
|
||||
dlls/kernel32/tests/file.c | 4 ++--
|
||||
2 files changed, 15 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c
|
||||
index a5c34fae12a..cc22a175fb5 100644
|
||||
--- a/dlls/kernel32/file.c
|
||||
+++ b/dlls/kernel32/file.c
|
||||
@@ -1772,7 +1772,7 @@ BOOL WINAPI ReplaceFileW(LPCWSTR lpReplacedFileName, LPCWSTR lpReplacementFileNa
|
||||
attr.SecurityDescriptor = NULL;
|
||||
attr.SecurityQualityOfService = NULL;
|
||||
|
||||
- /* 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;
|
||||
@@ -1784,6 +1784,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);
|
||||
if (status == STATUS_SUCCESS)
|
||||
status = wine_nt_to_unix_file_name(&nt_replaced_name, &unix_replaced_name, replaced_flags, FALSE);
|
||||
RtlFreeUnicodeString(&nt_replaced_name);
|
||||
@@ -1791,6 +1797,8 @@ BOOL WINAPI ReplaceFileW(LPCWSTR lpReplacedFileName, LPCWSTR lpReplacementFileNa
|
||||
{
|
||||
if (status == STATUS_OBJECT_NAME_NOT_FOUND)
|
||||
error = ERROR_FILE_NOT_FOUND;
|
||||
+ else if (status == STATUS_ACCESS_DENIED)
|
||||
+ error = ERROR_ACCESS_DENIED;
|
||||
else
|
||||
error = ERROR_UNABLE_TO_REMOVE_REPLACED;
|
||||
goto fail;
|
||||
@@ -1815,7 +1823,10 @@ BOOL WINAPI ReplaceFileW(LPCWSTR lpReplacedFileName, LPCWSTR lpReplacementFileNa
|
||||
RtlFreeUnicodeString(&nt_replacement_name);
|
||||
if (status != STATUS_SUCCESS)
|
||||
{
|
||||
- error = RtlNtStatusToDosError(status);
|
||||
+ if (status == STATUS_ACCESS_DENIED)
|
||||
+ error = ERROR_ACCESS_DENIED;
|
||||
+ else
|
||||
+ error = RtlNtStatusToDosError(status);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
|
||||
index 3354bacf967..fb2440e0379 100644
|
||||
--- a/dlls/kernel32/tests/file.c
|
||||
+++ b/dlls/kernel32/tests/file.c
|
||||
@@ -3781,7 +3781,7 @@ static void test_ReplaceFileA(void)
|
||||
*/
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = pReplaceFileA(replaced, replacement, backup, 0, 0, 0);
|
||||
- todo_wine ok(ret == 0 && GetLastError() == ERROR_ACCESS_DENIED, "ReplaceFileA: unexpected error %d\n", GetLastError());
|
||||
+ ok(ret == 0 && GetLastError() == ERROR_ACCESS_DENIED, "ReplaceFileA: unexpected error %d\n", GetLastError());
|
||||
/* make sure that the replacement file still exists */
|
||||
hReplacementFile = CreateFileA(replacement, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
|
||||
ok(hReplacementFile != INVALID_HANDLE_VALUE ||
|
||||
@@ -3813,7 +3813,7 @@ static void test_ReplaceFileA(void)
|
||||
"unexpected error, replaced file should be able to be opened %d\n", GetLastError());
|
||||
/*Calling ReplaceFileA on an exe should succeed*/
|
||||
ret = pReplaceFileA(replaced, replacement, NULL, 0, 0, 0);
|
||||
- todo_wine ok(ret, "ReplaceFileA: unexpected error %d\n", GetLastError());
|
||||
+ ok(ret, "ReplaceFileA: unexpected error %d\n", GetLastError());
|
||||
CloseHandle(hReplacedFile);
|
||||
|
||||
/* replacement file still exists, make pass w/o "replaced" */
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,3 +0,0 @@
|
||||
# Reference
|
||||
# https://www.winehq.org/pipermail/wine-devel/2018-October/133068.html
|
||||
Fixes: [33845] kernel32: Correct ReplaceFileW behaviour for warframe
|
@ -1,16 +1,16 @@
|
||||
From 524983ccd0ecbca845c0d54688b64e729fff9ed3 Mon Sep 17 00:00:00 2001
|
||||
From b68ba9df8489f913125e1aaaaf1203986f1ff346 Mon Sep 17 00:00:00 2001
|
||||
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
|
||||
Date: Thu, 16 Jan 2014 20:56:49 -0700
|
||||
Subject: [PATCH] ntdll: Add support for junction point creation.
|
||||
|
||||
---
|
||||
dlls/ntdll/file.c | 91 +++++++++++++++++++++++++++++++++++++++
|
||||
dlls/ntdll/tests/file.c | 94 +++++++++++++++++++++++++++++++++++++++++
|
||||
include/ddk/ntifs.h | 26 ++++++++++++
|
||||
dlls/ntdll/file.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++
|
||||
dlls/ntdll/tests/file.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
include/ddk/ntifs.h | 26 ++++++++++++++
|
||||
3 files changed, 211 insertions(+)
|
||||
|
||||
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
|
||||
index 1a935430..7e5ab211 100644
|
||||
index c1de955..c1075cf 100644
|
||||
--- a/dlls/ntdll/file.c
|
||||
+++ b/dlls/ntdll/file.c
|
||||
@@ -108,12 +108,14 @@
|
||||
@ -28,7 +28,7 @@ index 1a935430..7e5ab211 100644
|
||||
#define SECSPERDAY 86400
|
||||
#define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)
|
||||
|
||||
@@ -1645,6 +1647,76 @@ NTSTATUS WINAPI NtDeviceIoControlFile(HANDLE handle, HANDLE event,
|
||||
@@ -1746,6 +1748,76 @@ NTSTATUS WINAPI NtDeviceIoControlFile(HANDLE handle, HANDLE event,
|
||||
}
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ index 1a935430..7e5ab211 100644
|
||||
/**************************************************************************
|
||||
* NtFsControlFile [NTDLL.@]
|
||||
* ZwFsControlFile [NTDLL.@]
|
||||
@@ -1724,11 +1796,30 @@ NTSTATUS WINAPI NtFsControlFile(HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc
|
||||
@@ -1825,11 +1897,30 @@ NTSTATUS WINAPI NtFsControlFile(HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -137,7 +137,7 @@ index 1a935430..7e5ab211 100644
|
||||
return server_ioctl_file( handle, event, apc, apc_context, io, code,
|
||||
in_buffer, in_size, out_buffer, out_size );
|
||||
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
|
||||
index 45c8ef0f..167463dc 100644
|
||||
index 74adf4c..ed3ddea 100644
|
||||
--- a/dlls/ntdll/tests/file.c
|
||||
+++ b/dlls/ntdll/tests/file.c
|
||||
@@ -38,6 +38,7 @@
|
||||
@ -148,7 +148,7 @@ index 45c8ef0f..167463dc 100644
|
||||
|
||||
#ifndef IO_COMPLETION_ALL_ACCESS
|
||||
#define IO_COMPLETION_ALL_ACCESS 0x001F0003
|
||||
@@ -4767,6 +4768,98 @@ static void test_query_ea(void)
|
||||
@@ -4982,6 +4983,98 @@ static void test_query_ea(void)
|
||||
#undef EA_BUFFER_SIZE
|
||||
}
|
||||
|
||||
@ -244,17 +244,17 @@ index 45c8ef0f..167463dc 100644
|
||||
+ RemoveDirectoryW(path);
|
||||
+}
|
||||
+
|
||||
START_TEST(file)
|
||||
static void test_file_readonly_access(void)
|
||||
{
|
||||
HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
|
||||
@@ -4837,4 +4930,5 @@ START_TEST(file)
|
||||
static const DWORD default_sharing = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
|
||||
@@ -5122,4 +5215,5 @@ START_TEST(file)
|
||||
test_ioctl();
|
||||
test_flush_buffers_file();
|
||||
test_query_ea();
|
||||
+ test_junction_points();
|
||||
}
|
||||
diff --git a/include/ddk/ntifs.h b/include/ddk/ntifs.h
|
||||
index abe357fb..3cba319d 100644
|
||||
index abe357f..3cba319 100644
|
||||
--- a/include/ddk/ntifs.h
|
||||
+++ b/include/ddk/ntifs.h
|
||||
@@ -133,4 +133,30 @@ BOOLEAN WINAPI FsRtlIsNameInExpression(PUNICODE_STRING, PUNICODE_STRING, BOOLEAN
|
||||
@ -289,5 +289,5 @@ index abe357fb..3cba319d 100644
|
||||
+
|
||||
#endif
|
||||
--
|
||||
2.20.1
|
||||
1.9.1
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 89af577ac4db5a48ed30bcf06703a2e7ef05fa7a Mon Sep 17 00:00:00 2001
|
||||
From 7d5dfe000f83054692b919a07f60869bd350be83 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Sat, 6 Jun 2015 07:03:33 +0800
|
||||
Subject: [PATCH] ntdll: Improve stub of NtQueryEaFile.
|
||||
@ -10,10 +10,10 @@ Based on a patch by Qian Hong.
|
||||
2 files changed, 98 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
|
||||
index a2cc839..4c7f1b2 100644
|
||||
index 7c4eb91..c1de955 100644
|
||||
--- a/dlls/ntdll/file.c
|
||||
+++ b/dlls/ntdll/file.c
|
||||
@@ -3415,14 +3415,25 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile( HANDLE handle, PIO_STATUS_BLOCK io
|
||||
@@ -3426,14 +3426,25 @@ NTSTATUS WINAPI NtQueryVolumeInformationFile( HANDLE handle, PIO_STATUS_BLOCK io
|
||||
* Success: 0. Atrributes read into buffer
|
||||
* Failure: An NTSTATUS error code describing the error.
|
||||
*/
|
||||
@ -44,7 +44,7 @@ index a2cc839..4c7f1b2 100644
|
||||
|
||||
|
||||
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
|
||||
index 7554187..e9a0d79 100644
|
||||
index 8f986f6..74adf4c 100644
|
||||
--- a/dlls/ntdll/tests/file.c
|
||||
+++ b/dlls/ntdll/tests/file.c
|
||||
@@ -84,6 +84,7 @@ static NTSTATUS (WINAPI *pNtQueryDirectoryFile)(HANDLE,HANDLE,PIO_APC_ROUTINE,PV
|
||||
@ -55,7 +55,7 @@ index 7554187..e9a0d79 100644
|
||||
|
||||
static WCHAR fooW[] = {'f','o','o',0};
|
||||
|
||||
@@ -4796,6 +4797,86 @@ static void test_flush_buffers_file(void)
|
||||
@@ -4901,6 +4902,86 @@ static void test_flush_buffers_file(void)
|
||||
DeleteFileA(buffer);
|
||||
}
|
||||
|
||||
@ -139,10 +139,10 @@ index 7554187..e9a0d79 100644
|
||||
+ #undef EA_BUFFER_SIZE
|
||||
+}
|
||||
+
|
||||
START_TEST(file)
|
||||
static void test_file_readonly_access(void)
|
||||
{
|
||||
HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
|
||||
@@ -4836,6 +4917,7 @@ START_TEST(file)
|
||||
static const DWORD default_sharing = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
|
||||
@@ -5009,6 +5090,7 @@ START_TEST(file)
|
||||
pNtQueryVolumeInformationFile = (void *)GetProcAddress(hntdll, "NtQueryVolumeInformationFile");
|
||||
pNtQueryFullAttributesFile = (void *)GetProcAddress(hntdll, "NtQueryFullAttributesFile");
|
||||
pNtFlushBuffersFile = (void *)GetProcAddress(hntdll, "NtFlushBuffersFile");
|
||||
@ -150,7 +150,7 @@ index 7554187..e9a0d79 100644
|
||||
|
||||
test_read_write();
|
||||
test_NtCreateFile();
|
||||
@@ -4865,4 +4947,5 @@ START_TEST(file)
|
||||
@@ -5039,4 +5121,5 @@ START_TEST(file)
|
||||
test_query_attribute_information_file();
|
||||
test_ioctl();
|
||||
test_flush_buffers_file();
|
||||
|
@ -52,7 +52,7 @@ usage()
|
||||
# Get the upstream commit sha
|
||||
upstream_commit()
|
||||
{
|
||||
echo "0652a2ccc967c6d1ca04c67f58112ff491ab9a62"
|
||||
echo "0cb79db12ac7c48477518dcff269ccc5d6b745e0"
|
||||
}
|
||||
|
||||
# Show version information
|
||||
@ -167,7 +167,6 @@ patch_enable_all ()
|
||||
enable_kernel32_NeedCurrentDirectoryForExePath="$1"
|
||||
enable_kernel32_PE_Loader_Fixes="$1"
|
||||
enable_kernel32_Processor_Group="$1"
|
||||
enable_kernel32_ReplaceFileW="$1"
|
||||
enable_kernel32_SCSI_Sysfs="$1"
|
||||
enable_krnl386_exe16_GDT_LDT_Emulation="$1"
|
||||
enable_krnl386_exe16_Invalid_Console_Handles="$1"
|
||||
@ -642,9 +641,6 @@ patch_enable ()
|
||||
kernel32-Processor_Group)
|
||||
enable_kernel32_Processor_Group="$2"
|
||||
;;
|
||||
kernel32-ReplaceFileW)
|
||||
enable_kernel32_ReplaceFileW="$2"
|
||||
;;
|
||||
kernel32-SCSI_Sysfs)
|
||||
enable_kernel32_SCSI_Sysfs="$2"
|
||||
;;
|
||||
@ -4353,21 +4349,6 @@ if test "$enable_kernel32_Processor_Group" -eq 1; then
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset kernel32-ReplaceFileW
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
# | * [#33845] kernel32: Correct ReplaceFileW behaviour for warframe
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/kernel32/file.c, dlls/kernel32/tests/file.c
|
||||
# |
|
||||
if test "$enable_kernel32_ReplaceFileW" -eq 1; then
|
||||
patch_apply kernel32-ReplaceFileW/0001-kernel32-Correct-ReplaceFileW-behaviour.patch
|
||||
(
|
||||
printf '%s\n' '+ { "Brock York", "kernel32: Correct ReplaceFileW behaviour.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset kernel32-SCSI_Sysfs
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
@ -7392,7 +7373,7 @@ fi
|
||||
# | * [#18517] Improve eraser from working.
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/winex11.drv/wintab.c, dlls/wintab32/context.c, dlls/wintab32/tests/Makefile.in, dlls/wintab32/tests/context.c
|
||||
# | * dlls/winex11.drv/wintab.c, dlls/wintab32/context.c
|
||||
# |
|
||||
if test "$enable_wintab32_improvements" -eq 1; then
|
||||
patch_apply wintab32-improvements/0002-wintab32-Set-lcSysExtX-Y-for-the-first-index-of-WTI_.patch
|
||||
@ -7400,14 +7381,12 @@ if test "$enable_wintab32_improvements" -eq 1; then
|
||||
patch_apply wintab32-improvements/0004-winex11.drv-Support-multiplex-categories-WTI_DSCTXS-.patch
|
||||
patch_apply wintab32-improvements/0005-winex11-Support-WTI_STATUS-in-WTInfo.patch
|
||||
patch_apply wintab32-improvements/0006-wintab32-Scale-NormalPressure-before-sending-to-the-.patch
|
||||
patch_apply wintab32-improvements/0007-wintab32-tests-Initial-interactive-test.patch
|
||||
(
|
||||
printf '%s\n' '+ { "Alistair Leslie-Hughes", "wintab32: Set lcSysExtX/Y for the first index of WTI_DDCTXS.", 1 },';
|
||||
printf '%s\n' '+ { "Alistair Leslie-Hughes", "winex11: Handle negative orAltitude values.", 1 },';
|
||||
printf '%s\n' '+ { "Alistair Leslie-Hughes", "winex11.drv: Support multiplex categories WTI_DSCTXS and WTI_DDCTXS.", 1 },';
|
||||
printf '%s\n' '+ { "Alistair Leslie-Hughes", "winex11: Support WTI_STATUS in WTInfo.", 1 },';
|
||||
printf '%s\n' '+ { "Alistair Leslie-Hughes", "wintab32: Scale NormalPressure before sending to the client.", 1 },';
|
||||
printf '%s\n' '+ { "Alistair Leslie-Hughes", "wintab32/tests: Initial interactive test.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
|
@ -1,297 +0,0 @@
|
||||
From 47421c170433df8172083dc2d0187bd9426ba3ee Mon Sep 17 00:00:00 2001
|
||||
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
||||
Date: Tue, 2 Apr 2019 12:25:57 +1100
|
||||
Subject: [PATCH] wintab32/tests: Initial interactive test
|
||||
|
||||
This is a work in progress test when using a stylus.
|
||||
- Should display all information from the packet.
|
||||
- Cleanup of variable naming.
|
||||
|
||||
---
|
||||
dlls/wintab32/tests/Makefile.in | 2 +-
|
||||
dlls/wintab32/tests/context.c | 195 ++++++++++++++++++++++++++++++--
|
||||
2 files changed, 184 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/dlls/wintab32/tests/Makefile.in b/dlls/wintab32/tests/Makefile.in
|
||||
index 635e03fd5d6..ad63c27b5d1 100644
|
||||
--- a/dlls/wintab32/tests/Makefile.in
|
||||
+++ b/dlls/wintab32/tests/Makefile.in
|
||||
@@ -1,5 +1,5 @@
|
||||
TESTDLL = wintab32.dll
|
||||
-IMPORTS = user32
|
||||
+IMPORTS = user32 gdi32
|
||||
|
||||
C_SRCS = \
|
||||
context.c
|
||||
diff --git a/dlls/wintab32/tests/context.c b/dlls/wintab32/tests/context.c
|
||||
index 5f059127657..b77e6c546a9 100644
|
||||
--- a/dlls/wintab32/tests/context.c
|
||||
+++ b/dlls/wintab32/tests/context.c
|
||||
@@ -21,6 +21,11 @@
|
||||
#include <assert.h>
|
||||
#include <windows.h>
|
||||
#include <wintab.h>
|
||||
+#include <stdio.h>
|
||||
+
|
||||
+#define PACKETDATA (PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE)
|
||||
+#define PACKETMODE PK_BUTTONS
|
||||
+#include "pktdef.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
@@ -29,11 +34,19 @@ static const CHAR wintabTestWindowClassName[] = "WintabTestWnd";
|
||||
static const CHAR contextName[] = "TestContext";
|
||||
static const UINT X = 0;
|
||||
static const UINT Y = 0;
|
||||
-static const UINT WIDTH = 200;
|
||||
-static const UINT HEIGHT = 200;
|
||||
+static const UINT WIDTH = 640;
|
||||
+static const UINT HEIGHT = 480;
|
||||
+
|
||||
+static LOGCONTEXTA glogContext;
|
||||
+static HCTX hCtx = NULL;
|
||||
|
||||
-static HCTX (WINAPI *pWTOpenA)(HWND, LPLOGCONTEXTA, BOOL);
|
||||
static BOOL (WINAPI *pWTClose)(HCTX);
|
||||
+static BOOL (WINAPI *pWTEnable)(HCTX, BOOL);
|
||||
+static UINT (WINAPI *pWTInfoA)(UINT, UINT, void*);
|
||||
+static HCTX (WINAPI *pWTOpenA)(HWND, LPLOGCONTEXTA, BOOL);
|
||||
+static BOOL (WINAPI *pWTOverlap)(HCTX, BOOL);
|
||||
+static BOOL (WINAPI *pWTPacket)(HCTX, UINT, void*);
|
||||
+
|
||||
|
||||
static HMODULE load_functions(void)
|
||||
{
|
||||
@@ -49,8 +62,12 @@ static HMODULE load_functions(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- if (GET_PROC(WTOpenA) &&
|
||||
- GET_PROC(WTClose) )
|
||||
+ if (GET_PROC(WTClose) &&
|
||||
+ GET_PROC(WTEnable) &&
|
||||
+ GET_PROC(WTInfoA) &&
|
||||
+ GET_PROC(WTOpenA) &&
|
||||
+ GET_PROC(WTOverlap) &&
|
||||
+ GET_PROC(WTPacket) )
|
||||
{
|
||||
return hWintab;
|
||||
}
|
||||
@@ -70,7 +87,7 @@ static LRESULT CALLBACK wintabTestWndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
return DefWindowProcA(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
-static void wintab_create_window(HWND* pHwnd)
|
||||
+static void wintab_create_window(HWND* pHwnd, WNDPROC wndproc)
|
||||
{
|
||||
WNDCLASSA testWindowClass;
|
||||
|
||||
@@ -80,18 +97,18 @@ static void wintab_create_window(HWND* pHwnd)
|
||||
|
||||
ZeroMemory(&testWindowClass, sizeof(testWindowClass));
|
||||
|
||||
- testWindowClass.lpfnWndProc = wintabTestWndProc;
|
||||
+ testWindowClass.lpfnWndProc = wndproc;
|
||||
testWindowClass.hInstance = NULL;
|
||||
testWindowClass.hIcon = NULL;
|
||||
testWindowClass.hCursor = NULL;
|
||||
- testWindowClass.hbrBackground = NULL;
|
||||
+ testWindowClass.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE + 1);;
|
||||
testWindowClass.lpszMenuName = NULL;
|
||||
testWindowClass.lpszClassName = wintabTestWindowClassName;
|
||||
|
||||
assert(RegisterClassA(&testWindowClass));
|
||||
|
||||
*pHwnd = CreateWindowA(wintabTestWindowClassName, NULL,
|
||||
- WS_OVERLAPPED, X, Y, WIDTH, HEIGHT, NULL, NULL,
|
||||
+ WS_OVERLAPPEDWINDOW, X, Y, WIDTH, HEIGHT, NULL, NULL,
|
||||
NULL, NULL);
|
||||
|
||||
assert(*pHwnd != NULL);
|
||||
@@ -106,13 +123,12 @@ static void wintab_destroy_window(HWND hwnd)
|
||||
/* test how a logcontext is validated by wtopen */
|
||||
static void test_WTOpenContextValidation(void)
|
||||
{
|
||||
- HWND defaultWindow = NULL;
|
||||
- HCTX hCtx = NULL;
|
||||
+ HWND defaultWindow = NULL;
|
||||
LOGCONTEXTA testLogCtx;
|
||||
LOGCONTEXTA refLogCtx;
|
||||
int memdiff;
|
||||
|
||||
- wintab_create_window(&defaultWindow);
|
||||
+ wintab_create_window(&defaultWindow, wintabTestWndProc);
|
||||
|
||||
ZeroMemory(&testLogCtx, sizeof(testLogCtx));
|
||||
strcpy(testLogCtx.lcName, contextName);
|
||||
@@ -135,6 +151,158 @@ static void test_WTOpenContextValidation(void)
|
||||
wintab_destroy_window(defaultWindow);
|
||||
}
|
||||
|
||||
+static HCTX initial_tablet(HWND hwnd)
|
||||
+{
|
||||
+ HCTX hctx = NULL;
|
||||
+ UINT wWTInfoRetVal = 0;
|
||||
+ AXIS TabletX = {0};
|
||||
+ AXIS TabletY = {0};
|
||||
+ AXIS value = {0};
|
||||
+
|
||||
+ glogContext.lcOptions |= CXO_SYSTEM;
|
||||
+
|
||||
+ /* Open default system context so that we can get tablet data in screen coordinates (not tablet coordinates). */
|
||||
+ wWTInfoRetVal = pWTInfoA(WTI_DEFSYSCTX, 0, &glogContext);
|
||||
+ ok(wWTInfoRetVal == sizeof( LOGCONTEXTA ), "incorrect size\n" );
|
||||
+ ok(glogContext.lcOptions & CXO_SYSTEM, "Wrong options 0x%08x\n", glogContext.lcOptions);
|
||||
+
|
||||
+ /*wsprintf(glogContext.lcName, "PrsTest Digitizing %x", hInst);*/
|
||||
+
|
||||
+ glogContext.lcOptions |= CXO_MESSAGES; /* We want WT_PACKET messages. */
|
||||
+ glogContext.lcPktData = PACKETDATA;
|
||||
+ glogContext.lcPktMode = PACKETMODE;
|
||||
+ glogContext.lcMoveMask = PACKETDATA;
|
||||
+ glogContext.lcBtnUpMask = glogContext.lcBtnDnMask;
|
||||
+
|
||||
+ wWTInfoRetVal = pWTInfoA( WTI_DEVICES, DVC_X, &TabletX );
|
||||
+ ok(wWTInfoRetVal == sizeof( AXIS ), "Wrong DVC_X size %d\n", wWTInfoRetVal);
|
||||
+
|
||||
+ wWTInfoRetVal = pWTInfoA( WTI_DEVICES, DVC_Y, &TabletY );
|
||||
+ ok(wWTInfoRetVal == sizeof( AXIS ), "Wrong DVC_Y size %d\n", wWTInfoRetVal);
|
||||
+
|
||||
+ wWTInfoRetVal = pWTInfoA( WTI_DEVICES, DVC_NPRESSURE, &value );
|
||||
+ ok(wWTInfoRetVal == sizeof( AXIS ), "Wrong DVC_NPRESSURE, size %d\n", wWTInfoRetVal);
|
||||
+ ok(0, "DVC_NPRESSURE = %d, %d, %d\n", value.axMin, value.axMax, value.axUnits);
|
||||
+
|
||||
+ glogContext.lcInOrgX = 0;
|
||||
+ glogContext.lcInOrgY = 0;
|
||||
+ glogContext.lcInExtX = TabletX.axMax;
|
||||
+ glogContext.lcInExtY = TabletY.axMax;
|
||||
+
|
||||
+ /* Guarantee the output coordinate space to be in screen coordinates. */
|
||||
+ glogContext.lcOutOrgX = GetSystemMetrics( SM_XVIRTUALSCREEN );
|
||||
+ glogContext.lcOutOrgY = GetSystemMetrics( SM_YVIRTUALSCREEN );
|
||||
+ glogContext.lcOutExtX = GetSystemMetrics( SM_CXVIRTUALSCREEN );
|
||||
+
|
||||
+ /* In Wintab, the tablet origin is lower left. Move origin to upper left
|
||||
+ so that it coincides with screen origin. */
|
||||
+ glogContext.lcOutExtY = -GetSystemMetrics( SM_CYVIRTUALSCREEN );
|
||||
+
|
||||
+ hctx = pWTOpenA( hwnd, &glogContext, FALSE );
|
||||
+
|
||||
+ return hctx;
|
||||
+}
|
||||
+
|
||||
+static LRESULT CALLBACK wintabInteractiveWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
+{
|
||||
+ static POINT ptOld, ptNew;
|
||||
+ static UINT prsOld, prsNew;
|
||||
+ PACKET pkt;
|
||||
+ static RECT rcClient;
|
||||
+ PAINTSTRUCT psPaint;
|
||||
+ HDC hdc;
|
||||
+
|
||||
+ switch (msg)
|
||||
+ {
|
||||
+ case WM_CREATE:
|
||||
+ hCtx = initial_tablet(hwnd);
|
||||
+ break;
|
||||
+ case WM_DESTROY:
|
||||
+ if (hCtx)
|
||||
+ pWTClose(hCtx);
|
||||
+ PostQuitMessage(0);
|
||||
+ break;
|
||||
+ case WM_PAINT:
|
||||
+ if ( (hdc = BeginPaint(hwnd, &psPaint)) )
|
||||
+ {
|
||||
+ RECT clientRect;
|
||||
+ char buffer[1024];
|
||||
+
|
||||
+ GetClientRect(hwnd, &clientRect);
|
||||
+ if(!hCtx)
|
||||
+ {
|
||||
+ DrawTextA(hdc, "No Tablet", -1, &clientRect, 0);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ POINT scrPoint = {ptNew.x, ptNew.y};
|
||||
+
|
||||
+ ScreenToClient(hwnd, &scrPoint);
|
||||
+
|
||||
+ sprintf( buffer, "%d,%d, pressure %d", ptNew.x, ptNew.y, prsNew );
|
||||
+ DrawTextA(hdc, buffer, -1, &clientRect, 0);
|
||||
+
|
||||
+ PatBlt(hdc, rcClient.left, scrPoint.y, rcClient.right, 1, DSTINVERT);
|
||||
+ PatBlt(hdc, scrPoint.x, rcClient.top, 1, rcClient.bottom, DSTINVERT);
|
||||
+ Ellipse(hdc, scrPoint.x - prsNew, scrPoint.y - prsNew, scrPoint.x + prsNew, scrPoint.y + prsNew);
|
||||
+ EndPaint(hwnd, &psPaint);
|
||||
+ }
|
||||
+ }
|
||||
+ break;
|
||||
+ case WT_PACKET:
|
||||
+ {
|
||||
+ if (pWTPacket((HCTX)lParam, wParam, &pkt))
|
||||
+ {
|
||||
+ ptOld = ptNew;
|
||||
+ prsOld = prsNew;
|
||||
+
|
||||
+ ptNew.x = pkt.pkX;
|
||||
+ ptNew.y = pkt.pkY;
|
||||
+
|
||||
+ prsNew = pkt.pkNormalPressure;
|
||||
+
|
||||
+ if (ptNew.x != ptOld.x || ptNew.y != ptOld.y || prsNew != prsOld)
|
||||
+ InvalidateRect(hwnd, NULL, TRUE);
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ case WM_ACTIVATE:
|
||||
+ if (LOWORD(wParam))
|
||||
+ {
|
||||
+ InvalidateRect(hwnd, NULL, TRUE);
|
||||
+ }
|
||||
+
|
||||
+ /* if switching in the middle, disable the region */
|
||||
+ if (hCtx)
|
||||
+ {
|
||||
+ pWTEnable(hCtx, LOWORD(wParam));
|
||||
+ if (hCtx && LOWORD(wParam))
|
||||
+ {
|
||||
+ pWTOverlap(hCtx, TRUE);
|
||||
+ }
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ return DefWindowProcA(hwnd, msg, wParam, lParam);
|
||||
+}
|
||||
+
|
||||
+static void test_interactive(void)
|
||||
+{
|
||||
+ HWND defaultWindow = NULL;
|
||||
+ MSG msg;
|
||||
+
|
||||
+ wintab_create_window(&defaultWindow, wintabInteractiveWndProc);
|
||||
+ ShowWindow(defaultWindow, SW_SHOW);
|
||||
+
|
||||
+ while (GetMessageA(&msg, NULL, 0, 0))
|
||||
+ {
|
||||
+ TranslateMessage(&msg);
|
||||
+ DispatchMessageA(&msg);
|
||||
+ }
|
||||
+
|
||||
+ wintab_destroy_window(defaultWindow);
|
||||
+}
|
||||
+
|
||||
START_TEST(context)
|
||||
{
|
||||
HMODULE hWintab = load_functions();
|
||||
@@ -147,5 +315,8 @@ START_TEST(context)
|
||||
|
||||
test_WTOpenContextValidation();
|
||||
|
||||
+ if(winetest_interactive)
|
||||
+ test_interactive();
|
||||
+
|
||||
FreeLibrary(hWintab);
|
||||
}
|
||||
--
|
||||
2.20.1
|
||||
|
Loading…
x
Reference in New Issue
Block a user