Wine-devel
Threads by month
- ----- 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
March 2018
- 90 participants
- 798 discussions
[PATCH 5/5] bcrypt: Implement BCryptGetProperty for BCRYPT_AUTH_TAG_LENGTH.
by Alistair Leslie-Hughes 19 Mar '18
by Alistair Leslie-Hughes 19 Mar '18
19 Mar '18
From: Michael Müller <michael(a)fds-team.de>
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/bcrypt/bcrypt_main.c | 14 ++++++++++++++
dlls/bcrypt/tests/bcrypt.c | 16 ++++++++--------
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 55901f9..fa80318 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -566,6 +566,20 @@ static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop
}
return STATUS_SUCCESS;
}
+ if (!strcmpW( prop, BCRYPT_AUTH_TAG_LENGTH ))
+ {
+ BCRYPT_AUTH_TAG_LENGTHS_STRUCT *tag_length = (void *)buf;
+ if (alg->mode != MODE_ID_GCM) return STATUS_NOT_SUPPORTED;
+ *ret_size = sizeof(*tag_length);
+ if (tag_length && size < *ret_size) return STATUS_BUFFER_TOO_SMALL;
+ if (tag_length)
+ {
+ tag_length->dwMinLength = 12;
+ tag_length->dwMaxLength = 16;
+ tag_length->dwIncrement = 1;
+ }
+ return STATUS_SUCCESS;
+ }
break;
default:
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index b8eaf22..fbfb6d3 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -709,24 +709,24 @@ static void test_BCryptEncrypt(void)
size = 0;
ret = BCryptGetProperty(aes, BCRYPT_AUTH_TAG_LENGTH, NULL, 0, &size, 0);
- todo_wine ok(ret == STATUS_NOT_SUPPORTED, "got %08x\n", ret);
+ ok(ret == STATUS_NOT_SUPPORTED, "got %08x\n", ret);
ret = BCryptSetProperty(aes, BCRYPT_CHAINING_MODE, (UCHAR*)BCRYPT_CHAIN_MODE_GCM, sizeof(BCRYPT_CHAIN_MODE_GCM), 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
size = 0;
ret = BCryptGetProperty(aes, BCRYPT_AUTH_TAG_LENGTH, NULL, 0, &size, 0);
- todo_wine ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
- todo_wine ok(size == sizeof(tag_length), "got %u\n", size);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ ok(size == sizeof(tag_length), "got %u\n", size);
size = 0;
memset(&tag_length, 0, sizeof(tag_length));
ret = BCryptGetProperty(aes, BCRYPT_AUTH_TAG_LENGTH, (UCHAR*)&tag_length, sizeof(tag_length), &size, 0);
- todo_wine ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
- todo_wine ok(size == sizeof(tag_length), "got %u\n", size);
- todo_wine ok(tag_length.dwMinLength == 12, "Expected 12, got %d\n", tag_length.dwMinLength);
- todo_wine ok(tag_length.dwMaxLength == 16, "Expected 16, got %d\n", tag_length.dwMaxLength);
- todo_wine ok(tag_length.dwIncrement == 1, "Expected 1, got %d\n", tag_length.dwIncrement);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ ok(size == sizeof(tag_length), "got %u\n", size);
+ ok(tag_length.dwMinLength == 12, "Expected 12, got %d\n", tag_length.dwMinLength);
+ ok(tag_length.dwMaxLength == 16, "Expected 16, got %d\n", tag_length.dwMaxLength);
+ ok(tag_length.dwIncrement == 1, "Expected 1, got %d\n", tag_length.dwIncrement);
len = 0xdeadbeef;
size = sizeof(len);
--
1.9.1
2
1
[PATCH 4/5] bcrypt: Implement BCryptGetProperty for BCRYPT_CHAINING_MODE.
by Alistair Leslie-Hughes 19 Mar '18
by Alistair Leslie-Hughes 19 Mar '18
19 Mar '18
From: Michael Müller <michael(a)fds-team.de>
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/bcrypt/bcrypt_main.c | 19 ++++++++++---------
dlls/bcrypt/tests/bcrypt.c | 2 +-
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 2f56604..55901f9 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -540,17 +540,18 @@ static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop
}
if (!strcmpW( prop, BCRYPT_CHAINING_MODE ))
{
- if (size >= sizeof(BCRYPT_CHAIN_MODE_CBC) * sizeof(WCHAR))
+ const WCHAR *mode;
+ switch (alg->mode)
{
- memcpy(buf, BCRYPT_CHAIN_MODE_CBC, sizeof(BCRYPT_CHAIN_MODE_CBC));
- *ret_size = sizeof(BCRYPT_CHAIN_MODE_CBC) * sizeof(WCHAR);
- return STATUS_SUCCESS;
- }
- else
- {
- *ret_size = sizeof(BCRYPT_CHAIN_MODE_CBC) * sizeof(WCHAR);
- return STATUS_BUFFER_TOO_SMALL;
+ case MODE_ID_GCM: mode = BCRYPT_CHAIN_MODE_GCM; break;
+ case MODE_ID_CBC: mode = BCRYPT_CHAIN_MODE_CBC; break;
+ default: return STATUS_NOT_IMPLEMENTED;
}
+
+ *ret_size = 64;
+ if (size < *ret_size) return STATUS_BUFFER_TOO_SMALL;
+ memcpy( buf, mode, (strlenW(mode) + 1) * sizeof(WCHAR) );
+ return STATUS_SUCCESS;
}
if (!strcmpW( prop, BCRYPT_KEY_LENGTHS ))
{
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index c44626c..b8eaf22 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -483,7 +483,7 @@ static void test_aes(void)
memset(mode, 0, sizeof(mode));
ret = pBCryptGetProperty(alg, BCRYPT_CHAINING_MODE, mode, sizeof(mode), &size, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
- todo_wine ok(!lstrcmpW((const WCHAR *)mode, BCRYPT_CHAIN_MODE_GCM), "got %s\n", wine_dbgstr_w(mode));
+ ok(!lstrcmpW((const WCHAR *)mode, BCRYPT_CHAIN_MODE_GCM), "got %s\n", wine_dbgstr_w(mode));
ok(size == 64, "got %u\n", size);
test_alg_name(alg, "AES");
--
1.9.1
2
1
[PATCH 3/5] bcrypt: Implement BCryptSetProperty for algorithms.
by Alistair Leslie-Hughes 19 Mar '18
by Alistair Leslie-Hughes 19 Mar '18
19 Mar '18
From: Michael Müller <michael(a)fds-team.de>
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/bcrypt/bcrypt_main.c | 64 ++++++++++++++++++++++++++++++++++++++++++++--
dlls/bcrypt/tests/bcrypt.c | 17 +++++++++---
2 files changed, 76 insertions(+), 5 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 8af43c8..2f56604 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -192,6 +192,12 @@ enum alg_id
ALG_ID_SHA512
};
+enum mode_id
+{
+ MODE_ID_CBC,
+ MODE_ID_GCM
+};
+
#define MAX_HASH_OUTPUT_BYTES 64
#define MAX_HASH_BLOCK_BITS 1024
@@ -216,6 +222,7 @@ struct algorithm
{
struct object hdr;
enum alg_id id;
+ enum mode_id mode;
BOOL hmac;
};
@@ -298,6 +305,7 @@ NTSTATUS WINAPI BCryptOpenAlgorithmProvider( BCRYPT_ALG_HANDLE *handle, LPCWSTR
if (!(alg = heap_alloc( sizeof(*alg) ))) return STATUS_NO_MEMORY;
alg->hdr.magic = MAGIC_ALG;
alg->id = alg_id;
+ alg->mode = MODE_ID_CBC;
alg->hmac = flags & BCRYPT_ALG_HANDLE_HMAC_FLAG;
*handle = alg;
@@ -567,6 +575,38 @@ static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop
return STATUS_NOT_IMPLEMENTED;
}
+static NTSTATUS set_alg_property( struct algorithm *alg, const WCHAR *prop, UCHAR *value, ULONG size, ULONG flags )
+{
+ switch (alg->id)
+ {
+ case ALG_ID_AES:
+ if (!strcmpW( prop, BCRYPT_CHAINING_MODE ))
+ {
+ if (!strncmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_CBC, size ))
+ {
+ alg->mode = MODE_ID_CBC;
+ return STATUS_SUCCESS;
+ }
+ else if (!strncmpW( (WCHAR *)value, BCRYPT_CHAIN_MODE_GCM, size ))
+ {
+ alg->mode = MODE_ID_GCM;
+ return STATUS_SUCCESS;
+ }
+ else
+ {
+ FIXME( "unsupported mode %s\n", debugstr_wn( (WCHAR *)value, size ) );
+ return STATUS_NOT_IMPLEMENTED;
+ }
+ }
+ FIXME( "unsupported aes algorithm property %s\n", debugstr_w(prop) );
+ return STATUS_NOT_IMPLEMENTED;
+
+ default:
+ FIXME( "unsupported algorithm %u\n", alg->id );
+ return STATUS_NOT_IMPLEMENTED;
+ }
+}
+
static NTSTATUS get_hash_property( const struct hash *hash, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size )
{
NTSTATUS status;
@@ -606,8 +646,28 @@ NTSTATUS WINAPI BCryptGetProperty( BCRYPT_HANDLE handle, LPCWSTR prop, UCHAR *bu
NTSTATUS WINAPI BCryptSetProperty( BCRYPT_HANDLE handle, const WCHAR *prop, UCHAR *value, ULONG size, ULONG flags )
{
- FIXME( "%p, %s, %p, %u, %08x\n", handle, debugstr_w(prop), value, size, flags );
- return STATUS_NOT_IMPLEMENTED;
+ struct object *object = handle;
+
+ TRACE( "%p, %s, %p, %u, %08x\n", handle, debugstr_w(prop), value, size, flags );
+
+ if (!object) return STATUS_INVALID_HANDLE;
+
+ switch (object->magic)
+ {
+ case MAGIC_ALG:
+ {
+ struct algorithm *alg = (struct algorithm *)object;
+ return set_alg_property( alg, prop, value, size, flags );
+ }
+ case MAGIC_KEY:
+ {
+ FIXME( "keys not implemented yet\n" );
+ return STATUS_NOT_IMPLEMENTED;
+ }
+ default:
+ WARN( "unknown magic %08x\n", object->magic );
+ return STATUS_INVALID_HANDLE;
+ }
}
NTSTATUS WINAPI BCryptCreateHash( BCRYPT_ALG_HANDLE algorithm, BCRYPT_HASH_HANDLE *handle, UCHAR *object, ULONG objectlen,
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index 6cefe13..c44626c 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -475,6 +475,17 @@ static void test_aes(void)
ok(key_lengths.dwMaxLength == 256, "Expected 256, got %d\n", key_lengths.dwMaxLength);
ok(key_lengths.dwIncrement == 64, "Expected 64, got %d\n", key_lengths.dwIncrement);
+ memcpy(mode, BCRYPT_CHAIN_MODE_GCM, sizeof(BCRYPT_CHAIN_MODE_GCM));
+ ret = pBCryptSetProperty(alg, BCRYPT_CHAINING_MODE, mode, sizeof(mode), 0);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
+ size = 0;
+ memset(mode, 0, sizeof(mode));
+ ret = pBCryptGetProperty(alg, BCRYPT_CHAINING_MODE, mode, sizeof(mode), &size, 0);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ todo_wine ok(!lstrcmpW((const WCHAR *)mode, BCRYPT_CHAIN_MODE_GCM), "got %s\n", wine_dbgstr_w(mode));
+ ok(size == 64, "got %u\n", size);
+
test_alg_name(alg, "AES");
ret = pBCryptCloseAlgorithmProvider(alg, 0);
@@ -512,7 +523,7 @@ static void test_BCryptGenerateSymmetricKey(void)
ret = pBCryptSetProperty(aes, BCRYPT_CHAINING_MODE, (UCHAR *)BCRYPT_CHAIN_MODE_CBC,
sizeof(BCRYPT_CHAIN_MODE_CBC), 0);
- todo_wine ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
size = 0xdeadbeef;
ret = pBCryptEncrypt(key, NULL, 0, NULL, NULL, 0, NULL, 0, &size, 0);
@@ -701,7 +712,7 @@ static void test_BCryptEncrypt(void)
todo_wine ok(ret == STATUS_NOT_SUPPORTED, "got %08x\n", ret);
ret = BCryptSetProperty(aes, BCRYPT_CHAINING_MODE, (UCHAR*)BCRYPT_CHAIN_MODE_GCM, sizeof(BCRYPT_CHAIN_MODE_GCM), 0);
- todo_wine ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
size = 0;
ret = BCryptGetProperty(aes, BCRYPT_AUTH_TAG_LENGTH, NULL, 0, &size, 0);
@@ -939,7 +950,7 @@ static void test_BCryptDecrypt(void)
******************/
ret = BCryptSetProperty(aes, BCRYPT_CHAINING_MODE, (UCHAR*)BCRYPT_CHAIN_MODE_GCM, sizeof(BCRYPT_CHAIN_MODE_GCM), 0);
- todo_wine ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
ret = pBCryptGenerateSymmetricKey(aes, &key, buf, len, secret, sizeof(secret), 0);
--
1.9.1
2
1
[PATCH 2/5] bcrypt: Pass object to get_{alg, hash}_property instead of alg_id.
by Alistair Leslie-Hughes 19 Mar '18
by Alistair Leslie-Hughes 19 Mar '18
19 Mar '18
From: Sebastian Lackner <sebastian(a)fds-team.de>
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/bcrypt/bcrypt_main.c | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 6e47349..8af43c8 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -510,15 +510,15 @@ static NTSTATUS generic_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *
return STATUS_NOT_IMPLEMENTED;
}
-static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size )
+static NTSTATUS get_alg_property( const struct algorithm *alg, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size )
{
NTSTATUS status;
- status = generic_alg_property( id, prop, buf, size, ret_size );
+ status = generic_alg_property( alg->id, prop, buf, size, ret_size );
if (status != STATUS_NOT_IMPLEMENTED)
return status;
- switch (id)
+ switch (alg->id)
{
case ALG_ID_AES:
if (!strcmpW( prop, BCRYPT_BLOCK_LENGTH ))
@@ -567,11 +567,11 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf,
return STATUS_NOT_IMPLEMENTED;
}
-static NTSTATUS get_hash_property( enum alg_id id, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size )
+static NTSTATUS get_hash_property( const struct hash *hash, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size )
{
NTSTATUS status;
- status = generic_alg_property( id, prop, buf, size, ret_size );
+ status = generic_alg_property( hash->alg_id, prop, buf, size, ret_size );
if (status == STATUS_NOT_IMPLEMENTED)
FIXME( "unsupported property %s\n", debugstr_w(prop) );
return status;
@@ -591,12 +591,12 @@ NTSTATUS WINAPI BCryptGetProperty( BCRYPT_HANDLE handle, LPCWSTR prop, UCHAR *bu
case MAGIC_ALG:
{
const struct algorithm *alg = (const struct algorithm *)object;
- return get_alg_property( alg->id, prop, buffer, count, res );
+ return get_alg_property( alg, prop, buffer, count, res );
}
case MAGIC_HASH:
{
const struct hash *hash = (const struct hash *)object;
- return get_hash_property( hash->alg_id, prop, buffer, count, res );
+ return get_hash_property( hash, prop, buffer, count, res );
}
default:
WARN( "unknown magic %08x\n", object->magic );
@@ -798,7 +798,7 @@ struct key
#endif
#if defined(HAVE_GNUTLS_CIPHER_INIT) || defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
-static ULONG get_block_size( enum alg_id alg )
+static ULONG get_block_size( struct algorithm *alg )
{
ULONG ret = 0, size = sizeof(ret);
get_alg_property( alg, BCRYPT_BLOCK_LENGTH, (UCHAR *)&ret, sizeof(ret), &size );
@@ -827,27 +827,27 @@ static NTSTATUS key_export( struct key *key, const WCHAR *type, UCHAR *output, U
#endif
#if defined(HAVE_GNUTLS_CIPHER_INIT) && !defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H)
-static NTSTATUS key_init( struct key *key, enum alg_id id, const UCHAR *secret, ULONG secret_len )
+static NTSTATUS key_init( struct key *key, struct algorithm *alg, const UCHAR *secret, ULONG secret_len )
{
UCHAR *buffer;
if (!libgnutls_handle) return STATUS_INTERNAL_ERROR;
- switch (id)
+ switch (alg->id)
{
case ALG_ID_AES:
break;
default:
- FIXME( "algorithm %u not supported\n", id );
+ FIXME( "algorithm %u not supported\n", alg->id );
return STATUS_NOT_SUPPORTED;
}
- if (!(key->block_size = get_block_size( id ))) return STATUS_INVALID_PARAMETER;
+ if (!(key->block_size = get_block_size( alg ))) return STATUS_INVALID_PARAMETER;
if (!(buffer = heap_alloc( secret_len ))) return STATUS_NO_MEMORY;
memcpy( buffer, secret, secret_len );
- key->alg_id = id;
+ key->alg_id = alg->id;
key->handle = 0; /* initialized on first use */
key->secret = buffer;
key->secret_len = secret_len;
@@ -937,25 +937,25 @@ static NTSTATUS key_destroy( struct key *key )
return STATUS_SUCCESS;
}
#elif defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
-static NTSTATUS key_init( struct key *key, enum alg_id id, const UCHAR *secret, ULONG secret_len )
+static NTSTATUS key_init( struct key *key, struct algorithm *alg, const UCHAR *secret, ULONG secret_len )
{
UCHAR *buffer;
- switch (id)
+ switch (alg->id)
{
case ALG_ID_AES:
break;
default:
- FIXME( "algorithm %u not supported\n", id );
+ FIXME( "algorithm %u not supported\n", alg->id );
return STATUS_NOT_SUPPORTED;
}
- if (!(key->block_size = get_block_size( id ))) return STATUS_INVALID_PARAMETER;
+ if (!(key->block_size = get_block_size( alg ))) return STATUS_INVALID_PARAMETER;
if (!(buffer = heap_alloc( secret_len ))) return STATUS_NO_MEMORY;
memcpy( buffer, secret, secret_len );
- key->alg_id = id;
+ key->alg_id = alg->id;
key->ref_encrypt = NULL; /* initialized on first use */
key->ref_decrypt = NULL;
key->secret = buffer;
@@ -1034,7 +1034,7 @@ static NTSTATUS key_destroy( struct key *key )
return STATUS_SUCCESS;
}
#else
-static NTSTATUS key_init( struct key *key, enum alg_id id, const UCHAR *secret, ULONG secret_len )
+static NTSTATUS key_init( struct key *key, struct algorithm *alg, const UCHAR *secret, ULONG secret_len )
{
ERR( "support for keys not available at build time\n" );
return STATUS_NOT_IMPLEMENTED;
@@ -1089,7 +1089,7 @@ NTSTATUS WINAPI BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_
if (!(key = heap_alloc( sizeof(*key) ))) return STATUS_NO_MEMORY;
key->hdr.magic = MAGIC_KEY;
- if ((status = key_init( key, alg->id, secret, secret_len )))
+ if ((status = key_init( key, alg, secret, secret_len )))
{
heap_free( key );
return status;
--
1.9.1
2
1
19 Mar '18
From: Michael Müller <michael(a)fds-team.de>
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/bcrypt/tests/bcrypt.c | 155 ++++++++++++++++++++++++++++++++++++++++++++-
include/bcrypt.h | 24 ++++++-
2 files changed, 177 insertions(+), 2 deletions(-)
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index 6e28348..6cefe13 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -564,6 +564,8 @@ static void test_BCryptGenerateSymmetricKey(void)
static void test_BCryptEncrypt(void)
{
+ static UCHAR nonce[] =
+ {0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60};
static UCHAR secret[] =
{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
static UCHAR iv[] =
@@ -582,15 +584,28 @@ static void test_BCryptEncrypt(void)
{0xc6,0xa1,0x3b,0x37,0x87,0x8f,0x5b,0x82,0x6f,0x4f,0x81,0x62,0xa1,0xc8,0xd8,0x79,
0xb1,0xa2,0x92,0x73,0xbe,0x2c,0x42,0x07,0xa5,0xac,0xe3,0x93,0x39,0x8c,0xb6,0xfb,
0x87,0x5d,0xea,0xa3,0x7e,0x0f,0xde,0xfa,0xd9,0xec,0x6c,0x4e,0x3c,0x76,0x86,0xe4};
+ static UCHAR expected4[] =
+ {0xe1,0x82,0xc3,0xc0,0x24,0xfb,0x86,0x85,0xf3,0xf1,0x2b,0x7d,0x09,0xb4,0x73,0x67,
+ 0x86,0x64,0xc3,0xfe,0xa3,0x07,0x61,0xf8,0x16,0xc9,0x78,0x7f,0xe7,0xb1,0xc4,0x94};
+ static UCHAR expected_tag[] =
+ {0x89,0xb3,0x92,0x00,0x39,0x20,0x09,0xb4,0x6a,0xd6,0xaf,0xca,0x4b,0x5b,0xfd,0xd0};
+ static UCHAR expected_tag2[] =
+ {0x9a,0x92,0x32,0x2c,0x61,0x2a,0xae,0xef,0x66,0x2a,0xfb,0x55,0xe9,0x48,0xdf,0xbd};
+ BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO auth_info;
+ UCHAR *buf, ciphertext[48], ivbuf[16], tag[16];
+ BCRYPT_AUTH_TAG_LENGTHS_STRUCT tag_length;
BCRYPT_ALG_HANDLE aes;
BCRYPT_KEY_HANDLE key;
- UCHAR *buf, ciphertext[48], ivbuf[16];
ULONG size, len, i;
NTSTATUS ret;
ret = pBCryptOpenAlgorithmProvider(&aes, BCRYPT_AES_ALGORITHM, NULL, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ /******************
+ * AES - CBC mode *
+ ******************/
+
len = 0xdeadbeef;
size = sizeof(len);
ret = pBCryptGetProperty(aes, BCRYPT_OBJECT_LENGTH, (UCHAR *)&len, sizeof(len), &size, 0);
@@ -677,12 +692,101 @@ static void test_BCryptEncrypt(void)
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
HeapFree(GetProcessHeap(), 0, buf);
+ /******************
+ * AES - GCM mode *
+ ******************/
+
+ size = 0;
+ ret = BCryptGetProperty(aes, BCRYPT_AUTH_TAG_LENGTH, NULL, 0, &size, 0);
+ todo_wine ok(ret == STATUS_NOT_SUPPORTED, "got %08x\n", ret);
+
+ ret = BCryptSetProperty(aes, BCRYPT_CHAINING_MODE, (UCHAR*)BCRYPT_CHAIN_MODE_GCM, sizeof(BCRYPT_CHAIN_MODE_GCM), 0);
+ todo_wine ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
+ size = 0;
+ ret = BCryptGetProperty(aes, BCRYPT_AUTH_TAG_LENGTH, NULL, 0, &size, 0);
+ todo_wine ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ todo_wine ok(size == sizeof(tag_length), "got %u\n", size);
+
+ size = 0;
+ memset(&tag_length, 0, sizeof(tag_length));
+ ret = BCryptGetProperty(aes, BCRYPT_AUTH_TAG_LENGTH, (UCHAR*)&tag_length, sizeof(tag_length), &size, 0);
+ todo_wine ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ todo_wine ok(size == sizeof(tag_length), "got %u\n", size);
+ todo_wine ok(tag_length.dwMinLength == 12, "Expected 12, got %d\n", tag_length.dwMinLength);
+ todo_wine ok(tag_length.dwMaxLength == 16, "Expected 16, got %d\n", tag_length.dwMaxLength);
+ todo_wine ok(tag_length.dwIncrement == 1, "Expected 1, got %d\n", tag_length.dwIncrement);
+
+ len = 0xdeadbeef;
+ size = sizeof(len);
+ ret = pBCryptGetProperty(aes, BCRYPT_OBJECT_LENGTH, (UCHAR *)&len, sizeof(len), &size, 0);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
+ buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
+ ret = pBCryptGenerateSymmetricKey(aes, &key, buf, len, secret, sizeof(secret), 0);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
+ memset(&auth_info, 0, sizeof(auth_info));
+ auth_info.cbSize = sizeof(auth_info);
+ auth_info.dwInfoVersion = 1;
+ auth_info.pbNonce = nonce;
+ auth_info.cbNonce = sizeof(nonce);
+ auth_info.pbTag = tag;
+ auth_info.cbTag = sizeof(tag);
+
+ /* input size is a multiple of block size */
+ size = 0;
+ memcpy(ivbuf, iv, sizeof(iv));
+ memset(ciphertext, 0xff, sizeof(ciphertext));
+ memset(tag, 0xff, sizeof(tag));
+ ret = pBCryptEncrypt(key, data2, 32, &auth_info, ivbuf, 16, ciphertext, 32, &size, 0);
+ todo_wine ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ todo_wine ok(size == 32, "got %u\n", size);
+ todo_wine ok(!memcmp(ciphertext, expected4, sizeof(expected4)), "wrong data\n");
+ todo_wine ok(!memcmp(tag, expected_tag, sizeof(expected_tag)), "wrong tag\n");
+ for (i = 0; i < 32; i++)
+ todo_wine ok(ciphertext[i] == expected4[i], "%u: %02x != %02x\n", i, ciphertext[i], expected4[i]);
+ for (i = 0; i < 16; i++)
+ todo_wine ok(tag[i] == expected_tag[i], "%u: %02x != %02x\n", i, tag[i], expected_tag[i]);
+
+ /* input size is not multiple of block size */
+ size = 0;
+ memcpy(ivbuf, iv, sizeof(iv));
+ memset(ciphertext, 0xff, sizeof(ciphertext));
+ memset(tag, 0xff, sizeof(tag));
+ ret = pBCryptEncrypt(key, data2, 24, &auth_info, ivbuf, 16, ciphertext, 24, &size, 0);
+ todo_wine ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ todo_wine ok(size == 24, "got %u\n", size);
+ todo_wine ok(!memcmp(ciphertext, expected4, 24), "wrong data\n");
+ todo_wine ok(!memcmp(tag, expected_tag2, sizeof(expected_tag2)), "wrong tag\n");
+ for (i = 0; i < 24; i++)
+ todo_wine ok(ciphertext[i] == expected4[i], "%u: %02x != %02x\n", i, ciphertext[i], expected4[i]);
+ for (i = 0; i < 16; i++)
+ todo_wine ok(tag[i] == expected_tag2[i], "%u: %02x != %02x\n", i, tag[i], expected_tag2[i]);
+
+ /* test with padding */
+ memcpy(ivbuf, iv, sizeof(iv));
+ memset(ciphertext, 0, sizeof(ciphertext));
+ ret = pBCryptEncrypt(key, data2, 32, &auth_info, ivbuf, 16, ciphertext, 32, &size, BCRYPT_BLOCK_PADDING);
+ todo_wine ok(ret == STATUS_BUFFER_TOO_SMALL, "got %08x\n", ret);
+
+ memcpy(ivbuf, iv, sizeof(iv));
+ memset(ciphertext, 0, sizeof(ciphertext));
+ ret = pBCryptEncrypt(key, data2, 32, &auth_info, ivbuf, 16, ciphertext, 48, &size, BCRYPT_BLOCK_PADDING);
+ todo_wine ok(ret == STATUS_INVALID_PARAMETER, "got %08x\n", ret);
+
+ ret = pBCryptDestroyKey(key);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ HeapFree(GetProcessHeap(), 0, buf);
+
ret = pBCryptCloseAlgorithmProvider(aes, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
}
static void test_BCryptDecrypt(void)
{
+ static UCHAR nonce[] =
+ {0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60};
static UCHAR secret[] =
{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
static UCHAR iv[] =
@@ -704,6 +808,12 @@ static void test_BCryptDecrypt(void)
{0xc6,0xa1,0x3b,0x37,0x87,0x8f,0x5b,0x82,0x6f,0x4f,0x81,0x62,0xa1,0xc8,0xd8,0x79,
0xb1,0xa2,0x92,0x73,0xbe,0x2c,0x42,0x07,0xa5,0xac,0xe3,0x93,0x39,0x8c,0xb6,0xfb,
0x87,0x5d,0xea,0xa3,0x7e,0x0f,0xde,0xfa,0xd9,0xec,0x6c,0x4e,0x3c,0x76,0x86,0xe4};
+ static UCHAR ciphertext4[] =
+ {0xe1,0x82,0xc3,0xc0,0x24,0xfb,0x86,0x85,0xf3,0xf1,0x2b,0x7d,0x09,0xb4,0x73,0x67,
+ 0x86,0x64,0xc3,0xfe,0xa3,0x07,0x61,0xf8,0x16,0xc9,0x78,0x7f,0xe7,0xb1,0xc4,0x94};
+ static UCHAR tag[] =
+ {0x89,0xb3,0x92,0x00,0x39,0x20,0x09,0xb4,0x6a,0xd6,0xaf,0xca,0x4b,0x5b,0xfd,0xd0};
+ BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO auth_info;
BCRYPT_KEY_LENGTHS_STRUCT key_lengths;
BCRYPT_ALG_HANDLE aes;
BCRYPT_KEY_HANDLE key;
@@ -723,6 +833,10 @@ static void test_BCryptDecrypt(void)
ok(key_lengths.dwMaxLength == 256, "Expected 256, got %d\n", key_lengths.dwMaxLength);
ok(key_lengths.dwIncrement == 64, "Expected 64, got %d\n", key_lengths.dwIncrement);
+ /******************
+ * AES - CBC mode *
+ ******************/
+
len = 0xdeadbeef;
size = sizeof(len);
ret = pBCryptGetProperty(aes, BCRYPT_OBJECT_LENGTH, (UCHAR *)&len, sizeof(len), &size, 0);
@@ -820,6 +934,45 @@ static void test_BCryptDecrypt(void)
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
HeapFree(GetProcessHeap(), 0, buf);
+ /******************
+ * AES - GCM mode *
+ ******************/
+
+ ret = BCryptSetProperty(aes, BCRYPT_CHAINING_MODE, (UCHAR*)BCRYPT_CHAIN_MODE_GCM, sizeof(BCRYPT_CHAIN_MODE_GCM), 0);
+ todo_wine ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
+ buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
+ ret = pBCryptGenerateSymmetricKey(aes, &key, buf, len, secret, sizeof(secret), 0);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
+ memset(&auth_info, 0, sizeof(auth_info));
+ auth_info.cbSize = sizeof(auth_info);
+ auth_info.dwInfoVersion = 1;
+ auth_info.pbNonce = nonce;
+ auth_info.cbNonce = sizeof(nonce);
+ auth_info.pbTag = tag;
+ auth_info.cbTag = sizeof(tag);
+
+ /* input size is a multiple of block size */
+ size = 0;
+ memcpy(ivbuf, iv, sizeof(iv));
+ memset(plaintext, 0, sizeof(plaintext));
+ ret = pBCryptDecrypt(key, ciphertext4, 32, &auth_info, ivbuf, 16, plaintext, 32, &size, 0);
+ todo_wine ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ todo_wine ok(size == 32, "got %u\n", size);
+ todo_wine ok(!memcmp(plaintext, expected3, sizeof(expected3)), "wrong data\n");
+
+ /* test with wrong tag */
+ memcpy(ivbuf, iv, sizeof(iv));
+ auth_info.pbTag = iv; /* wrong tag */
+ ret = pBCryptDecrypt(key, ciphertext4, 32, &auth_info, ivbuf, 16, plaintext, 32, &size, 0);
+ todo_wine ok(ret == STATUS_AUTH_TAG_MISMATCH, "got %08x\n", ret);
+ todo_wine ok(size == 32, "got %u\n", size);
+
+ ret = pBCryptDestroyKey(key);
+ ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+ HeapFree(GetProcessHeap(), 0, buf);
+
ret = pBCryptCloseAlgorithmProvider(aes, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
}
diff --git a/include/bcrypt.h b/include/bcrypt.h
index 1be9b85..d0b29c7 100644
--- a/include/bcrypt.h
+++ b/include/bcrypt.h
@@ -96,7 +96,29 @@ typedef struct __BCRYPT_KEY_LENGTHS_STRUCT
ULONG dwMinLength;
ULONG dwMaxLength;
ULONG dwIncrement;
-} BCRYPT_KEY_LENGTHS_STRUCT;
+} BCRYPT_KEY_LENGTHS_STRUCT, BCRYPT_AUTH_TAG_LENGTHS_STRUCT;
+
+typedef struct _BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO
+{
+ ULONG cbSize;
+ ULONG dwInfoVersion;
+ UCHAR *pbNonce;
+ ULONG cbNonce;
+ UCHAR *pbAuthData;
+ ULONG cbAuthData;
+ UCHAR *pbTag;
+ ULONG cbTag;
+ UCHAR *pbMacContext;
+ ULONG cbMacContext;
+ ULONG cbAAD;
+ ULONGLONG cbData;
+ ULONG dwFlags;
+} BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO, *PBCRYPT_AUTHENTICATED_CIPHER_MODE_INFO;
+
+#define BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO_VERSION 1
+
+#define BCRYPT_AUTH_MODE_CHAIN_CALLS_FLAG 0x00000001
+#define BCRYPT_AUTH_MODE_IN_PROGRESS_FLAG 0x00000002
typedef struct _CRYPT_INTERFACE_REG
{
--
1.9.1
2
1
[PATCH 2/8] [v2] wsdapi: Add stub implementation of IWSDiscoveryPublisher_PublishEx.
by Owen Rudge 19 Mar '18
by Owen Rudge 19 Mar '18
19 Mar '18
Signed-off-by: Owen Rudge <orudge(a)codeweavers.com>
---
dlls/wsdapi/Makefile.in | 1 +
dlls/wsdapi/discovery.c | 40 ++++++++++----------------
dlls/wsdapi/soap.c | 65
+++++++++++++++++++++++++++++++++++++++++++
dlls/wsdapi/wsdapi_internal.h | 24 ++++++++++++++++
4 files changed, 104 insertions(+), 26 deletions(-)
create mode 100644 dlls/wsdapi/soap.c
2
1
19 Mar '18
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/shell32/tests/shlfolder.c | 29 +++++++++++++++++++++++++++++
include/shlobj.h | 1 +
include/shobjidl.idl | 14 ++++++++++++++
3 files changed, 44 insertions(+)
diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c
index 1b140c0501..95ebb92e5c 100644
--- a/dlls/shell32/tests/shlfolder.c
+++ b/dlls/shell32/tests/shlfolder.c
@@ -5217,6 +5217,34 @@ static void test_GetDefaultSearchGUID(void)
CoUninitialize();
}
+static void test_SHLimitInputEdit(void)
+{
+ IShellFolder *desktop;
+ HRESULT hr;
+ HWND hwnd;
+
+ hr = SHGetDesktopFolder(&desktop);
+ ok(hr == S_OK, "Failed to get desktop folder, hr %#x.\n", hr);
+
+ hr = SHLimitInputEdit(NULL, desktop);
+todo_wine
+ ok(hr == E_FAIL, "Unexpected hr %#x.\n", hr);
+
+ hwnd = CreateWindowA("EDIT", NULL, WS_VISIBLE, 0, 0, 100, 30, NULL, NULL, NULL, NULL);
+ ok(hwnd != NULL, "Failed to create Edit control.\n");
+
+ hr = SHLimitInputEdit(hwnd, desktop);
+todo_wine
+ ok(hr == S_OK, "Failed to set input limits, hr %#x.\n", hr);
+
+ hr = SHLimitInputEdit(hwnd, desktop);
+todo_wine
+ ok(hr == S_OK, "Failed to set input limits, hr %#x.\n", hr);
+
+ DestroyWindow(hwnd);
+ IShellFolder_Release(desktop);
+}
+
START_TEST(shlfolder)
{
init_function_pointers();
@@ -5258,6 +5286,7 @@ START_TEST(shlfolder)
test_DataObject();
test_GetDefaultColumn();
test_GetDefaultSearchGUID();
+ test_SHLimitInputEdit();
OleUninitialize();
}
diff --git a/include/shlobj.h b/include/shlobj.h
index 09efc18ee5..7cdb4f873d 100644
--- a/include/shlobj.h
+++ b/include/shlobj.h
@@ -1801,6 +1801,7 @@ HRESULT WINAPI CDefFolderMenu_Create2(LPCITEMIDLIST pidlFolder, HWND hwnd, UINT
IContextMenu **ppcm);
int WINAPI PickIconDlg(HWND owner, WCHAR *path, UINT path_len, int *index);
+HRESULT WINAPI SHLimitInputEdit(HWND hwnd, IShellFolder *folder);
#include <poppack.h>
diff --git a/include/shobjidl.idl b/include/shobjidl.idl
index 5e4da5de28..e0fe01c2c1 100644
--- a/include/shobjidl.idl
+++ b/include/shobjidl.idl
@@ -3699,6 +3699,20 @@ typedef enum ASSOC_FILTER
} ASSOC_FILTER;
cpp_quote("HRESULT WINAPI SHAssocEnumHandlers(PCWSTR extra, ASSOC_FILTER filter, IEnumAssocHandlers **handlersenum);")
+[
+ uuid(1df0d7f1-b267-4d28-8b10-12e23202a5c4),
+]
+interface IItemNameLimits : IUnknown
+{
+ HRESULT GetValidCharacters(
+ [out, string] LPWSTR *validchars,
+ [out, string] LPWSTR *invalidchars);
+
+ HRESULT GetMaxLength(
+ [in, string] LPCWSTR name,
+ [out] int *max_length);
+}
+
/*****************************************************************************
* ShellObjects typelibrary
*/
--
2.16.2
2
1
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/shell32/assoc.c | 2 +-
dlls/shell32/autocomplete.c | 2 +-
dlls/shell32/brsfolder.c | 6 ++----
dlls/shell32/classes.c | 2 +-
dlls/shell32/control.c | 34 +++++++++++++----------------
dlls/shell32/dde.c | 2 +-
dlls/shell32/dialogs.c | 4 ++--
dlls/shell32/recyclebin.c | 18 ++++++----------
dlls/shell32/shell32_main.c | 6 +++---
dlls/shell32/shell32_main.h | 2 ++
dlls/shell32/shelldispatch.c | 2 +-
dlls/shell32/shelllink.c | 13 +++++-------
dlls/shell32/shellole.c | 4 ++--
dlls/shell32/shellord.c | 8 +++----
dlls/shell32/shellpath.c | 47 ++++++++++++++++++++++-------------------
dlls/shell32/shfldr_desktop.c | 16 ++++++--------
dlls/shell32/shfldr_fs.c | 10 ++++-----
dlls/shell32/shfldr_netplaces.c | 9 +++-----
dlls/shell32/shfldr_unixfs.c | 10 ++++-----
dlls/shell32/shlexec.c | 16 +++++++-------
dlls/shell32/shlfileop.c | 11 +++++-----
dlls/shell32/shlmenu.c | 2 +-
dlls/shell32/shlview.c | 2 +-
dlls/shell32/systray.c | 11 +++++-----
dlls/shell32/xdg.c | 6 ++----
25 files changed, 114 insertions(+), 131 deletions(-)
diff --git a/dlls/shell32/assoc.c b/dlls/shell32/assoc.c
index a9eb70e933..d3f20c225b 100644
--- a/dlls/shell32/assoc.c
+++ b/dlls/shell32/assoc.c
@@ -676,7 +676,7 @@ get_friendly_name_fail:
case ASSOCSTR_SHELLEXTENSION:
{
static const WCHAR shellexW[] = {'S','h','e','l','l','E','x','\\',0};
- WCHAR keypath[sizeof(shellexW) / sizeof(shellexW[0]) + 39], guid[39];
+ WCHAR keypath[ARRAY_SIZE(shellexW) + 39], guid[39];
CLSID clsid;
HKEY hkey;
DWORD size;
diff --git a/dlls/shell32/autocomplete.c b/dlls/shell32/autocomplete.c
index b411c1b675..99ce23d040 100644
--- a/dlls/shell32/autocomplete.c
+++ b/dlls/shell32/autocomplete.c
@@ -123,7 +123,7 @@ static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam,
{
int len;
- GetWindowTextW( hwnd, hwndText, sizeof(hwndText)/sizeof(WCHAR));
+ GetWindowTextW(hwnd, hwndText, ARRAY_SIZE(hwndText));
switch(wParam) {
case VK_RETURN:
diff --git a/dlls/shell32/brsfolder.c b/dlls/shell32/brsfolder.c
index fc7b5b6b74..daddf1e9ec 100644
--- a/dlls/shell32/brsfolder.c
+++ b/dlls/shell32/brsfolder.c
@@ -82,8 +82,6 @@ static const LAYOUT_INFO g_layout_info[] =
{IDCANCEL, BF_BOTTOM|BF_RIGHT}
};
-#define LAYOUT_INFO_COUNT (sizeof(g_layout_info)/sizeof(g_layout_info[0]))
-
#define SUPPORTEDFLAGS (BIF_STATUSTEXT | \
BIF_BROWSEFORCOMPUTER | \
BIF_RETURNFSANCESTORS | \
@@ -667,7 +665,7 @@ static BOOL BrsFolder_OnCreate( HWND hWnd, browse_info *info )
{
RECT rcWnd;
- info->layout = LayoutInit(hWnd, g_layout_info, LAYOUT_INFO_COUNT);
+ info->layout = LayoutInit(hWnd, g_layout_info, ARRAY_SIZE(g_layout_info));
/* TODO: Windows allows shrinking the windows a bit */
GetWindowRect(hWnd, &rcWnd);
@@ -1012,7 +1010,7 @@ static INT_PTR CALLBACK BrsFolderDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
case WM_SIZE:
if (info->layout) /* new style dialogs */
- LayoutUpdate(hWnd, info->layout, g_layout_info, LAYOUT_INFO_COUNT);
+ LayoutUpdate(hWnd, info->layout, g_layout_info, ARRAY_SIZE(g_layout_info));
return 0;
case BFFM_SETSTATUSTEXTA:
diff --git a/dlls/shell32/classes.c b/dlls/shell32/classes.c
index 316abd53f5..653b55179e 100644
--- a/dlls/shell32/classes.c
+++ b/dlls/shell32/classes.c
@@ -187,7 +187,7 @@ BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LP
return FALSE;
ret = FALSE;
- if (HCR_GetDefaultVerbW(hkeyClass, szVerb, sTempVerb, sizeof(sTempVerb)/sizeof(sTempVerb[0])))
+ if (HCR_GetDefaultVerbW(hkeyClass, szVerb, sTempVerb, ARRAY_SIZE(sTempVerb)))
{
WCHAR sTemp[MAX_PATH];
lstrcpyW(sTemp, swShell);
diff --git a/dlls/shell32/control.c b/dlls/shell32/control.c
index 66fbf17954..6b86214bd8 100644
--- a/dlls/shell32/control.c
+++ b/dlls/shell32/control.c
@@ -124,10 +124,10 @@ CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
applet->info[i].icon = LoadIconW(applet->hModule, MAKEINTRESOURCEW(info.idIcon));
if (info.idName != CPL_DYNAMIC_RES)
LoadStringW(applet->hModule, info.idName,
- applet->info[i].name, sizeof(applet->info[i].name) / sizeof(WCHAR));
+ applet->info[i].name, ARRAY_SIZE(applet->info[i].name));
if (info.idInfo != CPL_DYNAMIC_RES)
LoadStringW(applet->hModule, info.idInfo,
- applet->info[i].info, sizeof(applet->info[i].info) / sizeof(WCHAR));
+ applet->info[i].info, ARRAY_SIZE(applet->info[i].info));
/* some broken control panels seem to return incorrect values in CPL_INQUIRE,
but proper data in CPL_NEWINQUIRE. if we get an empty string or a null
@@ -159,18 +159,16 @@ CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
memcpy(applet->info[i].info, newinfo.szInfo, sizeof(newinfo.szInfo));
memcpy(applet->info[i].helpfile, newinfo.szHelpFile, sizeof(newinfo.szHelpFile));
} else {
+ NEWCPLINFOA *infoA = (NEWCPLINFOA *)&newinfo;
+
if (info.idName == CPL_DYNAMIC_RES)
- MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szName,
- sizeof(((LPNEWCPLINFOA)&newinfo)->szName) / sizeof(CHAR),
- applet->info[i].name, sizeof(applet->info[i].name) / sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, infoA->szName, ARRAY_SIZE(infoA->szName),
+ applet->info[i].name, ARRAY_SIZE(applet->info[i].name));
if (info.idInfo == CPL_DYNAMIC_RES)
- MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szInfo,
- sizeof(((LPNEWCPLINFOA)&newinfo)->szInfo) / sizeof(CHAR),
- applet->info[i].info, sizeof(applet->info[i].info) / sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szHelpFile,
- sizeof(((LPNEWCPLINFOA)&newinfo)->szHelpFile) / sizeof(CHAR),
- applet->info[i].helpfile,
- sizeof(applet->info[i].helpfile) / sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, infoA->szInfo, ARRAY_SIZE(infoA->szInfo),
+ applet->info[i].info, ARRAY_SIZE(applet->info[i].info));
+ MultiByteToWideChar(CP_ACP, 0, infoA->szHelpFile, ARRAY_SIZE(infoA->szHelpFile),
+ applet->info[i].helpfile, ARRAY_SIZE(applet->info[i].helpfile));
}
}
}
@@ -229,7 +227,7 @@ static BOOL Control_CreateListView (CPanel *panel)
/* Name column */
lvc.iSubItem = 0;
lvc.cx = (ws.right - ws.left) / 3;
- LoadStringW(shell32_hInstance, IDS_CPANEL_NAME, buf, sizeof(buf) / sizeof(buf[0]));
+ LoadStringW(shell32_hInstance, IDS_CPANEL_NAME, buf, ARRAY_SIZE(buf));
if (ListView_InsertColumnW(panel->hWndListView, 0, &lvc) == -1)
return FALSE;
@@ -237,8 +235,7 @@ static BOOL Control_CreateListView (CPanel *panel)
/* Description column */
lvc.iSubItem = 1;
lvc.cx = ((ws.right - ws.left) / 3) * 2;
- LoadStringW(shell32_hInstance, IDS_CPANEL_DESCRIPTION, buf, sizeof(buf) /
- sizeof(buf[0]));
+ LoadStringW(shell32_hInstance, IDS_CPANEL_DESCRIPTION, buf, ARRAY_SIZE(buf));
if (ListView_InsertColumnW(panel->hWndListView, 1, &lvc) == -1)
return FALSE;
@@ -300,7 +297,7 @@ static void Control_WndProc_Create(HWND hWnd, const CREATESTRUCTW* cs)
mii.cbSize = sizeof(MENUITEMINFOW);
mii.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA;
mii.dwTypeData = applet->info[i].name;
- mii.cch = sizeof(applet->info[i].name) / sizeof(WCHAR);
+ mii.cch = ARRAY_SIZE(applet->info[i].name);
mii.wID = IDM_CPANEL_APPLET_BASE + menucount;
mii.dwItemData = (ULONG_PTR)item;
@@ -475,8 +472,7 @@ static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg,
HICON icon = LoadImageW(shell32_hInstance, MAKEINTRESOURCEW(IDI_SHELL_CONTROL_PANEL),
IMAGE_ICON, 48, 48, LR_SHARED);
- LoadStringW(shell32_hInstance, IDS_CPANEL_TITLE, appName,
- sizeof(appName) / sizeof(appName[0]));
+ LoadStringW(shell32_hInstance, IDS_CPANEL_TITLE, appName, ARRAY_SIZE(appName));
ShellAboutW(hWnd, appName, NULL, icon);
return 0;
@@ -616,7 +612,7 @@ static void Control_DoInterface(CPanel* panel, HWND hWnd, HINSTANCE hInst)
MSG msg;
WCHAR appName[MAX_STRING_LEN];
- LoadStringW(shell32_hInstance, IDS_CPANEL_TITLE, appName, sizeof(appName) / sizeof(appName[0]));
+ LoadStringW(shell32_hInstance, IDS_CPANEL_TITLE, appName, ARRAY_SIZE(appName));
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW|CS_VREDRAW;
diff --git a/dlls/shell32/dde.c b/dlls/shell32/dde.c
index 0283a45760..c54fe7854f 100644
--- a/dlls/shell32/dde.c
+++ b/dlls/shell32/dde.c
@@ -50,7 +50,7 @@ static DWORD dwDDEInst;
static const char *debugstr_hsz( HSZ hsz )
{
WCHAR buffer[256];
- if (!DdeQueryStringW( dwDDEInst, hsz, buffer, sizeof(buffer)/sizeof(WCHAR), CP_WINUNICODE ))
+ if (!DdeQueryStringW( dwDDEInst, hsz, buffer, ARRAY_SIZE(buffer), CP_WINUNICODE ))
return "<unknown>";
return debugstr_w( buffer );
}
diff --git a/dlls/shell32/dialogs.c b/dlls/shell32/dialogs.c
index 48321364d0..c6d8e95e96 100644
--- a/dlls/shell32/dialogs.c
+++ b/dlls/shell32/dialogs.c
@@ -499,8 +499,8 @@ static BOOL ConfirmDialog(HWND hWndOwner, UINT PromptId, UINT TitleId)
WCHAR Prompt[256];
WCHAR Title[256];
- LoadStringW(shell32_hInstance, PromptId, Prompt, sizeof(Prompt) / sizeof(WCHAR));
- LoadStringW(shell32_hInstance, TitleId, Title, sizeof(Title) / sizeof(WCHAR));
+ LoadStringW(shell32_hInstance, PromptId, Prompt, ARRAY_SIZE(Prompt));
+ LoadStringW(shell32_hInstance, TitleId, Title, ARRAY_SIZE(Title));
return MessageBoxW(hWndOwner, Prompt, Title, MB_YESNO|MB_ICONQUESTION) == IDYES;
}
diff --git a/dlls/shell32/recyclebin.c b/dlls/shell32/recyclebin.c
index 5d4725e425..0d80e6376d 100644
--- a/dlls/shell32/recyclebin.c
+++ b/dlls/shell32/recyclebin.c
@@ -200,13 +200,10 @@ static void DoRestore(RecycleBinMenu *This)
WCHAR message[100];
WCHAR caption[50];
if(_ILIsFolder(ILFindLastID(dest_pidl)))
- LoadStringW(shell32_hInstance,IDS_RECYCLEBIN_OVERWRITEFOLDER,
- message,sizeof(message)/sizeof(WCHAR));
+ LoadStringW(shell32_hInstance, IDS_RECYCLEBIN_OVERWRITEFOLDER, message, ARRAY_SIZE(message));
else
- LoadStringW(shell32_hInstance,IDS_RECYCLEBIN_OVERWRITEFILE,
- message,sizeof(message)/sizeof(WCHAR));
- LoadStringW(shell32_hInstance,IDS_RECYCLEBIN_OVERWRITE_CAPTION,
- caption,sizeof(caption)/sizeof(WCHAR));
+ LoadStringW(shell32_hInstance, IDS_RECYCLEBIN_OVERWRITEFILE, message, ARRAY_SIZE(message));
+ LoadStringW(shell32_hInstance, IDS_RECYCLEBIN_OVERWRITE_CAPTION, caption, ARRAY_SIZE(caption));
if(ShellMessageBoxW(shell32_hInstance,GetActiveWindow(),message,
caption,MB_YESNO|MB_ICONEXCLAMATION,
@@ -788,22 +785,19 @@ static HRESULT erase_items(HWND parent,const LPCITEMIDLIST * apidl, UINT cidl, B
WIN32_FIND_DATAW data;
TRASH_UnpackItemID(&((*apidl)->mkid),&data);
lstrcpynW(arg,data.cFileName,MAX_PATH);
- LoadStringW(shell32_hInstance,IDS_RECYCLEBIN_ERASEITEM,message,
- sizeof(message)/sizeof(WCHAR));
+ LoadStringW(shell32_hInstance, IDS_RECYCLEBIN_ERASEITEM, message, ARRAY_SIZE(message));
break;
}
default:
{
static const WCHAR format[]={'%','u','\0'};
- LoadStringW(shell32_hInstance,IDS_RECYCLEBIN_ERASEMULTIPLE,
- message,sizeof(message)/sizeof(WCHAR));
+ LoadStringW(shell32_hInstance, IDS_RECYCLEBIN_ERASEMULTIPLE, message, ARRAY_SIZE(message));
sprintfW(arg,format,cidl);
break;
}
}
- LoadStringW(shell32_hInstance,IDS_RECYCLEBIN_ERASE_CAPTION,caption,
- sizeof(caption)/sizeof(WCHAR));
+ LoadStringW(shell32_hInstance, IDS_RECYCLEBIN_ERASE_CAPTION, caption, ARRAY_SIZE(caption));
if(ShellMessageBoxW(shell32_hInstance,parent,message,caption,
MB_YESNO|MB_ICONEXCLAMATION,arg)!=IDYES)
return ret;
diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c
index dd0f6e71de..525eba4544 100644
--- a/dlls/shell32/shell32_main.c
+++ b/dlls/shell32/shell32_main.c
@@ -1075,15 +1075,15 @@ static INT_PTR CALLBACK AboutDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
if (info)
{
SendDlgItemMessageW(hWnd, stc1, STM_SETICON,(WPARAM)info->hIcon, 0);
- GetWindowTextW( hWnd, template, sizeof(template)/sizeof(WCHAR) );
+ GetWindowTextW( hWnd, template, ARRAY_SIZE(template) );
sprintfW( buffer, template, info->szApp );
SetWindowTextW( hWnd, buffer );
SetWindowTextW( GetDlgItem(hWnd, IDC_ABOUT_STATIC_TEXT1), info->szApp );
SetWindowTextW( GetDlgItem(hWnd, IDC_ABOUT_STATIC_TEXT2), info->szOtherStuff );
GetWindowTextW( GetDlgItem(hWnd, IDC_ABOUT_STATIC_TEXT3),
- template, sizeof(template)/sizeof(WCHAR) );
+ template, ARRAY_SIZE(template) );
MultiByteToWideChar( CP_UTF8, 0, wine_get_build_id(), -1,
- version, sizeof(version)/sizeof(WCHAR) );
+ version, ARRAY_SIZE(template) );
sprintfW( buffer, template, version );
SetWindowTextW( GetDlgItem(hWnd, IDC_ABOUT_STATIC_TEXT3), buffer );
hWndCtl = GetDlgItem(hWnd, IDC_ABOUT_LISTBOX);
diff --git a/dlls/shell32/shell32_main.h b/dlls/shell32/shell32_main.h
index 11a96309e8..d1b0e01cf1 100644
--- a/dlls/shell32/shell32_main.h
+++ b/dlls/shell32/shell32_main.h
@@ -39,6 +39,8 @@
#include "wine/unicode.h"
#include "wine/list.h"
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
+
/*******************************************
* global SHELL32.DLL variables
*/
diff --git a/dlls/shell32/shelldispatch.c b/dlls/shell32/shelldispatch.c
index 66635547ed..2835fad712 100644
--- a/dlls/shell32/shelldispatch.c
+++ b/dlls/shell32/shelldispatch.c
@@ -155,7 +155,7 @@ void release_typelib(void)
if (!typelib)
return;
- for (i = 0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
+ for (i = 0; i < ARRAY_SIZE(typeinfos); i++)
if (typeinfos[i])
ITypeInfo_Release(typeinfos[i]);
diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c
index ba04c8e288..e6774719b9 100644
--- a/dlls/shell32/shelllink.c
+++ b/dlls/shell32/shelllink.c
@@ -307,7 +307,7 @@ BOOL run_winemenubuilder( const WCHAR *args )
WCHAR app[MAX_PATH];
void *redir;
- GetSystemDirectoryW( app, MAX_PATH - sizeof(menubuilder)/sizeof(WCHAR) );
+ GetSystemDirectoryW( app, MAX_PATH - ARRAY_SIZE(menubuilder) );
strcatW( app, menubuilder );
len = (strlenW( app ) + strlenW( args ) + 1) * sizeof(WCHAR);
@@ -588,7 +588,7 @@ static HRESULT Stream_ReadChunk( IStream* stm, LPVOID *data )
static BOOL Stream_LoadVolume( LOCAL_VOLUME_INFO *vol, volume_info *volume )
{
- const int label_sz = sizeof volume->label/sizeof volume->label[0];
+ const int label_sz = ARRAY_SIZE(volume->label);
LPSTR label;
int len;
@@ -782,14 +782,11 @@ static HRESULT WINAPI IPersistStream_fnLoad(
if (TRACE_ON(shell))
{
WCHAR sTemp[MAX_PATH];
- GetDateFormatW(LOCALE_USER_DEFAULT,DATE_SHORTDATE, &This->time1,
- NULL, sTemp, sizeof(sTemp)/sizeof(*sTemp));
+ GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &This->time1, NULL, sTemp, ARRAY_SIZE(sTemp));
TRACE("-- time1: %s\n", debugstr_w(sTemp) );
- GetDateFormatW(LOCALE_USER_DEFAULT,DATE_SHORTDATE, &This->time2,
- NULL, sTemp, sizeof(sTemp)/sizeof(*sTemp));
+ GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &This->time2, NULL, sTemp, ARRAY_SIZE(sTemp));
TRACE("-- time2: %s\n", debugstr_w(sTemp) );
- GetDateFormatW(LOCALE_USER_DEFAULT,DATE_SHORTDATE, &This->time3,
- NULL, sTemp, sizeof(sTemp)/sizeof(*sTemp));
+ GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &This->time3, NULL, sTemp, ARRAY_SIZE(sTemp));
TRACE("-- time3: %s\n", debugstr_w(sTemp) );
}
diff --git a/dlls/shell32/shellole.c b/dlls/shell32/shellole.c
index c79242199b..3fe96801aa 100644
--- a/dlls/shell32/shellole.c
+++ b/dlls/shell32/shellole.c
@@ -150,7 +150,7 @@ HRESULT WINAPI SHCoCreateInstance(
}
/* we look up the dll path in the registry */
- SHStringFromGUIDW(myclsid, sClassID, sizeof(sClassID)/sizeof(WCHAR));
+ SHStringFromGUIDW(myclsid, sClassID, ARRAY_SIZE(sClassID));
lstrcpyW(sKeyName, sCLSID);
lstrcatW(sKeyName, sClassID);
lstrcatW(sKeyName, sInProcServer32);
@@ -258,7 +258,7 @@ DWORD WINAPI SHCLSIDFromStringA (LPCSTR clsid, CLSID *id)
{
WCHAR buffer[40];
TRACE("(%p(%s) %p)\n", clsid, clsid, id);
- if (!MultiByteToWideChar( CP_ACP, 0, clsid, -1, buffer, sizeof(buffer)/sizeof(WCHAR) ))
+ if (!MultiByteToWideChar( CP_ACP, 0, clsid, -1, buffer, ARRAY_SIZE(buffer) ))
return CO_E_CLASSSTRING;
return CLSIDFromString( buffer, id );
}
diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c
index 6bf29a1fbd..058e57e5b5 100644
--- a/dlls/shell32/shellord.c
+++ b/dlls/shell32/shellord.c
@@ -433,12 +433,12 @@ int WINAPIV ShellMessageBoxW(
hInstance,hWnd,lpText,lpCaption,uType);
if (IS_INTRESOURCE(lpCaption))
- LoadStringW(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle)/sizeof(szTitle[0]));
+ LoadStringW(hInstance, LOWORD(lpCaption), szTitle, ARRAY_SIZE(szTitle));
else
pszTitle = lpCaption;
if (IS_INTRESOURCE(lpText))
- LoadStringW(hInstance, LOWORD(lpText), szText, sizeof(szText)/sizeof(szText[0]));
+ LoadStringW(hInstance, LOWORD(lpText), szText, ARRAY_SIZE(szText));
else
pszText = lpText;
@@ -1774,7 +1774,7 @@ HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_
dwIndex = 0;
do
{
- dwHandlerLen = sizeof(szHandler) / sizeof(szHandler[0]);
+ dwHandlerLen = ARRAY_SIZE(szHandler);
lRet = RegEnumKeyExW(hkPropSheetHandlers, dwIndex++, szHandler, &dwHandlerLen, NULL, NULL, NULL, NULL);
if (lRet != ERROR_SUCCESS)
{
@@ -1793,7 +1793,7 @@ HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_
if (SHGetValueW(hkPropSheetHandlers, szHandler, NULL, NULL, szClsidHandler, &dwClsidSize) == ERROR_SUCCESS)
{
/* Force a NULL-termination and convert the string */
- szClsidHandler[(sizeof(szClsidHandler) / sizeof(szClsidHandler[0])) - 1] = 0;
+ szClsidHandler[ARRAY_SIZE(szClsidHandler) - 1] = 0;
lRet = SHCLSIDFromStringW(szClsidHandler, &clsid);
}
}
diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c
index fdd9c4087a..e14f533bb9 100644
--- a/dlls/shell32/shellpath.c
+++ b/dlls/shell32/shellpath.c
@@ -3421,8 +3421,9 @@ static HRESULT _SHGetDefaultValue(BYTE folder, LPWSTR pszPath)
TRACE("0x%02x,%p\n", folder, pszPath);
- if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]))
+ if (folder >= ARRAY_SIZE(CSIDL_Data))
return E_INVALIDARG;
+
if (!pszPath)
return E_INVALIDARG;
@@ -3508,7 +3509,7 @@ static HRESULT _SHGetCurrentVersionPath(DWORD dwFlags, BYTE folder,
TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
- if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]))
+ if (folder >= ARRAY_SIZE(CSIDL_Data))
return E_INVALIDARG;
if (CSIDL_Data[folder].type != CSIDL_Type_CurrVer)
return E_INVALIDARG;
@@ -3612,7 +3613,7 @@ static HRESULT _SHGetUserProfilePath(HANDLE hToken, DWORD dwFlags, BYTE folder,
TRACE("%p,0x%08x,0x%02x,%p\n", hToken, dwFlags, folder, pszPath);
- if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]))
+ if (folder >= ARRAY_SIZE(CSIDL_Data))
return E_INVALIDARG;
if (CSIDL_Data[folder].type != CSIDL_Type_User)
return E_INVALIDARG;
@@ -3684,7 +3685,7 @@ static HRESULT _SHGetAllUsersProfilePath(DWORD dwFlags, BYTE folder,
TRACE("0x%08x,0x%02x,%p\n", dwFlags, folder, pszPath);
- if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]))
+ if (folder >= ARRAY_SIZE(CSIDL_Data))
return E_INVALIDARG;
if (CSIDL_Data[folder].type != CSIDL_Type_AllUsers && CSIDL_Data[folder].type != CSIDL_Type_ProgramData)
return E_INVALIDARG;
@@ -3997,7 +3998,7 @@ HRESULT WINAPI SHGetFolderPathAndSubDirW(
if (pszPath)
*pszPath = '\0';
- if (folder >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]))
+ if (folder >= ARRAY_SIZE(CSIDL_Data))
return E_INVALIDARG;
if ((SHGFP_TYPE_CURRENT != dwFlags) && (SHGFP_TYPE_DEFAULT != dwFlags))
return E_INVALIDARG;
@@ -4293,7 +4294,7 @@ static HRESULT _SHRegisterUserShellFolders(BOOL bDefault)
}
hr = _SHRegisterFolders(hRootKey, hToken, pUserShellFolderPath,
- pShellFolderPath, folders, sizeof(folders) / sizeof(folders[0]));
+ pShellFolderPath, folders, ARRAY_SIZE(folders));
TRACE("returning 0x%08x\n", hr);
return hr;
}
@@ -4318,7 +4319,7 @@ static HRESULT _SHRegisterCommonShellFolders(void)
TRACE("\n");
hr = _SHRegisterFolders(HKEY_LOCAL_MACHINE, NULL, szSHUserFolders,
- szSHFolders, folders, sizeof(folders) / sizeof(folders[0]));
+ szSHFolders, folders, ARRAY_SIZE(folders));
TRACE("returning 0x%08x\n", hr);
return hr;
}
@@ -4411,7 +4412,7 @@ static void _SHCreateSymbolicLinks(void)
const WCHAR* MyOSXStuffW[] = { PicturesW, MoviesW, MusicW };
int acsidlMyStuff[] = { CSIDL_MYPICTURES, CSIDL_MYVIDEO, CSIDL_MYMUSIC };
static const char * const xdg_dirs[] = { "PICTURES", "VIDEOS", "MUSIC", "DOCUMENTS", "DESKTOP" };
- static const unsigned int num = sizeof(xdg_dirs) / sizeof(xdg_dirs[0]);
+ static const unsigned int num = ARRAY_SIZE(xdg_dirs);
WCHAR wszTempPath[MAX_PATH];
char szPersonalTarget[FILENAME_MAX], *pszPersonal;
char szMyStuffTarget[FILENAME_MAX], *pszMyStuff;
@@ -4446,7 +4447,7 @@ static void _SHCreateSymbolicLinks(void)
* 'My Videos' and 'My Music' subfolders or fail silently if
* they already exist.
*/
- for (i = 0; i < sizeof(aidsMyStuff)/sizeof(*aidsMyStuff); i++)
+ for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++)
{
strcpy(szMyStuffTarget, szPersonalTarget);
if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])))
@@ -4486,7 +4487,7 @@ static void _SHCreateSymbolicLinks(void)
* in '%USERPROFILE%\\My Documents' or fail silently if they already exist. */
pszHome = NULL;
strcpy(szPersonalTarget, pszPersonal);
- for (i = 0; i < sizeof(aidsMyStuff)/sizeof(aidsMyStuff[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(aidsMyStuff); i++) {
strcpy(szMyStuffTarget, szPersonalTarget);
if (_SHAppendToUnixPath(szMyStuffTarget, MAKEINTRESOURCEW(aidsMyStuff[i])))
mkdir(szMyStuffTarget, 0777);
@@ -4494,7 +4495,7 @@ static void _SHCreateSymbolicLinks(void)
}
/* Create symbolic links for 'My Pictures', 'My Videos' and 'My Music'. */
- for (i=0; i < sizeof(aidsMyStuff)/sizeof(aidsMyStuff[0]); i++)
+ for (i=0; i < ARRAY_SIZE(aidsMyStuff); i++)
{
/* Create the current 'My Whatever' folder and get its unix path. */
hr = SHGetFolderPathW(NULL, acsidlMyStuff[i]|CSIDL_FLAG_CREATE, NULL,
@@ -4655,11 +4656,11 @@ static HRESULT set_folder_attributes(void)
};
unsigned int i;
- WCHAR buffer[39 + (sizeof(clsidW) + sizeof(shellfolderW)) / sizeof(WCHAR)];
+ WCHAR buffer[39 + ARRAY_SIZE(clsidW) + ARRAY_SIZE(shellfolderW)];
LONG res;
HKEY hkey;
- for (i = 0; i < sizeof(folders)/sizeof(folders[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(folders); i++)
{
strcpyW( buffer, clsidW );
StringFromGUID2( folders[i].clsid, buffer + strlenW(buffer), 39 );
@@ -4855,7 +4856,7 @@ HRESULT WINAPI SHGetSpecialFolderLocation(
static int csidl_from_id( const KNOWNFOLDERID *id )
{
int i;
- for (i = 0; i < sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(CSIDL_Data); i++)
if (IsEqualGUID( CSIDL_Data[i].id, id )) return i;
return -1;
}
@@ -5049,7 +5050,7 @@ static HRESULT get_known_folder_registry_path(
TRACE("(%s, %s, %p)\n", debugstr_guid(rfid), debugstr_w(lpStringGuid), lpPath);
if(rfid)
- StringFromGUID2(rfid, sGuid, sizeof(sGuid)/sizeof(sGuid[0]));
+ StringFromGUID2(rfid, sGuid, ARRAY_SIZE(sGuid));
else
lstrcpyW(sGuid, lpStringGuid);
@@ -5178,7 +5179,7 @@ static HRESULT redirect_known_folder(
if(SUCCEEDED(hr))
{
- StringFromGUID2(rfid, sGuid, sizeof(sGuid)/sizeof(sGuid[0]));
+ StringFromGUID2(rfid, sGuid, ARRAY_SIZE(sGuid));
hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, sGuid, 0, REG_SZ, (LPBYTE)pszTargetPath, (lstrlenW(pszTargetPath)+1)*sizeof(WCHAR)));
@@ -5479,7 +5480,7 @@ static HRESULT get_known_folder_path_by_id(
/* if this is registry-registered known folder, get path from registry */
if(lpRegistryPath)
{
- StringFromGUID2(folderId, sGuid, sizeof(sGuid)/sizeof(sGuid[0]));
+ StringFromGUID2(folderId, sGuid, ARRAY_SIZE(sGuid));
hr = get_known_folder_path(sGuid, lpRegistryPath, ppszPath);
}
@@ -5709,7 +5710,7 @@ static HRESULT WINAPI foldermanager_FolderIdFromCsidl(
{
TRACE("%d, %p\n", nCsidl, pfid);
- if (nCsidl >= sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]))
+ if (nCsidl >= ARRAY_SIZE(CSIDL_Data))
return E_INVALIDARG;
*pfid = *CSIDL_Data[nCsidl].id;
return S_OK;
@@ -5879,7 +5880,7 @@ static HRESULT register_folder(const KNOWNFOLDERID *rfid, const KNOWNFOLDER_DEFI
if(SUCCEEDED(hr) && !IsEqualGUID(&pKFD->fidParent, &GUID_NULL))
{
WCHAR sParentGuid[39];
- StringFromGUID2(&pKFD->fidParent, sParentGuid, sizeof(sParentGuid)/sizeof(sParentGuid[0]));
+ StringFromGUID2(&pKFD->fidParent, sParentGuid, ARRAY_SIZE(sParentGuid));
/* this known folder has parent folder */
hr = HRESULT_FROM_WIN32(RegSetValueExW(hKey, szParentFolder, 0, REG_SZ, (LPBYTE)sParentGuid, sizeof(sParentGuid)));
@@ -5985,7 +5986,7 @@ static HRESULT foldermanager_create( void **ppv )
fm->refs = 1;
fm->num_ids = 0;
- for (i = 0; i < sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(CSIDL_Data); i++)
{
if (!IsEqualGUID( CSIDL_Data[i].id, &GUID_NULL )) fm->num_ids++;
}
@@ -5995,7 +5996,7 @@ static HRESULT foldermanager_create( void **ppv )
heap_free( fm );
return E_OUTOFMEMORY;
}
- for (i = j = 0; i < sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]); i++)
+ for (i = j = 0; i < ARRAY_SIZE(CSIDL_Data); i++)
{
if (!IsEqualGUID( CSIDL_Data[i].id, &GUID_NULL ))
{
@@ -6091,7 +6092,9 @@ HRESULT WINAPI SHGetKnownFolderItem(REFKNOWNFOLDERID rfid, KNOWN_FOLDER_FLAG fla
static void register_system_knownfolders(void)
{
int i;
- for(i = 0; i < sizeof(CSIDL_Data) / sizeof(CSIDL_Data[0]); ++i){
+
+ for (i = 0; i < ARRAY_SIZE(CSIDL_Data); ++i)
+ {
const CSIDL_DATA *folder = &CSIDL_Data[i];
if(folder->pszName){
KNOWNFOLDER_DEFINITION kfd;
diff --git a/dlls/shell32/shfldr_desktop.c b/dlls/shell32/shfldr_desktop.c
index 880291c8ef..d0b97c69e6 100644
--- a/dlls/shell32/shfldr_desktop.c
+++ b/dlls/shell32/shfldr_desktop.c
@@ -94,8 +94,6 @@ static const shvheader desktop_header[] =
{ &FMTID_Storage, PID_STG_ATTRIBUTES, IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5 },
};
-#define DESKTOPSHELLVIEWCOLUMNS sizeof(desktop_header)/sizeof(shvheader)
-
/**************************************************************************
* ISF_Desktop_fnQueryInterface
*
@@ -289,14 +287,14 @@ static void add_shell_namespace_extensions(IEnumIDListImpl *list, HKEY root)
static const WCHAR clsidfmtW[] = {'C','L','S','I','D','\\','%','s','\\',
'S','h','e','l','l','F','o','l','d','e','r',0};
static const WCHAR attributesW[] = {'A','t','t','r','i','b','u','t','e','s',0};
- WCHAR guid[39], clsidkeyW[sizeof(clsidfmtW)/sizeof(*clsidfmtW) + 39];
+ WCHAR guid[39], clsidkeyW[ARRAY_SIZE(clsidfmtW) + 39];
DWORD size, i = 0;
HKEY hkey;
if (RegOpenKeyExW(root, Desktop_NameSpaceW, 0, KEY_READ, &hkey))
return;
- size = sizeof(guid)/sizeof(guid[0]);
+ size = ARRAY_SIZE(guid);
while (!RegEnumKeyExW(hkey, i++, guid, &size, 0, NULL, NULL, NULL))
{
DWORD attributes, value_size = sizeof(attributes);
@@ -308,7 +306,7 @@ static void add_shell_namespace_extensions(IEnumIDListImpl *list, HKEY root)
if (!(attributes & SFGAO_NONENUMERATED))
AddToEnumList(list, _ILCreateGuidFromStrW(guid));
- size = sizeof(guid)/sizeof(guid[0]);
+ size = ARRAY_SIZE(guid);
}
RegCloseKey(hkey);
@@ -784,8 +782,8 @@ static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState (
TRACE ("(%p)->(%d %p)\n", This, iColumn, pcsFlags);
- if (!pcsFlags || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
- return E_INVALIDARG;
+ if (!pcsFlags || iColumn >= ARRAY_SIZE(desktop_header))
+ return E_INVALIDARG;
*pcsFlags = desktop_header[iColumn].pcsFlags;
@@ -809,7 +807,7 @@ static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface,
TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
- if (!psd || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
+ if (!psd || iColumn >= ARRAY_SIZE(desktop_header))
return E_INVALIDARG;
if (!pidl)
@@ -846,7 +844,7 @@ static HRESULT WINAPI ISF_Desktop_fnMapColumnToSCID(IShellFolder2 *iface, UINT c
TRACE("(%p)->(%u %p)\n", This, column, scid);
- if (column >= DESKTOPSHELLVIEWCOLUMNS)
+ if (column >= ARRAY_SIZE(desktop_header))
return E_INVALIDARG;
return shellfolder_map_column_to_scid(desktop_header, column, scid);
diff --git a/dlls/shell32/shfldr_fs.c b/dlls/shell32/shfldr_fs.c
index 1e7d1f2629..66150f4ce8 100644
--- a/dlls/shell32/shfldr_fs.c
+++ b/dlls/shell32/shfldr_fs.c
@@ -1089,8 +1089,8 @@ ISFHelper_fnGetUniqueName (ISFHelper * iface, LPWSTR pwszName, UINT uLen)
TRACE ("(%p)(%p %u)\n", This, pwszName, uLen);
- LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, sizeof(wszNewFolder)/sizeof(WCHAR));
- if (uLen < sizeof(wszNewFolder)/sizeof(WCHAR) + 3)
+ LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, ARRAY_SIZE(wszNewFolder));
+ if (uLen < ARRAY_SIZE(wszNewFolder) + 3)
return E_POINTER;
lstrcpynW (pwszName, wszNewFolder, uLen);
@@ -1180,10 +1180,8 @@ ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCWSTR pwszName,
WCHAR wszCaption[256];
/* Cannot Create folder because of permissions */
- LoadStringW (shell32_hInstance, IDS_CREATEFOLDER_DENIED, wszTempText,
- sizeof (wszTempText)/sizeof (wszTempText[0]));
- LoadStringW (shell32_hInstance, IDS_CREATEFOLDER_CAPTION, wszCaption,
- sizeof (wszCaption)/sizeof (wszCaption[0]));
+ LoadStringW (shell32_hInstance, IDS_CREATEFOLDER_DENIED, wszTempText, ARRAY_SIZE(wszTempText));
+ LoadStringW (shell32_hInstance, IDS_CREATEFOLDER_CAPTION, wszCaption, ARRAY_SIZE(wszCaption));
sprintfW (wszText, wszTempText, wszNewDir);
MessageBoxW (hwnd, wszText, wszCaption, MB_OK | MB_ICONEXCLAMATION);
}
diff --git a/dlls/shell32/shfldr_netplaces.c b/dlls/shell32/shfldr_netplaces.c
index 471abd879e..71b21c5e73 100644
--- a/dlls/shell32/shfldr_netplaces.c
+++ b/dlls/shell32/shfldr_netplaces.c
@@ -79,8 +79,6 @@ static const shvheader networkplaces_header[] =
{ NULL, 0, IDS_SHV_COLUMN9, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
};
-#define NETWORKPLACESSHELLVIEWCOLUMNS sizeof(networkplaces_header)/sizeof(shvheader)
-
/**************************************************************************
* ISF_NetworkPlaces_Constructor
*/
@@ -199,8 +197,7 @@ static HRESULT WINAPI ISF_NetworkPlaces_fnParseDisplayName (IShellFolder2 * ifac
szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
len = strlenW(szElement);
- if (len == sizeof(wszEntireNetwork)/sizeof(wszEntireNetwork[0]) &&
- !strncmpiW(szElement, wszEntireNetwork, sizeof(wszEntireNetwork)/sizeof(wszEntireNetwork[0])))
+ if (len == ARRAY_SIZE(wszEntireNetwork) && !strncmpiW(szElement, wszEntireNetwork, ARRAY_SIZE(wszEntireNetwork)))
{
pidlTemp = _ILCreateEntireNetwork();
if (pidlTemp)
@@ -534,7 +531,7 @@ static HRESULT WINAPI ISF_NetworkPlaces_fnGetDefaultColumnState (
TRACE ("(%p)->(%d %p)\n", This, iColumn, pcsFlags);
- if (!pcsFlags || iColumn >= NETWORKPLACESSHELLVIEWCOLUMNS)
+ if (!pcsFlags || iColumn >= ARRAY_SIZE(networkplaces_header))
return E_INVALIDARG;
*pcsFlags = networkplaces_header[iColumn].pcsFlags;
@@ -567,7 +564,7 @@ static HRESULT WINAPI ISF_NetworkPlaces_fnMapColumnToSCID (IShellFolder2 *iface,
TRACE("(%p)->(%u %p)\n", This, column, scid);
- if (column >= NETWORKPLACESSHELLVIEWCOLUMNS)
+ if (column >= ARRAY_SIZE(networkplaces_header))
return E_INVALIDARG;
return shellfolder_map_column_to_scid(networkplaces_header, column, scid);
diff --git a/dlls/shell32/shfldr_unixfs.c b/dlls/shell32/shfldr_unixfs.c
index cde815a99d..732a103b50 100644
--- a/dlls/shell32/shfldr_unixfs.c
+++ b/dlls/shell32/shfldr_unixfs.c
@@ -1362,7 +1362,7 @@ static HRESULT WINAPI ShellFolder2_SetNameOf(IShellFolder2* iface, HWND hwnd,
return E_INVALIDARG;
/* check for invalid characters in lpcwszName. */
- for (i=0; i < sizeof(awcInvalidChars)/sizeof(*awcInvalidChars); i++)
+ for (i=0; i < ARRAY_SIZE(awcInvalidChars); i++)
if (StrChrW(lpcwszName, awcInvalidChars[i]))
return HRESULT_FROM_WIN32(ERROR_CANCELLED);
@@ -1862,9 +1862,9 @@ static HRESULT WINAPI SFHelper_GetUniqueName(ISFHelper* iface, LPWSTR pwszName,
TRACE("(%p)->(%p %u)\n", This, pwszName, uLen);
- LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, sizeof(wszNewFolder)/sizeof(WCHAR));
+ LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, ARRAY_SIZE(wszNewFolder));
- if (uLen < sizeof(wszNewFolder)/sizeof(WCHAR)+3)
+ if (uLen < ARRAY_SIZE(wszNewFolder) + 3)
return E_INVALIDARG;
hr = IShellFolder2_EnumObjects(&This->IShellFolder2_iface, 0,
@@ -1913,9 +1913,9 @@ static HRESULT WINAPI SFHelper_AddFolder(ISFHelper* iface, HWND hwnd, LPCWSTR pw
char szMessage[256 + FILENAME_MAX];
char szCaption[256];
- LoadStringA(shell32_hInstance, IDS_CREATEFOLDER_DENIED, szCaption, sizeof(szCaption));
+ LoadStringA(shell32_hInstance, IDS_CREATEFOLDER_DENIED, szCaption, ARRAY_SIZE(szCaption));
sprintf(szMessage, szCaption, szNewDir);
- LoadStringA(shell32_hInstance, IDS_CREATEFOLDER_CAPTION, szCaption, sizeof(szCaption));
+ LoadStringA(shell32_hInstance, IDS_CREATEFOLDER_CAPTION, szCaption, ARRAY_SIZE(szCaption));
MessageBoxA(hwnd, szMessage, szCaption, MB_OK | MB_ICONEXCLAMATION);
return E_FAIL;
diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c
index 2055d21d30..d77e213c6d 100644
--- a/dlls/shell32/shlexec.c
+++ b/dlls/shell32/shlexec.c
@@ -158,7 +158,7 @@ static BOOL SHELL_ArgifyW(WCHAR* out, int len, const WCHAR* fmt, const WCHAR* lp
if (!done || (*fmt == '1'))
{
/*FIXME Is the call to SearchPathW() really needed? We already have separated out the parameter string in args. */
- if (SearchPathW(NULL, lpFile, wszExe, sizeof(xlpFile)/sizeof(WCHAR), xlpFile, NULL))
+ if (SearchPathW(NULL, lpFile, wszExe, ARRAY_SIZE(xlpFile), xlpFile, NULL))
cmd = xlpFile;
else
cmd = lpFile;
@@ -202,7 +202,7 @@ static BOOL SHELL_ArgifyW(WCHAR* out, int len, const WCHAR* fmt, const WCHAR* lp
HGLOBAL hmem = SHAllocShared(pidl, ILGetSize(pidl), 0);
pv = SHLockShared(hmem, 0);
chars = sprintfW(buf, wszILPtr, pv);
- if (chars >= sizeof(buf)/sizeof(WCHAR))
+ if (chars >= ARRAY_SIZE(buf))
ERR("pidl format buffer too small!\n");
used += chars;
if (used < len)
@@ -502,7 +502,7 @@ static UINT SHELL_FindExecutableByVerb(LPCWSTR lpVerb, LPWSTR key, LPWSTR classn
if (RegOpenKeyExW(HKEY_CLASSES_ROOT, classname, 0, 0x02000000, &hkeyClass))
return SE_ERR_NOASSOC;
- if (!HCR_GetDefaultVerbW(hkeyClass, lpVerb, verb, sizeof(verb)/sizeof(verb[0])))
+ if (!HCR_GetDefaultVerbW(hkeyClass, lpVerb, verb, ARRAY_SIZE(verb)))
return SE_ERR_NOASSOC;
RegCloseKey(hkeyClass);
@@ -603,13 +603,13 @@ static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpVerb,
return 33;
}
- if (SearchPathW(lpPath, lpFile, wszExe, sizeof(xlpFile)/sizeof(WCHAR), xlpFile, NULL))
+ if (SearchPathW(lpPath, lpFile, wszExe, ARRAY_SIZE(xlpFile), xlpFile, NULL))
{
TRACE("SearchPathW returned non-zero\n");
lpFile = xlpFile;
/* The file was found in the application-supplied default directory (or the system search path) */
}
- else if (lpPath && SearchPathW(NULL, lpFile, wszExe, sizeof(xlpFile)/sizeof(WCHAR), xlpFile, NULL))
+ else if (lpPath && SearchPathW(NULL, lpFile, wszExe, ARRAY_SIZE(xlpFile), xlpFile, NULL))
{
TRACE("SearchPathW returned non-zero\n");
lpFile = xlpFile;
@@ -652,7 +652,7 @@ static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpVerb,
/* See if it's a program - if GetProfileString fails, we skip this
* section. Actually, if GetProfileString fails, we've probably
* got a lot more to worry about than running a program... */
- if (GetProfileStringW(wWindows, wPrograms, wExtensions, wBuffer, sizeof(wBuffer)/sizeof(WCHAR)) > 0)
+ if (GetProfileStringW(wWindows, wPrograms, wExtensions, wBuffer, ARRAY_SIZE(wBuffer)) > 0)
{
CharLowerW(wBuffer);
tok = wBuffer;
@@ -684,7 +684,7 @@ static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpVerb,
&classnamelen) == ERROR_SUCCESS)
{
classnamelen /= sizeof(WCHAR);
- if (classnamelen == sizeof(classname)/sizeof(WCHAR))
+ if (classnamelen == ARRAY_SIZE(classname))
classnamelen--;
classname[classnamelen] = '\0';
TRACE("File type: %s\n", debugstr_w(classname));
@@ -734,7 +734,7 @@ static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpVerb,
/* Toss the leading dot */
extension++;
- if (GetProfileStringW(wExtensions, extension, wszEmpty, command, sizeof(command)/sizeof(WCHAR)) > 0)
+ if (GetProfileStringW(wExtensions, extension, wszEmpty, command, ARRAY_SIZE(command)) > 0)
{
if (strlenW(command) != 0)
{
diff --git a/dlls/shell32/shlfileop.c b/dlls/shell32/shlfileop.c
index 315f5a7453..02e7a1ba38 100644
--- a/dlls/shell32/shlfileop.c
+++ b/dlls/shell32/shlfileop.c
@@ -288,12 +288,13 @@ static BOOL SHELL_ConfirmDialogW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir, FI
if (!SHELL_ConfirmIDs(nKindOfDialog, &ids)) return FALSE;
- LoadStringW(shell32_hInstance, ids.caption_resource_id, szCaption, sizeof(szCaption)/sizeof(WCHAR));
- LoadStringW(shell32_hInstance, ids.text_resource_id, szText, sizeof(szText)/sizeof(WCHAR));
+ LoadStringW(shell32_hInstance, ids.caption_resource_id, szCaption, ARRAY_SIZE(szCaption));
+ LoadStringW(shell32_hInstance, ids.text_resource_id, szText, ARRAY_SIZE(szText));
+
+ args[0] = (DWORD_PTR)szDir;
+ FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
+ szText, 0, 0, szBuffer, ARRAY_SIZE(szBuffer), (__ms_va_list*)args);
- args[0] = (DWORD_PTR)szDir;
- FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
- szText, 0, 0, szBuffer, sizeof(szBuffer)/sizeof(szBuffer[0]), (__ms_va_list*)args);
hIcon = LoadIconW(ids.hIconInstance, (LPWSTR)MAKEINTRESOURCE(ids.icon_resource_id));
ret = SHELL_ConfirmMsgBox(hWnd, szBuffer, szCaption, hIcon, op && op->bManyItems);
diff --git a/dlls/shell32/shlmenu.c b/dlls/shell32/shlmenu.c
index 1c262e74b0..4047c714d3 100644
--- a/dlls/shell32/shlmenu.c
+++ b/dlls/shell32/shlmenu.c
@@ -905,7 +905,7 @@ UINT WINAPI Shell_MergeMenus (HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAd
miiSrc.fType = MFT_STRING;
miiSrc.dwTypeData = szName;
miiSrc.dwItemData = 0;
- miiSrc.cch = sizeof(szName)/sizeof(WCHAR);
+ miiSrc.cch = ARRAY_SIZE(szName);
if (!GetMenuItemInfoW(hmSrc, nItem, TRUE, &miiSrc))
{
diff --git a/dlls/shell32/shlview.c b/dlls/shell32/shlview.c
index ecc23cb727..c0c027fbd3 100644
--- a/dlls/shell32/shlview.c
+++ b/dlls/shell32/shlview.c
@@ -426,7 +426,7 @@ static void ShellView_InitList(IShellViewImpl *This)
lvColumn.fmt = sd.fmt;
lvColumn.cx = MulDiv(sd.cxChar, tm.tmAveCharWidth * 3, 2); /* chars->pixel */
- StrRetToStrNW(nameW, sizeof(nameW)/sizeof(WCHAR), &sd.str, NULL);
+ StrRetToStrNW(nameW, ARRAY_SIZE(nameW), &sd.str, NULL);
SendMessageW(This->hWndList, LVM_INSERTCOLUMNW, This->columns, (LPARAM)&lvColumn);
}
diff --git a/dlls/shell32/systray.c b/dlls/shell32/systray.c
index 7c5704505a..3a17cf3daa 100644
--- a/dlls/shell32/systray.c
+++ b/dlls/shell32/systray.c
@@ -30,6 +30,7 @@
#include "winnls.h"
#include "winuser.h"
#include "shellapi.h"
+#include "shell32_main.h"
#include "wine/debug.h"
#include "wine/heap.h"
@@ -94,7 +95,7 @@ BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid)
/* szTip */
if (pnid->uFlags & NIF_TIP)
- MultiByteToWideChar(CP_ACP, 0, pnid->szTip, -1, nidW.szTip, sizeof(nidW.szTip)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, pnid->szTip, -1, nidW.szTip, ARRAY_SIZE(nidW.szTip));
if (cbSize >= NOTIFYICONDATAA_V2_SIZE)
{
@@ -104,8 +105,8 @@ BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid)
/* szInfo, szInfoTitle */
if (pnid->uFlags & NIF_INFO)
{
- MultiByteToWideChar(CP_ACP, 0, pnid->szInfo, -1, nidW.szInfo, sizeof(nidW.szInfo)/sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, pnid->szInfoTitle, -1, nidW.szInfoTitle, sizeof(nidW.szInfoTitle)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, pnid->szInfo, -1, nidW.szInfo, ARRAY_SIZE(nidW.szInfo));
+ MultiByteToWideChar(CP_ACP, 0, pnid->szInfoTitle, -1, nidW.szInfoTitle, ARRAY_SIZE(nidW.szInfoTitle));
}
nidW.u.uTimeout = pnid->u.uTimeout;
@@ -228,8 +229,8 @@ noicon:
}
if (data->uFlags & NIF_INFO)
{
- lstrcpynW( data->szInfo, nid->szInfo, sizeof(data->szInfo)/sizeof(WCHAR) );
- lstrcpynW( data->szInfoTitle, nid->szInfoTitle, sizeof(data->szInfoTitle)/sizeof(WCHAR) );
+ lstrcpynW( data->szInfo, nid->szInfo, ARRAY_SIZE(data->szInfo) );
+ lstrcpynW( data->szInfoTitle, nid->szInfoTitle, ARRAY_SIZE(data->szInfoTitle));
data->u.uTimeout = nid->u.uTimeout;
data->dwInfoFlags = nid->dwInfoFlags;
}
diff --git a/dlls/shell32/xdg.c b/dlls/shell32/xdg.c
index 3f1d317b72..622ef34623 100644
--- a/dlls/shell32/xdg.c
+++ b/dlls/shell32/xdg.c
@@ -99,10 +99,8 @@ static const std_path paths[] = {
{"XDG_CACHE_HOME", "$HOME/.cache"}
};
-#define PATHS_COUNT (sizeof(paths)/sizeof(paths[0]))
-
/* will be filled with paths as they are computed */
-static const char *path_values[PATHS_COUNT] = {
+static const char *path_values[ARRAY_SIZE(paths)] = {
NULL,
NULL,
NULL,
@@ -161,7 +159,7 @@ static char *load_path(int path_id)
*/
static const char *XDG_GetPath(int path_id)
{
- if (path_id >= PATHS_COUNT || path_id < 0)
+ if (path_id >= ARRAY_SIZE(paths) || path_id < 0)
{
ERR("Invalid path_id %d\n", path_id);
return NULL;
--
2.16.2
1
0
Fixes https://bugs.winehq.org/show_bug.cgi?id=43232
Signed-off-by: Stefan Leichter <sle85276(a)gmx.de>
---
configure.ac | 1 +
dlls/strmdll/Makefile.in | 4 ++++
dlls/strmdll/main.c | 41 +++++++++++++++++++++++++++++++++++++++++
dlls/strmdll/strmdll.spec | 5 +++++
4 files changed, 51 insertions(+)
create mode 100644 dlls/strmdll/Makefile.in
create mode 100644 dlls/strmdll/main.c
create mode 100644 dlls/strmdll/strmdll.spec
1
0
[PATCH 4/5] wined3d: Pass the destination x/y coordinates as separate parameters to wined3d_surface_upload_data().
by Henri Verbeet 18 Mar '18
by Henri Verbeet 18 Mar '18
18 Mar '18
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/surface.c | 51 +++++++++++++++++++-----------------------
dlls/wined3d/texture.c | 10 ++++-----
dlls/wined3d/wined3d_private.h | 2 +-
3 files changed, 29 insertions(+), 34 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 794e2a35869..34f3ff3751e 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -777,8 +777,8 @@ static void texture2d_download_data(struct wined3d_texture *texture, unsigned in
/* Context activation is done by the caller. */
void wined3d_surface_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
const struct wined3d_gl_info *gl_info, const struct wined3d_format *format,
- const struct wined3d_box *src_box, unsigned int src_pitch, const POINT *dst_point, BOOL srgb,
- const struct wined3d_const_bo_address *data)
+ const struct wined3d_box *src_box, unsigned int src_pitch, unsigned int dst_x, unsigned int dst_y,
+ BOOL srgb, const struct wined3d_const_bo_address *data)
{
unsigned int update_w = src_box->right - src_box->left;
unsigned int update_h = src_box->bottom - src_box->top;
@@ -786,9 +786,9 @@ void wined3d_surface_upload_data(struct wined3d_texture *texture, unsigned int s
GLenum target;
TRACE("texure %p, sub_resource_idx %u, gl_info %p, format %s, src_box %s, "
- "src_pitch %u, dst_point %s, srgb %#x, data {%#x:%p}.\n",
+ "src_pitch %u, dst_x %u, dst_y %u, srgb %#x, data {%#x:%p}.\n",
texture, sub_resource_idx, gl_info, debug_d3dformat(format->id), debug_box(src_box),
- src_pitch, wine_dbgstr_point(dst_point), srgb, data->buffer_object, data->addr);
+ src_pitch, dst_x, dst_y, srgb, data->buffer_object, data->addr);
if (texture->sub_resources[sub_resource_idx].map_count)
{
@@ -831,21 +831,20 @@ void wined3d_surface_upload_data(struct wined3d_texture *texture, unsigned int s
wined3d_format_calculate_pitch(format, 1, update_w, update_h, &dst_row_pitch, &dst_slice_pitch);
- TRACE("Uploading compressed data, target %#x, level %u, layer %u, x %d, y %d, w %u, h %u, "
- "format %#x, image_size %#x, addr %p.\n",
- target, level, layer, dst_point->x, dst_point->y,
- update_w, update_h, internal, dst_slice_pitch, addr);
+ TRACE("Uploading compressed data, target %#x, level %u, layer %u, "
+ "x %u, y %u, w %u, h %u, format %#x, image_size %#x, addr %p.\n",
+ target, level, layer, dst_x, dst_y, update_w, update_h, internal, dst_slice_pitch, addr);
if (dst_row_pitch == src_pitch)
{
if (target == GL_TEXTURE_2D_ARRAY)
{
- GL_EXTCALL(glCompressedTexSubImage3D(target, level, dst_point->x, dst_point->y,
+ GL_EXTCALL(glCompressedTexSubImage3D(target, level, dst_x, dst_y,
layer, update_w, update_h, 1, internal, dst_slice_pitch, addr));
}
else
{
- GL_EXTCALL(glCompressedTexSubImage2D(target, level, dst_point->x, dst_point->y,
+ GL_EXTCALL(glCompressedTexSubImage2D(target, level, dst_x, dst_y,
update_w, update_h, internal, dst_slice_pitch, addr));
}
}
@@ -856,16 +855,16 @@ void wined3d_surface_upload_data(struct wined3d_texture *texture, unsigned int s
/* glCompressedTexSubImage2D() ignores pixel store state, so we
* can't use the unpack row length like for glTexSubImage2D. */
- for (row = 0, y = dst_point->y; row < row_count; ++row)
+ for (row = 0, y = dst_y; row < row_count; ++row)
{
if (target == GL_TEXTURE_2D_ARRAY)
{
- GL_EXTCALL(glCompressedTexSubImage3D(target, level, dst_point->x, y,
+ GL_EXTCALL(glCompressedTexSubImage3D(target, level, dst_x, y,
layer, update_w, format->block_height, 1, internal, dst_row_pitch, addr));
}
else
{
- GL_EXTCALL(glCompressedTexSubImage2D(target, level, dst_point->x, y,
+ GL_EXTCALL(glCompressedTexSubImage2D(target, level, dst_x, y,
update_w, format->block_height, internal, dst_row_pitch, addr));
}
@@ -884,18 +883,18 @@ void wined3d_surface_upload_data(struct wined3d_texture *texture, unsigned int s
TRACE("Uploading data, target %#x, level %u, layer %u, x %d, y %d, w %u, h %u, "
"format %#x, type %#x, addr %p.\n",
- target, level, layer, dst_point->x, dst_point->y,
+ target, level, layer, dst_x, dst_y,
update_w, update_h, format->glFormat, format->glType, addr);
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, src_pitch / format->byte_count);
if (target == GL_TEXTURE_2D_ARRAY)
{
- GL_EXTCALL(glTexSubImage3D(target, level, dst_point->x, dst_point->y,
+ GL_EXTCALL(glTexSubImage3D(target, level, dst_x, dst_y,
layer, update_w, update_h, 1, format->glFormat, format->glType, addr));
}
else
{
- gl_info->gl_ops.gl.p_glTexSubImage2D(target, level, dst_point->x, dst_point->y,
+ gl_info->gl_ops.gl.p_glTexSubImage2D(target, level, dst_x, dst_y,
update_w, update_h, format->glFormat, format->glType, addr);
}
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
@@ -923,8 +922,8 @@ void wined3d_surface_upload_data(struct wined3d_texture *texture, unsigned int s
}
}
-static HRESULT texture2d_upload_from_surface(struct wined3d_texture *dst_texture,
- unsigned int dst_sub_resource_idx, const POINT *dst_point, struct wined3d_texture *src_texture,
+static HRESULT texture2d_upload_from_surface(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
+ unsigned int dst_x, unsigned int dst_y, struct wined3d_texture *src_texture,
unsigned int src_sub_resource_idx, const struct wined3d_box *src_box)
{
unsigned int src_row_pitch, src_slice_pitch;
@@ -934,9 +933,9 @@ static HRESULT texture2d_upload_from_surface(struct wined3d_texture *dst_texture
struct wined3d_bo_address data;
UINT update_w, update_h;
- TRACE("dst_texture %p, dst_sub_resource_idx %u, dst_point %s, "
+ TRACE("dst_texture %p, dst_sub_resource_idx %u, dst_x %u, dst_y %u, "
"src_texture %p, src_sub_resource_idx %u, src_box %s.\n",
- dst_texture, dst_sub_resource_idx, wine_dbgstr_point(dst_point),
+ dst_texture, dst_sub_resource_idx, dst_x, dst_y,
src_texture, src_sub_resource_idx, debug_box(src_box));
context = context_acquire(dst_texture->resource.device, NULL, 0);
@@ -961,7 +960,7 @@ static HRESULT texture2d_upload_from_surface(struct wined3d_texture *dst_texture
wined3d_texture_get_pitch(src_texture, src_level, &src_row_pitch, &src_slice_pitch);
wined3d_surface_upload_data(dst_texture, dst_sub_resource_idx, gl_info, src_texture->resource.format,
- src_box, src_row_pitch, dst_point, FALSE, wined3d_const_bo_address(&data));
+ src_box, src_row_pitch, dst_x, dst_y, FALSE, wined3d_const_bo_address(&data));
context_release(context);
@@ -1316,14 +1315,13 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr
else
{
struct wined3d_box src_box = {0, 0, desc.width, desc.height, 0, 1};
- POINT dst_point = {0, 0};
TRACE("Using upload conversion.\n");
wined3d_texture_prepare_texture(dst_texture, context, FALSE);
wined3d_texture_bind_and_dirtify(dst_texture, context, FALSE);
wined3d_surface_upload_data(dst_texture, 0, gl_info, src_format,
- &src_box, src_row_pitch, &dst_point, FALSE, wined3d_const_bo_address(&src_data));
+ &src_box, src_row_pitch, 0, 0, FALSE, wined3d_const_bo_address(&src_data));
wined3d_texture_validate_location(dst_texture, 0, WINED3D_LOCATION_TEXTURE_RGB);
wined3d_texture_invalidate_location(dst_texture, 0, ~WINED3D_LOCATION_TEXTURE_RGB);
@@ -2149,7 +2147,6 @@ BOOL texture2d_load_texture(struct wined3d_texture *texture, unsigned int sub_re
BYTE *src_mem, *dst_mem = NULL;
struct wined3d_format format;
struct wined3d_box src_box;
- POINT dst_point = {0, 0};
BOOL depth;
depth = texture->resource.usage & WINED3DUSAGE_DEPTHSTENCIL;
@@ -2305,7 +2302,7 @@ BOOL texture2d_load_texture(struct wined3d_texture *texture, unsigned int sub_re
}
wined3d_surface_upload_data(texture, sub_resource_idx, gl_info, &format, &src_box,
- src_row_pitch, &dst_point, srgb, wined3d_const_bo_address(&data));
+ src_row_pitch, 0, 0, srgb, wined3d_const_bo_address(&data));
heap_free(dst_mem);
@@ -3842,10 +3839,8 @@ HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_
TRACE("Not doing upload because the destination format needs conversion.\n");
else
{
- POINT dst_point = {dst_box->left, dst_box->top};
-
if (SUCCEEDED(texture2d_upload_from_surface(dst_texture, dst_sub_resource_idx,
- &dst_point, src_texture, src_sub_resource_idx, src_box)))
+ dst_box->left, dst_box->top, src_texture, src_sub_resource_idx, src_box)))
{
if (!wined3d_resource_is_offscreen(&dst_texture->resource))
{
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 6dd013af37c..83c7a41632f 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1758,7 +1758,7 @@ static void texture2d_upload_data(struct wined3d_texture *texture, unsigned int
{
struct wined3d_box src_box;
unsigned int texture_level;
- POINT dst_point;
+ unsigned int dst_x, dst_y;
src_box.left = 0;
src_box.top = 0;
@@ -1766,21 +1766,21 @@ static void texture2d_upload_data(struct wined3d_texture *texture, unsigned int
src_box.back = 1;
if (box)
{
- dst_point.x = box->left;
- dst_point.y = box->top;
+ dst_x = box->left;
+ dst_y = box->top;
src_box.right = box->right - box->left;
src_box.bottom = box->bottom - box->top;
}
else
{
- dst_point.x = dst_point.y = 0;
+ dst_x = dst_y = 0;
texture_level = sub_resource_idx % texture->level_count;
src_box.right = wined3d_texture_get_level_width(texture, texture_level);
src_box.bottom = wined3d_texture_get_level_height(texture, texture_level);
}
wined3d_surface_upload_data(texture, sub_resource_idx, context->gl_info,
- texture->resource.format, &src_box, row_pitch, &dst_point, FALSE, data);
+ texture->resource.format, &src_box, row_pitch, dst_x, dst_y, FALSE, data);
}
/* Context activation is done by the caller. Context may be NULL in ddraw-only mode. */
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 6f44dee4f76..4c655c4bf30 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3335,7 +3335,7 @@ struct fbo_entry
void wined3d_surface_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
const struct wined3d_gl_info *gl_info, const struct wined3d_format *format,
- const struct wined3d_box *src_box, unsigned int src_pitch, const POINT *dst_point,
+ const struct wined3d_box *src_box, unsigned int src_pitch, unsigned int dst_x, unsigned int dst_y,
BOOL srgb, const struct wined3d_const_bo_address *data) DECLSPEC_HIDDEN;
void draw_textured_quad(struct wined3d_texture *texture, unsigned int sub_resource_idx,
--
2.11.0
1
0