Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
June 2018
- 68 participants
- 1149 messages
Re: [PATCH v6 4/8] ntdll: Return BIOS info from NtQuerySystemInformation on Linux
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=39213
Your paranoid android.
=== wvistau64 (32 bit info) ===
info.c:1855: Test failed: Expected STATUS_SUCCESS, got c0000022
0864:info: unhandled exception c0000005 at 002D0000
=== wvistau64_zh_CN (32 bit info) ===
info.c:1855: Test failed: Expected STATUS_SUCCESS, got c0000022
0bb8:info: unhandled exception c0000005 at 002C0000
=== wvistau64_fr (32 bit info) ===
info.c:1855: Test failed: Expected STATUS_SUCCESS, got c0000022
072c:info: unhandled exception c0000005 at 002E0000
=== wvistau64_he (32 bit info) ===
info.c:1855: Test failed: Expected STATUS_SUCCESS, got c0000022
0bd8:info: unhandled exception c0000005 at 00340000
=== w2008s64 (32 bit info) ===
info.c:1855: Test failed: Expected STATUS_SUCCESS, got c0000022
0888:info: unhandled exception c0000005 at 003C0000
=== w7u (32 bit info) ===
info.c:1855: Test failed: Expected STATUS_SUCCESS, got c0000022
=== w7pro64 (32 bit info) ===
info.c:1855: Test failed: Expected STATUS_SUCCESS, got c0000022
0aa4:info: unhandled exception c0000005 at 00340000
=== w8 (32 bit info) ===
info.c:1855: Test failed: Expected STATUS_SUCCESS, got c0000022
0ed8:info: unhandled exception c0000005 at 00670000
=== w864 (32 bit info) ===
info.c:1855: Test failed: Expected STATUS_SUCCESS, got c0000022
0a20:info: unhandled exception c0000005 at 002D0000
=== w1064 (32 bit info) ===
info.c:1855: Test failed: Expected STATUS_SUCCESS, got c0000022
0b6c:info: unhandled exception c0000005 at 00390000
June 18, 2018
Re: [PATCH v6 2/8] ntdll/tests: Add SystemFirmwareTableInformation tests
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=39211
Your paranoid android.
=== wxppro (32 bit info) ===
The task timed out
=== wvistau64 (32 bit info) ===
info.c:1848: Test failed: Expected STATUS_SUCCESS, got c0000022
0a4c:info: unhandled exception c0000005 at 003D0000
=== wvistau64_zh_CN (32 bit info) ===
info.c:1848: Test failed: Expected STATUS_SUCCESS, got c0000022
0bbc:info: unhandled exception c0000005 at 00360000
=== wvistau64_fr (32 bit info) ===
info.c:1848: Test failed: Expected STATUS_SUCCESS, got c0000022
06a8:info: unhandled exception c0000005 at 002D0000
=== wvistau64_he (32 bit info) ===
info.c:1848: Test failed: Expected STATUS_SUCCESS, got c0000022
0bd8:info: unhandled exception c0000005 at 002C0000
=== w2008s64 (32 bit info) ===
info.c:1848: Test failed: Expected STATUS_SUCCESS, got c0000022
0870:info: unhandled exception c0000005 at 002D0000
=== w7u (32 bit info) ===
info.c:1848: Test failed: Expected STATUS_SUCCESS, got c0000022
=== w7pro64 (32 bit info) ===
info.c:1848: Test failed: Expected STATUS_SUCCESS, got c0000022
0ac4:info: unhandled exception c0000005 at 00340000
=== w8 (32 bit info) ===
info.c:1848: Test failed: Expected STATUS_SUCCESS, got c0000022
0ecc:info: unhandled exception c0000005 at 003E0000
=== w864 (32 bit info) ===
info.c:1848: Test failed: Expected STATUS_SUCCESS, got c0000022
0758:info: unhandled exception c0000005 at 00370000
=== w1064 (32 bit info) ===
info.c:1848: Test failed: Expected STATUS_SUCCESS, got c0000022
0af4:info: unhandled exception c0000005 at 002D0000
June 18, 2018
[PATCH v6 8/8] ntdll: Return chassis info from NtQuerySystemInformation on Linux
by Alex Henrie
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
dlls/ntdll/nt.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 312fc711b6..eb5749e450 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -108,6 +108,17 @@ struct smbios_board {
BYTE serial;
};
+struct smbios_chassis {
+ BYTE type;
+ BYTE length;
+ WORD handle;
+ BYTE vendor;
+ BYTE shape;
+ BYTE version;
+ BYTE serial;
+ BYTE asset_tag;
+};
+
#include "poppack.h"
/* Firmware table providers */
@@ -1944,12 +1955,15 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
size_t system_vendor_len, system_product_len, system_version_len, system_serial_len;
char board_vendor[128], board_product[128], board_version[128], board_serial[128];
size_t board_vendor_len, board_product_len, board_version_len, board_serial_len;
+ char chassis_vendor[128], chassis_version[128], chassis_serial[128], chassis_asset_tag[128];
+ size_t chassis_vendor_len, chassis_version_len, chassis_serial_len, chassis_asset_tag_len;
char *buffer = (char*)sfti->TableBuffer;
BYTE string_count;
struct smbios_prologue *prologue;
struct smbios_bios *bios;
struct smbios_system *system;
struct smbios_board *board;
+ struct smbios_chassis *chassis;
get_smbios_string("/sys/class/dmi/id/bios_vendor", bios_vendor, &bios_vendor_len);
get_smbios_string("/sys/class/dmi/id/bios_version", bios_version, &bios_version_len);
@@ -1962,6 +1976,10 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
get_smbios_string("/sys/class/dmi/id/board_name", board_product, &board_product_len);
get_smbios_string("/sys/class/dmi/id/board_version", board_version, &board_version_len);
get_smbios_string("/sys/class/dmi/id/board_serial", board_serial, &board_serial_len);
+ get_smbios_string("/sys/class/dmi/id/chassis_vendor", chassis_vendor, &chassis_vendor_len);
+ get_smbios_string("/sys/class/dmi/id/chassis_version", chassis_version, &chassis_version_len);
+ get_smbios_string("/sys/class/dmi/id/chassis_serial", chassis_serial, &chassis_serial_len);
+ get_smbios_string("/sys/class/dmi/id/chassis_tag", chassis_asset_tag, &chassis_asset_tag_len);
*required_len = sizeof(struct smbios_prologue);
@@ -1975,6 +1993,10 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
*required_len += sizeof(struct smbios_board);
*required_len += max(board_vendor_len + board_product_len + board_version_len + board_serial_len + 5, 2);
+ *required_len += sizeof(struct smbios_chassis);
+ *required_len += max(chassis_vendor_len + chassis_version_len + chassis_serial_len +
+ chassis_asset_tag_len + 5, 2);
+
sfti->TableBufferLength = *required_len;
*required_len += FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
@@ -2063,6 +2085,33 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
copy_smbios_string(&buffer, board_version, board_version_len);
copy_smbios_string(&buffer, board_serial, board_serial_len);
memset(buffer, 0, 1);
+ buffer++;
+ }
+ else
+ {
+ memset(buffer, 0, 2);
+ buffer += 2;
+ }
+
+ string_count = 0;
+ chassis = (struct smbios_chassis*)buffer;
+ chassis->type = 3;
+ chassis->length = sizeof(struct smbios_chassis);
+ chassis->handle = 0;
+ chassis->vendor = chassis_vendor_len ? ++string_count : 0;
+ chassis->shape = 0x2; /* unknown */
+ chassis->version = chassis_version_len ? ++string_count : 0;
+ chassis->serial = chassis_serial_len ? ++string_count : 0;
+ chassis->asset_tag = chassis_asset_tag_len ? ++string_count : 0;
+ buffer += sizeof(struct smbios_chassis);
+
+ if (string_count)
+ {
+ copy_smbios_string(&buffer, chassis_vendor, chassis_vendor_len);
+ copy_smbios_string(&buffer, chassis_version, chassis_version_len);
+ copy_smbios_string(&buffer, chassis_serial, chassis_serial_len);
+ copy_smbios_string(&buffer, chassis_asset_tag, chassis_asset_tag_len);
+ memset(buffer, 0, 1);
}
else
{
--
2.17.1
June 18, 2018
[PATCH v6 7/8] ntdll: Return board info from NtQuerySystemInformation on Linux
by Alex Henrie
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
dlls/ntdll/nt.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 534b362c9e..312fc711b6 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -98,6 +98,16 @@ struct smbios_system {
BYTE serial;
};
+struct smbios_board {
+ BYTE type;
+ BYTE length;
+ WORD handle;
+ BYTE vendor;
+ BYTE product;
+ BYTE version;
+ BYTE serial;
+};
+
#include "poppack.h"
/* Firmware table providers */
@@ -1932,11 +1942,14 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
size_t bios_vendor_len, bios_version_len, bios_date_len;
char system_vendor[128], system_product[128], system_version[128], system_serial[128];
size_t system_vendor_len, system_product_len, system_version_len, system_serial_len;
+ char board_vendor[128], board_product[128], board_version[128], board_serial[128];
+ size_t board_vendor_len, board_product_len, board_version_len, board_serial_len;
char *buffer = (char*)sfti->TableBuffer;
BYTE string_count;
struct smbios_prologue *prologue;
struct smbios_bios *bios;
struct smbios_system *system;
+ struct smbios_board *board;
get_smbios_string("/sys/class/dmi/id/bios_vendor", bios_vendor, &bios_vendor_len);
get_smbios_string("/sys/class/dmi/id/bios_version", bios_version, &bios_version_len);
@@ -1945,6 +1958,10 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
get_smbios_string("/sys/class/dmi/id/product", system_product, &system_product_len);
get_smbios_string("/sys/class/dmi/id/product_version", system_version, &system_version_len);
get_smbios_string("/sys/class/dmi/id/product_serial", system_serial, &system_serial_len);
+ get_smbios_string("/sys/class/dmi/id/board_vendor", board_vendor, &board_vendor_len);
+ get_smbios_string("/sys/class/dmi/id/board_name", board_product, &board_product_len);
+ get_smbios_string("/sys/class/dmi/id/board_version", board_version, &board_version_len);
+ get_smbios_string("/sys/class/dmi/id/board_serial", board_serial, &board_serial_len);
*required_len = sizeof(struct smbios_prologue);
@@ -1955,6 +1972,9 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
*required_len += max(system_vendor_len + system_product_len + system_version_len +
system_serial_len + 5, 2);
+ *required_len += sizeof(struct smbios_board);
+ *required_len += max(board_vendor_len + board_product_len + board_version_len + board_serial_len + 5, 2);
+
sfti->TableBufferLength = *required_len;
*required_len += FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
@@ -2017,6 +2037,32 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
copy_smbios_string(&buffer, system_version, system_version_len);
copy_smbios_string(&buffer, system_serial, system_serial_len);
memset(buffer, 0, 1);
+ buffer++;
+ }
+ else
+ {
+ memset(buffer, 0, 2);
+ buffer += 2;
+ }
+
+ string_count = 0;
+ board = (struct smbios_board*)buffer;
+ board->type = 2;
+ board->length = sizeof(struct smbios_board);
+ board->handle = 0;
+ board->vendor = board_vendor_len ? ++string_count : 0;
+ board->product = board_product_len ? ++string_count : 0;
+ board->version = board_version_len ? ++string_count : 0;
+ board->serial = board_serial_len ? ++string_count : 0;
+ buffer += sizeof(struct smbios_board);
+
+ if (string_count)
+ {
+ copy_smbios_string(&buffer, board_vendor, board_vendor_len);
+ copy_smbios_string(&buffer, board_product, board_product_len);
+ copy_smbios_string(&buffer, board_version, board_version_len);
+ copy_smbios_string(&buffer, board_serial, board_serial_len);
+ memset(buffer, 0, 1);
}
else
{
--
2.17.1
June 18, 2018
[PATCH v6 6/8] ntdll: Return system info from NtQuerySystemInformation on Linux
by Alex Henrie
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
dlls/ntdll/nt.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 2a4ef783cd..534b362c9e 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -88,6 +88,16 @@ struct smbios_bios {
UINT64 characteristics;
};
+struct smbios_system {
+ BYTE type;
+ BYTE length;
+ WORD handle;
+ BYTE vendor;
+ BYTE product;
+ BYTE version;
+ BYTE serial;
+};
+
#include "poppack.h"
/* Firmware table providers */
@@ -1920,20 +1930,31 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
{
char bios_vendor[128], bios_version[128], bios_date[128];
size_t bios_vendor_len, bios_version_len, bios_date_len;
+ char system_vendor[128], system_product[128], system_version[128], system_serial[128];
+ size_t system_vendor_len, system_product_len, system_version_len, system_serial_len;
char *buffer = (char*)sfti->TableBuffer;
BYTE string_count;
struct smbios_prologue *prologue;
struct smbios_bios *bios;
+ struct smbios_system *system;
get_smbios_string("/sys/class/dmi/id/bios_vendor", bios_vendor, &bios_vendor_len);
get_smbios_string("/sys/class/dmi/id/bios_version", bios_version, &bios_version_len);
get_smbios_string("/sys/class/dmi/id/bios_date", bios_date, &bios_date_len);
+ get_smbios_string("/sys/class/dmi/id/sys_vendor", system_vendor, &system_vendor_len);
+ get_smbios_string("/sys/class/dmi/id/product", system_product, &system_product_len);
+ get_smbios_string("/sys/class/dmi/id/product_version", system_version, &system_version_len);
+ get_smbios_string("/sys/class/dmi/id/product_serial", system_serial, &system_serial_len);
*required_len = sizeof(struct smbios_prologue);
*required_len += sizeof(struct smbios_bios);
*required_len += max(bios_vendor_len + bios_version_len + bios_date_len + 4, 2);
+ *required_len += sizeof(struct smbios_system);
+ *required_len += max(system_vendor_len + system_product_len + system_version_len +
+ system_serial_len + 5, 2);
+
sfti->TableBufferLength = *required_len;
*required_len += FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
@@ -1970,6 +1991,32 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
copy_smbios_string(&buffer, bios_version, bios_version_len);
copy_smbios_string(&buffer, bios_date, bios_date_len);
memset(buffer, 0, 1);
+ buffer++;
+ }
+ else
+ {
+ memset(buffer, 0, 2);
+ buffer += 2;
+ }
+
+ string_count = 0;
+ system = (struct smbios_system*)buffer;
+ system->type = 1;
+ system->length = sizeof(struct smbios_system);
+ system->handle = 0;
+ system->vendor = system_vendor_len ? ++string_count : 0;
+ system->product = system_product_len ? ++string_count : 0;
+ system->version = system_version_len ? ++string_count : 0;
+ system->serial = system_serial_len ? ++string_count : 0;
+ buffer += sizeof(struct smbios_system);
+
+ if (string_count)
+ {
+ copy_smbios_string(&buffer, system_vendor, system_vendor_len);
+ copy_smbios_string(&buffer, system_product, system_product_len);
+ copy_smbios_string(&buffer, system_version, system_version_len);
+ copy_smbios_string(&buffer, system_serial, system_serial_len);
+ memset(buffer, 0, 1);
}
else
{
--
2.17.1
June 18, 2018
[PATCH v6 5/8] kernel32: Connect GetSystemFirmwareTable to NtQuerySystemInformation
by Alex Henrie
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
dlls/kernel32/cpu.c | 29 +++++++++++++++++++++++++++++
dlls/kernel32/process.c | 10 ----------
dlls/kernel32/tests/version.c | 2 +-
3 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/dlls/kernel32/cpu.c b/dlls/kernel32/cpu.c
index ec1fd0f90d..8397fbe729 100644
--- a/dlls/kernel32/cpu.c
+++ b/dlls/kernel32/cpu.c
@@ -336,3 +336,32 @@ DWORD64 WINAPI GetEnabledXStateFeatures(void)
FIXME("\n");
return 0;
}
+
+/***********************************************************************
+ * GetSystemFirmwareTable (KERNEL32.@)
+ */
+UINT WINAPI GetSystemFirmwareTable(DWORD provider, DWORD id, void *buffer, DWORD size)
+{
+ ULONG buffer_size = FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer) + size;
+ SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti = HeapAlloc(GetProcessHeap(), 0, buffer_size);
+ NTSTATUS status;
+
+ if (!sfti)
+ {
+ SetLastError(ERROR_OUTOFMEMORY);
+ return 0;
+ }
+
+ sfti->ProviderSignature = provider;
+ sfti->Action = SystemFirmwareTable_Get;
+ sfti->TableID = id;
+
+ status = NtQuerySystemInformation(SystemFirmwareTableInformation, sfti, buffer_size, &buffer_size);
+ buffer_size -= FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
+ if (buffer_size <= size)
+ memcpy(buffer, sfti->TableBuffer, buffer_size);
+
+ if (status) SetLastError(RtlNtStatusToDosError(status));
+ HeapFree(GetProcessHeap(), 0, sfti);
+ return buffer_size;
+}
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index ff56e9a692..6adf08d257 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -4126,16 +4126,6 @@ HRESULT WINAPI UnregisterApplicationRestart(void)
return S_OK;
}
-/***********************************************************************
- * GetSystemFirmwareTable (KERNEL32.@)
- */
-UINT WINAPI GetSystemFirmwareTable(DWORD provider, DWORD id, PVOID buffer, DWORD size)
-{
- FIXME("(%d %d %p %d):stub\n", provider, id, buffer, size);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
-}
-
struct proc_thread_attr
{
DWORD_PTR attr;
diff --git a/dlls/kernel32/tests/version.c b/dlls/kernel32/tests/version.c
index 08e8f0fb58..e33ce9cd42 100644
--- a/dlls/kernel32/tests/version.c
+++ b/dlls/kernel32/tests/version.c
@@ -717,7 +717,7 @@ void test_GetSystemFirmwareTable(void)
pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, 16, &expected_len);
if (expected_len == 0) /* xp, 2003 */
{
- skip("SystemFirmwareTableInformation is not available\n");
+ win_skip("SystemFirmwareTableInformation is not available\n");
HeapFree(GetProcessHeap(), 0, sfti);
return;
}
--
2.17.1
June 18, 2018
[PATCH v6 4/8] ntdll: Return BIOS info from NtQuerySystemInformation on Linux
by Alex Henrie
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
dlls/ntdll/nt.c | 170 ++++++++++++++++++++++++++++++++++++++++
dlls/ntdll/tests/info.c | 11 ++-
2 files changed, 179 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index dc0ce04f42..2a4ef783cd 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -66,6 +66,35 @@
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
+#include "pshpack1.h"
+
+struct smbios_prologue {
+ BYTE calling_method;
+ BYTE major_version;
+ BYTE minor_version;
+ BYTE revision;
+ DWORD length;
+};
+
+struct smbios_bios {
+ BYTE type;
+ BYTE length;
+ WORD handle;
+ BYTE vendor;
+ BYTE version;
+ WORD start;
+ BYTE date;
+ BYTE size;
+ UINT64 characteristics;
+};
+
+#include "poppack.h"
+
+/* Firmware table providers */
+#define ACPI 0x41435049
+#define FIRM 0x4649524D
+#define RSMB 0x52534D42
+
/*
* Token
*/
@@ -1850,6 +1879,125 @@ static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **
}
#endif
+static inline void copy_smbios_string(char **buffer, char *s, size_t len)
+{
+ if (!len) return;
+ strcpy(*buffer, s);
+ *buffer += len + 1;
+}
+
+#ifdef linux
+
+static void get_smbios_string(const char *path, char *s, size_t *len)
+{
+ FILE *file = fopen(path, "r");
+ if (!file)
+ {
+ *len = 0;
+ return;
+ }
+
+ *len = fread(s, 1, 127, file);
+ fclose(file);
+
+ if (*len >= 1 && s[*len - 1] == '\n')
+ {
+ s[*len - 1] = 0;
+ (*len)--;
+ }
+ else
+ {
+ s[*len] = 0;
+ }
+}
+
+static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti,
+ ULONG available_len, ULONG *required_len)
+{
+ switch (sfti->ProviderSignature)
+ {
+ case RSMB:
+ {
+ char bios_vendor[128], bios_version[128], bios_date[128];
+ size_t bios_vendor_len, bios_version_len, bios_date_len;
+ char *buffer = (char*)sfti->TableBuffer;
+ BYTE string_count;
+ struct smbios_prologue *prologue;
+ struct smbios_bios *bios;
+
+ get_smbios_string("/sys/class/dmi/id/bios_vendor", bios_vendor, &bios_vendor_len);
+ get_smbios_string("/sys/class/dmi/id/bios_version", bios_version, &bios_version_len);
+ get_smbios_string("/sys/class/dmi/id/bios_date", bios_date, &bios_date_len);
+
+ *required_len = sizeof(struct smbios_prologue);
+
+ *required_len += sizeof(struct smbios_bios);
+ *required_len += max(bios_vendor_len + bios_version_len + bios_date_len + 4, 2);
+
+ sfti->TableBufferLength = *required_len;
+
+ *required_len += FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
+
+ if (available_len < *required_len)
+ {
+ return STATUS_BUFFER_TOO_SMALL;
+ }
+
+ prologue = (struct smbios_prologue*)buffer;
+ prologue->calling_method = 0;
+ prologue->major_version = 2;
+ prologue->minor_version = 0;
+ prologue->revision = 0;
+ prologue->length = sfti->TableBufferLength - sizeof(struct smbios_prologue);
+ buffer += sizeof(struct smbios_prologue);
+
+ string_count = 0;
+ bios = (struct smbios_bios*)buffer;
+ bios->type = 0;
+ bios->length = sizeof(struct smbios_bios);
+ bios->handle = 0;
+ bios->vendor = bios_vendor_len ? ++string_count : 0;
+ bios->version = bios_version_len ? ++string_count : 0;
+ bios->start = 0;
+ bios->date = bios_date_len ? ++string_count : 0;
+ bios->size = 0;
+ bios->characteristics = 0x4; /* not supported */
+ buffer += sizeof(struct smbios_bios);
+
+ if (string_count)
+ {
+ copy_smbios_string(&buffer, bios_vendor, bios_vendor_len);
+ copy_smbios_string(&buffer, bios_version, bios_version_len);
+ copy_smbios_string(&buffer, bios_date, bios_date_len);
+ memset(buffer, 0, 1);
+ }
+ else
+ {
+ memset(buffer, 0, 2);
+ }
+
+ return STATUS_SUCCESS;
+ }
+ default:
+ {
+ FIXME("info_class SYSTEM_FIRMWARE_TABLE_INFORMATION\n");
+ return STATUS_NOT_IMPLEMENTED;
+ }
+ }
+}
+
+#else
+
+static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti,
+ ULONG available_len, ULONG *required_len)
+{
+ FIXME("info_class SYSTEM_FIRMWARE_TABLE_INFORMATION\n");
+ sfti->TableBufferLength = 0;
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+#endif
+
/******************************************************************************
* NtQuerySystemInformation [NTDLL.@]
* ZwQuerySystemInformation [NTDLL.@]
@@ -2359,6 +2507,28 @@ NTSTATUS WINAPI NtQuerySystemInformation(
else ret = STATUS_INFO_LENGTH_MISMATCH;
}
break;
+ case SystemFirmwareTableInformation:
+ {
+ SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti = (SYSTEM_FIRMWARE_TABLE_INFORMATION*)SystemInformation;
+ len = FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
+ if (Length < len)
+ {
+ ret = STATUS_INFO_LENGTH_MISMATCH;
+ break;
+ }
+
+ switch (sfti->Action)
+ {
+ case SystemFirmwareTable_Get:
+ ret = get_firmware_info(sfti, Length, &len);
+ break;
+ default:
+ len = 0;
+ ret = STATUS_NOT_IMPLEMENTED;
+ FIXME("info_class SYSTEM_FIRMWARE_TABLE_INFORMATION\n");
+ }
+ }
+ break;
default:
FIXME("(0x%08x,%p,0x%08x,%p) stub\n",
SystemInformationClass,SystemInformation,Length,ResultLength);
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index 804a0ac902..d1c451157d 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -59,6 +59,12 @@ static DWORD one_before_last_pid = 0;
#define FIRM 0x4649524D
#define RSMB 0x52534D42
+#ifdef linux
+static const int firmware_todo = 0;
+#else
+static const int firmware_todo = 1;
+#endif
+
static BOOL InitFunctionPtrs(void)
{
/* All needed functions are NT based, so using GetModuleHandle is a good check */
@@ -842,12 +848,11 @@ static void test_query_firmware(void)
ok(!!sfti, "Failed to allocate memory\n");
status = pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, 15, &len1);
-todo_wine
ok(status == STATUS_INFO_LENGTH_MISMATCH || broken(status == STATUS_INVALID_INFO_CLASS) /* xp */,
"Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
if (len1 == 0) /* xp, 2003 */
{
- skip("SystemFirmwareTableInformation is not available\n");
+ win_skip("SystemFirmwareTableInformation is not available\n");
HeapFree(GetProcessHeap(), 0, sfti);
return;
}
@@ -862,6 +867,7 @@ todo_wine
sfti->TableID = 0;
status = pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, 16, &len1);
+todo_wine_if(firmware_todo)
ok(status == STATUS_BUFFER_TOO_SMALL, "Expected STATUS_BUFFER_TOO_SMALL, got %08x\n", status);
ok(len1 >= 16, "Expected length >= 16, got %u\n", len1);
ok(sfti->TableBufferLength == len1 - 16, "Expected length %u, got %u\n", len1 - 16, sfti->TableBufferLength);
@@ -873,6 +879,7 @@ todo_wine
{
sfti->TableID = i;
status = pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, len1, &len2);
+todo_wine_if(firmware_todo)
ok(status == STATUS_SUCCESS, "Table %u: Expected STATUS_SUCCESS, got %08x\n", i, status);
ok(len2 == len1, "Table %u: Expected length %u, got %u\n", i, len1, len2);
ok(sfti->TableBufferLength == len1 - 16,
--
2.17.1
June 18, 2018
[PATCH v6 3/8] kernel32/tests: Add GetSystemFirmwareTable tests
by Alex Henrie
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
dlls/kernel32/tests/version.c | 41 +++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/dlls/kernel32/tests/version.c b/dlls/kernel32/tests/version.c
index eb78a383d2..08e8f0fb58 100644
--- a/dlls/kernel32/tests/version.c
+++ b/dlls/kernel32/tests/version.c
@@ -26,11 +26,17 @@
#include "winternl.h"
static BOOL (WINAPI * pGetProductInfo)(DWORD, DWORD, DWORD, DWORD, DWORD *);
+static NTSTATUS (WINAPI * pNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, void *, ULONG, ULONG *);
static NTSTATUS (WINAPI * pRtlGetVersion)(RTL_OSVERSIONINFOEXW *);
#define GET_PROC(func) \
p##func = (void *)GetProcAddress(hmod, #func);
+/* Firmware table providers */
+#define ACPI 0x41435049
+#define FIRM 0x4649524D
+#define RSMB 0x52534D42
+
static void init_function_pointers(void)
{
HMODULE hmod;
@@ -41,6 +47,7 @@ static void init_function_pointers(void)
hmod = GetModuleHandleA("ntdll.dll");
+ GET_PROC(NtQuerySystemInformation);
GET_PROC(RtlGetVersion);
}
@@ -697,6 +704,39 @@ static void test_VerifyVersionInfo(void)
ok(ret, "VerifyVersionInfoA failed with error %d\n", GetLastError());
}
+void test_GetSystemFirmwareTable(void)
+{
+ ULONG expected_len, i;
+ UINT len;
+ SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 16);
+ UCHAR *smbios_table = NULL;
+
+ ok(!!sfti, "Failed to allocate memory\n");
+ sfti->ProviderSignature = RSMB;
+ sfti->Action = SystemFirmwareTable_Get;
+ pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, 16, &expected_len);
+ if (expected_len == 0) /* xp, 2003 */
+ {
+ skip("SystemFirmwareTableInformation is not available\n");
+ HeapFree(GetProcessHeap(), 0, sfti);
+ return;
+ }
+ sfti = HeapReAlloc(GetProcessHeap(), 0, sfti, expected_len);
+ ok(!!sfti, "Failed to allocate memory\n");
+ pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, expected_len, &expected_len);
+
+ expected_len -= 16;
+ smbios_table = HeapAlloc(GetProcessHeap(), 0, expected_len);
+ for (i = 0; i < 100; i++)
+ {
+ len = GetSystemFirmwareTable(RSMB, i, smbios_table, expected_len);
+ ok(len == expected_len, "Table %u: Expected length %u, got %u\n", i, expected_len, len);
+ }
+
+ HeapFree(GetProcessHeap(), 0, sfti);
+ HeapFree(GetProcessHeap(), 0, smbios_table);
+}
+
START_TEST(version)
{
init_function_pointers();
@@ -704,4 +744,5 @@ START_TEST(version)
test_GetProductInfo();
test_GetVersionEx();
test_VerifyVersionInfo();
+ test_GetSystemFirmwareTable();
}
--
2.17.1
June 18, 2018
[PATCH v6 2/8] ntdll/tests: Add SystemFirmwareTableInformation tests
by Alex Henrie
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
dlls/ntdll/tests/info.c | 60 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index 6c93c3cd58..804a0ac902 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -54,6 +54,11 @@ static DWORD one_before_last_pid = 0;
} \
} while(0)
+/* Firmware table providers */
+#define ACPI 0x41435049
+#define FIRM 0x4649524D
+#define RSMB 0x52534D42
+
static BOOL InitFunctionPtrs(void)
{
/* All needed functions are NT based, so using GetModuleHandle is a good check */
@@ -826,6 +831,57 @@ static void test_query_logicalprocex(void)
}
}
+static void test_query_firmware(void)
+{
+ ULONG len1, len2;
+ NTSTATUS status;
+ SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti;
+ int i;
+
+ sfti = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 16);
+ ok(!!sfti, "Failed to allocate memory\n");
+
+ status = pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, 15, &len1);
+todo_wine
+ ok(status == STATUS_INFO_LENGTH_MISMATCH || broken(status == STATUS_INVALID_INFO_CLASS) /* xp */,
+ "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
+ if (len1 == 0) /* xp, 2003 */
+ {
+ skip("SystemFirmwareTableInformation is not available\n");
+ HeapFree(GetProcessHeap(), 0, sfti);
+ return;
+ }
+ ok(len1 == 16, "Expected length 16, got %u\n", len1);
+
+ status = pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, 16, &len1);
+ ok(status == STATUS_NOT_IMPLEMENTED, "Expected STATUS_NOT_IMPLEMENTED, got %08x\n", status);
+ ok(len1 == 0, "Expected length 0, got %u\n", len1);
+
+ sfti->ProviderSignature = RSMB;
+ sfti->Action = SystemFirmwareTable_Get;
+ sfti->TableID = 0;
+
+ status = pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, 16, &len1);
+ ok(status == STATUS_BUFFER_TOO_SMALL, "Expected STATUS_BUFFER_TOO_SMALL, got %08x\n", status);
+ ok(len1 >= 16, "Expected length >= 16, got %u\n", len1);
+ ok(sfti->TableBufferLength == len1 - 16, "Expected length %u, got %u\n", len1 - 16, sfti->TableBufferLength);
+
+ sfti = HeapReAlloc(GetProcessHeap(), 0, sfti, len1);
+ ok(!!sfti, "Failed to allocate memory\n");
+
+ for (i = 0; i < 100; i++)
+ {
+ sfti->TableID = i;
+ status = pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, len1, &len2);
+ ok(status == STATUS_SUCCESS, "Table %u: Expected STATUS_SUCCESS, got %08x\n", i, status);
+ ok(len2 == len1, "Table %u: Expected length %u, got %u\n", i, len1, len2);
+ ok(sfti->TableBufferLength == len1 - 16,
+ "Table %u: Expected length %u, got %u\n", i, len1 - 16, sfti->TableBufferLength);
+ }
+
+ HeapFree(GetProcessHeap(), 0, sfti);
+}
+
static void test_query_processor_power_info(void)
{
NTSTATUS status;
@@ -2267,6 +2323,10 @@ START_TEST(info)
trace("Starting test_process_debug_flags()\n");
test_query_process_debug_flags(argc, argv);
+ /* 0x4C SystemFirmwareTableInformation */
+ trace("Starting test_query_firmware()\n");
+ test_query_firmware();
+
/* belongs to its own file */
trace("Starting test_readvirtualmemory()\n");
test_readvirtualmemory();
--
2.17.1
June 18, 2018
[PATCH v6 1/8] include: Add SYSTEM_FIRMWARE_TABLE_INFORMATION to winternl.h
by Alex Henrie
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
include/winternl.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/include/winternl.h b/include/winternl.h
index 58c475dfff..6e0bd987b6 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -1579,6 +1579,23 @@ typedef struct _SYSTEM_TIME_ADJUSTMENT {
BOOLEAN TimeAdjustmentDisabled;
} SYSTEM_TIME_ADJUSTMENT, *PSYSTEM_TIME_ADJUSTMENT;
+typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION
+{
+ SystemFirmwareTable_Enumerate = 0,
+ SystemFirmwareTable_Get = 1
+} SYSTEM_FIRMWARE_TABLE_ACTION, *PSYSTEM_FIRMWARE_TABLE_ACTION;
+
+/* System Information Class 0x4C */
+
+typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION
+{
+ ULONG ProviderSignature;
+ SYSTEM_FIRMWARE_TABLE_ACTION Action;
+ ULONG TableID;
+ ULONG TableBufferLength;
+ UCHAR TableBuffer[1];
+} SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION;
+
typedef struct _TIME_FIELDS
{ CSHORT Year;
CSHORT Month;
--
2.17.1
June 18, 2018
Re: [PATCH 2/2] user32/tests: Skip tests for window messages if we failed to receive foreground status.
by Zebediah Figura
On 17/06/18 16:20, Marvin wrote:
> Hi,
>
> While running your changed tests on Windows, I think I found new failures.
> Being a bot and all I'm not very good at pattern recognition, so I might be
> wrong, but could you please double-check?
> Full results can be found at
> https://testbot.winehq.org/JobDetails.pl?Key=39204
>
> Your paranoid android.
>
>
> === w7pro64 (64 bit input) ===
> input.c:2055: Test failed: expected WM_NCHITTEST message
> input.c:2082: Test failed: expected loop with WM_NCHITTEST messages
> input.c:2135: Test failed: expected WM_LBUTTONDOWN message
> input.c:2136: Test failed: expected WM_LBUTTONUP message
>
>
This failure is in a different test, and should not be affected by my
changes. A similar failure can be seen here:
http://test.winehq.org/data/8e9ea7a8a163147012908bad696a539454654d8f/win7_n…
June 17, 2018
[PATCH] riched20/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/riched20/tests/editor.c | 62 ++++++++++++++++++++-----------------------
dlls/riched20/tests/richole.c | 4 +--
2 files changed, 31 insertions(+), 35 deletions(-)
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 2a6907bfe7..85c607becf 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -340,14 +340,12 @@ static void test_EM_FINDTEXT(BOOL unicode)
hwndRichEdit = new_richedit(NULL);
/* Empty rich edit control */
- run_tests_EM_FINDTEXT(hwndRichEdit, "1", find_tests,
- sizeof(find_tests)/sizeof(struct find_s), unicode);
+ run_tests_EM_FINDTEXT(hwndRichEdit, "1", find_tests, ARRAY_SIZE(find_tests), unicode);
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)haystack);
/* Haystack text */
- run_tests_EM_FINDTEXT(hwndRichEdit, "2", find_tests2,
- sizeof(find_tests2)/sizeof(struct find_s), unicode);
+ run_tests_EM_FINDTEXT(hwndRichEdit, "2", find_tests2, ARRAY_SIZE(find_tests2), unicode);
/* Setting a format on an arbitrary range should have no effect in search
results. This tests correct offset reporting across runs. */
@@ -359,8 +357,7 @@ static void test_EM_FINDTEXT(BOOL unicode)
SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2);
/* Haystack text, again */
- run_tests_EM_FINDTEXT(hwndRichEdit, "2-bis", find_tests2,
- sizeof(find_tests2)/sizeof(struct find_s), unicode);
+ run_tests_EM_FINDTEXT(hwndRichEdit, "2-bis", find_tests2, ARRAY_SIZE(find_tests2), unicode);
/* Yet another range */
cf2.dwMask = CFM_BOLD | cf2.dwMask;
@@ -369,8 +366,7 @@ static void test_EM_FINDTEXT(BOOL unicode)
SendMessageA(hwndRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf2);
/* Haystack text, again */
- run_tests_EM_FINDTEXT(hwndRichEdit, "2-bisbis", find_tests2,
- sizeof(find_tests2)/sizeof(struct find_s), unicode);
+ run_tests_EM_FINDTEXT(hwndRichEdit, "2-bisbis", find_tests2, ARRAY_SIZE(find_tests2), unicode);
DestroyWindow(hwndRichEdit);
}
@@ -404,7 +400,7 @@ static void test_EM_GETLINE(void)
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text);
memset(origdest, 0xBB, nBuf);
- for (i = 0; i < sizeof(gl)/sizeof(struct getline_s); i++)
+ for (i = 0; i < ARRAY_SIZE(gl); i++)
{
int nCopied;
int expected_nCopied = min(gl[i].buffer_len, strlen(gl[i].text));
@@ -509,7 +505,7 @@ static void test_EM_LINELENGTH(void)
{15, 4}, /* Line 3: |wine */
};
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1);
- for (i = 0; i < sizeof(offset_test1)/sizeof(offset_test1[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(offset_test1); i++) {
result = SendMessageA(hwndRichEdit, EM_LINELENGTH, offset_test1[i][0], 0);
ok(result == offset_test1[i][1], "Length of line at offset %d is %ld, expected %d\n",
offset_test1[i][0], result, offset_test1[i][1]);
@@ -2049,7 +2045,7 @@ static void test_EM_AUTOURLDETECT(void)
urlRet=SendMessageA(hwndRichEdit, EM_AUTOURLDETECT, (WPARAM)"h", (LPARAM)"h");
ok(urlRet==E_INVALIDARG, "Bad wParam2: urlRet is: %d\n", urlRet);
/* for each url, check the text to see if CFE_LINK effect is present */
- for (i = 0; i < sizeof(urls)/sizeof(struct urls_s); i++) {
+ for (i = 0; i < ARRAY_SIZE(urls); i++) {
SendMessageA(hwndRichEdit, EM_AUTOURLDETECT, FALSE, 0);
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)urls[i].text);
@@ -2063,10 +2059,10 @@ static void test_EM_AUTOURLDETECT(void)
DestroyWindow(hwndRichEdit);
/* Test detection of URLs within normal text - WM_SETTEXT case. */
- for (i = 0; i < sizeof(urls)/sizeof(struct urls_s); i++) {
+ for (i = 0; i < ARRAY_SIZE(urls); i++) {
hwndRichEdit = new_richedit(parent);
- for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -2117,7 +2113,7 @@ static void test_EM_AUTOURLDETECT(void)
}
}
- for (j = 0; j < sizeof(templates_non_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_non_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -2158,7 +2154,7 @@ static void test_EM_AUTOURLDETECT(void)
}
}
- for (j = 0; j < sizeof(templates_xten_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_xten_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -2213,7 +2209,7 @@ static void test_EM_AUTOURLDETECT(void)
}
}
- for (j = 0; j < sizeof(templates_neutral_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_neutral_delim); j++) {
char * at_pos, * end_pos;
int at_offset;
int end_offset;
@@ -2421,7 +2417,7 @@ static void test_EM_AUTOURLDETECT(void)
*/
/* Set entire text in one go, like WM_SETTEXT */
- for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -2476,7 +2472,7 @@ static void test_EM_AUTOURLDETECT(void)
}
/* Set selection with X to the URL */
- for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -2530,7 +2526,7 @@ static void test_EM_AUTOURLDETECT(void)
}
/* Set selection with X to the first character of the URL, then the rest */
- for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -2598,7 +2594,7 @@ static void test_EM_AUTOURLDETECT(void)
hwndRichEdit = new_richedit(parent);
/* Set selection with X to the URL */
- for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -2649,7 +2645,7 @@ static void test_EM_AUTOURLDETECT(void)
}
/* Set selection with X to the first character of the URL, then the rest */
- for (j = 0; j < sizeof(templates_delim) / sizeof(const char *); j++) {
+ for (j = 0; j < ARRAY_SIZE(templates_delim); j++) {
char * at_pos;
int at_offset;
int end_offset;
@@ -4933,7 +4929,7 @@ static void test_EM_EXSETSEL(void)
{
HWND hwndRichEdit = new_richedit(NULL);
int i;
- const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s);
+ const int num_tests = ARRAY_SIZE(exsetsel_tests);
/* sending some text to the window */
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection");
@@ -4988,7 +4984,7 @@ static void test_EM_SETSEL(void)
char buffA[32] = {0};
HWND hwndRichEdit = new_richedit(NULL);
int i;
- const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s);
+ const int num_tests = ARRAY_SIZE(exsetsel_tests);
/* sending some text to the window */
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection");
@@ -5623,7 +5619,7 @@ static void test_EM_FORMATRANGE(void)
SendMessageA(hwndRichEdit, EM_FORMATRANGE, FALSE, 0);
- for (i = 0; i < sizeof(fmtstrings)/sizeof(fmtstrings[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(fmtstrings); i++)
{
GETTEXTLENGTHEX gtl;
SIZE stringsize;
@@ -5831,7 +5827,7 @@ static void test_EM_STREAMIN(void)
};
const WCHAR streamText5[] = { 'T', 'e', 's', 't', 'S', 'o', 'm', 'e', 'T', 'e', 'x', 't' };
- int length5 = sizeof(streamText5) / sizeof(WCHAR);
+ int length5 = ARRAY_SIZE(streamText5);
struct StringWithLength cookieForStream5 = {
sizeof(streamText5),
(char *)streamText5,
@@ -6868,7 +6864,7 @@ static void test_EN_LINK(void)
GetCursorPos(&orig_cursor_pos);
SetCursorPos(0, 0);
- for (i = 0; i < sizeof(link_notify_tests)/sizeof(link_notify_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(link_notify_tests); i++)
{
link_notify_test("cursor position simulated", i, hwnd, parent,
link_notify_tests[i].msg, link_notify_tests[i].wParam, link_notify_tests[i].lParam,
@@ -6878,7 +6874,7 @@ static void test_EN_LINK(void)
ClientToScreen(hwnd, &cursor_screen_pos);
SetCursorPos(cursor_screen_pos.x, cursor_screen_pos.y);
- for (i = 0; i < sizeof(link_notify_tests)/sizeof(link_notify_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(link_notify_tests); i++)
{
link_notify_test("cursor position set", i, hwnd, parent,
link_notify_tests[i].msg, link_notify_tests[i].wParam, link_notify_tests[i].lParam,
@@ -8178,7 +8174,7 @@ static void test_EM_FINDWORDBREAK_W(void)
int i;
HWND hwndRichEdit = new_richeditW(NULL);
ok(IsWindowUnicode(hwndRichEdit), "window should be unicode\n");
- for (i = 0; i < sizeof(delimiter_tests)/sizeof(delimiter_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(delimiter_tests); i++)
{
WCHAR wbuf[2];
int result;
@@ -8212,7 +8208,7 @@ static void test_EM_FINDWORDBREAK_A(void)
HWND hwndRichEdit = new_richedit(NULL);
ok(!IsWindowUnicode(hwndRichEdit), "window should not be unicode\n");
- for (i = 0; i < sizeof(delimiter_tests)/sizeof(delimiter_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(delimiter_tests); i++)
{
int result;
char buf[2];
@@ -8256,7 +8252,7 @@ static void test_enter(void)
HWND hwndRichEdit = new_richedit(NULL);
UINT i,j;
- for (i = 0; i < sizeof(testenteritems)/sizeof(testenteritems[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(testenteritems); i++) {
char buf[1024] = {0};
LRESULT result;
@@ -8538,7 +8534,7 @@ static void test_alignment_style(void)
EDITSTREAM es;
int i;
- for (i = 0; i < sizeof(align_style) / sizeof(align_style[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(align_style); i++)
{
DWORD dwStyle, new_align;
@@ -8646,8 +8642,8 @@ static void test_rtf(void)
result = SendMessageA( edit, EM_STREAMIN, SF_RTF, (LPARAM)&es );
ok( result == 11, "got %ld\n", result );
- result = SendMessageW( edit, WM_GETTEXT, sizeof(buf)/sizeof(buf[0]), (LPARAM)buf );
- ok( result == sizeof(expect_specials)/sizeof(expect_specials[0]), "got %ld\n", result );
+ result = SendMessageW( edit, WM_GETTEXT, ARRAY_SIZE(buf), (LPARAM)buf );
+ ok( result == ARRAY_SIZE(expect_specials), "got %ld\n", result );
ok( !memcmp( buf, expect_specials, sizeof(expect_specials) ), "got %s\n", wine_dbgstr_w(buf) );
/* Show that \rtlpar propagates to the second paragraph and is
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index c4fe425dfa..aaf52bcfdd 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -247,8 +247,8 @@ static void test_ITextDocument_Open(void)
tomReadOnly|tomShareDenyWrite, tomReadOnly|tomShareDenyRead
};
- int tomNumSingle = sizeof(tomConstantsSingle)/sizeof(tomConstantsSingle[0]);
- int tomNumMulti = sizeof(tomConstantsMulti)/sizeof(tomConstantsMulti[0]);
+ int tomNumSingle = ARRAY_SIZE(tomConstantsSingle);
+ int tomNumMulti = ARRAY_SIZE(tomConstantsMulti);
int i;
V_VT(&testfile) = VT_BSTR;
--
2.14.4
June 17, 2018
[PATCH] riched32/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/riched32/tests/editor.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c
index 6fe4005599..7751d2b402 100644
--- a/dlls/riched32/tests/editor.c
+++ b/dlls/riched32/tests/editor.c
@@ -104,7 +104,7 @@ static void test_WM_SETTEXT(void)
* for line breaking (only \n adds a line break)
*/
- for (i = 0; i < sizeof(testitems)/sizeof(testitems[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(testitems); i++) {
char buf[1024] = {0};
LRESULT result;
@@ -410,7 +410,7 @@ static void test_EM_GETLINE(void)
}
memset(origdest, 0xBB, nBuf);
- for (i = 0; i < sizeof(gl)/sizeof(struct getline_s); i++)
+ for (i = 0; i < ARRAY_SIZE(gl); i++)
{
int nCopied, expected_nCopied, expected_bytes_written;
char gl_text[1024];
@@ -504,7 +504,7 @@ static void test_EM_LINELENGTH(void)
}
ok(result == 9, "Incorrect line count of %ld\n", result);
- for (i = 0; i < sizeof(offset_test)/sizeof(offset_test[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(offset_test); i++) {
result = SendMessageA(hwndRichEdit, EM_LINELENGTH, offset_test[i][0], 0);
ok(result == offset_test[i][1], "Length of line at offset %d is %ld, expected %d\n",
offset_test[i][0], result, offset_test[i][1]);
@@ -525,7 +525,7 @@ static void test_EM_LINELENGTH(void)
{16, 4}, /* Line 3: |wine */
};
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)text1);
- for (i = 0; i < sizeof(offset_test1)/sizeof(offset_test1[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(offset_test1); i++) {
result = SendMessageA(hwndRichEdit, EM_LINELENGTH, offset_test1[i][0], 0);
todo_wine_if (offset_test1[i][2])
ok(result == offset_test1[i][1], "Length of line at offset %d is %ld, expected %d\n",
@@ -781,20 +781,17 @@ static void test_EM_FINDTEXT(void)
HWND hwndRichEdit = new_richedit(NULL);
/* Empty rich edit control */
- run_tests_EM_FINDTEXT(hwndRichEdit, "1", find_tests,
- sizeof(find_tests)/sizeof(struct find_s));
+ run_tests_EM_FINDTEXT(hwndRichEdit, "1", find_tests, ARRAY_SIZE(find_tests));
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)haystack);
/* Haystack text */
- run_tests_EM_FINDTEXT(hwndRichEdit, "2", find_tests2,
- sizeof(find_tests2)/sizeof(struct find_s));
+ run_tests_EM_FINDTEXT(hwndRichEdit, "2", find_tests2, ARRAY_SIZE(find_tests2));
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)haystack2);
/* Haystack text 2 (with EOL characters) */
- run_tests_EM_FINDTEXT(hwndRichEdit, "3", find_tests3,
- sizeof(find_tests3)/sizeof(struct find_s));
+ run_tests_EM_FINDTEXT(hwndRichEdit, "3", find_tests3, ARRAY_SIZE(find_tests3));
DestroyWindow(hwndRichEdit);
}
@@ -1178,7 +1175,7 @@ static void test_enter(void)
HWND hwndRichEdit = new_richedit(NULL);
UINT i,j;
- for (i = 0; i < sizeof(testenteritems)/sizeof(testenteritems[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(testenteritems); i++) {
char buf[1024] = {0};
LRESULT result;
@@ -1321,7 +1318,7 @@ static void test_EM_EXSETSEL(void)
{
HWND hwndRichEdit = new_richedit(NULL);
int i;
- const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s);
+ const int num_tests = ARRAY_SIZE(exsetsel_tests);
/* sending some text to the window */
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection");
@@ -1378,7 +1375,7 @@ static void test_EM_SETSEL(void)
char buffA[32] = {0};
HWND hwndRichEdit = new_richedit(NULL);
int i;
- const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s);
+ const int num_tests = ARRAY_SIZE(exsetsel_tests);
/* sending some text to the window */
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection");
--
2.14.4
June 17, 2018
[PATCH 3/3] oleaut32/tests: Use a better type to avoid a cast
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/oleaut32/tests/safearray.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/oleaut32/tests/safearray.c b/dlls/oleaut32/tests/safearray.c
index dc23f58a40..bb4ed78185 100644
--- a/dlls/oleaut32/tests/safearray.c
+++ b/dlls/oleaut32/tests/safearray.c
@@ -765,7 +765,7 @@ static void test_SafeArrayAllocDestroyDescriptor(void)
{
SAFEARRAY *sa;
HRESULT hres;
- int i;
+ UINT i;
/* Failure cases */
hres = SafeArrayAllocDescriptor(0, &sa);
@@ -789,7 +789,7 @@ static void test_SafeArrayAllocDestroyDescriptor(void)
if (hres == S_OK)
{
- ok(SafeArrayGetDim(sa) == (UINT)i, "Dimension is %d; should be %d\n",
+ ok(SafeArrayGetDim(sa) == i, "Dimension is %d; should be %d\n",
SafeArrayGetDim(sa), i);
hres = SafeArrayDestroyDescriptor(sa);
--
2.14.4
June 17, 2018
[PATCH 2/3] oleaut32/tests: Avoid an ARRAY_SIZE-like macro
by Michael Stefaniuc
Also use a better type for the dimension variable.
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/oleaut32/tests/safearray.c | 36 +++++++++++++++++-------------------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/dlls/oleaut32/tests/safearray.c b/dlls/oleaut32/tests/safearray.c
index 8a215df04c..dc23f58a40 100644
--- a/dlls/oleaut32/tests/safearray.c
+++ b/dlls/oleaut32/tests/safearray.c
@@ -828,11 +828,9 @@ static void test_SafeArrayCreateLockDestroy(void)
SAFEARRAY *sa;
HRESULT hres;
VARTYPE vt;
- int dimension;
-
-#define NUM_DIMENSIONS (int)(sizeof(sab) / sizeof(sab[0]))
+ UINT dimension;
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
+ for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
{
sab[dimension].lLbound = 0;
sab[dimension].cElements = 8;
@@ -850,7 +848,7 @@ static void test_SafeArrayCreateLockDestroy(void)
/* Don't test 0 sized dimensions, as Windows has a bug which allows this */
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
+ for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
sab[dimension].cElements = 8;
/* Test all VARTYPES in 1-4 dimensions */
@@ -870,7 +868,7 @@ static void test_SafeArrayCreateLockDestroy(void)
if (sa)
{
- ok(SafeArrayGetDim(sa) == (UINT)dimension,
+ ok(SafeArrayGetDim(sa) == dimension,
"VARTYPE %d (@%d dimensions) cDims is %d, expected %d\n",
vt, dimension, SafeArrayGetDim(sa), dimension);
ok(SafeArrayGetElemsize(sa) == dwLen || vt == VT_R8,
@@ -1007,13 +1005,13 @@ static void test_LockUnlock(void)
hres = SafeArrayUnlock(NULL);
ok(hres == E_INVALIDARG, "Lock NULL array hres 0x%x\n", hres);
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
+ for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
{
sab[dimension].lLbound = 0;
sab[dimension].cElements = 8;
}
- sa = SafeArrayCreate(VT_UI1, NUM_DIMENSIONS, sab);
+ sa = SafeArrayCreate(VT_UI1, ARRAY_SIZE(sab), sab);
/* Test maximum locks */
test_LockUnlock_Vector:
@@ -1054,27 +1052,27 @@ test_LockUnlock_Vector:
static void test_SafeArrayGetPutElement(void)
{
SAFEARRAYBOUND sab[4];
- LONG indices[NUM_DIMENSIONS], index;
+ LONG indices[ARRAY_SIZE(sab)], index;
SAFEARRAY *sa;
HRESULT hres;
int value = 0, gotvalue, dimension;
IRecordInfoImpl *irec;
unsigned int x,y,z,a;
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
+ for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
{
sab[dimension].lLbound = dimension * 2 + 1;
sab[dimension].cElements = dimension * 3 + 1;
}
- sa = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab);
+ sa = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab);
if (!sa)
return; /* Some early versions can't handle > 3 dims */
ok(sa->cbElements == sizeof(value), "int size mismatch\n");
/* Failure cases */
- for (x = 0; x < NUM_DIMENSIONS; x++)
+ for (x = 0; x < ARRAY_SIZE(sab); x++)
{
indices[0] = sab[0].lLbound;
indices[1] = sab[1].lLbound;
@@ -1384,16 +1382,16 @@ static void test_SafeArrayCopyData(void)
return;
}
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
+ for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
{
sab[dimension].lLbound = dimension * 2 + 2;
sab[dimension].cElements = dimension * 3 + 1;
size *= sab[dimension].cElements;
}
- sa = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab);
+ sa = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab);
ok(sa != NULL, "Copy test couldn't create array\n");
- sacopy = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab);
+ sacopy = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab);
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
if (!sa || !sacopy)
@@ -1453,7 +1451,7 @@ static void test_SafeArrayCopyData(void)
hres = SafeArrayDestroy(sacopy);
ok(hres == S_OK, "got 0x%08x\n", hres);
- sacopy = SafeArrayCreate(VT_INT, NUM_DIMENSIONS, sab);
+ sacopy = SafeArrayCreate(VT_INT, ARRAY_SIZE(sab), sab);
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures);
@@ -1491,7 +1489,7 @@ static void test_SafeArrayCopyData(void)
"got 0x%04x\n", sacopy->fFeatures);
SafeArrayDestroy(sacopy);
- sacopy = SafeArrayCreate(VT_UI1, NUM_DIMENSIONS, sab);
+ sacopy = SafeArrayCreate(VT_UI1, ARRAY_SIZE(sab), sab);
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures);
hres = SafeArrayCopyData(sa, sacopy);
@@ -1507,7 +1505,7 @@ static void test_SafeArrayCreateEx(void)
SAFEARRAYBOUND sab[4];
SAFEARRAY *sa;
HRESULT hres;
- int dimension;
+ UINT dimension;
if (!pSafeArrayCreateEx)
{
@@ -1515,7 +1513,7 @@ static void test_SafeArrayCreateEx(void)
return;
}
- for (dimension = 0; dimension < NUM_DIMENSIONS; dimension++)
+ for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
{
sab[dimension].lLbound = 0;
sab[dimension].cElements = 8;
--
2.14.4
June 17, 2018
[PATCH 1/3] oleaut32/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/oleaut32/tests/olefont.c | 2 +-
dlls/oleaut32/tests/olepicture.c | 8 +++---
dlls/oleaut32/tests/safearray.c | 8 +++---
dlls/oleaut32/tests/tmarshal.c | 2 +-
dlls/oleaut32/tests/typelib.c | 26 ++++++++---------
dlls/oleaut32/tests/usrmarshal.c | 4 +--
dlls/oleaut32/tests/varformat.c | 16 +++++------
dlls/oleaut32/tests/vartest.c | 62 ++++++++++++++++++++--------------------
dlls/oleaut32/tests/vartype.c | 24 +++++++---------
9 files changed, 75 insertions(+), 77 deletions(-)
diff --git a/dlls/oleaut32/tests/olefont.c b/dlls/oleaut32/tests/olefont.c
index f9c5625701..10e2a4cf2f 100644
--- a/dlls/oleaut32/tests/olefont.c
+++ b/dlls/oleaut32/tests/olefont.c
@@ -420,7 +420,7 @@ static void test_font_events_disp(void)
hr = IFont_QueryInterface(pFont, &IID_IFontDisp, (void **)&pFontDisp);
EXPECT_HR(hr, S_OK);
- for (i = 0; i < sizeof(font_dispids)/sizeof(font_dispids[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(font_dispids); i++)
{
switch (font_dispids[i].dispid)
{
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c
index 7db1d844ba..50ba7652d8 100644
--- a/dlls/oleaut32/tests/olepicture.c
+++ b/dlls/oleaut32/tests/olepicture.c
@@ -501,7 +501,7 @@ static void test_Invoke(void)
/* DISPID_PICT_RENDER */
hdc = create_render_dc();
- for (i = 0; i < sizeof(args)/sizeof(args[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(args); i++)
V_VT(&args[i]) = VT_I4;
V_I4(&args[0]) = 0;
@@ -679,7 +679,7 @@ static HRESULT picture_render(IPicture *iface, HDC hdc, LONG x, LONG y, LONG cx,
IPicture_QueryInterface(iface, &IID_IDispatch, (void**)&disp);
/* This is broken on 64 bits - accepted pointer argument type is still VT_I4 */
- for (i = 0; i < sizeof(args)/sizeof(args[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(args); i++)
V_VT(&args[i]) = VT_I4;
/* pack arguments and call */
@@ -884,7 +884,7 @@ static void test_OleLoadPicturePath(void)
{emptyW, &IID_IPicture, NULL},
};
- for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{
pic = (IPicture *)0xdeadbeef;
hres = OleLoadPicturePath(invalid_parameters[i].szURLorPath, NULL, 0, 0,
@@ -924,7 +924,7 @@ static void test_OleLoadPicturePath(void)
WriteFile(file, bmpimage, sizeof(bmpimage), &size, NULL);
CloseHandle(file);
- MultiByteToWideChar(CP_ACP, 0, temp_file, -1, temp_fileW + 8, sizeof(temp_fileW)/sizeof(WCHAR) - 8);
+ MultiByteToWideChar(CP_ACP, 0, temp_file, -1, temp_fileW + 8, ARRAY_SIZE(temp_fileW) - 8);
/* Try a normal DOS path. */
hres = OleLoadPicturePath(temp_fileW + 8, NULL, 0, 0, &IID_IPicture, (void **)&pic);
diff --git a/dlls/oleaut32/tests/safearray.c b/dlls/oleaut32/tests/safearray.c
index 5ff29b3c3e..8a215df04c 100644
--- a/dlls/oleaut32/tests/safearray.c
+++ b/dlls/oleaut32/tests/safearray.c
@@ -567,7 +567,7 @@ static void test_safearray(void)
hres = SafeArrayDestroy(a);
ok(hres == S_OK,"SAD failed with hres %x\n", hres);
- for (i=0;i<sizeof(vttypes)/sizeof(vttypes[0]);i++) {
+ for (i = 0; i < ARRAY_SIZE(vttypes); i++) {
if ((i == VT_I8 || i == VT_UI8) && has_i8)
{
vttypes[i].elemsize = sizeof(LONG64);
@@ -704,7 +704,7 @@ static void test_safearray(void)
if (!pSafeArrayAllocDescriptorEx)
return;
- for (i = 0; i < sizeof(vttypes)/sizeof(vttypes[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(vttypes); i++) {
a = NULL;
hres = pSafeArrayAllocDescriptorEx(vttypes[i].vt,1,&a);
ok(hres == S_OK, "SafeArrayAllocDescriptorEx gave hres 0x%x\n", hres);
@@ -1457,7 +1457,7 @@ static void test_SafeArrayCopyData(void)
ok(sacopy != NULL, "Copy test couldn't create copy array\n");
ok(sacopy->fFeatures == FADF_HAVEVARTYPE, "0x%04x\n", sacopy->fFeatures);
- for (i = 0; i < sizeof(ignored_copy_features)/sizeof(USHORT); i++)
+ for (i = 0; i < ARRAY_SIZE(ignored_copy_features); i++)
{
USHORT feature = ignored_copy_features[i];
USHORT orig = sacopy->fFeatures;
@@ -1765,7 +1765,7 @@ static void test_SafeArrayCopy(void)
ok(sa->fFeatures == 0, "got src features 0x%04x\n", sa->fFeatures);
sa->cbElements = 16;
- for (i = 0; i < sizeof(ignored_copy_features)/sizeof(USHORT); i++)
+ for (i = 0; i < ARRAY_SIZE(ignored_copy_features); i++)
{
USHORT feature = ignored_copy_features[i];
diff --git a/dlls/oleaut32/tests/tmarshal.c b/dlls/oleaut32/tests/tmarshal.c
index 00cb4646c5..b48b7855db 100644
--- a/dlls/oleaut32/tests/tmarshal.c
+++ b/dlls/oleaut32/tests/tmarshal.c
@@ -725,7 +725,7 @@ static HRESULT WINAPI Widget_VarArg(
static BOOL mystruct_uint_ordered(MYSTRUCT *mystruct)
{
int i;
- for (i = 0; i < sizeof(mystruct->uarr)/sizeof(mystruct->uarr[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(mystruct->uarr); i++)
if (mystruct->uarr[i] != i)
return FALSE;
return TRUE;
diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c
index 4d5314e1ab..03031743df 100644
--- a/dlls/oleaut32/tests/typelib.c
+++ b/dlls/oleaut32/tests/typelib.c
@@ -627,7 +627,7 @@ static void test_CreateDispTypeInfo(void)
OLECHAR *name = func1;
ifdata.pmethdata = methdata;
- ifdata.cMembers = sizeof(methdata) / sizeof(methdata[0]);
+ ifdata.cMembers = ARRAY_SIZE(methdata);
methdata[0].szName = SysAllocString(func1);
methdata[0].ppdata = parms1;
@@ -1350,7 +1350,7 @@ static LSTATUS myRegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM view)
dwMaxSubkeyLen++;
dwMaxValueLen++;
dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
- if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
+ if (dwMaxLen > ARRAY_SIZE(szNameBuf))
{
/* Name too big: alloc a buffer for it */
if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
@@ -1483,7 +1483,7 @@ static void test_QueryPathOfRegTypeLib(DWORD arch)
if (!do_typelib_reg_key(&uid, 5, 37, arch, base, FALSE)) return;
if (arch == 64 && !do_typelib_reg_key(&uid, 5, 37, 32, wrongW, FALSE)) return;
- for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(td); i++)
{
ret = QueryPathOfRegTypeLib(&uid, td[i].maj, td[i].min, LOCALE_NEUTRAL, &path);
ok(ret == td[i].ret, "QueryPathOfRegTypeLib(%u.%u) returned %08x\n", td[i].maj, td[i].min, ret);
@@ -2309,7 +2309,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
SysFreeString(V_BSTR(¶mdescex.varDefaultValue));
WideCharToMultiByte(CP_ACP, 0, defaultW, -1, nameA, sizeof(nameA), NULL, NULL);
- MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, sizeof(nameW)/sizeof(nameW[0]));
+ MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, ARRAY_SIZE(nameW));
hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
ok(hres == S_OK, "got %08x\n", hres);
@@ -3041,7 +3041,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 0, "got: %u\n", cnames);
- hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
+ hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
@@ -3145,7 +3145,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
SysFreeString(name);
SysFreeString(helpfile);
- hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
+ hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 3, "got: %u\n", cnames);
ok(!memcmp(names[0], func2W, sizeof(func2W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
@@ -3375,7 +3375,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
SysFreeString(name);
SysFreeString(helpfile);
- hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
+ hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
@@ -3474,7 +3474,7 @@ static void test_CreateTypeLib(SYSKIND sys) {
SysFreeString(name);
SysFreeString(helpfile);
- hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, sizeof(names) / sizeof(*names), &cnames);
+ hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
ok(hres == S_OK, "got: %08x\n", hres);
ok(cnames == 1, "got: %u\n", cnames);
ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
@@ -4701,7 +4701,7 @@ static void test_dump_typelib(const char *name)
{
WCHAR wszName[MAX_PATH];
ITypeLib *typelib;
- int ticount = sizeof(info)/sizeof(info[0]);
+ int ticount = ARRAY_SIZE(info);
int iface, func;
MultiByteToWideChar(CP_ACP, 0, name, -1, wszName, MAX_PATH);
@@ -4739,7 +4739,7 @@ static void test_dump_typelib(const char *name)
HRESULT hr;
GUID guid;
- MultiByteToWideChar(CP_ACP, 0, ti->uuid, -1, guidW, sizeof(guidW)/sizeof(guidW[0]));
+ MultiByteToWideChar(CP_ACP, 0, ti->uuid, -1, guidW, ARRAY_SIZE(guidW));
IIDFromString(guidW, &guid);
expect_guid(&guid, &typeattr->guid);
@@ -5002,7 +5002,7 @@ static void test_register_typelib(BOOL system_registration)
}
- StringFromGUID2(&attr->guid, uuidW, sizeof(uuidW) / sizeof(uuidW[0]));
+ StringFromGUID2(&attr->guid, uuidW, ARRAY_SIZE(uuidW));
WideCharToMultiByte(CP_ACP, 0, uuidW, -1, uuid, sizeof(uuid), NULL, NULL);
sprintf(key_name, "Interface\\%s", uuid);
@@ -5050,7 +5050,7 @@ static void test_register_typelib(BOOL system_registration)
if((attr->typekind == TKIND_INTERFACE && (attr->wTypeFlags & TYPEFLAG_FOLEAUTOMATION)) ||
attr->typekind == TKIND_DISPATCH)
{
- StringFromGUID2(&attr->guid, uuidW, sizeof(uuidW) / sizeof(uuidW[0]));
+ StringFromGUID2(&attr->guid, uuidW, ARRAY_SIZE(uuidW));
WideCharToMultiByte(CP_ACP, 0, uuidW, -1, uuid, sizeof(uuid), NULL, NULL);
sprintf(key_name, "Interface\\%s", uuid);
@@ -6204,7 +6204,7 @@ static void test_stub(void)
WCHAR guidW[40];
REGSAM opposite = side ^ (KEY_WOW64_64KEY | KEY_WOW64_32KEY);
- StringFromGUID2(&interfaceguid, guidW, sizeof(guidW)/sizeof(guidW[0]));
+ StringFromGUID2(&interfaceguid, guidW, ARRAY_SIZE(guidW));
/* Delete the opposite interface key */
lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_READ | opposite, &hkey);
diff --git a/dlls/oleaut32/tests/usrmarshal.c b/dlls/oleaut32/tests/usrmarshal.c
index b9478d1b69..5ea13e418b 100644
--- a/dlls/oleaut32/tests/usrmarshal.c
+++ b/dlls/oleaut32/tests/usrmarshal.c
@@ -416,7 +416,7 @@ static void test_marshal_LPSAFEARRAY(void)
/* Test an array of VT_BSTR */
sab[0].lLbound = 3;
- sab[0].cElements = sizeof(values) / sizeof(values[0]);
+ sab[0].cElements = ARRAY_SIZE(values);
lpsa = SafeArrayCreate(VT_BSTR, 1, sab);
expected_bstr_size = 0;
@@ -463,7 +463,7 @@ static void test_marshal_LPSAFEARRAY(void)
ok(next - buffer == expected, "Marshaled %u bytes, expected %u\n", (ULONG) (next - buffer), expected);
ok(lpsa2 != NULL, "LPSAFEARRAY didn't unmarshal, result %p\n", next);
- for (i = 0; i < sizeof(values) / sizeof(values[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(values); i++)
{
BSTR gotvalue = NULL;
diff --git a/dlls/oleaut32/tests/varformat.c b/dlls/oleaut32/tests/varformat.c
index 69476aa5d3..d713894870 100644
--- a/dlls/oleaut32/tests/varformat.c
+++ b/dlls/oleaut32/tests/varformat.c
@@ -80,7 +80,7 @@ static void test_VarFormatNumber(void)
CHECKPTR(VarFormatNumber);
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
+ GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, ARRAY_SIZE(buff));
if (buff[0] != '.' || buff[1])
{
skip("Skipping VarFormatNumber tests as decimal separator is '%s'\n", buff);
@@ -127,7 +127,7 @@ static const char *szVarFmtFail = "VT %d|0x%04x Format %s: expected 0x%08x, '%s'
#define VARFMT(vt,v,val,fmt,ret,str) do { \
out = NULL; \
V_VT(&in) = (vt); v(&in) = val; \
- if (fmt) MultiByteToWideChar(CP_ACP, 0, fmt, -1, buffW, sizeof(buffW)/sizeof(WCHAR)); \
+ if (fmt) MultiByteToWideChar(CP_ACP, 0, fmt, -1, buffW, ARRAY_SIZE(buffW)); \
hres = pVarFormat(&in,fmt ? buffW : NULL,fd,fw,flags,&out); \
if (SUCCEEDED(hres)) WideCharToMultiByte(CP_ACP, 0, out, -1, buff, sizeof(buff),0,0); \
else buff[0] = '\0'; \
@@ -224,7 +224,7 @@ static const FMTDATERES VarFormat_namedtime_results[] =
};
#define VNUMFMT(vt,v) \
- for (i = 0; i < sizeof(VarFormat_results)/sizeof(FMTRES); i++) \
+ for (i = 0; i < ARRAY_SIZE(VarFormat_results); i++) \
{ \
VARFMT(vt,v,1,VarFormat_results[i].fmt,S_OK,VarFormat_results[i].one_res); \
VARFMT(vt,v,0,VarFormat_results[i].fmt,S_OK,VarFormat_results[i].zero_res); \
@@ -256,13 +256,13 @@ static void test_VarFormat(void)
skip("Skipping VarFormat tests for non English language\n");
return;
}
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
+ GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, ARRAY_SIZE(buff));
if (buff[0] != '.' || buff[1])
{
skip("Skipping VarFormat tests as decimal separator is '%s'\n", buff);
return;
}
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IDIGITS, buff, sizeof(buff)/sizeof(char));
+ GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IDIGITS, buff, ARRAY_SIZE(buff));
if (buff[0] != '2' || buff[1])
{
skip("Skipping VarFormat tests as decimal places is '%s'\n", buff);
@@ -296,7 +296,7 @@ static void test_VarFormat(void)
VARFMT(VT_BOOL|VT_BYREF,V_BOOLREF,&bFalse,"True/False",S_OK,"False");
/* Dates */
- for (i = 0; i < sizeof(VarFormat_date_results)/sizeof(FMTDATERES); i++)
+ for (i = 0; i < ARRAY_SIZE(VarFormat_date_results); i++)
{
if (i < 7)
fd = i + 1; /* Test first day */
@@ -308,14 +308,14 @@ static void test_VarFormat(void)
}
/* Named time formats */
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, buff, sizeof(buff)/sizeof(char));
+ GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, buff, ARRAY_SIZE(buff));
if (strcmp(buff, "h:mm:ss tt"))
{
skip("Skipping named time tests as time format is '%s'\n", buff);
}
else
{
- for (i = 0; i < sizeof(VarFormat_namedtime_results)/sizeof(FMTDATERES); i++)
+ for (i = 0; i < ARRAY_SIZE(VarFormat_namedtime_results); i++)
{
fd = 0;
VARFMT(VT_DATE,V_DATE,VarFormat_namedtime_results[i].val,
diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c
index 429ffbbb2e..c00968e225 100644
--- a/dlls/oleaut32/tests/vartest.c
+++ b/dlls/oleaut32/tests/vartest.c
@@ -537,7 +537,7 @@ static const char *vtstr(int x)
return "VT_BSTR_BLOB/VT_ILLEGALMASKED/VT_TYPEMASK";
default:
- vtstr_current %= sizeof(vtstr_buffer)/sizeof(*vtstr_buffer);
+ vtstr_current %= ARRAY_SIZE(vtstr_buffer);
sprintf(vtstr_buffer[vtstr_current], "unknown variant type %d", x);
return vtstr_buffer[vtstr_current++];
}
@@ -545,7 +545,7 @@ static const char *vtstr(int x)
static const char *variantstr( const VARIANT *var )
{
- vtstr_current %= sizeof(vtstr_buffer)/sizeof(*vtstr_buffer);
+ vtstr_current %= ARRAY_SIZE(vtstr_buffer);
switch(V_VT(var))
{
case VT_I1:
@@ -664,7 +664,7 @@ static void test_var_call2( int line, HRESULT (WINAPI *func)(LPVARIANT,LPVARIANT
static int strcmp_wa(const WCHAR *strw, const char *stra)
{
WCHAR buf[512];
- MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(buf[0]));
+ MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, ARRAY_SIZE(buf));
return lstrcmpW(strw, buf);
}
@@ -792,7 +792,7 @@ static void test_VariantClear(void)
* Also demonstrates that null pointers in 'v' are not dereferenced.
* Individual variant tests should test VariantClear() with non-NULL values.
*/
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE vt;
@@ -921,7 +921,7 @@ static void test_VariantCopy(void)
*/
/* vSrc == vDst */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
{
@@ -949,7 +949,7 @@ static void test_VariantCopy(void)
memset(&vSrc, 0, sizeof(vSrc));
V_VT(&vSrc) = VT_UI1;
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
{
@@ -975,7 +975,7 @@ static void test_VariantCopy(void)
}
/* Test that VariantClear() checks vSrc for validity before copying */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
{
@@ -1079,7 +1079,7 @@ static void test_VariantCopyInd(void)
memset(buffer, 0, sizeof(buffer));
/* vSrc == vDst */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
if (ExtraFlags[i] & VT_ARRAY)
continue; /* Native crashes on NULL safearray */
@@ -1130,7 +1130,7 @@ static void test_VariantCopyInd(void)
V_VT(&vSrc) = VT_UI1|VT_BYREF;
V_BYREF(&vSrc) = &buffer;
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
for (vt = 0; vt <= VT_BSTR_BLOB; vt++)
{
@@ -1156,7 +1156,7 @@ static void test_VariantCopyInd(void)
}
/* bad src */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
if (ExtraFlags[i] & VT_ARRAY)
continue; /* Native crashes on NULL safearray */
@@ -1276,7 +1276,7 @@ static HRESULT convert_str( const char *str, INT dig, ULONG flags,
NUMPARSE *np, BYTE rgb[128], LCID lcid )
{
OLECHAR buff[128];
- MultiByteToWideChar( CP_ACP,0, str, -1, buff, sizeof(buff)/sizeof(WCHAR) );
+ MultiByteToWideChar( CP_ACP,0, str, -1, buff, ARRAY_SIZE( buff ));
memset( rgb, FAILDIG, 128 );
memset( np, 255, sizeof(*np) );
np->cDig = dig;
@@ -2291,7 +2291,7 @@ static void test_VarAbs(void)
/* Test all possible V_VT values.
*/
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE vt;
@@ -2354,7 +2354,7 @@ static void test_VarAbs(void)
hres = pVarAbs(&v,&vDst);
ok(hres == S_OK && V_VT(&vDst) == VT_CY && V_CY(&vDst).int64 == 10000,
"VarAbs(CY): expected 0x0 got 0x%X\n", hres);
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
+ GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, ARRAY_SIZE(buff));
if (buff[1])
{
trace("Skipping VarAbs(BSTR) as decimal separator is '%s'\n", buff);
@@ -2392,7 +2392,7 @@ static void test_VarNot(void)
CHECKPTR(VarNot);
/* Test all possible V_VT values */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE vt;
@@ -2523,7 +2523,7 @@ static void test_VarSub(void)
VariantInit(&result);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -3254,7 +3254,7 @@ static void test_VarFix(void)
CHECKPTR(VarFix);
/* Test all possible V_VT values */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE vt;
@@ -3369,7 +3369,7 @@ static void test_VarInt(void)
CHECKPTR(VarInt);
/* Test all possible V_VT values */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE vt;
@@ -3490,7 +3490,7 @@ static void test_VarNeg(void)
* native version. This at least ensures (as with all tests here) that
* we will notice if/when new vtypes/flags are added in native.
*/
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE vt;
@@ -3677,7 +3677,7 @@ static void test_VarRound(void)
VARROUND(DATE,-1.449,1,DATE,-1.4);
/* replace the decimal separator */
- GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, sizeof(buff)/sizeof(char));
+ GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buff, ARRAY_SIZE(buff));
if (!buff[1]) {
szNumMin[2] = buff[0];
szNum[1] = buff[0];
@@ -3721,7 +3721,7 @@ static void test_VarRound(void)
"VarRound: expected 0x0,%d got 0x%X,%d\n", VT_NULL, hres, V_VT(&vDst));
/* VT_DECIMAL */
- for (i = 0; i < sizeof(decimal_round_data)/sizeof(struct decimal_round_t); i++)
+ for (i = 0; i < ARRAY_SIZE(decimal_round_data); i++)
{
const struct decimal_round_t *ptr = &decimal_round_data[i];
DECIMAL *pdec;
@@ -3786,7 +3786,7 @@ static void test_VarXor(void)
CHECKPTR(VarXor);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -4520,7 +4520,7 @@ static void test_VarOr(void)
CHECKPTR(VarOr);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -5252,7 +5252,7 @@ static void test_VarEqv(void)
CHECKPTR(VarEqv);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -5396,7 +5396,7 @@ static void test_VarMul(void)
rbstr = SysAllocString(sz12);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -5567,7 +5567,7 @@ static void test_VarAdd(void)
rbstr = SysAllocString(sz12);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -6231,7 +6231,7 @@ static void test_VarAnd(void)
false_str = SysAllocString(szFalse);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -6947,7 +6947,7 @@ static void test_VarCmp(void)
bstr1few = SysAllocString(sz1few);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt;
@@ -7183,7 +7183,7 @@ static void test_VarPow(void)
num3_str = SysAllocString(str3);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -7709,7 +7709,7 @@ static void test_VarDiv(void)
num2_str = SysAllocString(str2);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -8082,7 +8082,7 @@ static void test_VarIdiv(void)
num2_str = SysAllocString(str2);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
@@ -8648,7 +8648,7 @@ static void test_VarImp(void)
false_str = SysAllocString(szFalse);
/* Test all possible flag/vt combinations & the resulting vt type */
- for (i = 0; i < sizeof(ExtraFlags)/sizeof(ExtraFlags[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(ExtraFlags); i++)
{
VARTYPE leftvt, rightvt, resvt;
diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c
index 9be2eb2901..e93a6e6a8d 100644
--- a/dlls/oleaut32/tests/vartype.c
+++ b/dlls/oleaut32/tests/vartype.c
@@ -112,7 +112,7 @@ static BOOL has_locales;
#define CONVERT_STR(func,str,flags) \
SetLastError(0); \
- if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \
+ if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,ARRAY_SIZE(buff)); \
hres = func(str ? buff : NULL,in,flags,&out)
#define COPYTEST(val, vt, srcval, dstval, srcref, dstref, fs) do { \
@@ -2944,7 +2944,7 @@ static void test_VarDateFromDec(void)
#define DFS(str) \
buff[0] = '\0'; out = 0.0; \
- if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,sizeof(buff)/sizeof(WCHAR)); \
+ if (str) MultiByteToWideChar(CP_ACP,0,str,-1,buff,ARRAY_SIZE(buff)); \
hres = VarDateFromStr(str ? buff : NULL,lcid,LOCALE_NOUSEROVERRIDE,&out)
#define MKRELDATE(day,mth) st.wMonth = mth; st.wDay = day; \
@@ -3091,7 +3091,7 @@ static void test_VarDateFromStr(void)
DFS("1.2.3 4 5 6"); EXPECT_DBL(38812.04309027778);
DFS("1 2 3 4.5.6"); EXPECT_DBL(37623.17020833334);
- for (i = 0; i < sizeof(BadDateStrings)/sizeof(char*); i++)
+ for (i = 0; i < ARRAY_SIZE(BadDateStrings); i++)
{
DFS(BadDateStrings[i]); EXPECT_MISMATCH;
}
@@ -4816,12 +4816,12 @@ static void test_VarBstrCmp(void)
/* These two strings are considered equal even though one is
* NULL-terminated and the other not.
*/
- bstr2 = SysAllocStringLen(s1, sizeof(s1) / sizeof(WCHAR));
+ bstr2 = SysAllocStringLen(s1, ARRAY_SIZE(s1));
VARBSTRCMP(bstr,bstr2,0,VARCMP_EQ);
SysFreeString(bstr2);
/* These two strings are not equal */
- bstr2 = SysAllocStringLen(s2, sizeof(s2) / sizeof(WCHAR));
+ bstr2 = SysAllocStringLen(s2, ARRAY_SIZE(s2));
VARBSTRCMP(bstr,bstr2,0,VARCMP_LT);
SysFreeString(bstr2);
@@ -5235,8 +5235,7 @@ if (0)
ret = VarBstrCat(str1, str2, &res);
ok(ret == S_OK, "VarBstrCat failed: %08x\n", ret);
ok(res != NULL, "Expected a string\n");
- ok(SysStringLen(res) == sizeof(sz1sz2) / sizeof(WCHAR) - 1,
- "Unexpected length\n");
+ ok(SysStringLen(res) == ARRAY_SIZE(sz1sz2) - 1, "Unexpected length\n");
ok(!memcmp(res, sz1sz2, sizeof(sz1sz2)), "Unexpected value\n");
SysFreeString(res);
@@ -5244,14 +5243,13 @@ if (0)
SysFreeString(str1);
/* Concatenation of two strings with embedded NULLs */
- str1 = SysAllocStringLen(s1, sizeof(s1) / sizeof(WCHAR));
- str2 = SysAllocStringLen(s2, sizeof(s2) / sizeof(WCHAR));
+ str1 = SysAllocStringLen(s1, ARRAY_SIZE(s1));
+ str2 = SysAllocStringLen(s2, ARRAY_SIZE(s2));
ret = VarBstrCat(str1, str2, &res);
ok(ret == S_OK, "VarBstrCat failed: %08x\n", ret);
ok(res != NULL, "Expected a string\n");
- ok(SysStringLen(res) == sizeof(s1s2) / sizeof(WCHAR),
- "Unexpected length\n");
+ ok(SysStringLen(res) == ARRAY_SIZE(s1s2), "Unexpected length\n");
ok(!memcmp(res, s1s2, sizeof(s1s2)), "Unexpected value\n");
SysFreeString(res);
@@ -5893,13 +5891,13 @@ static void test_bstr_cache(void)
/* Fill the bucket with cached entries.
We roll our own, to show that the cache doesn't use
the bstr length field to determine bucket allocation. */
- for(i=0; i < sizeof(strs)/sizeof(*strs); i++)
+ for(i=0; i < ARRAY_SIZE(strs); i++)
{
DWORD_PTR *ptr = CoTaskMemAlloc(64);
ptr[0] = 0;
strs[i] = (BSTR)(ptr + 1);
}
- for(i=0; i < sizeof(strs)/sizeof(*strs); i++)
+ for(i=0; i < ARRAY_SIZE(strs); i++)
SysFreeString(strs[i]);
/* Following allocation will be made from cache */
--
2.14.4
June 17, 2018
[PATCH] winedbg: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
programs/winedbg/crashdlg.c | 13 ++++++-------
programs/winedbg/gdbproxy.c | 12 ++++++------
programs/winedbg/tgt_active.c | 6 +++---
3 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/programs/winedbg/crashdlg.c b/programs/winedbg/crashdlg.c
index 4e02a4bb7c..5c913ff7a1 100644
--- a/programs/winedbg/crashdlg.c
+++ b/programs/winedbg/crashdlg.c
@@ -38,8 +38,8 @@ int msgbox_res_id(HWND hwnd, UINT textId, UINT captionId, UINT uType)
{
WCHAR caption[256];
WCHAR text[256];
- LoadStringW(GetModuleHandleW(NULL), captionId, caption, sizeof(caption)/sizeof(caption[0]));
- LoadStringW(GetModuleHandleW(NULL), textId, text, sizeof(text)/sizeof(text[0]));
+ LoadStringW(GetModuleHandleW(NULL), captionId, caption, ARRAY_SIZE(caption));
+ LoadStringW(GetModuleHandleW(NULL), textId, text, ARRAY_SIZE(text));
return MessageBoxW(hwnd, text, caption, uType);
}
@@ -116,8 +116,7 @@ static void set_message_with_filename(HWND hDlg)
WCHAR originalText[1000];
WCHAR newText[1000 + MAX_PROGRAM_NAME_LENGTH];
- GetDlgItemTextW(hDlg, IDC_STATIC_TXT1, originalText,
- sizeof(originalText)/sizeof(originalText[0]));
+ GetDlgItemTextW(hDlg, IDC_STATIC_TXT1, originalText, ARRAY_SIZE(originalText));
wsprintfW(newText, originalText, g_ProgramName);
SetDlgItemTextW(hDlg, IDC_STATIC_TXT1, newText);
}
@@ -150,11 +149,11 @@ static void save_crash_log( HWND hwnd )
memset( &save, 0, sizeof(save) );
lstrcpyW( path, default_name );
- LoadStringW( GetModuleHandleW(0), IDS_TEXT_FILES, buffer, sizeof(buffer)/sizeof(buffer[0]) );
+ LoadStringW( GetModuleHandleW(0), IDS_TEXT_FILES, buffer, ARRAY_SIZE(buffer));
p = buffer + lstrlenW(buffer) + 1;
lstrcpyW(p, txt_files);
p += lstrlenW(p) + 1;
- LoadStringW( GetModuleHandleW(0), IDS_ALL_FILES, p, sizeof(buffer)/sizeof(buffer[0]) - (p - buffer) );
+ LoadStringW( GetModuleHandleW(0), IDS_ALL_FILES, p, ARRAY_SIZE(buffer) - (p - buffer) );
p += lstrlenW(p) + 1;
lstrcpyW(p, all_files);
p += lstrlenW(p) + 1;
@@ -189,7 +188,7 @@ static void save_crash_log( HWND hwnd )
}
else err = GetLastError();
- LoadStringW( GetModuleHandleW(0), IDS_SAVE_ERROR, buffer, sizeof(buffer)/sizeof(WCHAR) );
+ LoadStringW( GetModuleHandleW(0), IDS_SAVE_ERROR, buffer, ARRAY_SIZE(buffer));
FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, err, 0, (LPWSTR)&p, 0, NULL);
MessageBoxW( 0, p, buffer, MB_OK | MB_ICONERROR);
diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c
index 7f59ce1df6..b8387fe0ec 100644
--- a/programs/winedbg/gdbproxy.c
+++ b/programs/winedbg/gdbproxy.c
@@ -391,7 +391,7 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
memory_get_string_indirect(gdbctx->process,
de->u.CreateProcessInfo.lpImageName,
de->u.CreateProcessInfo.fUnicode,
- u.buffer, sizeof(u.buffer) / sizeof(WCHAR));
+ u.buffer, ARRAY_SIZE(u.buffer));
dbg_set_process_name(gdbctx->process, u.buffer);
if (gdbctx->trace & GDBPXY_TRC_WIN32_EVENT)
@@ -423,7 +423,7 @@ static void handle_debug_event(struct gdb_context* gdbctx, DEBUG_EVENT* de)
memory_get_string_indirect(gdbctx->process,
de->u.LoadDll.lpImageName,
de->u.LoadDll.fUnicode,
- u.buffer, sizeof(u.buffer) / sizeof(WCHAR));
+ u.buffer, ARRAY_SIZE(u.buffer));
if (gdbctx->trace & GDBPXY_TRC_WIN32_EVENT)
fprintf(stderr, "%04x:%04x: loads DLL %s @%p (%u<%u>)\n",
de->dwProcessId, de->dwThreadId,
@@ -1146,7 +1146,7 @@ static enum packet_return packet_verbose(struct gdb_context* gdbctx)
if (gdbctx->trace & GDBPXY_TRC_COMMAND)
fprintf(stderr, "trying to process a verbose packet %*.*s\n",
gdbctx->in_packet_len, gdbctx->in_packet_len, gdbctx->in_packet);
- for (i = 0; i < sizeof(verbose_details)/sizeof(verbose_details[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(verbose_details); i++)
{
if (klen == verbose_details[i].len &&
!memcmp(gdbctx->in_packet, verbose_details[i].name, verbose_details[i].len))
@@ -1934,11 +1934,11 @@ static BOOL extract_packets(struct gdb_context* gdbctx)
assert(plen);
/* FIXME: should use bsearch if packet_entries was sorted */
- for (i = 0; i < sizeof(packet_entries)/sizeof(packet_entries[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(packet_entries); i++)
{
if (packet_entries[i].key == gdbctx->in_buf[1]) break;
}
- if (i == sizeof(packet_entries)/sizeof(packet_entries[0]))
+ if (i == ARRAY_SIZE(packet_entries))
{
if (gdbctx->trace & GDBPXY_TRC_COMMAND_ERROR)
fprintf(stderr, "Unknown packet request %*.*s\n",
@@ -2178,7 +2178,7 @@ static BOOL gdb_init_context(struct gdb_context* gdbctx, unsigned flags, unsigne
gdbctx->in_trap = FALSE;
gdbctx->trace = /*GDBPXY_TRC_PACKET | GDBPXY_TRC_COMMAND |*/ GDBPXY_TRC_COMMAND_ERROR | GDBPXY_TRC_COMMAND_FIXME | GDBPXY_TRC_WIN32_EVENT;
gdbctx->process = NULL;
- for (i = 0; i < sizeof(gdbctx->wine_segs) / sizeof(gdbctx->wine_segs[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(gdbctx->wine_segs); i++)
gdbctx->wine_segs[i] = 0;
/* wait for first trap */
diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c
index e5fd07da92..c5569e6adf 100644
--- a/programs/winedbg/tgt_active.c
+++ b/programs/winedbg/tgt_active.c
@@ -360,7 +360,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
fetch_module_name(de->u.CreateProcessInfo.lpImageName,
de->u.CreateProcessInfo.fUnicode,
de->u.CreateProcessInfo.lpBaseOfImage,
- u.buffer, sizeof(u.buffer) / sizeof(WCHAR), TRUE);
+ u.buffer, ARRAY_SIZE(u.buffer), TRUE);
WINE_TRACE("%04x:%04x: create process '%s'/%p @%p (%u<%u>)\n",
de->dwProcessId, de->dwThreadId,
@@ -455,7 +455,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de)
fetch_module_name(de->u.LoadDll.lpImageName,
de->u.LoadDll.fUnicode,
de->u.LoadDll.lpBaseOfDll,
- u.buffer, sizeof(u.buffer) / sizeof(WCHAR), FALSE);
+ u.buffer, ARRAY_SIZE(u.buffer), FALSE);
WINE_TRACE("%04x:%04x: loads DLL %s @%p (%u<%u>)\n",
de->dwProcessId, de->dwThreadId,
@@ -708,7 +708,7 @@ static const char *get_windows_version(void)
GetVersionExW( (OSVERSIONINFOW *)&info );
- for (i = 0; i < sizeof(version_table) / sizeof(version_table[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(version_table); i++)
{
if (version_table[i].type == info.wProductType &&
version_table[i].platform == info.dwPlatformId &&
--
2.14.4
June 17, 2018
Re: [PATCH 2/2] user32/tests: Skip tests for window messages if we failed to receive foreground status.
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=39204
Your paranoid android.
=== w7pro64 (64 bit input) ===
input.c:2055: Test failed: expected WM_NCHITTEST message
input.c:2082: Test failed: expected loop with WM_NCHITTEST messages
input.c:2135: Test failed: expected WM_LBUTTONDOWN message
input.c:2136: Test failed: expected WM_LBUTTONUP message
June 17, 2018
[PATCH 2/2] user32/tests: Skip tests for window messages if we failed to receive foreground status.
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
This should be a better way of checking for failure since it addresses the
root cause, and should hopefully also fix an intermittent test failure on
Wine.
dlls/user32/tests/input.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index 2185cda..8fa1de2 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -691,14 +691,17 @@ static struct message sent_messages[MAXKEYMESSAGES];
static UINT sent_messages_cnt;
/* Verify that only specified key state transitions occur */
-static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinput_test_s *test)
+static void compare_and_check(int id, BYTE *ks1, BYTE *ks2,
+ const struct sendinput_test_s *test, BOOL foreground)
{
int i, failcount = 0;
const struct transition_s *t = test->expected_transitions;
UINT actual_cnt = 0;
const struct message *expected = test->expected_messages;
- while (t->wVk) {
+ while (t->wVk && foreground) {
+ /* We won't receive any information from GetKeyboardState() if we're
+ * not the foreground window. */
BOOL matched = ((ks1[t->wVk]&0x80) == (t->before_state&0x80)
&& (ks2[t->wVk]&0x80) == (~t->before_state&0x80));
@@ -781,6 +784,13 @@ static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinp
expected++;
continue;
}
+ else if (!(expected->flags & hook) && !foreground)
+ {
+ /* If we weren't able to receive foreground status, we won't get
+ * any window messages. */
+ expected++;
+ continue;
+ }
/* NT4 doesn't send SYSKEYDOWN/UP to hooks, only KEYDOWN/UP */
else if ((expected->flags & hook) &&
(expected->message == WM_SYSKEYDOWN || expected->message == WM_SYSKEYUP) &&
@@ -817,7 +827,7 @@ static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinp
expected++;
}
/* skip all optional trailing messages */
- while (expected->message && (expected->flags & optional))
+ while (expected->message && ((expected->flags & optional) || (!(expected->flags & hook) && !foreground)))
expected++;
@@ -897,6 +907,7 @@ static void test_Input_blackbox(void)
int ii;
BYTE ks1[256], ks2[256];
LONG_PTR prevWndProc;
+ BOOL foreground;
HWND window;
HHOOK hook;
@@ -910,7 +921,9 @@ static void test_Input_blackbox(void)
NULL, NULL);
ok(window != NULL, "error: %d\n", (int) GetLastError());
SetWindowPos( window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
- SetForegroundWindow( window );
+ foreground = SetForegroundWindow( window );
+ if (!foreground)
+ skip("Failed to set foreground window; some tests will be skipped.\n");
if (!(hook = SetWindowsHookExA(WH_KEYBOARD_LL, hook_proc, GetModuleHandleA( NULL ), 0)))
{
@@ -939,15 +952,7 @@ static void test_Input_blackbox(void)
pSendInput(1, (INPUT*)&i, sizeof(TEST_INPUT));
empty_message_queue();
GetKeyboardState(ks2);
- if (!ii && sent_messages_cnt <= 1 && !memcmp( ks1, ks2, sizeof(ks1) ))
- {
- win_skip( "window doesn't receive the queued input\n" );
- /* release the key */
- i.u.ki.dwFlags |= KEYEVENTF_KEYUP;
- pSendInput(1, (INPUT*)&i, sizeof(TEST_INPUT));
- break;
- }
- compare_and_check(ii, ks1, ks2, &sendinput_test[ii]);
+ compare_and_check(ii, ks1, ks2, &sendinput_test[ii], foreground);
}
empty_message_queue();
--
2.7.4
June 17, 2018
[PATCH 1/2] user32/tests: Ignore all non-keyboard messages in test_Input_blackbox().
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/user32/tests/input.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index e52f7d2..2185cda 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -848,16 +848,7 @@ static LRESULT CALLBACK WndProc2(HWND hWnd, UINT Msg, WPARAM wParam,
{
if (winetest_debug > 1) trace("MSG: %8x W:%8lx L:%8lx\n", Msg, wParam, lParam);
- if (Msg != WM_PAINT &&
- Msg != WM_NCPAINT &&
- Msg != WM_SYNCPAINT &&
- Msg != WM_ERASEBKGND &&
- Msg != WM_NCHITTEST &&
- Msg != WM_GETTEXT &&
- Msg != WM_GETICON &&
- Msg != WM_IME_SELECT &&
- Msg != WM_DEVICECHANGE &&
- Msg != WM_TIMECHANGE)
+ if ((Msg >= WM_KEYFIRST && Msg <= WM_KEYLAST) || Msg == WM_SYSCOMMAND)
{
ok(sent_messages_cnt < MAXKEYMESSAGES, "Too many messages\n");
if (sent_messages_cnt < MAXKEYMESSAGES)
--
2.7.4
June 17, 2018
[PATCH v2] msvcrt: Use already existent oneexit_table functions for _onexit and _c_exit
by Fabian Maurer
For that to work, MSVCRT__register_onexit_function and
MSVCRT__execute_onexit_table have to available all the time,
not only when _MSVCR_VER>=140
tests based on code by Piotr Caban
v2:
Create exit_event2 in test function, so it exists in child process
Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de>
---
dlls/msvcrt/exit.c | 68 ++++++++++-------------------------
dlls/ucrtbase/tests/misc.c | 74 +++++++++++++++++++++++++++++++++++++-
2 files changed, 91 insertions(+), 51 deletions(-)
diff --git a/dlls/msvcrt/exit.c b/dlls/msvcrt/exit.c
index 7e1805569c..c90f7df953 100644
--- a/dlls/msvcrt/exit.c
+++ b/dlls/msvcrt/exit.c
@@ -25,13 +25,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
-/* MT */
-#define LOCK_EXIT _mlock(_EXIT_LOCK1)
-#define UNLOCK_EXIT _munlock(_EXIT_LOCK1)
-
-static MSVCRT__onexit_t *MSVCRT_atexit_table = NULL;
-static int MSVCRT_atexit_table_size = 0;
-static int MSVCRT_atexit_registered = 0; /* Points to free slot */
static MSVCRT_purecall_handler purecall_handler = NULL;
typedef struct MSVCRT__onexit_table_t
@@ -41,6 +34,11 @@ typedef struct MSVCRT__onexit_table_t
MSVCRT__onexit_t *_end;
} MSVCRT__onexit_table_t;
+static MSVCRT__onexit_table_t MSVCRT_atexit_table;
+
+int CDECL MSVCRT__register_onexit_function(MSVCRT__onexit_table_t *table, MSVCRT__onexit_t func);
+int CDECL MSVCRT__execute_onexit_table(MSVCRT__onexit_table_t *table);
+
typedef void (__stdcall *_tls_callback_type)(void*,ULONG,void*);
static _tls_callback_type tls_atexit_callback;
@@ -65,17 +63,8 @@ void (*CDECL _aexit_rtn)(int) = MSVCRT__exit;
static void __MSVCRT__call_atexit(void)
{
/* Note: should only be called with the exit lock held */
- TRACE("%d atext functions to call\n", MSVCRT_atexit_registered);
if (tls_atexit_callback) tls_atexit_callback(NULL, DLL_PROCESS_DETACH, NULL);
- /* Last registered gets executed first */
- while (MSVCRT_atexit_registered > 0)
- {
- MSVCRT_atexit_registered--;
- TRACE("next is %p\n",MSVCRT_atexit_table[MSVCRT_atexit_registered]);
- if (MSVCRT_atexit_table[MSVCRT_atexit_registered])
- (*MSVCRT_atexit_table[MSVCRT_atexit_registered])();
- TRACE("returned\n");
- }
+ MSVCRT__execute_onexit_table(&MSVCRT_atexit_table);
}
/*********************************************************************
@@ -276,9 +265,7 @@ void CDECL MSVCRT__c_exit(void)
void CDECL MSVCRT__cexit(void)
{
TRACE("(void)\n");
- LOCK_EXIT;
__MSVCRT__call_atexit();
- UNLOCK_EXIT;
}
/*********************************************************************
@@ -291,26 +278,8 @@ MSVCRT__onexit_t CDECL MSVCRT__onexit(MSVCRT__onexit_t func)
if (!func)
return NULL;
- LOCK_EXIT;
- if (MSVCRT_atexit_registered > MSVCRT_atexit_table_size - 1)
- {
- MSVCRT__onexit_t *newtable;
- TRACE("expanding table\n");
- newtable = MSVCRT_calloc(MSVCRT_atexit_table_size + 32, sizeof(void *));
- if (!newtable)
- {
- TRACE("failed!\n");
- UNLOCK_EXIT;
- return NULL;
- }
- memcpy (newtable, MSVCRT_atexit_table, MSVCRT_atexit_table_size*sizeof(void *));
- MSVCRT_atexit_table_size += 32;
- MSVCRT_free (MSVCRT_atexit_table);
- MSVCRT_atexit_table = newtable;
- }
- MSVCRT_atexit_table[MSVCRT_atexit_registered] = func;
- MSVCRT_atexit_registered++;
- UNLOCK_EXIT;
+ MSVCRT__register_onexit_function(&MSVCRT_atexit_table, func);
+
return func;
}
@@ -359,6 +328,16 @@ int CDECL MSVCRT__crt_atexit(void (*func)(void))
return MSVCRT__onexit((MSVCRT__onexit_t)func) == (MSVCRT__onexit_t)func ? 0 : -1;
}
+/*********************************************************************
+ * _register_thread_local_exe_atexit_callback (UCRTBASE.@)
+ */
+void CDECL _register_thread_local_exe_atexit_callback(_tls_callback_type callback)
+{
+ TRACE("(%p)\n", callback);
+ tls_atexit_callback = callback;
+}
+
+#endif /* _MSVCR_VER>=140 */
/*********************************************************************
* _initialize_onexit_table (UCRTBASE.@)
@@ -457,17 +436,6 @@ int CDECL MSVCRT__execute_onexit_table(MSVCRT__onexit_table_t *table)
return 0;
}
-/*********************************************************************
- * _register_thread_local_exe_atexit_callback (UCRTBASE.@)
- */
-void CDECL _register_thread_local_exe_atexit_callback(_tls_callback_type callback)
-{
- TRACE("(%p)\n", callback);
- tls_atexit_callback = callback;
-}
-
-#endif /* _MSVCR_VER>=140 */
-
#if _MSVCR_VER>=71
/*********************************************************************
* _set_purecall_handler (MSVCR71.@)
diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c
index 354fab1e94..ed5bb0589c 100644
--- a/dlls/ucrtbase/tests/misc.c
+++ b/dlls/ucrtbase/tests/misc.c
@@ -125,6 +125,8 @@ static int (CDECL *p_fesetround)(int);
static void (CDECL *p___setusermatherr)(MSVCRT_matherr_func);
static int* (CDECL *p_errno)(void);
static char* (CDECL *p_asctime)(const struct tm *);
+static void (CDECL *p_exit)(int);
+static int (CDECL *p__crt_atexit)(void (CDECL*)(void));
static void test__initialize_onexit_table(void)
{
@@ -429,6 +431,8 @@ static BOOL init(void)
p___setusermatherr = (void*)GetProcAddress(module, "__setusermatherr");
p_errno = (void*)GetProcAddress(module, "_errno");
p_asctime = (void*)GetProcAddress(module, "asctime");
+ p__crt_atexit = (void*)GetProcAddress(module, "_crt_atexit");
+ p_exit = (void*)GetProcAddress(module, "exit");
return TRUE;
}
@@ -765,6 +769,70 @@ static void test_asctime(void)
ok(!strcmp(ret, "Thu Jan 1 00:00:00 1970\n"), "asctime returned %s\n", ret);
}
+static void test_exit(const char *argv0)
+{
+ HANDLE exit_event1, exit_event2;
+ PROCESS_INFORMATION proc;
+ STARTUPINFOA startup = {0};
+ char path[MAX_PATH];
+ DWORD ret;
+
+ exit_event1 = CreateEventA(NULL, FALSE, FALSE, "exit_event1");
+ exit_event2 = CreateEventA(NULL, FALSE, FALSE, "exit_event2");
+
+ sprintf(path, "%s misc exit", argv0);
+ startup.cb = sizeof(startup);
+ CreateProcessA(NULL, path, NULL, NULL, TRUE, 0, NULL, NULL, &startup, &proc);
+ winetest_wait_child_process(proc.hProcess);
+
+ ret = WaitForSingleObject(exit_event1, 0);
+ ok(ret == WAIT_OBJECT_0, "exit_event1 was not set (%x)\n", ret);
+
+ CloseHandle(exit_event1);
+ CloseHandle(exit_event2);
+}
+
+static void CDECL at_exit_func1(void)
+{
+ HANDLE exit_event1 = CreateEventA(NULL, FALSE, FALSE, "exit_event1");
+ HANDLE exit_event2 = CreateEventA(NULL, FALSE, FALSE, "exit_event2");
+ DWORD ret;
+
+ ok(exit_event1 != NULL, "CreateEvent failed: %d\n", GetLastError());
+ ok(exit_event2 != NULL, "CreateEvent failed: %d\n", GetLastError());
+
+ ret = WaitForSingleObject(exit_event2, 0);
+ ok(ret == WAIT_OBJECT_0, "exit_event2 was not set (%x)\n", ret);
+
+ SetEvent(exit_event1);
+ CloseHandle(exit_event1);
+ CloseHandle(exit_event2);
+}
+
+static void CDECL at_exit_func2(void)
+{
+ HANDLE exit_event1 = CreateEventA(NULL, FALSE, FALSE, "exit_event1");
+ HANDLE exit_event2 = CreateEventA(NULL, FALSE, FALSE, "exit_event2");
+ DWORD ret;
+
+ ok(exit_event1 != NULL, "CreateEvent failed: %d\n", GetLastError());
+ ok(exit_event2 != NULL, "CreateEvent failed: %d\n", GetLastError());
+
+ ret = WaitForSingleObject(exit_event1, 0);
+ ok(ret == WAIT_TIMEOUT, "exit_event1 should not be set (%x)\n", ret);
+
+ SetEvent(exit_event2);
+ CloseHandle(exit_event1);
+ CloseHandle(exit_event2);
+}
+
+static void test_call_exit(void)
+{
+ ok(!p__crt_atexit(at_exit_func1), "_crt_atexit failed\n");
+ ok(!p__crt_atexit(at_exit_func2), "_crt_atexit failed\n");
+ p_exit(0);
+}
+
START_TEST(misc)
{
int arg_c;
@@ -775,7 +843,10 @@ START_TEST(misc)
arg_c = winetest_get_mainargs(&arg_v);
if(arg_c == 3) {
- test__get_narrow_winmain_command_line(NULL);
+ if(!strcmp(arg_v[2], "cmd"))
+ test__get_narrow_winmain_command_line(NULL);
+ else if(!strcmp(arg_v[2], "exit"))
+ test_call_exit();
return;
}
@@ -791,4 +862,5 @@ START_TEST(misc)
test_isblank();
test_math_errors();
test_asctime();
+ test_exit(arg_v[0]);
}
--
2.17.1
June 17, 2018
Re: [PATCH] msvcrt: Use already existent oneexit_table functions for _onexit and _c_exit
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=39191
Your paranoid android.
=== wvistau64 (32 bit misc) ===
misc.c:803: Test failed: exit_event2 was not set (102)
ucrtbase:misc has unaccounted for failure messages
ucrtbase:misc returned success despite having failures
=== wvistau64_zh_CN (32 bit misc) ===
misc.c:803: Test failed: exit_event2 was not set (102)
ucrtbase:misc has unaccounted for failure messages
ucrtbase:misc returned success despite having failures
=== wvistau64_fr (32 bit misc) ===
misc.c:803: Test failed: exit_event2 was not set (102)
ucrtbase:misc has unaccounted for failure messages
ucrtbase:misc returned success despite having failures
=== wvistau64_he (32 bit misc) ===
misc.c:803: Test failed: exit_event2 was not set (102)
ucrtbase:misc has unaccounted for failure messages
ucrtbase:misc returned success despite having failures
=== w7u (32 bit misc) ===
misc.c:803: Test failed: exit_event2 was not set (102)
ucrtbase:misc has unaccounted for failure messages
ucrtbase:misc returned success despite having failures
=== w1064 (32 bit misc) ===
misc.c:803: Test failed: exit_event2 was not set (102)
ucrtbase:misc has unaccounted for failure messages
ucrtbase:misc returned success despite having failures
=== wvistau64 (64 bit misc) ===
misc.c:803: Test failed: exit_event2 was not set (102)
ucrtbase:misc has unaccounted for failure messages
ucrtbase:misc returned success despite having failures
=== w1064 (64 bit misc) ===
misc.c:803: Test failed: exit_event2 was not set (102)
ucrtbase:misc has unaccounted for failure messages
ucrtbase:misc returned success despite having failures
June 17, 2018
[PATCH] msvcrt: Use already existent oneexit_table functions for _onexit and _c_exit
by Fabian Maurer
For that to work, MSVCRT__register_onexit_function and
MSVCRT__execute_onexit_table have to available all the time,
not only when _MSVCR_VER>=140
tests based on code by Piotr Caban
Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de>
---
dlls/msvcrt/exit.c | 68 ++++++++++-------------------------
dlls/ucrtbase/tests/misc.c | 72 +++++++++++++++++++++++++++++++++++++-
2 files changed, 89 insertions(+), 51 deletions(-)
diff --git a/dlls/msvcrt/exit.c b/dlls/msvcrt/exit.c
index 7e1805569c..c90f7df953 100644
--- a/dlls/msvcrt/exit.c
+++ b/dlls/msvcrt/exit.c
@@ -25,13 +25,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
-/* MT */
-#define LOCK_EXIT _mlock(_EXIT_LOCK1)
-#define UNLOCK_EXIT _munlock(_EXIT_LOCK1)
-
-static MSVCRT__onexit_t *MSVCRT_atexit_table = NULL;
-static int MSVCRT_atexit_table_size = 0;
-static int MSVCRT_atexit_registered = 0; /* Points to free slot */
static MSVCRT_purecall_handler purecall_handler = NULL;
typedef struct MSVCRT__onexit_table_t
@@ -41,6 +34,11 @@ typedef struct MSVCRT__onexit_table_t
MSVCRT__onexit_t *_end;
} MSVCRT__onexit_table_t;
+static MSVCRT__onexit_table_t MSVCRT_atexit_table;
+
+int CDECL MSVCRT__register_onexit_function(MSVCRT__onexit_table_t *table, MSVCRT__onexit_t func);
+int CDECL MSVCRT__execute_onexit_table(MSVCRT__onexit_table_t *table);
+
typedef void (__stdcall *_tls_callback_type)(void*,ULONG,void*);
static _tls_callback_type tls_atexit_callback;
@@ -65,17 +63,8 @@ void (*CDECL _aexit_rtn)(int) = MSVCRT__exit;
static void __MSVCRT__call_atexit(void)
{
/* Note: should only be called with the exit lock held */
- TRACE("%d atext functions to call\n", MSVCRT_atexit_registered);
if (tls_atexit_callback) tls_atexit_callback(NULL, DLL_PROCESS_DETACH, NULL);
- /* Last registered gets executed first */
- while (MSVCRT_atexit_registered > 0)
- {
- MSVCRT_atexit_registered--;
- TRACE("next is %p\n",MSVCRT_atexit_table[MSVCRT_atexit_registered]);
- if (MSVCRT_atexit_table[MSVCRT_atexit_registered])
- (*MSVCRT_atexit_table[MSVCRT_atexit_registered])();
- TRACE("returned\n");
- }
+ MSVCRT__execute_onexit_table(&MSVCRT_atexit_table);
}
/*********************************************************************
@@ -276,9 +265,7 @@ void CDECL MSVCRT__c_exit(void)
void CDECL MSVCRT__cexit(void)
{
TRACE("(void)\n");
- LOCK_EXIT;
__MSVCRT__call_atexit();
- UNLOCK_EXIT;
}
/*********************************************************************
@@ -291,26 +278,8 @@ MSVCRT__onexit_t CDECL MSVCRT__onexit(MSVCRT__onexit_t func)
if (!func)
return NULL;
- LOCK_EXIT;
- if (MSVCRT_atexit_registered > MSVCRT_atexit_table_size - 1)
- {
- MSVCRT__onexit_t *newtable;
- TRACE("expanding table\n");
- newtable = MSVCRT_calloc(MSVCRT_atexit_table_size + 32, sizeof(void *));
- if (!newtable)
- {
- TRACE("failed!\n");
- UNLOCK_EXIT;
- return NULL;
- }
- memcpy (newtable, MSVCRT_atexit_table, MSVCRT_atexit_table_size*sizeof(void *));
- MSVCRT_atexit_table_size += 32;
- MSVCRT_free (MSVCRT_atexit_table);
- MSVCRT_atexit_table = newtable;
- }
- MSVCRT_atexit_table[MSVCRT_atexit_registered] = func;
- MSVCRT_atexit_registered++;
- UNLOCK_EXIT;
+ MSVCRT__register_onexit_function(&MSVCRT_atexit_table, func);
+
return func;
}
@@ -359,6 +328,16 @@ int CDECL MSVCRT__crt_atexit(void (*func)(void))
return MSVCRT__onexit((MSVCRT__onexit_t)func) == (MSVCRT__onexit_t)func ? 0 : -1;
}
+/*********************************************************************
+ * _register_thread_local_exe_atexit_callback (UCRTBASE.@)
+ */
+void CDECL _register_thread_local_exe_atexit_callback(_tls_callback_type callback)
+{
+ TRACE("(%p)\n", callback);
+ tls_atexit_callback = callback;
+}
+
+#endif /* _MSVCR_VER>=140 */
/*********************************************************************
* _initialize_onexit_table (UCRTBASE.@)
@@ -457,17 +436,6 @@ int CDECL MSVCRT__execute_onexit_table(MSVCRT__onexit_table_t *table)
return 0;
}
-/*********************************************************************
- * _register_thread_local_exe_atexit_callback (UCRTBASE.@)
- */
-void CDECL _register_thread_local_exe_atexit_callback(_tls_callback_type callback)
-{
- TRACE("(%p)\n", callback);
- tls_atexit_callback = callback;
-}
-
-#endif /* _MSVCR_VER>=140 */
-
#if _MSVCR_VER>=71
/*********************************************************************
* _set_purecall_handler (MSVCR71.@)
diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c
index 354fab1e94..de27daaed9 100644
--- a/dlls/ucrtbase/tests/misc.c
+++ b/dlls/ucrtbase/tests/misc.c
@@ -125,6 +125,8 @@ static int (CDECL *p_fesetround)(int);
static void (CDECL *p___setusermatherr)(MSVCRT_matherr_func);
static int* (CDECL *p_errno)(void);
static char* (CDECL *p_asctime)(const struct tm *);
+static void (CDECL *p_exit)(int);
+static int (CDECL *p__crt_atexit)(void (CDECL*)(void));
static void test__initialize_onexit_table(void)
{
@@ -429,6 +431,8 @@ static BOOL init(void)
p___setusermatherr = (void*)GetProcAddress(module, "__setusermatherr");
p_errno = (void*)GetProcAddress(module, "_errno");
p_asctime = (void*)GetProcAddress(module, "asctime");
+ p__crt_atexit = (void*)GetProcAddress(module, "_crt_atexit");
+ p_exit = (void*)GetProcAddress(module, "exit");
return TRUE;
}
@@ -765,6 +769,68 @@ static void test_asctime(void)
ok(!strcmp(ret, "Thu Jan 1 00:00:00 1970\n"), "asctime returned %s\n", ret);
}
+static void test_exit(const char *argv0)
+{
+ HANDLE exit_event1;
+ PROCESS_INFORMATION proc;
+ STARTUPINFOA startup = {0};
+ char path[MAX_PATH];
+ DWORD ret;
+
+ exit_event1 = CreateEventA(NULL, FALSE, FALSE, "exit_event1");
+
+ sprintf(path, "%s misc exit", argv0);
+ startup.cb = sizeof(startup);
+ CreateProcessA(NULL, path, NULL, NULL, TRUE, 0, NULL, NULL, &startup, &proc);
+ winetest_wait_child_process(proc.hProcess);
+
+ ret = WaitForSingleObject(exit_event1, 0);
+ ok(ret == WAIT_OBJECT_0, "exit_event1 was not set (%x)\n", ret);
+
+ CloseHandle(exit_event1);
+}
+
+static void CDECL at_exit_func1(void)
+{
+ HANDLE exit_event1 = CreateEventA(NULL, FALSE, FALSE, "exit_event1");
+ HANDLE exit_event2 = CreateEventA(NULL, FALSE, FALSE, "exit_event2");
+ DWORD ret;
+
+ ok(exit_event1 != NULL, "CreateEvent failed: %d\n", GetLastError());
+ ok(exit_event2 != NULL, "CreateEvent failed: %d\n", GetLastError());
+
+ ret = WaitForSingleObject(exit_event2, 0);
+ ok(ret == WAIT_OBJECT_0, "exit_event2 was not set (%x)\n", ret);
+
+ SetEvent(exit_event1);
+ CloseHandle(exit_event1);
+ CloseHandle(exit_event2);
+}
+
+static void CDECL at_exit_func2(void)
+{
+ HANDLE exit_event1 = CreateEventA(NULL, FALSE, FALSE, "exit_event1");
+ HANDLE exit_event2 = CreateEventA(NULL, FALSE, FALSE, "exit_event2");
+ DWORD ret;
+
+ ok(exit_event1 != NULL, "CreateEvent failed: %d\n", GetLastError());
+ ok(exit_event2 != NULL, "CreateEvent failed: %d\n", GetLastError());
+
+ ret = WaitForSingleObject(exit_event1, 0);
+ ok(ret == WAIT_TIMEOUT, "exit_event1 should not be set (%x)\n", ret);
+
+ SetEvent(exit_event2);
+ CloseHandle(exit_event1);
+ CloseHandle(exit_event2);
+}
+
+static void test_call_exit(void)
+{
+ ok(!p__crt_atexit(at_exit_func1), "_crt_atexit failed\n");
+ ok(!p__crt_atexit(at_exit_func2), "_crt_atexit failed\n");
+ p_exit(0);
+}
+
START_TEST(misc)
{
int arg_c;
@@ -775,7 +841,10 @@ START_TEST(misc)
arg_c = winetest_get_mainargs(&arg_v);
if(arg_c == 3) {
- test__get_narrow_winmain_command_line(NULL);
+ if(!strcmp(arg_v[2], "cmd"))
+ test__get_narrow_winmain_command_line(NULL);
+ else if(!strcmp(arg_v[2], "exit"))
+ test_call_exit();
return;
}
@@ -791,4 +860,5 @@ START_TEST(misc)
test_isblank();
test_math_errors();
test_asctime();
+ test_exit(arg_v[0]);
}
--
2.17.1
June 17, 2018
[PATCH] winetest: Increase maximum tag length.
by Zebediah Figura
This should hopefully make those failures surrounding newtb-wvistau64-zh-CN go away.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
programs/winetest/winetest.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/programs/winetest/winetest.h b/programs/winetest/winetest.h
index e74f126..0446ad5 100644
--- a/programs/winetest/winetest.h
+++ b/programs/winetest/winetest.h
@@ -66,7 +66,7 @@ enum report_type {
R_QUIET
};
-#define MAXTAGLEN 20
+#define MAXTAGLEN 30
extern char *tag;
extern char *email;
extern BOOL aborting;
--
2.7.4
June 17, 2018
[PATCH v2 2/2] hnetcfg: Store the UNC path in INetFwAuthorizedApplication_put_ProcessImageFileName().
by Zebediah Figura
Fixes test failures when running from virtual drive.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
v2: add some changes I forgot to commit...
dlls/hnetcfg/Makefile.in | 2 +-
dlls/hnetcfg/apps.c | 32 +++++++++++++++++++++++++++-----
dlls/hnetcfg/tests/Makefile.in | 2 +-
dlls/hnetcfg/tests/policy.c | 15 ++++++++++++++-
4 files changed, 43 insertions(+), 8 deletions(-)
diff --git a/dlls/hnetcfg/Makefile.in b/dlls/hnetcfg/Makefile.in
index 3744368..44c9cb5 100644
--- a/dlls/hnetcfg/Makefile.in
+++ b/dlls/hnetcfg/Makefile.in
@@ -1,5 +1,5 @@
MODULE = hnetcfg.dll
-IMPORTS = oleaut32 ole32 advapi32
+IMPORTS = oleaut32 ole32 advapi32 mpr
C_SRCS = \
apps.c \
diff --git a/dlls/hnetcfg/apps.c b/dlls/hnetcfg/apps.c
index fda714e..34ef108 100644
--- a/dlls/hnetcfg/apps.c
+++ b/dlls/hnetcfg/apps.c
@@ -29,6 +29,7 @@
#include "netfw.h"
#include "wine/debug.h"
+#include "wine/heap.h"
#include "wine/unicode.h"
#include "hnetcfg_private.h"
@@ -263,18 +264,39 @@ static HRESULT WINAPI fw_app_get_ProcessImageFileName(
}
static HRESULT WINAPI fw_app_put_ProcessImageFileName(
- INetFwAuthorizedApplication *iface,
- BSTR imageFileName )
+ INetFwAuthorizedApplication *iface, BSTR image )
{
fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
+ UNIVERSAL_NAME_INFOW *info;
+ WCHAR *netpath;
+ DWORD res;
+ DWORD sz;
- FIXME("%p, %s\n", This, debugstr_w(imageFileName));
+ FIXME("%p, %s\n", This, debugstr_w(image));
- if (!imageFileName || !imageFileName[0])
+ if (!image || !image[0])
return E_INVALIDARG;
+ sz = 0;
+ res = WNetGetUniversalNameW(image, UNIVERSAL_NAME_INFO_LEVEL, NULL, &sz);
+ if (res == WN_MORE_DATA)
+ {
+ if (!(netpath = heap_alloc(sz)))
+ return E_OUTOFMEMORY;
+
+ info = (UNIVERSAL_NAME_INFOW *)&netpath;
+ res = WNetGetUniversalNameW(image, UNIVERSAL_NAME_INFO_LEVEL, &info, &sz);
+ if (res == NO_ERROR)
+ {
+ SysFreeString(This->filename);
+ This->filename = SysAllocString(info->lpUniversalName);
+ }
+ heap_free(netpath);
+ return HRESULT_FROM_WIN32(res);
+ }
+
SysFreeString( This->filename );
- This->filename = SysAllocString( imageFileName );
+ This->filename = SysAllocString(image);
return This->filename ? S_OK : E_OUTOFMEMORY;
}
diff --git a/dlls/hnetcfg/tests/Makefile.in b/dlls/hnetcfg/tests/Makefile.in
index 8315b4b..922370a 100644
--- a/dlls/hnetcfg/tests/Makefile.in
+++ b/dlls/hnetcfg/tests/Makefile.in
@@ -1,5 +1,5 @@
TESTDLL = hnetcfg.dll
-IMPORTS = ole32 uuid oleaut32 advapi32
+IMPORTS = ole32 uuid oleaut32 advapi32 mpr
C_SRCS = \
policy.c
diff --git a/dlls/hnetcfg/tests/policy.c b/dlls/hnetcfg/tests/policy.c
index 012bbcd..f2d1372 100644
--- a/dlls/hnetcfg/tests/policy.c
+++ b/dlls/hnetcfg/tests/policy.c
@@ -106,9 +106,12 @@ static void test_NetFwAuthorizedApplication(void)
{
INetFwAuthorizedApplication *app;
static WCHAR empty[] = {0};
+ UNIVERSAL_NAME_INFOW *info;
+ WCHAR netpath[MAX_PATH];
WCHAR image[MAX_PATH];
HRESULT hr;
BSTR bstr;
+ DWORD sz;
hr = CoCreateInstance(&CLSID_NetFwAuthorizedApplication, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_INetFwAuthorizedApplication, (void**)&app);
@@ -135,9 +138,19 @@ static void test_NetFwAuthorizedApplication(void)
ok(hr == S_OK, "got: %08x\n", hr);
SysFreeString(bstr);
+ info = (UNIVERSAL_NAME_INFOW *)&netpath;
+ sz = sizeof(netpath);
+ hr = WNetGetUniversalNameW(image, UNIVERSAL_NAME_INFO_LEVEL, &info, &sz);
+ if (hr != NO_ERROR)
+ {
+ info->lpUniversalName = netpath + sizeof(*info)/sizeof(WCHAR);
+ lstrcpyW(info->lpUniversalName, image);
+ }
+
hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr);
ok(hr == S_OK, "got: %08x\n", hr);
- ok(!lstrcmpiW(bstr,image), "got: %s\n", wine_dbgstr_w(bstr));
+ ok(!lstrcmpW(bstr,info->lpUniversalName), "expected %s, got %s\n",
+ wine_dbgstr_w(info->lpUniversalName), wine_dbgstr_w(bstr));
SysFreeString(bstr);
INetFwAuthorizedApplication_Release(app);
--
2.7.4
June 17, 2018
[PATCH v2 1/2] hnetcfg/tests: Fix BSTR usage in test_NetFwAuthorizedApplication().
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/hnetcfg/tests/policy.c | 52 ++++++++++++++++++++-------------------------
1 file changed, 23 insertions(+), 29 deletions(-)
diff --git a/dlls/hnetcfg/tests/policy.c b/dlls/hnetcfg/tests/policy.c
index 4ee19d8..012bbcd 100644
--- a/dlls/hnetcfg/tests/policy.c
+++ b/dlls/hnetcfg/tests/policy.c
@@ -105,48 +105,42 @@ static void test_interfaces(void)
static void test_NetFwAuthorizedApplication(void)
{
INetFwAuthorizedApplication *app;
+ static WCHAR empty[] = {0};
+ WCHAR image[MAX_PATH];
HRESULT hr;
+ BSTR bstr;
hr = CoCreateInstance(&CLSID_NetFwAuthorizedApplication, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_INetFwAuthorizedApplication, (void**)&app);
ok(hr == S_OK, "got: %08x\n", hr);
- if(hr == S_OK)
- {
- BSTR image = SysAllocStringLen( NULL, MAX_PATH );
- static WCHAR empty[] = {0};
- BSTR bstr;
- if (!GetModuleFileNameW( NULL, image, MAX_PATH ))
- {
- ok(0, "Failed to get filename\n");
- SysFreeString( image );
- return;
- }
+ hr = GetModuleFileNameW(NULL, image, sizeof(image));
+ ok(hr, "GetModuleFileName failed: %u\n", GetLastError());
- hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, NULL);
- ok(hr == E_POINTER, "got: %08x\n", hr);
+ hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, NULL);
+ ok(hr == E_POINTER, "got: %08x\n", hr);
- hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr);
- ok(hr == S_OK || hr == HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY), "got: %08x\n", hr);
- ok(!bstr, "got: %s\n", wine_dbgstr_w(bstr));
+ hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr);
+ ok(hr == S_OK || hr == HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY), "got: %08x\n", hr);
+ ok(!bstr, "got: %s\n", wine_dbgstr_w(bstr));
- hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, NULL);
- ok(hr == E_INVALIDARG || hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got: %08x\n", hr);
+ hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, NULL);
+ ok(hr == E_INVALIDARG || hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got: %08x\n", hr);
- hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, empty);
- ok(hr == E_INVALIDARG || hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got: %08x\n", hr);
+ hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, empty);
+ ok(hr == E_INVALIDARG || hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got: %08x\n", hr);
- hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, image);
- ok(hr == S_OK, "got: %08x\n", hr);
+ bstr = SysAllocString(image);
+ hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, bstr);
+ ok(hr == S_OK, "got: %08x\n", hr);
+ SysFreeString(bstr);
- hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr);
- ok(hr == S_OK, "got: %08x\n", hr);
- ok(!lstrcmpiW(bstr,image), "got: %s\n", wine_dbgstr_w(bstr));
- SysFreeString( bstr );
+ hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr);
+ ok(hr == S_OK, "got: %08x\n", hr);
+ ok(!lstrcmpiW(bstr,image), "got: %s\n", wine_dbgstr_w(bstr));
+ SysFreeString(bstr);
- SysFreeString( image );
- INetFwAuthorizedApplication_Release(app);
- }
+ INetFwAuthorizedApplication_Release(app);
}
START_TEST(policy)
--
2.7.4
June 17, 2018
[PATCH] ntdll: Add stub for WinSqmSetDWORD
by Fabian Maurer
This is an undocumented win7 function appearently used to telemetry.
It's used by some native win7 dlls.
Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de>
---
dlls/ntdll/misc.c | 10 ++++++++++
dlls/ntdll/ntdll.spec | 1 +
2 files changed, 11 insertions(+)
diff --git a/dlls/ntdll/misc.c b/dlls/ntdll/misc.c
index 88e8b33324..85000ab225 100644
--- a/dlls/ntdll/misc.c
+++ b/dlls/ntdll/misc.c
@@ -484,3 +484,13 @@ void WINAPI DbgUiRemoteBreakin( void *arg )
{
FIXME("stub\n");
}
+
+/***********************************************************************
+ * WinSqmSetDWORD (NTDLL.@)
+ *
+ * SQM seems to be used for telemetry
+ */
+void WINAPI WinSqmSetDWORD(HANDLE session, DWORD datapoint_id, DWORD datapoint_value)
+{
+ FIXME("(%p, %d, %d): stub\n", session, datapoint_id, datapoint_value);
+}
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index fb505e2208..1c366649e0 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -1032,6 +1032,7 @@
@ stdcall -ret64 VerSetConditionMask(int64 long long)
@ stdcall WinSqmEndSession(long)
@ stdcall WinSqmIsOptedIn()
+@ stdcall WinSqmSetDWORD(ptr long long)
@ stdcall WinSqmStartSession(ptr long long)
@ stdcall -private ZwAcceptConnectPort(ptr long ptr long ptr ptr) NtAcceptConnectPort
@ stdcall -private ZwAccessCheck(ptr long long ptr ptr ptr ptr ptr) NtAccessCheck
--
2.17.1
June 17, 2018
[PATCH] ntdll: Add stub for RtlExpandEnvironmentStrings
by Fabian Maurer
This function is used by some native win7 dlls
Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de>
---
dlls/ntdll/env.c | 8 ++++++++
dlls/ntdll/ntdll.spec | 1 +
2 files changed, 9 insertions(+)
diff --git a/dlls/ntdll/env.c b/dlls/ntdll/env.c
index a5bdf0f050..328ba79aaa 100644
--- a/dlls/ntdll/env.c
+++ b/dlls/ntdll/env.c
@@ -362,6 +362,14 @@ NTSTATUS WINAPI RtlExpandEnvironmentStrings_U(PCWSTR renv, const UNICODE_STRING*
return (count) ? STATUS_SUCCESS : STATUS_BUFFER_TOO_SMALL;
}
+/******************************************************************************
+ * RtlExpandEnvironmentStrings [NTDLL.@]
+ */
+NTSTATUS WINAPI RtlExpandEnvironmentStrings(PVOID environment, PWSTR src, SIZE_T src_length, PWSTR dst, SIZE_T dst_length, PSIZE_T return_length)
+{
+ FIXME("(%p, %p, %lu, %p, %lu, %p): stub\n", environment, src, src_length, dst, dst_length, return_length);
+ return STATUS_NOT_IMPLEMENTED;
+}
static inline void normalize( void *base, WCHAR **ptr )
{
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 45cedb74f5..fb505e2208 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -596,6 +596,7 @@
@ stdcall RtlEraseUnicodeString(ptr)
@ stdcall RtlExitUserProcess(long)
@ stdcall RtlExitUserThread(long)
+@ stdcall RtlExpandEnvironmentStrings(ptr ptr long ptr long ptr)
@ stdcall RtlExpandEnvironmentStrings_U(ptr ptr ptr ptr)
@ stub RtlExtendHeap
@ stdcall -arch=win32 -ret64 RtlExtendedIntegerMultiply(int64 long)
--
2.17.1
June 17, 2018
Re: [PATCH 2/2] msvcp120: Add test for Concurrent_vector_swap.
by Piotr Caban
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
June 17, 2018
Re: [PATCH 1/2] msvcp120: Add test for Concurrent_vector_assign.
by Piotr Caban
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
June 17, 2018
Re: [PATCH 2/2] msvcp120: Add test for Concurrent_vector_swap.
by Piotr Caban
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
June 17, 2018
Re: [PATCH 1/2] msvcp120: Add test for Concurrent_vector_assign.
by Piotr Caban
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
June 17, 2018
[PATCH 3/3] comctl32/taskdialog: Add support for command links.
by Zhiyi Zhang
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/comctl32/taskdialog.c | 62 +++++++++++++++++++++++++++++---
dlls/comctl32/tests/taskdialog.c | 61 +++++++++++++++++--------------
2 files changed, 93 insertions(+), 30 deletions(-)
diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c
index c3c5fa0420..eb2f2a4082 100644
--- a/dlls/comctl32/taskdialog.c
+++ b/dlls/comctl32/taskdialog.c
@@ -60,6 +60,8 @@ struct taskdialog_info
HWND progress_bar;
HWND *radio_buttons;
INT radio_button_count;
+ HWND *command_links;
+ INT command_link_count;
HWND *buttons;
INT button_count;
HWND default_button;
@@ -184,7 +186,8 @@ static HWND taskdialog_find_button(HWND *buttons, INT count, INT id)
static void taskdialog_enable_button(const struct taskdialog_info *dialog_info, INT id, BOOL enable)
{
- HWND hwnd = taskdialog_find_button(dialog_info->buttons, dialog_info->button_count, id);
+ HWND hwnd = taskdialog_find_button(dialog_info->command_links, dialog_info->command_link_count, id);
+ if (!hwnd) hwnd = taskdialog_find_button(dialog_info->buttons, dialog_info->button_count, id);
if (hwnd) EnableWindow(hwnd, enable);
}
@@ -253,6 +256,11 @@ static BOOL taskdialog_hyperlink_enabled(struct taskdialog_info *dialog_info)
return dialog_info->taskconfig->dwFlags & TDF_ENABLE_HYPERLINKS;
}
+static BOOL taskdialog_use_command_link(struct taskdialog_info *dialog_info)
+{
+ return dialog_info->taskconfig->dwFlags & (TDF_USE_COMMAND_LINKS | TDF_USE_COMMAND_LINKS_NO_ICON);
+}
+
static void taskdialog_get_label_size(struct taskdialog_info *dialog_info, HWND hwnd, LONG max_width, SIZE *size,
BOOL syslink)
{
@@ -468,6 +476,34 @@ static void taskdialog_add_radio_buttons(struct taskdialog_info *dialog_info)
}
}
+static void taskdialog_add_command_links(struct taskdialog_info *dialog_info)
+{
+ const TASKDIALOGCONFIG *taskconfig = dialog_info->taskconfig;
+ DWORD default_style = BS_MULTILINE | BS_LEFT | BS_TOP | WS_CHILD | WS_VISIBLE | WS_TABSTOP, style;
+ BOOL is_default;
+ WCHAR *textW;
+ INT i;
+
+ if (!taskconfig->cButtons || !taskconfig->pButtons || !taskdialog_use_command_link(dialog_info)) return;
+
+ dialog_info->command_links = Alloc(taskconfig->cButtons * sizeof(*dialog_info->command_links));
+ if (!dialog_info->command_links) return;
+
+ dialog_info->command_link_count = taskconfig->cButtons;
+ for (i = 0; i < dialog_info->command_link_count; i++)
+ {
+ is_default = taskconfig->pButtons[i].nButtonID == taskconfig->nDefaultButton;
+ style = is_default ? default_style | BS_DEFCOMMANDLINK : default_style | BS_COMMANDLINK;
+ textW = taskdialog_gettext(dialog_info, TRUE, taskconfig->pButtons[i].pszButtonText);
+ dialog_info->command_links[i] = CreateWindowW(WC_BUTTONW, textW, style, 0, 0, 0, 0, dialog_info->hwnd,
+ (HMENU)taskconfig->pButtons[i].nButtonID, 0, NULL);
+ SendMessageW(dialog_info->command_links[i], WM_SETFONT, (WPARAM)dialog_info->font, 0);
+ Free(textW);
+
+ if (is_default && !dialog_info->default_button) dialog_info->default_button = dialog_info->command_links[i];
+ }
+}
+
static void taskdialog_add_button(struct taskdialog_info *dialog_info, HWND *button, INT_PTR id, const WCHAR *text,
BOOL custom_button)
{
@@ -486,17 +522,18 @@ static void taskdialog_add_button(struct taskdialog_info *dialog_info, HWND *but
static void taskdialog_add_buttons(struct taskdialog_info *dialog_info)
{
const TASKDIALOGCONFIG *taskconfig = dialog_info->taskconfig;
+ BOOL use_command_links = taskdialog_use_command_link(dialog_info);
DWORD flags = taskconfig->dwCommonButtons;
INT count, max_count;
/* Allocate enough memory for the custom and the default buttons. Maximum 6 default buttons possible. */
max_count = 6;
- if (taskconfig->cButtons && taskconfig->pButtons) max_count += taskconfig->cButtons;
+ if (!use_command_links && taskconfig->cButtons && taskconfig->pButtons) max_count += taskconfig->cButtons;
dialog_info->buttons = Alloc(max_count * sizeof(*dialog_info->buttons));
if (!dialog_info->buttons) return;
- for (count = 0; count < taskconfig->cButtons; count++)
+ for (count = 0; !use_command_links && count < taskconfig->cButtons; count++)
taskdialog_add_button(dialog_info, &dialog_info->buttons[count], taskconfig->pButtons[count].nButtonID,
taskconfig->pButtons[count].pszButtonText, TRUE);
@@ -514,7 +551,7 @@ static void taskdialog_add_buttons(struct taskdialog_info *dialog_info)
if (flags & TDCBF_CANCEL_BUTTON) TASKDIALOG_INIT_COMMON_BUTTON(CANCEL);
if (flags & TDCBF_CLOSE_BUTTON) TASKDIALOG_INIT_COMMON_BUTTON(CLOSE);
- if (!count) TASKDIALOG_INIT_COMMON_BUTTON(OK);
+ if (!count && !dialog_info->command_link_count) TASKDIALOG_INIT_COMMON_BUTTON(OK);
#undef TASKDIALOG_INIT_COMMON_BUTTON
dialog_info->button_count = count;
@@ -603,6 +640,19 @@ static void taskdialog_layout(struct taskdialog_info *dialog_info)
dialog_height = y + size.cy;
}
+ /* Command links */
+ for (i = 0; i < dialog_info->command_link_count; i++)
+ {
+ x = main_icon_right + h_spacing;
+ y = dialog_height + v_spacing;
+ taskdialog_get_label_size(dialog_info, dialog_info->command_links[i], dialog_width - x - h_spacing, &size, FALSE);
+ size.cx = dialog_width - x - h_spacing;
+ /* Add spacing */
+ size.cy += 4;
+ SetWindowPos(dialog_info->command_links[i], 0, x, y, size.cx, size.cy, SWP_NOZORDER);
+ dialog_height = y + size.cy;
+ }
+
dialog_height = max(dialog_height, main_icon_bottom);
/* Common and custom buttons */
@@ -738,9 +788,12 @@ static void taskdialog_init(struct taskdialog_info *dialog_info, HWND hwnd)
taskdialog_add_content(dialog_info);
taskdialog_add_progress_bar(dialog_info);
taskdialog_add_radio_buttons(dialog_info);
+ taskdialog_add_command_links(dialog_info);
taskdialog_add_buttons(dialog_info);
/* Set default button */
+ if (!dialog_info->default_button && dialog_info->command_links)
+ dialog_info->default_button = dialog_info->command_links[0];
if (!dialog_info->default_button) dialog_info->default_button = dialog_info->buttons[0];
SendMessageW(dialog_info->hwnd, WM_NEXTDLGCTL, (WPARAM)dialog_info->default_button, TRUE);
id = GetWindowLongW(dialog_info->default_button, GWLP_ID);
@@ -756,6 +809,7 @@ static void taskdialog_destroy(struct taskdialog_info *dialog_info)
if (dialog_info->main_instruction_font) DeleteObject(dialog_info->main_instruction_font);
if (dialog_info->buttons) Free(dialog_info->buttons);
if (dialog_info->radio_buttons) Free(dialog_info->radio_buttons);
+ if (dialog_info->command_links) Free(dialog_info->command_links);
}
static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c
index 2cda04081f..33d3757308 100644
--- a/dlls/comctl32/tests/taskdialog.c
+++ b/dlls/comctl32/tests/taskdialog.c
@@ -323,7 +323,7 @@ static void test_callback(void)
static void test_buttons(void)
{
TASKDIALOGCONFIG info = {0};
-
+ static const DWORD command_link_flags[] = {0, TDF_USE_COMMAND_LINKS, TDF_USE_COMMAND_LINKS_NO_ICON};
TASKDIALOG_BUTTON custom_buttons[TEST_NUM_BUTTONS], radio_buttons[TEST_NUM_RADIO_BUTTONS];
const WCHAR button_format[] = {'%','0','2','d',0};
/* Each button has two digits as title, plus null-terminator */
@@ -373,31 +373,40 @@ static void test_buttons(void)
info.dwCommonButtons = TDCBF_CANCEL_BUTTON | TDCBF_CLOSE_BUTTON;
run_test(&info, IDCANCEL, 0, msg_return_press_cancel, "default button: unset default");
- /* Test with all common and custom buttons and invalid default ID */
- info.nDefaultButton = 0xff; /* Random ID, should also default to first created button */
- info.cButtons = TEST_NUM_BUTTONS;
- info.pButtons = custom_buttons;
- run_test(&info, ID_START_BUTTON, 0, msg_return_press_custom1, "default button: invalid default, with common buttons - 1");
-
- info.nDefaultButton = -1; /* Should work despite button ID -1 */
- run_test(&info, -1, 0, msg_return_press_custom10, "default button: invalid default, with common buttons - 2");
-
- info.nDefaultButton = -2; /* Should also default to first created button */
- run_test(&info, ID_START_BUTTON, 0, msg_return_press_custom1, "default button: invalid default, with common buttons - 3");
-
- /* Test with only custom buttons and invalid default ID */
- info.dwCommonButtons = 0;
- run_test(&info, ID_START_BUTTON, 0, msg_return_press_custom1, "default button: invalid default, no common buttons");
-
- /* Test with common and custom buttons and valid default ID */
- info.dwCommonButtons = TDCBF_OK_BUTTON | TDCBF_YES_BUTTON | TDCBF_NO_BUTTON
- | TDCBF_CANCEL_BUTTON | TDCBF_RETRY_BUTTON | TDCBF_CLOSE_BUTTON;
- info.nDefaultButton = IDRETRY;
- run_test(&info, IDRETRY, 0, msg_return_press_retry, "default button: valid default - 1");
-
- /* Test with common and custom buttons and valid default ID */
- info.nDefaultButton = ID_START_BUTTON + 3;
- run_test(&info, ID_START_BUTTON + 3, 0, msg_return_press_custom4, "default button: valid default - 2");
+ /* Custom buttons could be command links */
+ for (i = 0; i < ARRAY_SIZE(command_link_flags); i++)
+ {
+ info.dwFlags = command_link_flags[i];
+
+ /* Test with all common and custom buttons and invalid default ID */
+ info.nDefaultButton = 0xff; /* Random ID, should also default to first created button */
+ info.cButtons = TEST_NUM_BUTTONS;
+ info.pButtons = custom_buttons;
+ run_test(&info, ID_START_BUTTON, 0, msg_return_press_custom1,
+ "default button: invalid default, with common buttons - 1");
+
+ info.nDefaultButton = -1; /* Should work despite button ID -1 */
+ run_test(&info, -1, 0, msg_return_press_custom10, "default button: invalid default, with common buttons - 2");
+
+ info.nDefaultButton = -2; /* Should also default to first created button */
+ run_test(&info, ID_START_BUTTON, 0, msg_return_press_custom1,
+ "default button: invalid default, with common buttons - 3");
+
+ /* Test with only custom buttons and invalid default ID */
+ info.dwCommonButtons = 0;
+ run_test(&info, ID_START_BUTTON, 0, msg_return_press_custom1,
+ "default button: invalid default, no common buttons");
+
+ /* Test with common and custom buttons and valid default ID */
+ info.dwCommonButtons = TDCBF_OK_BUTTON | TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON
+ | TDCBF_RETRY_BUTTON | TDCBF_CLOSE_BUTTON;
+ info.nDefaultButton = IDRETRY;
+ run_test(&info, IDRETRY, 0, msg_return_press_retry, "default button: valid default - 1");
+
+ /* Test with common and custom buttons and valid default ID */
+ info.nDefaultButton = ID_START_BUTTON + 3;
+ run_test(&info, ID_START_BUTTON + 3, 0, msg_return_press_custom4, "default button: valid default - 2");
+ }
/* Test radio buttons */
info.nDefaultButton = 0;
--
2.17.1
June 17, 2018
[PATCH 2/3] comctl32/taskdialog: Add support for radio buttons.
by Zhiyi Zhang
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/comctl32/taskdialog.c | 130 ++++++++++++++++++++++-
dlls/comctl32/tests/taskdialog.c | 172 +++++++++++++++++++++++++++----
2 files changed, 281 insertions(+), 21 deletions(-)
diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c
index 33fb578910..c3c5fa0420 100644
--- a/dlls/comctl32/taskdialog.c
+++ b/dlls/comctl32/taskdialog.c
@@ -58,6 +58,8 @@ struct taskdialog_info
HWND main_instruction;
HWND content;
HWND progress_bar;
+ HWND *radio_buttons;
+ INT radio_button_count;
HWND *buttons;
INT button_count;
HWND default_button;
@@ -69,6 +71,7 @@ struct taskdialog_info
LONG h_spacing;
LONG v_spacing;
} m;
+ INT selected_radio_id;
};
struct button_layout_info
@@ -185,6 +188,18 @@ static void taskdialog_enable_button(const struct taskdialog_info *dialog_info,
if (hwnd) EnableWindow(hwnd, enable);
}
+static void taskdialog_enable_radio_button(const struct taskdialog_info *dialog_info, INT id, BOOL enable)
+{
+ HWND hwnd = taskdialog_find_button(dialog_info->radio_buttons, dialog_info->radio_button_count, id);
+ if (hwnd) EnableWindow(hwnd, enable);
+}
+
+static void taskdialog_click_radio_button(const struct taskdialog_info *dialog_info, INT id)
+{
+ HWND hwnd = taskdialog_find_button(dialog_info->radio_buttons, dialog_info->radio_button_count, id);
+ if (hwnd) SendMessageW(hwnd, BM_CLICK, 0, 0);
+}
+
static HRESULT taskdialog_notify(struct taskdialog_info *dialog_info, UINT notification, WPARAM wparam, LPARAM lparam)
{
const TASKDIALOGCONFIG *taskconfig = dialog_info->taskconfig;
@@ -193,8 +208,18 @@ static HRESULT taskdialog_notify(struct taskdialog_info *dialog_info, UINT notif
: S_OK;
}
-static void taskdialog_on_button_click(struct taskdialog_info *dialog_info, WORD command_id)
+static void taskdialog_on_button_click(struct taskdialog_info *dialog_info, unsigned long command_id)
{
+ HWND radio_button;
+
+ radio_button = taskdialog_find_button(dialog_info->radio_buttons, dialog_info->radio_button_count, command_id);
+ if (radio_button)
+ {
+ dialog_info->selected_radio_id = command_id;
+ taskdialog_notify(dialog_info, TDN_RADIO_BUTTON_CLICKED, command_id, 0);
+ return;
+ }
+
if (taskdialog_notify(dialog_info, TDN_BUTTON_CLICKED, command_id, 0) == S_OK)
EndDialog(dialog_info->hwnd, command_id);
}
@@ -260,6 +285,40 @@ static void taskdialog_get_label_size(struct taskdialog_info *dialog_info, HWND
ReleaseDC(hwnd, hdc);
}
+static void taskdialog_get_checkbox_height(struct taskdialog_info *dialog_info, HWND hwnd, LONG max_width, SIZE *size)
+{
+ DWORD style = DT_EXPANDTABS | DT_CALCRECT | DT_WORDBREAK;
+ HFONT hfont, old_hfont;
+ HDC hdc;
+ RECT rect = {0};
+ WCHAR text[1024];
+ INT text_length;
+ LONG text_offset, checkbox_width, checkbox_height;
+
+ hdc = GetDC(hwnd);
+ hfont = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0);
+ old_hfont = SelectObject(hdc, hfont);
+
+ checkbox_width = 12 * GetDeviceCaps(hdc, LOGPIXELSX) / 96 + 1;
+ checkbox_height = 12 * GetDeviceCaps(hdc, LOGPIXELSY) / 96 + 1;
+ GetCharWidthW(hdc, '0', '0', &text_offset);
+ text_offset /= 2;
+
+ if (dialog_info->taskconfig->dwFlags & TDF_RTL_LAYOUT)
+ style |= DT_RIGHT | DT_RTLREADING;
+ else
+ style |= DT_LEFT;
+
+ rect.right = max_width - checkbox_width - text_offset;
+ text_length = GetWindowTextW(hwnd, text, ARRAY_SIZE(text));
+ size->cy = DrawTextW(hdc, text, text_length, &rect, style);
+ size->cx = min(max_width - checkbox_width - text_offset, rect.right - rect.left);
+ size->cx += checkbox_width + text_offset;
+ size->cy = max(size->cy, checkbox_height);
+ if (old_hfont) SelectObject(hdc, old_hfont);
+ ReleaseDC(hwnd, hdc);
+}
+
static ULONG_PTR taskdialog_get_standard_icon(LPCWSTR icon)
{
if (icon == TD_WARNING_ICON)
@@ -300,6 +359,28 @@ static void taskdialog_set_icon(struct taskdialog_info *dialog_info, INT element
}
}
+static void taskdialog_check_default_radio_buttons(struct taskdialog_info *dialog_info)
+{
+ const TASKDIALOGCONFIG *taskconfig = dialog_info->taskconfig;
+ HWND default_button;
+ INT id;
+
+ if (!dialog_info->radio_button_count) return;
+
+ default_button = taskdialog_find_button(dialog_info->radio_buttons, dialog_info->radio_button_count,
+ taskconfig->nDefaultRadioButton);
+
+ if (!default_button && !(taskconfig->dwFlags & TDF_NO_DEFAULT_RADIO_BUTTON))
+ default_button = dialog_info->radio_buttons[0];
+
+ if (default_button)
+ {
+ SendMessageW(default_button, BM_SETCHECK, BST_CHECKED, 0);
+ id = GetWindowLongW(default_button, GWLP_ID);
+ taskdialog_on_button_click(dialog_info, id);
+ }
+}
+
static void taskdialog_add_main_icon(struct taskdialog_info *dialog_info)
{
if (!dialog_info->taskconfig->u.hMainIcon) return;
@@ -363,6 +444,30 @@ static void taskdialog_add_progress_bar(struct taskdialog_info *dialog_info)
CreateWindowW(PROGRESS_CLASSW, NULL, style, 0, 0, 0, 0, dialog_info->hwnd, NULL, 0, NULL);
}
+static void taskdialog_add_radio_buttons(struct taskdialog_info *dialog_info)
+{
+ const TASKDIALOGCONFIG *taskconfig = dialog_info->taskconfig;
+ static const DWORD style = BS_AUTORADIOBUTTON | BS_MULTILINE | BS_TOP | WS_CHILD | WS_VISIBLE | WS_TABSTOP;
+ WCHAR *textW;
+ INT i;
+
+ if (!taskconfig->cRadioButtons || !taskconfig->pRadioButtons) return;
+
+ dialog_info->radio_buttons = Alloc(taskconfig->cRadioButtons * sizeof(*dialog_info->radio_buttons));
+ if (!dialog_info->radio_buttons) return;
+
+ dialog_info->radio_button_count = taskconfig->cRadioButtons;
+ for (i = 0; i < dialog_info->radio_button_count; i++)
+ {
+ textW = taskdialog_gettext(dialog_info, TRUE, taskconfig->pRadioButtons[i].pszButtonText);
+ dialog_info->radio_buttons[i] =
+ CreateWindowW(WC_BUTTONW, textW, i == 0 ? style | WS_GROUP : style, 0, 0, 0, 0, dialog_info->hwnd,
+ (HMENU)taskconfig->pRadioButtons[i].nButtonID, 0, NULL);
+ SendMessageW(dialog_info->radio_buttons[i], WM_SETFONT, (WPARAM)dialog_info->font, 0);
+ Free(textW);
+ }
+}
+
static void taskdialog_add_button(struct taskdialog_info *dialog_info, HWND *button, INT_PTR id, const WCHAR *text,
BOOL custom_button)
{
@@ -487,6 +592,17 @@ static void taskdialog_layout(struct taskdialog_info *dialog_info)
dialog_height = y + size.cy;
}
+ /* Radio buttons */
+ for (i = 0; i < dialog_info->radio_button_count; i++)
+ {
+ x = main_icon_right + h_spacing;
+ y = dialog_height;
+ taskdialog_get_checkbox_height(dialog_info, dialog_info->radio_buttons[i], dialog_width - x - h_spacing, &size);
+ size.cx = dialog_width - x - h_spacing;
+ SetWindowPos(dialog_info->radio_buttons[i], 0, x, y, size.cx, size.cy, SWP_NOZORDER);
+ dialog_height = y + size.cy;
+ }
+
dialog_height = max(dialog_height, main_icon_bottom);
/* Common and custom buttons */
@@ -621,6 +737,7 @@ static void taskdialog_init(struct taskdialog_info *dialog_info, HWND hwnd)
taskdialog_add_main_instruction(dialog_info);
taskdialog_add_content(dialog_info);
taskdialog_add_progress_bar(dialog_info);
+ taskdialog_add_radio_buttons(dialog_info);
taskdialog_add_buttons(dialog_info);
/* Set default button */
@@ -638,6 +755,7 @@ static void taskdialog_destroy(struct taskdialog_info *dialog_info)
if (dialog_info->font) DeleteObject(dialog_info->font);
if (dialog_info->main_instruction_font) DeleteObject(dialog_info->main_instruction_font);
if (dialog_info->buttons) Free(dialog_info->buttons);
+ if (dialog_info->radio_buttons) Free(dialog_info->radio_buttons);
}
static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -689,6 +807,12 @@ static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
case TDM_SET_PROGRESS_BAR_MARQUEE:
SendMessageW(dialog_info->progress_bar, PBM_SETMARQUEE, wParam, lParam);
break;
+ case TDM_CLICK_RADIO_BUTTON:
+ taskdialog_click_radio_button(dialog_info, wParam);
+ break;
+ case TDM_ENABLE_RADIO_BUTTON:
+ taskdialog_enable_radio_button(dialog_info, wParam, lParam);
+ break;
case WM_INITDIALOG:
dialog_info = (struct taskdialog_info *)lParam;
@@ -697,6 +821,8 @@ static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
SetPropW(hwnd, taskdialog_info_propnameW, dialog_info);
taskdialog_notify(dialog_info, TDN_DIALOG_CONSTRUCTED, 0, 0);
taskdialog_notify(dialog_info, TDN_CREATED, 0, 0);
+ /* Default radio button click notification sent after TDN_CREATED */
+ taskdialog_check_default_radio_buttons(dialog_info);
return FALSE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
@@ -762,7 +888,7 @@ HRESULT WINAPI TaskDialogIndirect(const TASKDIALOGCONFIG *taskconfig, int *butto
Free(template);
if (button) *button = ret;
- if (radio_button) *radio_button = taskconfig->nDefaultButton;
+ if (radio_button) *radio_button = dialog_info.selected_radio_id;
if (verification_flag_checked) *verification_flag_checked = TRUE;
return S_OK;
diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c
index e91a878876..2cda04081f 100644
--- a/dlls/comctl32/tests/taskdialog.c
+++ b/dlls/comctl32/tests/taskdialog.c
@@ -35,9 +35,11 @@
#define TASKDIALOG_SEQ_INDEX 0
#define TEST_NUM_BUTTONS 10 /* Number of custom buttons to test with */
+#define TEST_NUM_RADIO_BUTTONS 3
#define ID_START 20 /* Lower IDs might be used by the system */
#define ID_START_BUTTON (ID_START + 0)
+#define ID_START_RADIO_BUTTON (ID_START + 20)
static HRESULT (WINAPI *pTaskDialogIndirect)(const TASKDIALOGCONFIG *, int *, int *, BOOL *);
static HRESULT (WINAPI *pTaskDialog)(HWND, HINSTANCE, const WCHAR *, const WCHAR *, const WCHAR *,
@@ -141,6 +143,78 @@ static const struct message_info msg_got_tdn_help[] =
{ 0 }
};
+/* Three radio buttons */
+static const struct message_info msg_return_default_radio_button_1[] =
+{
+ { TDN_CREATED, 0, 0, S_OK, NULL },
+ { TDN_RADIO_BUTTON_CLICKED, ID_START_RADIO_BUTTON, 0, S_OK, msg_send_click_ok },
+ { TDN_BUTTON_CLICKED, IDOK, 0, S_OK, NULL },
+ { 0 }
+};
+
+static const struct message_info msg_return_default_radio_button_2[] =
+{
+ { TDN_CREATED, 0, 0, S_OK, NULL },
+ { TDN_RADIO_BUTTON_CLICKED, ID_START_RADIO_BUTTON + 1, 0, S_OK, msg_send_click_ok },
+ { TDN_BUTTON_CLICKED, IDOK, 0, S_OK, NULL },
+ { 0 }
+};
+
+static const struct message_info msg_return_default_radio_button_3[] =
+{
+ { TDN_CREATED, 0, 0, S_OK, NULL },
+ { TDN_RADIO_BUTTON_CLICKED, -2, 0, S_OK, msg_send_click_ok },
+ { TDN_BUTTON_CLICKED, IDOK, 0, S_OK, NULL },
+ { 0 }
+};
+
+static const struct message_info msg_select_first_radio_button[] =
+{
+ { TDM_CLICK_RADIO_BUTTON, ID_START_RADIO_BUTTON, 0 },
+ { 0 }
+};
+
+static const struct message_info msg_return_first_radio_button[] =
+{
+ { TDN_CREATED, 0, 0, S_OK, NULL },
+ { TDN_RADIO_BUTTON_CLICKED, ID_START_RADIO_BUTTON + 1, 0, S_OK, msg_select_first_radio_button },
+ { TDN_RADIO_BUTTON_CLICKED, ID_START_RADIO_BUTTON, 0, S_OK, msg_send_click_ok },
+ { TDN_BUTTON_CLICKED, IDOK, 0, S_OK, NULL },
+ { 0 }
+};
+
+static const struct message_info msg_select_first_disabled_radio_button_and_press_ok[] =
+{
+ { TDM_ENABLE_RADIO_BUTTON, ID_START_RADIO_BUTTON, 0 },
+ { TDM_CLICK_RADIO_BUTTON, ID_START_RADIO_BUTTON, 0 },
+ { TDM_CLICK_BUTTON, IDOK, 0 },
+ { 0 }
+};
+
+static const struct message_info msg_return_default_radio_button_clicking_disabled[] =
+{
+ { TDN_CREATED, 0, 0, S_OK, NULL },
+ { TDN_RADIO_BUTTON_CLICKED, ID_START_RADIO_BUTTON + 1, 0, S_OK, msg_select_first_disabled_radio_button_and_press_ok },
+ { TDN_RADIO_BUTTON_CLICKED, ID_START_RADIO_BUTTON, 0, S_OK, NULL },
+ { TDN_BUTTON_CLICKED, IDOK, 0, S_OK, NULL },
+ { 0 }
+};
+
+static const struct message_info msg_return_no_default_radio_button_flag[] =
+{
+ { TDN_CREATED, 0, 0, S_OK, msg_send_click_ok },
+ { TDN_RADIO_BUTTON_CLICKED, ID_START_RADIO_BUTTON, 0, S_OK, NULL },
+ { TDN_BUTTON_CLICKED, IDOK, 0, S_OK, NULL },
+ { 0 }
+};
+
+static const struct message_info msg_return_no_default_radio_button_id_and_flag[] =
+{
+ { TDN_CREATED, 0, 0, S_OK, msg_send_click_ok },
+ { TDN_BUTTON_CLICKED, IDOK, 0, S_OK, NULL },
+ { 0 }
+};
+
static void init_test_message(UINT message, WPARAM wParam, LPARAM lParam, struct message *msg)
{
msg->message = WM_TD_CALLBACK;
@@ -151,11 +225,13 @@ static void init_test_message(UINT message, WPARAM wParam, LPARAM lParam, struct
msg->stage = 0;
}
-#define run_test(info, expect_button, seq, context) \
- run_test_(info, expect_button, seq, context, ARRAY_SIZE(seq) - 1, __FILE__, __LINE__)
+#define run_test(info, expect_button, expect_radio_button, seq, context) \
+ run_test_(info, expect_button, expect_radio_button, seq, context, \
+ ARRAY_SIZE(seq) - 1, __FILE__, __LINE__)
-static void run_test_(TASKDIALOGCONFIG *info, int expect_button, const struct message_info *test_messages,
- const char *context, int test_messages_len, const char *file, int line)
+static void run_test_(TASKDIALOGCONFIG *info, int expect_button, int expect_radio_button,
+ const struct message_info *test_messages, const char *context, int test_messages_len,
+ const char *file, int line)
{
struct message *msg, *msg_start;
int ret_button = 0;
@@ -182,6 +258,8 @@ static void run_test_(TASKDIALOGCONFIG *info, int expect_button, const struct me
ok_sequence_(sequences, TASKDIALOG_SEQ_INDEX, msg_start, context, FALSE, file, line);
ok_(file, line)(ret_button == expect_button,
"Wrong button. Expected %d, got %d\n", expect_button, ret_button);
+ ok_(file, line)(ret_radio == expect_radio_button,
+ "Wrong radio button. Expected %d, got %d\n", expect_radio_button, ret_radio);
heap_free(msg_start);
}
@@ -239,16 +317,17 @@ static void test_callback(void)
info.pfCallback = taskdialog_callback_proc;
info.lpCallbackData = test_ref_data;
- run_test(&info, IDOK, msg_return_press_ok, "Press VK_RETURN.");
+ run_test(&info, IDOK, 0, msg_return_press_ok, "Press VK_RETURN.");
}
static void test_buttons(void)
{
TASKDIALOGCONFIG info = {0};
- TASKDIALOG_BUTTON custom_buttons[TEST_NUM_BUTTONS];
+ TASKDIALOG_BUTTON custom_buttons[TEST_NUM_BUTTONS], radio_buttons[TEST_NUM_RADIO_BUTTONS];
const WCHAR button_format[] = {'%','0','2','d',0};
- WCHAR button_titles[TEST_NUM_BUTTONS * 3]; /* Each button has two digits as title, plus null-terminator */
+ /* Each button has two digits as title, plus null-terminator */
+ WCHAR button_titles[TEST_NUM_BUTTONS * 3], radio_button_titles[TEST_NUM_BUTTONS * 3];
int i;
info.cbSize = sizeof(TASKDIALOGCONFIG);
@@ -266,48 +345,103 @@ static void test_buttons(void)
}
custom_buttons[TEST_NUM_BUTTONS - 1].nButtonID = -1;
+ /* Init radio buttons */
+ for (i = 0; i < TEST_NUM_RADIO_BUTTONS; i++)
+ {
+ WCHAR *text = &radio_button_titles[i * 3];
+ wsprintfW(text, button_format, i);
+
+ radio_buttons[i].pszButtonText = text;
+ radio_buttons[i].nButtonID = ID_START_RADIO_BUTTON + i;
+ }
+ radio_buttons[TEST_NUM_RADIO_BUTTONS - 1].nButtonID = -2;
+
/* Test nDefaultButton */
/* Test common buttons with invalid default ID */
info.nDefaultButton = 0; /* Should default to first created button */
info.dwCommonButtons = TDCBF_OK_BUTTON | TDCBF_YES_BUTTON | TDCBF_NO_BUTTON
| TDCBF_CANCEL_BUTTON | TDCBF_RETRY_BUTTON | TDCBF_CLOSE_BUTTON;
- run_test(&info, IDOK, msg_return_press_ok, "default button: unset default");
+ run_test(&info, IDOK, 0, msg_return_press_ok, "default button: unset default");
info.dwCommonButtons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON
| TDCBF_CANCEL_BUTTON | TDCBF_RETRY_BUTTON | TDCBF_CLOSE_BUTTON;
- run_test(&info, IDYES, msg_return_press_yes, "default button: unset default");
+ run_test(&info, IDYES, 0, msg_return_press_yes, "default button: unset default");
info.dwCommonButtons = TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON | TDCBF_RETRY_BUTTON | TDCBF_CLOSE_BUTTON;
- run_test(&info, IDNO, msg_return_press_no, "default button: unset default");
+ run_test(&info, IDNO, 0, msg_return_press_no, "default button: unset default");
info.dwCommonButtons = TDCBF_CANCEL_BUTTON | TDCBF_RETRY_BUTTON | TDCBF_CLOSE_BUTTON;
- run_test(&info, IDRETRY, msg_return_press_retry, "default button: unset default");
+ run_test(&info, IDRETRY, 0, msg_return_press_retry, "default button: unset default");
info.dwCommonButtons = TDCBF_CANCEL_BUTTON | TDCBF_CLOSE_BUTTON;
- run_test(&info, IDCANCEL, msg_return_press_cancel, "default button: unset default");
+ run_test(&info, IDCANCEL, 0, msg_return_press_cancel, "default button: unset default");
/* Test with all common and custom buttons and invalid default ID */
info.nDefaultButton = 0xff; /* Random ID, should also default to first created button */
info.cButtons = TEST_NUM_BUTTONS;
info.pButtons = custom_buttons;
- run_test(&info, ID_START_BUTTON, msg_return_press_custom1, "default button: invalid default, with common buttons - 1");
+ run_test(&info, ID_START_BUTTON, 0, msg_return_press_custom1, "default button: invalid default, with common buttons - 1");
info.nDefaultButton = -1; /* Should work despite button ID -1 */
- run_test(&info, -1, msg_return_press_custom10, "default button: invalid default, with common buttons - 2");
+ run_test(&info, -1, 0, msg_return_press_custom10, "default button: invalid default, with common buttons - 2");
info.nDefaultButton = -2; /* Should also default to first created button */
- run_test(&info, ID_START_BUTTON, msg_return_press_custom1, "default button: invalid default, with common buttons - 3");
+ run_test(&info, ID_START_BUTTON, 0, msg_return_press_custom1, "default button: invalid default, with common buttons - 3");
/* Test with only custom buttons and invalid default ID */
info.dwCommonButtons = 0;
- run_test(&info, ID_START_BUTTON, msg_return_press_custom1, "default button: invalid default, no common buttons");
+ run_test(&info, ID_START_BUTTON, 0, msg_return_press_custom1, "default button: invalid default, no common buttons");
/* Test with common and custom buttons and valid default ID */
info.dwCommonButtons = TDCBF_OK_BUTTON | TDCBF_YES_BUTTON | TDCBF_NO_BUTTON
| TDCBF_CANCEL_BUTTON | TDCBF_RETRY_BUTTON | TDCBF_CLOSE_BUTTON;
info.nDefaultButton = IDRETRY;
- run_test(&info, IDRETRY, msg_return_press_retry, "default button: valid default - 1");
+ run_test(&info, IDRETRY, 0, msg_return_press_retry, "default button: valid default - 1");
/* Test with common and custom buttons and valid default ID */
info.nDefaultButton = ID_START_BUTTON + 3;
- run_test(&info, ID_START_BUTTON + 3, msg_return_press_custom4, "default button: valid default - 2");
+ run_test(&info, ID_START_BUTTON + 3, 0, msg_return_press_custom4, "default button: valid default - 2");
+
+ /* Test radio buttons */
+ info.nDefaultButton = 0;
+ info.cButtons = 0;
+ info.pButtons = 0;
+ info.dwCommonButtons = TDCBF_OK_BUTTON;
+ info.cRadioButtons = TEST_NUM_RADIO_BUTTONS;
+ info.pRadioButtons = radio_buttons;
+
+ /* Test default first radio button */
+ run_test(&info, IDOK, ID_START_RADIO_BUTTON, msg_return_default_radio_button_1, "default radio button: default first radio button");
+
+ /* Test default radio button */
+ info.nDefaultRadioButton = ID_START_RADIO_BUTTON + 1;
+ run_test(&info, IDOK, info.nDefaultRadioButton, msg_return_default_radio_button_2, "default radio button: default radio button");
+
+ /* Test default radio button with -2 */
+ info.nDefaultRadioButton = -2;
+ run_test(&info, IDOK, info.nDefaultRadioButton, msg_return_default_radio_button_3, "default radio button: default radio button with id -2");
+
+ /* Test default radio button after clicking the first, messages still work even radio button is disabled */
+ info.nDefaultRadioButton = ID_START_RADIO_BUTTON + 1;
+ run_test(&info, IDOK, ID_START_RADIO_BUTTON, msg_return_first_radio_button, "default radio button: radio button after clicking");
+
+ /* Test radio button after disabling and clicking the first */
+ info.nDefaultRadioButton = ID_START_RADIO_BUTTON + 1;
+ run_test(&info, IDOK, ID_START_RADIO_BUTTON, msg_return_default_radio_button_clicking_disabled, "default radio button: disable radio button before clicking");
+
+ /* Test no default radio button, TDF_NO_DEFAULT_RADIO_BUTTON is set, TDN_RADIO_BUTTON_CLICKED will still be received, just radio button not selected */
+ info.nDefaultRadioButton = ID_START_RADIO_BUTTON;
+ info.dwFlags = TDF_NO_DEFAULT_RADIO_BUTTON;
+ run_test(&info, IDOK, info.nDefaultRadioButton, msg_return_no_default_radio_button_flag, "default radio button: no default radio flag");
+
+ /* Test no default radio button, TDF_NO_DEFAULT_RADIO_BUTTON is set and nDefaultRadioButton is 0.
+ * TDN_RADIO_BUTTON_CLICKED will not be sent, and just radio button not selected */
+ info.nDefaultRadioButton = 0;
+ info.dwFlags = TDF_NO_DEFAULT_RADIO_BUTTON;
+ run_test(&info, IDOK, 0, msg_return_no_default_radio_button_id_and_flag, "default radio button: no default radio id and flag");
+
+ /* Test no default radio button, TDF_NO_DEFAULT_RADIO_BUTTON is set and nDefaultRadioButton is invalid.
+ * TDN_RADIO_BUTTON_CLICKED will not be sent, and just radio button not selected */
+ info.nDefaultRadioButton = 0xff;
+ info.dwFlags = TDF_NO_DEFAULT_RADIO_BUTTON;
+ run_test(&info, IDOK, 0, msg_return_no_default_radio_button_id_and_flag, "default radio button: no default flag, invalid id");
}
static void test_help(void)
@@ -319,7 +453,7 @@ static void test_help(void)
info.lpCallbackData = test_ref_data;
info.dwCommonButtons = TDCBF_OK_BUTTON;
- run_test(&info, IDOK, msg_got_tdn_help, "send f1");
+ run_test(&info, IDOK, 0, msg_got_tdn_help, "send f1");
}
struct timer_notification_data
--
2.17.1
June 17, 2018
[PATCH 1/3] comctl32/taskdialog: Fix buttons might disappear.
by Zhiyi Zhang
In the old button layout algorithm, line count is added
before adding button. This cause line count buffer
overflow when the first button is very long.
This patch modify the algorithm to add button first before
adjusting line count.
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/comctl32/taskdialog.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c
index 1a5fad1609..33fb578910 100644
--- a/dlls/comctl32/taskdialog.c
+++ b/dlls/comctl32/taskdialog.c
@@ -506,16 +506,15 @@ static void taskdialog_layout(struct taskdialog_info *dialog_info)
x = h_spacing;
for (i = 0, line_count = 0; i < dialog_info->button_count; i++)
{
- if (x + button_layout_infos[i].width + h_spacing >= dialog_width)
+ button_layout_infos[i].line = line_count;
+ x += button_layout_infos[i].width + h_spacing;
+ line_widths[line_count] += button_layout_infos[i].width + h_spacing;
+
+ if ((i + 1 < dialog_info->button_count) && (x + button_layout_infos[i + 1].width + h_spacing >= dialog_width))
{
x = h_spacing;
line_count++;
}
-
- button_layout_infos[i].line = line_count;
-
- x += button_layout_infos[i].width + h_spacing;
- line_widths[line_count] += button_layout_infos[i].width + h_spacing;
}
line_count++;
--
2.17.1
June 17, 2018
[PATCH 2/2] msvcp120: Add test for Concurrent_vector_swap.
by Hua Meng
Signed-off-by: Hua meng <161220092(a)smail.nju.edu.cn>
---
dlls/msvcp120/tests/msvcp120.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
index 895ab36..aec66fb 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -402,6 +402,8 @@ static void (__thiscall *p_vector_base_v4__Internal_copy)(
static void (__thiscall *p_vector_base_v4__Internal_assign)(
vector_base_v4*, vector_base_v4*, size_t, void (__cdecl*)(void*, size_t),
void (__cdecl*)(void*, const void*, size_t), void (__cdecl*)(void*, const void*, size_t));
+static void (__thiscall *p_vector_base_v4__Internal_swap)(
+ vector_base_v4*, const vector_base_v4*);
static HMODULE msvcp;
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
@@ -548,6 +550,8 @@ static BOOL init(void)
"?_Internal_copy(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IEAAXAEBV123(a)_KP6AXPEAXPEBX1@Z(a)Z");
SET(p_vector_base_v4__Internal_assign,
"?_Internal_assign(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IEAAXAEBV123(a)_KP6AXPEAX1@ZP6AX2PEBX1(a)Z5@Z");
+ SET(p_vector_base_v4__Internal_swap,
+ "?_Internal_swap(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IEAAXAEAV123@@Z");
} else {
SET(p_tr2_sys__File_size,
"?_File_size(a)sys@tr2(a)std@@YA_KPBD(a)Z");
@@ -663,6 +667,8 @@ static BOOL init(void)
"?_Internal_copy(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IAEXABV123(a)IP6AXPAXPBXI@Z(a)Z");
SET(p_vector_base_v4__Internal_assign,
"?_Internal_assign(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IAEXABV123(a)IP6AXPAXI@ZP6AX1PBXI(a)Z4@Z");
+ SET(p_vector_base_v4__Internal_swap,
+ "?_Internal_swap(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IAEXAAV123@@Z");
#else
SET(p__Thrd_current,
"_Thrd_current");
@@ -706,6 +712,8 @@ static BOOL init(void)
"?_Internal_copy(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IAAXABV123(a)IP6AXPAXPBXI@Z(a)Z");
SET(p_vector_base_v4__Internal_assign,
"?_Internal_assign(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IAAXABV123(a)IP6AXPAXI@ZP6AX1PBXI(a)Z4@Z");
+ SET(p_vector_base_v4__Internal_swap,
+ "?_Internal_swap(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IAAXAAV123@@Z");
#endif
}
SET(p__Thrd_equal,
@@ -2851,6 +2859,39 @@ static void test_vector_base_v4(void)
CHECK_CALLED(concurrent_vector_int_destroy);
concurrent_vector_int_dtor(&v2);
+ concurrent_vector_int_ctor(&v2);
+ SET_EXPECT(concurrent_vector_int_alloc);
+ data = call_func3(p_vector_base_v4__Internal_push_back, &v2, sizeof(int), &idx);
+ ok(data != NULL, "_Internal_push_back returned NULL\n");
+ data = call_func3(p_vector_base_v4__Internal_push_back, &v2, sizeof(int), &idx);
+ ok(data != NULL, "_Internal_push_back returned NULL\n");
+ CHECK_CALLED(concurrent_vector_int_alloc);
+ SET_EXPECT(concurrent_vector_int_alloc);
+ data = call_func3(p_vector_base_v4__Internal_push_back, &v2, sizeof(int), &idx);
+ ok(data != NULL, "_Internal_push_back returned NULL\n");
+ CHECK_CALLED(concurrent_vector_int_alloc);
+ vector_elem_count += 3;
+ ok(idx == 2, "idx got %ld expected 2\n", (long)idx);
+ call_func2(p_vector_base_v4__Internal_swap,
+ &v2, &vector);
+ ok(v2.first_block == 1, "v2.first_block got %ld expected 1\n",
+ (long)v2.first_block);
+ ok(v2.early_size == 5, "v2.early_size got %ld expected 5\n",
+ (long)v2.early_size);
+ ok(vector.early_size == 3, "vector.early_size got %ld expected 3\n",
+ (long)vector.early_size);
+ call_func2(p_vector_base_v4__Internal_swap,
+ &v2, &vector);
+ ok(v2.early_size == 3, "v2.early_size got %ld expected 3\n",
+ (long)v2.early_size);
+ ok(vector.early_size == 5, "vector.early_size got %ld expected 5\n",
+ (long)vector.early_size);
+ SET_EXPECT(concurrent_vector_int_destroy);
+ size = (size_t)call_func2(p_vector_base_v4__Internal_clear,
+ &v2, concurrent_vector_int_destroy);
+ CHECK_CALLED(concurrent_vector_int_destroy);
+ concurrent_vector_int_dtor(&v2);
+
SET_EXPECT(concurrent_vector_int_destroy);
size = (size_t)call_func2(p_vector_base_v4__Internal_clear,
&vector, concurrent_vector_int_destroy);
--
2.11.0
June 17, 2018
[PATCH 1/2] msvcp120: Add test for Concurrent_vector_assign.
by Hua Meng
Signed-off-by: Hua meng <161220092(a)smail.nju.edu.cn>
---
dlls/msvcp120/tests/msvcp120.c | 56 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
index c34bd65..895ab36 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -40,6 +40,7 @@ struct expect_struct {
DEFINE_EXPECT(concurrent_vector_int_alloc);
DEFINE_EXPECT(concurrent_vector_int_destroy);
DEFINE_EXPECT(concurrent_vector_int_copy);
+ DEFINE_EXPECT(concurrent_vector_int_assign);
};
#define SET_EXPECT(func) \
@@ -114,6 +115,8 @@ static void * (WINAPI *call_thiscall_func3)( void *func, void *this, const void
const void *b );
static void * (WINAPI *call_thiscall_func4)( void *func, void *this, const void *a,
const void *b, const void *c );
+static void * (WINAPI *call_thiscall_func6)( void *func, void *this, const void *a,
+ const void *b, const void *c, const void *d, const void *e );
static void init_thiscall_thunk(void)
{
@@ -128,6 +131,7 @@ static void init_thiscall_thunk(void)
call_thiscall_func2 = (void *)thunk;
call_thiscall_func3 = (void *)thunk;
call_thiscall_func4 = (void *)thunk;
+ call_thiscall_func6 = (void *)thunk;
}
#define call_func1(func,_this) call_thiscall_func1(func,_this)
@@ -136,6 +140,8 @@ static void init_thiscall_thunk(void)
(const void*)(b))
#define call_func4(func,_this,a,b,c) call_thiscall_func4(func,_this,(const void*)(a),\
(const void*)(b),(const void*)(c))
+#define call_func6(func,_this,a,b,c,d,e) call_thiscall_func6(func,_this,(const void*)(a),\
+ (const void*)(b),(const void*)(c),(const void*)(d),(const void*)(e))
#else
#define init_thiscall_thunk()
@@ -143,6 +149,7 @@ static void init_thiscall_thunk(void)
#define call_func2(func,_this,a) func(_this,a)
#define call_func3(func,_this,a,b) func(_this,a,b)
#define call_func4(func,_this,a,b,c) func(_this,a,b,c)
+#define call_func6(func,_this,a,b,c,d,e) func(_this,a,b,c,d,e)
#endif /* __i386__ */
static inline float __port_infinity(void)
@@ -392,6 +399,9 @@ static size_t (__thiscall *p_vector_base_v4__Internal_clear)(
vector_base_v4*, void (__cdecl*)(void*, size_t));
static void (__thiscall *p_vector_base_v4__Internal_copy)(
vector_base_v4*, vector_base_v4*, size_t, void (__cdecl*)(void*, const void*, size_t));
+static void (__thiscall *p_vector_base_v4__Internal_assign)(
+ vector_base_v4*, vector_base_v4*, size_t, void (__cdecl*)(void*, size_t),
+ void (__cdecl*)(void*, const void*, size_t), void (__cdecl*)(void*, const void*, size_t));
static HMODULE msvcp;
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
@@ -536,6 +546,8 @@ static BOOL init(void)
"?_Internal_clear(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IEAA_KP6AXPEAX_K(a)Z@Z");
SET(p_vector_base_v4__Internal_copy,
"?_Internal_copy(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IEAAXAEBV123(a)_KP6AXPEAXPEBX1@Z(a)Z");
+ SET(p_vector_base_v4__Internal_assign,
+ "?_Internal_assign(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IEAAXAEBV123(a)_KP6AXPEAX1@ZP6AX2PEBX1(a)Z5@Z");
} else {
SET(p_tr2_sys__File_size,
"?_File_size(a)sys@tr2(a)std@@YA_KPBD(a)Z");
@@ -649,6 +661,8 @@ static BOOL init(void)
"?_Internal_clear(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IAEIP6AXPAXI(a)Z@Z");
SET(p_vector_base_v4__Internal_copy,
"?_Internal_copy(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IAEXABV123(a)IP6AXPAXPBXI@Z(a)Z");
+ SET(p_vector_base_v4__Internal_assign,
+ "?_Internal_assign(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IAEXABV123(a)IP6AXPAXI@ZP6AX1PBXI(a)Z4@Z");
#else
SET(p__Thrd_current,
"_Thrd_current");
@@ -690,6 +704,8 @@ static BOOL init(void)
"?_Internal_clear(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IAAIP6AXPAXI(a)Z@Z");
SET(p_vector_base_v4__Internal_copy,
"?_Internal_copy(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IAAXABV123(a)IP6AXPAXPBXI@Z(a)Z");
+ SET(p_vector_base_v4__Internal_assign,
+ "?_Internal_assign(a)_Concurrent_vector_base_v4@details(a)Concurrency@@IAAXABV123(a)IP6AXPAXI@ZP6AX1PBXI(a)Z4@Z");
#endif
}
SET(p__Thrd_equal,
@@ -2509,6 +2525,12 @@ static void __cdecl concurrent_vector_int_copy(void *dst, const void *src, size_
memcpy(dst, src, n*sizeof(int));
}
+static void __cdecl concurrent_vector_int_assign(void *dst, const void *src, size_t n)
+{
+ CHECK_EXPECT2(concurrent_vector_int_assign);
+ memcpy(dst, src, n*sizeof(int));
+}
+
static void test_queue_base_v4(void)
{
queue_base_v4 queue;
@@ -2793,6 +2815,40 @@ static void test_vector_base_v4(void)
SET_EXPECT(concurrent_vector_int_destroy);
size = (size_t)call_func2(p_vector_base_v4__Internal_clear,
&v2, concurrent_vector_int_destroy);
+ CHECK_CALLED(concurrent_vector_int_destroy);
+ concurrent_vector_int_dtor(&v2);
+
+ concurrent_vector_int_ctor(&v2);
+ SET_EXPECT(concurrent_vector_int_alloc);
+ data = call_func3(p_vector_base_v4__Internal_push_back, &v2, sizeof(int), &idx);
+ CHECK_CALLED(concurrent_vector_int_alloc);
+ ok(data != NULL, "_Internal_push_back returned NULL\n");
+ data = call_func3(p_vector_base_v4__Internal_push_back, &v2, sizeof(int), &idx);
+ ok(data != NULL, "_Internal_push_back returned NULL\n");
+ SET_EXPECT(concurrent_vector_int_alloc);
+ data = call_func3(p_vector_base_v4__Internal_push_back, &v2, sizeof(int), &idx);
+ ok(data != NULL, "_Internal_push_back returned NULL\n");
+ CHECK_CALLED(concurrent_vector_int_alloc);
+ vector_elem_count += 3;
+ ok(idx == 2, "idx got %ld expected 2\n", (long)idx);
+ SET_EXPECT(concurrent_vector_int_assign);
+ SET_EXPECT(concurrent_vector_int_copy);
+ SET_EXPECT(concurrent_vector_int_alloc);
+ call_func6(p_vector_base_v4__Internal_assign, &v2, &vector, sizeof(int),
+ concurrent_vector_int_destroy, concurrent_vector_int_assign,
+ concurrent_vector_int_copy);
+ CHECK_CALLED(concurrent_vector_int_assign);
+ CHECK_CALLED(concurrent_vector_int_copy);
+ CHECK_CALLED(concurrent_vector_int_alloc);
+ ok(v2.first_block == 1, "v2.first_block got %ld expected 1\n",
+ (long)v2.first_block);
+ ok(v2.early_size == 5, "v2.early_size got %ld expected 5\n",
+ (long)v2.early_size);
+
+ SET_EXPECT(concurrent_vector_int_destroy);
+ size = (size_t)call_func2(p_vector_base_v4__Internal_clear,
+ &v2, concurrent_vector_int_destroy);
+ CHECK_CALLED(concurrent_vector_int_destroy);
concurrent_vector_int_dtor(&v2);
SET_EXPECT(concurrent_vector_int_destroy);
--
2.11.0
June 17, 2018
[PATCH v3] vbscript: Treat \r as a newline separator.
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
Sorry about the delay; seems this one got lost somehow.
dlls/vbscript/lex.c | 6 ++++--
dlls/vbscript/tests/run.c | 12 ++++++++++++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c
index 98b4cbb..b0fac48 100644
--- a/dlls/vbscript/lex.c
+++ b/dlls/vbscript/lex.c
@@ -383,13 +383,14 @@ static int parse_hex_literal(parser_ctx_t *ctx, LONG *ret)
static void skip_spaces(parser_ctx_t *ctx)
{
- while(*ctx->ptr == ' ' || *ctx->ptr == '\t' || *ctx->ptr == '\r')
+ while(*ctx->ptr == ' ' || *ctx->ptr == '\t')
ctx->ptr++;
}
static int comment_line(parser_ctx_t *ctx)
{
- ctx->ptr = strchrW(ctx->ptr, '\n');
+ static const WCHAR newlineW[] = {'\n','\r',0};
+ ctx->ptr = strpbrkW(ctx->ptr, newlineW);
if(ctx->ptr)
ctx->ptr++;
else
@@ -421,6 +422,7 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx)
switch(c) {
case '\n':
+ case '\r':
ctx->ptr++;
return tNL;
case '\'':
diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c
index 6b57540..191f5a7 100644
--- a/dlls/vbscript/tests/run.c
+++ b/dlls/vbscript/tests/run.c
@@ -2394,6 +2394,18 @@ static void run_tests(void)
ok(FAILED(hres), "script didn't fail\n");
todo_wine CHECK_CALLED(OnScriptError);
+ SET_EXPECT(global_success_d);
+ SET_EXPECT(global_success_i);
+ parse_script_a("' comment\r"
+ "Sub testsub(arg)\r"
+ "If arg = 1 Then\r\r"
+ "Call reportSuccess()\n\n"
+ "End If\r\n"
+ "End Sub\n\r"
+ "Call testsub(1)");
+ CHECK_CALLED(global_success_d);
+ CHECK_CALLED(global_success_i);
+
run_from_res("lang.vbs");
run_from_res("api.vbs");
run_from_res("regexp.vbs");
--
2.7.4
June 17, 2018
[PATCH 2/2] hnetcfg: Store the UNC path in INetFwAuthorizedApplication_put_ProcessImageFileName().
by Zebediah Figura
Fixes test failures when running from virtual drive.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/hnetcfg/apps.c | 31 ++++++++++++++++++++++++++-----
dlls/hnetcfg/tests/Makefile.in | 2 +-
dlls/hnetcfg/tests/policy.c | 15 ++++++++++++++-
3 files changed, 41 insertions(+), 7 deletions(-)
diff --git a/dlls/hnetcfg/apps.c b/dlls/hnetcfg/apps.c
index fda714e..e3b6b36 100644
--- a/dlls/hnetcfg/apps.c
+++ b/dlls/hnetcfg/apps.c
@@ -263,18 +263,39 @@ static HRESULT WINAPI fw_app_get_ProcessImageFileName(
}
static HRESULT WINAPI fw_app_put_ProcessImageFileName(
- INetFwAuthorizedApplication *iface,
- BSTR imageFileName )
+ INetFwAuthorizedApplication *iface, BSTR image )
{
fw_app *This = impl_from_INetFwAuthorizedApplication( iface );
+ UNIVERSAL_NAME_INFOW *info;
+ WCHAR *netpath;
+ DWORD res;
+ DWORD sz;
- FIXME("%p, %s\n", This, debugstr_w(imageFileName));
+ FIXME("%p, %s\n", This, debugstr_w(image));
- if (!imageFileName || !imageFileName[0])
+ if (!image || !image[0])
return E_INVALIDARG;
+ sz = 0;
+ res = WNetGetUniversalNameW(image, UNIVERSAL_NAME_INFO_LEVEL, NULL, &sz);
+ if (res == WN_MORE_DATA)
+ {
+ if (!(netpath = heap_alloc(sz)))
+ return E_OUTOFMEMORY;
+
+ info = (UNIVERSAL_NAME_INFOW *)&netpath;
+ res = WNetGetUniversalNameW(image, UNIVERSAL_NAME_INFO_LEVEL, &info, &sz);
+ if (res == NO_ERROR)
+ {
+ SysFreeString(This->filename);
+ This->filename = SysAllocString(info->lpUniversalName);
+ }
+ heap_free(netpath);
+ return HRESULT_FROM_WIN32(res);
+ }
+
SysFreeString( This->filename );
- This->filename = SysAllocString( imageFileName );
+ This->filename = SysAllocString(image);
return This->filename ? S_OK : E_OUTOFMEMORY;
}
diff --git a/dlls/hnetcfg/tests/Makefile.in b/dlls/hnetcfg/tests/Makefile.in
index 8315b4b..922370a 100644
--- a/dlls/hnetcfg/tests/Makefile.in
+++ b/dlls/hnetcfg/tests/Makefile.in
@@ -1,5 +1,5 @@
TESTDLL = hnetcfg.dll
-IMPORTS = ole32 uuid oleaut32 advapi32
+IMPORTS = ole32 uuid oleaut32 advapi32 mpr
C_SRCS = \
policy.c
diff --git a/dlls/hnetcfg/tests/policy.c b/dlls/hnetcfg/tests/policy.c
index 012bbcd..f2d1372 100644
--- a/dlls/hnetcfg/tests/policy.c
+++ b/dlls/hnetcfg/tests/policy.c
@@ -106,9 +106,12 @@ static void test_NetFwAuthorizedApplication(void)
{
INetFwAuthorizedApplication *app;
static WCHAR empty[] = {0};
+ UNIVERSAL_NAME_INFOW *info;
+ WCHAR netpath[MAX_PATH];
WCHAR image[MAX_PATH];
HRESULT hr;
BSTR bstr;
+ DWORD sz;
hr = CoCreateInstance(&CLSID_NetFwAuthorizedApplication, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_INetFwAuthorizedApplication, (void**)&app);
@@ -135,9 +138,19 @@ static void test_NetFwAuthorizedApplication(void)
ok(hr == S_OK, "got: %08x\n", hr);
SysFreeString(bstr);
+ info = (UNIVERSAL_NAME_INFOW *)&netpath;
+ sz = sizeof(netpath);
+ hr = WNetGetUniversalNameW(image, UNIVERSAL_NAME_INFO_LEVEL, &info, &sz);
+ if (hr != NO_ERROR)
+ {
+ info->lpUniversalName = netpath + sizeof(*info)/sizeof(WCHAR);
+ lstrcpyW(info->lpUniversalName, image);
+ }
+
hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr);
ok(hr == S_OK, "got: %08x\n", hr);
- ok(!lstrcmpiW(bstr,image), "got: %s\n", wine_dbgstr_w(bstr));
+ ok(!lstrcmpW(bstr,info->lpUniversalName), "expected %s, got %s\n",
+ wine_dbgstr_w(info->lpUniversalName), wine_dbgstr_w(bstr));
SysFreeString(bstr);
INetFwAuthorizedApplication_Release(app);
--
2.7.4
June 16, 2018
[PATCH 1/2] hnetcfg/tests: Fix BSTR usage in test_NetFwAuthorizedApplication().
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/hnetcfg/tests/policy.c | 52 ++++++++++++++++++++-------------------------
1 file changed, 23 insertions(+), 29 deletions(-)
diff --git a/dlls/hnetcfg/tests/policy.c b/dlls/hnetcfg/tests/policy.c
index 4ee19d8..012bbcd 100644
--- a/dlls/hnetcfg/tests/policy.c
+++ b/dlls/hnetcfg/tests/policy.c
@@ -105,48 +105,42 @@ static void test_interfaces(void)
static void test_NetFwAuthorizedApplication(void)
{
INetFwAuthorizedApplication *app;
+ static WCHAR empty[] = {0};
+ WCHAR image[MAX_PATH];
HRESULT hr;
+ BSTR bstr;
hr = CoCreateInstance(&CLSID_NetFwAuthorizedApplication, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_INetFwAuthorizedApplication, (void**)&app);
ok(hr == S_OK, "got: %08x\n", hr);
- if(hr == S_OK)
- {
- BSTR image = SysAllocStringLen( NULL, MAX_PATH );
- static WCHAR empty[] = {0};
- BSTR bstr;
- if (!GetModuleFileNameW( NULL, image, MAX_PATH ))
- {
- ok(0, "Failed to get filename\n");
- SysFreeString( image );
- return;
- }
+ hr = GetModuleFileNameW(NULL, image, sizeof(image));
+ ok(hr, "GetModuleFileName failed: %u\n", GetLastError());
- hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, NULL);
- ok(hr == E_POINTER, "got: %08x\n", hr);
+ hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, NULL);
+ ok(hr == E_POINTER, "got: %08x\n", hr);
- hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr);
- ok(hr == S_OK || hr == HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY), "got: %08x\n", hr);
- ok(!bstr, "got: %s\n", wine_dbgstr_w(bstr));
+ hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr);
+ ok(hr == S_OK || hr == HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY), "got: %08x\n", hr);
+ ok(!bstr, "got: %s\n", wine_dbgstr_w(bstr));
- hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, NULL);
- ok(hr == E_INVALIDARG || hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got: %08x\n", hr);
+ hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, NULL);
+ ok(hr == E_INVALIDARG || hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got: %08x\n", hr);
- hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, empty);
- ok(hr == E_INVALIDARG || hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got: %08x\n", hr);
+ hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, empty);
+ ok(hr == E_INVALIDARG || hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "got: %08x\n", hr);
- hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, image);
- ok(hr == S_OK, "got: %08x\n", hr);
+ bstr = SysAllocString(image);
+ hr = INetFwAuthorizedApplication_put_ProcessImageFileName(app, bstr);
+ ok(hr == S_OK, "got: %08x\n", hr);
+ SysFreeString(bstr);
- hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr);
- ok(hr == S_OK, "got: %08x\n", hr);
- ok(!lstrcmpiW(bstr,image), "got: %s\n", wine_dbgstr_w(bstr));
- SysFreeString( bstr );
+ hr = INetFwAuthorizedApplication_get_ProcessImageFileName(app, &bstr);
+ ok(hr == S_OK, "got: %08x\n", hr);
+ ok(!lstrcmpiW(bstr,image), "got: %s\n", wine_dbgstr_w(bstr));
+ SysFreeString(bstr);
- SysFreeString( image );
- INetFwAuthorizedApplication_Release(app);
- }
+ INetFwAuthorizedApplication_Release(app);
}
START_TEST(policy)
--
2.7.4
June 16, 2018
Re: [PATCH v5 3/8] kernel32/tests: Add GetSystemFirmwareTable tests
by Alex Henrie
On Fri, Jun 15, 2018 at 2:37 AM Huw Davies <huw(a)codeweavers.com> wrote:
>
> On Fri, Jun 15, 2018 at 12:59:09AM -0600, Alex Henrie wrote:
> > + sfti->ProviderSignature = RSMB;
> > + sfti->Action = SystemFirmwareTable_Get;
>
> You need to initialize TableID.
When querying the RSMB table, TableID is ignored. You get the same
results no matter what the table ID is. I'm adding a test that
demonstrates this.
I did, however, notice that some of the RSMB table values change over
time. So, I'm going to omit the test for NtQuerySystemInformation and
GetSystemFirmwareTable returning exactly the same data, and instead
just check that they both return the same amount of data.
If you'd like to look over my latest work before Monday, you can see
it at https://github.com/alexhenrie/wine/commits/master
Thanks for the help!
-Alex
June 16, 2018
[PATCH] comctl32/imagelist: fix ImageList_Read/Write.
by Denis Malikov
From: Denis Malikov <mdn40000(a)mail.ru>
Date: Sat, 16 Jun 2018 16:35:45 +0700
Subject: [PATCH] comctl32/imagelist: fix ImageList_Read/Write.
Fix for versions x600 and x620 and pointer calculation for mixing image and mask bits.
Tested on ReactOS 0.4.10 with *.reg files extracted from:
- XP/2003 key HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify;
- Vista/7 key HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify
Signed-off-by: Denis Malikov <mdn40000(a)mail.ru>
---
dlls/comctl32/imagelist.c | 59 +++++++++++++++++++++++++++--------------------
1 file changed, 34 insertions(+), 25 deletions(-)
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index a08d60752e..052d59f9e4 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -59,7 +59,7 @@ struct _IMAGELIST
INT cGrow; /* 0C: cGrow */
INT cx; /* 10: cx */
INT cy; /* 14: cy */
- DWORD x4;
+ DWORD x4; /* hack for IL from stream. Keep version here */
UINT flags; /* 1C: flags */
COLORREF clrFg; /* 20: foreground color */
COLORREF clrBk; /* 24: background color */
@@ -83,6 +83,7 @@ struct _IMAGELIST
};
#define IMAGELIST_MAGIC 0x53414D58
+#define IMAGELIST_VERSION 0x101
/* Header used by ImageList_Read() and ImageList_Write() */
#include "pshpack2.h"
@@ -806,6 +807,7 @@ ImageList_Create (INT cx, INT cy, UINT flags,
himl->clrFg = CLR_DEFAULT;
himl->clrBk = CLR_NONE;
himl->color_table_set = FALSE;
+ himl->x4 = 0;
/* initialize overlay mask indices */
for (nCount = 0; nCount < MAX_OVERLAYIMAGE; nCount++)
@@ -2257,38 +2259,43 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm)
BITMAPINFO *image_info = (BITMAPINFO *)image_buf;
BITMAPINFO *mask_info = (BITMAPINFO *)mask_buf;
void *image_bits, *mask_bits = NULL;
- ILHEAD ilHead;
- HIMAGELIST himl;
+ ILHEAD ilHead;
+ HIMAGELIST himl;
unsigned int i;
TRACE("%p\n", pstm);
if (FAILED(IStream_Read (pstm, &ilHead, sizeof(ILHEAD), NULL)))
- return NULL;
+ return NULL;
if (ilHead.usMagic != (('L' << 8) | 'I'))
- return NULL;
- if (ilHead.usVersion != 0x101) /* probably version? */
- return NULL;
+ return NULL;
+ if (ilHead.usVersion != IMAGELIST_VERSION &&
+ ilHead.usVersion != 0x600 && /* XP/2003 version */
+ ilHead.usVersion != 0x620) /* Vista/7 version */
+ return NULL;
TRACE("cx %u, cy %u, flags 0x%04x, cCurImage %u, cMaxImage %u\n",
ilHead.cx, ilHead.cy, ilHead.flags, ilHead.cCurImage, ilHead.cMaxImage);
himl = ImageList_Create(ilHead.cx, ilHead.cy, ilHead.flags, ilHead.cCurImage, ilHead.cMaxImage);
if (!himl)
- return NULL;
+ return NULL;
+
+ // keep version from stream
+ himl->x4 = ilHead.usVersion;
if (!(image_bits = read_bitmap(pstm, image_info)))
{
- WARN("failed to read bitmap from stream\n");
- return NULL;
+ WARN("failed to read bitmap from stream\n");
+ return NULL;
}
if (ilHead.flags & ILC_MASK)
{
if (!(mask_bits = read_bitmap(pstm, mask_info)))
{
WARN("failed to read mask bitmap from stream\n");
- return NULL;
- }
+ return NULL;
+ }
}
else mask_info = NULL;
@@ -2296,23 +2303,25 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm)
{
DWORD *ptr = image_bits;
BYTE *mask_ptr = mask_bits;
- int stride = himl->cy * image_info->bmiHeader.biWidth;
+ int stride = himl->cy * (ilHead.usVersion != IMAGELIST_VERSION ? himl->cx : image_info->bmiHeader.biWidth);
+ int image_step = ilHead.usVersion != IMAGELIST_VERSION ? 1 : TILE_COUNT;
+ int mask_step = ilHead.usVersion != IMAGELIST_VERSION ? 4 : 8;
if (image_info->bmiHeader.biHeight > 0) /* bottom-up */
{
ptr += image_info->bmiHeader.biHeight * image_info->bmiHeader.biWidth - stride;
- mask_ptr += (image_info->bmiHeader.biHeight * image_info->bmiHeader.biWidth - stride) / 8;
+ mask_ptr += (image_info->bmiHeader.biHeight * image_info->bmiHeader.biWidth - stride) / mask_step;
stride = -stride;
image_info->bmiHeader.biHeight = himl->cy;
}
else image_info->bmiHeader.biHeight = -himl->cy;
- for (i = 0; i < ilHead.cCurImage; i += TILE_COUNT)
+ for (i = 0; i < ilHead.cCurImage; i += image_step)
{
- add_dib_bits( himl, i, min( ilHead.cCurImage - i, TILE_COUNT ),
+ add_dib_bits( himl, i, min( ilHead.cCurImage - i, image_step ),
himl->cx, himl->cy, image_info, mask_info, ptr, mask_ptr );
ptr += stride;
- mask_ptr += stride / 8;
+ mask_ptr += stride / mask_step;
}
}
else
@@ -2333,7 +2342,7 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm)
ImageList_SetBkColor(himl,ilHead.bkcolor);
for (i=0;i<4;i++)
- ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1);
+ ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1);
return himl;
}
@@ -3078,10 +3087,10 @@ BOOL WINAPI ImageList_Write(HIMAGELIST himl, IStream *pstm)
TRACE("%p %p\n", himl, pstm);
if (!is_valid(himl))
- return FALSE;
+ return FALSE;
ilHead.usMagic = (('L' << 8) | 'I');
- ilHead.usVersion = 0x101;
+ ilHead.usVersion = himl->x4 > 0 ? himl->x4 : IMAGELIST_VERSION;
ilHead.cCurImage = himl->cCurImage;
ilHead.cMaxImage = himl->cMaxImage;
ilHead.cGrow = himl->cGrow;
@@ -3090,23 +3099,23 @@ BOOL WINAPI ImageList_Write(HIMAGELIST himl, IStream *pstm)
ilHead.bkcolor = himl->clrBk;
ilHead.flags = himl->flags;
for(i = 0; i < 4; i++) {
- ilHead.ovls[i] = himl->nOvlIdx[i];
+ ilHead.ovls[i] = himl->nOvlIdx[i];
}
TRACE("cx %u, cy %u, flags 0x04%x, cCurImage %u, cMaxImage %u\n",
ilHead.cx, ilHead.cy, ilHead.flags, ilHead.cCurImage, ilHead.cMaxImage);
if(FAILED(IStream_Write(pstm, &ilHead, sizeof(ILHEAD), NULL)))
- return FALSE;
+ return FALSE;
/* write the bitmap */
if(!_write_bitmap(himl->hbmImage, pstm))
- return FALSE;
+ return FALSE;
/* write the mask if we have one */
if(himl->flags & ILC_MASK) {
- if(!_write_bitmap(himl->hbmMask, pstm))
- return FALSE;
+ if(!_write_bitmap(himl->hbmMask, pstm))
+ return FALSE;
}
return TRUE;
--
2.16.2.windows.1
June 16, 2018
Re: [PATCH] gdiplus: Check return value of SelectClipPath in brush_fill_path().
by Zhiyi Zhang
Thanks. I'll work on it as you suggest.
On Sat 6 16 23:26, Vincent Povirk wrote:
> If converting a path to a region fails for an open path, then our code
> in get_path_hrgn is also wrong. From reading gdi32 code, think it will
> work as long as there are points in the path, but the only way to be
> sure is to add a test.
>
> If we check for failure in SelectClipPath, I agree that we should not
> continue the operation for any error. I think we should report failure
> to the caller if it's an error we don't expect. That would also help
> explain why it's correct to silently ignore the failure.
>
> On Sat, Jun 16, 2018 at 9:31 AM, Zhiyi Zhang <zzhang(a)codeweavers.com> wrote:
>> Hi Vincent,
>>
>> Yes, we could check if a path is empty just like get_path_hrgn did.
>> I also worried that a not empty but open path will also make SelectClipPath()
>> fail. Is there any function to check if a path is closed? I couldn't found any.
>> As for SelectClipPath() last error, I don't think any further operation should
>> be continued if any error occurs.
>> So we add a check for empty path and also skip further operation if SelectClipPath()
>> returns any error. Is that enough?
>>
>> Thanks,
>> Zhiyi
>>
>> On Fri 6 15 23:55, Vincent Povirk wrote:
>>> It looks like we also encountered this case in get_path_hrgn. Maybe we
>>> shouldn't call brush_fill_pixels if the path is empty? If we're going
>>> to ignore errors, I think we should at least check GetLastError() to
>>> make sure it's one we expect.
>>>
>>> On Fri, Jun 15, 2018 at 4:04 AM, Zhiyi Zhang <zzhang(a)codeweavers.com> wrote:
>>>> For Crossover bug 16126.
>>>>
>>>> When GraphicPath is empty, filling path with gdi32 will
>>>> result in a DC with empty path. When SelectClipPath() is
>>>> called with such a DC, it will fail because it requires
>>>> a closed path in DC. Thus further operation should be canceled.
>>>>
>>>> Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
>>>> ---
>>>> dlls/gdiplus/graphics.c | 5 +++--
>>>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
>>>> index 76aabe74bf..2a95d686fa 100644
>>>> --- a/dlls/gdiplus/graphics.c
>>>> +++ b/dlls/gdiplus/graphics.c
>>>> @@ -1052,6 +1052,7 @@ static BOOL brush_can_fill_path(GpBrush *brush, BOOL is_fill)
>>>>
>>>> static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
>>>> {
>>>> + BOOL success;
>>>> switch (brush->bt)
>>>> {
>>>> case BrushTypeSolidColor:
>>>> @@ -1064,8 +1065,8 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
>>>> RECT rc;
>>>> /* partially transparent fill */
>>>>
>>>> - SelectClipPath(graphics->hdc, RGN_AND);
>>>> - if (GetClipBox(graphics->hdc, &rc) != NULLREGION)
>>>> + success = SelectClipPath(graphics->hdc, RGN_AND);
>>>> + if (success && GetClipBox(graphics->hdc, &rc) != NULLREGION)
>>>> {
>>>> HDC hdc = CreateCompatibleDC(NULL);
>>>>
>>>> --
>>>> 2.17.1
>>>>
>>>>
>>>>
>
>
June 16, 2018
Re: [PATCH] gdiplus: Check return value of SelectClipPath in brush_fill_path().
by Vincent Povirk
If converting a path to a region fails for an open path, then our code
in get_path_hrgn is also wrong. From reading gdi32 code, think it will
work as long as there are points in the path, but the only way to be
sure is to add a test.
If we check for failure in SelectClipPath, I agree that we should not
continue the operation for any error. I think we should report failure
to the caller if it's an error we don't expect. That would also help
explain why it's correct to silently ignore the failure.
On Sat, Jun 16, 2018 at 9:31 AM, Zhiyi Zhang <zzhang(a)codeweavers.com> wrote:
> Hi Vincent,
>
> Yes, we could check if a path is empty just like get_path_hrgn did.
> I also worried that a not empty but open path will also make SelectClipPath()
> fail. Is there any function to check if a path is closed? I couldn't found any.
> As for SelectClipPath() last error, I don't think any further operation should
> be continued if any error occurs.
> So we add a check for empty path and also skip further operation if SelectClipPath()
> returns any error. Is that enough?
>
> Thanks,
> Zhiyi
>
> On Fri 6 15 23:55, Vincent Povirk wrote:
>> It looks like we also encountered this case in get_path_hrgn. Maybe we
>> shouldn't call brush_fill_pixels if the path is empty? If we're going
>> to ignore errors, I think we should at least check GetLastError() to
>> make sure it's one we expect.
>>
>> On Fri, Jun 15, 2018 at 4:04 AM, Zhiyi Zhang <zzhang(a)codeweavers.com> wrote:
>>> For Crossover bug 16126.
>>>
>>> When GraphicPath is empty, filling path with gdi32 will
>>> result in a DC with empty path. When SelectClipPath() is
>>> called with such a DC, it will fail because it requires
>>> a closed path in DC. Thus further operation should be canceled.
>>>
>>> Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
>>> ---
>>> dlls/gdiplus/graphics.c | 5 +++--
>>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
>>> index 76aabe74bf..2a95d686fa 100644
>>> --- a/dlls/gdiplus/graphics.c
>>> +++ b/dlls/gdiplus/graphics.c
>>> @@ -1052,6 +1052,7 @@ static BOOL brush_can_fill_path(GpBrush *brush, BOOL is_fill)
>>>
>>> static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
>>> {
>>> + BOOL success;
>>> switch (brush->bt)
>>> {
>>> case BrushTypeSolidColor:
>>> @@ -1064,8 +1065,8 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
>>> RECT rc;
>>> /* partially transparent fill */
>>>
>>> - SelectClipPath(graphics->hdc, RGN_AND);
>>> - if (GetClipBox(graphics->hdc, &rc) != NULLREGION)
>>> + success = SelectClipPath(graphics->hdc, RGN_AND);
>>> + if (success && GetClipBox(graphics->hdc, &rc) != NULLREGION)
>>> {
>>> HDC hdc = CreateCompatibleDC(NULL);
>>>
>>> --
>>> 2.17.1
>>>
>>>
>>>
June 16, 2018
[PATCH] comctl32/imagelist: fix ImageList_Read/Write.
by Локтар Огар
From: Denis Malikov <mdn40000(a)mail.ru>
Date: Sat, 16 Jun 2018 16:35:45 +0700
Subject: [PATCH] comctl32/imagelist: fix ImageList_Read/Write.
Fix for versions x600 and x620 and pointer calculation for mixing
image and mask bits.
Tested on ReactOS 0.4.10 with *.reg files extracted from:
- XP/2003 key HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify;
- Vista/7 key HKEY_CLASSES_ROOT\Local
Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify
Signed-off-by: Denis Malikov <mdn40000(a)mail.ru>
---
dlls/comctl32/imagelist.c | 59 +++++++++++++++++++++++++++--------------------
1 file changed, 34 insertions(+), 25 deletions(-)
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index a08d60752e..052d59f9e4 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -59,7 +59,7 @@ struct _IMAGELIST
INT cGrow; /* 0C: cGrow */
INT cx; /* 10: cx */
INT cy; /* 14: cy */
- DWORD x4;
+ DWORD x4; /* hack for IL from
stream. Keep version here */
UINT flags; /* 1C: flags */
COLORREF clrFg; /* 20: foreground color */
COLORREF clrBk; /* 24: background color */
@@ -83,6 +83,7 @@ struct _IMAGELIST
};
#define IMAGELIST_MAGIC 0x53414D58
+#define IMAGELIST_VERSION 0x101
/* Header used by ImageList_Read() and ImageList_Write() */
#include "pshpack2.h"
@@ -806,6 +807,7 @@ ImageList_Create (INT cx, INT cy, UINT flags,
himl->clrFg = CLR_DEFAULT;
himl->clrBk = CLR_NONE;
himl->color_table_set = FALSE;
+ himl->x4 = 0;
/* initialize overlay mask indices */
for (nCount = 0; nCount < MAX_OVERLAYIMAGE; nCount++)
@@ -2257,38 +2259,43 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm)
BITMAPINFO *image_info = (BITMAPINFO *)image_buf;
BITMAPINFO *mask_info = (BITMAPINFO *)mask_buf;
void *image_bits, *mask_bits = NULL;
- ILHEAD ilHead;
- HIMAGELIST himl;
+ ILHEAD ilHead;
+ HIMAGELIST himl;
unsigned int i;
TRACE("%p\n", pstm);
if (FAILED(IStream_Read (pstm, &ilHead, sizeof(ILHEAD), NULL)))
- return NULL;
+ return NULL;
if (ilHead.usMagic != (('L' << 8) | 'I'))
- return NULL;
- if (ilHead.usVersion != 0x101) /* probably version? */
- return NULL;
+ return NULL;
+ if (ilHead.usVersion != IMAGELIST_VERSION &&
+ ilHead.usVersion != 0x600 && /* XP/2003 version */
+ ilHead.usVersion != 0x620) /* Vista/7 version */
+ return NULL;
TRACE("cx %u, cy %u, flags 0x%04x, cCurImage %u, cMaxImage %u\n",
ilHead.cx, ilHead.cy, ilHead.flags, ilHead.cCurImage,
ilHead.cMaxImage);
himl = ImageList_Create(ilHead.cx, ilHead.cy, ilHead.flags,
ilHead.cCurImage, ilHead.cMaxImage);
if (!himl)
- return NULL;
+ return NULL;
+
+ // keep version from stream
+ himl->x4 = ilHead.usVersion;
if (!(image_bits = read_bitmap(pstm, image_info)))
{
- WARN("failed to read bitmap from stream\n");
- return NULL;
+ WARN("failed to read bitmap from stream\n");
+ return NULL;
}
if (ilHead.flags & ILC_MASK)
{
if (!(mask_bits = read_bitmap(pstm, mask_info)))
{
WARN("failed to read mask bitmap from stream\n");
- return NULL;
- }
+ return NULL;
+ }
}
else mask_info = NULL;
@@ -2296,23 +2303,25 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm)
{
DWORD *ptr = image_bits;
BYTE *mask_ptr = mask_bits;
- int stride = himl->cy * image_info->bmiHeader.biWidth;
+ int stride = himl->cy * (ilHead.usVersion !=
IMAGELIST_VERSION ? himl->cx : image_info->bmiHeader.biWidth);
+ int image_step = ilHead.usVersion != IMAGELIST_VERSION ? 1 :
TILE_COUNT;
+ int mask_step = ilHead.usVersion != IMAGELIST_VERSION ? 4 : 8;
if (image_info->bmiHeader.biHeight > 0) /* bottom-up */
{
ptr += image_info->bmiHeader.biHeight *
image_info->bmiHeader.biWidth - stride;
- mask_ptr += (image_info->bmiHeader.biHeight *
image_info->bmiHeader.biWidth - stride) / 8;
+ mask_ptr += (image_info->bmiHeader.biHeight *
image_info->bmiHeader.biWidth - stride) / mask_step;
stride = -stride;
image_info->bmiHeader.biHeight = himl->cy;
}
else image_info->bmiHeader.biHeight = -himl->cy;
- for (i = 0; i < ilHead.cCurImage; i += TILE_COUNT)
+ for (i = 0; i < ilHead.cCurImage; i += image_step)
{
- add_dib_bits( himl, i, min( ilHead.cCurImage - i, TILE_COUNT ),
+ add_dib_bits( himl, i, min( ilHead.cCurImage - i, image_step ),
himl->cx, himl->cy, image_info, mask_info,
ptr, mask_ptr );
ptr += stride;
- mask_ptr += stride / 8;
+ mask_ptr += stride / mask_step;
}
}
else
@@ -2333,7 +2342,7 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm)
ImageList_SetBkColor(himl,ilHead.bkcolor);
for (i=0;i<4;i++)
- ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1);
+ ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1);
return himl;
}
@@ -3078,10 +3087,10 @@ BOOL WINAPI ImageList_Write(HIMAGELIST himl,
IStream *pstm)
TRACE("%p %p\n", himl, pstm);
if (!is_valid(himl))
- return FALSE;
+ return FALSE;
ilHead.usMagic = (('L' << 8) | 'I');
- ilHead.usVersion = 0x101;
+ ilHead.usVersion = himl->x4 > 0 ? himl->x4 : IMAGELIST_VERSION;
ilHead.cCurImage = himl->cCurImage;
ilHead.cMaxImage = himl->cMaxImage;
ilHead.cGrow = himl->cGrow;
@@ -3090,23 +3099,23 @@ BOOL WINAPI ImageList_Write(HIMAGELIST himl,
IStream *pstm)
ilHead.bkcolor = himl->clrBk;
ilHead.flags = himl->flags;
for(i = 0; i < 4; i++) {
- ilHead.ovls[i] = himl->nOvlIdx[i];
+ ilHead.ovls[i] = himl->nOvlIdx[i];
}
TRACE("cx %u, cy %u, flags 0x04%x, cCurImage %u, cMaxImage %u\n",
ilHead.cx, ilHead.cy, ilHead.flags, ilHead.cCurImage,
ilHead.cMaxImage);
if(FAILED(IStream_Write(pstm, &ilHead, sizeof(ILHEAD), NULL)))
- return FALSE;
+ return FALSE;
/* write the bitmap */
if(!_write_bitmap(himl->hbmImage, pstm))
- return FALSE;
+ return FALSE;
/* write the mask if we have one */
if(himl->flags & ILC_MASK) {
- if(!_write_bitmap(himl->hbmMask, pstm))
- return FALSE;
+ if(!_write_bitmap(himl->hbmMask, pstm))
+ return FALSE;
}
return TRUE;
--
2.16.2.windows.1
June 16, 2018
Re: [PATCH] gdiplus: Check return value of SelectClipPath in brush_fill_path().
by Zhiyi Zhang
Hi Vincent,
Yes, we could check if a path is empty just like get_path_hrgn did.
I also worried that a not empty but open path will also make SelectClipPath()
fail. Is there any function to check if a path is closed? I couldn't found any.
As for SelectClipPath() last error, I don't think any further operation should
be continued if any error occurs.
So we add a check for empty path and also skip further operation if SelectClipPath()
returns any error. Is that enough?
Thanks,
Zhiyi
On Fri 6 15 23:55, Vincent Povirk wrote:
> It looks like we also encountered this case in get_path_hrgn. Maybe we
> shouldn't call brush_fill_pixels if the path is empty? If we're going
> to ignore errors, I think we should at least check GetLastError() to
> make sure it's one we expect.
>
> On Fri, Jun 15, 2018 at 4:04 AM, Zhiyi Zhang <zzhang(a)codeweavers.com> wrote:
>> For Crossover bug 16126.
>>
>> When GraphicPath is empty, filling path with gdi32 will
>> result in a DC with empty path. When SelectClipPath() is
>> called with such a DC, it will fail because it requires
>> a closed path in DC. Thus further operation should be canceled.
>>
>> Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
>> ---
>> dlls/gdiplus/graphics.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
>> index 76aabe74bf..2a95d686fa 100644
>> --- a/dlls/gdiplus/graphics.c
>> +++ b/dlls/gdiplus/graphics.c
>> @@ -1052,6 +1052,7 @@ static BOOL brush_can_fill_path(GpBrush *brush, BOOL is_fill)
>>
>> static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
>> {
>> + BOOL success;
>> switch (brush->bt)
>> {
>> case BrushTypeSolidColor:
>> @@ -1064,8 +1065,8 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
>> RECT rc;
>> /* partially transparent fill */
>>
>> - SelectClipPath(graphics->hdc, RGN_AND);
>> - if (GetClipBox(graphics->hdc, &rc) != NULLREGION)
>> + success = SelectClipPath(graphics->hdc, RGN_AND);
>> + if (success && GetClipBox(graphics->hdc, &rc) != NULLREGION)
>> {
>> HDC hdc = CreateCompatibleDC(NULL);
>>
>> --
>> 2.17.1
>>
>>
>>
June 16, 2018
[PATCH] comctl32/imagelist: fix ImageList_Read/Write.
by Денис Маликов
From: Denis Malikov <mdn40000(a)mail.ru>
Date: Sat, 16 Jun 2018 16:35:45 +0700
Subject: [PATCH] comctl32/imagelist: fix ImageList_Read/Write.
Fixed acceptable version and pointer calculation for mixing image and mask bits.
Tested on ReactOS 0.4.10 with *.reg files extracted from XP/2003 key HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify
Signed-off-by: Denis Malikov <mdn40000(a)mail.ru>
---
dlls/comctl32/imagelist.c | 48 +++++++++++++++++++++++------------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index a08d60752e..f0f8a695fe 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -2257,38 +2257,38 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm)
BITMAPINFO *image_info = (BITMAPINFO *)image_buf;
BITMAPINFO *mask_info = (BITMAPINFO *)mask_buf;
void *image_bits, *mask_bits = NULL;
- ILHEAD ilHead;
- HIMAGELIST himl;
+ ILHEAD ilHead;
+ HIMAGELIST himl;
unsigned int i;
TRACE("%p\n", pstm);
if (FAILED(IStream_Read (pstm, &ilHead, sizeof(ILHEAD), NULL)))
- return NULL;
+ return NULL;
if (ilHead.usMagic != (('L' << 8) | 'I'))
- return NULL;
- if (ilHead.usVersion != 0x101) /* probably version? */
- return NULL;
+ return NULL;
+ if (ilHead.usVersion != 0x600) /* XP/2003 version */
+ return NULL;
TRACE("cx %u, cy %u, flags 0x%04x, cCurImage %u, cMaxImage %u\n",
ilHead.cx, ilHead.cy, ilHead.flags, ilHead.cCurImage, ilHead.cMaxImage);
himl = ImageList_Create(ilHead.cx, ilHead.cy, ilHead.flags, ilHead.cCurImage, ilHead.cMaxImage);
if (!himl)
- return NULL;
+ return NULL;
if (!(image_bits = read_bitmap(pstm, image_info)))
{
- WARN("failed to read bitmap from stream\n");
- return NULL;
+ WARN("failed to read bitmap from stream\n");
+ return NULL;
}
if (ilHead.flags & ILC_MASK)
{
if (!(mask_bits = read_bitmap(pstm, mask_info)))
{
WARN("failed to read mask bitmap from stream\n");
- return NULL;
- }
+ return NULL;
+ }
}
else mask_info = NULL;
@@ -2296,23 +2296,23 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm)
{
DWORD *ptr = image_bits;
BYTE *mask_ptr = mask_bits;
- int stride = himl->cy * image_info->bmiHeader.biWidth;
+ int stride = himl->cy * himl->cx;
if (image_info->bmiHeader.biHeight > 0) /* bottom-up */
{
ptr += image_info->bmiHeader.biHeight * image_info->bmiHeader.biWidth - stride;
- mask_ptr += (image_info->bmiHeader.biHeight * image_info->bmiHeader.biWidth - stride) / 8;
+ mask_ptr += (image_info->bmiHeader.biHeight * image_info->bmiHeader.biWidth - stride) / 4;
stride = -stride;
image_info->bmiHeader.biHeight = himl->cy;
}
else image_info->bmiHeader.biHeight = -himl->cy;
- for (i = 0; i < ilHead.cCurImage; i += TILE_COUNT)
+ for (i = 0; i < ilHead.cCurImage; i++)
{
- add_dib_bits( himl, i, min( ilHead.cCurImage - i, TILE_COUNT ),
+ add_dib_bits( himl, i, 1,
himl->cx, himl->cy, image_info, mask_info, ptr, mask_ptr );
ptr += stride;
- mask_ptr += stride / 8;
+ mask_ptr += stride / 4;
}
}
else
@@ -2333,7 +2333,7 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm)
ImageList_SetBkColor(himl,ilHead.bkcolor);
for (i=0;i<4;i++)
- ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1);
+ ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1);
return himl;
}
@@ -3078,10 +3078,10 @@ BOOL WINAPI ImageList_Write(HIMAGELIST himl, IStream *pstm)
TRACE("%p %p\n", himl, pstm);
if (!is_valid(himl))
- return FALSE;
+ return FALSE;
ilHead.usMagic = (('L' << 8) | 'I');
- ilHead.usVersion = 0x101;
+ ilHead.usVersion = 0x600;
ilHead.cCurImage = himl->cCurImage;
ilHead.cMaxImage = himl->cMaxImage;
ilHead.cGrow = himl->cGrow;
@@ -3090,23 +3090,23 @@ BOOL WINAPI ImageList_Write(HIMAGELIST himl, IStream *pstm)
ilHead.bkcolor = himl->clrBk;
ilHead.flags = himl->flags;
for(i = 0; i < 4; i++) {
- ilHead.ovls[i] = himl->nOvlIdx[i];
+ ilHead.ovls[i] = himl->nOvlIdx[i];
}
TRACE("cx %u, cy %u, flags 0x04%x, cCurImage %u, cMaxImage %u\n",
ilHead.cx, ilHead.cy, ilHead.flags, ilHead.cCurImage, ilHead.cMaxImage);
if(FAILED(IStream_Write(pstm, &ilHead, sizeof(ILHEAD), NULL)))
- return FALSE;
+ return FALSE;
/* write the bitmap */
if(!_write_bitmap(himl->hbmImage, pstm))
- return FALSE;
+ return FALSE;
/* write the mask if we have one */
if(himl->flags & ILC_MASK) {
- if(!_write_bitmap(himl->hbmMask, pstm))
- return FALSE;
+ if(!_write_bitmap(himl->hbmMask, pstm))
+ return FALSE;
}
return TRUE;
--
2.16.2.windows.1
June 16, 2018
[PATCH] msi: Mark exported wine functions CDECL.
by Zebediah Figura
Fixes relay traces on 64-bit.
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/msi/custom.c | 2 +-
programs/msiexec/msiexec.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c
index 8deebe5..e68528f 100644
--- a/dlls/msi/custom.c
+++ b/dlls/msi/custom.c
@@ -484,7 +484,7 @@ static void handle_msi_break(LPCSTR target)
static WCHAR ncalrpcW[] = {'n','c','a','l','r','p','c',0};
static WCHAR endpoint_lrpcW[] = {'m','s','i',0};
-UINT __wine_msi_call_dll_function(const GUID *guid)
+UINT CDECL __wine_msi_call_dll_function(const GUID *guid)
{
MsiCustomActionEntryPoint fn;
MSIHANDLE remote_package = 0;
diff --git a/programs/msiexec/msiexec.c b/programs/msiexec/msiexec.c
index 2ed0557..5ebfea7 100644
--- a/programs/msiexec/msiexec.c
+++ b/programs/msiexec/msiexec.c
@@ -393,7 +393,7 @@ static DWORD DoUnregServer(void)
return ret;
}
-extern UINT __wine_msi_call_dll_function(GUID *guid);
+extern UINT CDECL __wine_msi_call_dll_function(GUID *guid);
static int DoEmbedding(LPCWSTR key)
{
--
2.7.4
June 15, 2018
Re: [PATCH] msi/tests: Use the available ARRAY_SIZE() macro
by Hans Leidekker
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
June 15, 2018
Re: [PATCH] msi/tests: Use the available ARRAY_SIZE() macro
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=39159
Your paranoid android.
=== wxppro (32 bit install) ===
TestBot process got stuck or died unexpectedly
The previous 1 run(s) terminated abnormally
June 15, 2018