ReactOS.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
List overview
Download
Ros-diffs
January 2025
----- 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
ros-diffs@reactos.org
23 participants
278 discussions
Start a n
N
ew thread
[reactos] 04/20: [UCRT:STARTUP] Implement __scrt_uninitialize_crt stub
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=446234207603320f29d98…
commit 446234207603320f29d98852d73f1fdd930405f8 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Wed Dec 4 13:38:04 2024 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Sun Jan 26 18:08:55 2025 +0200 [UCRT:STARTUP] Implement __scrt_uninitialize_crt stub --- sdk/lib/ucrt/startup/__scrt_uninitialize_crt.cpp | 17 +++++++++++++++++ sdk/lib/ucrt/startup/startup.cmake | 1 + 2 files changed, 18 insertions(+) diff --git a/sdk/lib/ucrt/startup/__scrt_uninitialize_crt.cpp b/sdk/lib/ucrt/startup/__scrt_uninitialize_crt.cpp new file mode 100644 index 00000000000..dcb70fdebc5 --- /dev/null +++ b/sdk/lib/ucrt/startup/__scrt_uninitialize_crt.cpp @@ -0,0 +1,17 @@ +// +// __scrt_uninitialize_crt.c +// +// Copyright (c) 2024 Timo Kreuzer +// +// Implementation of __scrt_uninitialize_crt. +// +// SPDX-License-Identifier: MIT +// + +extern "C" +bool +__cdecl +__scrt_uninitialize_crt(bool is_terminating, bool from_exit) +{ + return true; +} diff --git a/sdk/lib/ucrt/startup/startup.cmake b/sdk/lib/ucrt/startup/startup.cmake index 9bc9b454df7..4bf94341ace 100644 --- a/sdk/lib/ucrt/startup/startup.cmake +++ b/sdk/lib/ucrt/startup/startup.cmake @@ -1,5 +1,6 @@ list(APPEND UCRT_STARTUP_SOURCES + startup/__scrt_uninitialize_crt.cpp startup/abort.cpp startup/argv_data.cpp startup/argv_parsing.cpp
1 week, 3 days
1
0
0
0
[reactos] 03/20: [UCRT:LOCALE] Implement __acrt_WideCharToMultiByte
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d21fd3765078594e07543…
commit d21fd3765078594e07543840e5dd835df1994111 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Mon Dec 2 13:47:49 2024 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Sun Jan 26 18:08:55 2025 +0200 [UCRT:LOCALE] Implement __acrt_WideCharToMultiByte --- sdk/lib/ucrt/locale/WideCharToMultiByte.c | 35 +++++++++++++++++++++++++++++++ sdk/lib/ucrt/locale/locale.cmake | 1 + 2 files changed, 36 insertions(+) diff --git a/sdk/lib/ucrt/locale/WideCharToMultiByte.c b/sdk/lib/ucrt/locale/WideCharToMultiByte.c new file mode 100644 index 00000000000..5e89e52f8dc --- /dev/null +++ b/sdk/lib/ucrt/locale/WideCharToMultiByte.c @@ -0,0 +1,35 @@ +// +// WideCharToMultiByte.c +// +// Copyright (c) 2024 Timo Kreuzer +// +// Definition of __acrt_WideCharToMultiByte. +// +// SPDX-License-Identifier: MIT +// + +#include <windows.h> +//#include <stringapiset.h> + +_Success_(return != 0) +int +__cdecl +__acrt_WideCharToMultiByte ( + _In_ UINT _CodePage, + _In_ DWORD _DWFlags, + _In_ LPCWSTR _LpWideCharStr, + _In_ int _CchWideChar, + _Out_writes_opt_(_CbMultiByte) LPSTR _LpMultiByteStr, + _In_ int _CbMultiByte, + _In_opt_ LPCSTR _LpDefaultChar, + _Out_opt_ LPBOOL _LpUsedDefaultChar) +{ + return WideCharToMultiByte(_CodePage, + _DWFlags, + _LpWideCharStr, + _CchWideChar, + _LpMultiByteStr, + _CbMultiByte, + _LpDefaultChar, + _LpUsedDefaultChar); +} diff --git a/sdk/lib/ucrt/locale/locale.cmake b/sdk/lib/ucrt/locale/locale.cmake index 7227d7e8d1f..c4622e4c445 100644 --- a/sdk/lib/ucrt/locale/locale.cmake +++ b/sdk/lib/ucrt/locale/locale.cmake @@ -24,4 +24,5 @@ list(APPEND UCRT_LOCALE_SOURCES locale/nlsdata.cpp locale/setlocale.cpp locale/wsetlocale.cpp + locale/WideCharToMultiByte.c )
1 week, 3 days
1
0
0
0
[reactos] 02/20: [UCRT:LOCALE] Implement __acrt_MultiByteToWideChar
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bd3c7654ec5483e735d46…
commit bd3c7654ec5483e735d46b238a262c617eadca6d Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Mon Dec 2 13:46:14 2024 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Sun Jan 26 18:08:55 2025 +0200 [UCRT:LOCALE] Implement __acrt_MultiByteToWideChar --- sdk/lib/ucrt/locale/MultiByteToWideChar.c | 31 +++++++++++++++++++++++++++++++ sdk/lib/ucrt/locale/locale.cmake | 1 + 2 files changed, 32 insertions(+) diff --git a/sdk/lib/ucrt/locale/MultiByteToWideChar.c b/sdk/lib/ucrt/locale/MultiByteToWideChar.c new file mode 100644 index 00000000000..fab0e2656a9 --- /dev/null +++ b/sdk/lib/ucrt/locale/MultiByteToWideChar.c @@ -0,0 +1,31 @@ +// +// MultiByteToWideChar.c +// +// Copyright (c) 2024 Timo Kreuzer +// +// Definition of __acrt_MultiByteToWideChar. +// +// SPDX-License-Identifier: MIT +// + +#include <windows.h> +//#include <stringapiset.h> + +_Success_(return != 0) +int +__cdecl +__acrt_MultiByteToWideChar ( + _In_ UINT _CodePage, + _In_ DWORD _DWFlags, + _In_ LPCSTR _LpMultiByteStr, + _In_ int _CbMultiByte, + _Out_writes_opt_(_CchWideChar) LPWSTR _LpWideCharStr, + _In_ int _CchWideChar) +{ + return MultiByteToWideChar(_CodePage, + _DWFlags, + _LpMultiByteStr, + _CbMultiByte, + _LpWideCharStr, + _CchWideChar); +} diff --git a/sdk/lib/ucrt/locale/locale.cmake b/sdk/lib/ucrt/locale/locale.cmake index 038a0f46dc0..7227d7e8d1f 100644 --- a/sdk/lib/ucrt/locale/locale.cmake +++ b/sdk/lib/ucrt/locale/locale.cmake @@ -20,6 +20,7 @@ list(APPEND UCRT_LOCALE_SOURCES locale/localeconv.cpp locale/locale_refcounting.cpp locale/locale_update.cpp + locale/MultiByteToWideChar.c locale/nlsdata.cpp locale/setlocale.cpp locale/wsetlocale.cpp
1 week, 3 days
1
0
0
0
[reactos] 01/20: [UCRT:LOCALE] Implement __acrt_GetStringTypeW
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4ea1841f31e178d0bbf63…
commit 4ea1841f31e178d0bbf6346e37e51f154a539e8b Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Mon Oct 21 17:33:43 2024 +0300 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Sun Jan 26 18:08:55 2025 +0200 [UCRT:LOCALE] Implement __acrt_GetStringTypeW --- sdk/lib/ucrt/locale/GetStringTypeW.c | 24 ++++++++++++++++++++++++ sdk/lib/ucrt/locale/locale.cmake | 1 + 2 files changed, 25 insertions(+) diff --git a/sdk/lib/ucrt/locale/GetStringTypeW.c b/sdk/lib/ucrt/locale/GetStringTypeW.c new file mode 100644 index 00000000000..10ac0d85132 --- /dev/null +++ b/sdk/lib/ucrt/locale/GetStringTypeW.c @@ -0,0 +1,24 @@ +// +// GetStringTypeW.c +// +// Copyright (c) 2024 Timo Kreuzer +// +// Definition of __acrt_GetStringTypeW. +// +// SPDX-License-Identifier: MIT +// + +#include <windows.h> +//#include <stringapiset.h> + +_Success_(return) +BOOL +__cdecl +__acrt_GetStringTypeW ( + _In_ DWORD _DWInfoType, + _In_NLS_string_(_CchSrc) PCWCH _LpSrcStr, + _In_ int _CchSrc, + _Out_ LPWORD _LpCharType) +{ + return GetStringTypeW(_DWInfoType, _LpSrcStr, _CchSrc, _LpCharType); +} diff --git a/sdk/lib/ucrt/locale/locale.cmake b/sdk/lib/ucrt/locale/locale.cmake index 97fe554114a..038a0f46dc0 100644 --- a/sdk/lib/ucrt/locale/locale.cmake +++ b/sdk/lib/ucrt/locale/locale.cmake @@ -6,6 +6,7 @@ list(APPEND UCRT_LOCALE_SOURCES locale/GetLocaleInfoA.cpp locale/getqloc_downlevel.cpp locale/GetStringTypeA.cpp + locale/GetStringTypeW.c locale/get_qualified_locale.cpp locale/glstatus.cpp locale/initctype.cpp
1 week, 3 days
1
0
0
0
[reactos] 01/01: [SYSSETUP] Move the creation of start menu items into the wizard
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=56b0f836c518d7f737dc9…
commit 56b0f836c518d7f737dc933697836a753fea1bbb Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Sun Jan 26 11:45:28 2025 +0100 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Sun Jan 26 11:46:04 2025 +0100 [SYSSETUP] Move the creation of start menu items into the wizard Start menu items were created after the wizard had finished. This patch moves the creation of the start menu items into the process page of the wizard and enables the 2nd item of the task list. --- dll/win32/syssetup/globals.h | 45 ++++++++++++++ dll/win32/syssetup/install.c | 142 ++++++++++++++++++++++++++++++++----------- dll/win32/syssetup/wizard.c | 38 +++--------- 3 files changed, 159 insertions(+), 66 deletions(-) diff --git a/dll/win32/syssetup/globals.h b/dll/win32/syssetup/globals.h index 8c020acefb3..85b3f8dea3a 100644 --- a/dll/win32/syssetup/globals.h +++ b/dll/win32/syssetup/globals.h @@ -25,12 +25,57 @@ typedef struct _ADMIN_INFO LPWSTR Password; } ADMIN_INFO, *PADMIN_INFO; + +typedef struct _ITEMSDATA +{ + HWND hwndDlg; +} ITEMSDATA, *PITEMSDATA; + +typedef struct _REGISTRATIONNOTIFY +{ + ULONG Progress; + UINT ActivityID; + LPCWSTR CurrentItem; + LPCWSTR ErrorMessage; + UINT MessageID; + DWORD LastError; +} REGISTRATIONNOTIFY, *PREGISTRATIONNOTIFY; + + +#define PM_REGISTRATION_NOTIFY (WM_APP + 1) +/* Private Message used to communicate progress from the background + registration thread to the main thread. + wParam = 0 Registration in progress + = 1 Registration completed + lParam = Pointer to a REGISTRATIONNOTIFY structure */ + +#define PM_ITEM_START (WM_APP + 2) +/* Start of a new Item + wParam = item number + lParam = number of steps */ + +#define PM_ITEM_END (WM_APP + 3) +/* End of a new Item + wParam = unused + lParam = Error Code */ + +#define PM_STEP_START (WM_APP + 4) +#define PM_STEP_END (WM_APP + 5) +#define PM_ITEMS_DONE (WM_APP + 6) + + extern HINSTANCE hDllInstance; extern HINF hSysSetupInf; extern ADMIN_INFO AdminInfo; BOOL RegisterTypeLibraries (HINF hinf, LPCWSTR szSection); +/* install */ + +VOID +InstallStartMenuItems( + _In_ PITEMSDATA pItemsData); + /* netinstall.c */ BOOL diff --git a/dll/win32/syssetup/install.c b/dll/win32/syssetup/install.c index 0f6a150da4e..61d5da1bc33 100644 --- a/dll/win32/syssetup/install.c +++ b/dll/win32/syssetup/install.c @@ -180,7 +180,13 @@ CreateShortcut( } -static BOOL CreateShortcutsFromSection(HINF hinf, LPWSTR pszSection, LPCWSTR pszFolder) +static BOOL +CreateShortcutsFromSection( + _In_ PITEMSDATA pItemsData, + _In_ PREGISTRATIONNOTIFY pNotify, + _In_ HINF hinf, + _In_ LPWSTR pszSection, + _In_ LPCWSTR pszFolder) { INFCONTEXT Context; DWORD dwFieldCount; @@ -196,6 +202,10 @@ static BOOL CreateShortcutsFromSection(HINF hinf, LPWSTR pszSection, LPCWSTR psz do { + pNotify->Progress++; + + SendMessage(pItemsData->hwndDlg, PM_STEP_START, 0, (LPARAM)pNotify); + dwFieldCount = SetupGetFieldCount(&Context); if (dwFieldCount < 3) continue; @@ -222,12 +232,19 @@ static BOOL CreateShortcutsFromSection(HINF hinf, LPWSTR pszSection, LPCWSTR psz CreateShortcut(pszFolder, szName, szCommand, szDescription, iIconNr, szDirectory, szArgs); + SendMessage(pItemsData->hwndDlg, PM_STEP_END, 0, (LPARAM)pNotify); + } while (SetupFindNextLine(&Context, &Context)); return TRUE; } -static BOOL CreateShortcuts(HINF hinf, LPCWSTR szSection) +static BOOL +CreateShortcuts( + _In_ PITEMSDATA pItemsData, + _In_ PREGISTRATIONNOTIFY pNotify, + _In_ HINF hinf, + _In_ LPCWSTR szSection) { INFCONTEXT Context; WCHAR szPath[MAX_PATH]; @@ -257,7 +274,7 @@ static BOOL CreateShortcuts(HINF hinf, LPCWSTR szSection) if (FAILED(SHGetFolderPathAndSubDirW(NULL, csidl|CSIDL_FLAG_CREATE, (HANDLE)-1, SHGFP_TYPE_DEFAULT, szFolder, szPath))) continue; - CreateShortcutsFromSection(hinf, szFolderSection, szPath); + CreateShortcutsFromSection(pItemsData, pNotify, hinf, szFolderSection, szPath); } while (SetupFindNextLine(&Context, &Context)); @@ -266,6 +283,92 @@ static BOOL CreateShortcuts(HINF hinf, LPCWSTR szSection) return TRUE; } +static LONG +CountShortcuts( + _In_ HINF hinf, + _In_ LPCWSTR szSection) +{ + INFCONTEXT Context; + WCHAR szFolderSection[MAX_PATH]; + LONG Steps = 0; + + if (!SetupFindFirstLine(hinf, szSection, NULL, &Context)) + return FALSE; + + do + { + if (SetupGetFieldCount(&Context) < 2) + continue; + + if (!SetupGetStringFieldW(&Context, 0, szFolderSection, ARRAYSIZE(szFolderSection), NULL)) + continue; + + Steps += SetupGetLineCountW(hinf, szFolderSection); + } while (SetupFindNextLine(&Context, &Context)); + + return Steps; +} + +VOID +InstallStartMenuItems( + _In_ PITEMSDATA pItemsData) +{ + HINF hShortcutsInf1 = INVALID_HANDLE_VALUE; + HINF hShortcutsInf2 = INVALID_HANDLE_VALUE; + LONG Steps = 0; + DWORD LastError = 0; + REGISTRATIONNOTIFY Notify; + + ZeroMemory(&Notify, sizeof(Notify)); + + hShortcutsInf1 = SetupOpenInfFileW(L"shortcuts.inf", + NULL, + INF_STYLE_WIN4, + NULL); + if (hShortcutsInf1 == INVALID_HANDLE_VALUE) + { + DPRINT1("Failed to open shortcuts.inf"); + return; + } + + hShortcutsInf2 = SetupOpenInfFileW(L"rosapps_shortcuts.inf", + NULL, + INF_STYLE_WIN4, + NULL); + +// Steps = SetupGetLineCountW(hShortcutsInf1, L"ShortcutFolders"); + Steps = CountShortcuts(hShortcutsInf1, L"ShortcutFolders"); + if (hShortcutsInf2 != INVALID_HANDLE_VALUE) + Steps += CountShortcuts(hShortcutsInf2, L"ShortcutFolders"); +// Steps += SetupGetLineCountW(hShortcutsInf2, L"ShortcutFolders"); + + SendMessage(pItemsData->hwndDlg, PM_ITEM_START, 1, (LPARAM)Steps); + + if (!CreateShortcuts(pItemsData, &Notify, hShortcutsInf1, L"ShortcutFolders")) + { + DPRINT1("CreateShortcuts() failed"); + goto done; + } + + if (hShortcutsInf2 != INVALID_HANDLE_VALUE) + { + if (!CreateShortcuts(pItemsData, &Notify, hShortcutsInf2, L"ShortcutFolders")) + { + DPRINT1("CreateShortcuts(rosapps) failed"); + goto done; + } + } + +done: + if (hShortcutsInf2 != INVALID_HANDLE_VALUE) + SetupCloseInfFile(hShortcutsInf2); + + if (hShortcutsInf1 != INVALID_HANDLE_VALUE) + SetupCloseInfFile(hShortcutsInf1); + + SendMessage(pItemsData->hwndDlg, PM_ITEM_END, 1, LastError); +} + static VOID CreateTempDir( IN LPCWSTR VarName) @@ -1393,7 +1496,6 @@ InstallReactOS(VOID) HANDLE token; TOKEN_PRIVILEGES privs; HKEY hKey; - HINF hShortcutsInf; HANDLE hHotkeyThread; BOOL ret; @@ -1484,38 +1586,6 @@ InstallReactOS(VOID) SetAutoAdminLogon(); - hShortcutsInf = SetupOpenInfFileW(L"shortcuts.inf", - NULL, - INF_STYLE_WIN4, - NULL); - if (hShortcutsInf == INVALID_HANDLE_VALUE) - { - FatalError("Failed to open shortcuts.inf"); - return 0; - } - - if (!CreateShortcuts(hShortcutsInf, L"ShortcutFolders")) - { - FatalError("CreateShortcuts() failed"); - return 0; - } - - SetupCloseInfFile(hShortcutsInf); - - hShortcutsInf = SetupOpenInfFileW(L"rosapps_shortcuts.inf", - NULL, - INF_STYLE_WIN4, - NULL); - if (hShortcutsInf != INVALID_HANDLE_VALUE) - { - if (!CreateShortcuts(hShortcutsInf, L"ShortcutFolders")) - { - FatalError("CreateShortcuts(rosapps) failed"); - return 0; - } - SetupCloseInfFile(hShortcutsInf); - } - SetupCloseInfFile(hSysSetupInf); SetSetupType(0); diff --git a/dll/win32/syssetup/wizard.c b/dll/win32/syssetup/wizard.c index 491e2504e12..4675ff904a9 100644 --- a/dll/win32/syssetup/wizard.c +++ b/dll/win32/syssetup/wizard.c @@ -27,34 +27,6 @@ #define NDEBUG #include <debug.h> -#define PM_REGISTRATION_NOTIFY (WM_APP + 1) -/* Private Message used to communicate progress from the background - registration thread to the main thread. - wParam = 0 Registration in progress - = 1 Registration completed - lParam = Pointer to a REGISTRATIONNOTIFY structure */ - -#define PM_ITEM_START (WM_APP + 2) -#define PM_ITEM_END (WM_APP + 3) -#define PM_STEP_START (WM_APP + 4) -#define PM_STEP_END (WM_APP + 5) -#define PM_ITEMS_DONE (WM_APP + 6) - -typedef struct _REGISTRATIONNOTIFY -{ - ULONG Progress; - UINT ActivityID; - LPCWSTR CurrentItem; - LPCWSTR ErrorMessage; - UINT MessageID; - DWORD LastError; -} REGISTRATIONNOTIFY, *PREGISTRATIONNOTIFY; - -typedef struct _ITEMSDATA -{ - HWND hwndDlg; -} ITEMSDATA, *PITEMSDATA; - typedef struct _REGISTRATIONDATA { HWND hwndDlg; @@ -2043,7 +2015,7 @@ RegistrationNotificationProc(PVOID Context, { DPRINT("Received SPFILENOTIFY_STARTREGISTRATION notification for %S\n", StatusInfo->FileName); - RegistrationNotify.ErrorMessage = NULL; +// RegistrationNotify.ErrorMessage = NULL; RegistrationNotify.Progress = RegistrationData->Registered; SendMessage(RegistrationData->hwndDlg, PM_STEP_START, 0, (LPARAM)&RegistrationNotify); } @@ -2193,10 +2165,14 @@ ItemCompletionThread( pItemsData = (PITEMSDATA)Parameter; hwndDlg = pItemsData->hwndDlg; + /* Step 0 - Registering components */ RegisterDlls(pItemsData); RegisterTypeLibraries(hSysSetupInf, L"TypeLibraries"); + /* Step 1 - Installing start menu items */ + InstallStartMenuItems(pItemsData); + /* FIXME: Add completion steps here! */ // FIXME: Move this call to a separate cleanup page! @@ -2345,7 +2321,6 @@ ProcessPageDlgProc(HWND hwndDlg, /* Save pointer to the global setup data */ SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (DWORD_PTR)SetupData); - ShowWindow(GetDlgItem(hwndDlg, IDC_TASKTEXT2), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_TASKTEXT3), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_TASKTEXT4), SW_HIDE); break; @@ -2354,12 +2329,15 @@ ProcessPageDlgProc(HWND hwndDlg, switch (((LPNMHDR)lParam)->code) { case PSN_SETACTIVE: + LogItem(L"BEGIN", L"ProcessPage"); + /* Disable the Back and Next buttons */ PropSheet_SetWizButtons(GetParent(hwndDlg), 0); RunItemCompletionThread(hwndDlg); break; case PSN_WIZNEXT: + LogItem(L"END", L"ProcessPage"); break; case PSN_WIZBACK:
1 week, 3 days
1
0
0
0
[reactos] 01/01: [SHELL32][SHELL32_APITEST][SDK] SHIsBadInterfacePtr (#7664)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a58bf9591479f9feff360…
commit a58bf9591479f9feff3609ef846af9d7563b9caa Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Sun Jan 26 19:24:24 2025 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Sun Jan 26 19:24:24 2025 +0900 [SHELL32][SHELL32_APITEST][SDK] SHIsBadInterfacePtr (#7664) Implementing missing features... JIRA issue: CORE-19278 - Move function definition from stubs.cpp to utils.cpp. - Implement SHIsBadInterfacePtr function in utils.cpp. - Add prototype to <undocshell.h>. --- dll/win32/shell32/stubs.cpp | 11 ----- dll/win32/shell32/utils.cpp | 24 ++++++++++ modules/rostests/apitests/shell32/CMakeLists.txt | 1 + .../apitests/shell32/SHIsBadInterfacePtr.cpp | 53 ++++++++++++++++++++++ modules/rostests/apitests/shell32/testlist.c | 2 + sdk/include/reactos/undocshell.h | 5 ++ 6 files changed, 85 insertions(+), 11 deletions(-) diff --git a/dll/win32/shell32/stubs.cpp b/dll/win32/shell32/stubs.cpp index f9ef73a2d7e..3034c25d9fd 100644 --- a/dll/win32/shell32/stubs.cpp +++ b/dll/win32/shell32/stubs.cpp @@ -566,17 +566,6 @@ DDECreatePostNotify(LPVOID lpUnknown) return NULL; } -/* - * Unimplemented - */ -EXTERN_C BOOL -WINAPI -SHIsBadInterfacePtr(LPVOID pv, UINT ucb) -{ - FIXME("SHIsBadInterfacePtr() stub\n"); - return FALSE; -} - /* * Unimplemented */ diff --git a/dll/win32/shell32/utils.cpp b/dll/win32/shell32/utils.cpp index 8214a9bb10c..693a8619aff 100644 --- a/dll/win32/shell32/utils.cpp +++ b/dll/win32/shell32/utils.cpp @@ -1809,6 +1809,30 @@ SHELL_CreateShell32DefaultExtractIcon(int IconIndex, REFIID riid, LPVOID *ppvOut return initIcon->QueryInterface(riid, ppvOut); } +/************************************************************************* + * SHIsBadInterfacePtr [SHELL32.84] + * + * Retired in 6.0 from Windows Vista and higher. + */ +EXTERN_C +BOOL WINAPI +SHIsBadInterfacePtr( + _In_ LPCVOID pv, + _In_ UINT_PTR ucb) +{ + struct CUnknownVtbl + { + HRESULT (STDMETHODCALLTYPE *QueryInterface)(REFIID riid, LPVOID *ppvObj); + ULONG (STDMETHODCALLTYPE *AddRef)(); + ULONG (STDMETHODCALLTYPE *Release)(); + }; + struct CUnknown { CUnknownVtbl *lpVtbl; }; + const CUnknown *punk = reinterpret_cast<const CUnknown *>(pv); + return !punk || IsBadReadPtr(punk, sizeof(punk->lpVtbl)) || + IsBadReadPtr(punk->lpVtbl, ucb) || + IsBadCodePtr((FARPROC)punk->lpVtbl->Release); +} + /************************************************************************* * SHGetUserDisplayName [SHELL32.241] * diff --git a/modules/rostests/apitests/shell32/CMakeLists.txt b/modules/rostests/apitests/shell32/CMakeLists.txt index 3c9a2e73dcf..6f4dfdb00f3 100644 --- a/modules/rostests/apitests/shell32/CMakeLists.txt +++ b/modules/rostests/apitests/shell32/CMakeLists.txt @@ -32,6 +32,7 @@ list(APPEND SOURCE SHCreateFileDataObject.cpp SHCreateFileExtractIconW.cpp SHGetUnreadMailCountW.cpp + SHIsBadInterfacePtr.cpp SHParseDisplayName.cpp SHRestricted.cpp SHShouldShowWizards.cpp diff --git a/modules/rostests/apitests/shell32/SHIsBadInterfacePtr.cpp b/modules/rostests/apitests/shell32/SHIsBadInterfacePtr.cpp new file mode 100644 index 00000000000..d90ad1dfb01 --- /dev/null +++ b/modules/rostests/apitests/shell32/SHIsBadInterfacePtr.cpp @@ -0,0 +1,53 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+
) + * PURPOSE: Test for SHIsBadInterfacePtr + * COPYRIGHT: Copyright 2025 Katayama Hirofumi MZ (katayama.hirofumi.mz(a)gmail.com) + */ + +#include "shelltest.h" +#include <undocshell.h> + +typedef BOOL (WINAPI *FN_SHIsBadInterfacePtr)(LPCVOID, UINT_PTR); + +static HRESULT STDMETHODCALLTYPE dummy_QueryInterface(REFIID riid, LPVOID *ppvObj) { return S_OK; } +static ULONG STDMETHODCALLTYPE dummy_AddRef() { return S_OK; } +static ULONG STDMETHODCALLTYPE dummy_Release() { return S_OK; } + +START_TEST(SHIsBadInterfacePtr) +{ + struct CUnknownVtbl + { + HRESULT (STDMETHODCALLTYPE *QueryInterface)(REFIID riid, LPVOID *ppvObj); + ULONG (STDMETHODCALLTYPE *AddRef)(); + ULONG (STDMETHODCALLTYPE *Release)(); + }; + struct CUnknown { CUnknownVtbl *lpVtbl; }; + + BOOL ret; + FN_SHIsBadInterfacePtr SHIsBadInterfacePtr = + (FN_SHIsBadInterfacePtr)GetProcAddress(GetModuleHandleW(L"shell32"), MAKEINTRESOURCEA(84)); + + if (!SHIsBadInterfacePtr) + { + skip("There is no SHIsBadInterfacePtr\n"); + return; + } + + ret = SHIsBadInterfacePtr(NULL, 1); + ok_int(ret, TRUE); + + CUnknown unk1 = { NULL }; + ret = SHIsBadInterfacePtr(&unk1, 1); + ok_int(ret, TRUE); + + CUnknownVtbl vtbl1 = { dummy_QueryInterface, dummy_AddRef, NULL }; + CUnknown unk2 = { &vtbl1 }; + ret = SHIsBadInterfacePtr(&unk2, 1); + ok_int(ret, TRUE); + + CUnknownVtbl vtbl2 = { dummy_QueryInterface, dummy_AddRef, dummy_Release }; + CUnknown unk3 = { &vtbl2 }; + ret = SHIsBadInterfacePtr(&unk3, 1); + ok_int(ret, FALSE); +} diff --git a/modules/rostests/apitests/shell32/testlist.c b/modules/rostests/apitests/shell32/testlist.c index 3c1cbd7e045..91078fb8cc1 100644 --- a/modules/rostests/apitests/shell32/testlist.c +++ b/modules/rostests/apitests/shell32/testlist.c @@ -46,6 +46,7 @@ extern void func_SHGetAttributesFromDataObject(void); extern void func_SHGetFileInfo(void); extern void func_SHGetUnreadMailCountW(void); extern void func_SHGetUserDisplayName(void); +extern void func_SHIsBadInterfacePtr(void); extern void func_SHLimitInputEdit(void); extern void func_SHParseDisplayName(void); extern void func_SHShouldShowWizards(void); @@ -99,6 +100,7 @@ const struct test winetest_testlist[] = { "SHGetFileInfo", func_SHGetFileInfo }, { "SHGetUnreadMailCountW", func_SHGetUnreadMailCountW }, { "SHGetUserDisplayName", func_SHGetUserDisplayName }, + { "SHIsBadInterfacePtr", func_SHIsBadInterfacePtr }, { "SHLimitInputEdit", func_SHLimitInputEdit }, { "SHParseDisplayName", func_SHParseDisplayName }, { "SHShouldShowWizards", func_SHShouldShowWizards }, diff --git a/sdk/include/reactos/undocshell.h b/sdk/include/reactos/undocshell.h index 797979334ee..574f4851e1a 100644 --- a/sdk/include/reactos/undocshell.h +++ b/sdk/include/reactos/undocshell.h @@ -954,6 +954,11 @@ LONG WINAPI SHRegQueryValueExW( #define SHRegQueryValueEx SHRegQueryValueExA #endif +BOOL WINAPI +SHIsBadInterfacePtr( + _In_ LPCVOID pv, + _In_ UINT_PTR ucb); + HRESULT WINAPI CopyStreamUI( _In_ IStream *pSrc,
1 week, 3 days
1
0
0
0
[reactos] 01/01: [NTDLL] Acquire LdrpLoaderLock in LdrpInitializeThread
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e302bacd7eec26abda16e…
commit e302bacd7eec26abda16ee3674f61a7cf5588df6 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Mon Jun 3 10:06:57 2024 +0300 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Sat Jan 25 21:50:32 2025 +0200 [NTDLL] Acquire LdrpLoaderLock in LdrpInitializeThread This is required to protect against a race with LdrShutdownThread, which can lead to all kinds of problems, including deadlocks. --- dll/ntdll/ldr/ldrinit.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dll/ntdll/ldr/ldrinit.c b/dll/ntdll/ldr/ldrinit.c index 5ee01e3e68d..4fbc4f293aa 100644 --- a/dll/ntdll/ldr/ldrinit.c +++ b/dll/ntdll/ldr/ldrinit.c @@ -517,6 +517,9 @@ LdrpInitializeThread(IN PCONTEXT Context) NtCurrentTeb()->RealClientId.UniqueProcess, NtCurrentTeb()->RealClientId.UniqueThread); + /* Acquire the loader Lock */ + RtlEnterCriticalSection(&LdrpLoaderLock); + /* Allocate an Activation Context Stack */ DPRINT("ActivationContextStack %p\n", NtCurrentTeb()->ActivationContextStackPointer); Status = RtlAllocateActivationContextStack(&NtCurrentTeb()->ActivationContextStackPointer); @@ -526,7 +529,7 @@ LdrpInitializeThread(IN PCONTEXT Context) } /* Make sure we are not shutting down */ - if (LdrpShutdownInProgress) return; + if (LdrpShutdownInProgress) goto Exit; /* Allocate TLS */ LdrpAllocateTls(); @@ -633,6 +636,11 @@ LdrpInitializeThread(IN PCONTEXT Context) RtlDeactivateActivationContextUnsafeFast(&ActCtx); } +Exit: + + /* Release the loader lock */ + RtlLeaveCriticalSection(&LdrpLoaderLock); + DPRINT("LdrpInitializeThread() done\n"); }
1 week, 4 days
1
0
0
0
[reactos] 01/01: [RAPPS] Reuse active pending downloads window (#7648)
by Whindmar Saksit
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=72951421e6780b85ac125…
commit 72951421e6780b85ac1254f7561425ef3b6eb5a9 Author: Whindmar Saksit <whindsaks(a)proton.me> AuthorDate: Sat Jan 25 16:42:48 2025 +0100 Commit: GitHub <noreply(a)github.com> CommitDate: Sat Jan 25 16:42:48 2025 +0100 [RAPPS] Reuse active pending downloads window (#7648) CORE-16716 CORE-16804 --- base/applications/rapps/gui.cpp | 2 +- base/applications/rapps/loaddlg.cpp | 1094 ++++++++++++++++++----------------- 2 files changed, 551 insertions(+), 545 deletions(-) diff --git a/base/applications/rapps/gui.cpp b/base/applications/rapps/gui.cpp index 5e8dc85a8ba..6f2e1a1d3d8 100644 --- a/base/applications/rapps/gui.cpp +++ b/base/applications/rapps/gui.cpp @@ -816,7 +816,7 @@ CMainWindow::InstallApplication(CAppInfo *Info) { if (DownloadApplication(Info)) { - UpdateApplicationsList(SelectedEnumType); + //FIXME: Delay UpdateApplicationsList(SelectedEnumType); until install completes return TRUE; } } diff --git a/base/applications/rapps/loaddlg.cpp b/base/applications/rapps/loaddlg.cpp index c0ca9d135dc..df8afcbeeea 100644 --- a/base/applications/rapps/loaddlg.cpp +++ b/base/applications/rapps/loaddlg.cpp @@ -119,6 +119,19 @@ UrlUnescapeAndMakeFileNameValid(CStringW& str) str = szPath; } +static void +SetFriendlyUrl(HWND hWnd, LPCWSTR pszUrl) +{ + CStringW buf; + DWORD cch = (DWORD)(wcslen(pszUrl) + 1); + if (InternetCanonicalizeUrlW(pszUrl, buf.GetBuffer(cch), &cch, ICU_DECODE | ICU_NO_ENCODE)) + { + buf.ReleaseBuffer(); + pszUrl = buf; + } + SetWindowTextW(hWnd, pszUrl); +} + struct DownloadInfo { DownloadInfo() : DLType(DLTYPE_APPLICATION), IType(INSTALLER_UNKNOWN), SizeInBytes(0) @@ -130,9 +143,12 @@ struct DownloadInfo szName = AppInfo.szDisplayName; IType = AppInfo.GetInstallerType(); if (IType == INSTALLER_GENERATE) - { szPackageName = AppInfo.szIdentifier; - } + } + + bool Equal(const DownloadInfo &other) const + { + return DLType == other.DLType && !lstrcmpW(szUrl, other.szUrl); } DownloadType DLType; @@ -144,21 +160,6 @@ struct DownloadInfo ULONG SizeInBytes; }; -struct DownloadParam -{ - DownloadParam() : Dialog(NULL), AppInfo(), szCaption(NULL) - { - } - DownloadParam(HWND dlg, const ATL::CSimpleArray<DownloadInfo> &info, LPCWSTR caption) - : Dialog(dlg), AppInfo(info), szCaption(caption) - { - } - - HWND Dialog; - ATL::CSimpleArray<DownloadInfo> AppInfo; - LPCWSTR szCaption; -}; - class CDownloaderProgress : public CWindowImpl<CDownloaderProgress, CWindow, CControlWinTraits> { CStringW m_szProgressText; @@ -313,7 +314,7 @@ class CDowloadingAppsListView : public CListView RECT r; ::GetClientRect(hwndParent, &r); r.top = (2 * r.top + 1 * r.bottom) / 3; /* The vertical position at ratio 1 : 2 */ -#define MARGIN 10 + const INT MARGIN = 10; ::InflateRect(&r, -MARGIN, -MARGIN); const DWORD style = WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | @@ -328,11 +329,12 @@ class CDowloadingAppsListView : public CListView } VOID - LoadList(ATL::CSimpleArray<DownloadInfo> arrInfo) + LoadList(ATL::CSimpleArray<DownloadInfo> arrInfo, UINT Start = 0) { - for (INT i = 0; i < arrInfo.GetSize(); ++i) + const INT base = GetItemCount(); + for (INT i = Start; i < arrInfo.GetSize(); ++i) { - AddRow(i, arrInfo[i].szName.GetString(), DLSTATUS_WAITING); + AddRow(base + i - Start, arrInfo[i].szName, DLSTATUS_WAITING); } } @@ -420,7 +422,7 @@ CertGetSubjectAndIssuer(HINTERNET hFile, CLocalPtr<char> &subjectInfo, CLocalPtr } #endif -inline VOID +static inline VOID MessageBox_LoadString(HWND hOwnerWnd, INT StringID) { CStringW szMsgText; @@ -430,65 +432,175 @@ MessageBox_LoadString(HWND hOwnerWnd, INT StringID) } } +static BOOL +ShowLastError(HWND hWndOwner, BOOL bInetError, DWORD dwLastError) +{ + CLocalPtr<WCHAR> lpMsg; + + if (!FormatMessageW( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | + (bInetError ? FORMAT_MESSAGE_FROM_HMODULE : FORMAT_MESSAGE_FROM_SYSTEM), + (bInetError ? GetModuleHandleW(L"wininet.dll") : NULL), dwLastError, LANG_USER_DEFAULT, (LPWSTR)&lpMsg, 0, + NULL)) + { + DPRINT1("FormatMessageW unexpected failure (err %d)\n", GetLastError()); + return FALSE; + } + + MessageBoxW(hWndOwner, lpMsg, NULL, MB_OK | MB_ICONERROR); + return TRUE; +} + // Download dialog (loaddlg.cpp) -class CDownloadManager +HWND g_hDownloadWnd = NULL; + +class CDownloadManager : + public CComCoClass<CDownloadManager, &CLSID_NULL>, + public CComObjectRootEx<CComMultiThreadModelNoCS>, + public IUnknown { - static ATL::CSimpleArray<DownloadInfo> AppsDownloadList; - static CDowloadingAppsListView DownloadsListView; - static CDownloaderProgress ProgressBar; - static BOOL bCancelled; - static BOOL bModal; - static VOID - UpdateProgress(HWND hDlg, ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText); +public: + enum { + WM_ISCANCELLED = WM_APP, // Return BOOL + WM_SETSTATUS, // wParam DownloadStatus + WM_GETINSTANCE, // Return CDownloadManager* + WM_GETNEXT, // Return DownloadInfo* or NULL + }; + + CDownloadManager() : m_hDlg(NULL), m_Threads(0), m_Index(0), m_bCancelled(FALSE) {} + + static CDownloadManager* + CreateInstanceHelper(BOOL Modal) + { + if (!Modal) + { + CDownloadManager* pExisting = CDownloadManager::FindInstance(); + if (pExisting) + { + pExisting->AddRef(); + return pExisting; + } + } + CComPtr<CDownloadManager> obj; + if (FAILED(ShellObjectCreator(obj))) + return NULL; + obj->m_bModal = Modal; + return obj.Detach(); + } - public: - static VOID - Add(DownloadInfo info); - static VOID - Download(const DownloadInfo &DLInfo, BOOL bIsModal = FALSE); - static INT_PTR CALLBACK - DownloadDlgProc(HWND Dlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - static unsigned int WINAPI - ThreadFunc(LPVOID Context); - static VOID LaunchDownloadDialog(BOOL); + static BOOL + CreateInstance(BOOL Modal, CComPtr<CDownloadManager> &Obj) + { + CDownloadManager *p = CreateInstanceHelper(Modal); + if (!p) + return FALSE; + Obj.Attach(p); + return TRUE; + } + + static CDownloadManager* + FindInstance() + { + if (g_hDownloadWnd) + return (CDownloadManager*)SendMessageW(g_hDownloadWnd, WM_GETINSTANCE, 0, 0); + return NULL; + } + + BOOL + IsCancelled() + { + return !IsWindow(m_hDlg) || SendMessageW(m_hDlg, WM_ISCANCELLED, 0, 0); + } + + void StartWorkerThread(); + void Add(const DownloadInfo &Info); + void Show(); + static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); + INT_PTR RealDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); + void UpdateProgress(ULONG ulProgress, ULONG ulProgressMax); + static unsigned int CALLBACK ThreadFunc(void*ThreadParam); + void PerformDownloadAndInstall(const DownloadInfo &Info); + + DECLARE_NO_REGISTRY() + DECLARE_NOT_AGGREGATABLE(CDownloadManager) + BEGIN_COM_MAP(CDownloadManager) + END_COM_MAP() + +protected: + HWND m_hDlg; + UINT m_Threads; + UINT m_Index; + BOOL m_bCancelled; + BOOL m_bModal; + WCHAR m_szCaptionFmt[100]; + ATL::CSimpleArray<DownloadInfo> m_List; + CDowloadingAppsListView m_ListView; + CDownloaderProgress m_ProgressBar; }; -// CDownloadManager -ATL::CSimpleArray<DownloadInfo> CDownloadManager::AppsDownloadList; -CDowloadingAppsListView CDownloadManager::DownloadsListView; -CDownloaderProgress CDownloadManager::ProgressBar; -BOOL CDownloadManager::bCancelled = FALSE; -BOOL CDownloadManager::bModal = FALSE; +void +CDownloadManager::StartWorkerThread() +{ + AddRef(); // To keep m_List alive in thread + unsigned int ThreadId; + HANDLE Thread = (HANDLE)_beginthreadex(NULL, 0, ThreadFunc, this, 0, &ThreadId); + if (Thread) + CloseHandle(Thread); + else + Release(); +} -VOID -CDownloadManager::Add(DownloadInfo info) +void +CDownloadManager::Add(const DownloadInfo &Info) { - AppsDownloadList.Add(info); + const UINT count = m_List.GetSize(), start = count; + for (UINT i = 0; i < count; ++i) + { + if (Info.Equal(m_List[i])) + return; // Already in the list + } + m_List.Add(Info); + if (m_hDlg) + m_ListView.LoadList(m_List, start); } -VOID -CDownloadManager::Download(const DownloadInfo &DLInfo, BOOL bIsModal) +void +CDownloadManager::Show() { - AppsDownloadList.RemoveAll(); - AppsDownloadList.Add(DLInfo); - LaunchDownloadDialog(bIsModal); + if (m_bModal) + DialogBoxParamW(hInst, MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG), hMainWnd, DlgProc, (LPARAM)this); + else if (!m_hDlg || !IsWindow(m_hDlg)) + CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG), hMainWnd, DlgProc, (LPARAM)this); } INT_PTR CALLBACK -CDownloadManager::DownloadDlgProc(HWND Dlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +CDownloadManager::DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - static WCHAR szCaption[MAX_PATH]; + CDownloadManager* pThis = (CDownloadManager*)GetWindowLongPtrW(hDlg, DWLP_USER); + if (!pThis) + { + if (uMsg != WM_INITDIALOG) + return FALSE; + SetWindowLongPtrW(hDlg, DWLP_USER, lParam); + pThis = (CDownloadManager*)lParam; + } + return pThis->RealDlgProc(hDlg, uMsg, wParam, lParam); +} +INT_PTR +CDownloadManager::RealDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ switch (uMsg) { case WM_INITDIALOG: { g_Busy++; - HICON hIconSm, hIconBg; - CStringW szTempCaption; - - bCancelled = FALSE; + AddRef(); + m_hDlg = hDlg; + if (!m_bModal) + g_hDownloadWnd = hDlg; + HICON hIconSm, hIconBg; if (hMainWnd) { hIconBg = (HICON)GetClassLongPtrW(hMainWnd, GCLP_HICON); @@ -496,630 +608,515 @@ CDownloadManager::DownloadDlgProc(HWND Dlg, UINT uMsg, WPARAM wParam, LPARAM lPa } if (!hMainWnd || (!hIconBg || !hIconSm)) { - /* Load the default icon */ hIconBg = hIconSm = LoadIconW(hInst, MAKEINTRESOURCEW(IDI_MAIN)); } + SendMessageW(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hIconBg); + SendMessageW(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm); - if (hIconBg && hIconSm) - { - SendMessageW(Dlg, WM_SETICON, ICON_BIG, (LPARAM)hIconBg); - SendMessageW(Dlg, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm); - } + GetWindowTextW(hDlg, m_szCaptionFmt, _countof(m_szCaptionFmt)); + CStringW buf; + buf = m_szCaptionFmt; + buf.Replace(L"%ls", L""); + SetWindowTextW(hDlg, buf); // "Downloading..." - HWND Item = GetDlgItem(Dlg, IDC_DOWNLOAD_PROGRESS); - if (Item) + HWND hItem = GetDlgItem(hDlg, IDC_DOWNLOAD_PROGRESS); + if (hItem) { // initialize the default values for our nifty progress bar // and subclass it so that it learns to print a status text - ProgressBar.SubclassWindow(Item); - ProgressBar.SendMessage(PBM_SETRANGE, 0, MAKELPARAM(0, 100)); - ProgressBar.SendMessage(PBM_SETPOS, 0, 0); - if (AppsDownloadList.GetSize() > 0) - ProgressBar.SetProgress(0, AppsDownloadList[0].SizeInBytes); - } - - // Add a ListView - HWND hListView = DownloadsListView.Create(Dlg); - if (!hListView) - { - return FALSE; + m_ProgressBar.SubclassWindow(hItem); + m_ProgressBar.SendMessageW(PBM_SETRANGE, 0, MAKELPARAM(0, 100)); + m_ProgressBar.SendMessageW(PBM_SETPOS, 0, 0); + if (m_List.GetSize() > 0) + m_ProgressBar.SetProgress(0, m_List[0].SizeInBytes); } - DownloadsListView.LoadList(AppsDownloadList); - // Get a dlg string for later use - GetWindowTextW(Dlg, szCaption, _countof(szCaption)); - - // Hide a placeholder from displaying - szTempCaption = szCaption; - szTempCaption.Replace(L"%ls", L""); - SetWindowText(Dlg, szTempCaption.GetString()); - - ShowWindow(Dlg, SW_SHOW); - - // Start download process - DownloadParam *param = new DownloadParam(Dlg, AppsDownloadList, szCaption); - unsigned int ThreadId; - HANDLE Thread = (HANDLE)_beginthreadex(NULL, 0, ThreadFunc, (void *)param, 0, &ThreadId); - if (!Thread) - { + if (!m_ListView.Create(hDlg)) return FALSE; - } + m_ListView.LoadList(m_List); - CloseHandle(Thread); - AppsDownloadList.RemoveAll(); + ShowWindow(hDlg, SW_SHOW); + StartWorkerThread(); return TRUE; } case WM_COMMAND: - if (wParam == IDCANCEL) + if (LOWORD(wParam) == IDCANCEL) { - bCancelled = TRUE; - PostMessageW(Dlg, WM_CLOSE, 0, 0); + m_bCancelled = TRUE; + PostMessageW(hDlg, WM_CLOSE, 0, 0); } return FALSE; case WM_CLOSE: - if (ProgressBar) - ProgressBar.UnsubclassWindow(TRUE); - if (CDownloadManager::bModal) - { - ::EndDialog(Dlg, 0); - } - else - { - ::DestroyWindow(Dlg); - } - return TRUE; + m_bCancelled = TRUE; + if (m_ProgressBar) + m_ProgressBar.UnsubclassWindow(TRUE); + return m_bModal ? ::EndDialog(hDlg, 0) : ::DestroyWindow(hDlg); case WM_DESTROY: + if (g_hDownloadWnd == hDlg) + g_hDownloadWnd = NULL; g_Busy--; if (hMainWnd) PostMessage(hMainWnd, WM_NOTIFY_OPERATIONCOMPLETED, 0, 0); - return FALSE; - - default: - return FALSE; - } -} - -BOOL UrlHasBeenCopied; + Release(); + break; -VOID -CDownloadManager::UpdateProgress( - HWND hDlg, - ULONG ulProgress, - ULONG ulProgressMax, - ULONG ulStatusCode, - LPCWSTR szStatusText) -{ - HWND Item; + case WM_ISCANCELLED: + return SetDlgMsgResult(hDlg, uMsg, m_bCancelled); - if (!IsWindow(hDlg)) - return; - ProgressBar.SetProgress(ulProgress, ulProgressMax); + case WM_SETSTATUS: + m_ListView.SetDownloadStatus(m_Index - 1, (DownloadStatus)wParam); + break; - if (!IsWindow(hDlg)) - return; - Item = GetDlgItem(hDlg, IDC_DOWNLOAD_STATUS); - if (Item && szStatusText && wcslen(szStatusText) > 0 && UrlHasBeenCopied == FALSE) - { - SIZE_T len = wcslen(szStatusText) + 1; - CStringW buf; - DWORD dummyLen; + case WM_GETINSTANCE: + return SetDlgMsgResult(hDlg, uMsg, (INT_PTR)this); - /* beautify our url for display purposes */ - if (!InternetCanonicalizeUrlW(szStatusText, buf.GetBuffer(len), &dummyLen, ICU_DECODE | ICU_NO_ENCODE)) - { - /* just use the original */ - buf.ReleaseBuffer(); - buf = szStatusText; - } - else + case WM_GETNEXT: { - buf.ReleaseBuffer(); + DownloadInfo *pItem = NULL; + if (!m_bCancelled && m_Index < (SIZE_T)m_List.GetSize()) + pItem = &m_List[m_Index++]; + return SetDlgMsgResult(hDlg, uMsg, (INT_PTR)pItem); } - - /* paste it into our dialog and don't do it again in this instance */ - ::SetWindowText(Item, buf.GetString()); - UrlHasBeenCopied = TRUE; } + return FALSE; } -BOOL -ShowLastError(HWND hWndOwner, BOOL bInetError, DWORD dwLastError) +void +CDownloadManager::UpdateProgress(ULONG ulProgress, ULONG ulProgressMax) { - CLocalPtr<WCHAR> lpMsg; + m_ProgressBar.SetProgress(ulProgress, ulProgressMax); +} - if (!FormatMessageW( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | - (bInetError ? FORMAT_MESSAGE_FROM_HMODULE : FORMAT_MESSAGE_FROM_SYSTEM), - (bInetError ? GetModuleHandleW(L"wininet.dll") : NULL), dwLastError, LANG_USER_DEFAULT, (LPWSTR)&lpMsg, 0, - NULL)) +unsigned int CALLBACK +CDownloadManager::ThreadFunc(void* ThreadParam) +{ + CDownloadManager *pThis = (CDownloadManager*)ThreadParam; + HWND hDlg = pThis->m_hDlg; + for (;;) { - DPRINT1("FormatMessageW unexpected failure (err %d)\n", GetLastError()); - return FALSE; + DownloadInfo *pItem = (DownloadInfo*)SendMessageW(hDlg, WM_GETNEXT, 0, 0); + if (!pItem) + break; + pThis->PerformDownloadAndInstall(*pItem); } - - MessageBoxW(hWndOwner, lpMsg, NULL, MB_OK | MB_ICONERROR); - return TRUE; + SendMessageW(hDlg, WM_CLOSE, 0, 0); + return pThis->Release(); } -unsigned int WINAPI -CDownloadManager::ThreadFunc(LPVOID param) +void +CDownloadManager::PerformDownloadAndInstall(const DownloadInfo &Info) { + const HWND hDlg = m_hDlg; + const HWND hStatus = GetDlgItem(m_hDlg, IDC_DOWNLOAD_STATUS); + SetFriendlyUrl(hStatus, Info.szUrl); + + m_ProgressBar.SetMarquee(FALSE); + m_ProgressBar.SendMessageW(PBM_SETPOS, 0, 0); + m_ProgressBar.SetProgress(0, Info.SizeInBytes); + + CStringW str; CPathW Path; PCWSTR p, q; - HWND hDlg = static_cast<DownloadParam *>(param)->Dialog; - HWND Item; - INT iAppId; - - ULONG dwContentLen, dwBytesWritten, dwBytesRead, dwStatus; + ULONG dwContentLen, dwBytesWritten, dwBytesRead, dwStatus, dwStatusLen; ULONG dwCurrentBytesRead = 0; - ULONG dwStatusLen = sizeof(dwStatus); - - BOOL bTempfile = FALSE; + BOOL bTempfile = FALSE, bCancelled = FALSE; HINTERNET hOpen = NULL; HINTERNET hFile = NULL; HANDLE hOut = INVALID_HANDLE_VALUE; - unsigned char lpBuffer[4096]; + LPCWSTR lpszAgent = L"RApps/1.1"; - URL_COMPONENTSW urlComponents; - size_t urlLength, filenameLength; - - const ATL::CSimpleArray<DownloadInfo> &InfoArray = static_cast<DownloadParam *>(param)->AppInfo; - LPCWSTR szCaption = static_cast<DownloadParam *>(param)->szCaption; - CStringW szNewCaption; - const DWORD dwUrlConnectFlags = INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_KEEP_CONNECTION; + URL_COMPONENTSW urlComponents; + size_t urlLength, filenameLength; + unsigned char lpBuffer[4096]; - if (InfoArray.GetSize() <= 0) + // Change caption to show the currently downloaded app + switch (Info.DLType) { - MessageBox_LoadString(hMainWnd, IDS_UNABLE_TO_DOWNLOAD); - goto end; + case DLTYPE_APPLICATION: + str.Format(m_szCaptionFmt, Info.szName.GetString()); + break; + case DLTYPE_DBUPDATE: + str.LoadStringW(IDS_DL_DIALOG_DB_DOWNLOAD_DISP); + break; + case DLTYPE_DBUPDATE_UNOFFICIAL: + str.LoadStringW(IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP); + break; } + SetWindowTextW(hDlg, str); - for (iAppId = 0; iAppId < InfoArray.GetSize(); ++iAppId) + // is this URL an update package for RAPPS? if so store it in a different place + if (Info.DLType != DLTYPE_APPLICATION) { - // Reset progress bar - if (!IsWindow(hDlg)) - break; - Item = GetDlgItem(hDlg, IDC_DOWNLOAD_PROGRESS); - if (Item) + if (!GetStorageDirectory(Path)) { - ProgressBar.SetMarquee(FALSE); - ProgressBar.SendMessage(PBM_SETPOS, 0, 0); - ProgressBar.SetProgress(0, InfoArray[iAppId].SizeInBytes); + ShowLastError(hMainWnd, FALSE, GetLastError()); + goto end; } + } + else + { + Path = SettingsInfo.szDownloadDir; + } - // is this URL an update package for RAPPS? if so store it in a different place - if (InfoArray[iAppId].DLType != DLTYPE_APPLICATION) - { - if (!GetStorageDirectory(Path)) - { - ShowLastError(hMainWnd, FALSE, GetLastError()); - goto end; - } - } - else - { - Path = SettingsInfo.szDownloadDir; - } + // build the path for the download + p = wcsrchr(Info.szUrl.GetString(), L'/'); + q = wcsrchr(Info.szUrl.GetString(), L'?'); - // Change caption to show the currently downloaded app - switch (InfoArray[iAppId].DLType) - { - case DLTYPE_APPLICATION: - szNewCaption.Format(szCaption, InfoArray[iAppId].szName.GetString()); - break; - case DLTYPE_DBUPDATE: - szNewCaption.LoadStringW(IDS_DL_DIALOG_DB_DOWNLOAD_DISP); - break; - case DLTYPE_DBUPDATE_UNOFFICIAL: - szNewCaption.LoadStringW(IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP); - break; - } + // do we have a final slash separator? + if (!p) + { + MessageBox_LoadString(hMainWnd, IDS_UNABLE_PATH); + goto end; + } - if (!IsWindow(hDlg)) - goto end; - SetWindowTextW(hDlg, szNewCaption.GetString()); + // prepare the tentative length of the filename, maybe we've to remove part of it later on + filenameLength = wcslen(p) * sizeof(WCHAR); - // build the path for the download - p = wcsrchr(InfoArray[iAppId].szUrl.GetString(), L'/'); - q = wcsrchr(InfoArray[iAppId].szUrl.GetString(), L'?'); + /* do we have query arguments in the target URL after the filename? account for them + (e.g.
https://example.org/myfile.exe?no_adware_plz
) */ + if (q && q > p && (q - p) > 0) + filenameLength -= wcslen(q - 1) * sizeof(WCHAR); - // do we have a final slash separator? - if (!p) + // is the path valid? can we access it? + if (GetFileAttributesW(Path) == INVALID_FILE_ATTRIBUTES) + { + if (!CreateDirectoryW(Path, NULL)) { - MessageBox_LoadString(hMainWnd, IDS_UNABLE_PATH); + ShowLastError(hMainWnd, FALSE, GetLastError()); goto end; } + } - // prepare the tentative length of the filename, maybe we've to remove part of it later on - filenameLength = wcslen(p) * sizeof(WCHAR); - - /* do we have query arguments in the target URL after the filename? account for them - (e.g.
https://example.org/myfile.exe?no_adware_plz
) */ - if (q && q > p && (q - p) > 0) - filenameLength -= wcslen(q - 1) * sizeof(WCHAR); - - // is the path valid? can we access it? - if (GetFileAttributesW(Path) == INVALID_FILE_ATTRIBUTES) + switch (Info.DLType) + { + case DLTYPE_DBUPDATE: + case DLTYPE_DBUPDATE_UNOFFICIAL: + Path += APPLICATION_DATABASE_NAME; + break; + case DLTYPE_APPLICATION: { - if (!CreateDirectoryW(Path, NULL)) - { - ShowLastError(hMainWnd, FALSE, GetLastError()); - goto end; - } + CStringW str = p + 1; // use the filename retrieved from URL + UrlUnescapeAndMakeFileNameValid(str); + Path += str; + break; } + } - switch (InfoArray[iAppId].DLType) - { - case DLTYPE_DBUPDATE: - case DLTYPE_DBUPDATE_UNOFFICIAL: - Path += APPLICATION_DATABASE_NAME; - break; - case DLTYPE_APPLICATION: - { - CStringW str = p + 1; // use the filename retrieved from URL - UrlUnescapeAndMakeFileNameValid(str); - Path += str; - break; - } - } + if ((Info.DLType == DLTYPE_APPLICATION) && Info.szSHA1[0] && + GetFileAttributesW(Path) != INVALID_FILE_ATTRIBUTES) + { + // only open it in case of total correctness + if (VerifyInteg(Info.szSHA1.GetString(), Path)) + goto run; + } - if ((InfoArray[iAppId].DLType == DLTYPE_APPLICATION) && InfoArray[iAppId].szSHA1[0] && - GetFileAttributesW(Path) != INVALID_FILE_ATTRIBUTES) - { - // only open it in case of total correctness - if (VerifyInteg(InfoArray[iAppId].szSHA1.GetString(), Path)) - goto run; - } + // Download it + SendMessageW(hDlg, WM_SETSTATUS, DLSTATUS_DOWNLOADING, 0); + /* FIXME: this should just be using the system-wide proxy settings */ + switch (SettingsInfo.Proxy) + { + case 0: // preconfig + default: + hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); + break; + case 1: // direct (no proxy) + hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); + break; + case 2: // use proxy + hOpen = InternetOpenW( + lpszAgent, INTERNET_OPEN_TYPE_PROXY, SettingsInfo.szProxyServer, SettingsInfo.szNoProxyFor, 0); + break; + } - // Add the download URL - if (!IsWindow(hDlg)) - goto end; - SetDlgItemTextW(hDlg, IDC_DOWNLOAD_STATUS, InfoArray[iAppId].szUrl.GetString()); + if (!hOpen) + { + ShowLastError(hMainWnd, TRUE, GetLastError()); + goto end; + } - DownloadsListView.SetDownloadStatus(iAppId, DLSTATUS_DOWNLOADING); + bTempfile = TRUE; + dwContentLen = 0; + dwStatusLen = sizeof(dwStatus); + ZeroMemory(&urlComponents, sizeof(urlComponents)); + urlComponents.dwStructSize = sizeof(urlComponents); - // download it - UrlHasBeenCopied = FALSE; - bTempfile = TRUE; + urlLength = Info.szUrl.GetLength(); + urlComponents.dwSchemeLength = urlLength + 1; + urlComponents.lpszScheme = (LPWSTR)malloc(urlComponents.dwSchemeLength * sizeof(WCHAR)); - /* FIXME: this should just be using the system-wide proxy settings */ - switch (SettingsInfo.Proxy) + if (!InternetCrackUrlW(Info.szUrl, urlLength + 1, ICU_DECODE | ICU_ESCAPE, &urlComponents)) + { + ShowLastError(hMainWnd, TRUE, GetLastError()); + goto end; + } + + if (urlComponents.nScheme == INTERNET_SCHEME_HTTP || urlComponents.nScheme == INTERNET_SCHEME_HTTPS) + { + hFile = InternetOpenUrlW(hOpen, Info.szUrl, NULL, 0, dwUrlConnectFlags, 0); + if (!hFile) { - case 0: // preconfig - default: - hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); - break; - case 1: // direct (no proxy) - hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); - break; - case 2: // use proxy - hOpen = InternetOpenW( - lpszAgent, INTERNET_OPEN_TYPE_PROXY, SettingsInfo.szProxyServer, SettingsInfo.szNoProxyFor, 0); - break; + if (!ShowLastError(hMainWnd, TRUE, GetLastError())) + { + /* Workaround for CORE-17377 */ + MessageBox_LoadString(hMainWnd, IDS_UNABLE_TO_DOWNLOAD2); + } + goto end; } - if (!hOpen) + // query connection + if (!HttpQueryInfoW(hFile, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwStatus, &dwStatusLen, NULL)) { ShowLastError(hMainWnd, TRUE, GetLastError()); goto end; } - dwStatusLen = sizeof(dwStatus); - - memset(&urlComponents, 0, sizeof(urlComponents)); - urlComponents.dwStructSize = sizeof(urlComponents); - - urlLength = InfoArray[iAppId].szUrl.GetLength(); - urlComponents.dwSchemeLength = urlLength + 1; - urlComponents.lpszScheme = (LPWSTR)malloc(urlComponents.dwSchemeLength * sizeof(WCHAR)); - - if (!InternetCrackUrlW(InfoArray[iAppId].szUrl, urlLength + 1, ICU_DECODE | ICU_ESCAPE, &urlComponents)) + if (dwStatus != HTTP_STATUS_OK) { - ShowLastError(hMainWnd, TRUE, GetLastError()); + MessageBox_LoadString(hMainWnd, IDS_UNABLE_TO_DOWNLOAD); goto end; } - dwContentLen = 0; - - if (urlComponents.nScheme == INTERNET_SCHEME_HTTP || urlComponents.nScheme == INTERNET_SCHEME_HTTPS) + // query content length + HttpQueryInfoW(hFile, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &dwContentLen, &dwStatusLen, NULL); + } + else if (urlComponents.nScheme == INTERNET_SCHEME_FTP) + { + // force passive mode on FTP + hFile = + InternetOpenUrlW(hOpen, Info.szUrl, NULL, 0, dwUrlConnectFlags | INTERNET_FLAG_PASSIVE, 0); + if (!hFile) { - hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl.GetString(), NULL, 0, dwUrlConnectFlags, 0); - if (!hFile) - { - if (!ShowLastError(hMainWnd, TRUE, GetLastError())) - { - /* Workaround for CORE-17377 */ - MessageBox_LoadString(hMainWnd, IDS_UNABLE_TO_DOWNLOAD2); - } - goto end; - } - - // query connection - if (!HttpQueryInfoW(hFile, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwStatus, &dwStatusLen, NULL)) + if (!ShowLastError(hMainWnd, TRUE, GetLastError())) { - ShowLastError(hMainWnd, TRUE, GetLastError()); - goto end; - } - - if (dwStatus != HTTP_STATUS_OK) - { - MessageBox_LoadString(hMainWnd, IDS_UNABLE_TO_DOWNLOAD); - goto end; + /* Workaround for CORE-17377 */ + MessageBox_LoadString(hMainWnd, IDS_UNABLE_TO_DOWNLOAD2); } - - // query content length - HttpQueryInfoW( - hFile, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &dwContentLen, &dwStatusLen, NULL); + goto end; } - else if (urlComponents.nScheme == INTERNET_SCHEME_FTP) - { - // force passive mode on FTP - hFile = - InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl, NULL, 0, dwUrlConnectFlags | INTERNET_FLAG_PASSIVE, 0); - if (!hFile) - { - if (!ShowLastError(hMainWnd, TRUE, GetLastError())) - { - /* Workaround for CORE-17377 */ - MessageBox_LoadString(hMainWnd, IDS_UNABLE_TO_DOWNLOAD2); - } - goto end; - } - dwContentLen = FtpGetFileSize(hFile, &dwStatus); - } - else if (urlComponents.nScheme == INTERNET_SCHEME_FILE) + dwContentLen = FtpGetFileSize(hFile, &dwStatus); + } + else if (urlComponents.nScheme == INTERNET_SCHEME_FILE) + { + // Add support for the file scheme so testing locally is simpler + WCHAR LocalFilePath[MAX_PATH]; + DWORD cchPath = _countof(LocalFilePath); + // Ideally we would use PathCreateFromUrlAlloc here, but that is not exported (yet) + HRESULT hr = PathCreateFromUrlW(Info.szUrl, LocalFilePath, &cchPath, 0); + if (SUCCEEDED(hr)) { - // Add support for the file scheme so testing locally is simpler - WCHAR LocalFilePath[MAX_PATH]; - DWORD cchPath = _countof(LocalFilePath); - // Ideally we would use PathCreateFromUrlAlloc here, but that is not exported (yet) - HRESULT hr = PathCreateFromUrlW(InfoArray[iAppId].szUrl, LocalFilePath, &cchPath, 0); - if (SUCCEEDED(hr)) + if (CopyFileW(LocalFilePath, Path, FALSE)) { - if (CopyFileW(LocalFilePath, Path, FALSE)) - { - goto run; - } - else - { - ShowLastError(hMainWnd, FALSE, GetLastError()); - goto end; - } + goto run; } else { - ShowLastError(hMainWnd, FALSE, hr); + ShowLastError(hMainWnd, FALSE, GetLastError()); goto end; } } + else + { + ShowLastError(hMainWnd, FALSE, hr); + goto end; + } + } - if (!dwContentLen) + if (!dwContentLen) + { + // Someone was nice enough to add this, let's use it + if (Info.SizeInBytes) { - // Someone was nice enough to add this, let's use it - if (InfoArray[iAppId].SizeInBytes) - { - dwContentLen = InfoArray[iAppId].SizeInBytes; - } - else - { - // content-length is not known, enable marquee mode - ProgressBar.SetMarquee(TRUE); - } + dwContentLen = Info.SizeInBytes; } + else + { + // content-length is not known, enable marquee mode + m_ProgressBar.SetMarquee(TRUE); + } + } - free(urlComponents.lpszScheme); + free(urlComponents.lpszScheme); #ifdef USE_CERT_PINNING - // are we using HTTPS to download the RAPPS update package? check if the certificate is original - if ((urlComponents.nScheme == INTERNET_SCHEME_HTTPS) && (InfoArray[iAppId].DLType == DLTYPE_DBUPDATE)) + // are we using HTTPS to download the RAPPS update package? check if the certificate is original + if ((urlComponents.nScheme == INTERNET_SCHEME_HTTPS) && (Info.DLType == DLTYPE_DBUPDATE)) + { + CLocalPtr<char> subjectName, issuerName; + CStringA szMsgText; + bool bAskQuestion = false; + if (!CertGetSubjectAndIssuer(hFile, subjectName, issuerName)) { - CLocalPtr<char> subjectName, issuerName; - CStringA szMsgText; - bool bAskQuestion = false; - if (!CertGetSubjectAndIssuer(hFile, subjectName, issuerName)) - { - szMsgText.LoadStringW(IDS_UNABLE_TO_QUERY_CERT); - bAskQuestion = true; - } - else if (!IsTrustedPinnedCert(subjectName, issuerName)) - { - szMsgText.Format(IDS_MISMATCH_CERT_INFO, (LPCSTR)subjectName, (LPCSTR)issuerName); - bAskQuestion = true; - } + szMsgText.LoadStringW(IDS_UNABLE_TO_QUERY_CERT); + bAskQuestion = true; + } + else if (!IsTrustedPinnedCert(subjectName, issuerName)) + { + szMsgText.Format(IDS_MISMATCH_CERT_INFO, (LPCSTR)subjectName, (LPCSTR)issuerName); + bAskQuestion = true; + } - if (bAskQuestion) + if (bAskQuestion) + { + if (MessageBoxA(hDlg, szMsgText, NULL, MB_YESNO | MB_ICONERROR) != IDYES) { - if (MessageBoxA(hMainWnd, szMsgText.GetString(), NULL, MB_YESNO | MB_ICONERROR) != IDYES) - { - goto end; - } + goto end; } } + } #endif - hOut = CreateFileW(Path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL); + hOut = CreateFileW(Path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL); + if (hOut == INVALID_HANDLE_VALUE) + { + ShowLastError(hDlg, FALSE, GetLastError()); + goto end; + } - if (hOut == INVALID_HANDLE_VALUE) + dwCurrentBytesRead = 0; + do + { + bCancelled = IsCancelled(); + if (bCancelled) + break; + + if (!InternetReadFile(hFile, lpBuffer, _countof(lpBuffer), &dwBytesRead)) { - ShowLastError(hMainWnd, FALSE, GetLastError()); + ShowLastError(hDlg, TRUE, GetLastError()); goto end; } - dwCurrentBytesRead = 0; - do + if (!WriteFile(hOut, &lpBuffer[0], dwBytesRead, &dwBytesWritten, NULL)) { - if (!InternetReadFile(hFile, lpBuffer, _countof(lpBuffer), &dwBytesRead)) - { - ShowLastError(hMainWnd, TRUE, GetLastError()); - goto end; - } + ShowLastError(hDlg, FALSE, GetLastError()); + goto end; + } - if (!WriteFile(hOut, &lpBuffer[0], dwBytesRead, &dwBytesWritten, NULL)) - { - ShowLastError(hMainWnd, FALSE, GetLastError()); - goto end; - } + dwCurrentBytesRead += dwBytesRead; + UpdateProgress(dwCurrentBytesRead, dwContentLen); + + } while (dwBytesRead); - dwCurrentBytesRead += dwBytesRead; - if (!IsWindow(hDlg)) - goto end; - UpdateProgress(hDlg, dwCurrentBytesRead, dwContentLen, 0, InfoArray[iAppId].szUrl.GetString()); - } while (dwBytesRead && !bCancelled); + CloseHandle(hOut); + hOut = INVALID_HANDLE_VALUE; - CloseHandle(hOut); - hOut = INVALID_HANDLE_VALUE; + if (bCancelled) + { + DPRINT1("Operation cancelled\n"); + goto end; + } - if (bCancelled) + if (!dwContentLen) + { + // set progress bar to 100% + m_ProgressBar.SetMarquee(FALSE); + + dwContentLen = dwCurrentBytesRead; + UpdateProgress(dwCurrentBytesRead, dwContentLen); + } + + /* if this thing isn't a RAPPS update and it has a SHA-1 checksum + verify its integrity by using the native advapi32.A_SHA1 functions */ + if ((Info.DLType == DLTYPE_APPLICATION) && Info.szSHA1[0] != 0) + { + CStringW szMsgText; + + // change a few strings in the download dialog to reflect the verification process + if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_TITLE)) { - DPRINT1("Operation cancelled\n"); + DPRINT1("Unable to load string\n"); goto end; } - if (!dwContentLen) - { - // set progress bar to 100% - ProgressBar.SetMarquee(FALSE); - - dwContentLen = dwCurrentBytesRead; - if (!IsWindow(hDlg)) - goto end; - UpdateProgress(hDlg, dwCurrentBytesRead, dwContentLen, 0, InfoArray[iAppId].szUrl.GetString()); - } + SetWindowTextW(hDlg, szMsgText); + SetWindowTextW(hStatus, Path); - /* if this thing isn't a RAPPS update and it has a SHA-1 checksum - verify its integrity by using the native advapi32.A_SHA1 functions */ - if ((InfoArray[iAppId].DLType == DLTYPE_APPLICATION) && InfoArray[iAppId].szSHA1[0] != 0) + // this may take a while, depending on the file size + if (!VerifyInteg(Info.szSHA1, Path)) { - CStringW szMsgText; - - // change a few strings in the download dialog to reflect the verification process - if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_TITLE)) + if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_FAIL)) { DPRINT1("Unable to load string\n"); goto end; } - if (!IsWindow(hDlg)) - goto end; - SetWindowTextW(hDlg, szMsgText.GetString()); - ::SetDlgItemTextW(hDlg, IDC_DOWNLOAD_STATUS, Path); - - // this may take a while, depending on the file size - if (!VerifyInteg(InfoArray[iAppId].szSHA1.GetString(), Path)) - { - if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_FAIL)) - { - DPRINT1("Unable to load string\n"); - goto end; - } - - if (!IsWindow(hDlg)) - goto end; - MessageBoxW(hDlg, szMsgText.GetString(), NULL, MB_OK | MB_ICONERROR); - goto end; - } + MessageBoxW(hDlg, szMsgText, NULL, MB_OK | MB_ICONERROR); + goto end; } + } - run: - DownloadsListView.SetDownloadStatus(iAppId, DLSTATUS_WAITING_INSTALL); +run: + SendMessageW(hDlg, WM_SETSTATUS, DLSTATUS_WAITING_INSTALL, 0); - // run it - if (InfoArray[iAppId].DLType == DLTYPE_APPLICATION) + // run it + if (Info.DLType == DLTYPE_APPLICATION) + { + CStringW app, params; + SHELLEXECUTEINFOW shExInfo = {0}; + shExInfo.cbSize = sizeof(shExInfo); + shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS; + shExInfo.lpVerb = L"open"; + shExInfo.lpFile = Path; + shExInfo.lpParameters = L""; + shExInfo.nShow = SW_SHOW; + + if (Info.IType == INSTALLER_GENERATE) { - CStringW app, params; - SHELLEXECUTEINFOW shExInfo = {0}; - shExInfo.cbSize = sizeof(shExInfo); - shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS; - shExInfo.lpVerb = L"open"; - shExInfo.lpFile = Path; - shExInfo.lpParameters = L""; - shExInfo.nShow = SW_SHOW; - - if (InfoArray[iAppId].IType == INSTALLER_GENERATE) - { - params = L"/" + CStringW(CMD_KEY_GENINST) + L" \"" + - InfoArray[iAppId].szPackageName + L"\" \"" + - CStringW(shExInfo.lpFile) + L"\""; - shExInfo.lpParameters = params; - shExInfo.lpFile = app.GetBuffer(MAX_PATH); - GetModuleFileNameW(NULL, const_cast<LPWSTR>(shExInfo.lpFile), MAX_PATH); - app.ReleaseBuffer(); - } - - /* FIXME: Do we want to log installer status? */ - WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_INSTALL, InfoArray[iAppId].szName); - - if (ShellExecuteExW(&shExInfo)) - { - // reflect installation progress in the titlebar - // TODO: make a separate string with a placeholder to include app name? - CStringW szMsgText = LoadStatusString(DLSTATUS_INSTALLING); - if (!IsWindow(hDlg)) - goto end; - SetWindowTextW(hDlg, szMsgText.GetString()); - - DownloadsListView.SetDownloadStatus(iAppId, DLSTATUS_INSTALLING); - - // TODO: issue an install operation separately so that the apps could be downloaded in the background - WaitForSingleObject(shExInfo.hProcess, INFINITE); - CloseHandle(shExInfo.hProcess); - } - else - { - ShowLastError(hMainWnd, FALSE, GetLastError()); - } + params = L"/" + CStringW(CMD_KEY_GENINST) + L" \"" + + Info.szPackageName + L"\" \"" + + CStringW(shExInfo.lpFile) + L"\""; + shExInfo.lpParameters = params; + shExInfo.lpFile = app.GetBuffer(MAX_PATH); + GetModuleFileNameW(NULL, const_cast<LPWSTR>(shExInfo.lpFile), MAX_PATH); + app.ReleaseBuffer(); } - end: - if (hOut != INVALID_HANDLE_VALUE) - CloseHandle(hOut); + /* FIXME: Do we want to log installer status? */ + WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_INSTALL, Info.szName); - if (hFile) - InternetCloseHandle(hFile); - InternetCloseHandle(hOpen); + if (ShellExecuteExW(&shExInfo)) + { + // reflect installation progress in the titlebar + // TODO: make a separate string with a placeholder to include app name? + CStringW szMsgText = LoadStatusString(DLSTATUS_INSTALLING); + SetWindowTextW(hDlg, szMsgText); + + SendMessageW(hDlg, WM_SETSTATUS, DLSTATUS_INSTALLING, 0); - if (bTempfile) + // TODO: issue an install operation separately so that the apps could be downloaded in the background + WaitForSingleObject(shExInfo.hProcess, INFINITE); + CloseHandle(shExInfo.hProcess); + } + else { - if (bCancelled || (SettingsInfo.bDelInstaller && (InfoArray[iAppId].DLType == DLTYPE_APPLICATION))) - DeleteFileW(Path); + ShowLastError(hMainWnd, FALSE, GetLastError()); } - - if (!IsWindow(hDlg)) - return 0; - DownloadsListView.SetDownloadStatus(iAppId, DLSTATUS_FINISHED); } - delete static_cast<DownloadParam *>(param); - if (!IsWindow(hDlg)) - return 0; - SendMessageW(hDlg, WM_CLOSE, 0, 0); - return 0; -} +end: + if (hOut != INVALID_HANDLE_VALUE) + CloseHandle(hOut); -// TODO: Reuse the dialog -VOID -CDownloadManager::LaunchDownloadDialog(BOOL bIsModal) -{ - CDownloadManager::bModal = bIsModal; - if (bIsModal) - { - DialogBoxW(hInst, MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG), hMainWnd, DownloadDlgProc); - } - else + if (hFile) + InternetCloseHandle(hFile); + InternetCloseHandle(hOpen); + + if (bTempfile) { - CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG), hMainWnd, DownloadDlgProc); + if (bCancelled || (SettingsInfo.bDelInstaller && Info.DLType == DLTYPE_APPLICATION)) + DeleteFileW(Path); } + + SendMessageW(hDlg, WM_SETSTATUS, DLSTATUS_FINISHED, 0); } -// CDownloadManager BOOL DownloadListOfApplications(const CAtlList<CAppInfo *> &AppsList, BOOL bIsModal) @@ -1127,35 +1124,44 @@ DownloadListOfApplications(const CAtlList<CAppInfo *> &AppsList, BOOL bIsModal) if (AppsList.IsEmpty()) return FALSE; - POSITION CurrentListPosition = AppsList.GetHeadPosition(); - while (CurrentListPosition) + CComPtr<CDownloadManager> pDM; + if (!CDownloadManager::CreateInstance(bIsModal, pDM)) + return FALSE; + + for (POSITION it = AppsList.GetHeadPosition(); it;) { - const CAppInfo *Info = AppsList.GetNext(CurrentListPosition); - CDownloadManager::Add(DownloadInfo(*Info)); + const CAppInfo *Info = AppsList.GetNext(it); + pDM->Add(DownloadInfo(*Info)); } - - // Create a dialog and issue a download process - CDownloadManager::LaunchDownloadDialog(bIsModal); - + pDM->Show(); return TRUE; } BOOL DownloadApplication(CAppInfo *pAppInfo) { + const bool bModal = false; if (!pAppInfo) return FALSE; - CDownloadManager::Download(*pAppInfo, FALSE); - return TRUE; + CAtlList<CAppInfo*> list; + list.AddTail(pAppInfo); + return DownloadListOfApplications(list, bModal); } VOID DownloadApplicationsDB(LPCWSTR lpUrl, BOOL IsOfficial) { - static DownloadInfo DatabaseDLInfo; + const bool bModal = true; + CComPtr<CDownloadManager> pDM; + if (!CDownloadManager::CreateInstance(bModal, pDM)) + return; + + DownloadInfo DatabaseDLInfo; DatabaseDLInfo.szUrl = lpUrl; DatabaseDLInfo.szName.LoadStringW(IDS_DL_DIALOG_DB_DISP); DatabaseDLInfo.DLType = IsOfficial ? DLTYPE_DBUPDATE : DLTYPE_DBUPDATE_UNOFFICIAL; - CDownloadManager::Download(DatabaseDLInfo, TRUE); + + pDM->Add(DatabaseDLInfo); + pDM->Show(); }
1 week, 4 days
1
0
0
0
[reactos] 02/02: [NTDLL] Demote UNIMPLEMENTED to DPRINT in LdrpValidateImageForMp
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cc762c2b7132991f828ac…
commit cc762c2b7132991f828ac4d6b7315bcd3e962ccd Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Mon Sep 23 15:06:35 2024 +0300 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Sat Jan 25 16:33:27 2025 +0200 [NTDLL] Demote UNIMPLEMENTED to DPRINT in LdrpValidateImageForMp This avoids debug spam on SMP builds. --- dll/ntdll/ldr/ldrinit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dll/ntdll/ldr/ldrinit.c b/dll/ntdll/ldr/ldrinit.c index 991f498dba2..5ee01e3e68d 100644 --- a/dll/ntdll/ldr/ldrinit.c +++ b/dll/ntdll/ldr/ldrinit.c @@ -1538,7 +1538,9 @@ VOID NTAPI LdrpValidateImageForMp(IN PLDR_DATA_TABLE_ENTRY LdrDataTableEntry) { - UNIMPLEMENTED; + DPRINT("LdrpValidateImageForMp is unimplemented\n"); + // TODO: + // Scan the LockPrefixTable in the load config directory } BOOLEAN
1 week, 4 days
1
0
0
0
[reactos] 01/02: [NTOS:MM] Fix process affinity in MmCreatePeb
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=647b518bd3e7f34025830…
commit 647b518bd3e7f340258309f04248768f1decbc78 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Mon Jan 20 18:25:05 2025 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Sat Jan 25 16:33:27 2025 +0200 [NTOS:MM] Fix process affinity in MmCreatePeb --- ntoskrnl/mm/ARM3/procsup.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/ntoskrnl/mm/ARM3/procsup.c b/ntoskrnl/mm/ARM3/procsup.c index da94b64b7ec..77ca7befd70 100644 --- a/ntoskrnl/mm/ARM3/procsup.c +++ b/ntoskrnl/mm/ARM3/procsup.c @@ -20,6 +20,7 @@ ULONG MmProcessColorSeed = 0x12345678; ULONG MmMaximumDeadKernelStacks = 5; SLIST_HEADER MmDeadStackSListHead; +ULONG MmRotatingUniprocessorNumber = 0; /* PRIVATE FUNCTIONS **********************************************************/ @@ -526,7 +527,6 @@ MmCreatePeb(IN PEPROCESS Process, PIMAGE_LOAD_CONFIG_DIRECTORY ImageConfigData; NTSTATUS Status; USHORT Characteristics; - KAFFINITY ProcessAffinityMask = 0; SectionOffset.QuadPart = (ULONGLONG)0; *BasePeb = NULL; @@ -606,6 +606,7 @@ MmCreatePeb(IN PEPROCESS Process, // Heap and Debug Data // Peb->NumberOfProcessors = KeNumberProcessors; + Peb->ImageProcessAffinityMask = KeActiveProcessors; Peb->BeingDebugged = (BOOLEAN)(Process->DebugPort != NULL); Peb->NtGlobalFlag = NtGlobalFlag; Peb->HeapSegmentReserve = MmHeapSegmentReserve; @@ -712,7 +713,7 @@ MmCreatePeb(IN PEPROCESS Process, if ((ImageConfigData) && (ImageConfigData->ProcessAffinityMask)) { /* Take the value from the image configuration directory */ - ProcessAffinityMask = ImageConfigData->ProcessAffinityMask; + Peb->ImageProcessAffinityMask = ImageConfigData->ProcessAffinityMask; } // @@ -720,17 +721,12 @@ MmCreatePeb(IN PEPROCESS Process, if (Characteristics & IMAGE_FILE_UP_SYSTEM_ONLY) { // - // Force it to use CPU 0 + // Set single processor rotating affinity. + // See
https://www.microsoftpressstore.com/articles/article.aspx?p=2233328&seqNum=3
// - /* FIXME: this should use the MmRotatingUniprocessorNumber */ - Peb->ImageProcessAffinityMask = 0; - } - else - { - // - // Whatever was configured - // - Peb->ImageProcessAffinityMask = ProcessAffinityMask; + Peb->ImageProcessAffinityMask = AFFINITY_MASK(MmRotatingUniprocessorNumber); + ASSERT(Peb->ImageProcessAffinityMask & KeActiveProcessors); + MmRotatingUniprocessorNumber = (MmRotatingUniprocessorNumber + 1) % KeNumberProcessors; } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
1 week, 4 days
1
0
0
0
← Newer
1
...
6
7
8
9
10
11
12
...
28
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
Results per page:
10
25
50
100
200