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
[PATCH v5 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 | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index e79059b224..7380b236b1 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 */
@@ -1945,12 +1956,15 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
size_t system_vendor_size, system_product_size, system_version_size, system_serial_size;
char *board_vendor, *board_product, *board_version, *board_serial;
size_t board_vendor_size, board_product_size, board_version_size, board_serial_size;
+ char *chassis_vendor, *chassis_version, *chassis_serial, *chassis_asset_tag;
+ size_t chassis_vendor_size, chassis_version_size, chassis_serial_size, chassis_asset_tag_size;
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;
bios_vendor = get_smbios_string("/sys/class/dmi/id/bios_vendor", &bios_vendor_size);
bios_version = get_smbios_string("/sys/class/dmi/id/bios_version", &bios_version_size);
@@ -1963,6 +1977,10 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
board_product = get_smbios_string("/sys/class/dmi/id/board_name", &board_product_size);
board_version = get_smbios_string("/sys/class/dmi/id/board_version", &board_version_size);
board_serial = get_smbios_string("/sys/class/dmi/id/board_serial", &board_serial_size);
+ chassis_vendor = get_smbios_string("/sys/class/dmi/id/chassis_vendor", &chassis_vendor_size);
+ chassis_version = get_smbios_string("/sys/class/dmi/id/chassis_version", &chassis_version_size);
+ chassis_serial = get_smbios_string("/sys/class/dmi/id/chassis_serial", &chassis_serial_size);
+ chassis_asset_tag = get_smbios_string("/sys/class/dmi/id/chassis_tag", &chassis_asset_tag_size);
*required_len = FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
@@ -1980,6 +1998,10 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
*required_len += max(board_vendor_size + board_product_size + board_version_size +
board_serial_size + 1, 2);
+ *required_len += sizeof(struct smbios_chassis);
+ *required_len += max(chassis_vendor_size + chassis_version_size + chassis_serial_size +
+ chassis_asset_tag_size + 1, 2);
+
if (available_len < *required_len)
{
return STATUS_BUFFER_TOO_SMALL;
@@ -2048,6 +2070,33 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
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 ? ++string_count : 0;
+ chassis->shape = 0x2; /* unknown */
+ chassis->version = chassis_version ? ++string_count : 0;
+ chassis->serial = chassis_serial ? ++string_count : 0;
+ chassis->asset_tag = chassis_asset_tag ? ++string_count : 0;
+ buffer += sizeof(struct smbios_chassis);
+
+ if (string_count)
+ {
+ copy_smbios_string(&buffer, chassis_vendor, chassis_vendor_size);
+ copy_smbios_string(&buffer, chassis_version, chassis_version_size);
+ copy_smbios_string(&buffer, chassis_serial, chassis_serial_size);
+ copy_smbios_string(&buffer, chassis_asset_tag, chassis_asset_tag_size);
+ memset(buffer, 0, 1);
+ buffer++;
+ }
+ else
+ {
+ memset(buffer, 0, 2);
+ buffer += 2;
+ }
+
string_count = 0;
board = (struct smbios_board*)buffer;
board->type = 2;
@@ -2083,6 +2132,10 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
free(board_product);
free(board_version);
free(board_serial);
+ free(chassis_vendor);
+ free(chassis_version);
+ free(chassis_serial);
+ free(chassis_asset_tag);
return STATUS_SUCCESS;
}
--
2.17.1
June 15, 2018
[PATCH v5 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 | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 560cb747bf..e79059b224 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 */
@@ -1933,11 +1943,14 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
size_t bios_vendor_size, bios_version_size, bios_date_size;
char *system_vendor, *system_product, *system_version, *system_serial;
size_t system_vendor_size, system_product_size, system_version_size, system_serial_size;
+ char *board_vendor, *board_product, *board_version, *board_serial;
+ size_t board_vendor_size, board_product_size, board_version_size, board_serial_size;
char *buffer = (char*)sfti->TableBuffer;
BYTE string_count;
struct smbios_prologue *prologue;
struct smbios_bios *bios;
struct smbios_system *system;
+ struct smbios_board *board;
bios_vendor = get_smbios_string("/sys/class/dmi/id/bios_vendor", &bios_vendor_size);
bios_version = get_smbios_string("/sys/class/dmi/id/bios_version", &bios_version_size);
@@ -1946,6 +1959,10 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
system_product = get_smbios_string("/sys/class/dmi/id/product", &system_product_size);
system_version = get_smbios_string("/sys/class/dmi/id/product_version", &system_version_size);
system_serial = get_smbios_string("/sys/class/dmi/id/product_serial", &system_serial_size);
+ board_vendor = get_smbios_string("/sys/class/dmi/id/board_vendor", &board_vendor_size);
+ board_product = get_smbios_string("/sys/class/dmi/id/board_name", &board_product_size);
+ board_version = get_smbios_string("/sys/class/dmi/id/board_version", &board_version_size);
+ board_serial = get_smbios_string("/sys/class/dmi/id/board_serial", &board_serial_size);
*required_len = FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
@@ -1955,9 +1972,14 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
*required_len += max(bios_vendor_size + bios_version_size + bios_date_size + 1, 2);
*required_len += sizeof(struct smbios_system);
+
*required_len += max(system_vendor_size + system_product_size + system_version_size +
system_serial_size + 1, 2);
+ *required_len += sizeof(struct smbios_board);
+ *required_len += max(board_vendor_size + board_product_size + board_version_size +
+ board_serial_size + 1, 2);
+
if (available_len < *required_len)
{
return STATUS_BUFFER_TOO_SMALL;
@@ -2018,6 +2040,32 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
copy_smbios_string(&buffer, system_version, system_version_size);
copy_smbios_string(&buffer, system_serial, system_serial_size);
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 ? ++string_count : 0;
+ board->product = board_product ? ++string_count : 0;
+ board->version = board_version ? ++string_count : 0;
+ board->serial = board_serial ? ++string_count : 0;
+ buffer += sizeof(struct smbios_board);
+
+ if (string_count)
+ {
+ copy_smbios_string(&buffer, board_vendor, board_vendor_size);
+ copy_smbios_string(&buffer, board_product, board_product_size);
+ copy_smbios_string(&buffer, board_version, board_version_size);
+ copy_smbios_string(&buffer, board_serial, board_serial_size);
+ memset(buffer, 0, 1);
}
else
{
@@ -2031,6 +2079,10 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
free(system_product);
free(system_version);
free(system_serial);
+ free(board_vendor);
+ free(board_product);
+ free(board_version);
+ free(board_serial);
return STATUS_SUCCESS;
}
--
2.17.1
June 15, 2018
[PATCH v5 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 | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 658970b051..560cb747bf 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 */
@@ -1921,14 +1931,21 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
{
char *bios_vendor, *bios_version, *bios_date;
size_t bios_vendor_size, bios_version_size, bios_date_size;
+ char *system_vendor, *system_product, *system_version, *system_serial;
+ size_t system_vendor_size, system_product_size, system_version_size, system_serial_size;
char *buffer = (char*)sfti->TableBuffer;
BYTE string_count;
struct smbios_prologue *prologue;
struct smbios_bios *bios;
+ struct smbios_system *system;
bios_vendor = get_smbios_string("/sys/class/dmi/id/bios_vendor", &bios_vendor_size);
bios_version = get_smbios_string("/sys/class/dmi/id/bios_version", &bios_version_size);
bios_date = get_smbios_string("/sys/class/dmi/id/bios_date", &bios_date_size);
+ system_vendor = get_smbios_string("/sys/class/dmi/id/sys_vendor", &system_vendor_size);
+ system_product = get_smbios_string("/sys/class/dmi/id/product", &system_product_size);
+ system_version = get_smbios_string("/sys/class/dmi/id/product_version", &system_version_size);
+ system_serial = get_smbios_string("/sys/class/dmi/id/product_serial", &system_serial_size);
*required_len = FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
@@ -1937,6 +1954,10 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
*required_len += sizeof(struct smbios_bios);
*required_len += max(bios_vendor_size + bios_version_size + bios_date_size + 1, 2);
+ *required_len += sizeof(struct smbios_system);
+ *required_len += max(system_vendor_size + system_product_size + system_version_size +
+ system_serial_size + 1, 2);
+
if (available_len < *required_len)
{
return STATUS_BUFFER_TOO_SMALL;
@@ -1971,6 +1992,32 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
copy_smbios_string(&buffer, bios_version, bios_version_size);
copy_smbios_string(&buffer, bios_date, bios_date_size);
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 ? ++string_count : 0;
+ system->product = system_product ? ++string_count : 0;
+ system->version = system_version ? ++string_count : 0;
+ system->serial = system_serial ? ++string_count : 0;
+ buffer += sizeof(struct smbios_system);
+
+ if (string_count)
+ {
+ copy_smbios_string(&buffer, system_vendor, system_vendor_size);
+ copy_smbios_string(&buffer, system_product, system_product_size);
+ copy_smbios_string(&buffer, system_version, system_version_size);
+ copy_smbios_string(&buffer, system_serial, system_serial_size);
+ memset(buffer, 0, 1);
}
else
{
@@ -1980,6 +2027,10 @@ static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti
free(bios_vendor);
free(bios_version);
free(bios_date);
+ free(system_vendor);
+ free(system_product);
+ free(system_version);
+ free(system_serial);
return STATUS_SUCCESS;
}
--
2.17.1
June 15, 2018
[PATCH v5 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, 29 insertions(+), 12 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 6ca45f0b2e..90d63c2794 100644
--- a/dlls/kernel32/tests/version.c
+++ b/dlls/kernel32/tests/version.c
@@ -721,12 +721,10 @@ void test_GetSystemFirmwareTable(void)
expected_len -= 16;
len = GetSystemFirmwareTable(RSMB, 0, smbios_table, 0);
-todo_wine
ok(len == expected_len, "Expected length %u, got %u\n", expected_len, len);
smbios_table = HeapAlloc(GetProcessHeap(), 0, len);
len = GetSystemFirmwareTable(RSMB, 0, smbios_table, len);
-todo_wine
ok(len == expected_len, "Expected length %u, got %u\n", expected_len, len);
for (i = 0; i < len; i++)
{
--
2.17.1
June 15, 2018
[PATCH v5 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 | 174 ++++++++++++++++++++++++++++++++++++++++
dlls/ntdll/tests/info.c | 14 ++--
2 files changed, 182 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index dc0ce04f42..658970b051 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,129 @@ static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **
}
#endif
+static inline void copy_smbios_string(char **buffer, char *string, size_t string_size)
+{
+ if (!string) return;
+ strcpy(*buffer, string);
+ *buffer += string_size;
+}
+
+#ifdef linux
+
+static char* get_smbios_string(const char *path, size_t *string_size)
+{
+ FILE *file = fopen(path, "r");
+ char *ret = NULL;
+ *string_size = 0;
+ if (file)
+ {
+ *string_size = getline(&ret, string_size, file) + 1;
+ fclose(file);
+ if (*string_size >= 2 && ret[*string_size - 2] == '\n')
+ {
+ ret[*string_size - 2] = 0;
+ (*string_size)--;
+ }
+ if (*string_size == 1)
+ {
+ free(ret);
+ ret = NULL;
+ *string_size = 0;
+ }
+ }
+ return ret;
+}
+
+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, *bios_version, *bios_date;
+ size_t bios_vendor_size, bios_version_size, bios_date_size;
+ char *buffer = (char*)sfti->TableBuffer;
+ BYTE string_count;
+ struct smbios_prologue *prologue;
+ struct smbios_bios *bios;
+
+ bios_vendor = get_smbios_string("/sys/class/dmi/id/bios_vendor", &bios_vendor_size);
+ bios_version = get_smbios_string("/sys/class/dmi/id/bios_version", &bios_version_size);
+ bios_date = get_smbios_string("/sys/class/dmi/id/bios_date", &bios_date_size);
+
+ *required_len = FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
+
+ *required_len += sizeof(struct smbios_prologue);
+
+ *required_len += sizeof(struct smbios_bios);
+ *required_len += max(bios_vendor_size + bios_version_size + bios_date_size + 1, 2);
+
+ if (available_len < *required_len)
+ {
+ return STATUS_BUFFER_TOO_SMALL;
+ }
+
+ sfti->TableBufferLength = *required_len - FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
+
+ 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 ? ++string_count : 0;
+ bios->version = bios_version ? ++string_count : 0;
+ bios->start = 0;
+ bios->date = bios_date ? ++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_size);
+ copy_smbios_string(&buffer, bios_version, bios_version_size);
+ copy_smbios_string(&buffer, bios_date, bios_date_size);
+ memset(buffer, 0, 1);
+ }
+ else
+ {
+ memset(buffer, 0, 2);
+ }
+
+ free(bios_vendor);
+ free(bios_version);
+ free(bios_date);
+
+ return STATUS_SUCCESS;
+ }
+ default:
+ {
+ return STATUS_NOT_IMPLEMENTED;
+ FIXME("info_class SYSTEM_FIRMWARE_TABLE_INFORMATION\n");
+ }
+ }
+}
+
+#else
+
+static inline NTSTATUS get_firmware_info(SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti,
+ ULONG available_len, ULONG *required_len)
+{
+ return STATUS_NOT_IMPLEMENTED;
+ FIXME("info_class SYSTEM_FIRMWARE_TABLE_INFORMATION\n");
+}
+
+#endif
+
/******************************************************************************
* NtQuerySystemInformation [NTDLL.@]
* ZwQuerySystemInformation [NTDLL.@]
@@ -2359,6 +2511,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 cdb91e1b73..b8feebd474 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 */
@@ -840,13 +846,10 @@ 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, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
-todo_wine
ok(len1 == 16, "Expected length 16, got %u\n", len1);
status = pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, 16, &len1);
-todo_wine
ok(status == STATUS_NOT_IMPLEMENTED, "Expected STATUS_NOT_IMPLEMENTED, got %08x\n", status);
ok(len1 == 0, "Expected length 0, got %u\n", len1);
@@ -854,16 +857,15 @@ todo_wine
sfti->Action = SystemFirmwareTable_Get;
status = pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, 16, &len1);
-todo_wine
+todo_wine_if(firmware_todo)
ok(status == STATUS_BUFFER_TOO_SMALL, "Expected STATUS_BUFFER_TOO_SMALL, got %08x\n", status);
-todo_wine
ok(len1 >= 16, "Expected length >= 16, got %u\n", len1);
sfti = HeapReAlloc(GetProcessHeap(), 0, sfti, len1);
ok(!!sfti, "Failed to allocate memory\n");
status = pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, len1, &len2);
-todo_wine
+todo_wine_if(firmware_todo)
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
ok(len2 == len1, "Expected length %u, got %u\n", len1, len2);
--
2.17.1
June 15, 2018
[PATCH v5 3/8] kernel32/tests: Add GetSystemFirmwareTable tests
by Alex Henrie
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
dlls/kernel32/tests/version.c | 42 +++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/dlls/kernel32/tests/version.c b/dlls/kernel32/tests/version.c
index eb78a383d2..6ca45f0b2e 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,40 @@ 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(), 0, 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);
+ sfti = HeapReAlloc(GetProcessHeap(), 0, sfti, expected_len);
+ ok(!!sfti, "Failed to allocate memory\n");
+ pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, expected_len, &expected_len);
+
+ expected_len -= 16;
+ len = GetSystemFirmwareTable(RSMB, 0, smbios_table, 0);
+todo_wine
+ ok(len == expected_len, "Expected length %u, got %u\n", expected_len, len);
+
+ smbios_table = HeapAlloc(GetProcessHeap(), 0, len);
+ len = GetSystemFirmwareTable(RSMB, 0, smbios_table, len);
+todo_wine
+ ok(len == expected_len, "Expected length %u, got %u\n", expected_len, len);
+ for (i = 0; i < len; i++)
+ {
+ ok(smbios_table[i] == sfti->TableBuffer[i],
+ "Offset %u: Expected %02x, got %02x\n", i, sfti->TableBuffer[i], smbios_table[i]);
+ }
+
+ HeapFree(GetProcessHeap(), 0, sfti);
+ HeapFree(GetProcessHeap(), 0, smbios_table);
+}
+
START_TEST(version)
{
init_function_pointers();
@@ -704,4 +745,5 @@ START_TEST(version)
test_GetProductInfo();
test_GetVersionEx();
test_VerifyVersionInfo();
+ test_GetSystemFirmwareTable();
}
--
2.17.1
June 15, 2018
[PATCH v5 2/8] ntdll/tests: Add SystemFirmwareTableInformation tests
by Alex Henrie
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
dlls/ntdll/tests/info.c | 48 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index 6c93c3cd58..cdb91e1b73 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,45 @@ static void test_query_logicalprocex(void)
}
}
+static void test_query_firmware(void)
+{
+ ULONG len1, len2;
+ NTSTATUS status;
+ SYSTEM_FIRMWARE_TABLE_INFORMATION *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, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
+todo_wine
+ ok(len1 == 16, "Expected length 16, got %u\n", len1);
+
+ status = pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, 16, &len1);
+todo_wine
+ 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;
+
+ status = pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, 16, &len1);
+todo_wine
+ ok(status == STATUS_BUFFER_TOO_SMALL, "Expected STATUS_BUFFER_TOO_SMALL, got %08x\n", status);
+todo_wine
+ ok(len1 >= 16, "Expected length >= 16, got %u\n", len1);
+
+ sfti = HeapReAlloc(GetProcessHeap(), 0, sfti, len1);
+ ok(!!sfti, "Failed to allocate memory\n");
+
+ status = pNtQuerySystemInformation(SystemFirmwareTableInformation, sfti, len1, &len2);
+todo_wine
+ ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
+ ok(len2 == len1, "Expected length %u, got %u\n", len1, len2);
+
+ HeapFree(GetProcessHeap(), 0, sfti);
+}
+
static void test_query_processor_power_info(void)
{
NTSTATUS status;
@@ -2267,6 +2311,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 15, 2018
[PATCH v5 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 15, 2018
[PATCH 2/2] iphlpapi: Improve parameter checking for IcmpSendEcho().
by Zhiyi Zhang
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/iphlpapi/icmp.c | 9 +++++++--
dlls/iphlpapi/tests/iphlpapi.c | 8 --------
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/dlls/iphlpapi/icmp.c b/dlls/iphlpapi/icmp.c
index 7c91443598..c9603b7baa 100644
--- a/dlls/iphlpapi/icmp.c
+++ b/dlls/iphlpapi/icmp.c
@@ -290,11 +290,16 @@ DWORD WINAPI IcmpSendEcho(
if (IcmpHandle==INVALID_HANDLE_VALUE) {
/* FIXME: in fact win98 seems to ignore the handle value !!! */
- SetLastError(ERROR_INVALID_HANDLE);
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ if (!ReplyBuffer||!ReplySize) {
+ SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
- if (ReplySize<sizeof(ICMP_ECHO_REPLY)+ICMP_MINLEN) {
+ if (ReplySize<sizeof(ICMP_ECHO_REPLY)) {
SetLastError(IP_BUF_TOO_SMALL);
return 0;
}
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c
index f964878d68..ff381c5e29 100644
--- a/dlls/iphlpapi/tests/iphlpapi.c
+++ b/dlls/iphlpapi/tests/iphlpapi.c
@@ -966,7 +966,6 @@ static void testIcmpSendEcho(void)
ret = pIcmpSendEcho(INVALID_HANDLE_VALUE, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000);
error = GetLastError();
ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
-todo_wine
ok (error == ERROR_INVALID_PARAMETER
|| broken(error == ERROR_INVALID_HANDLE) /* <= 2003 */,
"expected 87, got %d\n", error);
@@ -1009,20 +1008,16 @@ todo_wine
error = GetLastError();
ok (ret, "IcmpSendEcho failed unexpectedly with error %d\n", error);
- if (0) /* crashes in wine, remove IF when fixed */
- {
SetLastError(0xdeadbeef);
ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, NULL, replysz, 1000);
error = GetLastError();
ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
ok (error == ERROR_INVALID_PARAMETER, "expected 87, got %d\n", error);
- }
SetLastError(0xdeadbeef);
ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, 0, 1000);
error = GetLastError();
ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
-todo_wine
ok (error == ERROR_INVALID_PARAMETER
|| broken(error == ERROR_INSUFFICIENT_BUFFER) /* <= 2003 */,
"expected 87, got %d\n", error);
@@ -1031,7 +1026,6 @@ todo_wine
ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, NULL, 0, 1000);
error = GetLastError();
ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
-todo_wine
ok (error == ERROR_INVALID_PARAMETER
|| broken(error == ERROR_INSUFFICIENT_BUFFER) /* <= 2003 */,
"expected 87, got %d\n", error);
@@ -1049,7 +1043,6 @@ todo_wine
replysz = sizeof(ICMP_ECHO_REPLY);
ret = pIcmpSendEcho(icmp, address, senddata, 0, NULL, replydata, replysz, 1000);
error = GetLastError();
-todo_wine
ok (ret, "IcmpSendEcho failed unexpectedly with error %d\n", error);
SetLastError(0xdeadbeef);
@@ -1071,7 +1064,6 @@ todo_wine
ret = pIcmpSendEcho(icmp, address, senddata, ICMP_MINLEN, NULL, replydata, replysz - 1, 1000);
error = GetLastError();
ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
-todo_wine
ok (error == IP_GENERAL_FAILURE
|| broken(error == IP_BUF_TOO_SMALL) /* <= 2003 */,
"expected 11050, got %d\n", error);
--
2.17.1
June 15, 2018
[PATCH 1/2] iphlpapi: Use a standalone buffer in IcmpSendEcho().
by Zhiyi Zhang
Fix https://bugs.winehq.org/show_bug.cgi?id=43252
The old implementation uses user provided buffer to receive
packet data, which is alway not enough, causing data corruptions
or incorrectly timeout.
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/iphlpapi/icmp.c | 38 +++++++++++++++++++++++++++-------
dlls/iphlpapi/tests/iphlpapi.c | 21 +++++++++++++++----
2 files changed, 47 insertions(+), 12 deletions(-)
diff --git a/dlls/iphlpapi/icmp.c b/dlls/iphlpapi/icmp.c
index ebc2f2b65c..7c91443598 100644
--- a/dlls/iphlpapi/icmp.c
+++ b/dlls/iphlpapi/icmp.c
@@ -113,6 +113,9 @@ typedef struct {
#define IP_OPTS_DEFAULT 1
#define IP_OPTS_CUSTOM 2
+#define MAXIPLEN 60
+#define MAXICMPLEN 76
+
/* The sequence number is unique process wide, so that all threads
* have a distinct sequence number.
*/
@@ -270,13 +273,14 @@ DWORD WINAPI IcmpSendEcho(
icmp_t* icp=(icmp_t*)IcmpHandle;
unsigned char* reqbuf;
int reqsize;
+ unsigned char* repbuf;
+ int repsize;
struct icmp_echo_reply* ier;
struct ip* ip_header;
struct icmp* icmp_header;
char* endbuf;
int ip_header_len;
- int maxlen;
struct pollfd fdr;
DWORD send_time,recv_time;
struct sockaddr_in addr;
@@ -312,6 +316,16 @@ DWORD WINAPI IcmpSendEcho(
return 0;
}
+ /* max ip header + max icmp header and error data + reply size(max 65535 on Windows) */
+ /* FIXME: request size of 65535 is not supported yet because max buffer size of raw socket on linux is 32767 */
+ repsize=MAXIPLEN+MAXICMPLEN+(ReplySize&0xFFFF);
+ repbuf=HeapAlloc(GetProcessHeap(), 0, repsize);
+ if (reqbuf==NULL) {
+ HeapFree(GetProcessHeap(), 0, reqbuf);
+ SetLastError(ERROR_OUTOFMEMORY);
+ return 0;
+ }
+
icmp_header=(struct icmp*)reqbuf;
icmp_header->icmp_type=ICMP_ECHO;
icmp_header->icmp_code=0;
@@ -367,9 +381,7 @@ DWORD WINAPI IcmpSendEcho(
fdr.events = POLLIN;
addrlen=sizeof(addr);
ier=ReplyBuffer;
- ip_header=(struct ip *) ((char *) ReplyBuffer+sizeof(ICMP_ECHO_REPLY));
endbuf=(char *) ReplyBuffer+ReplySize;
- maxlen=ReplySize-sizeof(ICMP_ECHO_REPLY);
/* Send the packet */
TRACE("Sending %d bytes (RequestSize=%d) to %s\n", reqsize, RequestSize, inet_ntoa(addr.sin_addr));
@@ -407,10 +419,11 @@ DWORD WINAPI IcmpSendEcho(
}
/* Get the reply */
+ ip_header=(struct ip*)repbuf;
ip_header_len=0; /* because gcc was complaining */
while (poll(&fdr,1,Timeout)>0) {
recv_time = GetTickCount();
- res=recvfrom(icp->sid, (char*)ip_header, maxlen, 0, (struct sockaddr*)&addr,&addrlen);
+ res=recvfrom(icp->sid, (char*)repbuf, repsize, 0, (struct sockaddr*)&addr, &addrlen);
TRACE("received %d bytes from %s\n",res, inet_ntoa(addr.sin_addr));
ier->Status=IP_REQ_TIMED_OUT;
@@ -508,6 +521,12 @@ DWORD WINAPI IcmpSendEcho(
else Timeout = 0;
continue;
} else {
+ /* Check free space, should be large enough for an ICMP_ECHO_REPLY and remainning icmp data */
+ if (endbuf-(char *)ier < sizeof(struct icmp_echo_reply)+(res-ip_header_len-ICMP_MINLEN)) {
+ res=ier-(ICMP_ECHO_REPLY *)ReplyBuffer;
+ SetLastError(IP_GENERAL_FAILURE);
+ goto done;
+ }
/* This is a reply to our packet */
memcpy(&ier->Address,&ip_header->ip_src,sizeof(IPAddr));
/* Status is already set */
@@ -515,7 +534,7 @@ DWORD WINAPI IcmpSendEcho(
ier->DataSize=res-ip_header_len-ICMP_MINLEN;
ier->Reserved=0;
ier->Data=endbuf-ier->DataSize;
- memmove(ier->Data,((char*)ip_header)+ip_header_len+ICMP_MINLEN,ier->DataSize);
+ memcpy(ier->Data, ((char *)ip_header)+ip_header_len+ICMP_MINLEN, ier->DataSize);
ier->Options.Ttl=ip_header->ip_ttl;
ier->Options.Tos=ip_header->ip_tos;
ier->Options.Flags=ip_header->ip_off >> 13;
@@ -523,7 +542,7 @@ DWORD WINAPI IcmpSendEcho(
if (ier->Options.OptionsSize!=0) {
ier->Options.OptionsData=(unsigned char *) ier->Data-ier->Options.OptionsSize;
/* FIXME: We are supposed to rearrange the option's 'source route' data */
- memmove(ier->Options.OptionsData,((char*)ip_header)+ip_header_len,ier->Options.OptionsSize);
+ memcpy(ier->Options.OptionsData, ((char *)ip_header)+ip_header_len, ier->Options.OptionsSize);
endbuf=(char*)ier->Options.OptionsData;
} else {
ier->Options.OptionsData=NULL;
@@ -531,9 +550,8 @@ DWORD WINAPI IcmpSendEcho(
}
/* Prepare for the next packet */
+ endbuf-=ier->DataSize;
ier++;
- ip_header=(struct ip*)(((char*)ip_header)+sizeof(ICMP_ECHO_REPLY));
- maxlen=endbuf-(char*)ip_header;
/* Check out whether there is more but don't wait this time */
Timeout=0;
@@ -542,6 +560,10 @@ DWORD WINAPI IcmpSendEcho(
res=ier-(ICMP_ECHO_REPLY*)ReplyBuffer;
if (res==0)
SetLastError(IP_REQ_TIMED_OUT);
+ else
+ SetLastError(NO_ERROR);
+done:
+ HeapFree(GetProcessHeap(), 0, repbuf);
TRACE("received %d replies\n",res);
return res;
}
diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c
index d5613d7b4b..f964878d68 100644
--- a/dlls/iphlpapi/tests/iphlpapi.c
+++ b/dlls/iphlpapi/tests/iphlpapi.c
@@ -951,6 +951,8 @@ static void testIcmpSendEcho(void)
char senddata[32], replydata[sizeof(senddata) + sizeof(ICMP_ECHO_REPLY)];
DWORD ret, error, replysz = sizeof(replydata);
IPAddr address;
+ ICMP_ECHO_REPLY *reply;
+ INT i;
if (!pIcmpSendEcho || !pIcmpCreateFile)
{
@@ -1038,12 +1040,10 @@ todo_wine
replysz = sizeof(replydata) - 1;
ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000);
error = GetLastError();
- todo_wine {
ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
ok (error == IP_GENERAL_FAILURE
|| broken(error == IP_BUF_TOO_SMALL) /* <= 2003 */,
"expected 11050, got %d\n", error);
- }
SetLastError(0xdeadbeef);
replysz = sizeof(ICMP_ECHO_REPLY);
@@ -1056,7 +1056,6 @@ todo_wine
replysz = sizeof(ICMP_ECHO_REPLY) + ICMP_MINLEN;
ret = pIcmpSendEcho(icmp, address, senddata, ICMP_MINLEN, NULL, replydata, replysz, 1000);
error = GetLastError();
-todo_wine
ok (ret, "IcmpSendEcho failed unexpectedly with error %d\n", error);
SetLastError(0xdeadbeef);
@@ -1064,7 +1063,6 @@ todo_wine
ret = pIcmpSendEcho(icmp, address, senddata, ICMP_MINLEN + 1, NULL, replydata, replysz, 1000);
error = GetLastError();
ok (!ret, "IcmpSendEcho succeeded unexpectedly\n");
-todo_wine
ok (error == IP_GENERAL_FAILURE
|| broken(error == IP_BUF_TOO_SMALL) /* <= 2003 */,
"expected 11050, got %d\n", error);
@@ -1111,6 +1109,21 @@ todo_wine
{
skip ("Failed to ping with error %d, is lo interface down?.\n", error);
}
+
+ /* check reply data */
+ SetLastError(0xdeadbeef);
+ address = htonl(INADDR_LOOPBACK);
+ for (i = 0; i < ARRAY_SIZE(senddata); i++) senddata[i] = i & 0xff;
+ ret = pIcmpSendEcho(icmp, address, senddata, sizeof(senddata), NULL, replydata, replysz, 1000);
+ error = GetLastError();
+ reply = (ICMP_ECHO_REPLY *)replydata;
+ ok(ret, "IcmpSendEcho failed unexpectedly\n");
+ ok(error == NO_ERROR, "Expect last error:0x%08x, got:0x%08x\n", NO_ERROR, error);
+ ok(INADDR_LOOPBACK == ntohl(reply->Address), "Address mismatch, expect:%s, got: %s\n", ntoa(INADDR_LOOPBACK),
+ ntoa(reply->Address));
+ ok(reply->Status == IP_SUCCESS, "Expect status:0x%08x, got:0x%08x\n", IP_SUCCESS, reply->Status);
+ ok(reply->DataSize == sizeof(senddata), "Expect data size:%d, got:%d\n", sizeof(senddata), reply->DataSize);
+ ok(!memcmp(senddata, reply->Data, min(sizeof(senddata), reply->DataSize)), "Data mismatch\n");
}
/*
--
2.17.1
June 15, 2018
[PATCH] kernel32: Always start debugger on WinSta0.
by Alistair Leslie-Hughes
From: Sebastian Lackner <sebastian(a)fds-team.de>
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/kernel32/except.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/dlls/kernel32/except.c b/dlls/kernel32/except.c
index de244fc..5f2166e 100644
--- a/dlls/kernel32/except.c
+++ b/dlls/kernel32/except.c
@@ -304,6 +304,7 @@ static BOOL start_debugger(PEXCEPTION_POINTERS epointers, HANDLE hEvent)
TRACE("Starting debugger %s\n", debugstr_a(cmdline));
memset(&startup, 0, sizeof(startup));
startup.cb = sizeof(startup);
+ startup.lpDesktop = (char *)"WinSta0";
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = SW_SHOWNORMAL;
ret = CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, 0, env, NULL, &startup, &info);
--
1.9.1
June 15, 2018
[PATCH v3] comctl32/taskdialog: Add support for progress bar.
by Zhiyi Zhang
Rebase. Supersede 147419.
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/comctl32/taskdialog.c | 55 ++++++++++++++++++++++++++
dlls/comctl32/tests/taskdialog.c | 67 ++++++++++++++++++++++++++++++++
2 files changed, 122 insertions(+)
diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c
index 07c031b2c7..1a5fad1609 100644
--- a/dlls/comctl32/taskdialog.c
+++ b/dlls/comctl32/taskdialog.c
@@ -57,6 +57,7 @@ struct taskdialog_info
HWND main_icon;
HWND main_instruction;
HWND content;
+ HWND progress_bar;
HWND *buttons;
INT button_count;
HWND default_button;
@@ -351,6 +352,17 @@ static void taskdialog_add_content(struct taskdialog_info *dialog_info)
taskdialog_hyperlink_enabled(dialog_info));
}
+static void taskdialog_add_progress_bar(struct taskdialog_info *dialog_info)
+{
+ const TASKDIALOGCONFIG *taskconfig = dialog_info->taskconfig;
+ DWORD style = PBS_SMOOTH | PBS_SMOOTHREVERSE | WS_CHILD | WS_VISIBLE;
+
+ if (!(taskconfig->dwFlags & (TDF_SHOW_PROGRESS_BAR | TDF_SHOW_MARQUEE_PROGRESS_BAR))) return;
+ if (taskconfig->dwFlags & TDF_SHOW_MARQUEE_PROGRESS_BAR) style |= PBS_MARQUEE;
+ dialog_info->progress_bar =
+ CreateWindowW(PROGRESS_CLASSW, NULL, style, 0, 0, 0, 0, dialog_info->hwnd, NULL, 0, NULL);
+}
+
static void taskdialog_add_button(struct taskdialog_info *dialog_info, HWND *button, INT_PTR id, const WCHAR *text,
BOOL custom_button)
{
@@ -464,6 +476,17 @@ static void taskdialog_layout(struct taskdialog_info *dialog_info)
/* Content */
taskdialog_label_layout(dialog_info, dialog_info->content, main_icon_right, dialog_width, &dialog_height, syslink);
+ /* Progress bar */
+ if (dialog_info->progress_bar)
+ {
+ x = main_icon_right + h_spacing;
+ y = dialog_height + v_spacing;
+ size.cx = dialog_width - x - h_spacing;
+ size.cy = GetSystemMetrics(SM_CYVSCROLL);
+ SetWindowPos(dialog_info->progress_bar, 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 */
@@ -598,6 +621,7 @@ static void taskdialog_init(struct taskdialog_info *dialog_info, HWND hwnd)
taskdialog_add_main_icon(dialog_info);
taskdialog_add_main_instruction(dialog_info);
taskdialog_add_content(dialog_info);
+ taskdialog_add_progress_bar(dialog_info);
taskdialog_add_buttons(dialog_info);
/* Set default button */
@@ -621,6 +645,7 @@ static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
{
static const WCHAR taskdialog_info_propnameW[] = {'T','a','s','k','D','i','a','l','o','g','I','n','f','o',0};
struct taskdialog_info *dialog_info;
+ LRESULT result;
TRACE("hwnd=%p msg=0x%04x wparam=%lx lparam=%lx\n", hwnd, msg, wParam, lParam);
@@ -635,6 +660,36 @@ static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
case TDM_ENABLE_BUTTON:
taskdialog_enable_button(dialog_info, wParam, lParam);
break;
+ case TDM_SET_MARQUEE_PROGRESS_BAR:
+ {
+ BOOL marquee = wParam;
+ LONG style;
+ if(!dialog_info->progress_bar) break;
+ style = GetWindowLongW(dialog_info->progress_bar, GWL_STYLE);
+ style = marquee ? style | PBS_MARQUEE : style & (~PBS_MARQUEE);
+ SetWindowLongW(dialog_info->progress_bar, GWL_STYLE, style);
+ break;
+ }
+ case TDM_SET_PROGRESS_BAR_STATE:
+ result = SendMessageW(dialog_info->progress_bar, PBM_SETSTATE, wParam, 0);
+ SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, result);
+ break;
+ case TDM_SET_PROGRESS_BAR_RANGE:
+ result = SendMessageW(dialog_info->progress_bar, PBM_SETRANGE, 0, lParam);
+ SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, result);
+ break;
+ case TDM_SET_PROGRESS_BAR_POS:
+ result = 0;
+ if (dialog_info->progress_bar)
+ {
+ LONG style = GetWindowLongW(dialog_info->progress_bar, GWL_STYLE);
+ if (!(style & PBS_MARQUEE)) result = SendMessageW(dialog_info->progress_bar, PBM_SETPOS, wParam, 0);
+ }
+ SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, result);
+ break;
+ case TDM_SET_PROGRESS_BAR_MARQUEE:
+ SendMessageW(dialog_info->progress_bar, PBM_SETMARQUEE, wParam, lParam);
+ break;
case WM_INITDIALOG:
dialog_info = (struct taskdialog_info *)lParam;
diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c
index cca700cd18..e91a878876 100644
--- a/dlls/comctl32/tests/taskdialog.c
+++ b/dlls/comctl32/tests/taskdialog.c
@@ -373,6 +373,72 @@ static void test_timer(void)
pTaskDialogIndirect(&info, NULL, NULL, NULL);
}
+static HRESULT CALLBACK taskdialog_callback_proc_progress_bar(HWND hwnd, UINT notification, WPARAM wParam,
+ LPARAM lParam, LONG_PTR ref_data)
+{
+ unsigned long ret;
+ LONG flags = (LONG)ref_data;
+ if (notification == TDN_CREATED)
+ {
+ /* TDM_SET_PROGRESS_BAR_STATE */
+ ret = SendMessageW(hwnd, TDM_SET_PROGRESS_BAR_STATE, PBST_NORMAL, 0);
+ ok(ret == PBST_NORMAL, "Expect state: %d got state: %lx\n", PBST_NORMAL, ret);
+ ret = SendMessageW(hwnd, TDM_SET_PROGRESS_BAR_STATE, PBST_PAUSED, 0);
+ ok(ret == PBST_NORMAL, "Expect state: %d got state: %lx\n", PBST_NORMAL, ret);
+ ret = SendMessageW(hwnd, TDM_SET_PROGRESS_BAR_STATE, PBST_ERROR, 0);
+ /* Progress bar has fixme on handling PBM_SETSTATE message */
+ todo_wine ok(ret == PBST_PAUSED, "Expect state: %d got state: %lx\n", PBST_PAUSED, ret);
+ ret = SendMessageW(hwnd, TDM_SET_PROGRESS_BAR_STATE, PBST_NORMAL, 0);
+ todo_wine ok(ret == PBST_ERROR, "Expect state: %d got state: %lx\n", PBST_ERROR, ret);
+
+ /* TDM_SET_PROGRESS_BAR_RANGE */
+ ret = SendMessageW(hwnd, TDM_SET_PROGRESS_BAR_RANGE, 0, MAKELPARAM(0, 200));
+ ok(ret == MAKELONG(0, 100), "Expect range:%x got:%lx\n", MAKELONG(0, 100), ret);
+ ret = SendMessageW(hwnd, TDM_SET_PROGRESS_BAR_RANGE, 0, MAKELPARAM(0, 200));
+ ok(ret == MAKELONG(0, 200), "Expect range:%x got:%lx\n", MAKELONG(0, 200), ret);
+
+ /* TDM_SET_PROGRESS_BAR_POS */
+ if (flags & TDF_SHOW_MARQUEE_PROGRESS_BAR)
+ {
+ ret = SendMessageW(hwnd, TDM_SET_PROGRESS_BAR_POS, 1, 0);
+ ok(ret == 0, "Expect position:%x got:%lx\n", 0, ret);
+ ret = SendMessageW(hwnd, TDM_SET_PROGRESS_BAR_POS, 2, 0);
+ ok(ret == 0, "Expect position:%x got:%lx\n", 0, ret);
+ }
+ else
+ {
+ ret = SendMessageW(hwnd, TDM_SET_PROGRESS_BAR_POS, 1, 0);
+ ok(ret == 0, "Expect position:%x got:%lx\n", 0, ret);
+ ret = SendMessageW(hwnd, TDM_SET_PROGRESS_BAR_POS, 2, 0);
+ ok(ret == 1, "Expect position:%x got:%lx\n", 1, ret);
+ }
+
+ SendMessageW(hwnd, TDM_CLICK_BUTTON, IDOK, 0);
+ }
+
+ return S_OK;
+}
+
+static void test_progress_bar(void)
+{
+ TASKDIALOGCONFIG info = {0};
+
+ info.cbSize = sizeof(TASKDIALOGCONFIG);
+ info.dwFlags = TDF_SHOW_PROGRESS_BAR;
+ info.pfCallback = taskdialog_callback_proc_progress_bar;
+ info.lpCallbackData = (LONG_PTR)info.dwFlags;
+ info.dwCommonButtons = TDCBF_OK_BUTTON;
+ pTaskDialogIndirect(&info, NULL, NULL, NULL);
+
+ info.dwFlags = TDF_SHOW_MARQUEE_PROGRESS_BAR;
+ info.lpCallbackData = (LONG_PTR)info.dwFlags;
+ pTaskDialogIndirect(&info, NULL, NULL, NULL);
+
+ info.dwFlags = TDF_SHOW_PROGRESS_BAR | TDF_SHOW_MARQUEE_PROGRESS_BAR;
+ info.lpCallbackData = (LONG_PTR)info.dwFlags;
+ pTaskDialogIndirect(&info, NULL, NULL, NULL);
+}
+
START_TEST(taskdialog)
{
ULONG_PTR ctx_cookie;
@@ -411,6 +477,7 @@ START_TEST(taskdialog)
test_buttons();
test_help();
test_timer();
+ test_progress_bar();
unload_v6_module(ctx_cookie, hCtx);
}
--
2.17.1
June 15, 2018
Re: [PATCH] urlmon/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=39144
Your paranoid android.
=== wvistau64 (64 bit url) ===
url.c:1877: Test failed: binding failed: 800c0006, expected 00000000
url.c:1888: Test failed: res = 00002f4f, expected 00000000
url.c:3190: Test failed: expected OnProgress_SENDINGREQUEST
url.c:3198: Test failed: expected OnProgress_MIMETYPEAVAILABLE
url.c:3199: Test failed: expected OnProgress_BEGINDOWNLOADDATA
url.c:3200: Test failed: expected OnProgress_ENDDOWNLOADDATA
url.c:3212: Test failed: expected OnDataAvailable
=== w7pro64 (64 bit url) ===
url.c:3680: Test failed: CreateFile failed
url.c:1550: Test failed: unexpected call QueryInterface_IWindowForBindingUI
url.c:1420: Test failed: unexpected call QueryService_IWindowForBindingUI
url.c:1350: Test failed: unexpected call GetWindow_ICodeInstall
url.c:1877: Test failed: binding failed: 80040154, expected 00000000
url.c:3430: Test failed: expected Obj_OnProgress_CLASSIDAVAILABLE
url.c:3439: Test failed: expected OnObjectAvailable
June 14, 2018
[PATCH] winex11.drv: Correct compile without vulkan support
by Alistair Leslie-Hughes
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/winex11.drv/vulkan.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/dlls/winex11.drv/vulkan.c b/dlls/winex11.drv/vulkan.c
index 7eca31b..fdb858d 100644
--- a/dlls/winex11.drv/vulkan.c
+++ b/dlls/winex11.drv/vulkan.c
@@ -626,4 +626,8 @@ const struct vulkan_funcs *get_vulkan_driver(UINT version)
return NULL;
}
+void wine_vk_surface_destroy(HWND hwnd)
+{
+}
+
#endif /* SONAME_LIBVULKAN */
--
1.9.1
June 14, 2018
Re: [PATCH] shell32/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=39142
Your paranoid android.
=== wvistau64_zh_CN (32 bit shlexec) ===
shlexec.c:2501: Test failed: ShellExecuteEx(mask="0x8540", file="C:\Users\winetest\AppData\Local\Temp\wt39B5.tmp\test file.sde") Assoc class="shlexec.sde", verb="Open", rawcmd="0", cmdtail="", ddeexec="[open("%1")]", app="shlexec", topic="dde" failed: rc=2 err=2
shlexec.c:2501: Test failed: ShellExecuteEx(mask="0x8540", file="C:\Users\winetest\AppData\Local\Temp\wt39B5.tmp\test file.sde") Assoc class="shlexec.sde", verb="Open", rawcmd="0", cmdtail=""%1"", ddeexec="[open("%1")]", app="shlexec", topic="dde" failed: rc=2 err=2
June 14, 2018
[PATCH] d3dx9/tests: Add initial tests for ID3DXFont::DrawText().
by Matteo Bruni
From: Kieran Duggan <kieranduggan15(a)gmail.com>
Signed-off-by: Kieran Duggan <kieranduggan15(a)gmail.com>
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
---
dlls/d3dx9_36/tests/core.c | 81 +++++++++++++++++++++++++++++++++++-----------
1 file changed, 62 insertions(+), 19 deletions(-)
diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c
index 75d33c1e0dc..3ed25f8176b 100644
--- a/dlls/d3dx9_36/tests/core.c
+++ b/dlls/d3dx9_36/tests/core.c
@@ -305,23 +305,28 @@ static void test_ID3DXSprite(IDirect3DDevice9 *device)
static void test_ID3DXFont(IDirect3DDevice9 *device)
{
- D3DXFONT_DESCA desc;
- ID3DXFont *font;
- HRESULT hr;
- int ref;
- int i;
- static const struct {
- INT font_height;
- UINT expected_size;
- DWORD expected_levels;
- } texture_tests[] = {
+ static const WCHAR testW[] = {'t','e','s','t',0};
+ static const struct
+ {
+ int font_height;
+ unsigned int expected_size;
+ unsigned int expected_levels;
+ }
+ tests[] =
+ {
{ 6, 128, 4 },
{ 8, 128, 4 },
{ 10, 256, 5 },
{ 12, 256, 5 },
- { 72, 256, 8 }
+ { 72, 256, 8 },
};
-
+ const unsigned int size = ARRAY_SIZE(testW);
+ D3DXFONT_DESCA desc;
+ ID3DXSprite *sprite;
+ int ref, i, height;
+ ID3DXFont *font;
+ HRESULT hr;
+ RECT rect;
/* D3DXCreateFont */
ref = get_ref((IUnknown*)device);
@@ -463,8 +468,6 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
/* ID3DXFont_PreloadText */
hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font);
if(SUCCEEDED(hr)) {
- const WCHAR testW[] = {'t','e','s','t',0};
-
todo_wine {
hr = ID3DXFont_PreloadTextA(font, NULL, -1);
ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
@@ -552,7 +555,8 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
check_release((IUnknown*)font, 0);
} else skip("Failed to create a ID3DXFont object\n");
- for(i = 0; i < ARRAY_SIZE(texture_tests); i++) {
+ for (i = 0; i < ARRAY_SIZE(tests); ++i)
+ {
HDC hdc;
DWORD ret;
HRESULT hr;
@@ -560,7 +564,8 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
char c = 'a';
IDirect3DTexture9 *texture;
- hr = D3DXCreateFontA(device, texture_tests[i].font_height, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font);
+ hr = D3DXCreateFontA(device, tests[i].font_height, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET,
+ OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font);
if(FAILED(hr)) {
skip("Failed to create a ID3DXFont object\n");
continue;
@@ -578,17 +583,55 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
D3DSURFACE_DESC desc;
levels = IDirect3DTexture9_GetLevelCount(texture);
- ok(levels == texture_tests[i].expected_levels, "Got levels %u, expected %u\n", levels, texture_tests[i].expected_levels);
+ ok(levels == tests[i].expected_levels, "Got levels %u, expected %u\n",
+ levels, tests[i].expected_levels);
hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc);
ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc failed\n");
ok(desc.Format == D3DFMT_A8R8G8B8, "Got format %#x, expected %#x\n", desc.Format, D3DFMT_A8R8G8B8);
ok(desc.Usage == 0, "Got usage %#x, expected %#x\n", desc.Usage, 0);
- ok(desc.Width == texture_tests[i].expected_size, "Got width %u, expected %u\n", desc.Width, texture_tests[i].expected_size);
- ok(desc.Height == texture_tests[i].expected_size, "Got height %u, expected %u\n", desc.Height, texture_tests[i].expected_size);
+ ok(desc.Width == tests[i].expected_size, "Got width %u, expected %u\n",
+ desc.Width, tests[i].expected_size);
+ ok(desc.Height == tests[i].expected_size, "Got height %u, expected %u\n",
+ desc.Height, tests[i].expected_size);
ok(desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected %u\n", desc.Pool, D3DPOOL_MANAGED);
IDirect3DTexture9_Release(texture);
}
+
+ /* ID3DXFontImpl_DrawText */
+ D3DXCreateSprite(device, &sprite);
+ SetRect(&rect, 0, 0, 640, 480);
+
+ IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0);
+
+ IDirect3DDevice9_BeginScene(device);
+ hr = ID3DXSprite_Begin(sprite, D3DXSPRITE_ALPHABLEND);
+ ok (hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ height = ID3DXFont_DrawTextW(font, sprite, testW, -1, &rect, DT_TOP, 0xffffffff);
+ ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+ height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_TOP, 0xffffffff);
+ ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+ height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_RIGHT, 0xffffffff);
+ ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+ height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_LEFT | DT_NOCLIP,
+ 0xffffffff);
+ ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+
+ SetRect(&rect, 0, 0, 0, 0);
+ height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect,
+ DT_LEFT | DT_CALCRECT, 0xffffffff);
+ ok(height == tests[i].font_height, "Got unexpected height %u.\n", height);
+ ok(!rect.left, "Got unexpected rect left %d.\n", rect.left);
+ ok(!rect.top, "Got unexpected rect top %d.\n", rect.top);
+ ok(rect.right, "Got unexpected rect right %d.\n", rect.right);
+ ok(rect.bottom == tests[i].font_height, "Got unexpected rect bottom %d.\n", rect.bottom);
+
+ hr = ID3DXSprite_End(sprite);
+ ok (hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ IDirect3DDevice9_EndScene(device);
+ ID3DXSprite_Release(sprite);
+
ID3DXFont_Release(font);
}
}
--
2.16.1
June 14, 2018
[PATCH] urlmon/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/urlmon/tests/misc.c | 66 +++++++++++++++++---------------------
dlls/urlmon/tests/protocol.c | 26 +++++++--------
dlls/urlmon/tests/sec_mgr.c | 20 ++++++------
dlls/urlmon/tests/uri.c | 76 ++++++++++++++++++++++----------------------
dlls/urlmon/tests/url.c | 2 +-
5 files changed, 91 insertions(+), 99 deletions(-)
diff --git a/dlls/urlmon/tests/misc.c b/dlls/urlmon/tests/misc.c
index e88c960497..ff0f24ed76 100644
--- a/dlls/urlmon/tests/misc.c
+++ b/dlls/urlmon/tests/misc.c
@@ -85,7 +85,7 @@ static HRESULT (WINAPI *pIEInstallScope)(DWORD*);
static int strcmp_wa(const WCHAR *strw, const char *stra)
{
WCHAR buf[512];
- MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, sizeof(buf)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, stra, -1, buf, ARRAY_SIZE(buf));
return lstrcmpW(strw, buf);
}
@@ -367,23 +367,23 @@ static void test_CoInternetParseUrl(void)
3, &size, 0);
ok(hres == E_POINTER, "schema failed: %08x, expected E_POINTER\n", hres);
- for(i=0; i < sizeof(parse_tests)/sizeof(parse_tests[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(parse_tests); i++) {
memset(buf, 0xf0, sizeof(buf));
hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_SECURITY_URL, 0, buf,
- sizeof(buf)/sizeof(WCHAR), &size, 0);
+ ARRAY_SIZE(buf), &size, 0);
ok(hres == parse_tests[i].secur_hres, "[%d] security url failed: %08x, expected %08x\n",
i, hres, parse_tests[i].secur_hres);
memset(buf, 0xf0, sizeof(buf));
hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_ENCODE, 0, buf,
- sizeof(buf)/sizeof(WCHAR), &size, 0);
+ ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "[%d] encoding failed: %08x\n", i, hres);
ok(size == lstrlenW(parse_tests[i].encoded_url), "[%d] wrong size\n", i);
ok(!lstrcmpW(parse_tests[i].encoded_url, buf), "[%d] wrong encoded url\n", i);
memset(buf, 0xf0, sizeof(buf));
hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_PATH_FROM_URL, 0, buf,
- sizeof(buf)/sizeof(WCHAR), &size, 0);
+ ARRAY_SIZE(buf), &size, 0);
ok(hres == parse_tests[i].path_hres, "[%d] path failed: %08x, expected %08x\n",
i, hres, parse_tests[i].path_hres);
if(parse_tests[i].path) {
@@ -393,7 +393,7 @@ static void test_CoInternetParseUrl(void)
memset(buf, 0xf0, sizeof(buf));
hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_SCHEMA, 0, buf,
- sizeof(buf)/sizeof(WCHAR), &size, 0);
+ ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "[%d] schema failed: %08x\n", i, hres);
ok(size == lstrlenW(parse_tests[i].schema), "[%d] wrong size\n", i);
ok(!lstrcmpW(parse_tests[i].schema, buf), "[%d] wrong schema\n", i);
@@ -402,7 +402,7 @@ static void test_CoInternetParseUrl(void)
&& memcmp(parse_tests[i].url, wszAbout, 5*sizeof(WCHAR))) {
memset(buf, 0xf0, sizeof(buf));
hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_DOMAIN, 0, buf,
- sizeof(buf)/sizeof(WCHAR), &size, 0);
+ ARRAY_SIZE(buf), &size, 0);
ok(hres == parse_tests[i].domain_hres, "[%d] domain failed: %08x\n", i, hres);
if(parse_tests[i].domain)
ok(!lstrcmpW(parse_tests[i].domain, buf), "[%d] wrong domain, received %s\n", i, wine_dbgstr_w(buf));
@@ -410,7 +410,7 @@ static void test_CoInternetParseUrl(void)
memset(buf, 0xf0, sizeof(buf));
hres = pCoInternetParseUrl(parse_tests[i].url, PARSE_ROOTDOCUMENT, 0, buf,
- sizeof(buf)/sizeof(WCHAR), &size, 0);
+ ARRAY_SIZE(buf), &size, 0);
ok(hres == parse_tests[i].rootdocument_hres, "[%d] rootdocument failed: %08x\n", i, hres);
if(parse_tests[i].rootdocument)
ok(!lstrcmpW(parse_tests[i].rootdocument, buf), "[%d] wrong rootdocument, received %s\n", i, wine_dbgstr_w(buf));
@@ -451,7 +451,7 @@ static void test_CoInternetQueryInfo(void)
DWORD cb, i;
HRESULT hres;
- for(i=0; i < sizeof(query_info_tests)/sizeof(query_info_tests[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(query_info_tests); i++) {
cb = 0xdeadbeef;
memset(buf, '?', sizeof(buf));
hres = pCoInternetQueryInfo(query_info_tests[0].url, QUERY_USES_NETWORK, 0, buf, sizeof(buf), &cb, 0);
@@ -724,7 +724,7 @@ static void test_FindMimeFromData(void)
static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
static const WCHAR text_plainW[] = {'t','e','x','t','/','p','l','a','i','n',0};
- for(i=0; i<sizeof(mime_tests)/sizeof(mime_tests[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(mime_tests); i++) {
mime = (LPWSTR)0xf0f0f0f0;
url = a2w(mime_tests[i].url);
hres = pFindMimeFromData(NULL, url, NULL, 0, NULL, 0, &mime, 0);
@@ -757,7 +757,7 @@ static void test_FindMimeFromData(void)
heap_free(url);
}
- for(i=0; i < sizeof(mime_tests2)/sizeof(mime_tests2[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(mime_tests2); i++) {
url = a2w(mime_tests2[i].url);
proposed_mime = a2w(mime_tests2[i].proposed_mime);
hres = pFindMimeFromData(NULL, url, mime_tests2[i].data, mime_tests2[i].size,
@@ -879,9 +879,9 @@ static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface
if(ParseAction == PARSE_SECURITY_URL) {
if(pcchResult)
- *pcchResult = sizeof(url1)/sizeof(WCHAR);
+ *pcchResult = ARRAY_SIZE(url1);
- if(cchResult<sizeof(url1)/sizeof(WCHAR))
+ if(cchResult < ARRAY_SIZE(url1))
return S_FALSE;
memcpy(pwzResult, url1, sizeof(url1));
@@ -1032,8 +1032,7 @@ static void test_NameSpace(void)
SET_EXPECT(CreateInstance);
SET_EXPECT(ParseUrl);
- hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
- &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
CHECK_CALLED(QI_IInternetProtocolInfo);
@@ -1044,8 +1043,7 @@ static void test_NameSpace(void)
SET_EXPECT(QI_IInternetProtocolInfo);
SET_EXPECT(ParseUrl);
- hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
- &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
CHECK_CALLED(QI_IInternetProtocolInfo);
@@ -1054,11 +1052,10 @@ static void test_NameSpace(void)
SET_EXPECT(QI_IInternetProtocolInfo);
SET_EXPECT(ParseUrl);
- hres = pCoInternetParseUrl(url8, PARSE_SECURITY_URL, 0, buf,
- sizeof(buf)/sizeof(WCHAR), &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_SECURITY_URL, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
- ok(size == sizeof(url1)/sizeof(WCHAR), "Size = %d\n", size);
- if(size == sizeof(url1)/sizeof(WCHAR))
+ ok(size == ARRAY_SIZE(url1), "Size = %d\n", size);
+ if(size == ARRAY_SIZE(url1))
ok(!memcmp(buf, url1, sizeof(url1)), "Encoded url = %s\n", wine_dbgstr_w(buf));
CHECK_CALLED(QI_IInternetProtocolInfo);
@@ -1071,7 +1068,7 @@ static void test_NameSpace(void)
hres = pCoInternetGetSecurityUrl(url8, &sec_url, PSU_SECURITY_URL_ONLY, 0);
ok(hres == S_OK, "CoInternetGetSecurityUrl failed: %08x\n", hres);
if(hres == S_OK) {
- ok(lstrlenW(sec_url)>sizeof(wszFile)/sizeof(WCHAR) &&
+ ok(lstrlenW(sec_url) > ARRAY_SIZE(wszFile) &&
!memcmp(sec_url, wszFile, sizeof(wszFile)-sizeof(WCHAR)),
"Encoded url = %s\n", wine_dbgstr_w(sec_url));
CoTaskMemFree(sec_url);
@@ -1084,8 +1081,7 @@ static void test_NameSpace(void)
hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf, wszTest);
ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
- hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
- &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
hres = IInternetSession_RegisterNameSpace(session, &test_protocol_cf2, &IID_NULL,
@@ -1103,8 +1099,7 @@ static void test_NameSpace(void)
SET_EXPECT(QI_IInternetProtocolInfo);
SET_EXPECT(ParseUrl);
- hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
- &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
CHECK_CALLED(QI_IInternetProtocolInfo);
@@ -1116,8 +1111,7 @@ static void test_NameSpace(void)
SET_EXPECT(QI_IInternetProtocolInfo);
SET_EXPECT(ParseUrl);
- hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
- &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
CHECK_CALLED(QI_IInternetProtocolInfo);
@@ -1130,8 +1124,7 @@ static void test_NameSpace(void)
SET_EXPECT(QI_IInternetProtocolInfo);
SET_EXPECT(ParseUrl);
- hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
- &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
CHECK_CALLED(QI_IInternetProtocolInfo);
@@ -1149,8 +1142,7 @@ static void test_NameSpace(void)
hres = IInternetSession_UnregisterNameSpace(session, &test_protocol_cf2, wszTest);
ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
- hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, sizeof(buf)/sizeof(WCHAR),
- &size, 0);
+ hres = pCoInternetParseUrl(url8, PARSE_ENCODE, 0, buf, ARRAY_SIZE(buf), &size, 0);
ok(hres == S_OK, "CoInternetParseUrl failed: %08x\n", hres);
IInternetSession_Release(session);
@@ -1627,7 +1619,7 @@ static void test_MkParseDisplayNameEx(void)
CreateBindCtx(0, &bctx);
- for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{
eaten = 0xdeadbeef;
mon = (IMoniker *)0xdeadbeef;
@@ -1643,7 +1635,7 @@ static void test_MkParseDisplayNameEx(void)
hres = MkParseDisplayNameEx(bctx, url9, &eaten, &mon);
ok(hres == S_OK, "MkParseDisplayNameEx failed: %08x\n", hres);
- ok(eaten == sizeof(url9)/sizeof(WCHAR)-1, "eaten=%d\n", eaten);
+ ok(eaten == ARRAY_SIZE(url9)-1, "eaten=%d\n", eaten);
ok(mon != NULL, "mon == NULL\n");
hres = IMoniker_GetDisplayName(mon, NULL, 0, &name);
@@ -1659,7 +1651,7 @@ static void test_MkParseDisplayNameEx(void)
hres = MkParseDisplayNameEx(bctx, clsid_nameW, &eaten, &mon);
ok(hres == S_OK, "MkParseDisplayNameEx failed: %08x\n", hres);
- ok(eaten == sizeof(clsid_nameW)/sizeof(WCHAR)-1, "eaten=%d\n", eaten);
+ ok(eaten == ARRAY_SIZE(clsid_nameW)-1, "eaten=%d\n", eaten);
ok(mon != NULL, "mon == NULL\n");
hres = IMoniker_IsSystemMoniker(mon, &issys);
@@ -1733,7 +1725,7 @@ static void test_internet_feature_defaults(void) {
HRESULT hres;
DWORD i;
- for(i = 0; i < sizeof(default_feature_tests)/sizeof(default_feature_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(default_feature_tests); ++i) {
hres = pCoInternetIsFeatureEnabled(default_feature_tests[i].feature, default_feature_tests[i].get_flags);
todo_wine_if (default_feature_tests[i].todo)
ok(hres == default_feature_tests[i].expected, "CoInternetIsFeatureEnabled returned %08x, expected %08x on test %d\n",
@@ -1880,7 +1872,7 @@ static void test_CoInternetSetFeatureEnabled(void) {
hres = pCoInternetSetFeatureEnabled(FEATURE_ENTRY_COUNT,SET_FEATURE_ON_PROCESS,TRUE);
ok(hres == E_FAIL, "CoInternetSetFeatureEnabled returned %08x, expected E_FAIL\n", hres);
- for(i = 0; i < sizeof(internet_feature_tests)/sizeof(internet_feature_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(internet_feature_tests); ++i) {
hres = pCoInternetSetFeatureEnabled(internet_feature_tests[i].feature, internet_feature_tests[i].set_flags,
internet_feature_tests[i].enable);
todo_wine_if (internet_feature_tests[i].set_todo)
diff --git a/dlls/urlmon/tests/protocol.c b/dlls/urlmon/tests/protocol.c
index 0ca8feebcb..999b591f5f 100644
--- a/dlls/urlmon/tests/protocol.c
+++ b/dlls/urlmon/tests/protocol.c
@@ -824,7 +824,7 @@ static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface,
if (winetest_debug > 1)
{
- if (ulStatusCode < sizeof(status_names)/sizeof(status_names[0]))
+ if (ulStatusCode < ARRAY_SIZE(status_names))
trace( "progress: %s %s\n", status_names[ulStatusCode], wine_dbgstr_w(szStatusText) );
else
trace( "progress: %u %s\n", ulStatusCode, wine_dbgstr_w(szStatusText) );
@@ -3051,55 +3051,55 @@ static void test_file_protocol(void) {
test_file_protocol_url(index_url);
memcpy(buf, wszFile, sizeof(wszFile));
- len = sizeof(wszFile)/sizeof(WCHAR)-1;
- len += GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR)-len, buf+len);
+ len = ARRAY_SIZE(wszFile)-1;
+ len += GetCurrentDirectoryW(ARRAY_SIZE(buf)-len, buf+len);
buf[len++] = '\\';
memcpy(buf+len, wszIndexHtml, sizeof(wszIndexHtml));
- file_name = buf + sizeof(wszFile)/sizeof(WCHAR)-1;
+ file_name = buf + ARRAY_SIZE(wszFile)-1;
bindf = 0;
test_file_protocol_url(buf);
bindf = BINDF_FROMURLMON;
test_file_protocol_url(buf);
memcpy(buf, wszFile2, sizeof(wszFile2));
- len = GetCurrentDirectoryW(sizeof(file_name_buf)/sizeof(WCHAR), file_name_buf);
+ len = GetCurrentDirectoryW(ARRAY_SIZE(file_name_buf), file_name_buf);
file_name_buf[len++] = '\\';
memcpy(file_name_buf+len, wszIndexHtml, sizeof(wszIndexHtml));
- lstrcpyW(buf+sizeof(wszFile2)/sizeof(WCHAR)-1, file_name_buf);
+ lstrcpyW(buf+ARRAY_SIZE(wszFile2)-1, file_name_buf);
file_name = file_name_buf;
bindf = 0;
test_file_protocol_url(buf);
bindf = BINDF_FROMURLMON;
test_file_protocol_url(buf);
- buf[sizeof(wszFile2)/sizeof(WCHAR)] = '|';
+ buf[ARRAY_SIZE(wszFile2)] = '|';
test_file_protocol_url(buf);
memcpy(buf, wszFile3, sizeof(wszFile3));
- len = sizeof(wszFile3)/sizeof(WCHAR)-1;
- len += GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR)-len, buf+len);
+ len = ARRAY_SIZE(wszFile3)-1;
+ len += GetCurrentDirectoryW(ARRAY_SIZE(buf)-len, buf+len);
buf[len++] = '\\';
memcpy(buf+len, wszIndexHtml, sizeof(wszIndexHtml));
- file_name = buf + sizeof(wszFile3)/sizeof(WCHAR)-1;
+ file_name = buf + ARRAY_SIZE(wszFile3)-1;
bindf = 0;
test_file_protocol_url(buf);
bindf = BINDF_FROMURLMON;
test_file_protocol_url(buf);
memcpy(buf, wszFile4, sizeof(wszFile4));
- len = GetCurrentDirectoryW(sizeof(file_name_buf)/sizeof(WCHAR), file_name_buf);
+ len = GetCurrentDirectoryW(ARRAY_SIZE(file_name_buf), file_name_buf);
file_name_buf[len++] = '\\';
memcpy(file_name_buf+len, wszIndexHtml, sizeof(wszIndexHtml));
- lstrcpyW(buf+sizeof(wszFile4)/sizeof(WCHAR)-1, file_name_buf);
+ lstrcpyW(buf+ARRAY_SIZE(wszFile4)-1, file_name_buf);
file_name = file_name_buf;
bindf = 0;
test_file_protocol_url(buf);
bindf = BINDF_FROMURLMON;
test_file_protocol_url(buf);
- buf[sizeof(wszFile4)/sizeof(WCHAR)] = '|';
+ buf[ARRAY_SIZE(wszFile4)] = '|';
test_file_protocol_url(buf);
/* Fragment part of URL is skipped if the file doesn't exist. */
diff --git a/dlls/urlmon/tests/sec_mgr.c b/dlls/urlmon/tests/sec_mgr.c
index 411a3b7781..2974eecc36 100644
--- a/dlls/urlmon/tests/sec_mgr.c
+++ b/dlls/urlmon/tests/sec_mgr.c
@@ -221,7 +221,7 @@ static LONG myRegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
dwMaxSubkeyLen++;
dwMaxValueLen++;
dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
- if (dwMaxLen > sizeof(szNameBuf)/sizeof(CHAR))
+ if (dwMaxLen > ARRAY_SIZE(szNameBuf))
{
/* Name too big: alloc a buffer for it */
if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(CHAR))))
@@ -381,7 +381,7 @@ static void test_SecurityManager(void)
if(FAILED(hres))
return;
- for(i=0; i < sizeof(secmgr_tests)/sizeof(secmgr_tests[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(secmgr_tests); i++) {
zone = 100;
hres = IInternetSecurityManager_MapUrlToZone(secmgr, secmgr_tests[i].url,
&zone, 0);
@@ -785,7 +785,7 @@ static BOOL register_zone_domains(void)
res = RegOpenKeyA(HKEY_CURRENT_USER, szZoneMapDomainsKey, &domains);
ok(res == ERROR_SUCCESS, "RegOpenKey failed: %d\n", res);
- for(i = 0; i < sizeof(zone_domain_mappings)/sizeof(zone_domain_mappings[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(zone_domain_mappings); ++i) {
const zone_domain_mapping *test = zone_domain_mappings+i;
HKEY domain;
@@ -830,7 +830,7 @@ static void unregister_zone_domains(void)
res = RegOpenKeyA(HKEY_CURRENT_USER, szZoneMapDomainsKey, &domains);
ok(res == ERROR_SUCCESS, "RegOpenKey failed: %d\n", res);
- for(i = 0; i < sizeof(zone_domain_mappings)/sizeof(zone_domain_mappings[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(zone_domain_mappings); ++i) {
const zone_domain_mapping *test = zone_domain_mappings+i;
/* FIXME: Uses the "cludge" approach to remove the test data from the registry!
@@ -936,7 +936,7 @@ static void test_zone_domain_mappings(void)
RegCloseKey(domains);
}
- for(i = 0; i < sizeof(zone_mapping_tests)/sizeof(zone_mapping_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(zone_mapping_tests); ++i) {
const zone_mapping_test *test = zone_mapping_tests+i;
LPWSTR urlW = a2w(test->url);
zone = URLZONE_INVALID;
@@ -1360,7 +1360,7 @@ static void test_InternetGetSecurityUrl(void)
trace("testing CoInternetGetSecurityUrl...\n");
- for(i=0; i<sizeof(in)/sizeof(WCHAR*); i++) {
+ for(i = 0; i < ARRAY_SIZE(in); i++) {
hres = pCoInternetGetSecurityUrl(in[i], &sec, PSU_DEFAULT, 0);
ok(hres == S_OK, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i, hres);
if(hres == S_OK) {
@@ -1625,7 +1625,7 @@ static void test_InternetGetSecurityUrlEx(void)
ok(hr == E_INVALIDARG, "CoInternetGetSecurityUrlEx returned 0x%08x, expected E_INVALIDARG\n", hr);
ok(result == (void*) 0xdeadbeef, "'result' was %p\n", result);
- for(i = 0; i < sizeof(sec_url_ex_tests)/sizeof(sec_url_ex_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(sec_url_ex_tests); ++i) {
LPWSTR uriW = a2w(sec_url_ex_tests[i].uri);
uri = NULL;
@@ -1827,7 +1827,7 @@ static void test_SecurityManagerEx2(void)
IUri_Release(uri);
- for(i = 0; i < sizeof(sec_mgr_ex2_tests)/sizeof(sec_mgr_ex2_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(sec_mgr_ex2_tests); ++i) {
LPWSTR uriW = a2w(sec_mgr_ex2_tests[i].uri);
uri = NULL;
@@ -1925,7 +1925,7 @@ static void test_CoInternetIsFeatureZoneElevationEnabled(void)
trace("Testing CoInternetIsFeatureZoneElevationEnabled... (%x)\n", hres);
- for(i=0; i<sizeof(testcases)/sizeof(testcases[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(testcases); i++) {
if(hres==S_OK && testcases[i].flags == GET_FEATURE_FROM_PROCESS)
testcases[i].policy_flags = URLPOLICY_ALLOW;
}
@@ -1940,7 +1940,7 @@ static void test_CoInternetIsFeatureZoneElevationEnabled(void)
return;
}
- for(i=0; i<sizeof(testcases)/sizeof(testcases[0]); i++) {
+ for(i = 0; i < ARRAY_SIZE(testcases); i++) {
url_from = a2w(testcases[i].url_from);
url_to = a2w(testcases[i].url_to);
diff --git a/dlls/urlmon/tests/uri.c b/dlls/urlmon/tests/uri.c
index 90f51bf5dd..7580a1302d 100644
--- a/dlls/urlmon/tests/uri.c
+++ b/dlls/urlmon/tests/uri.c
@@ -7786,7 +7786,7 @@ static void change_property(IUriBuilder *builder, const uri_builder_property *pr
static void test_CreateUri_InvalidFlags(void) {
DWORD i;
- for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(invalid_flag_tests); ++i) {
HRESULT hr;
IUri *uri = (void*) 0xdeadbeef;
@@ -7825,7 +7825,7 @@ static void test_CreateUri_InvalidArgs(void) {
static void test_CreateUri_InvalidUri(void) {
DWORD i;
- for(i = 0; i < sizeof(invalid_uri_tests)/sizeof(invalid_uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(invalid_uri_tests); ++i) {
invalid_uri test = invalid_uri_tests[i];
IUri *uri = NULL;
LPWSTR uriW;
@@ -7877,7 +7877,7 @@ static void test_IUri_GetPropertyBSTR(void) {
}
if(uri) IUri_Release(uri);
- for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); ++i) {
uri_properties test = uri_tests[i];
LPWSTR uriW;
uri = NULL;
@@ -7937,7 +7937,7 @@ static void test_IUri_GetPropertyDWORD(void) {
}
if(uri) IUri_Release(uri);
- for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); ++i) {
uri_properties test = uri_tests[i];
LPWSTR uriW;
uri = NULL;
@@ -7952,7 +7952,7 @@ static void test_IUri_GetPropertyDWORD(void) {
DWORD j;
/* Checks all the DWORD properties of the uri. */
- for(j = 0; j < sizeof(test.dword_props)/sizeof(test.dword_props[0]); ++j) {
+ for(j = 0; j < ARRAY_SIZE(test.dword_props); ++j) {
DWORD received;
uri_dword_property prop = test.dword_props[j];
@@ -8029,7 +8029,7 @@ static void test_IUri_GetStrProperties(void) {
}
if(uri) IUri_Release(uri);
- for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); ++i) {
uri_properties test = uri_tests[i];
LPWSTR uriW;
uri = NULL;
@@ -8257,7 +8257,7 @@ static void test_IUri_GetDwordProperties(void) {
}
if(uri) IUri_Release(uri);
- for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); ++i) {
uri_properties test = uri_tests[i];
LPWSTR uriW;
uri = NULL;
@@ -8343,7 +8343,7 @@ static void test_IUri_GetPropertyLength(void) {
}
if(uri) IUri_Release(uri);
- for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); ++i) {
uri_properties test = uri_tests[i];
LPWSTR uriW;
uri = NULL;
@@ -8426,7 +8426,7 @@ static void test_IUri_GetProperties(void) {
}
if(uri) IUri_Release(uri);
- for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); ++i) {
uri_properties test = uri_tests[i];
LPWSTR uriW;
uri = NULL;
@@ -8475,7 +8475,7 @@ static void test_IUri_HasProperty(void) {
}
if(uri) IUri_Release(uri);
- for(i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); ++i) {
uri_properties test = uri_tests[i];
LPWSTR uriW;
uri = NULL;
@@ -8540,7 +8540,7 @@ static void test_IUri_IsEqual(void) {
IUri_Release(uriA);
IUri_Release(uriB);
- for(i = 0; i < sizeof(equality_tests)/sizeof(equality_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(equality_tests); ++i) {
uri_equality test = equality_tests[i];
LPWSTR uriA_W, uriB_W;
@@ -8592,7 +8592,7 @@ static void test_CreateUriWithFragment_InvalidArgs(void) {
static void test_CreateUriWithFragment_InvalidFlags(void) {
DWORD i;
- for(i = 0; i < sizeof(invalid_flag_tests)/sizeof(invalid_flag_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(invalid_flag_tests); ++i) {
HRESULT hr;
IUri *uri = (void*) 0xdeadbeef;
@@ -8606,7 +8606,7 @@ static void test_CreateUriWithFragment_InvalidFlags(void) {
static void test_CreateUriWithFragment(void) {
DWORD i;
- for(i = 0; i < sizeof(uri_fragment_tests)/sizeof(uri_fragment_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_fragment_tests); ++i) {
HRESULT hr;
IUri *uri = NULL;
LPWSTR uriW, fragW;
@@ -8685,7 +8685,7 @@ static void test_IUriBuilder_CreateUri(IUriBuilder *builder, const uri_builder_t
if(SUCCEEDED(hr)) {
DWORD i;
- for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->expected_str_props); ++i) {
uri_builder_str_property prop = test->expected_str_props[i];
BSTR received = NULL;
@@ -8703,7 +8703,7 @@ static void test_IUriBuilder_CreateUri(IUriBuilder *builder, const uri_builder_t
SysFreeString(received);
}
- for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->expected_dword_props); ++i) {
uri_builder_dword_property prop = test->expected_dword_props[i];
DWORD received = -2;
@@ -8737,7 +8737,7 @@ static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_bui
if(SUCCEEDED(hr)) {
DWORD i;
- for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->expected_str_props); ++i) {
uri_builder_str_property prop = test->expected_str_props[i];
BSTR received = NULL;
@@ -8755,7 +8755,7 @@ static void test_IUriBuilder_CreateUriSimple(IUriBuilder *builder, const uri_bui
SysFreeString(received);
}
- for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->expected_dword_props); ++i) {
uri_builder_dword_property prop = test->expected_dword_props[i];
DWORD received = -2;
@@ -8790,7 +8790,7 @@ static void test_IUriBuilder_CreateUriWithFlags(IUriBuilder *builder, const uri_
if(SUCCEEDED(hr)) {
DWORD i;
- for(i = 0; i < sizeof(test->expected_str_props)/sizeof(test->expected_str_props[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->expected_str_props); ++i) {
uri_builder_str_property prop = test->expected_str_props[i];
BSTR received = NULL;
@@ -8808,7 +8808,7 @@ static void test_IUriBuilder_CreateUriWithFlags(IUriBuilder *builder, const uri_
SysFreeString(received);
}
- for(i = 0; i < sizeof(test->expected_dword_props)/sizeof(test->expected_dword_props[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->expected_dword_props); ++i) {
uri_builder_dword_property prop = test->expected_dword_props[i];
DWORD received = -2;
@@ -9051,7 +9051,7 @@ static void test_IUriBuilder_GetFragment(IUriBuilder *builder, const uri_builder
const uri_builder_property *prop = NULL;
/* Check if the property was set earlier. */
- for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->properties); ++i) {
if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_FRAGMENT)
prop = &(test->properties[i]);
}
@@ -9146,7 +9146,7 @@ static void test_IUriBuilder_GetHost(IUriBuilder *builder, const uri_builder_tes
const uri_builder_property *prop = NULL;
/* Check if the property was set earlier. */
- for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->properties); ++i) {
if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_HOST)
prop = &(test->properties[i]);
}
@@ -9241,7 +9241,7 @@ static void test_IUriBuilder_GetPassword(IUriBuilder *builder, const uri_builder
const uri_builder_property *prop = NULL;
/* Check if the property was set earlier. */
- for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->properties); ++i) {
if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PASSWORD)
prop = &(test->properties[i]);
}
@@ -9336,7 +9336,7 @@ static void test_IUriBuilder_GetPath(IUriBuilder *builder, const uri_builder_tes
const uri_builder_property *prop = NULL;
/* Check if the property was set earlier. */
- for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->properties); ++i) {
if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_PATH)
prop = &(test->properties[i]);
}
@@ -9498,7 +9498,7 @@ static void test_IUriBuilder_GetQuery(IUriBuilder *builder, const uri_builder_te
const uri_builder_property *prop = NULL;
/* Check if the property was set earlier. */
- for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->properties); ++i) {
if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_QUERY)
prop = &(test->properties[i]);
}
@@ -9593,7 +9593,7 @@ static void test_IUriBuilder_GetSchemeName(IUriBuilder *builder, const uri_build
const uri_builder_property *prop = NULL;
/* Check if the property was set earlier. */
- for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->properties); ++i) {
if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_SCHEME_NAME)
prop = &(test->properties[i]);
}
@@ -9688,7 +9688,7 @@ static void test_IUriBuilder_GetUserName(IUriBuilder *builder, const uri_builder
const uri_builder_property *prop = NULL;
/* Check if the property was set earlier. */
- for(i = 0; i < sizeof(test->properties)/sizeof(test->properties[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(test->properties); ++i) {
if(test->properties[i].change && test->properties[i].property == Uri_PROPERTY_USER_NAME)
prop = &(test->properties[i]);
}
@@ -9780,7 +9780,7 @@ static void test_IUriBuilder(void) {
IUriBuilder *builder;
DWORD i;
- for(i = 0; i < sizeof(uri_builder_tests)/sizeof(uri_builder_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_builder_tests); ++i) {
IUri *uri = NULL;
uri_builder_test test = uri_builder_tests[i];
LPWSTR uriW = NULL;
@@ -10132,7 +10132,7 @@ static void test_IUriBuilder_RemoveProperties(void) {
}
if(builder) IUriBuilder_Release(builder);
- for(i = 0; i < sizeof(uri_builder_remove_tests)/sizeof(uri_builder_remove_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_builder_remove_tests); ++i) {
uri_builder_remove_test test = uri_builder_remove_tests[i];
IUri *uri = NULL;
LPWSTR uriW;
@@ -10328,7 +10328,7 @@ static void test_CoInternetCombineIUri(void) {
if(base) IUri_Release(base);
if(relative) IUri_Release(relative);
- for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_combine_tests); ++i) {
LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
@@ -10349,7 +10349,7 @@ static void test_CoInternetCombineIUri(void) {
if(SUCCEEDED(hr)) {
DWORD j;
- for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
+ for(j = 0; j < ARRAY_SIZE(uri_combine_tests[i].str_props); ++j) {
uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
BSTR received;
@@ -10366,7 +10366,7 @@ static void test_CoInternetCombineIUri(void) {
SysFreeString(received);
}
- for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
+ for(j = 0; j < ARRAY_SIZE(uri_combine_tests[i].dword_props); ++j) {
uri_dword_property prop = uri_combine_tests[i].dword_props[j];
DWORD received;
@@ -10619,7 +10619,7 @@ static void test_CoInternetCombineUrlEx(void) {
hr, E_POINTER);
if(base) IUri_Release(base);
- for(i = 0; i < sizeof(uri_combine_tests)/sizeof(uri_combine_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_combine_tests); ++i) {
LPWSTR baseW = a2w(uri_combine_tests[i].base_uri);
hr = pCreateUri(baseW, uri_combine_tests[i].base_create_flags, 0, &base);
@@ -10636,7 +10636,7 @@ static void test_CoInternetCombineUrlEx(void) {
if(SUCCEEDED(hr)) {
DWORD j;
- for(j = 0; j < sizeof(uri_combine_tests[i].str_props)/sizeof(uri_combine_tests[i].str_props[0]); ++j) {
+ for(j = 0; j < ARRAY_SIZE(uri_combine_tests[i].str_props); ++j) {
uri_combine_str_property prop = uri_combine_tests[i].str_props[j];
BSTR received;
LPCSTR value = (prop.value_ex) ? prop.value_ex : prop.value;
@@ -10654,7 +10654,7 @@ static void test_CoInternetCombineUrlEx(void) {
SysFreeString(received);
}
- for(j = 0; j < sizeof(uri_combine_tests[i].dword_props)/sizeof(uri_combine_tests[i].dword_props[0]); ++j) {
+ for(j = 0; j < ARRAY_SIZE(uri_combine_tests[i].dword_props); ++j) {
uri_dword_property prop = uri_combine_tests[i].dword_props[j];
DWORD received;
@@ -10776,7 +10776,7 @@ static void test_CoInternetParseIUri_InvalidArgs(void) {
len = INTERNET_MAX_URL_LENGTH*2;
longurl = heap_alloc((len+1)*sizeof(WCHAR));
memcpy(longurl, http_urlW, sizeof(http_urlW));
- for(i = sizeof(http_urlW)/sizeof(WCHAR)-1; i < len; i++)
+ for(i = ARRAY_SIZE(http_urlW)-1; i < len; i++)
longurl[i] = 'x';
longurl[len] = 0;
@@ -10803,7 +10803,7 @@ static void test_CoInternetParseIUri_InvalidArgs(void) {
static void test_CoInternetParseIUri(void) {
DWORD i;
- for(i = 0; i < sizeof(uri_parse_tests)/sizeof(uri_parse_tests[0]); ++i) {
+ for(i = 0; i < ARRAY_SIZE(uri_parse_tests); ++i) {
HRESULT hr;
IUri *uri;
LPWSTR uriW;
@@ -11001,7 +11001,7 @@ static void test_CreateURLMoniker(void)
IUri *uri, *base_uri;
HRESULT hres;
- for(test = create_urlmon_tests; test < create_urlmon_tests + sizeof(create_urlmon_tests)/sizeof(*create_urlmon_tests); test++) {
+ for(test = create_urlmon_tests; test < create_urlmon_tests + ARRAY_SIZE(create_urlmon_tests); test++) {
url = a2w(test->url);
base_url = a2w(test->base_url);
@@ -11100,7 +11100,7 @@ static void test_IPersistStream(void)
props_order[Uri_PROPERTY_SCHEME_NAME] = 8;
props_order[Uri_PROPERTY_USER_NAME] = 9;
- for(i=0; i<sizeof(uri_tests)/sizeof(*uri_tests); i++) {
+ for(i = 0; i < ARRAY_SIZE(uri_tests); i++) {
const uri_properties *test = uri_tests+i;
LPWSTR uriW;
IUri *uri;
diff --git a/dlls/urlmon/tests/url.c b/dlls/urlmon/tests/url.c
index 8da0fd8256..893632fd2e 100644
--- a/dlls/urlmon/tests/url.c
+++ b/dlls/urlmon/tests/url.c
@@ -2901,7 +2901,7 @@ static void init_bind_test(int protocol, DWORD flags, DWORD t)
}
if(url_a)
- MultiByteToWideChar(CP_ACP, 0, url_a, -1, current_url, sizeof(current_url)/sizeof(*current_url));
+ MultiByteToWideChar(CP_ACP, 0, url_a, -1, current_url, ARRAY_SIZE(current_url));
test_redirect = (flags & BINDTEST_REDIRECT) != 0;
use_cache_file = (flags & BINDTEST_USE_CACHE) != 0;
--
2.14.4
June 14, 2018
[PATCH] shell32/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/shell32/tests/autocomplete.c | 4 ++--
dlls/shell32/tests/shelldispatch.c | 14 +++++++-------
dlls/shell32/tests/shelllink.c | 2 +-
dlls/shell32/tests/shellole.c | 2 +-
dlls/shell32/tests/shellpath.c | 4 ++--
dlls/shell32/tests/shlexec.c | 14 +++++++-------
dlls/shell32/tests/string.c | 8 ++++----
7 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/dlls/shell32/tests/autocomplete.c b/dlls/shell32/tests/autocomplete.c
index 859734ce59..1c51e5179f 100644
--- a/dlls/shell32/tests/autocomplete.c
+++ b/dlls/shell32/tests/autocomplete.c
@@ -369,7 +369,7 @@ static void test_custom_source(void)
hr = CoCreateInstance(&CLSID_AutoComplete, NULL, CLSCTX_INPROC_SERVER, &IID_IAutoComplete2, (void**)&autocomplete);
ok(hr == S_OK, "CoCreateInstance failed: %x\n", hr);
- string_enumerator_create((void**)&enumerator, suggestions, sizeof(suggestions) / sizeof(*suggestions));
+ string_enumerator_create((void**)&enumerator, suggestions, ARRAY_SIZE(suggestions));
hr = IAutoComplete2_SetOptions(autocomplete, ACO_AUTOSUGGEST | ACO_AUTOAPPEND);
ok(hr == S_OK, "IAutoComplete2_SetOptions failed: %x\n", hr);
@@ -385,7 +385,7 @@ static void test_custom_source(void)
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
- SendMessageW(hwnd_edit, WM_GETTEXT, sizeof(buffer) / sizeof(*buffer), (LPARAM)buffer);
+ SendMessageW(hwnd_edit, WM_GETTEXT, ARRAY_SIZE(buffer), (LPARAM)buffer);
ok(lstrcmpW(str_beta, buffer) == 0, "Expected %s, got %s\n", wine_dbgstr_w(str_beta), wine_dbgstr_w(buffer));
ShowWindow(hMainWnd, SW_HIDE);
diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c
index ed109a9e17..30c8291f58 100644
--- a/dlls/shell32/tests/shelldispatch.c
+++ b/dlls/shell32/tests/shelldispatch.c
@@ -161,7 +161,7 @@ static void test_namespace(void)
ok(folder == NULL, "expected NULL, got %p\n", folder);
/* test valid folder ids */
- for (i = 0; i < sizeof(special_folders)/sizeof(special_folders[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(special_folders); i++)
{
V_VT(&var) = VT_I4;
V_I4(&var) = special_folders[i];
@@ -474,7 +474,7 @@ static void test_items(void)
ok(!item, "item is not null\n");
/* create test files */
- for (i = 0; i < sizeof(file_defs)/sizeof(file_defs[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(file_defs); i++)
{
switch (file_defs[i].type)
{
@@ -605,7 +605,7 @@ static void test_items(void)
V_VT(&int_index) = VT_I4;
/* test the folder item corresponding to each file */
- for (i = 0; i < sizeof(file_defs)/sizeof(file_defs[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(file_defs); i++)
{
VARIANT_BOOL b;
BSTR name;
@@ -729,7 +729,7 @@ static void test_items(void)
}
/* test that there are only as many folder items as there were files */
- V_I4(&int_index) = sizeof(file_defs)/sizeof(file_defs[0]);
+ V_I4(&int_index) = ARRAY_SIZE(file_defs);
item = (FolderItem*)0xdeadbeef;
r = FolderItems_Item(items, int_index, &item);
ok(r == S_FALSE, "expected S_FALSE, got %08x\n", r);
@@ -975,7 +975,7 @@ if (0) /* crashes on pre-vista */ {
IShellView_Release(view);
/* Try with some other folder, that's not a desktop */
- GetTempPathW(sizeof(pathW)/sizeof(pathW[0]), pathW);
+ GetTempPathW(ARRAY_SIZE(pathW), pathW);
hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL, pathW, NULL, &pidl, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -1218,7 +1218,7 @@ static void test_ParseName(void)
&IID_IShellDispatch, (void**)&sd);
ok(hr == S_OK, "got 0x%08x\n", hr);
- GetTempPathW(sizeof(pathW)/sizeof(pathW[0]), pathW);
+ GetTempPathW(ARRAY_SIZE(pathW), pathW);
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = SysAllocString(pathW);
hr = IShellDispatch_NameSpace(sd, v, &folder);
@@ -1287,7 +1287,7 @@ static void test_Verbs(void)
&IID_IShellDispatch, (void**)&sd);
ok(hr == S_OK, "got 0x%08x\n", hr);
- GetTempPathW(sizeof(pathW)/sizeof(pathW[0]), pathW);
+ GetTempPathW(ARRAY_SIZE(pathW), pathW);
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = SysAllocString(pathW);
hr = IShellDispatch_NameSpace(sd, v, &folder);
diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c
index 1e07090dc4..65e9a6dd55 100644
--- a/dlls/shell32/tests/shelllink.c
+++ b/dlls/shell32/tests/shelllink.c
@@ -1287,7 +1287,7 @@ if (0)
ok(hicon == NULL, "Got icon %p\n", hicon);
/* Create a temporary non-executable file */
- GetTempPathW(sizeof(pathW)/sizeof(pathW[0]), pathW);
+ GetTempPathW(ARRAY_SIZE(pathW), pathW);
lstrcatW(pathW, nameW);
file = CreateFileW(pathW, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
ok(file != INVALID_HANDLE_VALUE, "Failed to create a test file\n");
diff --git a/dlls/shell32/tests/shellole.c b/dlls/shell32/tests/shellole.c
index 4144f18155..4b91302a15 100644
--- a/dlls/shell32/tests/shellole.c
+++ b/dlls/shell32/tests/shellole.c
@@ -869,7 +869,7 @@ static void test_SHCreateSessionKey(void)
HKEY hkey, hkey2;
HRESULT hr;
DWORD session;
- WCHAR sessionW[(sizeof(session_format)/sizeof(WCHAR)) + 16];
+ WCHAR sessionW[ARRAY_SIZE(session_format) + 16];
LONG ret;
if (!pSHCreateSessionKey)
diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c
index 613c4eb15d..505da2778e 100644
--- a/dlls/shell32/tests/shellpath.c
+++ b/dlls/shell32/tests/shellpath.c
@@ -114,7 +114,7 @@ static const BYTE printersType[] = { PT_YAGUID, PT_SHELLEXT, 0x71 };
static const BYTE ieSpecialType[] = { PT_IESPECIAL2 };
static const BYTE shellExtType[] = { PT_SHELLEXT };
static const BYTE workgroupType[] = { PT_WORKGRP };
-#define DECLARE_TYPE(x, y) { x, sizeof(y) / sizeof(y[0]), y }
+#define DECLARE_TYPE(x, y) { x, ARRAY_SIZE(y), y }
static const struct shellExpectedValues requiredShellValues[] = {
DECLARE_TYPE(CSIDL_BITBUCKET, guidType),
DECLARE_TYPE(CSIDL_CONTROLS, controlPanelType),
@@ -2545,7 +2545,7 @@ static void test_DoEnvironmentSubst(void)
"%HOMEDRIVE%%HOMEPATH%",
"%OS% %windir%"}; /* always the last entry in the table */
- for (i = 0; i < (sizeof(names)/sizeof(LPSTR)); i++)
+ for (i = 0; i < (ARRAY_SIZE(names)); i++)
{
memset(bufferA, '#', MAX_PATH - 1);
bufferA[MAX_PATH - 1] = 0;
diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index 7cdae878db..c67cc46a46 100644
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -758,7 +758,7 @@ static LSTATUS myRegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
dwMaxSubkeyLen++;
dwMaxValueLen++;
dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
- if (dwMaxLen > sizeof(szNameBuf)/sizeof(CHAR))
+ if (dwMaxLen > ARRAY_SIZE(szNameBuf))
{
/* Name too big: alloc a buffer for it */
if (!(lpszName = heap_alloc(dwMaxLen*sizeof(CHAR))))
@@ -1329,7 +1329,7 @@ static BOOL test_one_cmdline(const cmdline_tests_t* test)
int i, count;
/* trace("----- cmd='%s'\n", test->cmd); */
- MultiByteToWideChar(CP_ACP, 0, test->cmd, -1, cmdW, sizeof(cmdW)/sizeof(*cmdW));
+ MultiByteToWideChar(CP_ACP, 0, test->cmd, -1, cmdW, ARRAY_SIZE(cmdW));
argsW = cl2a = CommandLineToArgvW(cmdW, &cl2a_count);
if (argsW == NULL && cl2a_count == -1)
{
@@ -1349,7 +1349,7 @@ static BOOL test_one_cmdline(const cmdline_tests_t* test)
{
if (i < count)
{
- MultiByteToWideChar(CP_ACP, 0, test->args[i], -1, argW, sizeof(argW)/sizeof(*argW));
+ MultiByteToWideChar(CP_ACP, 0, test->args[i], -1, argW, ARRAY_SIZE(argW));
todo_wine_if(test->todo & (1 << (i+4)))
ok(!lstrcmpW(*argsW, argW), "%s: arg[%d] expected %s but got %s\n", test->cmd, i, wine_dbgstr_w(argW), wine_dbgstr_w(*argsW));
}
@@ -1395,7 +1395,7 @@ static void test_commandline2argv(void)
"expected NULL-terminated list of commandline arguments\n");
if (numargs == 1)
{
- GetModuleFileNameW(NULL, strW, sizeof(strW)/sizeof(*strW));
+ GetModuleFileNameW(NULL, strW, ARRAY_SIZE(strW));
ok(!lstrcmpW(args[0], strW), "wrong path to the current executable: %s instead of %s\n", wine_dbgstr_w(args[0]), wine_dbgstr_w(strW));
}
if (args) LocalFree(args);
@@ -1859,7 +1859,7 @@ static void test_fileurls(void)
return;
}
- get_long_path_name(tmpdir, longtmpdir, sizeof(longtmpdir)/sizeof(*longtmpdir));
+ get_long_path_name(tmpdir, longtmpdir, ARRAY_SIZE(longtmpdir));
SetEnvironmentVariableA("urlprefix", "file:///");
test=fileurl_tests;
@@ -2779,7 +2779,7 @@ static void init_test(void)
/* Setup the test shortcuts */
sprintf(filename, "%s\\test_shortcut_shlexec.lnk", tmpdir);
- MultiByteToWideChar(CP_ACP, 0, filename, -1, lnkfile, sizeof(lnkfile)/sizeof(*lnkfile));
+ MultiByteToWideChar(CP_ACP, 0, filename, -1, lnkfile, ARRAY_SIZE(lnkfile));
desc.description=NULL;
desc.workdir=NULL;
sprintf(filename, "%s\\test file.shlexec", tmpdir);
@@ -2793,7 +2793,7 @@ static void init_test(void)
create_lnk(lnkfile, &desc, 0);
sprintf(filename, "%s\\test_shortcut_exe.lnk", tmpdir);
- MultiByteToWideChar(CP_ACP, 0, filename, -1, lnkfile, sizeof(lnkfile)/sizeof(*lnkfile));
+ MultiByteToWideChar(CP_ACP, 0, filename, -1, lnkfile, ARRAY_SIZE(lnkfile));
desc.description=NULL;
desc.workdir=NULL;
desc.path=argv0;
diff --git a/dlls/shell32/tests/string.c b/dlls/shell32/tests/string.c
index 6cdb386eba..5fd589300b 100644
--- a/dlls/shell32/tests/string.c
+++ b/dlls/shell32/tests/string.c
@@ -67,14 +67,14 @@ static void test_StrRetToStringNW(void)
strret.uType = STRRET_WSTR;
U(strret).pOleStr = CoDupStrW("Test");
memset(buff, 0xff, sizeof(buff));
- ret = pStrRetToStrNAW(buff, sizeof(buff)/sizeof(WCHAR), &strret, NULL);
+ ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, NULL);
ok(ret == TRUE && !strcmpW(buff, szTestW),
"STRRET_WSTR: dup failed, ret=%d\n", ret);
strret.uType = STRRET_CSTR;
lstrcpyA(U(strret).cStr, "Test");
memset(buff, 0xff, sizeof(buff));
- ret = pStrRetToStrNAW(buff, sizeof(buff)/sizeof(WCHAR), &strret, NULL);
+ ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, NULL);
ok(ret == TRUE && !strcmpW(buff, szTestW),
"STRRET_CSTR: dup failed, ret=%d\n", ret);
@@ -82,7 +82,7 @@ static void test_StrRetToStringNW(void)
U(strret).uOffset = 1;
strcpy((char*)&iidl, " Test");
memset(buff, 0xff, sizeof(buff));
- ret = pStrRetToStrNAW(buff, sizeof(buff)/sizeof(WCHAR), &strret, iidl);
+ ret = pStrRetToStrNAW(buff, ARRAY_SIZE(buff), &strret, iidl);
ok(ret == TRUE && !strcmpW(buff, szTestW),
"STRRET_OFFSET: dup failed, ret=%d\n", ret);
@@ -92,7 +92,7 @@ if (0)
/* Invalid dest - should return FALSE, except NT4 does not, so we don't check. */
strret.uType = STRRET_WSTR;
U(strret).pOleStr = CoDupStrW("Test");
- pStrRetToStrNAW(NULL, sizeof(buff)/sizeof(WCHAR), &strret, NULL);
+ pStrRetToStrNAW(NULL, ARRAY_SIZE(buff), &strret, NULL);
trace("NULL dest: ret=%d\n", ret);
}
}
--
2.14.4
June 14, 2018
[PATCH] shell32/tests: Avoid sizeof in a trace
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/shell32/tests/shelldispatch.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c
index cc00757840..ed109a9e17 100644
--- a/dlls/shell32/tests/shelldispatch.c
+++ b/dlls/shell32/tests/shelldispatch.c
@@ -541,8 +541,7 @@ static void test_items(void)
count = -1;
r = FolderItems_get_Count(items, &count);
ok(r == S_OK, "FolderItems::get_Count failed: %08x\n", r);
- ok(count == sizeof(file_defs)/sizeof(file_defs[0]),
- "expected %d files, got %d\n", (LONG)(sizeof(file_defs)/sizeof(file_defs[0])), count);
+ ok(count == ARRAY_SIZE(file_defs), "got %d files\n", count);
V_VT(&var) = VT_EMPTY;
item = (FolderItem*)0xdeadbeef;
--
2.14.4
June 14, 2018
[PATCH] setupapi/tests: Use the available ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/setupapi/tests/devinst.c | 4 ++--
dlls/setupapi/tests/misc.c | 4 ++--
dlls/setupapi/tests/parser.c | 8 ++++----
dlls/setupapi/tests/setupcab.c | 20 +++++++++-----------
4 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c
index 4df00b1855..420c65a142 100644
--- a/dlls/setupapi/tests/devinst.c
+++ b/dlls/setupapi/tests/devinst.c
@@ -121,7 +121,7 @@ static LSTATUS devinst_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
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))))
@@ -1259,7 +1259,7 @@ static void testSetupDiGetINFClassA(void)
retval = SetupDiGetINFClassA(filename, &guid, cn, MAX_PATH, &count);
ok(!retval, "expected SetupDiGetINFClassA to fail!\n");
- for(i=0; i < sizeof(signatures)/sizeof(char*); i++)
+ for(i=0; i < ARRAY_SIZE(signatures); i++)
{
trace("testing signature %s\n", signatures[i]);
h = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
diff --git a/dlls/setupapi/tests/misc.c b/dlls/setupapi/tests/misc.c
index dbe684bb29..9143cd4bd3 100644
--- a/dlls/setupapi/tests/misc.c
+++ b/dlls/setupapi/tests/misc.c
@@ -594,7 +594,7 @@ static void test_SetupDecompressOrCopyFile(void)
create_source_file(source, uncompressed, sizeof(uncompressed));
- for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{
type = FILE_COMPRESSION_NONE;
ret = SetupDecompressOrCopyFileA(invalid_parameters[i].source,
@@ -697,7 +697,7 @@ static void test_SetupDecompressOrCopyFile(void)
p = strrchr(target, '\\');
- for (i = 0; i < sizeof(zip_multi_tests)/sizeof(zip_multi_tests[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(zip_multi_tests); i++)
{
lstrcpyA(p + 1, zip_multi_tests[i].filename);
diff --git a/dlls/setupapi/tests/parser.c b/dlls/setupapi/tests/parser.c
index 67c9887a61..f8d2c5de1c 100644
--- a/dlls/setupapi/tests/parser.c
+++ b/dlls/setupapi/tests/parser.c
@@ -154,7 +154,7 @@ static void test_invalid_files(void)
HINF hinf;
DWORD err;
- for (i = 0; i < sizeof(invalid_files)/sizeof(invalid_files[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(invalid_files); i++)
{
SetLastError( 0xdeadbeef );
err_line = 0xdeadbeef;
@@ -229,7 +229,7 @@ static void test_section_names(void)
DWORD err;
LONG ret;
- for (i = 0; i < sizeof(section_names)/sizeof(section_names[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(section_names); i++)
{
SetLastError( 0xdeadbeef );
hinf = test_file_contents( section_names[i].data, &err_line );
@@ -418,7 +418,7 @@ static void test_key_names(void)
BOOL ret;
INFCONTEXT context;
- for (i = 0; i < sizeof(key_names)/sizeof(key_names[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(key_names); i++)
{
strcpy( buffer, STD_HEADER "[Test]\n" );
strcat( buffer, key_names[i].data );
@@ -622,7 +622,7 @@ static void test_SetupGetIntField(void)
};
unsigned int i;
- for (i = 0; i < sizeof(keys)/sizeof(keys[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(keys); i++)
{
HINF hinf;
char buffer[MAX_INF_STRING_LENGTH];
diff --git a/dlls/setupapi/tests/setupcab.c b/dlls/setupapi/tests/setupcab.c
index 33daae922b..bb9add035d 100644
--- a/dlls/setupapi/tests/setupcab.c
+++ b/dlls/setupapi/tests/setupcab.c
@@ -109,7 +109,7 @@ static void test_invalid_parametersA(void)
create_source_fileA(source, NULL, 0);
- for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{
SetLastError(0xdeadbeef);
ret = SetupIterateCabinetA(invalid_parameters[i].CabinetFile, 0,
@@ -170,12 +170,12 @@ static void test_invalid_parametersW(void)
return;
}
- GetTempPathW(sizeof(temp)/sizeof(WCHAR), temp);
+ GetTempPathW(ARRAY_SIZE(temp), temp);
GetTempFileNameW(temp, docW, 0, source);
create_source_fileW(source, NULL, 0);
- for (i = 0; i < sizeof(invalid_parameters)/sizeof(invalid_parameters[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
{
SetLastError(0xdeadbeef);
ret = SetupIterateCabinetW(invalid_parameters[i].CabinetFile, 0,
@@ -275,7 +275,7 @@ static void test_invalid_callbackW(void)
return;
}
- GetTempPathW(sizeof(temp)/sizeof(WCHAR), temp);
+ GetTempPathW(ARRAY_SIZE(temp), temp);
GetTempFileNameW(temp, docW, 0, source);
create_source_fileW(source, comp_cab_zip_multi, sizeof(comp_cab_zip_multi));
@@ -316,7 +316,7 @@ static UINT CALLBACK simple_callbackA(PVOID Context, UINT Notification,
(*file_count)++;
- if (index < sizeof(expected_files)/sizeof(char *))
+ if (index < ARRAY_SIZE(expected_files))
{
ok(!strcmp(expected_files[index], info->NameInCabinet),
"[%d] Expected file \"%s\", got \"%s\"\n",
@@ -348,8 +348,7 @@ static void test_simple_enumerationA(void)
ret = SetupIterateCabinetA(source, 0, simple_callbackA, &enum_count);
ok(ret == 1, "Expected SetupIterateCabinetA to return 1, got %d\n", ret);
- ok(enum_count == sizeof(expected_files)/sizeof(char *),
- "Unexpectedly enumerated %d files\n", enum_count);
+ ok(enum_count == ARRAY_SIZE(expected_files), "Unexpectedly enumerated %d files\n", enum_count);
DeleteFileA(source);
}
@@ -376,7 +375,7 @@ static UINT CALLBACK simple_callbackW(PVOID Context, UINT Notification,
(*file_count)++;
- if (index < sizeof(expected_filesW)/sizeof(WCHAR *))
+ if (index < ARRAY_SIZE(expected_filesW))
{
ok(!lstrcmpW(expected_filesW[index], info->NameInCabinet),
"[%d] Expected file %s, got %s\n",
@@ -408,15 +407,14 @@ static void test_simple_enumerationW(void)
return;
}
- GetTempPathW(sizeof(temp)/sizeof(WCHAR), temp);
+ GetTempPathW(ARRAY_SIZE(temp), temp);
GetTempFileNameW(temp, docW, 0, source);
create_source_fileW(source, comp_cab_zip_multi, sizeof(comp_cab_zip_multi));
ret = SetupIterateCabinetW(source, 0, simple_callbackW, &enum_count);
ok(ret == 1, "Expected SetupIterateCabinetW to return 1, got %d\n", ret);
- ok(enum_count == sizeof(expected_files)/sizeof(WCHAR *),
- "Unexpectedly enumerated %d files\n", enum_count);
+ ok(enum_count == ARRAY_SIZE(expected_files), "Unexpectedly enumerated %d files\n", enum_count);
DeleteFileW(source);
}
--
2.14.4
June 14, 2018
[PATCH] winedbg/gdbproxy: Handle VS thread renaming.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
programs/winedbg/gdbproxy.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c
index 869d56b..7f59ce1 100644
--- a/programs/winedbg/gdbproxy.c
+++ b/programs/winedbg/gdbproxy.c
@@ -339,6 +339,30 @@ static BOOL handle_exception(struct gdb_context* gdbctx, EXCEPTION_DEBUG_INFO* e
ret = TRUE;
/* FIXME: we could also add here a O packet with additional information */
break;
+ case EXCEPTION_NAME_THREAD:
+ {
+ const THREADNAME_INFO *threadname = (const THREADNAME_INFO *)rec->ExceptionInformation;
+ struct dbg_thread *thread;
+ char name[9];
+ SIZE_T read;
+
+ if (threadname->dwThreadID == -1)
+ thread = dbg_curr_thread;
+ else
+ thread = dbg_get_thread(gdbctx->process, threadname->dwThreadID);
+ if (thread)
+ {
+ if (gdbctx->process->process_io->read( gdbctx->process->handle,
+ threadname->szName, name, sizeof(name), &read) && read == sizeof(name))
+ {
+ fprintf(stderr, "Thread ID=%04x renamed to \"%.9s\"\n",
+ threadname->dwThreadID, name);
+ }
+ }
+ else
+ fprintf(stderr, "Cannot set name of thread %04x\n", threadname->dwThreadID);
+ return DBG_CONTINUE;
+ }
default:
if (gdbctx->trace & GDBPXY_TRC_WIN32_EVENT)
fprintf(stderr, "Unhandled exception code 0x%08x\n", rec->ExceptionCode);
--
2.7.4
June 14, 2018
[PATCH 6/6] dbghelp: Read the stabs nlist entry corresponding to the target's architecture.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/dbghelp/dbghelp_private.h | 2 +-
dlls/dbghelp/macho_module.c | 16 +++------
dlls/dbghelp/stabs.c | 73 ++++++++++++++++++++++++------------------
3 files changed, 47 insertions(+), 44 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index 0963f1e..76f5d00 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -676,7 +676,7 @@ typedef void (*stabs_def_cb)(struct module* module, unsigned long load_offset,
BOOL is_public, BOOL is_global, unsigned char other,
struct symt_compiland* compiland, void* user);
extern BOOL stabs_parse(struct module* module, unsigned long load_offset,
- const void* stabs, int stablen,
+ const char* stabs, int stablen,
const char* strs, int strtablen,
stabs_def_cb callback, void* user) DECLSPEC_HIDDEN;
diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c
index b8f5967..52c8e69 100644
--- a/dlls/dbghelp/macho_module.c
+++ b/dlls/dbghelp/macho_module.c
@@ -88,13 +88,6 @@ struct dyld_all_image_infos {
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_macho);
-#ifdef _WIN64
-typedef struct nlist_64 macho_nlist;
-#else
-typedef struct nlist macho_nlist;
-#endif
-
-
/* Bitmask for Mach-O image header flags indicating that the image is in dyld's
shared cached. That implies that its segments are mapped non-contiguously.
This value isn't defined anywhere in headers. It's used in dyld and in
@@ -913,24 +906,25 @@ static int macho_parse_symtab(struct image_file_map* ifm,
struct macho_file_map* fmap = &ifm->u.macho;
const struct symtab_command* sc = (const struct symtab_command*)lc;
struct macho_debug_info* mdi = user;
- const macho_nlist* stab;
const char* stabstr;
int ret = 0;
+ size_t stabsize = (ifm->addr_size == 32) ? sizeof(struct nlist) : sizeof(struct nlist_64);
+ const char *stab;
TRACE("(%p/%d, %p, %p) %u syms at 0x%08x, strings 0x%08x - 0x%08x\n", fmap, fmap->fd, lc,
user, sc->nsyms, sc->symoff, sc->stroff, sc->stroff + sc->strsize);
- if (!macho_map_ranges(fmap, sc->symoff, sc->nsyms * sizeof(macho_nlist),
+ if (!macho_map_ranges(fmap, sc->symoff, sc->nsyms * stabsize,
sc->stroff, sc->strsize, (const void**)&stab, (const void**)&stabstr))
return 0;
if (!stabs_parse(mdi->module,
mdi->module->format_info[DFI_MACHO]->u.macho_info->load_addr - fmap->segs_start,
- stab, sc->nsyms * sizeof(macho_nlist),
+ stab, sc->nsyms * stabsize,
stabstr, sc->strsize, macho_stabs_def_cb, mdi))
ret = -1;
- macho_unmap_ranges(fmap, sc->symoff, sc->nsyms * sizeof(macho_nlist),
+ macho_unmap_ranges(fmap, sc->symoff, sc->nsyms * stabsize,
sc->stroff, sc->strsize, (const void**)&stab, (const void**)&stabstr);
return ret;
diff --git a/dlls/dbghelp/stabs.c b/dlls/dbghelp/stabs.c
index 177c6bc..846a935 100644
--- a/dlls/dbghelp/stabs.c
+++ b/dlls/dbghelp/stabs.c
@@ -41,6 +41,7 @@
#include <sys/mman.h>
#endif
#include <limits.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
@@ -111,11 +112,7 @@ struct stab_nlist
unsigned char n_type;
char n_other;
short n_desc;
-#if defined(__APPLE__) && defined(_WIN64)
- unsigned long n_value;
-#else
unsigned n_value;
-#endif
};
static void stab_strcpy(char* dest, int sz, const char* source)
@@ -1265,7 +1262,7 @@ static inline void stabbuf_append(char **buf, unsigned *buf_size, const char *st
}
BOOL stabs_parse(struct module* module, unsigned long load_offset,
- const void* pv_stab_ptr, int stablen,
+ const char* pv_stab_ptr, int stablen,
const char* strs, int strtablen,
stabs_def_cb callback, void* user)
{
@@ -1278,7 +1275,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
const char* ptr;
char* stabbuff;
unsigned int stabbufflen;
- const struct stab_nlist* stab_ptr = pv_stab_ptr;
+ const struct stab_nlist* stab_ptr;
const char* strs_end;
int strtabinc;
char symname[4096];
@@ -1290,8 +1287,14 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
BOOL ret = TRUE;
struct location loc;
unsigned char type;
+ size_t stabsize = sizeof(struct stab_nlist);
+ uint64_t n_value;
- nstab = stablen / sizeof(struct stab_nlist);
+#ifdef __APPLE__
+ if (module->process->is_64bit)
+ stabsize = sizeof(struct nlist_64);
+#endif
+ nstab = stablen / stabsize;
strs_end = strs + strtablen;
memset(stabs_basic, 0, sizeof(stabs_basic));
@@ -1307,8 +1310,14 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
strtabinc = 0;
stabbuff[0] = '\0';
- for (i = 0; i < nstab; i++, stab_ptr++)
+ for (i = 0; i < nstab; i++)
{
+ stab_ptr = (struct stab_nlist *)(pv_stab_ptr + i * stabsize);
+ n_value = stab_ptr->n_value;
+#ifdef __APPLE__
+ if (module->process->is_64bit)
+ n_value = ((struct nlist_64 *)stab_ptr)->n_value;
+#endif
ptr = strs + stab_ptr->n_strx;
if ((ptr > strs_end) || (ptr + strlen(ptr) > strs_end))
{
@@ -1382,7 +1391,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
stab_strcpy(symname, sizeof(symname), ptr);
loc.kind = loc_absolute;
loc.reg = 0;
- loc.offset = load_offset + stab_ptr->n_value;
+ loc.offset = load_offset + n_value;
symt_new_global_variable(module, compiland, symname, TRUE /* FIXME */,
loc, 0, stabs_parse_type(ptr));
break;
@@ -1392,7 +1401,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
stab_strcpy(symname, sizeof(symname), ptr);
loc.kind = loc_absolute;
loc.reg = 0;
- loc.offset = load_offset + stab_ptr->n_value;
+ loc.offset = load_offset + n_value;
symt_new_global_variable(module, compiland, symname, TRUE /* FIXME */,
loc, 0, stabs_parse_type(ptr));
break;
@@ -1400,14 +1409,14 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
if (curr_func)
{
block = symt_open_func_block(module, curr_func, block,
- stab_ptr->n_value, 0);
+ n_value, 0);
pending_flush(&pending_block, module, curr_func, block);
}
break;
case N_RBRAC:
if (curr_func)
block = symt_close_func_block(module, curr_func, block,
- stab_ptr->n_value);
+ n_value);
break;
case N_PSYM:
/* These are function parameters. */
@@ -1417,9 +1426,9 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
stab_strcpy(symname, sizeof(symname), ptr);
loc.kind = loc_regrel;
loc.reg = dbghelp_current_cpu->frame_regno;
- loc.offset = stab_ptr->n_value;
+ loc.offset = n_value;
symt_add_func_local(module, curr_func,
- (int)stab_ptr->n_value >= 0 ? DataIsParam : DataIsLocal,
+ (int)n_value >= 0 ? DataIsParam : DataIsLocal,
&loc, NULL, param_type, symname);
symt_add_function_signature_parameter(module,
(struct symt_function_signature*)curr_func->type,
@@ -1433,7 +1442,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
loc.kind = loc_register;
loc.offset = 0;
- switch (stab_ptr->n_value)
+ switch (n_value)
{
case 0: loc.reg = CV_REG_EAX; break;
case 1: loc.reg = CV_REG_ECX; break;
@@ -1451,7 +1460,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
case 16:
case 17:
case 18:
- case 19: loc.reg = CV_REG_ST0 + stab_ptr->n_value - 12; break;
+ case 19: loc.reg = CV_REG_ST0 + n_value - 12; break;
case 21:
case 22:
case 23:
@@ -1459,7 +1468,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
case 25:
case 26:
case 27:
- case 28: loc.reg = CV_REG_XMM0 + stab_ptr->n_value - 21; break;
+ case 28: loc.reg = CV_REG_XMM0 + n_value - 21; break;
case 29:
case 30:
case 31:
@@ -1467,9 +1476,9 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
case 33:
case 34:
case 35:
- case 36: loc.reg = CV_REG_MM0 + stab_ptr->n_value - 29; break;
+ case 36: loc.reg = CV_REG_MM0 + n_value - 29; break;
default:
- FIXME("Unknown register value (%lu)\n", (unsigned long)stab_ptr->n_value);
+ FIXME("Unknown register value (%lu)\n", (unsigned long)n_value);
loc.reg = CV_REG_NONE;
break;
}
@@ -1492,7 +1501,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
/* These are local variables */
loc.kind = loc_regrel;
loc.reg = dbghelp_current_cpu->frame_regno;
- loc.offset = stab_ptr->n_value;
+ loc.offset = n_value;
if (curr_func != NULL) pending_add_var(&pending_block, ptr, DataIsLocal, &loc);
break;
case N_SLINE:
@@ -1503,14 +1512,14 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
assert(source_idx >= 0);
if (curr_func != NULL)
{
- unsigned long offset = stab_ptr->n_value;
+ unsigned long offset = n_value;
if (module->type == DMT_MACHO)
offset -= curr_func->address - load_offset;
symt_add_func_line(module, curr_func, source_idx,
stab_ptr->n_desc, offset);
}
else pending_add_line(&pending_func, source_idx, stab_ptr->n_desc,
- stab_ptr->n_value, load_offset);
+ n_value, load_offset);
break;
case N_FUN:
/*
@@ -1537,13 +1546,13 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
* and offset of last function
*/
stabs_finalize_function(module, curr_func,
- stab_ptr->n_value ?
- (load_offset + stab_ptr->n_value - curr_func->address) : 0);
+ n_value ?
+ (load_offset + n_value - curr_func->address) : 0);
}
func_type = symt_new_function_signature(module,
stabs_parse_type(ptr), -1);
curr_func = symt_new_function(module, compiland, symname,
- load_offset + stab_ptr->n_value, 0,
+ load_offset + n_value, 0,
&func_type->symt);
pending_flush(&pending_func, module, curr_func, NULL);
}
@@ -1552,7 +1561,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
/* some versions of GCC to use a N_FUN "" to mark the end of a function
* and n_value contains the size of the func
*/
- stabs_finalize_function(module, curr_func, stab_ptr->n_value);
+ stabs_finalize_function(module, curr_func, n_value);
curr_func = NULL;
}
break;
@@ -1594,7 +1603,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
break;
case N_UNDF:
strs += strtabinc;
- strtabinc = stab_ptr->n_value;
+ strtabinc = n_value;
/* I'm not sure this is needed, so trace it before we obsolete it */
if (curr_func)
{
@@ -1607,7 +1616,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
/* Ignore this. We don't care what it points to. */
break;
case N_BINCL:
- stabs_add_include(stabs_new_include(ptr, stab_ptr->n_value));
+ stabs_add_include(stabs_new_include(ptr, n_value));
assert(incl_stk < (int)(sizeof(incl) / sizeof(incl[0])) - 1);
incl[++incl_stk] = source_idx;
source_idx = source_new(module, NULL, ptr);
@@ -1617,9 +1626,9 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
source_idx = incl[incl_stk--];
break;
case N_EXCL:
- if (stabs_add_include(stabs_find_include(ptr, stab_ptr->n_value)) < 0)
+ if (stabs_add_include(stabs_find_include(ptr, n_value)) < 0)
{
- ERR("Excluded header not found (%s,%ld)\n", ptr, (unsigned long)stab_ptr->n_value);
+ ERR("Excluded header not found (%s,%ld)\n", ptr, (unsigned long)n_value);
module_reset_debug_info(module);
ret = FALSE;
goto done;
@@ -1656,7 +1665,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
if (*ptr == '_') ptr++;
stab_strcpy(symname, sizeof(symname), ptr);
- callback(module, load_offset, symname, stab_ptr->n_value,
+ callback(module, load_offset, symname, n_value,
is_public, is_global, stab_ptr->n_other, compiland, user);
}
break;
@@ -1666,7 +1675,7 @@ BOOL stabs_parse(struct module* module, unsigned long load_offset,
}
stabbuff[0] = '\0';
TRACE("0x%02x %lx %s\n",
- stab_ptr->n_type, (unsigned long)stab_ptr->n_value, debugstr_a(strs + stab_ptr->n_strx));
+ stab_ptr->n_type, (unsigned long)n_value, debugstr_a(strs + stab_ptr->n_strx));
}
module->module.SymType = SymDia;
module->module.CVSig = 'S' | ('T' << 8) | ('A' << 16) | ('B' << 24);
--
2.7.4
June 14, 2018
[PATCH 5/6] dbghelp: Translate the 32-bit Mach-O section header to the 64-bit one.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/dbghelp/image_private.h | 8 +-------
dlls/dbghelp/macho_module.c | 43 +++++++++++++++++++++++++++++--------------
2 files changed, 30 insertions(+), 21 deletions(-)
diff --git a/dlls/dbghelp/image_private.h b/dlls/dbghelp/image_private.h
index 60cdd35..9990850 100644
--- a/dlls/dbghelp/image_private.h
+++ b/dlls/dbghelp/image_private.h
@@ -44,12 +44,6 @@
#endif
#ifdef HAVE_MACH_O_LOADER_H
#include <mach-o/loader.h>
-
-#ifdef _WIN64
-typedef struct section_64 macho_section;
-#else
-typedef struct section macho_section;
-#endif
#endif
#define IMAGE_NO_MAP ((void*)-1)
@@ -105,7 +99,7 @@ struct image_file_map
int num_sections;
struct
{
- const macho_section* section;
+ struct section_64 section;
const char* mapped;
unsigned int ignored : 1;
}* sect;
diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c
index 52ea739..b8f5967 100644
--- a/dlls/dbghelp/macho_module.c
+++ b/dlls/dbghelp/macho_module.c
@@ -328,7 +328,7 @@ BOOL macho_find_section(struct image_file_map* ifm, const char* segname, const c
{
struct macho_file_map* fmap;
unsigned i;
- char tmp[sizeof(fmap->sect[0].section->sectname)];
+ char tmp[sizeof(fmap->sect[0].section.sectname)];
/* Other parts of dbghelp use section names like ".eh_frame". Mach-O uses
names like "__eh_frame". Convert those. */
@@ -345,8 +345,8 @@ BOOL macho_find_section(struct image_file_map* ifm, const char* segname, const c
for (i = 0; i < fmap->num_sections; i++)
{
if (!fmap->sect[i].ignored &&
- strcmp(fmap->sect[i].section->sectname, sectname) == 0 &&
- (!segname || strcmp(fmap->sect[i].section->segname, segname) == 0))
+ strcmp(fmap->sect[i].section.sectname, sectname) == 0 &&
+ (!segname || strcmp(fmap->sect[i].section.segname, segname) == 0))
{
ism->fmap = ifm;
ism->sidx = i;
@@ -372,7 +372,7 @@ const char* macho_map_section(struct image_section_map* ism)
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.macho.num_sections || fmap->sect[ism->sidx].ignored)
return IMAGE_NO_MAP;
- return macho_map_range(fmap, fmap->sect[ism->sidx].section->offset, fmap->sect[ism->sidx].section->size,
+ return macho_map_range(fmap, fmap->sect[ism->sidx].section.offset, fmap->sect[ism->sidx].section.size,
&fmap->sect[ism->sidx].mapped);
}
@@ -385,8 +385,8 @@ void macho_unmap_section(struct image_section_map* ism)
if (ism->sidx >= 0 && ism->sidx < fmap->num_sections && fmap->sect[ism->sidx].mapped != IMAGE_NO_MAP)
{
- macho_unmap_range(&fmap->sect[ism->sidx].mapped, NULL, fmap, fmap->sect[ism->sidx].section->offset,
- fmap->sect[ism->sidx].section->size);
+ macho_unmap_range(&fmap->sect[ism->sidx].mapped, NULL, fmap, fmap->sect[ism->sidx].section.offset,
+ fmap->sect[ism->sidx].section.size);
}
}
@@ -398,7 +398,7 @@ DWORD_PTR macho_get_map_rva(const struct image_section_map* ism)
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.macho.num_sections ||
ism->fmap->u.macho.sect[ism->sidx].ignored)
return 0;
- return ism->fmap->u.macho.sect[ism->sidx].section->addr - ism->fmap->u.macho.segs_start;
+ return ism->fmap->u.macho.sect[ism->sidx].section.addr - ism->fmap->u.macho.segs_start;
}
/******************************************************************
@@ -409,7 +409,7 @@ unsigned macho_get_map_size(const struct image_section_map* ism)
if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.macho.num_sections ||
ism->fmap->u.macho.sect[ism->sidx].ignored)
return 0;
- return ism->fmap->u.macho.sect[ism->sidx].section->size;
+ return ism->fmap->u.macho.sect[ism->sidx].section.size;
}
/******************************************************************
@@ -539,12 +539,12 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load
struct macho_file_map* fmap = &ifm->u.macho;
struct section_info* info = user;
BOOL ignore;
- const macho_section* section;
int i;
unsigned long tmp, page_mask = sysconf( _SC_PAGESIZE ) - 1;
uint64_t vmaddr, vmsize;
char segname[16];
uint32_t nsects;
+ const void *sections;
if (ifm->addr_size == 32)
{
@@ -553,7 +553,7 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load
vmsize = sc->vmsize;
memcpy(segname, sc->segname, sizeof(segname));
nsects = sc->nsects;
- section = (const macho_section*)(sc + 1);
+ sections = (const void *)(sc + 1);
}
else
{
@@ -562,7 +562,7 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load
vmsize = sc->vmsize;
memcpy(segname, sc->segname, sizeof(segname));
nsects = sc->nsects;
- section = (const macho_section*)(sc + 1);
+ sections = (const void *)(sc + 1);
}
TRACE("(%p/%d, %p, %p) before: 0x%08lx - 0x%08lx\n", fmap, fmap->fd, lc, user,
@@ -596,7 +596,22 @@ static int macho_load_section_info(struct image_file_map* ifm, const struct load
for (i = 0; i < nsects; i++)
{
- fmap->sect[info->section_index].section = §ion[i];
+ if (ifm->addr_size == 32)
+ {
+ const struct section *section = &((const struct section *)sections)[i];
+ memcpy(fmap->sect[info->section_index].section.sectname, section->sectname, sizeof(section->sectname));
+ memcpy(fmap->sect[info->section_index].section.segname, section->segname, sizeof(section->segname));
+ fmap->sect[info->section_index].section.addr = section->addr;
+ fmap->sect[info->section_index].section.size = section->size;
+ fmap->sect[info->section_index].section.offset = section->offset;
+ fmap->sect[info->section_index].section.align = section->align;
+ fmap->sect[info->section_index].section.reloff = section->reloff;
+ fmap->sect[info->section_index].section.nreloc = section->nreloc;
+ fmap->sect[info->section_index].section.flags = section->flags;
+ }
+ else
+ fmap->sect[info->section_index].section = ((const struct section_64 *)sections)[i];
+
fmap->sect[info->section_index].mapped = IMAGE_NO_MAP;
fmap->sect[info->section_index].ignored = ignore;
info->section_index++;
@@ -831,8 +846,8 @@ static BOOL macho_sect_is_code(struct macho_file_map* fmap, unsigned char sectid
sectidx--; /* convert from 1-based to 0-based */
if (sectidx >= fmap->num_sections || fmap->sect[sectidx].ignored) return FALSE;
- ret = (!(fmap->sect[sectidx].section->flags & SECTION_TYPE) &&
- (fmap->sect[sectidx].section->flags & (S_ATTR_PURE_INSTRUCTIONS|S_ATTR_SOME_INSTRUCTIONS)));
+ ret = (!(fmap->sect[sectidx].section.flags & SECTION_TYPE) &&
+ (fmap->sect[sectidx].section.flags & (S_ATTR_PURE_INSTRUCTIONS|S_ATTR_SOME_INSTRUCTIONS)));
TRACE("-> %d\n", ret);
return ret;
}
--
2.7.4
June 14, 2018
[PATCH 4/6] dbghelp: Read the Mach-O segment command corresponding to the target's architecture.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/dbghelp/macho_module.c | 68 +++++++++++++++++++++++++++++++++------------
1 file changed, 50 insertions(+), 18 deletions(-)
diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c
index 50fcca4..52ea739 100644
--- a/dlls/dbghelp/macho_module.c
+++ b/dlls/dbghelp/macho_module.c
@@ -89,10 +89,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_macho);
#ifdef _WIN64
-typedef struct segment_command_64 macho_segment_command;
typedef struct nlist_64 macho_nlist;
#else
-typedef struct segment_command macho_segment_command;
typedef struct nlist macho_nlist;
#endif
@@ -506,12 +504,26 @@ static int macho_enum_load_commands(struct image_file_map *ifm, unsigned cmd,
*/
static int macho_count_sections(struct image_file_map* ifm, const struct load_command* lc, void* user)
{
- const macho_segment_command* sc = (const macho_segment_command*)lc;
+ char segname[16];
+ uint32_t nsects;
+
+ if (ifm->addr_size == 32)
+ {
+ const struct segment_command *sc = (const struct segment_command *)lc;
+ memcpy(segname, sc->segname, sizeof(segname));
+ nsects = sc->nsects;
+ }
+ else
+ {
+ const struct segment_command_64 *sc = (const struct segment_command_64 *)lc;
+ memcpy(segname, sc->segname, sizeof(segname));
+ nsects = sc->nsects;
+ }
TRACE("(%p/%d, %p, %p) segment %s\n", ifm, ifm->u.macho.fd, lc, user,
- debugstr_an(sc->segname, sizeof(sc->segname)));
+ debugstr_an(segname, sizeof(segname)));
- ifm->u.macho.num_sections += sc->nsects;
+ ifm->u.macho.num_sections += nsects;
return 0;
}
@@ -525,44 +537,64 @@ static int macho_count_sections(struct image_file_map* ifm, const struct load_co
static int macho_load_section_info(struct image_file_map* ifm, const struct load_command* lc, void* user)
{
struct macho_file_map* fmap = &ifm->u.macho;
- const macho_segment_command* sc = (const macho_segment_command*)lc;
struct section_info* info = user;
BOOL ignore;
const macho_section* section;
int i;
unsigned long tmp, page_mask = sysconf( _SC_PAGESIZE ) - 1;
+ uint64_t vmaddr, vmsize;
+ char segname[16];
+ uint32_t nsects;
+
+ if (ifm->addr_size == 32)
+ {
+ const struct segment_command *sc = (const struct segment_command *)lc;
+ vmaddr = sc->vmaddr;
+ vmsize = sc->vmsize;
+ memcpy(segname, sc->segname, sizeof(segname));
+ nsects = sc->nsects;
+ section = (const macho_section*)(sc + 1);
+ }
+ else
+ {
+ const struct segment_command_64 *sc = (const struct segment_command_64 *)lc;
+ vmaddr = sc->vmaddr;
+ vmsize = sc->vmsize;
+ memcpy(segname, sc->segname, sizeof(segname));
+ nsects = sc->nsects;
+ section = (const macho_section*)(sc + 1);
+ }
TRACE("(%p/%d, %p, %p) before: 0x%08lx - 0x%08lx\n", fmap, fmap->fd, lc, user,
(unsigned long)fmap->segs_start, (unsigned long)fmap->segs_size);
- TRACE("Segment command vm: 0x%08lx - 0x%08lx\n", (unsigned long)sc->vmaddr,
- (unsigned long)(sc->vmaddr + sc->vmsize));
+ TRACE("Segment command vm: 0x%08lx - 0x%08lx\n", (unsigned long)vmaddr,
+ (unsigned long)(vmaddr + vmsize));
/* Images in the dyld shared cache have their segments mapped non-contiguously.
We don't know how to properly locate any of the segments other than __TEXT,
so ignore them. */
- ignore = (info->split_segs && strcmp(sc->segname, SEG_TEXT));
+ ignore = (info->split_segs && strcmp(segname, SEG_TEXT));
- if (!strncmp(sc->segname, "WINE_", 5))
- TRACE("Ignoring special Wine segment %s\n", debugstr_an(sc->segname, sizeof(sc->segname)));
- else if (!strncmp(sc->segname, "__PAGEZERO", 10))
+ if (!strncmp(segname, "WINE_", 5))
+ TRACE("Ignoring special Wine segment %s\n", debugstr_an(segname, sizeof(segname)));
+ else if (!strncmp(segname, "__PAGEZERO", 10))
TRACE("Ignoring __PAGEZERO segment\n");
else if (ignore)
- TRACE("Ignoring %s segment because image has split segments\n", sc->segname);
+ TRACE("Ignoring %s segment because image has split segments\n", segname);
else
{
/* If this segment starts before previously-known earliest, record new earliest. */
- if (sc->vmaddr < fmap->segs_start)
- fmap->segs_start = sc->vmaddr;
+ if (vmaddr < fmap->segs_start)
+ fmap->segs_start = vmaddr;
/* If this segment extends beyond previously-known furthest, record new furthest. */
- tmp = (sc->vmaddr + sc->vmsize + page_mask) & ~page_mask;
+ tmp = (vmaddr + vmsize + page_mask) & ~page_mask;
if (fmap->segs_size < tmp) fmap->segs_size = tmp;
TRACE("after: 0x%08lx - 0x%08lx\n", (unsigned long)fmap->segs_start, (unsigned long)fmap->segs_size);
}
- section = (const macho_section*)(sc + 1);
- for (i = 0; i < sc->nsects; i++)
+ for (i = 0; i < nsects; i++)
{
fmap->sect[info->section_index].section = §ion[i];
fmap->sect[info->section_index].mapped = IMAGE_NO_MAP;
--
2.7.4
June 14, 2018
[PATCH 3/6] dbghelp: Pass an image_file_map to macho_enum_load_commands().
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/dbghelp/macho_module.c | 38 ++++++++++++++++++++++----------------
1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c
index 679c203..50fcca4 100644
--- a/dlls/dbghelp/macho_module.c
+++ b/dlls/dbghelp/macho_module.c
@@ -467,10 +467,11 @@ static const struct load_command* macho_next_load_command(const struct load_comm
* callback. If >=0, that's the count of load commands successfully
* processed.
*/
-static int macho_enum_load_commands(struct macho_file_map* fmap, unsigned cmd,
- int (*cb)(struct macho_file_map*, const struct load_command*, void*),
+static int macho_enum_load_commands(struct image_file_map *ifm, unsigned cmd,
+ int (*cb)(struct image_file_map*, const struct load_command*, void*),
void* user)
{
+ struct macho_file_map* fmap = &ifm->u.macho;
const struct load_command* lc;
int i;
int count = 0;
@@ -488,7 +489,7 @@ static int macho_enum_load_commands(struct macho_file_map* fmap, unsigned cmd,
if (cmd && cmd != lc->cmd) continue;
count++;
- result = cb(fmap, lc, user);
+ result = cb(ifm, lc, user);
TRACE("load_command[%d] (%p), cmd %u; callback => %d\n", i, lc, lc->cmd, result);
if (result) return (result < 0) ? result : count;
}
@@ -503,13 +504,14 @@ static int macho_enum_load_commands(struct macho_file_map* fmap, unsigned cmd,
* significant sections in a Mach-O file. All commands are
* expected to be of LC_SEGMENT[_64] type.
*/
-static int macho_count_sections(struct macho_file_map* fmap, const struct load_command* lc, void* user)
+static int macho_count_sections(struct image_file_map* ifm, const struct load_command* lc, void* user)
{
const macho_segment_command* sc = (const macho_segment_command*)lc;
- TRACE("(%p/%d, %p, %p) segment %s\n", fmap, fmap->fd, lc, user, debugstr_an(sc->segname, sizeof(sc->segname)));
+ TRACE("(%p/%d, %p, %p) segment %s\n", ifm, ifm->u.macho.fd, lc, user,
+ debugstr_an(sc->segname, sizeof(sc->segname)));
- fmap->num_sections += sc->nsects;
+ ifm->u.macho.num_sections += sc->nsects;
return 0;
}
@@ -520,8 +522,9 @@ static int macho_count_sections(struct macho_file_map* fmap, const struct load_c
* range covered by the segments of a Mach-O file and builds the
* section map. All commands are expected to be of LC_SEGMENT[_64] type.
*/
-static int macho_load_section_info(struct macho_file_map* fmap, const struct load_command* lc, void* user)
+static int macho_load_section_info(struct image_file_map* ifm, const struct load_command* lc, void* user)
{
+ struct macho_file_map* fmap = &ifm->u.macho;
const macho_segment_command* sc = (const macho_segment_command*)lc;
struct section_info* info = user;
BOOL ignore;
@@ -576,9 +579,9 @@ static int macho_load_section_info(struct macho_file_map* fmap, const struct loa
* Callback for macho_enum_load_commands. Records the UUID load
* command of a Mach-O file.
*/
-static int find_uuid(struct macho_file_map* fmap, const struct load_command* lc, void* user)
+static int find_uuid(struct image_file_map* ifm, const struct load_command* lc, void* user)
{
- fmap->uuid = (const struct uuid_command*)lc;
+ ifm->u.macho.uuid = (const struct uuid_command*)lc;
return 1;
}
@@ -700,7 +703,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW,
TRACE("... verified Mach header\n");
fmap->num_sections = 0;
- if (macho_enum_load_commands(fmap, target_cmd, macho_count_sections, NULL) < 0)
+ if (macho_enum_load_commands(ifm, target_cmd, macho_count_sections, NULL) < 0)
goto done;
TRACE("%d sections\n", fmap->num_sections);
@@ -713,7 +716,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW,
info.split_segs = split_segs;
info.section_index = 0;
- if (macho_enum_load_commands(fmap, target_cmd, macho_load_section_info, &info) < 0)
+ if (macho_enum_load_commands(ifm, target_cmd, macho_load_section_info, &info) < 0)
{
fmap->num_sections = 0;
goto done;
@@ -723,7 +726,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW,
TRACE("segs_start: 0x%08lx, segs_size: 0x%08lx\n", (unsigned long)fmap->segs_start,
(unsigned long)fmap->segs_size);
- if (macho_enum_load_commands(fmap, LC_UUID, find_uuid, NULL) < 0)
+ if (macho_enum_load_commands(ifm, LC_UUID, find_uuid, NULL) < 0)
goto done;
if (fmap->uuid)
{
@@ -857,9 +860,10 @@ static void macho_stabs_def_cb(struct module* module, unsigned long load_offset,
* Callback for macho_enum_load_commands. Processes the LC_SYMTAB
* load commands from the Mach-O file.
*/
-static int macho_parse_symtab(struct macho_file_map* fmap,
+static int macho_parse_symtab(struct image_file_map* ifm,
const struct load_command* lc, void* user)
{
+ struct macho_file_map* fmap = &ifm->u.macho;
const struct symtab_command* sc = (const struct symtab_command*)lc;
struct macho_debug_info* mdi = user;
const macho_nlist* stab;
@@ -1219,6 +1223,7 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module)
BOOL ret = FALSE;
struct macho_debug_info mdi;
int result;
+ struct image_file_map *ifm;
struct macho_file_map *fmap;
if (module->type != DMT_MACHO || !module->format_info[DFI_MACHO]->u.macho_info)
@@ -1227,7 +1232,8 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module)
return FALSE;
}
- fmap = &module->format_info[DFI_MACHO]->u.macho_info->file_map.u.macho;
+ ifm = &module->format_info[DFI_MACHO]->u.macho_info->file_map;
+ fmap = &ifm->u.macho;
TRACE("(%p, %p/%d)\n", module, fmap, fmap->fd);
@@ -1246,7 +1252,7 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module)
mdi.module = module;
pool_init(&mdi.pool, 65536);
hash_table_init(&mdi.pool, &mdi.ht_symtab, 256);
- result = macho_enum_load_commands(fmap, LC_SYMTAB, macho_parse_symtab, &mdi);
+ result = macho_enum_load_commands(ifm, LC_SYMTAB, macho_parse_symtab, &mdi);
if (result > 0)
ret = TRUE;
else if (result < 0)
@@ -1255,7 +1261,7 @@ BOOL macho_load_debug_info(struct process *pcs, struct module* module)
if (!(dbghelp_options & SYMOPT_PUBLICS_ONLY) && fmap->dsym)
{
mdi.fmap = &fmap->dsym->u.macho;
- result = macho_enum_load_commands(mdi.fmap, LC_SYMTAB, macho_parse_symtab, &mdi);
+ result = macho_enum_load_commands(fmap->dsym, LC_SYMTAB, macho_parse_symtab, &mdi);
if (result > 0)
ret = TRUE;
else if (result < 0)
--
2.7.4
June 14, 2018