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
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-commits
March 2022
----- 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-commits@winehq.org
2 participants
1138 discussions
Start a n
N
ew thread
Jacek Caban : win32u: Move GWLP_HWNDPARENT implementation from user32.
by Alexandre Julliard
08 Mar '22
08 Mar '22
Module: wine Branch: master Commit: 115f3f3a0adcbd1ffee7d4987eb3cce40d6c3d3a URL:
https://source.winehq.org/git/wine.git/?a=commit;h=115f3f3a0adcbd1ffee7d498…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue Mar 8 14:24:07 2022 +0100 win32u: Move GWLP_HWNDPARENT implementation from user32. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/win.c | 14 -------------- dlls/win32u/window.c | 6 ++++-- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/dlls/user32/win.c b/dlls/user32/win.c index eecc696023a..fe8d929a102 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -2555,21 +2555,11 @@ LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, UINT size, LONG_PTR newval, B } -/* FIXME: move to win32u */ -static ULONG_PTR get_hwnd_parent( HWND hwnd ) -{ - HWND parent = NtUserGetAncestor( hwnd, GA_PARENT ); - if (parent == GetDesktopWindow()) parent = GetWindow( hwnd, GW_OWNER ); - return (ULONG_PTR)parent; -} - - /********************************************************************** * GetWindowWord (USER32.@) */ WORD WINAPI GetWindowWord( HWND hwnd, INT offset ) { - if (offset == GWLP_HWNDPARENT) return get_hwnd_parent( hwnd ); return NtUserCallHwndParam( hwnd, offset, NtUserGetWindowWord ); } @@ -2590,7 +2580,6 @@ LONG WINAPI GetWindowLongA( HWND hwnd, INT offset ) return 0; #endif default: - if (offset == GWLP_HWNDPARENT) return get_hwnd_parent( hwnd ); return NtUserCallHwndParam( hwnd, offset, NtUserGetWindowLongA ); } } @@ -2612,7 +2601,6 @@ LONG WINAPI GetWindowLongW( HWND hwnd, INT offset ) return 0; #endif default: - if (offset == GWLP_HWNDPARENT) return get_hwnd_parent( hwnd ); return NtUserCallHwndParam( hwnd, offset, NtUserGetWindowLongW ); } } @@ -3805,7 +3793,6 @@ BOOL WINAPI SetProcessDefaultLayout( DWORD layout ) */ LONG_PTR WINAPI GetWindowLongPtrW( HWND hwnd, INT offset ) { - if (offset == GWLP_HWNDPARENT) return get_hwnd_parent( hwnd ); return NtUserCallHwndParam( hwnd, offset, NtUserGetWindowLongPtrW ); } @@ -3814,7 +3801,6 @@ LONG_PTR WINAPI GetWindowLongPtrW( HWND hwnd, INT offset ) */ LONG_PTR WINAPI GetWindowLongPtrA( HWND hwnd, INT offset ) { - if (offset == GWLP_HWNDPARENT) return get_hwnd_parent( hwnd ); return NtUserCallHwndParam( hwnd, offset, NtUserGetWindowLongPtrA ); } diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 3ac177d310a..f7f0d4e6a65 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -612,8 +612,10 @@ static LONG_PTR get_window_long_size( HWND hwnd, INT offset, UINT size, BOOL ans if (offset == GWLP_HWNDPARENT) { - FIXME( "GWLP_HWNDPARENT not supported\n" ); - return 0; + HWND parent = NtUserGetAncestor( hwnd, GA_PARENT ); + if (user_callbacks && parent == user_callbacks->pGetDesktopWindow()) + parent = get_window_relative( hwnd, GW_OWNER ); + return (ULONG_PTR)parent; } if (!(win = get_win_ptr( hwnd )))
1
0
0
0
Jacek Caban : win32u: Move NtUserGetAncestor implementation from user32.
by Alexandre Julliard
08 Mar '22
08 Mar '22
Module: wine Branch: master Commit: 4ef69e2b5920f3bab3f823345639c83811e7a02d URL:
https://source.winehq.org/git/wine.git/?a=commit;h=4ef69e2b5920f3bab3f82334…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue Mar 8 14:24:03 2022 +0100 win32u: Move NtUserGetAncestor implementation from user32. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/defwnd.c | 4 +- dlls/user32/desktop.c | 2 +- dlls/user32/driver.c | 2 +- dlls/user32/focus.c | 6 +-- dlls/user32/menu.c | 2 +- dlls/user32/message.c | 2 +- dlls/user32/nonclient.c | 6 +-- dlls/user32/painting.c | 4 +- dlls/user32/user32.spec | 2 +- dlls/user32/win.c | 63 +---------------------- dlls/user32/winpos.c | 26 +++++----- dlls/win32u/syscall.c | 1 + dlls/win32u/win32u.spec | 2 +- dlls/win32u/window.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++ dlls/wow64win/syscall.h | 1 + dlls/wow64win/user.c | 8 +++ include/ntuser.h | 1 + 17 files changed, 170 insertions(+), 91 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=4ef69e2b5920f3bab3f8…
1
0
0
0
Jacek Caban : win32u: Move GetParent implementation from user32.
by Alexandre Julliard
08 Mar '22
08 Mar '22
Module: wine Branch: master Commit: 5da6282a60319bddb4f25b360a65441bf96b4d54 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=5da6282a60319bddb4f25b36…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue Mar 8 14:24:00 2022 +0100 win32u: Move GetParent implementation from user32. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/win.c | 34 +--------------------------------- dlls/win32u/win32u_private.h | 1 + dlls/win32u/window.c | 42 +++++++++++++++++++++++++++++++++++++++++- include/ntuser.h | 1 + 4 files changed, 44 insertions(+), 34 deletions(-) diff --git a/dlls/user32/win.c b/dlls/user32/win.c index fb7d05b71dc..c860464125e 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -2908,39 +2908,7 @@ DWORD WINAPI GetWindowThreadProcessId( HWND hwnd, LPDWORD process ) */ HWND WINAPI GetParent( HWND hwnd ) { - WND *wndPtr; - HWND retvalue = 0; - - if (!(wndPtr = WIN_GetPtr( hwnd ))) - { - SetLastError( ERROR_INVALID_WINDOW_HANDLE ); - return 0; - } - if (wndPtr == WND_DESKTOP) return 0; - if (wndPtr == WND_OTHER_PROCESS) - { - LONG style = GetWindowLongW( hwnd, GWL_STYLE ); - if (style & (WS_POPUP | WS_CHILD)) - { - SERVER_START_REQ( get_window_tree ) - { - req->handle = wine_server_user_handle( hwnd ); - if (!wine_server_call_err( req )) - { - if (style & WS_POPUP) retvalue = wine_server_ptr_handle( reply->owner ); - else if (style & WS_CHILD) retvalue = wine_server_ptr_handle( reply->parent ); - } - } - SERVER_END_REQ; - } - } - else - { - if (wndPtr->dwStyle & WS_POPUP) retvalue = wndPtr->owner; - else if (wndPtr->dwStyle & WS_CHILD) retvalue = wndPtr->parent; - WIN_ReleasePtr( wndPtr ); - } - return retvalue; + return UlongToHandle( NtUserCallHwnd( hwnd, NtUserGetParent )); } diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index e3cf939db09..a46accddd71 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -296,6 +296,7 @@ extern void user_check_not_lock(void) DECLSPEC_HIDDEN; struct tagWND; extern HWND is_current_thread_window( HWND hwnd ) DECLSPEC_HIDDEN; extern void flush_window_surfaces( BOOL idle ) DECLSPEC_HIDDEN; +extern DWORD get_window_long( HWND hwnd, INT offset ) DECLSPEC_HIDDEN; extern void register_window_surface( struct window_surface *old, struct window_surface *new ) DECLSPEC_HIDDEN; diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index f24fc531f16..eb49d9bf237 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -361,6 +361,44 @@ static DWORD get_window_thread( HWND hwnd, DWORD *process ) return tid; } +/* see GetParent */ +static HWND get_parent( HWND hwnd ) +{ + HWND retval = 0; + WND *win; + + if (!(win = get_win_ptr( hwnd ))) + { + SetLastError( ERROR_INVALID_WINDOW_HANDLE ); + return 0; + } + if (win == WND_DESKTOP) return 0; + if (win == WND_OTHER_PROCESS) + { + LONG style = get_window_long( hwnd, GWL_STYLE ); + if (style & (WS_POPUP | WS_CHILD)) + { + SERVER_START_REQ( get_window_tree ) + { + req->handle = wine_server_user_handle( hwnd ); + if (!wine_server_call_err( req )) + { + if (style & WS_POPUP) retval = wine_server_ptr_handle( reply->owner ); + else if (style & WS_CHILD) retval = wine_server_ptr_handle( reply->parent ); + } + } + SERVER_END_REQ; + } + } + else + { + if (win->dwStyle & WS_POPUP) retval = win->owner; + else if (win->dwStyle & WS_CHILD) retval = win->parent; + release_win_ptr( win ); + } + return retval; +} + /* see GetWindow */ static HWND get_window_relative( HWND hwnd, UINT rel ) { @@ -557,7 +595,7 @@ static LONG_PTR get_window_long_size( HWND hwnd, INT offset, UINT size, BOOL ans } /* see GetWindowLongW */ -static DWORD get_window_long( HWND hwnd, INT offset ) +DWORD get_window_long( HWND hwnd, INT offset ) { return get_window_long_size( hwnd, offset, sizeof(LONG), FALSE ); } @@ -757,6 +795,8 @@ DWORD WINAPI NtUserCallHwnd( HWND hwnd, DWORD code ) { switch (code) { + case NtUserGetParent: + return HandleToUlong( get_parent( hwnd )); case NtUserGetWindowTextLength: return get_server_window_text( hwnd, NULL, 0 ); case NtUserIsWindow: diff --git a/include/ntuser.h b/include/ntuser.h index 3021a8a9af4..8ae916e57bd 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -139,6 +139,7 @@ enum /* NtUserCallHwnd codes, not compatible with Windows */ enum { + NtUserGetParent, NtUserGetWindowTextLength, NtUserIsWindow, };
1
0
0
0
Jacek Caban : win32u: Move GetWindow implementation from user32.
by Alexandre Julliard
08 Mar '22
08 Mar '22
Module: wine Branch: master Commit: cde008fe7192798db143074578aac78caf4eddac URL:
https://source.winehq.org/git/wine.git/?a=commit;h=cde008fe7192798db1430745…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue Mar 8 14:23:56 2022 +0100 win32u: Move GetWindow implementation from user32. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/win.c | 51 +--------------------------------------------- dlls/win32u/window.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/ntuser.h | 1 + 3 files changed, 59 insertions(+), 50 deletions(-) diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 8678aa39454..fb7d05b71dc 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -3200,56 +3200,7 @@ HWND WINAPI GetTopWindow( HWND hwnd ) */ HWND WINAPI GetWindow( HWND hwnd, UINT rel ) { - HWND retval = 0; - - if (rel == GW_OWNER) /* this one may be available locally */ - { - WND *wndPtr = WIN_GetPtr( hwnd ); - if (!wndPtr) - { - SetLastError( ERROR_INVALID_HANDLE ); - return 0; - } - if (wndPtr == WND_DESKTOP) return 0; - if (wndPtr != WND_OTHER_PROCESS) - { - retval = wndPtr->owner; - WIN_ReleasePtr( wndPtr ); - return retval; - } - /* else fall through to server call */ - } - - SERVER_START_REQ( get_window_tree ) - { - req->handle = wine_server_user_handle( hwnd ); - if (!wine_server_call_err( req )) - { - switch(rel) - { - case GW_HWNDFIRST: - retval = wine_server_ptr_handle( reply->first_sibling ); - break; - case GW_HWNDLAST: - retval = wine_server_ptr_handle( reply->last_sibling ); - break; - case GW_HWNDNEXT: - retval = wine_server_ptr_handle( reply->next_sibling ); - break; - case GW_HWNDPREV: - retval = wine_server_ptr_handle( reply->prev_sibling ); - break; - case GW_OWNER: - retval = wine_server_ptr_handle( reply->owner ); - break; - case GW_CHILD: - retval = wine_server_ptr_handle( reply->first_child ); - break; - } - } - } - SERVER_END_REQ; - return retval; + return UlongToHandle( NtUserCallHwndParam( hwnd, rel, NtUserGetWindowRelative )); } diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 86356b609b0..f24fc531f16 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -361,6 +361,61 @@ static DWORD get_window_thread( HWND hwnd, DWORD *process ) return tid; } +/* see GetWindow */ +static HWND get_window_relative( HWND hwnd, UINT rel ) +{ + HWND retval = 0; + + if (rel == GW_OWNER) /* this one may be available locally */ + { + WND *win = get_win_ptr( hwnd ); + if (!win) + { + SetLastError( ERROR_INVALID_HANDLE ); + return 0; + } + if (win == WND_DESKTOP) return 0; + if (win != WND_OTHER_PROCESS) + { + retval = win->owner; + release_win_ptr( win ); + return retval; + } + /* else fall through to server call */ + } + + SERVER_START_REQ( get_window_tree ) + { + req->handle = wine_server_user_handle( hwnd ); + if (!wine_server_call_err( req )) + { + switch(rel) + { + case GW_HWNDFIRST: + retval = wine_server_ptr_handle( reply->first_sibling ); + break; + case GW_HWNDLAST: + retval = wine_server_ptr_handle( reply->last_sibling ); + break; + case GW_HWNDNEXT: + retval = wine_server_ptr_handle( reply->next_sibling ); + break; + case GW_HWNDPREV: + retval = wine_server_ptr_handle( reply->prev_sibling ); + break; + case GW_OWNER: + retval = wine_server_ptr_handle( reply->owner ); + break; + case GW_CHILD: + retval = wine_server_ptr_handle( reply->first_child ); + break; + } + } + } + SERVER_END_REQ; + return retval; +} + static LONG_PTR get_win_data( const void *ptr, UINT size ) { if (size == sizeof(WORD)) @@ -737,6 +792,8 @@ ULONG_PTR WINAPI NtUserCallHwndParam( HWND hwnd, DWORD_PTR param, DWORD code ) return get_window_long_ptr( hwnd, param, TRUE ); case NtUserGetWindowLongPtrW: return get_window_long_ptr( hwnd, param, FALSE ); + case NtUserGetWindowRelative: + return HandleToUlong( get_window_relative( hwnd, param )); case NtUserGetWindowThread: return get_window_thread( hwnd, (DWORD *)param ); case NtUserGetWindowWord: diff --git a/include/ntuser.h b/include/ntuser.h index ccdfdb04de5..3021a8a9af4 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -155,6 +155,7 @@ enum NtUserGetWindowLongW, NtUserGetWindowLongPtrA, NtUserGetWindowLongPtrW, + NtUserGetWindowRelative, NtUserGetWindowThread, NtUserGetWindowWord, };
1
0
0
0
Jacek Caban : win32u: Move GetWindowLong implementation from user32.
by Alexandre Julliard
08 Mar '22
08 Mar '22
Module: wine Branch: master Commit: d174cb22944e2ec90bfdf268af94b11e7f81136b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d174cb22944e2ec90bfdf268…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue Mar 8 14:23:52 2022 +0100 win32u: Move GetWindowLong implementation from user32. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/win.c | 166 ++++-------------------------- dlls/user32/win.h | 10 -- dlls/win32u/class.c | 2 +- dlls/win32u/ntuser_private.h | 11 ++ dlls/win32u/window.c | 237 +++++++++++++++++++++++++++++++++++++++++++ include/ntuser.h | 5 + 6 files changed, 274 insertions(+), 157 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=d174cb22944e2ec90bfd…
1
0
0
0
Jacek Caban : win32u: Move GetWindowTextLength implementation from user32.
by Alexandre Julliard
08 Mar '22
08 Mar '22
Module: wine Branch: master Commit: d312083e0add3a5752f6fd6e265a667f22d71af7 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d312083e0add3a5752f6fd6e…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue Mar 8 14:23:45 2022 +0100 win32u: Move GetWindowTextLength implementation from user32. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/win.c | 29 ++--------------------------- dlls/win32u/window.c | 2 ++ include/ntuser.h | 1 + 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 9c2ceedd6a3..0aa0a0b6f08 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -399,31 +399,6 @@ void update_window_state( HWND hwnd ) } -/******************************************************************* - * get_server_window_text - * - * Retrieve the window text from the server. - */ -static data_size_t get_server_window_text( HWND hwnd, WCHAR *text, data_size_t count ) -{ - data_size_t len = 0, needed = 0; - - SERVER_START_REQ( get_window_text ) - { - req->handle = wine_server_user_handle( hwnd ); - if (count) wine_server_set_reply( req, text, (count - 1) * sizeof(WCHAR) ); - if (!wine_server_call_err( req )) - { - needed = reply->length; - len = wine_server_reply_size(reply); - } - } - SERVER_END_REQ; - if (text) text[len / sizeof(WCHAR)] = 0; - return needed; -} - - /******************************************************************* * get_hwnd_message_parent * @@ -3023,7 +2998,7 @@ INT WINAPI GetWindowTextLengthA( HWND hwnd ) /* when window belongs to other process, don't send a message */ GetCPInfo( CP_ACP, &info ); - return get_server_window_text( hwnd, NULL, 0 ) * info.MaxCharSize; + return NtUserCallHwnd( hwnd, NtUserGetWindowTextLength ) * info.MaxCharSize; } /******************************************************************* @@ -3034,7 +3009,7 @@ INT WINAPI GetWindowTextLengthW( HWND hwnd ) if (WIN_IsCurrentProcess( hwnd )) return SendMessageW( hwnd, WM_GETTEXTLENGTH, 0, 0 ); /* when window belongs to other process, don't send a message */ - return get_server_window_text( hwnd, NULL, 0 ); + return NtUserCallHwnd( hwnd, NtUserGetWindowTextLength ); } diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 93ee0ffd164..168195dcd44 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -475,6 +475,8 @@ DWORD WINAPI NtUserCallHwnd( HWND hwnd, DWORD code ) { switch (code) { + case NtUserGetWindowTextLength: + return get_server_window_text( hwnd, NULL, 0 ); case NtUserIsWindow: return is_window( hwnd ); default: diff --git a/include/ntuser.h b/include/ntuser.h index 34d75f4f726..ab46a1a5b09 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -139,6 +139,7 @@ enum /* NtUserCallHwnd codes, not compatible with Windows */ enum { + NtUserGetWindowTextLength, NtUserIsWindow, };
1
0
0
0
Jacek Caban : user32: Use NtUserInternalGetWindowText in GetWindowText.
by Alexandre Julliard
08 Mar '22
08 Mar '22
Module: wine Branch: master Commit: 6c49dfff14bff4a07570c8e42465c87bfe9b1e8e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=6c49dfff14bff4a07570c8e4…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue Mar 8 14:23:41 2022 +0100 user32: Use NtUserInternalGetWindowText in GetWindowText. Instead of get_server_window_text. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/win.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dlls/user32/win.c b/dlls/user32/win.c index fc31e0cc01d..9c2ceedd6a3 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -2927,7 +2927,7 @@ INT WINAPI GetWindowTextA( HWND hwnd, LPSTR lpString, INT nMaxCount ) else if ((buffer = HeapAlloc( GetProcessHeap(), 0, nMaxCount * sizeof(WCHAR) ))) { /* when window belongs to other process, don't send a message */ - get_server_window_text( hwnd, buffer, nMaxCount ); + NtUserInternalGetWindowText( hwnd, buffer, nMaxCount ); if (!WideCharToMultiByte( CP_ACP, 0, buffer, -1, lpString, nMaxCount, NULL, NULL )) lpString[nMaxCount-1] = 0; HeapFree( GetProcessHeap(), 0, buffer ); @@ -2964,8 +2964,7 @@ INT WINAPI GetWindowTextW( HWND hwnd, LPWSTR lpString, INT nMaxCount ) else { /* when window belongs to other process, don't send a message */ - get_server_window_text( hwnd, lpString, nMaxCount ); - ret = lstrlenW(lpString); + ret = NtUserInternalGetWindowText( hwnd, lpString, nMaxCount ); } } __EXCEPT_PAGE_FAULT
1
0
0
0
Jacek Caban : win32u: Move NtUserInternalGetWindowText implementation from user32.
by Alexandre Julliard
08 Mar '22
08 Mar '22
Module: wine Branch: master Commit: 90c13be9dde8ea32cbe4958e2ba3bc0bf1669a2f URL:
https://source.winehq.org/git/wine.git/?a=commit;h=90c13be9dde8ea32cbe4958e…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue Mar 8 14:23:37 2022 +0100 win32u: Move NtUserInternalGetWindowText implementation from user32. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/button.c | 2 +- dlls/user32/mdi.c | 4 ++-- dlls/user32/spy.c | 2 +- dlls/user32/static.c | 2 +- dlls/user32/tests/win.c | 5 +++++ dlls/user32/user32.spec | 2 +- dlls/user32/win.c | 26 +------------------------- dlls/win32u/syscall.c | 1 + dlls/win32u/win32u.spec | 2 +- dlls/win32u/window.c | 43 +++++++++++++++++++++++++++++++++++++++++++ dlls/wow64win/syscall.h | 1 + dlls/wow64win/user.c | 9 +++++++++ include/ntuser.h | 1 + 13 files changed, 68 insertions(+), 32 deletions(-) diff --git a/dlls/user32/button.c b/dlls/user32/button.c index e3af68e0e54..5fdf4803c18 100644 --- a/dlls/user32/button.c +++ b/dlls/user32/button.c @@ -173,7 +173,7 @@ 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 ); + if (buffer) NtUserInternalGetWindowText( hwnd, buffer, len + 1 ); return buffer; } diff --git a/dlls/user32/mdi.c b/dlls/user32/mdi.c index 66f258bb3f3..4b8e0bcd7fd 100644 --- a/dlls/user32/mdi.c +++ b/dlls/user32/mdi.c @@ -452,7 +452,7 @@ static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci) buf[0] = '&'; buf[1] = '0' + visible; buf[2] = ' '; - InternalGetWindowText(ci->child[i], buf + 3, ARRAY_SIZE(buf) - 3); + NtUserInternalGetWindowText(ci->child[i], buf + 3, ARRAY_SIZE(buf) - 3); TRACE("Adding %p, id %u %s\n", ci->child[i], id, debugstr_w(buf)); AppendMenuW(ci->hWindowMenu, MF_STRING, id, buf); @@ -1911,7 +1911,7 @@ static INT_PTR WINAPI MDI_MoreWindowsDlgProc (HWND hDlg, UINT iMsg, WPARAM wPara { WCHAR buffer[MDI_MAXTITLELENGTH]; - if (!InternalGetWindowText(ci->child[i], buffer, ARRAY_SIZE(buffer))) + if (!NtUserInternalGetWindowText(ci->child[i], buffer, ARRAY_SIZE(buffer))) continue; SendMessageW(hListBox, LB_ADDSTRING, 0, (LPARAM)buffer ); SendMessageW(hListBox, LB_SETITEMDATA, i, (LPARAM)ci->child[i] ); diff --git a/dlls/user32/spy.c b/dlls/user32/spy.c index 8093799ed6b..dc8e0b2a708 100644 --- a/dlls/user32/spy.c +++ b/dlls/user32/spy.c @@ -2186,7 +2186,7 @@ static void SPY_GetWndName( SPY_INSTANCE *sp_e ) SPY_GetClassName( sp_e ); - len = InternalGetWindowText(sp_e->msg_hwnd, sp_e->wnd_name, ARRAY_SIZE(sp_e->wnd_name)); + len = NtUserInternalGetWindowText( sp_e->msg_hwnd, sp_e->wnd_name, ARRAY_SIZE(sp_e->wnd_name) ); if(!len) /* get class name */ { LPWSTR dst = sp_e->wnd_name; diff --git a/dlls/user32/static.c b/dlls/user32/static.c index 8de216269c1..d19df22dcb9 100644 --- a/dlls/user32/static.c +++ b/dlls/user32/static.c @@ -635,7 +635,7 @@ static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style ) if (!(text = HeapAlloc( GetProcessHeap(), 0, buf_size * sizeof(WCHAR) ))) goto no_TextOut; - while ((len = InternalGetWindowText( hwnd, text, buf_size )) == buf_size - 1) + while ((len = NtUserInternalGetWindowText( hwnd, text, buf_size )) == buf_size - 1) { buf_size *= 2; if (!(text = HeapReAlloc( GetProcessHeap(), 0, text, buf_size * sizeof(WCHAR) ))) diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index d6087873f21..cfcec5cc78f 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -8308,6 +8308,11 @@ static void test_gettext(void) ok( !strcmp(buf, "blah"), "got %s\n", buf ); ok( num_gettext_msgs == 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs ); + bufW[0] = 0xcc; + buf_len = InternalGetWindowText( hwnd, bufW, ARRAYSIZE(bufW) ); + ok( buf_len == ARRAYSIZE("caption") - 1, "expected a nonempty window text\n" ); + ok( !lstrcmpW( bufW, L"caption" ), "got %s\n", debugstr_w(bufW) ); + g_wm_gettext_override.enabled = FALSE; /* same for W window */ diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 88f73206943..cdd8815f67c 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -446,7 +446,7 @@ @ stdcall InsertMenuItemW(long long long ptr) @ stdcall InsertMenuW(long long long long ptr) @ stdcall InternalGetWindowIcon(ptr long) -@ stdcall InternalGetWindowText(long ptr long) +@ stdcall InternalGetWindowText(long ptr long) NtUserInternalGetWindowText @ stdcall IntersectRect(ptr ptr ptr) @ stdcall InvalidateRect(long ptr long) @ stdcall InvalidateRgn(long long long) diff --git a/dlls/user32/win.c b/dlls/user32/win.c index a71753bd148..fc31e0cc01d 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -2037,7 +2037,7 @@ HWND WINAPI FindWindowExW( HWND parent, HWND child, LPCWSTR className, LPCWSTR t { while (list[i]) { - if (InternalGetWindowText( list[i], buffer, len + 1 )) + if (NtUserInternalGetWindowText( list[i], buffer, len + 1 )) { if (!wcsicmp( buffer, title )) break; } @@ -2944,30 +2944,6 @@ INT WINAPI GetWindowTextA( HWND hwnd, LPSTR lpString, INT nMaxCount ) } -/******************************************************************* - * InternalGetWindowText (USER32.@) - */ -INT WINAPI InternalGetWindowText(HWND hwnd,LPWSTR lpString,INT nMaxCount ) -{ - WND *win; - - if (nMaxCount <= 0) return 0; - if (!(win = WIN_GetPtr( hwnd ))) return 0; - if (win == WND_DESKTOP) lpString[0] = 0; - else if (win != WND_OTHER_PROCESS) - { - if (win->text) lstrcpynW( lpString, win->text, nMaxCount ); - else lpString[0] = 0; - WIN_ReleasePtr( win ); - } - else - { - get_server_window_text( hwnd, lpString, nMaxCount ); - } - return lstrlenW(lpString); -} - - /******************************************************************* * GetWindowTextW (USER32.@) */ diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c index 95cb2452f9c..19c03b277b1 100644 --- a/dlls/win32u/syscall.c +++ b/dlls/win32u/syscall.c @@ -139,6 +139,7 @@ static void * const syscalls[] = NtUserGetSystemDpiForProcess, NtUserGetThreadDesktop, NtUserInitializeClientPfnArrays, + NtUserInternalGetWindowText, NtUserNotifyWinEvent, NtUserOpenDesktop, NtUserOpenInputDesktop, diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index d0561ad8e58..e3e7b31b4a2 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -1045,7 +1045,7 @@ @ stub NtUserInjectTouchInput @ stub NtUserInteractiveControlQueryUsage @ stub NtUserInternalGetWindowIcon -@ stub NtUserInternalGetWindowText +@ stdcall -syscall NtUserInternalGetWindowText(long ptr long) @ stub NtUserInternalToUnicode @ stub NtUserInvalidateRect @ stub NtUserInvalidateRgn diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index b0aab45d28d..93ee0ffd164 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -425,6 +425,49 @@ NTSTATUS WINAPI NtUserBuildHwndList( HDESK desktop, ULONG unk2, ULONG unk3, ULON return STATUS_SUCCESS; } +/* Retrieve the window text from the server. */ +static data_size_t get_server_window_text( HWND hwnd, WCHAR *text, data_size_t count ) +{ + data_size_t len = 0, needed = 0; + + SERVER_START_REQ( get_window_text ) + { + req->handle = wine_server_user_handle( hwnd ); + if (count) wine_server_set_reply( req, text, (count - 1) * sizeof(WCHAR) ); + if (!wine_server_call_err( req )) + { + needed = reply->length; + len = wine_server_reply_size(reply); + } + } + SERVER_END_REQ; + if (text) text[len / sizeof(WCHAR)] = 0; + return needed; +} + +/******************************************************************* + * NtUserInternalGetWindowText (win32u.@) + */ +INT WINAPI NtUserInternalGetWindowText( HWND hwnd, WCHAR *text, INT count ) +{ + WND *win; + + if (count <= 0) return 0; + if (!(win = get_win_ptr( hwnd ))) return 0; + if (win == WND_DESKTOP) text[0] = 0; + else if (win != WND_OTHER_PROCESS) + { + if (win->text) lstrcpynW( text, win->text, count ); + else text[0] = 0; + release_win_ptr( win ); + } + else + { + get_server_window_text( hwnd, text, count ); + } + return lstrlenW(text); +} + /***************************************************************************** * NtUserCallHwnd (win32u.@) */ diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h index 6ca0daee71a..78ba09645b2 100644 --- a/dlls/wow64win/syscall.h +++ b/dlls/wow64win/syscall.h @@ -124,6 +124,7 @@ SYSCALL_ENTRY( NtUserGetSystemDpiForProcess ) \ SYSCALL_ENTRY( NtUserGetThreadDesktop ) \ SYSCALL_ENTRY( NtUserInitializeClientPfnArrays ) \ + SYSCALL_ENTRY( NtUserInternalGetWindowText ) \ SYSCALL_ENTRY( NtUserNotifyWinEvent ) \ SYSCALL_ENTRY( NtUserOpenDesktop ) \ SYSCALL_ENTRY( NtUserOpenInputDesktop ) \ diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 51879956a7c..a72b0307cc5 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -214,6 +214,15 @@ NTSTATUS WINAPI wow64_NtUserBuildHwndList( UINT *args ) return status; } +NTSTATUS WINAPI wow64_NtUserInternalGetWindowText( UINT *args ) +{ + HWND hwnd = get_handle( &args ); + WCHAR *text = get_ptr( &args ); + INT count = get_ulong( &args ); + + return NtUserInternalGetWindowText( hwnd, text, count ); +} + NTSTATUS WINAPI wow64_NtUserGetLayeredWindowAttributes( UINT *args ) { HWND hwnd = get_handle( &args ); diff --git a/include/ntuser.h b/include/ntuser.h index 6111d227476..34d75f4f726 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -312,6 +312,7 @@ BOOL WINAPI NtUserGetUpdatedClipboardFormats( UINT *formats, UINT size, UINT NTSTATUS WINAPI NtUserInitializeClientPfnArrays( const struct user_client_procs *client_procsA, const struct user_client_procs *client_procsW, const void *client_workers, HINSTANCE user_module ); +INT WINAPI NtUserInternalGetWindowText( HWND hwnd, WCHAR *text, INT count ); BOOL WINAPI NtUserIsClipboardFormatAvailable( UINT format ); UINT WINAPI NtUserMapVirtualKeyEx( UINT code, UINT type, HKL layout ); void WINAPI NtUserNotifyWinEvent( DWORD event, HWND hwnd, LONG object_id, LONG child_id );
1
0
0
0
Santino Mazza : ncrypt/tests: Test for symmetric keys support.
by Alexandre Julliard
08 Mar '22
08 Mar '22
Module: wine Branch: master Commit: a5ba63b80a9ffcfd5cf58820cb5c956e76f6065c URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a5ba63b80a9ffcfd5cf58820…
Author: Santino Mazza <mazzasantino1206(a)gmail.com> Date: Tue Mar 8 11:10:56 2022 +0100 ncrypt/tests: Test for symmetric keys support. Signed-off-by: Santino Mazza <mazzasantino1206(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ncrypt/tests/ncrypt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dlls/ncrypt/tests/ncrypt.c b/dlls/ncrypt/tests/ncrypt.c index d1bcbbcab2a..cf434054428 100644 --- a/dlls/ncrypt/tests/ncrypt.c +++ b/dlls/ncrypt/tests/ncrypt.c @@ -291,6 +291,13 @@ static void test_create_persisted_key(void) NCryptFinalizeKey(key, 0); NCryptFreeObject(key); + + key = 0; + ret = NCryptCreatePersistedKey(prov, &key, BCRYPT_AES_ALGORITHM, NULL, 0, 0); + ok(ret == ERROR_SUCCESS || broken(ret == NTE_NOT_SUPPORTED) /* win 7 */, "got %#lx\n", ret); + if (ret == NTE_NOT_SUPPORTED) win_skip("broken, symmetric keys not supported.\n"); + else ok(key, "got null handle\n"); + NCryptFreeObject(prov); } }
1
0
0
0
Santino Mazza : ncrypt: Make use of bcrypt for low level cryptography.
by Alexandre Julliard
08 Mar '22
08 Mar '22
Module: wine Branch: master Commit: e679b7413eaa00161e326bffff3cd76d84f7c542 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e679b7413eaa00161e326bff…
Author: Santino Mazza <mazzasantino1206(a)gmail.com> Date: Tue Mar 8 11:10:55 2022 +0100 ncrypt: Make use of bcrypt for low level cryptography. Signed-off-by: Santino Mazza <mazzasantino1206(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ncrypt/Makefile.in | 1 + dlls/ncrypt/main.c | 93 ++++++++++++++----------------------------- dlls/ncrypt/ncrypt_internal.h | 28 ++----------- 3 files changed, 34 insertions(+), 88 deletions(-) diff --git a/dlls/ncrypt/Makefile.in b/dlls/ncrypt/Makefile.in index ad3ed409961..f46aecae66b 100644 --- a/dlls/ncrypt/Makefile.in +++ b/dlls/ncrypt/Makefile.in @@ -1,5 +1,6 @@ IMPORTLIB = ncrypt MODULE = ncrypt.dll +IMPORTS = bcrypt EXTRADLLFLAGS = -Wb,--prefer-native diff --git a/dlls/ncrypt/main.c b/dlls/ncrypt/main.c index 68d9d884618..8ace3e55731 100644 --- a/dlls/ncrypt/main.c +++ b/dlls/ncrypt/main.c @@ -88,21 +88,9 @@ SECURITY_STATUS WINAPI NCryptFreeBuffer(PVOID buf) static SECURITY_STATUS free_key_object(struct key *key) { - switch (key->alg) - { - case RSA: - { - free(key->rsa.modulus); - free(key->rsa.public_exp); - free(key->rsa.prime1); - free(key->rsa.prime2); - break; - } - default: - WARN("invalid key %p\n", key); - return NTE_INVALID_HANDLE; - } - return ERROR_SUCCESS; + NTSTATUS ret = BCryptDestroyKey(key->bcrypt_key); + if (BCryptCloseAlgorithmProvider(key->bcrypt_alg, 0)) return NTE_INVALID_HANDLE; + return ret ? NTE_INVALID_HANDLE : ERROR_SUCCESS; } SECURITY_STATUS WINAPI NCryptFreeObject(NCRYPT_HANDLE handle) @@ -246,8 +234,9 @@ SECURITY_STATUS WINAPI NCryptImportKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_H BYTE *data, DWORD datasize, DWORD flags) { BCRYPT_KEY_BLOB *header = (BCRYPT_KEY_BLOB *)data; + struct object *object; - TRACE("(%#Ix, %#Ix, %s, %p, %p, %p, %lu, %#lx): stub\n", provider, decrypt_key, wine_dbgstr_w(type), + TRACE("(%#Ix, %#Ix, %s, %p, %p, %p, %lu, %#lx)\n", provider, decrypt_key, wine_dbgstr_w(type), params, handle, data, datasize, flags); if (decrypt_key) @@ -270,70 +259,48 @@ SECURITY_STATUS WINAPI NCryptImportKey(NCRYPT_PROV_HANDLE provider, NCRYPT_KEY_H return NTE_BAD_FLAGS; } - switch (header->Magic) + if (!(object = allocate_object(KEY))) { + ERR("Error allocating memory\n"); + return NTE_NO_MEMORY; + } + + switch(header->Magic) + { + case BCRYPT_RSAFULLPRIVATE_MAGIC: + case BCRYPT_RSAPRIVATE_MAGIC: case BCRYPT_RSAPUBLIC_MAGIC: { - DWORD expected_size; - struct object *object; - struct key *key; - BYTE *public_exp, *modulus; - BCRYPT_RSAKEY_BLOB *rsaheader = (BCRYPT_RSAKEY_BLOB *)data; - - if (datasize < sizeof(*rsaheader)) - { - ERR("Invalid buffer size.\n"); - return NTE_BAD_DATA; - } - - expected_size = sizeof(*rsaheader) + rsaheader->cbPublicExp + rsaheader->cbModulus; - if (datasize != expected_size) - { - ERR("Invalid buffer size.\n"); - return NTE_BAD_DATA; - } - - if (!(object = allocate_object(KEY))) + NTSTATUS ret; + BCRYPT_RSAKEY_BLOB *rsablob = (BCRYPT_RSAKEY_BLOB *)data; + ret = BCryptOpenAlgorithmProvider(&object->key.bcrypt_alg, BCRYPT_RSA_ALGORITHM, NULL, 0); + if (ret != ERROR_SUCCESS) { - ERR("Error allocating memory.\n"); - return NTE_NO_MEMORY; - } - - key = &object->key; - key->alg = RSA; - key->rsa.bit_length = rsaheader->BitLength; - key->rsa.public_exp_size = rsaheader->cbPublicExp; - key->rsa.modulus_size = rsaheader->cbModulus; - if (!(key->rsa.public_exp = malloc(rsaheader->cbPublicExp))) - { - ERR("Error allocating memory.\n"); + ERR("Error opening algorithm provider\n"); free(object); - return NTE_NO_MEMORY; + return NTE_INTERNAL_ERROR; } - if (!(key->rsa.modulus = malloc(rsaheader->cbModulus))) + ret = BCryptImportKeyPair(object->key.bcrypt_alg, NULL, type, &object->key.bcrypt_key, data, datasize, 0); + if (ret != ERROR_SUCCESS) { - ERR("Error allocating memory.\n"); - free(key->rsa.public_exp); + WARN("Error importing key pair with bcrypt %#lx\n", ret); + BCryptCloseAlgorithmProvider(object->key.bcrypt_alg, 0); free(object); - return NTE_NO_MEMORY; + return NTE_BAD_DATA; } - public_exp = &data[sizeof(*rsaheader)]; /* The public exp is after the header. */ - modulus = &public_exp[rsaheader->cbPublicExp]; /* The modulus is after the public exponent. */ - memcpy(key->rsa.public_exp, public_exp, rsaheader->cbPublicExp); - memcpy(key->rsa.modulus, modulus, rsaheader->cbModulus); - - set_object_property(object, NCRYPT_ALGORITHM_GROUP_PROPERTY, (BYTE *)L"RSA", sizeof(L"RSA")); - set_object_property(object, NCRYPT_LENGTH_PROPERTY, (BYTE *)&key->rsa.bit_length, sizeof(key->rsa.bit_length)); set_object_property(object, NCRYPT_PROVIDER_HANDLE_PROPERTY, (BYTE *)&provider, sizeof(provider)); - *handle = (NCRYPT_KEY_HANDLE)object; + set_object_property(object, NCRYPT_ALGORITHM_GROUP_PROPERTY, (BYTE *)BCRYPT_RSA_ALGORITHM, sizeof(BCRYPT_RSA_ALGORITHM)); + set_object_property(object, NCRYPT_LENGTH_PROPERTY, (BYTE *)&rsablob->BitLength, sizeof(rsablob->BitLength)); break; } default: - FIXME("Unhandled key magic %#lx.\n", header->Magic); + FIXME("Unhandled key magic %#lx\n", header->Magic); + free(object); return NTE_INVALID_PARAMETER; } + *handle = (NCRYPT_KEY_HANDLE)object; return ERROR_SUCCESS; } diff --git a/dlls/ncrypt/ncrypt_internal.h b/dlls/ncrypt/ncrypt_internal.h index 3966dd73ed6..e5884c8871a 100644 --- a/dlls/ncrypt/ncrypt_internal.h +++ b/dlls/ncrypt/ncrypt_internal.h @@ -16,34 +16,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -enum key_algorithm -{ - DH, - DSA, - ECC, - RSA, -}; - -struct rsa_key -{ - DWORD bit_length; - DWORD public_exp_size; - BYTE *public_exp; - DWORD modulus_size; - BYTE *modulus; - DWORD prime1_size; - BYTE *prime1; - DWORD prime2_size; - BYTE *prime2; -}; +#include <bcrypt.h> struct key { - enum key_algorithm alg; - union - { - struct rsa_key rsa; - }; + BCRYPT_ALG_HANDLE bcrypt_alg; + BCRYPT_KEY_HANDLE bcrypt_key; }; struct storage_provider
1
0
0
0
← Newer
1
...
77
78
79
80
81
82
83
...
114
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
Results per page:
10
25
50
100
200