winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
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
List overview
wine-devel
February 2018
----- 2025 -----
July 2025
June 2025
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-devel@winehq.org
74 participants
746 discussions
Start a n
N
ew thread
[PATCH] winhttp: Use the global HeapAlloc() wrappers
by Michael Stefaniuc
06 Feb '18
06 Feb '18
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> --- dlls/winhttp/winhttp_private.h | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h index ee41481646..0eb0dead87 100644 --- a/dlls/winhttp/winhttp_private.h +++ b/dlls/winhttp/winhttp_private.h @@ -23,6 +23,7 @@ # error You must include config.h to use this header #endif +#include "wine/heap.h" #include "wine/list.h" #
…
[View More]
include "wine/unicode.h" @@ -322,31 +323,11 @@ void release_host( hostdata_t *host ) DECLSPEC_HIDDEN; extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN; void release_typelib( void ) DECLSPEC_HIDDEN; -static inline void* __WINE_ALLOC_SIZE(1) heap_alloc( SIZE_T size ) -{ - return HeapAlloc( GetProcessHeap(), 0, size ); -} - -static inline void* __WINE_ALLOC_SIZE(1) heap_alloc_zero( SIZE_T size ) -{ - return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size ); -} - -static inline void* __WINE_ALLOC_SIZE(2) heap_realloc( LPVOID mem, SIZE_T size ) -{ - return HeapReAlloc( GetProcessHeap(), 0, mem, size ); -} - static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero( LPVOID mem, SIZE_T size ) { return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, size ); } -static inline BOOL heap_free( LPVOID mem ) -{ - return HeapFree( GetProcessHeap(), 0, mem ); -} - static inline WCHAR *strdupW( const WCHAR *src ) { WCHAR *dst; -- 2.14.3
[View Less]
2
1
0
0
[PATCH] webservices: Use the global HeapAlloc() wrappers
by Michael Stefaniuc
06 Feb '18
06 Feb '18
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> --- dlls/webservices/channel.c | 1 + dlls/webservices/error.c | 1 + dlls/webservices/heap.c | 1 + dlls/webservices/listener.c | 1 + dlls/webservices/msg.c | 1 + dlls/webservices/proxy.c | 1 + dlls/webservices/reader.c | 1 + dlls/webservices/string.c | 1 + dlls/webservices/url.c | 1 + dlls/
…
[View More]
webservices/webservices_private.h | 20 -------------------- dlls/webservices/writer.c | 1 + 11 files changed, 10 insertions(+), 20 deletions(-) diff --git a/dlls/webservices/channel.c b/dlls/webservices/channel.c index 0765e0dc6b..685e13d99d 100644 --- a/dlls/webservices/channel.c +++ b/dlls/webservices/channel.c @@ -25,6 +25,7 @@ #include "webservices.h" #include "wine/debug.h" +#include "wine/heap.h" #include "wine/list.h" #include "wine/unicode.h" #include "webservices_private.h" diff --git a/dlls/webservices/error.c b/dlls/webservices/error.c index 747af2a3f9..e4292db5bf 100644 --- a/dlls/webservices/error.c +++ b/dlls/webservices/error.c @@ -24,6 +24,7 @@ #include "webservices.h" #include "wine/debug.h" +#include "wine/heap.h" #include "wine/list.h" #include "webservices_private.h" diff --git a/dlls/webservices/heap.c b/dlls/webservices/heap.c index 080cc0d631..5e1a273329 100644 --- a/dlls/webservices/heap.c +++ b/dlls/webservices/heap.c @@ -24,6 +24,7 @@ #include "webservices.h" #include "wine/debug.h" +#include "wine/heap.h" #include "wine/list.h" #include "webservices_private.h" diff --git a/dlls/webservices/listener.c b/dlls/webservices/listener.c index 41afb27443..a178e276e4 100644 --- a/dlls/webservices/listener.c +++ b/dlls/webservices/listener.c @@ -23,6 +23,7 @@ #include "webservices.h" #include "wine/debug.h" +#include "wine/heap.h" #include "wine/list.h" #include "wine/unicode.h" #include "webservices_private.h" diff --git a/dlls/webservices/msg.c b/dlls/webservices/msg.c index f4d167f64e..19a107629c 100644 --- a/dlls/webservices/msg.c +++ b/dlls/webservices/msg.c @@ -25,6 +25,7 @@ #include "webservices.h" #include "wine/debug.h" +#include "wine/heap.h" #include "wine/list.h" #include "wine/unicode.h" #include "webservices_private.h" diff --git a/dlls/webservices/proxy.c b/dlls/webservices/proxy.c index a4041fe153..da30cb027a 100644 --- a/dlls/webservices/proxy.c +++ b/dlls/webservices/proxy.c @@ -24,6 +24,7 @@ #include "webservices.h" #include "wine/debug.h" +#include "wine/heap.h" #include "wine/list.h" #include "webservices_private.h" diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c index 4c121d9f4a..a56bb7eb9f 100644 --- a/dlls/webservices/reader.c +++ b/dlls/webservices/reader.c @@ -25,6 +25,7 @@ #include "webservices.h" #include "wine/debug.h" +#include "wine/heap.h" #include "wine/list.h" #include "webservices_private.h" diff --git a/dlls/webservices/string.c b/dlls/webservices/string.c index 45a5512f6b..18c55e3833 100644 --- a/dlls/webservices/string.c +++ b/dlls/webservices/string.c @@ -24,6 +24,7 @@ #include "webservices.h" #include "wine/debug.h" +#include "wine/heap.h" #include "wine/list.h" #include "webservices_private.h" diff --git a/dlls/webservices/url.c b/dlls/webservices/url.c index e5e04e47a1..465857aec4 100644 --- a/dlls/webservices/url.c +++ b/dlls/webservices/url.c @@ -24,6 +24,7 @@ #include "webservices.h" #include "wine/debug.h" +#include "wine/heap.h" #include "wine/list.h" #include "wine/unicode.h" #include "webservices_private.h" diff --git a/dlls/webservices/webservices_private.h b/dlls/webservices/webservices_private.h index 3f6d2f4492..cce49cce14 100644 --- a/dlls/webservices/webservices_private.h +++ b/dlls/webservices/webservices_private.h @@ -394,27 +394,7 @@ static inline BOOL is_valid_parent( const struct node *node ) return (node_type( node ) == WS_XML_NODE_TYPE_ELEMENT || node_type( node ) == WS_XML_NODE_TYPE_BOF); } -static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size) -{ - return HeapAlloc(GetProcessHeap(), 0, size); -} - -static inline void* __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t size) -{ - return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); -} - -static inline void* __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t size) -{ - return HeapReAlloc(GetProcessHeap(), 0, mem, size); -} - static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t size) { return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, size); } - -static inline BOOL heap_free(void *mem) -{ - return HeapFree(GetProcessHeap(), 0, mem); -} diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c index 75cf7b4e64..9cba4e60a2 100644 --- a/dlls/webservices/writer.c +++ b/dlls/webservices/writer.c @@ -28,6 +28,7 @@ #include "webservices.h" #include "wine/debug.h" +#include "wine/heap.h" #include "wine/list.h" #include "wine/unicode.h" #include "webservices_private.h" -- 2.14.3
[View Less]
2
1
0
0
[PATCH] wbemprox: Use the global HeapAlloc() wrappers
by Michael Stefaniuc
06 Feb '18
06 Feb '18
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> --- dlls/wbemprox/wbemprox_private.h | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/dlls/wbemprox/wbemprox_private.h b/dlls/wbemprox/wbemprox_private.h index 15ea9c6bcf..54b1ba3d8e 100644 --- a/dlls/wbemprox/wbemprox_private.h +++ b/dlls/wbemprox/wbemprox_private.h @@ -17,6 +17,7 @@ */ #include "wine/debug.h" +#include "wine/heap.h" #include "wine/list.h" #include "wine/unicode.h"
…
[View More]
@@ -227,26 +228,6 @@ HRESULT service_stop_service(IWbemClassObject *, IWbemClassObject *, IWbemClassO HRESULT security_get_sd(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN; HRESULT security_set_sd(IWbemClassObject *, IWbemClassObject *, IWbemClassObject **) DECLSPEC_HIDDEN; -static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size) -{ - return HeapAlloc(GetProcessHeap(), 0, size); -} - -static inline void* __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t size) -{ - return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); -} - -static inline void* __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t size) -{ - return HeapReAlloc(GetProcessHeap(), 0, mem, size); -} - -static inline BOOL heap_free(void *mem) -{ - return HeapFree(GetProcessHeap(), 0, mem); -} - static inline WCHAR *heap_strdupW( const WCHAR *src ) { WCHAR *dst; -- 2.14.3
[View Less]
2
1
0
0
[PATCH] wbemdisp: Use the global HeapAlloc() wrappers
by Michael Stefaniuc
06 Feb '18
06 Feb '18
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> --- dlls/wbemdisp/locator.c | 1 + dlls/wbemdisp/main.c | 1 + dlls/wbemdisp/wbemdisp_private.h | 10 ---------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/dlls/wbemdisp/locator.c b/dlls/wbemdisp/locator.c index d1be48f3a5..e782d1f523 100644 --- a/dlls/wbemdisp/locator.c +++ b/dlls/wbemdisp/locator.c @@ -30,6 +30,7 @@ #include "wbemdisp.h" #include "wine/debug.h" +#include "wine/heap.
…
[View More]
h" #include "wine/unicode.h" #include "wbemdisp_private.h" #include "wbemdisp_classes.h" diff --git a/dlls/wbemdisp/main.c b/dlls/wbemdisp/main.c index 97cd1e7d2f..9d9b0adf40 100644 --- a/dlls/wbemdisp/main.c +++ b/dlls/wbemdisp/main.c @@ -29,6 +29,7 @@ #include "rpcproxy.h" #include "wine/debug.h" +#include "wine/heap.h" #include "wine/unicode.h" #include "wbemdisp_private.h" #include "wbemdisp_classes.h" diff --git a/dlls/wbemdisp/wbemdisp_private.h b/dlls/wbemdisp/wbemdisp_private.h index 28912483e4..b03a13e2ea 100644 --- a/dlls/wbemdisp/wbemdisp_private.h +++ b/dlls/wbemdisp/wbemdisp_private.h @@ -17,13 +17,3 @@ */ HRESULT SWbemLocator_create(LPVOID *) DECLSPEC_HIDDEN; - -static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size) -{ - return HeapAlloc(GetProcessHeap(), 0, size); -} - -static inline BOOL heap_free(void *mem) -{ - return HeapFree(GetProcessHeap(), 0, mem); -} -- 2.14.3
[View Less]
2
1
0
0
[PATCH v2] kerberos: Support non-DCE style contexts.
by Hans Leidekker
06 Feb '18
06 Feb '18
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> --- v2: Fix build without gssapi. dlls/kerberos/krb5_ap.c | 168 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 139 insertions(+), 29 deletions(-) diff --git a/dlls/kerberos/krb5_ap.c b/dlls/kerberos/krb5_ap.c index 8b5b6128ac..ce1893bcec 100644 --- a/dlls/kerberos/krb5_ap.c +++ b/dlls/kerberos/krb5_ap.c @@ -590,12 +590,15 @@ MAKE_FUNCPTR(gss_display_status); MAKE_FUNCPTR(gss_get_mic); MAKE_FUNCPTR(
…
[View More]
gss_import_name); MAKE_FUNCPTR(gss_init_sec_context); +MAKE_FUNCPTR(gss_inquire_context); MAKE_FUNCPTR(gss_release_buffer); MAKE_FUNCPTR(gss_release_cred); MAKE_FUNCPTR(gss_release_iov_buffer); MAKE_FUNCPTR(gss_release_name); +MAKE_FUNCPTR(gss_unwrap); MAKE_FUNCPTR(gss_unwrap_iov); MAKE_FUNCPTR(gss_verify_mic); +MAKE_FUNCPTR(gss_wrap); MAKE_FUNCPTR(gss_wrap_iov); #undef MAKE_FUNCPTR @@ -621,12 +624,15 @@ static BOOL load_gssapi_krb5(void) LOAD_FUNCPTR(gss_get_mic) LOAD_FUNCPTR(gss_import_name) LOAD_FUNCPTR(gss_init_sec_context) + LOAD_FUNCPTR(gss_inquire_context) LOAD_FUNCPTR(gss_release_buffer) LOAD_FUNCPTR(gss_release_cred) LOAD_FUNCPTR(gss_release_iov_buffer) LOAD_FUNCPTR(gss_release_name) + LOAD_FUNCPTR(gss_unwrap) LOAD_FUNCPTR(gss_unwrap_iov) LOAD_FUNCPTR(gss_verify_mic) + LOAD_FUNCPTR(gss_wrap) LOAD_FUNCPTR(gss_wrap_iov) #undef LOAD_FUNCPTR @@ -757,7 +763,7 @@ static SECURITY_STATUS name_sspi_to_gss( const UNICODE_STRING *name_str, gss_nam static ULONG flags_isc_req_to_gss( ULONG flags ) { - ULONG ret = GSS_C_DCE_STYLE; + ULONG ret = 0; if (flags & ISC_REQ_DELEGATE) ret |= GSS_C_DELEG_FLAG; if (flags & ISC_REQ_MUTUAL_AUTH) ret |= GSS_C_MUTUAL_FLAG; if (flags & ISC_REQ_REPLAY_DETECT) ret |= GSS_C_REPLAY_FLAG; @@ -765,6 +771,7 @@ static ULONG flags_isc_req_to_gss( ULONG flags ) if (flags & ISC_REQ_CONFIDENTIALITY) ret |= GSS_C_CONF_FLAG; if (flags & ISC_REQ_INTEGRITY) ret |= GSS_C_INTEG_FLAG; if (flags & ISC_REQ_NULL_SESSION) ret |= GSS_C_ANON_FLAG; + if (flags & ISC_REQ_USE_DCE_STYLE) ret |= GSS_C_DCE_STYLE; return ret; } @@ -794,6 +801,13 @@ static ULONG flags_gss_to_asc_ret( ULONG flags ) return ret; } +static BOOL is_dce_style_context( gss_ctx_id_t ctxt_handle ) +{ + OM_uint32 ret, minor_status, flags; + ret = pgss_inquire_context( &minor_status, ctxt_handle, NULL, NULL, NULL, NULL, &flags, NULL, NULL ); + return (ret == GSS_S_COMPLETE && (flags & GSS_C_DCE_STYLE)); +} + static int get_buffer_index( SecBufferDesc *desc, DWORD type ) { UINT i; @@ -1075,10 +1089,21 @@ static NTSTATUS NTAPI kerberos_SpQueryContextAttributes( LSA_SEC_HANDLE context, case SECPKG_ATTR_SIZES: { SecPkgContext_Sizes *sizes = (SecPkgContext_Sizes *)buffer; + ULONG size_max_signature = 37, size_security_trailer = 49; +#ifdef SONAME_LIBGSSAPI_KRB5 + gss_ctx_id_t ctxt_handle; + + if (!(ctxt_handle = ctxthandle_sspi_to_gss( context ))) return SEC_E_INVALID_HANDLE; + if (is_dce_style_context( ctxt_handle )) + { + size_max_signature = 28; + size_security_trailer = 76; + } +#endif sizes->cbMaxToken = KERBEROS_MAX_BUF; - sizes->cbMaxSignature = 37; + sizes->cbMaxSignature = size_max_signature; sizes->cbBlockSize = 1; - sizes->cbSecurityTrailer = 49; + sizes->cbSecurityTrailer = size_security_trailer; return SEC_E_OK; } case SECPKG_ATTR_NEGOTIATION_INFO: @@ -1256,26 +1281,13 @@ static SECURITY_STATUS SEC_ENTRY kerberos_SpVerifySignature( LSA_SEC_HANDLE cont #endif } -static NTSTATUS NTAPI kerberos_SpSealMessage( LSA_SEC_HANDLE context, ULONG quality_of_protection, - SecBufferDesc *message, ULONG message_seq_no ) -{ #ifdef SONAME_LIBGSSAPI_KRB5 - gss_ctx_id_t ctxt_handle; +static NTSTATUS seal_message_iov( gss_ctx_id_t ctxt_handle, SecBufferDesc *message ) +{ gss_iov_buffer_desc iov[4]; OM_uint32 ret, minor_status; int token_idx, data_idx, conf_state; - TRACE( "(%lx 0x%08x %p %u)\n", context, quality_of_protection, message, message_seq_no ); - if (quality_of_protection) - { - FIXME( "flags %08x not supported\n", quality_of_protection ); - return SEC_E_UNSUPPORTED_FUNCTION; - } - if (message_seq_no) FIXME( "ignoring message_seq_no %u\n", message_seq_no ); - - if (!context) return SEC_E_INVALID_HANDLE; - ctxt_handle = ctxthandle_sspi_to_gss( context ); - /* FIXME: multiple data buffers, read-only buffers */ if ((data_idx = get_buffer_index( message, SECBUFFER_DATA )) == -1) return SEC_E_INVALID_TOKEN; if ((token_idx = get_buffer_index( message, SECBUFFER_TOKEN )) == -1) return SEC_E_INVALID_TOKEN; @@ -1307,27 +1319,75 @@ static NTSTATUS NTAPI kerberos_SpSealMessage( LSA_SEC_HANDLE context, ULONG qual } return status_gss_to_sspi( ret ); -#else - FIXME( "(%lx 0x%08x %p %u)\n", context, quality_of_protection, message, message_seq_no ); - return SEC_E_UNSUPPORTED_FUNCTION; -#endif } -static NTSTATUS NTAPI kerberos_SpUnsealMessage( LSA_SEC_HANDLE context, SecBufferDesc *message, - ULONG message_seq_no, ULONG *quality_of_protection ) +static NTSTATUS seal_message( gss_ctx_id_t ctxt_handle, SecBufferDesc *message ) { -#ifdef SONAME_LIBGSSAPI_KRB5 - gss_ctx_id_t ctxt_handle; - gss_iov_buffer_desc iov[4]; + gss_buffer_desc input, output; OM_uint32 ret, minor_status; int token_idx, data_idx, conf_state; - TRACE( "(%lx %p %u %p)\n", context, message, message_seq_no, quality_of_protection ); + /* FIXME: multiple data buffers, read-only buffers */ + if ((data_idx = get_buffer_index( message, SECBUFFER_DATA )) == -1) return SEC_E_INVALID_TOKEN; + if ((token_idx = get_buffer_index( message, SECBUFFER_TOKEN )) == -1) return SEC_E_INVALID_TOKEN; + + input.length = message->pBuffers[data_idx].cbBuffer; + input.value = message->pBuffers[data_idx].pvBuffer; + + ret = pgss_wrap( &minor_status, ctxt_handle, 1, GSS_C_QOP_DEFAULT, &input, &conf_state, &output ); + TRACE( "gss_wrap returned %08x minor status %08x\n", ret, minor_status ); + if (GSS_ERROR(ret)) trace_gss_status( ret, minor_status ); + if (ret == GSS_S_COMPLETE) + { + DWORD len_data = message->pBuffers[data_idx].cbBuffer, len_token = message->pBuffers[token_idx].cbBuffer; + if (len_token < output.length - len_data) + { + TRACE( "buffer too small %lu > %u\n", (SIZE_T)output.length - len_data, len_token ); + pgss_release_buffer( &minor_status, &output ); + return SEC_E_BUFFER_TOO_SMALL; + } + memcpy( message->pBuffers[data_idx].pvBuffer, output.value, len_data ); + memcpy( message->pBuffers[token_idx].pvBuffer, (char *)output.value + len_data, output.length - len_data ); + message->pBuffers[token_idx].cbBuffer = output.length - len_data; + pgss_release_buffer( &minor_status, &output ); + } + + return status_gss_to_sspi( ret ); +} +#endif + +static NTSTATUS NTAPI kerberos_SpSealMessage( LSA_SEC_HANDLE context, ULONG quality_of_protection, + SecBufferDesc *message, ULONG message_seq_no ) +{ +#ifdef SONAME_LIBGSSAPI_KRB5 + gss_ctx_id_t ctxt_handle; + + TRACE( "(%lx 0x%08x %p %u)\n", context, quality_of_protection, message, message_seq_no ); + if (quality_of_protection) + { + FIXME( "flags %08x not supported\n", quality_of_protection ); + return SEC_E_UNSUPPORTED_FUNCTION; + } if (message_seq_no) FIXME( "ignoring message_seq_no %u\n", message_seq_no ); if (!context) return SEC_E_INVALID_HANDLE; ctxt_handle = ctxthandle_sspi_to_gss( context ); + if (is_dce_style_context( ctxt_handle )) return seal_message_iov( ctxt_handle, message ); + return seal_message( ctxt_handle, message ); +#else + FIXME( "(%lx 0x%08x %p %u)\n", context, quality_of_protection, message, message_seq_no ); + return SEC_E_UNSUPPORTED_FUNCTION; +#endif +} + +#ifdef SONAME_LIBGSSAPI_KRB5 +static NTSTATUS unseal_message_iov( gss_ctx_id_t ctxt_handle, SecBufferDesc *message, ULONG *quality_of_protection ) +{ + gss_iov_buffer_desc iov[4]; + OM_uint32 ret, minor_status; + int token_idx, data_idx, conf_state; + if ((data_idx = get_buffer_index( message, SECBUFFER_DATA )) == -1) return SEC_E_INVALID_TOKEN; if ((token_idx = get_buffer_index( message, SECBUFFER_TOKEN )) == -1) return SEC_E_INVALID_TOKEN; @@ -1350,10 +1410,60 @@ static NTSTATUS NTAPI kerberos_SpUnsealMessage( LSA_SEC_HANDLE context, SecBuffe ret = pgss_unwrap_iov( &minor_status, ctxt_handle, &conf_state, NULL, iov, 4 ); TRACE( "gss_unwrap_iov returned %08x minor status %08x\n", ret, minor_status ); if (GSS_ERROR(ret)) trace_gss_status( ret, minor_status ); - if (ret == GSS_S_COMPLETE && quality_of_protection) *quality_of_protection = (conf_state ? 0 : SECQOP_WRAP_NO_ENCRYPT); + if (ret == GSS_S_COMPLETE && quality_of_protection) + { + *quality_of_protection = (conf_state ? 0 : SECQOP_WRAP_NO_ENCRYPT); + } + return status_gss_to_sspi( ret ); +} + +static NTSTATUS unseal_message( gss_ctx_id_t ctxt_handle, SecBufferDesc *message, ULONG *quality_of_protection ) +{ + gss_buffer_desc input, output; + OM_uint32 ret, minor_status; + int token_idx, data_idx, conf_state; + DWORD len_data, len_token; + + if ((data_idx = get_buffer_index( message, SECBUFFER_DATA )) == -1) return SEC_E_INVALID_TOKEN; + if ((token_idx = get_buffer_index( message, SECBUFFER_TOKEN )) == -1) return SEC_E_INVALID_TOKEN; + + len_data = message->pBuffers[data_idx].cbBuffer; + len_token = message->pBuffers[token_idx].cbBuffer; + + input.length = len_data + len_token; + if (!(input.value = heap_alloc( input.length ))) return SEC_E_INSUFFICIENT_MEMORY; + memcpy( input.value, message->pBuffers[data_idx].pvBuffer, len_data ); + memcpy( (char *)input.value + len_data, message->pBuffers[token_idx].pvBuffer, len_token ); + + ret = pgss_unwrap( &minor_status, ctxt_handle, &input, &output, &conf_state, NULL ); + heap_free( input.value ); + TRACE( "gss_unwrap returned %08x minor status %08x\n", ret, minor_status ); + if (GSS_ERROR(ret)) trace_gss_status( ret, minor_status ); + if (ret == GSS_S_COMPLETE) + { + if (quality_of_protection) *quality_of_protection = (conf_state ? 0 : SECQOP_WRAP_NO_ENCRYPT); + memcpy( message->pBuffers[data_idx].pvBuffer, output.value, len_data ); + pgss_release_buffer( &minor_status, &output ); + } return status_gss_to_sspi( ret ); +} +#endif + +static NTSTATUS NTAPI kerberos_SpUnsealMessage( LSA_SEC_HANDLE context, SecBufferDesc *message, + ULONG message_seq_no, ULONG *quality_of_protection ) +{ +#ifdef SONAME_LIBGSSAPI_KRB5 + gss_ctx_id_t ctxt_handle; + + TRACE( "(%lx %p %u %p)\n", context, message, message_seq_no, quality_of_protection ); + if (message_seq_no) FIXME( "ignoring message_seq_no %u\n", message_seq_no ); + + if (!context) return SEC_E_INVALID_HANDLE; + ctxt_handle = ctxthandle_sspi_to_gss( context ); + if (is_dce_style_context( ctxt_handle )) return unseal_message_iov( ctxt_handle, message, quality_of_protection ); + return unseal_message( ctxt_handle, message, quality_of_protection ); #else FIXME( "(%lx %p %u %p)\n", context, message, message_seq_no, quality_of_protection ); return SEC_E_UNSUPPORTED_FUNCTION; -- 2.11.0
[View Less]
1
0
0
0
[v4 PATCH] comctl32/tests: Add test for v6 combobox dropdown size
by Nikolay Sivov
06 Feb '18
06 Feb '18
From: Fabian Maurer <dark.shadow4(a)web.de> Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/comctl32/tests/combo.c | 110 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/dlls/comctl32/tests/combo.c b/dlls/comctl32/tests/combo.c index 895d9429b4..da2ded2328 100644 --- a/dlls/comctl32/tests/combo.c +++ b/dlls/comctl32/tests/combo.c @@ -1151,6 +1151,114 @@ static void test_combo_WS_VSCROLL(void) DestroyWindow(hCombo);
…
[View More]
} +static void test_combo_dropdown_size(DWORD style) +{ + static const char wine_test[] = "Wine Test"; + HWND hCombo, hList; + COMBOBOXINFO cbInfo; + int i, test, ret; + + static const struct list_size_info + { + int num_items; + int height_combo; + int limit; + } info_height[] = { + {33, 50, -1}, + {35, 50, 40}, + {15, 50, 3}, + }; + + for (test = 0; test < sizeof(info_height) / sizeof(info_height[0]); test++) + { + const struct list_size_info *info_test = &info_height[test]; + int height_item; /* Height of a list item */ + int height_list; /* Height of the list we got */ + int expected_height_list; + RECT rect_list_client; + int min_visible_expected; + + hCombo = CreateWindowA(WC_COMBOBOXA, "Combo", CBS_DROPDOWN | WS_VISIBLE | WS_CHILD | style, 5, 5, 100, + info_test->height_combo, hMainWnd, (HMENU)COMBO_ID, NULL, 0); + + min_visible_expected = SendMessageA(hCombo, CB_GETMINVISIBLE, 0, 0); + todo_wine + ok(min_visible_expected == 30, "Unexpected number of items %d.\n", min_visible_expected); + + cbInfo.cbSize = sizeof(COMBOBOXINFO); + ret = SendMessageA(hCombo, CB_GETCOMBOBOXINFO, 0, (LPARAM)&cbInfo); + ok(ret, "Failed to get combo info, %d\n", ret); + + hList = cbInfo.hwndList; + for (i = 0; i < info_test->num_items; i++) + { + ret = SendMessageA(hCombo, CB_ADDSTRING, 0, (LPARAM) wine_test); + ok(ret == i, "Failed to add string %d, returned %d.\n", i, ret); + } + + if (info_test->limit != -1) + { + int min_visible_actual; + min_visible_expected = info_test->limit; + + ret = SendMessageA(hCombo, CB_SETMINVISIBLE, min_visible_expected, 0); + todo_wine + ok(ret, "Failed to set visible limit.\n"); + min_visible_actual = SendMessageA(hCombo, CB_GETMINVISIBLE, 0, 0); + todo_wine + ok(min_visible_expected == min_visible_actual, "test %d: unexpected number of items %d.\n", + test, min_visible_actual); + } + + ret = SendMessageA(hCombo, CB_SHOWDROPDOWN, TRUE,0); + ok(ret, "Failed to show dropdown.\n"); + ret = SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0); + ok(ret, "Unexpected dropped state.\n"); + + GetClientRect(hList, &rect_list_client); + height_list = rect_list_client.bottom - rect_list_client.top; + height_item = (int)SendMessageA(hList, LB_GETITEMHEIGHT, 0, 0); + + if (style & CBS_NOINTEGRALHEIGHT) + { + RECT rect_list_complete; + int list_height_nonclient; + int list_height_calculated; + int edit_padding_size = cbInfo.rcItem.top; /* edit client rect top is the padding it has to its parent + We assume it's the same on the bottom */ + + GetWindowRect(hList, &rect_list_complete); + + list_height_nonclient = (rect_list_complete.bottom - rect_list_complete.top) + - (rect_list_client.bottom - rect_list_client.top); + + /* Calculate the expected client size of the listbox popup from the size of the combobox. */ + list_height_calculated = info_test->height_combo /* Take height we created combobox with */ + - (cbInfo.rcItem.bottom - cbInfo.rcItem.top) /* Subtract size of edit control */ + - list_height_nonclient /* Subtract list nonclient area */ + - edit_padding_size * 2; /* subtract space around the edit control */ + + expected_height_list = min(list_height_calculated, height_item * info_test->num_items); + if (expected_height_list < 0) + expected_height_list = 0; + + todo_wine + ok(expected_height_list == height_list, "Test %d, expected list height to be %d, got %d\n", + test, expected_height_list, height_list); + } + else + { + expected_height_list = min(info_test->num_items, min_visible_expected) * height_item; + + todo_wine + ok(expected_height_list == height_list, "Test %d, expected list height to be %d, got %d\n", + test, expected_height_list, height_list); + } + + DestroyWindow(hCombo); + } +} + START_TEST(combo) { ULONG_PTR ctx_cookie; @@ -1192,6 +1300,8 @@ START_TEST(combo) test_combo_listbox_styles(CBS_SIMPLE); test_combo_listbox_styles(CBS_DROPDOWN); test_combo_listbox_styles(CBS_DROPDOWNLIST); + test_combo_dropdown_size(0); + test_combo_dropdown_size(CBS_NOINTEGRALHEIGHT); cleanup(); unload_v6_module(ctx_cookie, hCtx); -- 2.15.1
[View Less]
1
0
0
0
[PATCH] oleaut32/tests: Fix leak (Valgrind).
by Daniel Lehman
06 Feb '18
06 Feb '18
Signed-off-by: Daniel Lehman <dlehman25(a)gmail.com> --- dlls/oleaut32/tests/vartype.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c index 6348fee..9be2eb2 100644 --- a/dlls/oleaut32/tests/vartype.c +++ b/dlls/oleaut32/tests/vartype.c @@ -6074,6 +6074,7 @@ static void test_recinfo(void) IRecordInfo_Release(recinfo); ITypeInfo_Release(typeinfo); + ITypeLib_Release(typelib2); ITypeLib_Release(typelib);
…
[View More]
DeleteFileW(filenameW); DeleteFileW(filename2W); -- 2.7.4
[View Less]
1
0
0
0
[PATCH 1/5] comctl32: Introduce Button control
by Nikolay Sivov
06 Feb '18
06 Feb '18
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/comctl32/Makefile.in | 1 + dlls/comctl32/button.c | 1153 ++++++++++++++++++++++++++++++++++++++++++ dlls/comctl32/comctl32.h | 1 + dlls/comctl32/commctrl.c | 2 + dlls/comctl32/tests/button.c | 18 +- dlls/comctl32/tests/misc.c | 3 +- dlls/user32/class.c | 1 - 7 files changed, 1164 insertions(+), 15 deletions(-) create mode 100644 dlls/comctl32/button.c diff --git a/dlls/
…
[View More]
comctl32/Makefile.in b/dlls/comctl32/Makefile.in index db65bbc400..37bc025510 100644 --- a/dlls/comctl32/Makefile.in +++ b/dlls/comctl32/Makefile.in @@ -6,6 +6,7 @@ DELAYIMPORTS = winmm uxtheme C_SRCS = \ animate.c \ + button.c \ comboex.c \ comctl32undoc.c \ commctrl.c \ diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c new file mode 100644 index 0000000000..de036c6542 --- /dev/null +++ b/dlls/comctl32/button.c @@ -0,0 +1,1153 @@ +/* + * Copyright (C) 1993 Johannes Ruscheinski + * Copyright (C) 1993 David Metcalfe + * Copyright (C) 1994 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * + * NOTES + * + * This code was audited for completeness against the documented features + * of Comctl32.dll version 6.0 on Oct. 3, 2004, by Dimitrie O. Paun. + * + * Unless otherwise noted, we believe this code to be complete, as per + * the specification mentioned above. + * If you discover missing features, or bugs, please note them below. + * + * TODO + * Styles + * - BS_NOTIFY: is it complete? + * - BS_RIGHTBUTTON: same as BS_LEFTTEXT + * + * Messages + * - WM_CHAR: Checks a (manual or automatic) check box on '+' or '=', clears it on '-' key. + * - WM_SETFOCUS: For (manual or automatic) radio buttons, send the parent window BN_CLICKED + * - WM_NCCREATE: Turns any BS_OWNERDRAW button into a BS_PUSHBUTTON button. + * - WM_SYSKEYUP + * - BCM_GETIDEALSIZE + * - BCM_GETIMAGELIST + * - BCM_GETTEXTMARGIN + * - BCM_SETIMAGELIST + * - BCM_SETTEXTMARGIN + * + * Notifications + * - BCN_HOTITEMCHANGE + * - BN_DISABLE + * - BN_PUSHED/BN_HILITE + * + BN_KILLFOCUS: is it OK? + * - BN_PAINT + * + BN_SETFOCUS: is it OK? + * - BN_UNPUSHED/BN_UNHILITE + * - NM_CUSTOMDRAW + * + * Structures/Macros/Definitions + * - BUTTON_IMAGELIST + * - NMBCHOTITEM + * - Button_GetIdealSize + * - Button_GetImageList + * - Button_GetTextMargin + * - Button_SetImageList + * - Button_SetTextMargin + */ + +#include <stdarg.h> +#include <string.h> +#include <stdlib.h> + +#define OEMRESOURCE + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "wine/debug.h" + +#include "comctl32.h" + +WINE_DEFAULT_DEBUG_CHANNEL(button); + +/* GetWindowLong offsets for window extra information */ +#define STATE_GWL_OFFSET 0 +#define HFONT_GWL_OFFSET (sizeof(LONG)) +#define HIMAGE_GWL_OFFSET (HFONT_GWL_OFFSET+sizeof(HFONT)) +#define NB_EXTRA_BYTES (HIMAGE_GWL_OFFSET+sizeof(HANDLE)) + +/* undocumented flags */ +#define BUTTON_NSTATES 0x0F +#define BUTTON_BTNPRESSED 0x40 +#define BUTTON_UNKNOWN2 0x20 +#define BUTTON_UNKNOWN3 0x10 + +#define BUTTON_NOTIFY_PARENT(hWnd, code) \ + do { /* Notify parent which has created this button control */ \ + TRACE("notification " #code " sent to hwnd=%p\n", GetParent(hWnd)); \ + SendMessageW(GetParent(hWnd), WM_COMMAND, \ + MAKEWPARAM(GetWindowLongPtrW((hWnd),GWLP_ID), (code)), \ + (LPARAM)(hWnd)); \ + } while(0) + +static UINT BUTTON_CalcLabelRect( HWND hwnd, HDC hdc, RECT *rc ); +static void PB_Paint( HWND hwnd, HDC hDC, UINT action ); +static void CB_Paint( HWND hwnd, HDC hDC, UINT action ); +static void GB_Paint( HWND hwnd, HDC hDC, UINT action ); +static void UB_Paint( HWND hwnd, HDC hDC, UINT action ); +static void OB_Paint( HWND hwnd, HDC hDC, UINT action ); +static void BUTTON_CheckAutoRadioButton( HWND hwnd ); + +#define MAX_BTN_TYPE 16 + +static const WORD maxCheckState[MAX_BTN_TYPE] = +{ + BST_UNCHECKED, /* BS_PUSHBUTTON */ + BST_UNCHECKED, /* BS_DEFPUSHBUTTON */ + BST_CHECKED, /* BS_CHECKBOX */ + BST_CHECKED, /* BS_AUTOCHECKBOX */ + BST_CHECKED, /* BS_RADIOBUTTON */ + BST_INDETERMINATE, /* BS_3STATE */ + BST_INDETERMINATE, /* BS_AUTO3STATE */ + BST_UNCHECKED, /* BS_GROUPBOX */ + BST_UNCHECKED, /* BS_USERBUTTON */ + BST_CHECKED, /* BS_AUTORADIOBUTTON */ + BST_UNCHECKED, /* BS_PUSHBOX */ + BST_UNCHECKED /* BS_OWNERDRAW */ +}; + +typedef void (*pfPaint)( HWND hwnd, HDC hdc, UINT action ); + +static const pfPaint btnPaintFunc[MAX_BTN_TYPE] = +{ + PB_Paint, /* BS_PUSHBUTTON */ + PB_Paint, /* BS_DEFPUSHBUTTON */ + CB_Paint, /* BS_CHECKBOX */ + CB_Paint, /* BS_AUTOCHECKBOX */ + CB_Paint, /* BS_RADIOBUTTON */ + CB_Paint, /* BS_3STATE */ + CB_Paint, /* BS_AUTO3STATE */ + GB_Paint, /* BS_GROUPBOX */ + UB_Paint, /* BS_USERBUTTON */ + CB_Paint, /* BS_AUTORADIOBUTTON */ + NULL, /* BS_PUSHBOX */ + OB_Paint /* BS_OWNERDRAW */ +}; + +/********************************************************************* + * button class descriptor + */ + +static inline LONG get_button_state( HWND hwnd ) +{ + return GetWindowLongW( hwnd, STATE_GWL_OFFSET ); +} + +static inline void set_button_state( HWND hwnd, LONG state ) +{ + SetWindowLongW( hwnd, STATE_GWL_OFFSET, state ); +} + +static inline HFONT get_button_font( HWND hwnd ) +{ + return (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET ); +} + +static inline void set_button_font( HWND hwnd, HFONT font ) +{ + SetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET, (LONG_PTR)font ); +} + +static inline UINT get_button_type( LONG window_style ) +{ + return (window_style & BS_TYPEMASK); +} + +/* paint a button of any type */ +static inline void paint_button( HWND hwnd, LONG style, UINT action ) +{ + if (btnPaintFunc[style] && IsWindowVisible(hwnd)) + { + HDC hdc = GetDC( hwnd ); + btnPaintFunc[style]( hwnd, hdc, action ); + ReleaseDC( hwnd, hdc ); + } +} + +/* retrieve the button text; returned buffer must be freed by caller */ +static inline WCHAR *get_button_text( HWND hwnd ) +{ + static const INT len = 512; + WCHAR *buffer = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ); + if (buffer) InternalGetWindowText( hwnd, buffer, len + 1 ); + return buffer; +} + +static HRGN set_control_clipping( HDC hdc, const RECT *rect ) +{ + RECT rc = *rect; + HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 ); + + if (GetClipRgn( hdc, hrgn ) != 1) + { + DeleteObject( hrgn ); + hrgn = 0; + } + DPtoLP( hdc, (POINT *)&rc, 2 ); + if (GetLayout( hdc ) & LAYOUT_RTL) /* compensate for the shifting done by IntersectClipRect */ + { + rc.left++; + rc.right++; + } + IntersectClipRect( hdc, rc.left, rc.top, rc.right, rc.bottom ); + return hrgn; +} + +static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + RECT rect; + POINT pt; + LONG style = GetWindowLongW( hWnd, GWL_STYLE ); + UINT btn_type = get_button_type( style ); + LONG state; + HANDLE oldHbitmap; + + if (!IsWindow( hWnd )) return 0; + + pt.x = (short)LOWORD(lParam); + pt.y = (short)HIWORD(lParam); + + switch (uMsg) + { + case WM_GETDLGCODE: + switch(btn_type) + { + case BS_USERBUTTON: + case BS_PUSHBUTTON: return DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON; + case BS_DEFPUSHBUTTON: return DLGC_BUTTON | DLGC_DEFPUSHBUTTON; + case BS_RADIOBUTTON: + case BS_AUTORADIOBUTTON: return DLGC_BUTTON | DLGC_RADIOBUTTON; + case BS_GROUPBOX: return DLGC_STATIC; + default: return DLGC_BUTTON; + } + + case WM_ENABLE: + paint_button( hWnd, btn_type, ODA_DRAWENTIRE ); + break; + + case WM_CREATE: + if (btn_type >= MAX_BTN_TYPE) + return -1; /* abort */ + + /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */ + if (btn_type == BS_USERBUTTON ) + { + style = (style & ~BS_TYPEMASK) | BS_PUSHBUTTON; + SetWindowLongW( hWnd, GWL_STYLE, style ); + } + set_button_state( hWnd, BST_UNCHECKED ); + return 0; + + case WM_ERASEBKGND: + if (btn_type == BS_OWNERDRAW) + { + HDC hdc = (HDC)wParam; + RECT rc; + HBRUSH hBrush; + HWND parent = GetParent(hWnd); + if (!parent) parent = hWnd; + hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hdc, (LPARAM)hWnd); + if (!hBrush) /* did the app forget to call defwindowproc ? */ + hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN, + (WPARAM)hdc, (LPARAM)hWnd); + GetClientRect(hWnd, &rc); + FillRect(hdc, &rc, hBrush); + } + return 1; + + case WM_PRINTCLIENT: + case WM_PAINT: + { + PAINTSTRUCT ps; + HDC hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps ); + if (btnPaintFunc[btn_type]) + { + int nOldMode = SetBkMode( hdc, OPAQUE ); + (btnPaintFunc[btn_type])( hWnd, hdc, ODA_DRAWENTIRE ); + SetBkMode(hdc, nOldMode); /* reset painting mode */ + } + if ( !wParam ) EndPaint( hWnd, &ps ); + break; + } + + case WM_KEYDOWN: + if (wParam == VK_SPACE) + { + SendMessageW( hWnd, BM_SETSTATE, TRUE, 0 ); + set_button_state( hWnd, get_button_state( hWnd ) | BUTTON_BTNPRESSED ); + SetCapture( hWnd ); + } + break; + + case WM_LBUTTONDBLCLK: + if(style & BS_NOTIFY || + btn_type == BS_RADIOBUTTON || + btn_type == BS_USERBUTTON || + btn_type == BS_OWNERDRAW) + { + BUTTON_NOTIFY_PARENT(hWnd, BN_DOUBLECLICKED); + break; + } + /* fall through */ + case WM_LBUTTONDOWN: + SetCapture( hWnd ); + SetFocus( hWnd ); + set_button_state( hWnd, get_button_state( hWnd ) | BUTTON_BTNPRESSED ); + SendMessageW( hWnd, BM_SETSTATE, TRUE, 0 ); + break; + + case WM_KEYUP: + if (wParam != VK_SPACE) + break; + /* fall through */ + case WM_LBUTTONUP: + state = get_button_state( hWnd ); + if (!(state & BUTTON_BTNPRESSED)) break; + state &= BUTTON_NSTATES; + set_button_state( hWnd, state ); + if (!(state & BST_PUSHED)) + { + ReleaseCapture(); + break; + } + SendMessageW( hWnd, BM_SETSTATE, FALSE, 0 ); + GetClientRect( hWnd, &rect ); + if (uMsg == WM_KEYUP || PtInRect( &rect, pt )) + { + state = get_button_state( hWnd ); + switch(btn_type) + { + case BS_AUTOCHECKBOX: + SendMessageW( hWnd, BM_SETCHECK, !(state & BST_CHECKED), 0 ); + break; + case BS_AUTORADIOBUTTON: + SendMessageW( hWnd, BM_SETCHECK, TRUE, 0 ); + break; + case BS_AUTO3STATE: + SendMessageW( hWnd, BM_SETCHECK, + (state & BST_INDETERMINATE) ? 0 : ((state & 3) + 1), 0 ); + break; + } + ReleaseCapture(); + BUTTON_NOTIFY_PARENT(hWnd, BN_CLICKED); + } + else + { + ReleaseCapture(); + } + break; + + case WM_CAPTURECHANGED: + TRACE("WM_CAPTURECHANGED %p\n", hWnd); + if (hWnd == (HWND)lParam) break; + state = get_button_state( hWnd ); + if (state & BUTTON_BTNPRESSED) + { + state &= BUTTON_NSTATES; + set_button_state( hWnd, state ); + if (state & BST_PUSHED) SendMessageW( hWnd, BM_SETSTATE, FALSE, 0 ); + } + break; + + case WM_MOUSEMOVE: + if ((wParam & MK_LBUTTON) && GetCapture() == hWnd) + { + GetClientRect( hWnd, &rect ); + SendMessageW( hWnd, BM_SETSTATE, PtInRect(&rect, pt), 0 ); + } + break; + + case WM_SETTEXT: + { + /* Clear an old text here as Windows does */ + if (IsWindowVisible(hWnd)) + { + HDC hdc = GetDC(hWnd); + HBRUSH hbrush; + RECT client, rc; + HWND parent = GetParent(hWnd); + UINT message = (btn_type == BS_PUSHBUTTON || + btn_type == BS_DEFPUSHBUTTON || + btn_type == BS_USERBUTTON || + btn_type == BS_OWNERDRAW) ? + WM_CTLCOLORBTN : WM_CTLCOLORSTATIC; + + if (!parent) parent = hWnd; + hbrush = (HBRUSH)SendMessageW(parent, message, + (WPARAM)hdc, (LPARAM)hWnd); + if (!hbrush) /* did the app forget to call DefWindowProc ? */ + hbrush = (HBRUSH)DefWindowProcW(parent, message, + (WPARAM)hdc, (LPARAM)hWnd); + + GetClientRect(hWnd, &client); + rc = client; + /* FIXME: check other BS_* handlers */ + if (btn_type == BS_GROUPBOX) + InflateRect(&rc, -7, 1); /* GB_Paint does this */ + BUTTON_CalcLabelRect(hWnd, hdc, &rc); + /* Clip by client rect bounds */ + if (rc.right > client.right) rc.right = client.right; + if (rc.bottom > client.bottom) rc.bottom = client.bottom; + FillRect(hdc, &rc, hbrush); + ReleaseDC(hWnd, hdc); + } + + DefWindowProcW( hWnd, WM_SETTEXT, wParam, lParam ); + if (btn_type == BS_GROUPBOX) /* Yes, only for BS_GROUPBOX */ + InvalidateRect( hWnd, NULL, TRUE ); + else + paint_button( hWnd, btn_type, ODA_DRAWENTIRE ); + return 1; /* success. FIXME: check text length */ + } + + case WM_SETFONT: + set_button_font( hWnd, (HFONT)wParam ); + if (lParam) InvalidateRect(hWnd, NULL, TRUE); + break; + + case WM_GETFONT: + return (LRESULT)get_button_font( hWnd ); + + case WM_SETFOCUS: + TRACE("WM_SETFOCUS %p\n",hWnd); + set_button_state( hWnd, get_button_state(hWnd) | BST_FOCUS ); + paint_button( hWnd, btn_type, ODA_FOCUS ); + if (style & BS_NOTIFY) + BUTTON_NOTIFY_PARENT(hWnd, BN_SETFOCUS); + break; + + case WM_KILLFOCUS: + TRACE("WM_KILLFOCUS %p\n",hWnd); + state = get_button_state( hWnd ); + set_button_state( hWnd, state & ~BST_FOCUS ); + paint_button( hWnd, btn_type, ODA_FOCUS ); + + if ((state & BUTTON_BTNPRESSED) && GetCapture() == hWnd) + ReleaseCapture(); + if (style & BS_NOTIFY) + BUTTON_NOTIFY_PARENT(hWnd, BN_KILLFOCUS); + + InvalidateRect( hWnd, NULL, FALSE ); + break; + + case WM_SYSCOLORCHANGE: + InvalidateRect( hWnd, NULL, FALSE ); + break; + + case BM_SETSTYLE: + btn_type = wParam & BS_TYPEMASK; + style = (style & ~BS_TYPEMASK) | btn_type; + SetWindowLongW( hWnd, GWL_STYLE, style ); + + /* Only redraw if lParam flag is set.*/ + if (lParam) + InvalidateRect( hWnd, NULL, TRUE ); + + break; + + case BM_CLICK: + SendMessageW( hWnd, WM_LBUTTONDOWN, 0, 0 ); + SendMessageW( hWnd, WM_LBUTTONUP, 0, 0 ); + break; + + case BM_SETIMAGE: + /* Check that image format matches button style */ + switch (style & (BS_BITMAP|BS_ICON)) + { + case BS_BITMAP: + if (wParam != IMAGE_BITMAP) return 0; + break; + case BS_ICON: + if (wParam != IMAGE_ICON) return 0; + break; + default: + return 0; + } + oldHbitmap = (HBITMAP)SetWindowLongPtrW( hWnd, HIMAGE_GWL_OFFSET, lParam ); + InvalidateRect( hWnd, NULL, FALSE ); + return (LRESULT)oldHbitmap; + + case BM_GETIMAGE: + return GetWindowLongPtrW( hWnd, HIMAGE_GWL_OFFSET ); + + case BM_GETCHECK: + return get_button_state( hWnd ) & 3; + + case BM_SETCHECK: + if (wParam > maxCheckState[btn_type]) wParam = maxCheckState[btn_type]; + state = get_button_state( hWnd ); + if ((btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON)) + { + style = wParam ? style | WS_TABSTOP : style & ~WS_TABSTOP; + SetWindowLongW( hWnd, GWL_STYLE, style ); + } + if ((state & 3) != wParam) + { + set_button_state( hWnd, (state & ~3) | wParam ); + paint_button( hWnd, btn_type, ODA_SELECT ); + } + if ((btn_type == BS_AUTORADIOBUTTON) && (wParam == BST_CHECKED) && (style & WS_CHILD)) + BUTTON_CheckAutoRadioButton( hWnd ); + break; + + case BM_GETSTATE: + return get_button_state( hWnd ); + + case BM_SETSTATE: + state = get_button_state( hWnd ); + if (wParam) + set_button_state( hWnd, state | BST_PUSHED ); + else + set_button_state( hWnd, state & ~BST_PUSHED ); + + paint_button( hWnd, btn_type, ODA_SELECT ); + break; + + case WM_NCHITTEST: + if(btn_type == BS_GROUPBOX) return HTTRANSPARENT; + /* fall through */ + default: + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + } + return 0; +} + +/********************************************************************** + * Convert button styles to flags used by DrawText. + */ +static UINT BUTTON_BStoDT( DWORD style, DWORD ex_style ) +{ + UINT dtStyle = DT_NOCLIP; /* We use SelectClipRgn to limit output */ + + /* "Convert" pushlike buttons to pushbuttons */ + if (style & BS_PUSHLIKE) + style &= ~BS_TYPEMASK; + + if (!(style & BS_MULTILINE)) + dtStyle |= DT_SINGLELINE; + else + dtStyle |= DT_WORDBREAK; + + switch (style & BS_CENTER) + { + case BS_LEFT: /* DT_LEFT is 0 */ break; + case BS_RIGHT: dtStyle |= DT_RIGHT; break; + case BS_CENTER: dtStyle |= DT_CENTER; break; + default: + /* Pushbutton's text is centered by default */ + if (get_button_type(style) <= BS_DEFPUSHBUTTON) dtStyle |= DT_CENTER; + /* all other flavours have left aligned text */ + } + + if (ex_style & WS_EX_RIGHT) dtStyle = DT_RIGHT | (dtStyle & ~(DT_LEFT | DT_CENTER)); + + /* DrawText ignores vertical alignment for multiline text, + * but we use these flags to align label manually. + */ + if (get_button_type(style) != BS_GROUPBOX) + { + switch (style & BS_VCENTER) + { + case BS_TOP: /* DT_TOP is 0 */ break; + case BS_BOTTOM: dtStyle |= DT_BOTTOM; break; + case BS_VCENTER: /* fall through */ + default: dtStyle |= DT_VCENTER; break; + } + } + else + /* GroupBox's text is always single line and is top aligned. */ + dtStyle |= DT_SINGLELINE; + + return dtStyle; +} + +/********************************************************************** + * BUTTON_CalcLabelRect + * + * Calculates label's rectangle depending on button style. + * + * Returns flags to be passed to DrawText. + * Calculated rectangle doesn't take into account button state + * (pushed, etc.). If there is nothing to draw (no text/image) output + * rectangle is empty, and return value is (UINT)-1. + */ +static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc) +{ + LONG style = GetWindowLongW( hwnd, GWL_STYLE ); + LONG ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE ); + WCHAR *text; + ICONINFO iconInfo; + BITMAP bm; + UINT dtStyle = BUTTON_BStoDT( style, ex_style ); + RECT r = *rc; + INT n; + + /* Calculate label rectangle according to label type */ + switch (style & (BS_ICON|BS_BITMAP)) + { + case BS_TEXT: + { + HFONT hFont, hPrevFont = 0; + + if (!(text = get_button_text( hwnd ))) goto empty_rect; + if (!text[0]) + { + HeapFree( GetProcessHeap(), 0, text ); + goto empty_rect; + } + + if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hdc, hFont ); + DrawTextW(hdc, text, -1, &r, dtStyle | DT_CALCRECT); + if (hPrevFont) SelectObject( hdc, hPrevFont ); + HeapFree( GetProcessHeap(), 0, text ); + break; + } + + case BS_ICON: + if (!GetIconInfo((HICON)GetWindowLongPtrW( hwnd, HIMAGE_GWL_OFFSET ), &iconInfo)) + goto empty_rect; + + GetObjectW (iconInfo.hbmColor, sizeof(BITMAP), &bm); + + r.right = r.left + bm.bmWidth; + r.bottom = r.top + bm.bmHeight; + + DeleteObject(iconInfo.hbmColor); + DeleteObject(iconInfo.hbmMask); + break; + + case BS_BITMAP: + if (!GetObjectW( (HANDLE)GetWindowLongPtrW( hwnd, HIMAGE_GWL_OFFSET ), sizeof(BITMAP), &bm)) + goto empty_rect; + + r.right = r.left + bm.bmWidth; + r.bottom = r.top + bm.bmHeight; + break; + + default: + empty_rect: + rc->right = r.left; + rc->bottom = r.top; + return (UINT)-1; + } + + /* Position label inside bounding rectangle according to + * alignment flags. (calculated rect is always left-top aligned). + * If label is aligned to any side - shift label in opposite + * direction to leave extra space for focus rectangle. + */ + switch (dtStyle & (DT_CENTER|DT_RIGHT)) + { + case DT_LEFT: r.left++; r.right++; break; + case DT_CENTER: n = r.right - r.left; + r.left = rc->left + ((rc->right - rc->left) - n) / 2; + r.right = r.left + n; break; + case DT_RIGHT: n = r.right - r.left; + r.right = rc->right - 1; + r.left = r.right - n; + break; + } + + switch (dtStyle & (DT_VCENTER|DT_BOTTOM)) + { + case DT_TOP: r.top++; r.bottom++; break; + case DT_VCENTER: n = r.bottom - r.top; + r.top = rc->top + ((rc->bottom - rc->top) - n) / 2; + r.bottom = r.top + n; break; + case DT_BOTTOM: n = r.bottom - r.top; + r.bottom = rc->bottom - 1; + r.top = r.bottom - n; + break; + } + + *rc = r; + return dtStyle; +} + + +/********************************************************************** + * BUTTON_DrawTextCallback + * + * Callback function used by DrawStateW function. + */ +static BOOL CALLBACK BUTTON_DrawTextCallback(HDC hdc, LPARAM lp, WPARAM wp, int cx, int cy) +{ + RECT rc; + + SetRect(&rc, 0, 0, cx, cy); + DrawTextW(hdc, (LPCWSTR)lp, -1, &rc, (UINT)wp); + return TRUE; +} + + +/********************************************************************** + * BUTTON_DrawLabel + * + * Common function for drawing button label. + */ +static void BUTTON_DrawLabel(HWND hwnd, HDC hdc, UINT dtFlags, const RECT *rc) +{ + DRAWSTATEPROC lpOutputProc = NULL; + LPARAM lp; + WPARAM wp = 0; + HBRUSH hbr = 0; + UINT flags = IsWindowEnabled(hwnd) ? DSS_NORMAL : DSS_DISABLED; + LONG state = get_button_state( hwnd ); + LONG style = GetWindowLongW( hwnd, GWL_STYLE ); + WCHAR *text = NULL; + + /* FIXME: To draw disabled label in Win31 look-and-feel, we probably + * must use DSS_MONO flag and COLOR_GRAYTEXT brush (or maybe DSS_UNION). + * I don't have Win31 on hand to verify that, so I leave it as is. + */ + + if ((style & BS_PUSHLIKE) && (state & BST_INDETERMINATE)) + { + hbr = GetSysColorBrush(COLOR_GRAYTEXT); + flags |= DSS_MONO; + } + + switch (style & (BS_ICON|BS_BITMAP)) + { + case BS_TEXT: + /* DST_COMPLEX -- is 0 */ + lpOutputProc = BUTTON_DrawTextCallback; + if (!(text = get_button_text( hwnd ))) return; + lp = (LPARAM)text; + wp = dtFlags; + break; + + case BS_ICON: + flags |= DST_ICON; + lp = GetWindowLongPtrW( hwnd, HIMAGE_GWL_OFFSET ); + break; + + case BS_BITMAP: + flags |= DST_BITMAP; + lp = GetWindowLongPtrW( hwnd, HIMAGE_GWL_OFFSET ); + break; + + default: + return; + } + + DrawStateW(hdc, hbr, lpOutputProc, lp, wp, rc->left, rc->top, + rc->right - rc->left, rc->bottom - rc->top, flags); + HeapFree( GetProcessHeap(), 0, text ); +} + +/********************************************************************** + * Push Button Functions + */ +static void PB_Paint( HWND hwnd, HDC hDC, UINT action ) +{ + RECT rc, r; + UINT dtFlags, uState; + HPEN hOldPen, hpen; + HBRUSH hOldBrush; + INT oldBkMode; + COLORREF oldTxtColor; + HFONT hFont; + LONG state = get_button_state( hwnd ); + LONG style = GetWindowLongW( hwnd, GWL_STYLE ); + BOOL pushedState = (state & BST_PUSHED); + HWND parent; + HRGN hrgn; + + GetClientRect( hwnd, &rc ); + + /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */ + if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont ); + parent = GetParent(hwnd); + if (!parent) parent = hwnd; + SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd ); + + hrgn = set_control_clipping( hDC, &rc ); + + hpen = CreatePen( PS_SOLID, 1, GetSysColor(COLOR_WINDOWFRAME)); + hOldPen = SelectObject(hDC, hpen); + hOldBrush = SelectObject(hDC,GetSysColorBrush(COLOR_BTNFACE)); + oldBkMode = SetBkMode(hDC, TRANSPARENT); + + if (get_button_type(style) == BS_DEFPUSHBUTTON) + { + if (action != ODA_FOCUS) + Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom); + InflateRect( &rc, -1, -1 ); + } + + /* completely skip the drawing if only focus has changed */ + if (action == ODA_FOCUS) goto draw_focus; + + uState = DFCS_BUTTONPUSH; + + if (style & BS_FLAT) + uState |= DFCS_MONO; + else if (pushedState) + { + if (get_button_type(style) == BS_DEFPUSHBUTTON ) + uState |= DFCS_FLAT; + else + uState |= DFCS_PUSHED; + } + + if (state & (BST_CHECKED | BST_INDETERMINATE)) + uState |= DFCS_CHECKED; + + DrawFrameControl( hDC, &rc, DFC_BUTTON, uState ); + + /* draw button label */ + r = rc; + dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &r); + + if (dtFlags == (UINT)-1L) + goto cleanup; + + if (pushedState) + OffsetRect(&r, 1, 1); + + oldTxtColor = SetTextColor( hDC, GetSysColor(COLOR_BTNTEXT) ); + + BUTTON_DrawLabel(hwnd, hDC, dtFlags, &r); + + SetTextColor( hDC, oldTxtColor ); + +draw_focus: + if (action == ODA_FOCUS || (state & BST_FOCUS)) + { + InflateRect( &rc, -2, -2 ); + DrawFocusRect( hDC, &rc ); + } + + cleanup: + SelectObject( hDC, hOldPen ); + SelectObject( hDC, hOldBrush ); + SetBkMode(hDC, oldBkMode); + SelectClipRgn( hDC, hrgn ); + if (hrgn) DeleteObject( hrgn ); + DeleteObject( hpen ); +} + +/********************************************************************** + * Check Box & Radio Button Functions + */ + +static void CB_Paint( HWND hwnd, HDC hDC, UINT action ) +{ + RECT rbox, rtext, client; + HBRUSH hBrush; + int delta, text_offset, checkBoxWidth, checkBoxHeight; + UINT dtFlags; + HFONT hFont; + LONG state = get_button_state( hwnd ); + LONG style = GetWindowLongW( hwnd, GWL_STYLE ); + LONG ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE ); + HWND parent; + HRGN hrgn; + + if (style & BS_PUSHLIKE) + { + PB_Paint( hwnd, hDC, action ); + return; + } + + GetClientRect(hwnd, &client); + rbox = rtext = client; + + checkBoxWidth = 12 * GetDeviceCaps( hDC, LOGPIXELSX ) / 96 + 1; + checkBoxHeight = 12 * GetDeviceCaps( hDC, LOGPIXELSY ) / 96 + 1; + + if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont ); + GetCharWidthW( hDC, '0', '0', &text_offset ); + text_offset /= 2; + + parent = GetParent(hwnd); + if (!parent) parent = hwnd; + hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC, + (WPARAM)hDC, (LPARAM)hwnd); + if (!hBrush) /* did the app forget to call defwindowproc ? */ + hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC, + (WPARAM)hDC, (LPARAM)hwnd ); + hrgn = set_control_clipping( hDC, &client ); + + if (style & BS_LEFTTEXT || ex_style & WS_EX_RIGHT) + { + rtext.right -= checkBoxWidth + text_offset; + rbox.left = rbox.right - checkBoxWidth; + } + else + { + rtext.left += checkBoxWidth + text_offset; + rbox.right = checkBoxWidth; + } + + /* Since WM_ERASEBKGND does nothing, first prepare background */ + if (action == ODA_SELECT) FillRect( hDC, &rbox, hBrush ); + if (action == ODA_DRAWENTIRE) FillRect( hDC, &client, hBrush ); + + /* Draw label */ + client = rtext; + dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &rtext); + + /* Only adjust rbox when rtext is valid */ + if (dtFlags != (UINT)-1L) + { + rbox.top = rtext.top; + rbox.bottom = rtext.bottom; + } + + /* Draw the check-box bitmap */ + if (action == ODA_DRAWENTIRE || action == ODA_SELECT) + { + UINT flags; + + if ((get_button_type(style) == BS_RADIOBUTTON) || + (get_button_type(style) == BS_AUTORADIOBUTTON)) flags = DFCS_BUTTONRADIO; + else if (state & BST_INDETERMINATE) flags = DFCS_BUTTON3STATE; + else flags = DFCS_BUTTONCHECK; + + if (state & (BST_CHECKED | BST_INDETERMINATE)) flags |= DFCS_CHECKED; + if (state & BST_PUSHED) flags |= DFCS_PUSHED; + + if (style & WS_DISABLED) flags |= DFCS_INACTIVE; + + /* rbox must have the correct height */ + delta = rbox.bottom - rbox.top - checkBoxHeight; + + if (style & BS_TOP) { + if (delta > 0) { + rbox.bottom = rbox.top + checkBoxHeight; + } else { + rbox.top -= -delta/2 + 1; + rbox.bottom = rbox.top + checkBoxHeight; + } + } else if (style & BS_BOTTOM) { + if (delta > 0) { + rbox.top = rbox.bottom - checkBoxHeight; + } else { + rbox.bottom += -delta/2 + 1; + rbox.top = rbox.bottom - checkBoxHeight; + } + } else { /* Default */ + if (delta > 0) { + int ofs = (delta / 2); + rbox.bottom -= ofs + 1; + rbox.top = rbox.bottom - checkBoxHeight; + } else if (delta < 0) { + int ofs = (-delta / 2); + rbox.top -= ofs + 1; + rbox.bottom = rbox.top + checkBoxHeight; + } + } + + DrawFrameControl( hDC, &rbox, DFC_BUTTON, flags ); + } + + if (dtFlags == (UINT)-1L) /* Noting to draw */ + return; + + if (action == ODA_DRAWENTIRE) + BUTTON_DrawLabel(hwnd, hDC, dtFlags, &rtext); + + /* ... and focus */ + if (action == ODA_FOCUS || (state & BST_FOCUS)) + { + rtext.left--; + rtext.right++; + IntersectRect(&rtext, &rtext, &client); + DrawFocusRect( hDC, &rtext ); + } + SelectClipRgn( hDC, hrgn ); + if (hrgn) DeleteObject( hrgn ); +} + + +/********************************************************************** + * BUTTON_CheckAutoRadioButton + * + * hwnd is checked, uncheck every other auto radio button in group + */ +static void BUTTON_CheckAutoRadioButton( HWND hwnd ) +{ + HWND parent, sibling, start; + + parent = GetParent(hwnd); + /* make sure that starting control is not disabled or invisible */ + start = sibling = GetNextDlgGroupItem( parent, hwnd, TRUE ); + do + { + if (!sibling) break; + if ((hwnd != sibling) && + ((GetWindowLongW( sibling, GWL_STYLE) & BS_TYPEMASK) == BS_AUTORADIOBUTTON)) + SendMessageW( sibling, BM_SETCHECK, BST_UNCHECKED, 0 ); + sibling = GetNextDlgGroupItem( parent, sibling, FALSE ); + } while (sibling != start); +} + + +/********************************************************************** + * Group Box Functions + */ + +static void GB_Paint( HWND hwnd, HDC hDC, UINT action ) +{ + RECT rc, rcFrame; + HBRUSH hbr; + HFONT hFont; + UINT dtFlags; + TEXTMETRICW tm; + LONG style = GetWindowLongW( hwnd, GWL_STYLE ); + HWND parent; + HRGN hrgn; + + if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont ); + /* GroupBox acts like static control, so it sends CTLCOLORSTATIC */ + parent = GetParent(hwnd); + if (!parent) parent = hwnd; + hbr = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)hwnd); + if (!hbr) /* did the app forget to call defwindowproc ? */ + hbr = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC, + (WPARAM)hDC, (LPARAM)hwnd); + GetClientRect( hwnd, &rc); + rcFrame = rc; + hrgn = set_control_clipping( hDC, &rc ); + + GetTextMetricsW (hDC, &tm); + rcFrame.top += (tm.tmHeight / 2) - 1; + DrawEdge (hDC, &rcFrame, EDGE_ETCHED, BF_RECT | ((style & BS_FLAT) ? BF_FLAT : 0)); + + InflateRect(&rc, -7, 1); + dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &rc); + + if (dtFlags != (UINT)-1) + { + /* Because buttons have CS_PARENTDC class style, there is a chance + * that label will be drawn out of client rect. + * But Windows doesn't clip label's rect, so do I. + */ + + /* There is 1-pixel margin at the left, right, and bottom */ + rc.left--; rc.right++; rc.bottom++; + FillRect(hDC, &rc, hbr); + rc.left++; rc.right--; rc.bottom--; + + BUTTON_DrawLabel(hwnd, hDC, dtFlags, &rc); + } + SelectClipRgn( hDC, hrgn ); + if (hrgn) DeleteObject( hrgn ); +} + + +/********************************************************************** + * User Button Functions + */ + +static void UB_Paint( HWND hwnd, HDC hDC, UINT action ) +{ + RECT rc; + HBRUSH hBrush; + HFONT hFont; + LONG state = get_button_state( hwnd ); + HWND parent; + + GetClientRect( hwnd, &rc); + + if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont ); + + parent = GetParent(hwnd); + if (!parent) parent = hwnd; + hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd); + if (!hBrush) /* did the app forget to call defwindowproc ? */ + hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN, + (WPARAM)hDC, (LPARAM)hwnd); + + FillRect( hDC, &rc, hBrush ); + if (action == ODA_FOCUS || (state & BST_FOCUS)) + DrawFocusRect( hDC, &rc ); + + switch (action) + { + case ODA_FOCUS: + BUTTON_NOTIFY_PARENT( hwnd, (state & BST_FOCUS) ? BN_SETFOCUS : BN_KILLFOCUS ); + break; + + case ODA_SELECT: + BUTTON_NOTIFY_PARENT( hwnd, (state & BST_PUSHED) ? BN_HILITE : BN_UNHILITE ); + break; + + default: + BUTTON_NOTIFY_PARENT( hwnd, BN_PAINT ); + break; + } +} + + +/********************************************************************** + * Ownerdrawn Button Functions + */ + +static void OB_Paint( HWND hwnd, HDC hDC, UINT action ) +{ + LONG state = get_button_state( hwnd ); + DRAWITEMSTRUCT dis; + LONG_PTR id = GetWindowLongPtrW( hwnd, GWLP_ID ); + HWND parent; + HFONT hFont, hPrevFont = 0; + HRGN hrgn; + + dis.CtlType = ODT_BUTTON; + dis.CtlID = id; + dis.itemID = 0; + dis.itemAction = action; + dis.itemState = ((state & BST_FOCUS) ? ODS_FOCUS : 0) | + ((state & BST_PUSHED) ? ODS_SELECTED : 0) | + (IsWindowEnabled(hwnd) ? 0: ODS_DISABLED); + dis.hwndItem = hwnd; + dis.hDC = hDC; + dis.itemData = 0; + GetClientRect( hwnd, &dis.rcItem ); + + if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont ); + parent = GetParent(hwnd); + if (!parent) parent = hwnd; + SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd ); + + hrgn = set_control_clipping( hDC, &dis.rcItem ); + + SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis ); + if (hPrevFont) SelectObject(hDC, hPrevFont); + SelectClipRgn( hDC, hrgn ); + if (hrgn) DeleteObject( hrgn ); +} + +void BUTTON_Register(void) +{ + WNDCLASSW wndClass; + + memset(&wndClass, 0, sizeof(wndClass)); + wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC; + wndClass.lpfnWndProc = BUTTON_WindowProc; + wndClass.cbClsExtra = 0; + wndClass.cbWndExtra = NB_EXTRA_BYTES; + wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW); + wndClass.hbrBackground = NULL; + wndClass.lpszClassName = WC_BUTTONW; + RegisterClassW(&wndClass); +} diff --git a/dlls/comctl32/comctl32.h b/dlls/comctl32/comctl32.h index cb66ad420d..33cb0c78e2 100644 --- a/dlls/comctl32/comctl32.h +++ b/dlls/comctl32/comctl32.h @@ -175,6 +175,7 @@ BOOL WINAPI MirrorIcon(HICON *phicon1, HICON *phicon2); extern void ANIMATE_Register(void) DECLSPEC_HIDDEN; extern void ANIMATE_Unregister(void) DECLSPEC_HIDDEN; +extern void BUTTON_Register(void) DECLSPEC_HIDDEN; extern void COMBOEX_Register(void) DECLSPEC_HIDDEN; extern void COMBOEX_Unregister(void) DECLSPEC_HIDDEN; extern void DATETIME_Register(void) DECLSPEC_HIDDEN; diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c index 3bf4649112..b618ff2bfa 100644 --- a/dlls/comctl32/commctrl.c +++ b/dlls/comctl32/commctrl.c @@ -98,6 +98,7 @@ static void unregister_versioned_classes(void) #define VERSION "6.0.2600.2982!" static const char *classes[] = { + VERSION WC_BUTTONA, VERSION WC_EDITA, }; int i; @@ -167,6 +168,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) TREEVIEW_Register (); UPDOWN_Register (); + BUTTON_Register (); EDIT_Register (); /* subclass user32 controls */ diff --git a/dlls/comctl32/tests/button.c b/dlls/comctl32/tests/button.c index 441ca581c5..38e55c8f69 100644 --- a/dlls/comctl32/tests/button.c +++ b/dlls/comctl32/tests/button.c @@ -576,7 +576,8 @@ static void test_button_messages(void) SendMessageA(hwnd, BM_SETSTYLE, button[i].style | BS_BOTTOM, TRUE); SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); - ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].setstyle, "BM_SETSTYLE on a button", TRUE); + todo = button[i].style == BS_USERBUTTON || button[i].style == BS_OWNERDRAW; + ok_sequence(sequences, COMBINED_SEQ_INDEX, button[i].setstyle, "BM_SETSTYLE on a button", todo); style = GetWindowLongA(hwnd, GWL_STYLE); style &= ~(WS_VISIBLE | WS_CHILD | BS_NOTIFY); @@ -623,17 +624,14 @@ static void test_button_messages(void) button[i].style == BS_AUTORADIOBUTTON) { seq = setcheck_radio_seq; - todo = TRUE; } else - { seq = setcheck_ignored_seq; - todo = FALSE; - } + SendMessageA(hwnd, BM_SETCHECK, BST_UNCHECKED, 0); SendMessageA(hwnd, WM_APP, 0, 0); /* place a separator mark here */ while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); - ok_sequence(sequences, COMBINED_SEQ_INDEX, seq, "BM_SETCHECK on a button", todo); + ok_sequence(sequences, COMBINED_SEQ_INDEX, seq, "BM_SETCHECK on a button", FALSE); state = SendMessageA(hwnd, BM_GETCHECK, 0, 0); ok(state == BST_UNCHECKED, "expected BST_UNCHECKED, got %04x\n", state); @@ -715,7 +713,6 @@ static void test_button_class(void) ret = GetClassInfoExA(NULL, WC_BUTTONA, &exA); ok(ret, "got %d\n", ret); -todo_wine ok(IS_WNDPROC_HANDLE(exA.lpfnWndProc), "got %p\n", exA.lpfnWndProc); ret = GetClassInfoExW(NULL, WC_BUTTONW, &exW); @@ -727,9 +724,7 @@ todo_wine ok(lstrcmpW(nameW, WC_BUTTONW), "got %s\n", wine_dbgstr_w(nameW)); ret = GetClassInfoExW(NULL, nameW, &ex2W); -todo_wine ok(ret, "got %d\n", ret); -if (ret) /* TODO: remove once Wine is fixed */ ok(ex2W.lpfnWndProc == exW.lpfnWndProc, "got %p, %p\n", exW.lpfnWndProc, ex2W.lpfnWndProc); /* Check reported class name */ @@ -745,10 +740,8 @@ if (ret) /* TODO: remove once Wine is fixed */ /* explicitly create with versioned class name */ hwnd = CreateWindowExW(0, nameW, testW, BS_CHECKBOX, 0, 0, 50, 14, NULL, 0, 0, NULL); -todo_wine ok(hwnd != NULL, "failed to create a window %s\n", wine_dbgstr_w(nameW)); -if (hwnd) -{ + len = GetClassNameA(hwnd, buffA, sizeof(buffA)); ok(len == strlen(buffA), "got %d\n", len); ok(!strcmp(buffA, "Button"), "got %s\n", buffA); @@ -759,7 +752,6 @@ if (hwnd) DestroyWindow(hwnd); } -} static void register_parent_class(void) { diff --git a/dlls/comctl32/tests/misc.c b/dlls/comctl32/tests/misc.c index bef92b88dc..cb59de243e 100644 --- a/dlls/comctl32/tests/misc.c +++ b/dlls/comctl32/tests/misc.c @@ -345,7 +345,8 @@ static void check_class( const char *name, int must_exist, UINT style, UINT igno if (GetClassInfoA( 0, name, &wc )) { -todo_wine_if(strcmp(name, "Edit")) +todo_wine_if(strcmp(name, "Button") && + strcmp(name, "Edit")) ok( !(~wc.style & style & ~ignore), "System class %s is missing bits %x (%08x/%08x)\n", name, ~wc.style & style, wc.style, style ); ok( !(wc.style & ~style), "System class %s has extra bits %x (%08x/%08x)\n", diff --git a/dlls/user32/class.c b/dlls/user32/class.c index 8fba5bf115..441d5cb132 100644 --- a/dlls/user32/class.c +++ b/dlls/user32/class.c @@ -166,7 +166,6 @@ static BOOL is_builtin_class( const WCHAR *name ) { static const WCHAR classesW[][20] = { - {'B','u','t','t','o','n',0}, {'C','o','m','b','o','B','o','x',0}, {'C','o','m','b','o','L','B','o','x',0}, {'I','M','E',0}, -- 2.15.1
[View Less]
2
7
0
0
[PATCH 1/2] msxml3: Use the global HeapAlloc() helpers
by Nikolay Sivov
06 Feb '18
06 Feb '18
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/msxml3/saxreader.c | 6 +++--- dlls/msxml3/schema.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dlls/msxml3/saxreader.c b/dlls/msxml3/saxreader.c index be2caf972b..e8d5b271d7 100644 --- a/dlls/msxml3/saxreader.c +++ b/dlls/msxml3/saxreader.c @@ -561,7 +561,7 @@ static BOOL bstr_pool_insert(struct bstrpool *pool, BSTR pool_entry) { if (!pool->pool) { - pool->pool =
…
[View More]
HeapAlloc(GetProcessHeap(), 0, 16 * sizeof(*pool->pool)); + pool->pool = heap_alloc(16 * sizeof(*pool->pool)); if (!pool->pool) return FALSE; @@ -570,7 +570,7 @@ static BOOL bstr_pool_insert(struct bstrpool *pool, BSTR pool_entry) } else if (pool->index == pool->len) { - BSTR *realloc = HeapReAlloc(GetProcessHeap(), 0, pool->pool, pool->len * 2 * sizeof(*realloc)); + BSTR *realloc = heap_realloc(pool->pool, pool->len * 2 * sizeof(*realloc)); if (!realloc) return FALSE; @@ -590,7 +590,7 @@ static void free_bstr_pool(struct bstrpool *pool) for (i = 0; i < pool->index; i++) SysFreeString(pool->pool[i]); - HeapFree(GetProcessHeap(), 0, pool->pool); + heap_free(pool->pool); pool->pool = NULL; pool->index = pool->len = 0; diff --git a/dlls/msxml3/schema.c b/dlls/msxml3/schema.c index 30272cbfdd..8087985204 100644 --- a/dlls/msxml3/schema.c +++ b/dlls/msxml3/schema.c @@ -749,7 +749,7 @@ void schemasInit(void) /* Resource is loaded as raw data, * need a null-terminated string */ while (buf[datatypes_len - 1] != '>') datatypes_len--; - datatypes_src = HeapAlloc(GetProcessHeap(), 0, datatypes_len + 1); + datatypes_src = heap_alloc(datatypes_len + 1); memcpy(datatypes_src, buf, datatypes_len); datatypes_src[datatypes_len] = 0; @@ -763,7 +763,7 @@ void schemasInit(void) void schemasCleanup(void) { xmlSchemaFree(datatypes_schema); - HeapFree(GetProcessHeap(), 0, datatypes_src); + heap_free(datatypes_src); xmlSetExternalEntityLoader(_external_entity_loader); } -- 2.15.1
[View Less]
1
1
0
0
[PATCH v4] windowscodecs: Fix data corruption for Adobe CMYK JPEGs
by Anton Romanov
06 Feb '18
06 Feb '18
Fixes
https://bugs.winehq.org/show_bug.cgi?id=43520
Signed-off-by: Anton Romanov <theli.ua(a)gmail.com> --- dlls/windowscodecs/jpegformat.c | 11 ++- dlls/windowscodecs/tests/Makefile.in | 1 + dlls/windowscodecs/tests/jpegformat.c | 127 ++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 dlls/windowscodecs/tests/jpegformat.c diff --git a/dlls/windowscodecs/jpegformat.c b/dlls/windowscodecs/jpegformat.c index ef050ba688..
…
[View More]
2327057285 100644 --- a/dlls/windowscodecs/jpegformat.c +++ b/dlls/windowscodecs/jpegformat.c @@ -680,9 +680,16 @@ static HRESULT WINAPI JpegDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface, } if (This->cinfo.out_color_space == JCS_CMYK && This->cinfo.saw_Adobe_marker) + { + UINT i; + DWORD *pDwordData = (DWORD*) (This->image_data + stride * first_scanline); + DWORD *pDwordDataEnd = pDwordData + stride * max_rows; + /* Adobe JPEG's have inverted CMYK data. */ - for (i=0; i<data_size; i++) - This->image_data[i] ^= 0xff; + while(pDwordData < pDwordDataEnd) + *pDwordData++ ^= 0xffffffff; + } + } LeaveCriticalSection(&This->lock); diff --git a/dlls/windowscodecs/tests/Makefile.in b/dlls/windowscodecs/tests/Makefile.in index b1e78f995c..3d64210ba0 100644 --- a/dlls/windowscodecs/tests/Makefile.in +++ b/dlls/windowscodecs/tests/Makefile.in @@ -13,4 +13,5 @@ C_SRCS = \ pngformat.c \ propertybag.c \ stream.c \ + jpegformat.c \ tiffformat.c diff --git a/dlls/windowscodecs/tests/jpegformat.c b/dlls/windowscodecs/tests/jpegformat.c new file mode 100644 index 0000000000..7a7e2a1b59 --- /dev/null +++ b/dlls/windowscodecs/tests/jpegformat.c @@ -0,0 +1,127 @@ +#define COBJMACROS + +#include "objbase.h" +#include "wincodec.h" +#include "wine/test.h" + +static const char jpeg_adobe_cmyk_1x5[] = + "\xff\xd8\xff\xe0\x00\x10\x4a\x46\x49\x46\x00\x01\x01\x01\x01\x2c" + "\x01\x2c\x00\x00\xff\xee\x00\x0e\x41\x64\x6f\x62\x65\x00\x64\x00" + "\x00\x00\x00\x02\xff\xfe\x00\x13\x43\x72\x65\x61\x74\x65\x64\x20" + "\x77\x69\x74\x68\x20\x47\x49\x4d\x50\xff\xdb\x00\x43\x00\x01\x01" + "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01" + "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01" + "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01" + "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\xff\xdb" + "\x00\x43\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01" + "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01" + "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01" + "\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01" + "\x01\x01\x01\xff\xc0\x00\x14\x08\x00\x05\x00\x01\x04\x01\x11\x00" + "\x02\x11\x01\x03\x11\x01\x04\x11\x00\xff\xc4\x00\x15\x00\x01\x01" + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x08" + "\xff\xc4\x00\x14\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\xff\xc4\x00\x14\x01\x01\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\xff\xc4\x00\x14" + "\x11\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + "\x00\x00\xff\xda\x00\x0e\x04\x01\x00\x02\x11\x03\x11\x04\x00\x00" + "\x3f\x00\x40\x44\x02\x1e\xa4\x1f\xff\xd9"; + +static void test_decode_adobe_cmyk(void) +{ + IWICBitmapDecoder *decoder; + IWICBitmapFrameDecode *framedecode; + HRESULT hr; + HGLOBAL hjpegdata; + char *jpegdata; + IStream *jpegstream; + GUID guidresult; + UINT count=0, width=0, height=0; + BYTE imagedata[5 * 4] = {1}; + const BYTE expected_imagedata[5 * 4] = { + 0x00, 0xb0, 0xfc, 0x6d, + 0x00, 0xb0, 0xfc, 0x6d, + 0x00, 0xb0, 0xfc, 0x6d, + 0x00, 0xb0, 0xfc, 0x6d, + 0x00, 0xb0, 0xfc, 0x6d, + }; + + const BYTE expected_imagedata_24bpp[5 * 4] = { + 0x0d, 0x4b, 0x94, 0x00, + 0x0d, 0x4b, 0x94, 0x00, + 0x0d, 0x4b, 0x94, 0x00, + 0x0d, 0x4b, 0x94, 0x00, + 0x0d, 0x4b, 0x94, 0x00, + }; + + hr = CoCreateInstance(&CLSID_WICJpegDecoder, NULL, CLSCTX_INPROC_SERVER, + &IID_IWICBitmapDecoder, (void**)&decoder); + ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr); + if (FAILED(hr)) return; + + hjpegdata = GlobalAlloc(GMEM_MOVEABLE, sizeof(jpeg_adobe_cmyk_1x5)); + ok(hjpegdata != 0, "GlobalAlloc failed\n"); + if (hjpegdata) + { + jpegdata = GlobalLock(hjpegdata); + memcpy(jpegdata, jpeg_adobe_cmyk_1x5, sizeof(jpeg_adobe_cmyk_1x5)); + GlobalUnlock(hjpegdata); + + hr = CreateStreamOnHGlobal(hjpegdata, FALSE, &jpegstream); + ok(SUCCEEDED(hr), "CreateStreamOnHGlobal failed, hr=%x\n", hr); + if (SUCCEEDED(hr)) + { + hr = IWICBitmapDecoder_Initialize(decoder, jpegstream, WICDecodeMetadataCacheOnLoad); + ok(hr == S_OK, "Initialize failed, hr=%x\n", hr); + + hr = IWICBitmapDecoder_GetContainerFormat(decoder, &guidresult); + ok(SUCCEEDED(hr), "GetContainerFormat failed, hr=%x\n", hr); + ok(IsEqualGUID(&guidresult, &GUID_ContainerFormatJpeg), "unexpected container format\n"); + + hr = IWICBitmapDecoder_GetFrameCount(decoder, &count); + ok(SUCCEEDED(hr), "GetFrameCount failed, hr=%x\n", hr); + ok(count == 1, "unexpected count %u\n", count); + + hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode); + ok(SUCCEEDED(hr), "GetFrame failed, hr=%x\n", hr); + if (SUCCEEDED(hr)) + { + hr = IWICBitmapFrameDecode_GetSize(framedecode, &width, &height); + ok(SUCCEEDED(hr), "GetSize failed, hr=%x\n", hr); + ok(width == 1, "expected width=1, got %u\n", width); + ok(height == 5, "expected height=5, got %u\n", height); + + hr = IWICBitmapFrameDecode_GetPixelFormat(framedecode, &guidresult); + ok(SUCCEEDED(hr), "GetPixelFormat failed, hr=%x\n", hr); + ok(IsEqualGUID(&guidresult, &GUID_WICPixelFormat32bppCMYK) || + broken(IsEqualGUID(&guidresult, &GUID_WICPixelFormat24bppBGR)), /* xp/2003 */ + "unexpected pixel format: %s\n", wine_dbgstr_guid(&guidresult)); + + /* We want to be sure our state tracking will not impact output + * data on subsequent calls */ + for(int i=2; i>0; --i) + { + hr = IWICBitmapFrameDecode_CopyPixels(framedecode, NULL, 4, sizeof(imagedata), imagedata); + ok(SUCCEEDED(hr), "CopyPixels failed, hr=%x\n", hr); + ok(!memcmp(imagedata, expected_imagedata, sizeof(imagedata)) || + broken(!memcmp(imagedata, expected_imagedata_24bpp, sizeof(expected_imagedata))), /* xp/2003 */ + "unexpected image data\n"); + } + IWICBitmapFrameDecode_Release(framedecode); + } + IStream_Release(jpegstream); + } + GlobalFree(hjpegdata); + } + IWICBitmapDecoder_Release(decoder); +} + + +START_TEST(jpegformat) +{ + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + + test_decode_adobe_cmyk(); + + CoUninitialize(); +} -- 2.16.1
[View Less]
2
1
0
0
← Newer
1
...
56
57
58
59
60
61
62
...
75
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
Results per page:
10
25
50
100
200