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
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
August 2017
----- 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
22 participants
262 discussions
Start a n
N
ew thread
[ssawant] 75546: [STOBJECT] -Added Balloon notification for safely removal icon. -Added familiar warning dialog when device ejection fails. -Figured out that 'Problem number' of a device is perhaps...
by ssawant@svn.reactos.org
Author: ssawant Date: Mon Aug 14 18:29:44 2017 New Revision: 75546 URL:
http://svn.reactos.org/svn/reactos?rev=75546&view=rev
Log: [STOBJECT] -Added Balloon notification for safely removal icon. -Added familiar warning dialog when device ejection fails. -Figured out that 'Problem number' of a device is perhaps an important enumeration filter. -Minor code cleanup and whitespace fixes. -Test in win xpvm looks fine, but needs further testing. Modified: branches/GSoC_2017/shellext/reactos/dll/shellext/stobject/hotplug.cpp Modified: branches/GSoC_2017/shellext/reactos/dll/shellext/stobject/hotplug.cpp URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/shellext/reactos/dll/…
============================================================================== --- branches/GSoC_2017/shellext/reactos/dll/shellext/stobject/hotplug.cpp [iso-8859-1] (original) +++ branches/GSoC_2017/shellext/reactos/dll/shellext/stobject/hotplug.cpp [iso-8859-1] Mon Aug 14 18:29:44 2017 @@ -24,8 +24,9 @@ static HDEVNOTIFY g_hDevNotify = NULL; static HICON g_hIconHotplug = NULL; static LPWSTR g_strTooltip = L"Safely Remove Hardware and Eject Media"; +static WCHAR g_strMenuSel[DISPLAY_NAME_LEN]; static BOOL g_IsRunning = FALSE; -static BOOL g_IsRemoved = FALSE; +static BOOL g_IsRemoving = FALSE; // Enumerate the connected removable devices // TODO: Require proper enumeration and filters. @@ -40,12 +41,12 @@ for (int idev = 0; SetupDiEnumDeviceInfo(hdev, idev, &did); idev++) { - DWORD dwCapabilities = 0, dwSize = sizeof(dwCapabilities); + DWORD dwCapabilities = 0, dwSize = sizeof(dwCapabilities); WCHAR dispName[DISPLAY_NAME_LEN]; ULONG ulStatus = 0, ulPnum = 0, ulLength = DISPLAY_NAME_LEN * sizeof(WCHAR); CONFIGRET cr = CM_Get_DevNode_Status(&ulStatus, &ulPnum, did.DevInst, 0); if (cr != CR_SUCCESS) - continue; + continue; cr = CM_Get_DevNode_Registry_Property(did.DevInst, CM_DRP_DEVICEDESC, NULL, dispName, &ulLength, 0); if (cr != CR_SUCCESS) continue; @@ -53,9 +54,9 @@ if (cr != CR_SUCCESS) continue; - if ((dwCapabilities & CM_DEVCAP_REMOVABLE) && (dwCapabilities & CM_DEVCAP_UNIQUEID)) - { - devList.Add(did.DevInst); + if ((dwCapabilities & CM_DEVCAP_REMOVABLE) && (dwCapabilities & CM_DEVCAP_UNIQUEID) && !ulPnum) + { + devList.Add(did.DevInst); } } SetupDiDestroyDeviceInfoList(hdev); @@ -66,6 +67,31 @@ } return S_OK; +} + +// Pops a balloon notification +HRESULT NotifyBalloon(CSysTray* pSysTray, LPCWSTR szTitle = NULL, LPCWSTR szInfo = NULL, UINT uId = ID_ICON_HOTPLUG) +{ + NOTIFYICONDATA nim = { 0 }; + nim.cbSize = sizeof(NOTIFYICONDATA); + nim.uID = uId; + nim.hWnd = pSysTray->GetHWnd(); + + nim.uFlags = NIF_INFO; + nim.uTimeout = 10; + nim.dwInfoFlags = NIIF_INFO; + + StringCchCopy(nim.szInfoTitle, _countof(nim.szInfoTitle), szTitle); + StringCchCopy(nim.szInfo, _countof(nim.szInfo), szInfo); + BOOL ret = Shell_NotifyIcon(NIM_MODIFY, &nim); + + Sleep(8000); + StringCchCopy(nim.szInfoTitle, _countof(nim.szInfoTitle), L""); + StringCchCopy(nim.szInfo, _countof(nim.szInfo), L""); + ret = Shell_NotifyIcon(NIM_MODIFY, &nim); + g_IsRemoving = FALSE; + + return ret ? S_OK : E_FAIL; } HRESULT STDMETHODCALLTYPE Hotplug_Init(_In_ CSysTray * pSysTray) @@ -73,16 +99,16 @@ TRACE("Hotplug_Init\n"); g_hIconHotplug = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_HOTPLUG_OK)); g_IsRunning = TRUE; - EnumHotpluggedDevices(g_devList); + EnumHotpluggedDevices(g_devList); return pSysTray->NotifyIcon(NIM_ADD, ID_ICON_HOTPLUG, g_hIconHotplug, g_strTooltip, NIS_HIDDEN); } HRESULT STDMETHODCALLTYPE Hotplug_Update(_In_ CSysTray * pSysTray) { - TRACE("Hotplug_Update\n"); - - if(g_devList.GetSize()) + TRACE("Hotplug_Update\n"); + + if(g_devList.GetSize() || g_IsRemoving) return pSysTray->NotifyIcon(NIM_MODIFY, ID_ICON_HOTPLUG, g_hIconHotplug, g_strTooltip); else return pSysTray->NotifyIcon(NIM_MODIFY, ID_ICON_HOTPLUG, g_hIconHotplug, g_strTooltip, NIS_HIDDEN); @@ -104,18 +130,18 @@ static void _ShowContextMenu(CSysTray * pSysTray) { HMENU hPopup = CreatePopupMenu(); - + ULONG ulLength = DISPLAY_NAME_LEN * sizeof(WCHAR); + for (UINT index = 0; index < g_devList.GetSize(); index++) { WCHAR dispName[DISPLAY_NAME_LEN], menuName[DISPLAY_NAME_LEN + 10]; - ULONG ulLength = DISPLAY_NAME_LEN * sizeof(WCHAR); CONFIGRET cr = CM_Get_DevNode_Registry_Property(g_devList[index], CM_DRP_DEVICEDESC, NULL, dispName, &ulLength, 0); if (cr != CR_SUCCESS) StrCpyW(dispName, L"Unknown Device"); swprintf(menuName, L"Eject %wS", dispName); AppendMenuW(hPopup, MF_STRING, index+1, menuName); - } + } SetForegroundWindow(pSysTray->GetHWnd()); DWORD flags = TPM_RETURNCMD | TPM_NONOTIFY | TPM_RIGHTALIGN | TPM_BOTTOMALIGN; @@ -128,15 +154,25 @@ if (id > 0) { - id--; // since array indices starts from zero. - CONFIGRET cr = CM_Request_Device_Eject_Ex(g_devList[id], 0, 0, 0, 0, 0); - if (cr != CR_SUCCESS) - MessageBox(0, L"Device ejection failed!! Please try again after closing any open programs on device!", L"Safely Remove Hardware", MB_OKCANCEL | MB_ICONEXCLAMATION); - else + id--; // since array indices starts from zero. + CONFIGRET cr = CM_Get_DevNode_Registry_Property(g_devList[id], CM_DRP_DEVICEDESC, NULL, g_strMenuSel, &ulLength, 0); + if (cr != CR_SUCCESS) + StrCpyW(g_strMenuSel, L"Unknown Device"); + + cr = CM_Request_Device_Eject_Ex(g_devList[id], 0, 0, 0, 0, 0); + if (cr != CR_SUCCESS) { - MessageBox(0, L"Device ejected successfully!! You can safely remove the device now!", L"Safely Remove Hardware", MB_OKCANCEL | MB_ICONINFORMATION); - g_devList.RemoveAt(id); + WCHAR strInfo[128]; + swprintf(strInfo, L"Problem Ejecting %wS", g_strMenuSel); + MessageBox(0, L"The device cannot be stopped right now! Try stopping it again later!", strInfo, MB_OKCANCEL | MB_ICONEXCLAMATION); } + else //TODO + { + //MessageBox(0, L"Device ejected successfully!! You can safely remove the device now!", L"Safely Remove Hardware", MB_OKCANCEL | MB_ICONINFORMATION); + g_IsRemoving = TRUE; + g_devList.RemoveAt(id); // thing is.. even after removing id at this point, the devnode_change occurs after some seconds of sucessful removal + // and since pendrive is still plugged in it gets enumerated, if problem number is not filtered. + } } DestroyMenu(hPopup); @@ -145,8 +181,8 @@ static void _ShowContextMenuR(CSysTray * pSysTray) { CString strMenu((LPWSTR)IDS_HOTPLUG_REMOVE_2); - HMENU hPopup = CreatePopupMenu(); - AppendMenuW(hPopup, MF_STRING, IDS_HOTPLUG_REMOVE_2, strMenu); + HMENU hPopup = CreatePopupMenu(); + AppendMenuW(hPopup, MF_STRING, IDS_HOTPLUG_REMOVE_2, strMenu); SetForegroundWindow(pSysTray->GetHWnd()); DWORD flags = TPM_RETURNCMD | TPM_NONOTIFY | TPM_RIGHTALIGN | TPM_BOTTOMALIGN; @@ -167,7 +203,8 @@ HRESULT STDMETHODCALLTYPE Hotplug_Message(_In_ CSysTray * pSysTray, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult) { - TRACE("Hotplug_Message uMsg=%d, wParam=%x, lParam=%x\n", uMsg, wParam, lParam); + HRESULT hr = E_FAIL; + TRACE("Hotplug_Message uMsg=%d, wParam=%x, lParam=%x\n", uMsg, wParam, lParam); switch (uMsg) { @@ -177,7 +214,7 @@ ZeroMemory(&NotificationFilter, sizeof(NotificationFilter)); NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); - NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; + NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; g_hDevNotify = RegisterDeviceNotification(pSysTray->GetHWnd(), &NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES); if (g_hDevNotify != NULL) @@ -227,7 +264,7 @@ break; case WM_RBUTTONUP: - _ShowContextMenuR(pSysTray); + _ShowContextMenuR(pSysTray); break; case WM_RBUTTONDBLCLK: @@ -238,16 +275,32 @@ } return S_OK; - case WM_DEVICECHANGE: + case WM_DEVICECHANGE: switch (wParam) { case DBT_DEVNODES_CHANGED: - HRESULT hr = EnumHotpluggedDevices(g_devList); + hr = EnumHotpluggedDevices(g_devList); if (FAILED(hr)) return hr; - } - - lResult = true; + + lResult = true; + break; + case DBT_DEVICEARRIVAL: + break; + case DBT_DEVICEQUERYREMOVE: + break; + case DBT_DEVICEQUERYREMOVEFAILED: + break; + case DBT_DEVICEREMOVECOMPLETE: + WCHAR strInfo[128]; + swprintf(strInfo, L"The %wS can now be safely removed from the system.", g_strMenuSel); + NotifyBalloon(pSysTray, L"Safe to Remove Hardware", strInfo); + + lResult = true; + break; + case DBT_DEVICEREMOVEPENDING: + break; + } return S_OK; /*case WM_CLOSE: @@ -255,7 +308,7 @@ { return S_FALSE; } - return S_OK;*/ + return S_OK;*/ default: TRACE("Hotplug_Message received for unknown ID %d, ignoring.\n");
7 years, 4 months
1
0
0
0
[hbelusca] 75545: [USETUP]: Sync with tfaber's r75536.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon Aug 14 17:11:50 2017 New Revision: 75545 URL:
http://svn.reactos.org/svn/reactos?rev=75545&view=rev
Log: [USETUP]: Sync with tfaber's r75536. Modified: branches/setup_improvements/base/setup/usetup/cabinet.c Modified: branches/setup_improvements/base/setup/usetup/cabinet.c URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
============================================================================== --- branches/setup_improvements/base/setup/usetup/cabinet.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/cabinet.c [iso-8859-1] Mon Aug 14 17:11:50 2017 @@ -544,7 +544,7 @@ if (!NT_SUCCESS(NtStatus)) { - DPRINT1("NtCreateSection failed: %x\n", NtStatus); + DPRINT1("NtCreateSection failed for %ls: %x\n", CabinetName, NtStatus); return CAB_STATUS_NOMEMORY; } @@ -954,7 +954,7 @@ if (!NT_SUCCESS(NtStatus)) { - DPRINT1("NtCreateSection failed: %x\n", NtStatus); + DPRINT1("NtCreateSection failed for %ls: %x\n", DestName, NtStatus); Status = CAB_STATUS_NOMEMORY; goto CloseDestFile; }
7 years, 4 months
1
0
0
0
[hbelusca] 75544: [REACTOS]: Adapt the 1st-stage GUI setup to compile with the setuplib.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon Aug 14 17:06:19 2017 New Revision: 75544 URL:
http://svn.reactos.org/svn/reactos?rev=75544&view=rev
Log: [REACTOS]: Adapt the 1st-stage GUI setup to compile with the setuplib. Added: branches/setup_improvements/base/setup/reactos/inffile.c (with props) Modified: branches/setup_improvements/base/setup/reactos/CMakeLists.txt branches/setup_improvements/base/setup/reactos/drivepage.c branches/setup_improvements/base/setup/reactos/reactos.c branches/setup_improvements/base/setup/reactos/reactos.h Modified: branches/setup_improvements/base/setup/reactos/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/r…
============================================================================== --- branches/setup_improvements/base/setup/reactos/CMakeLists.txt [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/reactos/CMakeLists.txt [iso-8859-1] Mon Aug 14 17:06:19 2017 @@ -1,14 +1,22 @@ + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../lib +# ${REACTOS_SOURCE_DIR}/base/setup/lib + ${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/zlib + ${REACTOS_SOURCE_DIR}/sdk/include/reactos/drivers) list(APPEND SOURCE drivepage.c + inffile.c reactos.c reactos.h) file(GLOB reactos_rc_deps res/*.*) add_rc_deps(reactos.rc ${reactos_rc_deps}) add_executable(reactos ${SOURCE} reactos.rc) +set_module_type(reactos win32gui UNICODE) add_pch(reactos reactos.h SOURCE) -target_link_libraries(reactos uuid) -set_module_type(reactos win32gui UNICODE) +target_link_libraries(reactos uuid setuplib) add_importlibs(reactos advapi32 gdi32 user32 comctl32 setupapi msvcrt kernel32 ntdll) add_cd_file(TARGET reactos DESTINATION reactos NO_CAB FOR bootcd) Modified: branches/setup_improvements/base/setup/reactos/drivepage.c URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/r…
============================================================================== --- branches/setup_improvements/base/setup/reactos/drivepage.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/reactos/drivepage.c [iso-8859-1] Mon Aug 14 17:06:19 2017 @@ -58,7 +58,7 @@ SendMessage(GetDlgItem(hwndDlg, IDC_PATH), WM_SETTEXT, (WPARAM)0, - (LPARAM)pSetupData->InstallDir); + (LPARAM)pSetupData->USetupData.InstallationDirectory); break; case WM_COMMAND: @@ -67,8 +67,8 @@ case IDOK: SendMessage(GetDlgItem(hwndDlg, IDC_PATH), WM_GETTEXT, - (WPARAM)sizeof(pSetupData->InstallDir) / sizeof(TCHAR), - (LPARAM)pSetupData->InstallDir); + (WPARAM)sizeof(pSetupData->USetupData.InstallationDirectory) / sizeof(TCHAR), + (LPARAM)pSetupData->USetupData.InstallationDirectory); EndDialog(hwndDlg, IDOK); return TRUE; Added: branches/setup_improvements/base/setup/reactos/inffile.c URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/r…
============================================================================== --- branches/setup_improvements/base/setup/reactos/inffile.c (added) +++ branches/setup_improvements/base/setup/reactos/inffile.c [iso-8859-1] Mon Aug 14 17:06:19 2017 @@ -0,0 +1,71 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS text-mode setup + * FILE: base/setup/usetup/inffile.c + * PURPOSE: .inf files support functions + * PROGRAMMERS: Hervé Poussineau + * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) + */ + +/* INCLUDES ******************************************************************/ + +#include "reactos.h" + +#define NDEBUG +#include <debug.h> + +/* SETUP* API COMPATIBILITY FUNCTIONS ****************************************/ + +/* Functions from the INFLIB library */ + +/* SetupOpenInfFileW with support for a user-provided LCID */ +HINF +WINAPI +SetupOpenInfFileExW( + IN PCWSTR FileName, + IN PCWSTR InfClass, + IN DWORD InfStyle, + IN LCID LocaleId, + OUT PUINT ErrorLine) +{ + UNREFERENCED_PARAMETER(LocaleId); + return SetupOpenInfFileW(FileName, InfClass, InfStyle, ErrorLine); +} + + +/* HELPER FUNCTIONS **********************************************************/ + +#if 0 + +HINF WINAPI +INF_OpenBufferedFileA( + IN PSTR FileBuffer, + IN ULONG FileSize, + IN PCSTR InfClass, + IN DWORD InfStyle, + IN LCID LocaleId, + OUT PUINT ErrorLine) +{ +#ifdef __REACTOS__ + HINF hInf = NULL; + ULONG ErrorLineUL; + NTSTATUS Status; + + Status = InfOpenBufferedFile(&hInf, + FileBuffer, + FileSize, + LANGIDFROMLCID(LocaleId), + &ErrorLineUL); + *ErrorLine = (UINT)ErrorLineUL; + if (!NT_SUCCESS(Status)) + return INVALID_HANDLE_VALUE; + + return hInf; +#else + return INVALID_HANDLE_VALUE; +#endif /* !__REACTOS__ */ +} + +#endif + +/* EOF */ Propchange: branches/setup_improvements/base/setup/reactos/inffile.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/setup_improvements/base/setup/reactos/reactos.c URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/r…
============================================================================== --- branches/setup_improvements/base/setup/reactos/reactos.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/reactos/reactos.c [iso-8859-1] Mon Aug 14 17:06:19 2017 @@ -28,12 +28,22 @@ #include "reactos.h" #include "resource.h" +#define NDEBUG +#include <debug.h> + /* GLOBALS ******************************************************************/ +HANDLE ProcessHeap; + +BOOLEAN IsUnattendedSetup = FALSE; +PWCHAR SelectedLanguageId; + +SETUPDATA SetupData; + + +/* FUNCTIONS ****************************************************************/ LONG LoadGenentry(HINF hinf,PCTSTR name,PGENENTRY *gen,PINFCONTEXT context); - -/* FUNCTIONS ****************************************************************/ static VOID CenterWindow(HWND hWnd) @@ -81,6 +91,19 @@ ReleaseDC(NULL, hdc); return hFont; +} + +INT DisplayError( + IN HWND hParentWnd OPTIONAL, + IN UINT uIDTitle, + IN UINT uIDMessage) +{ + WCHAR message[512], caption[64]; + + LoadStringW(SetupData.hInstance, uIDMessage, message, ARRAYSIZE(message)); + LoadStringW(SetupData.hInstance, uIDTitle, caption, ARRAYSIZE(caption)); + + return MessageBoxW(hParentWnd, message, caption, MB_OK | MB_ICONERROR); } static INT_PTR CALLBACK @@ -277,9 +300,9 @@ if (tindex != CB_ERR) { pSetupData->SelectedComputer = SendMessage(hList, - CB_GETITEMDATA, - (WPARAM) tindex, - (LPARAM) 0); + CB_GETITEMDATA, + (WPARAM) tindex, + (LPARAM) 0); } hList = GetDlgItem(hwndDlg, IDC_DISPLAY); @@ -288,9 +311,9 @@ if (tindex != CB_ERR) { pSetupData->SelectedDisplay = SendMessage(hList, - CB_GETITEMDATA, - (WPARAM) tindex, - (LPARAM) 0); + CB_GETITEMDATA, + (WPARAM) tindex, + (LPARAM) 0); } hList =GetDlgItem(hwndDlg, IDC_KEYBOARD); @@ -299,9 +322,9 @@ if (tindex != CB_ERR) { pSetupData->SelectedKeyboard = SendMessage(hList, - CB_GETITEMDATA, - (WPARAM) tindex, - (LPARAM) 0); + CB_GETITEMDATA, + (WPARAM) tindex, + (LPARAM) 0); } return TRUE; } @@ -499,37 +522,15 @@ BOOL LoadSetupData( PSETUPDATA pSetupData) { - WCHAR szPath[MAX_PATH]; + BOOL ret = TRUE; + INFCONTEXT InfContext; TCHAR tmp[10]; - WCHAR *ch; - HINF hTxtsetupSif = INVALID_HANDLE_VALUE; - INFCONTEXT InfContext; //TCHAR szValue[MAX_PATH]; DWORD LineLength; LONG Count; - BOOL ret = TRUE; - - GetModuleFileNameW(NULL,szPath,MAX_PATH); - ch = strrchrW(szPath,L'\\'); - if (ch != NULL) - *ch = L'\0'; - - wcscat(szPath, L"\\txtsetup.sif"); - hTxtsetupSif = SetupOpenInfFileW(szPath, NULL, INF_STYLE_OLDNT, NULL); - if (hTxtsetupSif == INVALID_HANDLE_VALUE) - { - TCHAR message[512], caption[64]; - - // txtsetup.sif cannot be found - LoadString(pSetupData->hInstance, IDS_NO_TXTSETUP_SIF, message, sizeof(message)/sizeof(TCHAR)); - LoadString(pSetupData->hInstance, IDS_CAPTION, caption, sizeof(caption)/sizeof(TCHAR)); - - MessageBox(NULL, message, caption, MB_OK | MB_ICONERROR); - return FALSE; - } // get language list - pSetupData->LangCount = SetupGetLineCount(hTxtsetupSif, _T("Language")); + pSetupData->LangCount = SetupGetLineCount(pSetupData->SetupInf, _T("Language")); if (pSetupData->LangCount > 0) { pSetupData->pLanguages = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LANG) * pSetupData->LangCount); @@ -540,7 +541,7 @@ } Count = 0; - if (SetupFindFirstLine(hTxtsetupSif, _T("Language"), NULL, &InfContext)) + if (SetupFindFirstLine(pSetupData->SetupInf, _T("Language"), NULL, &InfContext)) { do { @@ -562,7 +563,7 @@ } // get keyboard layout list - pSetupData->KbLayoutCount = SetupGetLineCount(hTxtsetupSif, _T("KeyboardLayout")); + pSetupData->KbLayoutCount = SetupGetLineCount(pSetupData->SetupInf, _T("KeyboardLayout")); if (pSetupData->KbLayoutCount > 0) { pSetupData->pKbLayouts = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(KBLAYOUT) * pSetupData->KbLayoutCount); @@ -573,7 +574,7 @@ } Count = 0; - if (SetupFindFirstLine(hTxtsetupSif, _T("KeyboardLayout"), NULL, &InfContext)) + if (SetupFindFirstLine(pSetupData->SetupInf, _T("KeyboardLayout"), NULL, &InfContext)) { do { @@ -599,7 +600,7 @@ pSetupData->DefaultLang = -1; // TODO: get defaults from underlaying running system - if (SetupFindFirstLine(hTxtsetupSif, _T("NLS"), _T("DefaultLayout"), &InfContext)) + if (SetupFindFirstLine(pSetupData->SetupInf, _T("NLS"), _T("DefaultLayout"), &InfContext)) { SetupGetStringField(&InfContext, 1, tmp, sizeof(tmp) / sizeof(TCHAR), &LineLength); for (Count = 0; Count < pSetupData->KbLayoutCount; Count++) @@ -612,7 +613,7 @@ } } - if (SetupFindFirstLine(hTxtsetupSif, _T("NLS"), _T("DefaultLanguage"), &InfContext)) + if (SetupFindFirstLine(pSetupData->SetupInf, _T("NLS"), _T("DefaultLanguage"), &InfContext)) { SetupGetStringField(&InfContext, 1, tmp, sizeof(tmp) / sizeof(TCHAR), &LineLength); for (Count = 0; Count < pSetupData->LangCount; Count++) @@ -626,21 +627,21 @@ } // get computers list - pSetupData->CompCount = LoadGenentry(hTxtsetupSif,_T("Computer"),&pSetupData->pComputers,&InfContext); + pSetupData->CompCount = LoadGenentry(pSetupData->SetupInf,_T("Computer"),&pSetupData->pComputers,&InfContext); // get display list - pSetupData->DispCount = LoadGenentry(hTxtsetupSif,_T("Display"),&pSetupData->pDisplays,&InfContext); + pSetupData->DispCount = LoadGenentry(pSetupData->SetupInf,_T("Display"),&pSetupData->pDisplays,&InfContext); // get keyboard list - pSetupData->KeybCount = LoadGenentry(hTxtsetupSif, _T("Keyboard"),&pSetupData->pKeyboards,&InfContext); + pSetupData->KeybCount = LoadGenentry(pSetupData->SetupInf, _T("Keyboard"),&pSetupData->pKeyboards,&InfContext); // get install directory - if (SetupFindFirstLine(hTxtsetupSif, _T("SetupData"), _T("DefaultPath"), &InfContext)) + if (SetupFindFirstLine(pSetupData->SetupInf, _T("SetupData"), _T("DefaultPath"), &InfContext)) { SetupGetStringField(&InfContext, 1, - pSetupData->InstallDir, - sizeof(pSetupData->InstallDir) / sizeof(TCHAR), + pSetupData->USetupData.InstallationDirectory, + sizeof(pSetupData->USetupData.InstallationDirectory) / sizeof(TCHAR), &LineLength); } @@ -659,9 +660,6 @@ pSetupData->pLanguages = NULL; } } - - if (hTxtsetupSif != INVALID_HANDLE_VALUE) - SetupCloseInfFile(hTxtsetupSif); return ret; } @@ -703,7 +701,7 @@ return TotalCount; } -BOOL isUnattendSetup(VOID) +BOOL IsUnattendSetup(VOID) { WCHAR szPath[MAX_PATH]; WCHAR *ch; @@ -715,7 +713,7 @@ BOOL result = 0; GetModuleFileNameW(NULL, szPath, MAX_PATH); - ch = strrchrW(szPath, L'\\'); + ch = wcsrchr(szPath, L'\\'); if (ch != NULL) *ch = L'\0'; @@ -742,50 +740,35 @@ return result; } -#if 0 -static -VOID -EnableShutdownPrivilege(VOID) -{ - HANDLE hToken = NULL; - TOKEN_PRIVILEGES Privileges; - - /* Get shutdown privilege */ - if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken)) - { -// FatalError("OpenProcessToken() failed!"); - return; - } - - if (!LookupPrivilegeValue(NULL, - SE_SHUTDOWN_NAME, - &Privileges.Privileges[0].Luid)) - { -// FatalError("LookupPrivilegeValue() failed!"); - goto done; - } - - Privileges.PrivilegeCount = 1; - Privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - - if (AdjustTokenPrivileges(hToken, - FALSE, - &Privileges, - 0, - (PTOKEN_PRIVILEGES)NULL, - NULL) == 0) - { -// FatalError("AdjustTokenPrivileges() failed!"); - goto done; - } - -done: - if (hToken != NULL) - CloseHandle(hToken); - - return; -} -#endif + +/* Used to enable and disable the shutdown privilege */ +/* static */ BOOL +EnablePrivilege(LPCWSTR lpszPrivilegeName, BOOL bEnablePrivilege) +{ + BOOL Success; + HANDLE hToken; + TOKEN_PRIVILEGES tp; + + Success = OpenProcessToken(GetCurrentProcess(), + TOKEN_ADJUST_PRIVILEGES, + &hToken); + if (!Success) return Success; + + Success = LookupPrivilegeValueW(NULL, + lpszPrivilegeName, + &tp.Privileges[0].Luid); + if (!Success) goto Quit; + + tp.PrivilegeCount = 1; + tp.Privileges[0].Attributes = (bEnablePrivilege ? SE_PRIVILEGE_ENABLED : 0); + + Success = AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL); + +Quit: + CloseHandle(hToken); + return Success; +} + int WINAPI _tWinMain(HINSTANCE hInst, @@ -793,40 +776,81 @@ LPTSTR lpszCmdLine, int nCmdShow) { - PSETUPDATA pSetupData = NULL; + NTSTATUS Status; + ULONG Error; + // PSETUPDATA pSetupData = NULL; PROPSHEETHEADER psh; HPROPSHEETPAGE ahpsp[8]; PROPSHEETPAGE psp = {0}; UINT nPages = 0; - pSetupData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SETUPDATA)); - if (pSetupData == NULL) - { - return 1; - } - - pSetupData->hInstance = hInst; - pSetupData->bUnattend = isUnattendSetup(); - - LoadString(hInst,IDS_ABORTSETUP, pSetupData->szAbortMessage, sizeof(pSetupData->szAbortMessage)/sizeof(TCHAR)); - LoadString(hInst,IDS_ABORTSETUP2, pSetupData->szAbortTitle, sizeof(pSetupData->szAbortTitle)/sizeof(TCHAR)); + ProcessHeap = GetProcessHeap(); + + // pSetupData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SETUPDATA)); + // if (pSetupData == NULL) + // return 1; + + /* Initialize global unicode strings */ + RtlInitUnicodeString(&SetupData.USetupData.SourcePath, NULL); + RtlInitUnicodeString(&SetupData.USetupData.SourceRootPath, NULL); + RtlInitUnicodeString(&SetupData.USetupData.SourceRootDir, NULL); + // RtlInitUnicodeString(&InstallPath, NULL); + RtlInitUnicodeString(&SetupData.USetupData.DestinationPath, NULL); + RtlInitUnicodeString(&SetupData.USetupData.DestinationArcPath, NULL); + RtlInitUnicodeString(&SetupData.USetupData.DestinationRootPath, NULL); + RtlInitUnicodeString(&SetupData.USetupData.SystemRootPath, NULL); + + /* Get the source path and source root path */ + // + // NOTE: Sometimes the source path may not be in SystemRoot !! + // (and this is the case when using the 1st-stage GUI setup!) + // + Status = GetSourcePaths(&SetupData.USetupData.SourcePath, + &SetupData.USetupData.SourceRootPath, + &SetupData.USetupData.SourceRootDir); + if (!NT_SUCCESS(Status)) + { + DPRINT1("GetSourcePaths() failed (Status 0x%08lx)", Status); + // MUIDisplayError(ERROR_NO_SOURCE_DRIVE, Ir, POPUP_WAIT_ENTER); + MessageBoxW(NULL, L"GetSourcePaths failed!", L"Error", MB_ICONERROR); + goto Quit; + } + DPRINT1("SourcePath: '%wZ'\n", &SetupData.USetupData.SourcePath); + DPRINT1("SourceRootPath: '%wZ'\n", &SetupData.USetupData.SourceRootPath); + DPRINT1("SourceRootDir: '%wZ'\n", &SetupData.USetupData.SourceRootDir); + + /* Load 'txtsetup.sif' from the installation media */ + Error = LoadSetupInf(&SetupData.SetupInf, &SetupData.USetupData); + if (Error != ERROR_SUCCESS) + { + // MUIDisplayError(Error, Ir, POPUP_WAIT_ENTER); + DisplayError(NULL, IDS_CAPTION, IDS_NO_TXTSETUP_SIF); + goto Quit; + } + /* Load extra setup data (HW lists etc...) */ + if (!LoadSetupData(&SetupData)) + goto Quit; + + SetupData.hInstance = hInst; + + // SetupData.bUnattend = IsUnattendSetup(); + CheckUnattendedSetup(&SetupData.USetupData); + SetupData.bUnattend = IsUnattendedSetup; + + LoadStringW(hInst, IDS_ABORTSETUP, SetupData.szAbortMessage, ARRAYSIZE(SetupData.szAbortMessage)); + LoadStringW(hInst, IDS_ABORTSETUP2, SetupData.szAbortTitle, ARRAYSIZE(SetupData.szAbortTitle)); /* Create title font */ - pSetupData->hTitleFont = CreateTitleFont(); - - if (!pSetupData->bUnattend) - { - if (!LoadSetupData(pSetupData)) - { - HeapFree(GetProcessHeap(), 0, pSetupData); - return 0; - } - + SetupData.hTitleFont = CreateTitleFont(); + + if (!SetupData.bUnattend) + { /* Create the Start page, until setup is working */ + // NOTE: What does "until setup is working" mean?? psp.dwSize = sizeof(PROPSHEETPAGE); psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER; psp.hInstance = hInst; - psp.lParam = (LPARAM)pSetupData; + psp.lParam = (LPARAM)&SetupData; psp.pfnDlgProc = StartDlgProc; psp.pszTemplate = MAKEINTRESOURCE(IDD_STARTPAGE); ahpsp[nPages++] = CreatePropertySheetPage(&psp); @@ -837,7 +861,7 @@ psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_TYPETITLE); psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_TYPESUBTITLE); psp.hInstance = hInst; - psp.lParam = (LPARAM)pSetupData; + psp.lParam = (LPARAM)&SetupData; psp.pfnDlgProc = TypeDlgProc; psp.pszTemplate = MAKEINTRESOURCE(IDD_TYPEPAGE); ahpsp[nPages++] = CreatePropertySheetPage(&psp); @@ -848,7 +872,7 @@ psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_DEVICETITLE); psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_DEVICESUBTITLE); psp.hInstance = hInst; - psp.lParam = (LPARAM)pSetupData; + psp.lParam = (LPARAM)&SetupData; psp.pfnDlgProc = DeviceDlgProc; psp.pszTemplate = MAKEINTRESOURCE(IDD_DEVICEPAGE); ahpsp[nPages++] = CreatePropertySheetPage(&psp); @@ -859,7 +883,7 @@ psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_DRIVETITLE); psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_DRIVESUBTITLE); psp.hInstance = hInst; - psp.lParam = (LPARAM)pSetupData; + psp.lParam = (LPARAM)&SetupData; psp.pfnDlgProc = DriveDlgProc; psp.pszTemplate = MAKEINTRESOURCE(IDD_DRIVEPAGE); ahpsp[nPages++] = CreatePropertySheetPage(&psp); @@ -870,7 +894,7 @@ psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_SUMMARYTITLE); psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_SUMMARYSUBTITLE); psp.hInstance = hInst; - psp.lParam = (LPARAM)pSetupData; + psp.lParam = (LPARAM)&SetupData; psp.pfnDlgProc = SummaryDlgProc; psp.pszTemplate = MAKEINTRESOURCE(IDD_SUMMARYPAGE); ahpsp[nPages++] = CreatePropertySheetPage(&psp); @@ -882,7 +906,7 @@ psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_PROCESSTITLE); psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_PROCESSSUBTITLE); psp.hInstance = hInst; - psp.lParam = (LPARAM)pSetupData; + psp.lParam = (LPARAM)&SetupData; psp.pfnDlgProc = ProcessDlgProc; psp.pszTemplate = MAKEINTRESOURCE(IDD_PROCESSPAGE); ahpsp[nPages++] = CreatePropertySheetPage(&psp); @@ -891,7 +915,7 @@ psp.dwSize = sizeof(PROPSHEETPAGE); psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER; psp.hInstance = hInst; - psp.lParam = (LPARAM)pSetupData; + psp.lParam = (LPARAM)&SetupData; psp.pfnDlgProc = RestartDlgProc; psp.pszTemplate = MAKEINTRESOURCE(IDD_RESTARTPAGE); ahpsp[nPages++] = CreatePropertySheetPage(&psp); @@ -910,14 +934,18 @@ /* Display the wizard */ PropertySheet(&psh); - if (pSetupData->hTitleFont) - DeleteObject(pSetupData->hTitleFont); - - HeapFree(GetProcessHeap(), 0, pSetupData); - -#if 0 - EnableShutdownPrivilege(); + if (SetupData.hTitleFont) + DeleteObject(SetupData.hTitleFont); + + SetupCloseInfFile(SetupData.SetupInf); + +Quit: + // HeapFree(GetProcessHeap(), 0, pSetupData); + +#if 0 // NOTE: Disabled for testing purposes only! + EnablePrivilege(SE_SHUTDOWN_NAME, TRUE); ExitWindowsEx(EWX_REBOOT, 0); + EnablePrivilege(SE_SHUTDOWN_NAME, FALSE); #endif return 0; Modified: branches/setup_improvements/base/setup/reactos/reactos.h URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/r…
============================================================================== --- branches/setup_improvements/base/setup/reactos/reactos.h [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/reactos/reactos.h [iso-8859-1] Mon Aug 14 17:06:19 2017 @@ -28,16 +28,33 @@ #ifndef _REACTOS_PCH_ #define _REACTOS_PCH_ +/* C Headers */ #include <stdarg.h> +#include <tchar.h> + +/* PSDK/NDK */ +#define WIN32_NO_STATUS #include <windef.h> #include <winbase.h> #include <winreg.h> #include <wingdi.h> #include <winuser.h> -#include <tchar.h> -#include <setupapi.h> + +#include <commctrl.h> +/**/#include <setupapi.h>/**/ #include <devguid.h> -#include <wine/unicode.h> +// #include <wine/unicode.h> + +#define NTOS_MODE_USER +#include <ndk/cmtypes.h> // For CM_DISK stuff +#include <ndk/iofuncs.h> // For NtCreate/OpenFile +#include <ndk/rtlfuncs.h> + + +/* Setup library headers */ +// #include <reactos/rosioctl.h> +#include <../lib/setuplib.h> +// #include "errorcode.h" typedef struct _LANG @@ -72,20 +89,22 @@ TCHAR szAbortMessage[512]; TCHAR szAbortTitle[64]; + USETUP_DATA USetupData; + HINF SetupInf; + // Settings - LONG DestDiskNumber; // physical disk - LONG DestPartNumber; // partition on disk LONG DestPartSize; // if partition doesn't exist, size of partition LONG FSType; // file system type on partition - LONG MBRInstallType; // install bootloader LONG FormatPart; // type of format the partition + LONG SelectedLangId; // selected language (table index) LONG SelectedKBLayout; // selected keyboard layout (table index) - TCHAR InstallDir[MAX_PATH]; // installation directory on hdd LONG SelectedComputer; // selected computer type (table index) LONG SelectedDisplay; // selected display type (table index) LONG SelectedKeyboard; // selected keyboard type (table index) BOOLEAN RepairUpdateFlag; // flag for update/repair an installed reactos + + // txtsetup.sif data LONG DefaultLang; // default language (table index) PLANG pLanguages; @@ -100,6 +119,10 @@ PGENENTRY pKeyboards; LONG KeybCount; } SETUPDATA, *PSETUPDATA; + +extern HANDLE ProcessHeap; +extern BOOLEAN IsUnattendedSetup; +extern PWCHAR SelectedLanguageId; typedef struct _IMGINFO {
7 years, 4 months
1
0
0
0
[ashaposhnikov] 75543: [RAPPS] - Added headers to CMake file to have them in the VS project
by ashaposhnikov@svn.reactos.org
Author: ashaposhnikov Date: Mon Aug 14 17:04:43 2017 New Revision: 75543 URL:
http://svn.reactos.org/svn/reactos?rev=75543&view=rev
Log: [RAPPS] - Added headers to CMake file to have them in the VS project Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/CMakeLists.txt Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
============================================================================== --- branches/GSoC_2017/rapps/reactos/base/applications/rapps/CMakeLists.txt [iso-8859-1] (original) +++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/CMakeLists.txt [iso-8859-1] Mon Aug 14 17:04:43 2017 @@ -18,6 +18,16 @@ settingsdlg.cpp winmain.cpp include/rapps.h + include/available.h + include/gui.h + include/dialogs.h + include/installed.h + include/crichedit.h + include/defines.h + include/misc.h + include/resource.h + include/rosui.h + include/winmain.h ) add_definitions(-DUSE_CERT_PINNING)
7 years, 4 months
1
0
0
0
[ashaposhnikov] 75542: [RAPPS] - Added /SETUP key support TODO: use the short names from db files - Some style changes - Conditional creation of the dialogs
by ashaposhnikov@svn.reactos.org
Author: ashaposhnikov Date: Mon Aug 14 17:00:20 2017 New Revision: 75542 URL:
http://svn.reactos.org/svn/reactos?rev=75542&view=rev
Log: [RAPPS] - Added /SETUP key support TODO: use the short names from db files - Some style changes - Conditional creation of the dialogs Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/available.h branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/dialogs.h branches/GSoC_2017/rapps/reactos/base/applications/rapps/installdlg.cpp branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
============================================================================== --- branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp [iso-8859-1] (original) +++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp [iso-8859-1] Mon Aug 14 17:00:20 2017 @@ -292,12 +292,13 @@ CDownloadManager::DownloadApplicationsDB(APPLICATION_DATABASE_URL); } - ExtractFilesFromCab(m_szCabPath, m_szAppsPath); hFind = FindFirstFileW(m_szSearchPath.GetString(), &FindFileData); if (hFind == INVALID_HANDLE_VALUE) + { return FALSE; + } } do @@ -348,13 +349,34 @@ Info->RefreshAppInfo(); - if (!lpEnumProc(static_cast<PAPPLICATION_INFO>(Info), m_szAppsPath.GetString())) - break; + if (lpEnumProc) + lpEnumProc(static_cast<PAPPLICATION_INFO>(Info), m_szAppsPath.GetString()); } while (FindNextFileW(hFind, &FindFileData) != 0); FindClose(hFind); return TRUE; +} + +const PAPPLICATION_INFO CAvailableApps::FindInfo(const ATL::CStringW& szAppName) +{ + if (m_InfoList.IsEmpty()) + { + return NULL; + } + + // linear search + POSITION CurrentListPosition = m_InfoList.GetHeadPosition(); + PAPPLICATION_INFO info; + while (CurrentListPosition != NULL) + { + info = m_InfoList.GetNext(CurrentListPosition); + if (info->szName == szAppName) + { + return info; + } + } + return NULL; } const ATL::CStringW & CAvailableApps::GetFolderPath() Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
============================================================================== --- branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp [iso-8859-1] (original) +++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp [iso-8859-1] Mon Aug 14 17:00:20 2017 @@ -1053,7 +1053,7 @@ { if (IS_INSTALLED_ENUM(SelectedEnumType)) ShowInstalledAppInfo(ItemIndex); - if (IS_AVAILABLE_ENUM(SelectedEnumType)) + if (isAvailableEnum(SelectedEnumType)) CAvailableAppView::ShowAvailableAppInfo(ItemIndex); } /* Check if the item is checked */ @@ -1081,7 +1081,7 @@ { if (IS_INSTALLED_ENUM(SelectedEnumType)) ShowInstalledAppInfo(-1); - if (IS_AVAILABLE_ENUM(SelectedEnumType)) + if (isAvailableEnum(SelectedEnumType)) CAvailableAppView::ShowAvailableAppInfo(-1); } } @@ -1463,7 +1463,9 @@ if (EnumType < 0) EnumType = SelectedEnumType; if (IS_INSTALLED_ENUM(SelectedEnumType)) + { FreeInstalledAppList(); + } m_ListView->DeleteAllItems(); @@ -1478,21 +1480,21 @@ ImageList_Destroy(hImageListBuf); } - if (IS_AVAILABLE_ENUM(EnumType)) + if (isAvailableEnum(EnumType)) { /* Enum available applications */ m_AvailableApps.EnumAvailableApplications(EnumType, s_EnumAvailableAppProc); } SelectedEnumType = EnumType; - UpdateStatusBarText(); - SetWelcomeText(); - /* set automatic column width for program names if the list is not empty */ + /* Set automatic column width for program names if the list is not empty */ if (m_ListView->GetItemCount() > 0) + { ListView_SetColumnWidth(m_ListView->GetWindow(), 0, LVSCW_AUTOSIZE); + } bUpdating = FALSE; m_ListView->SetRedraw(TRUE); Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/available.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
============================================================================== --- branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/available.h [iso-8859-1] (original) +++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/available.h [iso-8859-1] Mon Aug 14 17:00:20 2017 @@ -5,29 +5,34 @@ #include <atlcoll.h> /* EnumType flags for EnumAvailableApplications */ -#define ENUM_ALL_AVAILABLE 0 -#define ENUM_CAT_AUDIO 1 -#define ENUM_CAT_VIDEO 2 -#define ENUM_CAT_GRAPHICS 3 -#define ENUM_CAT_GAMES 4 -#define ENUM_CAT_INTERNET 5 -#define ENUM_CAT_OFFICE 6 -#define ENUM_CAT_DEVEL 7 -#define ENUM_CAT_EDU 8 -#define ENUM_CAT_ENGINEER 9 -#define ENUM_CAT_FINANCE 10 -#define ENUM_CAT_SCIENCE 11 -#define ENUM_CAT_TOOLS 12 -#define ENUM_CAT_DRIVERS 13 -#define ENUM_CAT_LIBS 14 -#define ENUM_CAT_OTHER 15 +enum AvailableCategories +{ + ENUM_ALL_AVAILABLE, + ENUM_CAT_AUDIO, + ENUM_CAT_VIDEO, + ENUM_CAT_GRAPHICS, + ENUM_CAT_GAMES, + ENUM_CAT_INTERNET, + ENUM_CAT_OFFICE, + ENUM_CAT_DEVEL, + ENUM_CAT_EDU, + ENUM_CAT_ENGINEER, + ENUM_CAT_FINANCE, + ENUM_CAT_SCIENCE, + ENUM_CAT_TOOLS, + ENUM_CAT_DRIVERS, + ENUM_CAT_LIBS, + ENUM_CAT_OTHER, + ENUM_AVAILABLE_MIN = ENUM_ALL_AVAILABLE, + ENUM_AVAILABLE_MAX = ENUM_CAT_OTHER +}; -#define ENUM_AVAILABLE_MIN ENUM_ALL_AVAILABLE -#define ENUM_AVAILABLE_MAX ENUM_CAT_OTHER +inline BOOL isAvailableEnum(INT x) +{ + return (x >= ENUM_AVAILABLE_MIN && x <= ENUM_AVAILABLE_MAX); +} -#define IS_AVAILABLE_ENUM(a) (a >= ENUM_AVAILABLE_MIN && a <= ENUM_AVAILABLE_MAX) - -typedef enum +typedef enum LICENSE_TYPE { None, OpenSource, @@ -35,7 +40,7 @@ Trial, Max = Trial, Min = None -} LICENSE_TYPE, *PLICENSE_TYPE; +} *PLICENSE_TYPE; class CConfigParser { @@ -62,7 +67,7 @@ UINT GetInt(const ATL::CStringW& KeyName); }; -typedef struct +typedef struct APPLICATION_INFO { INT Category; LICENSE_TYPE LicenseType; @@ -84,9 +89,7 @@ // Optional integrity checks (SHA-1 digests are 160 bit = 40 characters in hex string form) ATL::CStringW szSHA1; -} APPLICATION_INFO, *PAPPLICATION_INFO; - -extern ATL::CAtlList<PAPPLICATION_INFO> InfoList; +} *PAPPLICATION_INFO; typedef BOOL(CALLBACK *AVAILENUMPROC)(PAPPLICATION_INFO Info, LPCWSTR szFolderPath); @@ -113,8 +116,7 @@ BOOL m_HasInstalledVersion = FALSE; CConfigParser m_Parser; - inline BOOL GetString(LPCWSTR lpKeyName, - ATL::CStringW& ReturnedString); + inline BOOL GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString); // Lazily load general info from the file VOID RetrieveGeneralInfo(); @@ -139,6 +141,7 @@ BOOL DeleteCurrentAppsDB(); BOOL UpdateAppsDB(); BOOL EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc); + const PAPPLICATION_INFO FindInfo(const ATL::CStringW& szAppName); const ATL::CStringW& GetFolderPath(); const ATL::CStringW& GetAppPath(); const ATL::CStringW& GetCabPath(); Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/dialogs.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
============================================================================== --- branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/dialogs.h [iso-8859-1] (original) +++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/include/dialogs.h [iso-8859-1] Mon Aug 14 17:00:20 2017 @@ -26,9 +26,9 @@ static DWORD WINAPI ThreadFunc(LPVOID Context); static BOOL DownloadListOfApplications(const ATL::CSimpleArray<PAPPLICATION_INFO>& AppsList); - static BOOL DownloadApplication(PAPPLICATION_INFO pAppInfo); + static BOOL DownloadApplication(PAPPLICATION_INFO pAppInfo, BOOL modal = FALSE); static VOID DownloadApplicationsDB(LPCWSTR lpUrl); - static VOID LaunchDownloadDialog(); + static VOID LaunchDownloadDialog(BOOL); }; // Settings dialog (settingsdlg.cpp) Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/installdlg.cpp URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
============================================================================== --- branches/GSoC_2017/rapps/reactos/base/applications/rapps/installdlg.cpp [iso-8859-1] (original) +++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/installdlg.cpp [iso-8859-1] Mon Aug 14 17:00:20 2017 @@ -42,7 +42,7 @@ BOOL InstallApplication(INT Index) { - if (!IS_AVAILABLE_ENUM(SelectedEnumType)) + if (!isAvailableEnum(SelectedEnumType)) return FALSE; AppInfo = (PAPPLICATION_INFO) ListViewGetlParam(Index); Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
============================================================================== --- branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp [iso-8859-1] (original) +++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp [iso-8859-1] Mon Aug 14 17:00:20 2017 @@ -401,7 +401,7 @@ ShowWindow(Dlg, SW_SHOW); - //Start new download + // Start new download SendMessageW(Dlg, DL_START_NEW, 0, 0); return TRUE; @@ -804,12 +804,12 @@ AppsToInstallList = AppsList; // Create a dialog and issue a download process - LaunchDownloadDialog(); + LaunchDownloadDialog(FALSE); return TRUE; } -BOOL CDownloadManager::DownloadApplication(PAPPLICATION_INFO pAppInfo) +BOOL CDownloadManager::DownloadApplication(PAPPLICATION_INFO pAppInfo, BOOL modal) { if (!pAppInfo) { @@ -818,7 +818,7 @@ AppsToInstallList.RemoveAll(); AppsToInstallList.Add(pAppInfo); - LaunchDownloadDialog(); + LaunchDownloadDialog(modal); return TRUE; } @@ -832,11 +832,22 @@ } //TODO: Reuse the dialog -VOID CDownloadManager::LaunchDownloadDialog() -{ - CreateDialogW(hInst, - MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG), - hMainWnd, - DownloadDlgProc); +VOID CDownloadManager::LaunchDownloadDialog(BOOL modal) +{ + if (modal) + { + DialogBoxW(hInst, + MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG), + hMainWnd, + DownloadDlgProc); + } + else + { + CreateDialogW(hInst, + MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG), + hMainWnd, + DownloadDlgProc); + } + } // CDownloadManager Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
============================================================================== --- branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp [iso-8859-1] (original) +++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp [iso-8859-1] Mon Aug 14 17:00:20 2017 @@ -72,7 +72,7 @@ } szDownloadDir += L"\\RAPPS Downloads"; - ATL::CStringW::CopyChars(pSettingsInfo->szDownloadDir, + ATL::CStringW::CopyChars(pSettingsInfo->szDownloadDir, _countof(pSettingsInfo->szDownloadDir), szDownloadDir.GetString(), szDownloadDir.GetLength() + 1); @@ -119,13 +119,13 @@ SettingsInfo.Top = wp.rcNormalPosition.top; SettingsInfo.Width = wp.rcNormalPosition.right - wp.rcNormalPosition.left; SettingsInfo.Height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top; - SettingsInfo.Maximized = (wp.showCmd == SW_MAXIMIZE - || (wp.showCmd == SW_SHOWMINIMIZED + SettingsInfo.Maximized = (wp.showCmd == SW_MAXIMIZE + || (wp.showCmd == SW_SHOWMINIMIZED && (wp.flags & WPF_RESTORETOMAXIMIZED))); } if (RegKey.Create(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", NULL, - REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, NULL) == ERROR_SUCCESS) + REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, NULL) == ERROR_SUCCESS) { RegKey.SetBinaryValue(L"Settings", (const PVOID) &SettingsInfo, sizeof(SettingsInfo)); RegKey.Close(); @@ -133,28 +133,38 @@ } -#define CMD_KEY_SETUP L"//SETUP" - -VOID CmdParser(LPWSTR lpCmdLine) +#define CMD_KEY_SETUP L"/SETUP" + +// return TRUE if the SETUP key was valid +BOOL CmdParser(LPWSTR lpCmdLine) { INT argc; LPWSTR* argv = CommandLineToArgvW(lpCmdLine, &argc); - if (!argv || argc < 2) - { - return; - } - - if (!StrCmpW(argv[0], CMD_KEY_SETUP)) - { - //TODO: call cmd app installation - } + CAvailableApps apps; + PAPPLICATION_INFO appInfo; + ATL::CString szName; + + if (!argv || argc < 2 || StrCmpW(argv[0], CMD_KEY_SETUP)) + { + return FALSE; + } + + apps.EnumAvailableApplications(ENUM_ALL_AVAILABLE, NULL); + appInfo = apps.FindInfo(argv[1]); + if (appInfo) + { + CDownloadManager::DownloadApplication(appInfo, TRUE); + return TRUE; + } + + return FALSE; } INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) { LPCWSTR szWindowClass = L"ROSAPPMGR"; HANDLE hMutex = NULL; - HACCEL KeyBrd; + HACCEL KeyBrd = NULL; MSG Msg; InitializeAtlModule(hInstance, TRUE); @@ -187,27 +197,31 @@ InitCommonControls(); - hMainWnd = CreateMainWindow(); - if (hMainWnd) - { - /* Maximize it if we must */ - ShowWindow(hMainWnd, (SettingsInfo.bSaveWndPos && SettingsInfo.Maximized ? SW_MAXIMIZE : nShowCmd)); - UpdateWindow(hMainWnd); - - //TODO: get around the ugliness - if (SettingsInfo.bUpdateAtStart) - GetAvailableApps()->UpdateAppsDB(); - - /* Load the menu hotkeys */ - KeyBrd = LoadAcceleratorsW(NULL, MAKEINTRESOURCEW(HOTKEYS)); - - /* Message Loop */ - while (GetMessageW(&Msg, NULL, 0, 0)) + //skip window creation if there were some keys + if (!CmdParser(lpCmdLine)) + { + hMainWnd = CreateMainWindow(); + if (hMainWnd) { - if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg)) + /* Maximize it if we must */ + ShowWindow(hMainWnd, (SettingsInfo.bSaveWndPos && SettingsInfo.Maximized ? SW_MAXIMIZE : nShowCmd)); + UpdateWindow(hMainWnd); + + //TODO: get around the ugliness + if (SettingsInfo.bUpdateAtStart) + GetAvailableApps()->UpdateAppsDB(); + + /* Load the menu hotkeys */ + KeyBrd = LoadAcceleratorsW(NULL, MAKEINTRESOURCEW(HOTKEYS)); + + /* Message Loop */ + while (GetMessageW(&Msg, NULL, 0, 0)) { - TranslateMessage(&Msg); - DispatchMessageW(&Msg); + if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg)) + { + TranslateMessage(&Msg); + DispatchMessageW(&Msg); + } } } }
7 years, 4 months
1
0
0
0
[mjansen] 75541: [SHIMENG] Filter shims based on the include/exclude node specified, as well as their presence in certain directories. - Shims are not allowed on files from System32 / WinSxs. - Ind...
by mjansen@svn.reactos.org
Author: mjansen Date: Mon Aug 14 16:34:56 2017 New Revision: 75541 URL:
http://svn.reactos.org/svn/reactos?rev=75541&view=rev
Log: [SHIMENG] Filter shims based on the include/exclude node specified, as well as their presence in certain directories. - Shims are not allowed on files from System32 / WinSxs. - Individual shims can override this per module with includes/excludes. - Shims can specify additional dlls to ignore or include. - Specify a default list of dlls to be included from system32. CORE-13618 Modified: trunk/reactos/dll/appcompat/apphelp/apphelp.h trunk/reactos/dll/appcompat/apphelp/shimeng.c trunk/reactos/dll/appcompat/apphelp/shimeng.h trunk/reactos/media/sdb/sysmain.xml Modified: trunk/reactos/dll/appcompat/apphelp/apphelp.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/apph…
============================================================================== --- trunk/reactos/dll/appcompat/apphelp/apphelp.h [iso-8859-1] (original) +++ trunk/reactos/dll/appcompat/apphelp/apphelp.h [iso-8859-1] Mon Aug 14 16:34:56 2017 @@ -89,6 +89,7 @@ /* sdbapi.c */ PWSTR SdbpStrDup(LPCWSTR string); +DWORD SdbpStrsize(PCWSTR string); HSDB WINAPI SdbInitDatabase(DWORD, LPCWSTR); void WINAPI SdbReleaseDatabase(HSDB); BOOL WINAPI SdbGUIDToString(CONST GUID *Guid, PWSTR GuidString, SIZE_T Length); Modified: trunk/reactos/dll/appcompat/apphelp/shimeng.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/shim…
============================================================================== --- trunk/reactos/dll/appcompat/apphelp/shimeng.c [iso-8859-1] (original) +++ trunk/reactos/dll/appcompat/apphelp/shimeng.c [iso-8859-1] Mon Aug 14 16:34:56 2017 @@ -27,21 +27,24 @@ #include "shimeng.h" -typedef FARPROC(WINAPI* GETPROCADDRESSPROC)(HINSTANCE, LPCSTR); - FARPROC WINAPI StubGetProcAddress(HINSTANCE hModule, LPCSTR lpProcName); BOOL WINAPI SE_IsShimDll(PVOID BaseAddress); extern HMODULE g_hInstance; +static UNICODE_STRING g_WindowsDirectory; +static UNICODE_STRING g_System32Directory; +static UNICODE_STRING g_SxsDirectory; ULONG g_ShimEngDebugLevel = 0xffffffff; BOOL g_bComPlusImage = FALSE; BOOL g_bShimDuringInit = FALSE; BOOL g_bInternalHooksUsed = FALSE; -static ARRAY g_pShimInfo; /* PSHIMMODULE */ -static ARRAY g_pHookArray; /* HOOKMODULEINFO */ - +static ARRAY g_pShimInfo; /* PSHIMMODULE */ +static ARRAY g_pHookArray; /* HOOKMODULEINFO */ +static ARRAY g_InExclude; /* INEXCLUDE */ + +/* If we have setup a hook for a function, we should also redirect GetProcAddress for this function */ HOOKAPIEX g_IntHookEx[] = { { @@ -132,7 +135,7 @@ static const UNICODE_STRING DebugKey = RTL_CONSTANT_STRING(L"SHIMENG_DEBUG_LEVEL"); UNICODE_STRING DebugValue; NTSTATUS Status; - ULONG NewLevel = 0; + ULONG NewLevel = SEI_MSG; /* Show some basic info in the logs, unless configured different */ WCHAR Buffer[40]; RtlInitEmptyUnicodeString(&DebugValue, Buffer, sizeof(Buffer)); @@ -294,20 +297,29 @@ return Data; } -VOID SeiAppendHookInfo(PSHIMMODULE pShimModuleInfo, PHOOKAPIEX pHookApi, DWORD dwHookCount) +PSHIMINFO SeiAppendHookInfo(PSHIMMODULE pShimModuleInfo, PHOOKAPIEX pHookApi, DWORD dwHookCount, PCWSTR ShimName) { PSHIMINFO* pData, Data; pData = ARRAY_Append(&pShimModuleInfo->EnabledShims, PSHIMINFO); if (!pData) - return; + return NULL; *pData = SeiAlloc(sizeof(SHIMINFO)); Data = *pData; + + if (!Data) + return NULL; + + Data->ShimName = SdbpStrDup(ShimName); + if (!Data->ShimName) + return NULL; Data->pHookApi = pHookApi; Data->dwHookCount = dwHookCount; Data->pShimModule = pShimModuleInfo; + ARRAY_Init(&Data->InExclude, INEXCLUDE); + return Data; } PHOOKMODULEINFO SeiFindHookModuleInfo(PUNICODE_STRING ModuleName, PVOID BaseAddress) @@ -382,6 +394,7 @@ *Data = trShimRef; } +/* Propagate layers to child processes */ static VOID SeiSetLayerEnvVar(LPCWSTR wszLayer) { NTSTATUS Status; @@ -399,6 +412,7 @@ #define MAX_LAYER_LENGTH 256 +/* Translate all Exe and Layer entries to Shims, and propagate all layers */ static VOID SeiBuildShimRefArray(HSDB hsdb, SDBQUERYRESULT* pQuery, PARRAY pShimRef) { WCHAR wszLayerEnvVar[MAX_LAYER_LENGTH] = { 0 }; @@ -468,7 +482,7 @@ SeiSetLayerEnvVar(wszLayerEnvVar); } - +/* Given the hooks from one shim, find the relevant modules and store the combination of module + hook */ VOID SeiAddHooks(PHOOKAPIEX hooks, DWORD dwHookCount, PSHIMINFO pShim) { DWORD n, j; @@ -542,7 +556,9 @@ } } - +typedef FARPROC(WINAPI* GETPROCADDRESSPROC)(HINSTANCE, LPCSTR); + +/* Check if we should fake the return from GetProcAddress (because we also redirected the iat for this module) */ FARPROC WINAPI StubGetProcAddress(HINSTANCE hModule, LPCSTR lpProcName) { char szOrdProcName[10] = ""; @@ -588,6 +604,7 @@ return proc; } +/* Walk all shim modules / enabled shims, and add their hooks */ VOID SeiResolveAPIs(VOID) { DWORD mod, n; @@ -611,6 +628,7 @@ } } +/* If we hooked something, we should also redirect GetProcAddress */ VOID SeiAddInternalHooks(DWORD dwNumHooks) { if (dwNumHooks == 0) @@ -623,6 +641,7 @@ g_bInternalHooksUsed = TRUE; } +/* Patch one function in the iat */ VOID SeiPatchNewImport(PIMAGE_THUNK_DATA FirstThunk, PHOOKAPIEX HookApi, PLDR_DATA_TABLE_ENTRY LdrEntry) { ULONG OldProtection = 0; @@ -658,8 +677,161 @@ } } -/* Level(INFO) [SeiPrintExcludeInfo] Module "kernel32.dll" excluded for shim VistaRTMVersionLie, API "NTDLL.DLL!RtlGetVersion", because it is in System32/WinSXS. */ - + +PINEXCLUDE SeiFindInExclude(PARRAY InExclude, PCUNICODE_STRING DllName) +{ + DWORD n; + + for (n = 0; n < ARRAY_Size(InExclude); ++n) + { + PINEXCLUDE InEx = ARRAY_At(InExclude, INEXCLUDE, n); + + if (RtlEqualUnicodeString(&InEx->Module, DllName, TRUE)) + return InEx; + } + + return NULL; +} + +BOOL SeiIsExcluded(PLDR_DATA_TABLE_ENTRY LdrEntry, PHOOKAPIEX HookApi) +{ + PSHIMINFO pShimInfo = HookApi->pShimInfo; + PINEXCLUDE InExclude; + BOOL IsExcluded = FALSE; + + if (!pShimInfo) + { + /* Internal hook, do not exclude it */ + return FALSE; + } + + /* By default, everything from System32 or WinSxs is excluded */ + if (RtlPrefixUnicodeString(&g_System32Directory, &LdrEntry->FullDllName, TRUE) || + RtlPrefixUnicodeString(&g_SxsDirectory, &LdrEntry->FullDllName, TRUE)) + IsExcluded = TRUE; + + InExclude = SeiFindInExclude(&pShimInfo->InExclude, &LdrEntry->BaseDllName); + if (InExclude) + { + /* If it is on the 'exclude' list, bail out */ + if (!InExclude->Include) + { + SHIMENG_INFO("Module '%wZ' excluded for shim %S, API '%s!%s', because it on in the exclude list.\n", + &LdrEntry->BaseDllName, pShimInfo->ShimName, HookApi->LibraryName, HookApi->FunctionName); + + return TRUE; + } + /* If it is on the 'include' list, override System32 / Winsxs check. */ + if (IsExcluded) + { + SHIMENG_INFO("Module '%wZ' included for shim %S, API '%s!%s', because it is on the include list.\n", + &LdrEntry->BaseDllName, pShimInfo->ShimName, HookApi->LibraryName, HookApi->FunctionName); + + } + IsExcluded = FALSE; + } + + if (IsExcluded) + { + SHIMENG_INFO("Module '%wZ' excluded for shim %S, API '%s!%s', because it is in System32/WinSXS.\n", + &LdrEntry->BaseDllName, pShimInfo->ShimName, HookApi->LibraryName, HookApi->FunctionName); + } + + return IsExcluded; +} + +VOID SeiAppendInExclude(PARRAY dest, PCWSTR ModuleName, BOOL IsInclude) +{ + PINEXCLUDE InExclude; + UNICODE_STRING ModuleNameU; + RtlInitUnicodeString(&ModuleNameU, ModuleName); + + InExclude = SeiFindInExclude(dest, &ModuleNameU); + if (InExclude) + { + InExclude->Include = IsInclude; + return; + } + + InExclude = ARRAY_Append(dest, INEXCLUDE); + if (InExclude) + { + PCWSTR ModuleNameCopy = SdbpStrDup(ModuleName); + RtlInitUnicodeString(&InExclude->Module, ModuleNameCopy); + InExclude->Include = IsInclude; + } +} + +/* Read the INEXCLUD tags from a given parent tag */ +VOID SeiReadInExclude(PDB pdb, TAGID parent, PARRAY dest) +{ + TAGID InExcludeTag; + + InExcludeTag = SdbFindFirstTag(pdb, parent, TAG_INEXCLUD); + + while (InExcludeTag != TAGID_NULL) + { + PCWSTR ModuleName; + TAGID ModuleTag = SdbFindFirstTag(pdb, InExcludeTag, TAG_MODULE); + TAGID IncludeTag = SdbFindFirstTag(pdb, InExcludeTag, TAG_INCLUDE); + + ModuleName = SdbGetStringTagPtr(pdb, ModuleTag); + if (ModuleName) + { + SeiAppendInExclude(dest, ModuleName, IncludeTag != TAGID_NULL); + } + else + { + SHIMENG_WARN("INEXCLUDE without Module: 0x%x\n", InExcludeTag); + } + + InExcludeTag = SdbFindNextTag(pdb, parent, InExcludeTag); + } +} + +VOID SeiBuildGlobalInclExclList(HSDB hsdb) +{ + PDB pdb; + TAGREF tr = TAGREF_ROOT; + TAGID root, db, library; + + if (!SdbTagRefToTagID(hsdb, tr, &pdb, &root)) + { + SHIMENG_WARN("Unable to resolve database root\n"); + return; + } + db = SdbFindFirstTag(pdb, root, TAG_DATABASE); + if (db == TAGID_NULL) + { + SHIMENG_WARN("Unable to resolve database\n"); + return; + } + library = SdbFindFirstTag(pdb, db, TAG_LIBRARY); + if (library == TAGID_NULL) + { + SHIMENG_WARN("Unable to resolve library\n"); + return; + } + + SeiReadInExclude(pdb, library, &g_InExclude); +} + +VOID SeiBuildInclExclList(PDB pdb, TAGID ShimTag, PSHIMINFO pShimInfo) +{ + DWORD n; + + /* First duplicate the global in/excludes */ + for (n = 0; n < ARRAY_Size(&g_InExclude); ++n) + { + PINEXCLUDE InEx = ARRAY_At(&g_InExclude, INEXCLUDE, n); + SeiAppendInExclude(&pShimInfo->InExclude, InEx->Module.Buffer, InEx->Include); + } + + /* Now read this shim's in/excludes (possibly overriding the global ones) */ + SeiReadInExclude(pdb, ShimTag, &pShimInfo->InExclude); +} + +/* Given one loaded module, redirect (hook) all functions from the iat that are registered by shims */ VOID SeiHookImports(PLDR_DATA_TABLE_ENTRY LdrEntry) { ULONG Size; @@ -698,9 +870,16 @@ DWORD dwFound = 0; PHOOKAPIEX HookApi = *ARRAY_At(&HookModuleInfo->HookApis, PHOOKAPIEX, n); + /* Check if this module should be excluded from being hooked (system32/winsxs, global or shim exclude) */ + if (SeiIsExcluded(LdrEntry, HookApi)) + { + continue; + } + OriginalThunk = (PIMAGE_THUNK_DATA)(DllBase + ImportDescriptor->OriginalFirstThunk); FirstThunk = (PIMAGE_THUNK_DATA)(DllBase + ImportDescriptor->FirstThunk); + /* Walk all imports */ for (;OriginalThunk->u1.AddressOfData && FirstThunk->u1.Function; OriginalThunk++, FirstThunk++) { if (!IMAGE_SNAP_BY_ORDINAL32(OriginalThunk->u1.AddressOfData)) @@ -755,6 +934,28 @@ } +VOID SeiInitPaths(VOID) +{ +#define SYSTEM32 L"\\system32" +#define WINSXS L"\\winsxs" + + PWSTR WindowsDirectory = SdbpStrDup(SharedUserData->NtSystemRoot); + RtlInitUnicodeString(&g_WindowsDirectory, WindowsDirectory); + + g_System32Directory.MaximumLength = g_WindowsDirectory.Length + SdbpStrsize(SYSTEM32); + g_System32Directory.Buffer = SdbpAlloc(g_System32Directory.MaximumLength); + RtlCopyUnicodeString(&g_System32Directory, &g_WindowsDirectory); + RtlAppendUnicodeToString(&g_System32Directory, SYSTEM32); + + g_SxsDirectory.MaximumLength = g_WindowsDirectory.Length + SdbpStrsize(WINSXS); + g_SxsDirectory.Buffer = SdbpAlloc(g_SxsDirectory.MaximumLength); + RtlCopyUnicodeString(&g_SxsDirectory, &g_WindowsDirectory); + RtlAppendUnicodeToString(&g_SxsDirectory, WINSXS); + +#undef SYSTEM32 +#undef WINSXS +} + /* Level(INFO) Using USER apphack flags 0x2080000 */ @@ -773,6 +974,9 @@ ARRAY_Init(&ShimRefArray, TAGREF); ARRAY_Init(&g_pShimInfo, PSHIMMODULE); ARRAY_Init(&g_pHookArray, HOOKMODULEINFO); + ARRAY_Init(&g_InExclude, INEXCLUDE); + + SeiInitPaths(); SeiCheckComPlusImage(Peb->ImageBaseAddress); @@ -786,10 +990,9 @@ SeiDbgPrint(SEI_MSG, NULL, "ShimInfo(Complete)\n"); SHIMENG_INFO("Got %d shims\n", ARRAY_Size(&ShimRefArray)); - /* TODO: - SeiBuildGlobalInclExclList() - */ - + SeiBuildGlobalInclExclList(hsdb); + + /* Walk all shims referenced (in layers + exes), and load their modules */ for (n = 0; n < ARRAY_Size(&ShimRefArray); ++n) { PDB pdb; @@ -806,6 +1009,7 @@ PVOID BaseAddress; PSHIMMODULE pShimModuleInfo = NULL; ANSI_STRING AnsiCommandLine = RTL_CONSTANT_STRING(""); + PSHIMINFO pShimInfo = NULL; PHOOKAPIEX pHookApi; DWORD dwHookCount; @@ -856,6 +1060,7 @@ RtlInitUnicodeString(&UnicodeDllName, FullNameBuffer); if (NT_SUCCESS(LdrGetDllHandle(NULL, NULL, &UnicodeDllName, &BaseAddress))) { + /* This shim dll was already loaded, let's find it */ pShimModuleInfo = SeiGetShimModuleInfo(BaseAddress); } else if (!NT_SUCCESS(LdrLoadDll(NULL, NULL, &UnicodeDllName, &BaseAddress))) @@ -863,6 +1068,7 @@ SHIMENG_WARN("Failed to load %wZ for %S\n", &UnicodeDllName, ShimName); continue; } + /* No shim module found (or we just loaded it) */ if (!pShimModuleInfo) { pShimModuleInfo = SeiCreateShimModuleInfo(DllName, BaseAddress); @@ -876,16 +1082,20 @@ SHIMENG_INFO("Shim DLL 0x%p \"%wZ\" loaded\n", BaseAddress, &UnicodeDllName); SHIMENG_INFO("Using SHIM \"%S!%S\"\n", DllName, ShimName); + /* Ask this shim what hooks it needs (and pass along the commandline) */ pHookApi = pShimModuleInfo->pGetHookAPIs(AnsiCommandLine.Buffer, ShimName, &dwHookCount); SHIMENG_INFO("GetHookAPIs returns %d hooks for DLL \"%wZ\" SHIM \"%S\"\n", dwHookCount, &UnicodeDllName, ShimName); if (dwHookCount) - SeiAppendHookInfo(pShimModuleInfo, pHookApi, dwHookCount); + pShimInfo = SeiAppendHookInfo(pShimModuleInfo, pHookApi, dwHookCount, ShimName); + + /* If this shim has hooks, create the include / exclude lists */ + if (pShimInfo) + SeiBuildInclExclList(pdb, ShimTag, pShimInfo); if (CommandLine && *CommandLine) RtlFreeAnsiString(&AnsiCommandLine); dwTotalHooks += dwHookCount; - /*SeiBuildInclExclList*/ } } @@ -895,7 +1105,7 @@ } - +/* Load the database + unpack the shim data (if this process is allowed) */ BOOL SeiGetShimData(PUNICODE_STRING ProcessImage, PVOID pShimData, HSDB* pHsdb, SDBQUERYRESULT* pQuery) { static const UNICODE_STRING ForbiddenShimmingApps[] = { Modified: trunk/reactos/dll/appcompat/apphelp/shimeng.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/shim…
============================================================================== --- trunk/reactos/dll/appcompat/apphelp/shimeng.h [iso-8859-1] (original) +++ trunk/reactos/dll/appcompat/apphelp/shimeng.h [iso-8859-1] Mon Aug 14 16:34:56 2017 @@ -19,7 +19,7 @@ #ifndef SHIMENG_H #define SHIMENG_H -/* ReactOS specific */ +/* This header is ReactOS specific */ /* Structure that allows dynamic growing. Be aware, the data may move! */ @@ -48,12 +48,19 @@ C_ASSERT(sizeof(HOOKAPIEX) == sizeof(HOOKAPI)); C_ASSERT(offsetof(HOOKAPIEX, pShimInfo) == offsetof(HOOKAPI, Reserved)); +typedef struct _INEXCLUDE +{ + UNICODE_STRING Module; + BOOL Include; +} INEXCLUDE, *PINEXCLUDE; typedef struct _SHIMINFO { + PCWSTR ShimName; PHOOKAPIEX pHookApi; DWORD dwHookCount; PSHIMMODULE pShimModule; + ARRAY InExclude; /* INEXCLUDE */ } SHIMINFO, *PSHIMINFO; typedef struct _SHIMMODULE Modified: trunk/reactos/media/sdb/sysmain.xml URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/sdb/sysmain.xml?rev=…
============================================================================== --- trunk/reactos/media/sdb/sysmain.xml [iso-8859-1] (original) +++ trunk/reactos/media/sdb/sysmain.xml [iso-8859-1] Mon Aug 14 16:34:56 2017 @@ -4,6 +4,10 @@ <OS_PLATFORM >1</OS_PLATFORM> <DATABASE_ID>{11111111-1111-1111-1111-111111111111}</DATABASE_ID> <LIBRARY> + <INCLUDE MODULE="kernel32.dll" /> + <INCLUDE MODULE="msvcrt.dll" /> + <INCLUDE MODULE="ole32.dll" /> + <INCLUDE MODULE="oleaut32.dll" /> <!-- Version lie shims -->
7 years, 4 months
1
0
0
0
[hbelusca] 75540: [USETUP]: Sync with hpoussin's r75532, and add the corresponding INF_FreeData().
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon Aug 14 16:33:55 2017 New Revision: 75540 URL:
http://svn.reactos.org/svn/reactos?rev=75540&view=rev
Log: [USETUP]: Sync with hpoussin's r75532, and add the corresponding INF_FreeData(). Modified: branches/setup_improvements/base/setup/usetup/devinst.c Modified: branches/setup_improvements/base/setup/usetup/devinst.c URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
============================================================================== --- branches/setup_improvements/base/setup/usetup/devinst.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/devinst.c [iso-8859-1] Mon Aug 14 16:33:55 2017 @@ -50,39 +50,43 @@ OBJECT_ATTRIBUTES ObjectAttributes; HANDLE hService; INFCONTEXT Context; - PWSTR Driver, ImagePath, FullImagePath; + PWSTR Driver, ClassGuid, ImagePath, FullImagePath; ULONG dwValue; ULONG Disposition; NTSTATUS Status; BOOLEAN deviceInstalled = FALSE; UNICODE_STRING UpperFiltersU = RTL_CONSTANT_STRING(L"UpperFilters"); PWSTR keyboardClass = L"kbdclass\0"; - BOOLEAN keyboardDevice = FALSE; /* Check if we know the hardware */ if (!SetupFindFirstLineW(hInf, L"HardwareIdsDatabase", HardwareId, &Context)) return FALSE; if (!INF_GetDataField(&Context, 1, &Driver)) return FALSE; + + /* Get associated class GUID (if any) */ + if (!INF_GetDataField(&Context, 2, &ClassGuid)) + ClassGuid = NULL; /* Find associated driver name */ /* FIXME: check in other sections too! */ if (!SetupFindFirstLineW(hInf, L"BootBusExtenders.Load", Driver, &Context) && !SetupFindFirstLineW(hInf, L"BusExtenders.Load", Driver, &Context) && !SetupFindFirstLineW(hInf, L"SCSI.Load", Driver, &Context) - && !SetupFindFirstLineW(hInf, L"InputDevicesSupport.Load", Driver, &Context)) - { - if (!SetupFindFirstLineW(hInf, L"Keyboard.Load", Driver, &Context)) - { - INF_FreeData(Driver); - return FALSE; - } - - keyboardDevice = TRUE; + && !SetupFindFirstLineW(hInf, L"InputDevicesSupport.Load", Driver, &Context) + && !SetupFindFirstLineW(hInf, L"Keyboard.Load", Driver, &Context)) + { + INF_FreeData(ClassGuid); + INF_FreeData(Driver); + return FALSE; } if (!INF_GetDataField(&Context, 1, &ImagePath)) - return FALSE; + { + INF_FreeData(ClassGuid); + INF_FreeData(Driver); + return FALSE; + } /* Prepare full driver path */ dwValue = PathPrefix.MaximumLength + wcslen(ImagePath) * sizeof(WCHAR); @@ -91,6 +95,7 @@ { DPRINT1("RtlAllocateHeap() failed\n"); INF_FreeData(ImagePath); + INF_FreeData(ClassGuid); INF_FreeData(Driver); return FALSE; } @@ -108,6 +113,7 @@ DPRINT1("NtCreateKey('%wZ') failed with status 0x%08x\n", &StringU, Status); RtlFreeHeap(ProcessHeap, 0, FullImagePath); INF_FreeData(ImagePath); + INF_FreeData(ClassGuid); INF_FreeData(Driver); return FALSE; } @@ -149,7 +155,7 @@ INF_FreeData(ImagePath); - if (keyboardDevice) + if (ClassGuid &&_wcsicmp(ClassGuid, L"{4D36E96B-E325-11CE-BFC1-08002BE10318}") == 0) { DPRINT1("Installing keyboard class driver for '%S'\n", DeviceId); NtSetValueKey(hDeviceKey, @@ -159,6 +165,8 @@ keyboardClass, (wcslen(keyboardClass) + 2) * sizeof(WCHAR)); } + + INF_FreeData(ClassGuid); /* Associate device with the service we just filled */ Status = NtSetValueKey(hDeviceKey,
7 years, 4 months
1
0
0
0
[hbelusca] 75539: [USETUP]: Close the txtsetup.sif file at the end of the operations.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon Aug 14 16:32:39 2017 New Revision: 75539 URL:
http://svn.reactos.org/svn/reactos?rev=75539&view=rev
Log: [USETUP]: Close the txtsetup.sif file at the end of the operations. Modified: branches/setup_improvements/base/setup/usetup/usetup.c Modified: branches/setup_improvements/base/setup/usetup/usetup.c URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
============================================================================== --- branches/setup_improvements/base/setup/usetup/usetup.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/usetup.c [iso-8859-1] Mon Aug 14 16:32:39 2017 @@ -4791,6 +4791,8 @@ } } + SetupCloseInfFile(SetupInf); + if (Page == RECOVERY_PAGE) RecoveryConsole();
7 years, 4 months
1
0
0
0
[hbelusca] 75538: [USETUP]: Addendum to 75537.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon Aug 14 16:31:55 2017 New Revision: 75538 URL:
http://svn.reactos.org/svn/reactos?rev=75538&view=rev
Log: [USETUP]: Addendum to 75537. Modified: branches/setup_improvements/base/setup/usetup/inffile.c Modified: branches/setup_improvements/base/setup/usetup/inffile.c URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
============================================================================== --- branches/setup_improvements/base/setup/usetup/inffile.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/inffile.c [iso-8859-1] Mon Aug 14 16:31:55 2017 @@ -132,13 +132,13 @@ ULONG FieldIndex, INT *IntegerValue); // #define SetupGetIntField InfGetIntField -BOOLEAN +BOOL WINAPI SetupGetIntField(PINFCONTEXT Context, ULONG FieldIndex, - INT *IntegerValue) -{ - return InfGetIntField(Context, FieldIndex, IntegerValue); + INT *IntegerValue) // PINT +{ + return !!InfGetIntField(Context, FieldIndex, IntegerValue); } extern BOOLEAN InfGetMultiSzField(PINFCONTEXT Context,
7 years, 4 months
1
0
0
0
[hbelusca] 75537: [SETUPLIB]: Fix compilation errors when using these headers with usetup (that doesn't use setupapi.dll) and "reactos" (the 1st-stage GUI installer, which uses setupapi.dll).
by hbelusca@svn.reactos.org
Author: hbelusca Date: Mon Aug 14 16:29:01 2017 New Revision: 75537 URL:
http://svn.reactos.org/svn/reactos?rev=75537&view=rev
Log: [SETUPLIB]: Fix compilation errors when using these headers with usetup (that doesn't use setupapi.dll) and "reactos" (the 1st-stage GUI installer, which uses setupapi.dll). Modified: branches/setup_improvements/base/setup/lib/errorcode.h branches/setup_improvements/base/setup/lib/infsupp.h Modified: branches/setup_improvements/base/setup/lib/errorcode.h URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
============================================================================== --- branches/setup_improvements/base/setup/lib/errorcode.h [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/lib/errorcode.h [iso-8859-1] Mon Aug 14 16:29:01 2017 @@ -8,7 +8,12 @@ #pragma once -typedef enum +/* setupapi.h defines ERROR_NOT_INSTALLED with another meaning */ +#ifdef ERROR_NOT_INSTALLED +#undef ERROR_NOT_INSTALLED +#endif + +typedef enum _ERROR_NUMBER { NOT_AN_ERROR = 0, // ERROR_SUCCESS, ERROR_NOT_INSTALLED, Modified: branches/setup_improvements/base/setup/lib/infsupp.h URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
============================================================================== --- branches/setup_improvements/base/setup/lib/infsupp.h [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/lib/infsupp.h [iso-8859-1] Mon Aug 14 16:29:01 2017 @@ -8,13 +8,14 @@ #pragma once +/* Make setupapi.h to not define the API as exports to the DLL */ #ifdef __REACTOS__ #define _SETUPAPI_ #endif // FIXME: Temporary measure until all the users of this header // (usetup...) use or define SetupAPI-conforming APIs. -#if 0 +#if defined(_SETUPAPI_H_) || defined(_INC_SETUPAPI) #include <setupapi.h> @@ -64,11 +65,11 @@ PULONG RequiredSize); // #define SetupGetIntField InfGetIntField -BOOLEAN +BOOL WINAPI SetupGetIntField(PINFCONTEXT Context, ULONG FieldIndex, - INT *IntegerValue); + INT *IntegerValue); // PINT // #define SetupGetMultiSzFieldW InfGetMultiSzField BOOL
7 years, 4 months
1
0
0
0
← Newer
1
...
16
17
18
19
20
21
22
...
27
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
Results per page:
10
25
50
100
200