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
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
June 2017
----- 2025 -----
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
20 participants
526 discussions
Start a n
N
ew thread
[ssawant] 74961: [QCKLNCH] -Created a sample button to test toolbar area. -Added qcklnch.dll entry in syssetup.inf file for registration.
by ssawant@svn.reactos.org
Author: ssawant Date: Thu Jun 8 15:18:21 2017 New Revision: 74961 URL:
http://svn.reactos.org/svn/reactos?rev=74961&view=rev
Log: [QCKLNCH] -Created a sample button to test toolbar area. -Added qcklnch.dll entry in syssetup.inf file for registration. Modified: branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CQuickLaunchBand.cpp branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CQuickLaunchBand.h branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/precomp.
…
[View More]
h branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/qcklnch.cpp branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/rgs/qcklnch.rgs branches/GSoC_2017/shellext/reactos/media/inf/syssetup.inf Modified: branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CQuickLaunchBand.cpp URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/shellext/reactos/dll/…
============================================================================== --- branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CQuickLaunchBand.cpp [iso-8859-1] (original) +++ branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CQuickLaunchBand.cpp [iso-8859-1] Thu Jun 8 15:18:21 2017 @@ -13,7 +13,7 @@ // {260CB95D-4544-44F6-A079-575BAA60B72F} static const GUID CLSID_QuickLaunchBand = { 0x260cb95d, 0x4544, 0x44f6, { 0xa0, 0x79, 0x57, 0x5b, 0xaa, 0x60, 0xb7, 0x2f } }; -//RegComCat function +//Componenet Category Registration HRESULT RegisterComCat() { ICatRegister *pcr; @@ -26,6 +26,18 @@ } return hr; } +HRESULT UnregisterComCat() +{ + ICatRegister *pcr; + HRESULT hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr); + if (SUCCEEDED(hr)) + { + CATID catid = CATID_DeskBand; + hr = pcr->UnRegisterClassImplCategories(CLSID_QuickLaunchBand, 1, &catid); + pcr->Release(); + } + return hr; +} //CQuickLaunchBand @@ -42,7 +54,9 @@ //IObjectWithSite HRESULT STDMETHODCALLTYPE CQuickLaunchBand::SetSite(IUnknown *pUnkSite) { - /*HRESULT hRet; + MessageBox(0, L"CQuickLaunchBand::SetSite called!", L"Testing", MB_OK | MB_ICONINFORMATION); + + HRESULT hRet; HWND hwndSite; TRACE("CQuickLaunchBand::SetSite(0x%p)\n", pUnkSite); @@ -53,19 +67,10 @@ TRACE("Querying site window failed: 0x%x\n", hRet); return hRet; } - - TRACE("CreateTaskSwitchWnd(Parent: 0x%p)\n", hwndSite); - - HWND hwndTaskSwitch = CreateTaskSwitchWnd(hwndSite, m_Tray); - if (!hwndTaskSwitch) - { - ERR("CreateTaskSwitchWnd failed"); - return E_FAIL; - } - - m_Site = pUnkSite; - m_hWnd = hwndTaskSwitch;*/ - + m_Site = pUnkSite; + + m_hWnd = CreateWindowEx(0, L"BUTTON", L"Quick Launch >>", WS_CHILD, CW_USEDEFAULT, CW_USEDEFAULT, 50, 50, hwndSite, 0, m_hInstance, 0); + return S_OK; } @@ -73,14 +78,16 @@ IN REFIID riid, OUT VOID **ppvSite) { + //MessageBox(0, L"GetSite called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); TRACE("CQuickLaunchBand::GetSite(0x%p,0x%p)\n", riid, ppvSite); - /* if (m_Site != NULL) + if (m_Site != NULL) { return m_Site->QueryInterface(riid, ppvSite); } - *ppvSite = NULL;*/ + *ppvSite = NULL; + return E_FAIL; } @@ -88,11 +95,14 @@ //IDeskBand HRESULT STDMETHODCALLTYPE CQuickLaunchBand::GetWindow(OUT HWND *phwnd) { - /*if (!m_hWnd) + //MessageBox(0, L"GetWindow called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); + + if (!m_hWnd) return E_FAIL; if (!phwnd) return E_INVALIDARG; - *phwnd = m_hWnd;*/ + *phwnd = m_hWnd; + return S_OK; } @@ -100,20 +110,36 @@ IN BOOL fEnterMode) { /* FIXME: Implement */ + + //MessageBox(0, L"ContextSensitiveHelp called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::ShowDW( IN BOOL bShow) { + //MessageBox(0, L"ShowDW called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); /* We don't do anything... */ + if (m_hWnd) + { + ShowWindow(m_hWnd, bShow ? SW_SHOW : SW_HIDE); + } + return S_OK; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::CloseDW( IN DWORD dwReserved) { + //MessageBox(0, L"CloseDW called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); /* We don't do anything... */ + if (m_hWnd) + { + ShowWindow(m_hWnd, SW_HIDE); + DestroyWindow(m_hWnd); + m_hWnd = NULL; + } + return S_OK; } @@ -123,6 +149,8 @@ BOOL fReserved) { /* No need to implement this method */ + + //MessageBox(0, L"ResizeBorderDW called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return E_NOTIMPL; } @@ -131,7 +159,58 @@ IN DWORD dwViewMode, IN OUT DESKBANDINFO *pdbi) { - TRACE("CQuickLaunchBand::GetBandInfo(0x%x,0x%x,0x%p) hWnd=0x%p\n", dwBandID, dwViewMode, pdbi, m_hWnd); + //MessageBox(0, L"GetBandInfo called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); + TRACE("CTaskBand::GetBandInfo(0x%x,0x%x,0x%p) hWnd=0x%p\n", dwBandID, dwViewMode, pdbi, m_hWnd); + + if (m_hWnd != NULL) + { + /* The task band never has a title */ + pdbi->dwMask &= ~DBIM_TITLE; + + /* NOTE: We don't return DBIMF_UNDELETEABLE here, the band site will + handle us differently and add this flag for us. The reason for + this is future changes that might allow it to be deletable. + We want the band site to be in charge of this decision rather + the band itself! */ + /* FIXME: What about DBIMF_NOGRIPPER and DBIMF_ALWAYSGRIPPER */ + pdbi->dwModeFlags = DBIMF_VARIABLEHEIGHT; + + if (dwViewMode & DBIF_VIEWMODE_VERTICAL) + { + pdbi->ptIntegral.y = 1; + pdbi->ptMinSize.y = 1; + /* FIXME: Get the button metrics from the task bar object!!! */ + pdbi->ptMinSize.x = (3 * GetSystemMetrics(SM_CXEDGE) / 2) + /* FIXME: Might be wrong if only one column! */ + GetSystemMetrics(SM_CXSIZE) + (2 * GetSystemMetrics(SM_CXEDGE)); /* FIXME: Min button size, query!!! */ + } + else + { + /* When the band is horizontal its minimum height is the height of the start button */ + RECT rcButton; + GetWindowRect(m_hWndStartButton, &rcButton); + pdbi->ptMinSize.y = rcButton.bottom - rcButton.top; + pdbi->ptIntegral.y = pdbi->ptMinSize.y + (3 * GetSystemMetrics(SM_CYEDGE) / 2); /* FIXME: Query metrics */ + /* We're not going to allow task bands where not even the minimum button size fits into the band */ + pdbi->ptMinSize.x = pdbi->ptIntegral.y; + } + + /* Ignored: pdbi->ptMaxSize.x */ + pdbi->ptMaxSize.y = -1; + + /* FIXME: We should query the height from the task bar object!!! */ + pdbi->ptActual.y = GetSystemMetrics(SM_CYSIZE) + (2 * GetSystemMetrics(SM_CYEDGE)); + + /* Save the band ID for future use in case we need to check whether a given band + is the task band */ + m_BandID = dwBandID; + + TRACE("H: %d, Min: %d,%d, Integral.y: %d Actual: %d,%d\n", (dwViewMode & DBIF_VIEWMODE_VERTICAL) == 0, + pdbi->ptMinSize.x, pdbi->ptMinSize.y, pdbi->ptIntegral.y, + pdbi->ptActual.x, pdbi->ptActual.y); + + return S_OK; + } + return E_FAIL; } @@ -141,6 +220,8 @@ IN IUnknown *punkClient) { TRACE("IDeskBar::SetClient(0x%p)\n", punkClient); + + //MessageBox(0, L"SetClient called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return E_NOTIMPL; } @@ -148,16 +229,19 @@ OUT IUnknown **ppunkClient) { TRACE("IDeskBar::GetClient(0x%p)\n", ppunkClient); + + //MessageBox(0, L"GetClient called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::OnPosRectChangeDB( IN RECT *prc) { - /*TRACE("IDeskBar::OnPosRectChangeDB(0x%p=(%d,%d,%d,%d))\n", prc, prc->left, prc->top, prc->right, prc->bottom); + TRACE("IDeskBar::OnPosRectChangeDB(0x%p=(%d,%d,%d,%d))\n", prc, prc->left, prc->top, prc->right, prc->bottom); if (prc->bottom - prc->top == 0) - return S_OK;*/ - + return S_OK; + + //MessageBox(0, L"OnPosRectChangeDB called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return S_FALSE; } @@ -166,15 +250,19 @@ HRESULT STDMETHODCALLTYPE CQuickLaunchBand::GetClassID( OUT CLSID *pClassID) { + //MessageBox(0, L"GetClassID called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); TRACE("CQuickLaunchBand::GetClassID(0x%p)\n", pClassID); - /* We're going to return the (internal!) CLSID of the task band interface */ + /* We're going to return the (internal!) CLSID of the quick launch band */ *pClassID = CLSID_QuickLaunchBand; + return S_OK; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::IsDirty() { /* The object hasn't changed since the last save! */ + + //MessageBox(0, L"IsDirty called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return S_FALSE; } @@ -183,6 +271,8 @@ { TRACE("CQuickLaunchBand::Load called\n"); /* Nothing to do */ + + //MessageBox(0, L"Load called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return S_OK; } @@ -191,6 +281,8 @@ IN BOOL fClearDirty) { /* Nothing to do */ + + //MessageBox(0, L"Save called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return S_OK; } @@ -200,6 +292,8 @@ TRACE("CQuickLaunchBand::GetSizeMax called\n"); /* We don't need any space for the task band */ //pcbSize->QuadPart = 0; + + //MessageBox(0, L"GetSizeMax called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return S_OK; } @@ -214,30 +308,36 @@ OUT LRESULT *plrResult) { TRACE("CQuickLaunchBand: IWinEventHandler::ProcessMessage(0x%p, 0x%x, 0x%p, 0x%p, 0x%p)\n", hWnd, uMsg, wParam, lParam, plrResult); + + //MessageBox(0, L"ProcessMessage called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::ContainsWindow( IN HWND hWnd) { - /*if (hWnd == m_hWnd || + //MessageBox(0, L"ContainsWindow called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); + + if (hWnd == m_hWnd || IsChild(m_hWnd, hWnd)) { TRACE("CQuickLaunchBand::ContainsWindow(0x%p) returns S_OK\n", hWnd); return S_OK; - }*/ + } return S_FALSE; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult) - { - UNIMPLEMENTED; + { + //MessageBox(0, L"OnWinEvent called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); + UNIMPLEMENTED; return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::IsWindowOwner(HWND hWnd) { + //MessageBox(0, L"IsWindowOwner called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); return (hWnd == m_hWnd) ? S_OK : S_FALSE; } @@ -245,13 +345,14 @@ // *** IOleCommandTarget methods *** HRESULT STDMETHODCALLTYPE CQuickLaunchBand::QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText) { + //MessageBox(0, L"QueryStatus called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); UNIMPLEMENTED; return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CQuickLaunchBand::Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) { - /*if (IsEqualIID(*pguidCmdGroup, IID_IBandSite)) + if (IsEqualIID(*pguidCmdGroup, IID_IBandSite)) { return S_OK; } @@ -259,9 +360,11 @@ if (IsEqualIID(*pguidCmdGroup, IID_IDeskBand)) { return S_OK; - }*/ - + } + + //MessageBox(0, L"Exec called!", L"Test Caption", MB_OK | MB_ICONINFORMATION); UNIMPLEMENTED; + return E_NOTIMPL; } Modified: branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CQuickLaunchBand.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/shellext/reactos/dll/…
============================================================================== --- branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CQuickLaunchBand.h [iso-8859-1] (original) +++ branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/CQuickLaunchBand.h [iso-8859-1] Thu Jun 8 15:18:21 2017 @@ -9,8 +9,11 @@ extern const GUID CLSID_QuickLaunchBand; +//Component category registration HRESULT RegisterComCat(); +HRESULT UnregisterComCat(); +//COM class for quick launch class CQuickLaunchBand : public CComCoClass<CQuickLaunchBand, &CLSID_QuickLaunchBand>, public CComObjectRootEx<CComMultiThreadModelNoCS>, @@ -21,13 +24,16 @@ public IWinEventHandler, public IOleCommandTarget { + CComPtr<IUnknown> m_Site; + HINSTANCE m_hInstance; HWND m_hWnd; + HWND m_hWndStartButton; DWORD m_BandID; public: CQuickLaunchBand(); - virtual ~CQuickLaunchBand(); + virtual ~CQuickLaunchBand(); //IObjectWithSite Modified: branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/precomp.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/shellext/reactos/dll/…
============================================================================== --- branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/precomp.h [iso-8859-1] (original) +++ branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/precomp.h [iso-8859-1] Thu Jun 8 15:18:21 2017 @@ -38,16 +38,4 @@ #undef DbgPrint -#include "CQuickLaunchBand.h" - -/*extern HINSTANCE g_hInstance; - -#define ID_ICON_VOLUME (WM_APP + 0x4CB) - -// {845B0FB2-66E0-416B-8F91-314E23F7C12D} -DEFINE_GUID(CLSID_NtObjectFolder, - 0x845b0fb2, 0x66e0, 0x416b, 0x8f, 0x91, 0x31, 0x4e, 0x23, 0xf7, 0xc1, 0x2d); - -//#include "ntobjfolder.h" -//#include "regfolder.h" -*/ +#include "CQuickLaunchBand.h" Modified: branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/qcklnch.cpp URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/shellext/reactos/dll/…
============================================================================== --- branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/qcklnch.cpp [iso-8859-1] (original) +++ branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/qcklnch.cpp [iso-8859-1] Thu Jun 8 15:18:21 2017 @@ -56,7 +56,12 @@ STDAPI DllUnregisterServer(void) { - return g_Module.DllUnregisterServer(FALSE); + HRESULT hr = g_Module.DllUnregisterServer(FALSE); + + if (FAILED(hr)) + return hr; + else + return UnregisterComCat(); } STDAPI Modified: branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/rgs/qcklnch.rgs URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/shellext/reactos/dll/…
============================================================================== --- branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/rgs/qcklnch.rgs [iso-8859-1] (original) +++ branches/GSoC_2017/shellext/reactos/dll/shellext/qcklnch/rgs/qcklnch.rgs [iso-8859-1] Thu Jun 8 15:18:21 2017 @@ -2,7 +2,7 @@ { NoRemove CLSID { - ForceRemove {260CB95D-4544-44F6-A079-575BAA60B72F} = s 'QuickLaunchBand' + ForceRemove {260CB95D-4544-44F6-A079-575BAA60B72F} = s 'Quick Launch' { InprocServer32 = s '%MODULE%' { Modified: branches/GSoC_2017/shellext/reactos/media/inf/syssetup.inf URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/shellext/reactos/medi…
============================================================================== --- branches/GSoC_2017/shellext/reactos/media/inf/syssetup.inf [iso-8859-1] (original) +++ branches/GSoC_2017/shellext/reactos/media/inf/syssetup.inf [iso-8859-1] Thu Jun 8 15:18:21 2017 @@ -85,6 +85,7 @@ 11,,olepro32.dll,1 11,,propsys.dll,1 11,,pstorec.dll,1 +11,,qcklnch.dll,1 11,,qedit.dll,1 11,,qmgr.dll,1 11,,qmgrprxy.dll,1
[View Less]
7 years, 10 months
1
0
0
0
[gadamopoulos] 74960: [UXTHEME] -Implement support for non rectangular caption buttons in WM_NCHITTEST handling. Please note that non rectangular buttons or buttons with no gaps between them are HA...
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Thu Jun 8 14:27:52 2017 New Revision: 74960 URL:
http://svn.reactos.org/svn/reactos?rev=74960&view=rev
Log: [UXTHEME] -Implement support for non rectangular caption buttons in WM_NCHITTEST handling. Please note that non rectangular buttons or buttons with no gaps between them are HACKY for XP so hittesting will never work properly (we really mimic windows xp here). Cache the position of caption buttons in the WINDOWINFO. CORE-13171 Modified: trunk/reactos/
…
[View More]
dll/win32/uxtheme/nonclient.c trunk/reactos/dll/win32/uxtheme/themehooks.c trunk/reactos/dll/win32/uxtheme/uxthemep.h Modified: trunk/reactos/dll/win32/uxtheme/nonclient.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/uxtheme/nonclien…
============================================================================== --- trunk/reactos/dll/win32/uxtheme/nonclient.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/uxtheme/nonclient.c [iso-8859-1] Thu Jun 8 14:27:52 2017 @@ -222,15 +222,88 @@ pcontext->hDC = pcontext->hDCScreen; } +void ThemeCalculateCaptionButtonsPos(HWND hWnd, HTHEME htheme) +{ + PWND_DATA pwndData; + DWORD style; + INT ButtonWidth, ButtonHeight, iPartId, i; + WINDOWINFO wi = {sizeof(wi)}; + RECT rcCurrent; + + /* First of all check if we have something to do here */ + style = GetWindowLongW(hWnd, GWL_STYLE); + if((style & (WS_CAPTION | WS_SYSMENU)) != (WS_CAPTION | WS_SYSMENU)) + return; + + /* Get theme data for this window */ + pwndData = ThemeGetWndData(hWnd); + if (pwndData == NULL) + return; + + if (!htheme) + htheme = pwndData->hthemeWindow; + + if(!GetWindowInfo(hWnd, &wi)) + return; + + /* Calculate the area of the caption */ + rcCurrent.top = rcCurrent.left = 0; + rcCurrent.right = wi.rcWindow.right - wi.rcWindow.left; + rcCurrent.bottom = wi.rcWindow.bottom - wi.rcWindow.top; + + /* Add a padding around the objects of the caption */ + InflateRect(&rcCurrent, -(int)wi.cyWindowBorders-BUTTON_GAP_SIZE, + -(int)wi.cyWindowBorders-BUTTON_GAP_SIZE); + + for (i = CLOSEBUTTON; i <= HELPBUTTON; i++) + { + SIZE ButtonSize; + + switch(i) + { + case CLOSEBUTTON: + iPartId = wi.dwExStyle & WS_EX_TOOLWINDOW ? WP_SMALLCLOSEBUTTON : WP_CLOSEBUTTON; + break; + + case MAXBUTTON: + iPartId = wi.dwStyle & WS_MAXIMIZE ? WP_RESTOREBUTTON : WP_MAXBUTTON; + break; + + case MINBUTTON: + iPartId = wi.dwStyle & WS_MINIMIZE ? WP_RESTOREBUTTON : WP_MINBUTTON; + break; + + default: + iPartId = WP_HELPBUTTON ; + } + + GetThemePartSize(htheme, NULL, iPartId, 0, NULL, TS_MIN, &ButtonSize); + + ButtonHeight = GetSystemMetrics( wi.dwExStyle & WS_EX_TOOLWINDOW ? SM_CYSMSIZE : SM_CYSIZE); + ButtonWidth = MulDiv(ButtonSize.cx, ButtonHeight, ButtonSize.cy); + + ButtonHeight -= 4; + ButtonWidth -= 4; + + SetRect(&pwndData->rcCaptionButtons[i], + rcCurrent.right - ButtonWidth, + rcCurrent.top, + rcCurrent.right, + rcCurrent.top + ButtonHeight); + + rcCurrent.right -= ButtonWidth + BUTTON_GAP_SIZE; + } +} + static void ThemeDrawCaptionButton(PDRAW_CONTEXT pcontext, - RECT* prcCurrent, CAPTIONBUTTON buttonId, INT iStateId) { - RECT rcPart; - INT ButtonWidth, ButtonHeight, iPartId; - SIZE ButtonSize; + INT iPartId; + PWND_DATA pwndData = ThemeGetWndData(pcontext->hWnd); + if (!pwndData) + return; switch(buttonId) { @@ -267,22 +340,7 @@ return; } - GetThemePartSize(pcontext->theme, pcontext->hDC, iPartId, 0, NULL, TS_MIN, &ButtonSize); - - ButtonHeight = GetSystemMetrics( pcontext->wi.dwExStyle & WS_EX_TOOLWINDOW ? SM_CYSMSIZE : SM_CYSIZE); - ButtonWidth = MulDiv(ButtonSize.cx, ButtonHeight, ButtonSize.cy); - - ButtonHeight -= 4; - ButtonWidth -= 4; - - /* Calculate the position */ - rcPart.top = prcCurrent->top; - rcPart.right = prcCurrent->right; - rcPart.bottom = rcPart.top + ButtonHeight ; - rcPart.left = rcPart.right - ButtonWidth ; - prcCurrent->right -= ButtonWidth + BUTTON_GAP_SIZE; - - DrawThemeBackground(pcontext->theme, pcontext->hDC, iPartId, iStateId, &rcPart, NULL); + DrawThemeBackground(pcontext->theme, pcontext->hDC, iPartId, iStateId, &pwndData->rcCaptionButtons[buttonId], NULL); } static DWORD @@ -302,25 +360,14 @@ static void ThemeDrawCaptionButtons(PDRAW_CONTEXT pcontext, DWORD htHot, DWORD htDown) { - RECT rcCurrent; - - /* Calculate the area of the caption */ - rcCurrent.top = rcCurrent.left = 0; - rcCurrent.right = pcontext->wi.rcWindow.right - pcontext->wi.rcWindow.left; - rcCurrent.bottom = pcontext->CaptionHeight; - - /* Add a padding around the objects of the caption */ - InflateRect(&rcCurrent, -(int)pcontext->wi.cyWindowBorders-BUTTON_GAP_SIZE, - -(int)pcontext->wi.cyWindowBorders-BUTTON_GAP_SIZE); - /* Draw the buttons */ - ThemeDrawCaptionButton(pcontext, &rcCurrent, CLOSEBUTTON, + ThemeDrawCaptionButton(pcontext, CLOSEBUTTON, ThemeGetButtonState(HTCLOSE, htHot, htDown, pcontext->Active)); - ThemeDrawCaptionButton(pcontext, &rcCurrent, MAXBUTTON, + ThemeDrawCaptionButton(pcontext, MAXBUTTON, ThemeGetButtonState(HTMAXBUTTON, htHot, htDown, pcontext->Active)); - ThemeDrawCaptionButton(pcontext, &rcCurrent, MINBUTTON, + ThemeDrawCaptionButton(pcontext, MINBUTTON, ThemeGetButtonState(HTMINBUTTON, htHot, htDown, pcontext->Active)); - ThemeDrawCaptionButton(pcontext, &rcCurrent, HELPBUTTON, + ThemeDrawCaptionButton(pcontext, HELPBUTTON, ThemeGetButtonState(HTHELP, htHot, htDown, pcontext->Active)); } @@ -366,10 +413,10 @@ { iState = pcontext->Active ? BUTTON_NORMAL : BUTTON_INACTIVE; - ThemeDrawCaptionButton(pcontext, &rcPart, CLOSEBUTTON, iState); - ThemeDrawCaptionButton(pcontext, &rcPart, MAXBUTTON, iState); - ThemeDrawCaptionButton(pcontext, &rcPart, MINBUTTON, iState); - ThemeDrawCaptionButton(pcontext, &rcPart, HELPBUTTON, iState); + ThemeDrawCaptionButton(pcontext, CLOSEBUTTON, iState); + ThemeDrawCaptionButton(pcontext, MAXBUTTON, iState); + ThemeDrawCaptionButton(pcontext, MINBUTTON, iState); + ThemeDrawCaptionButton(pcontext, HELPBUTTON, iState); } rcPart.top += 3 ; @@ -851,23 +898,11 @@ if (!PtInRect(&WindowRect, Point)) { - INT ButtonWidth; - - if (wi.dwExStyle & WS_EX_TOOLWINDOW) - ButtonWidth = GetSystemMetrics(SM_CXSMSIZE); - else - ButtonWidth = GetSystemMetrics(SM_CXSIZE); - - ButtonWidth -= 4; - ButtonWidth += BUTTON_GAP_SIZE; - if (wi.dwStyle & WS_SYSMENU) { - if (wi.dwExStyle & WS_EX_TOOLWINDOW) - { - WindowRect.right -= ButtonWidth; - } - else + PWND_DATA pwndData = ThemeGetWndData(hWnd); + + if (!(wi.dwExStyle & WS_EX_TOOLWINDOW)) { // if(!(wi.dwExStyle & WS_EX_DLGMODALFRAME)) // FIXME: The real test should check whether there is @@ -876,22 +911,22 @@ // See win32ss/user/user32/windows/nonclient.c!DefWndNCHitTest // and win32ss/user/ntuser/nonclient.c!GetNCHitEx which does // the test better. - WindowRect.left += ButtonWidth; - WindowRect.right -= ButtonWidth; + WindowRect.left += GetSystemMetrics(SM_CXSMICON); + } + + if (pwndData) + { + POINT pt = {Point.x - wi.rcWindow.left, Point.y - wi.rcWindow.top}; + if (PtInRect(&pwndData->rcCaptionButtons[CLOSEBUTTON], pt)) + return HTCLOSE; + if (PtInRect(&pwndData->rcCaptionButtons[MAXBUTTON], pt)) + return HTMAXBUTTON; + if (PtInRect(&pwndData->rcCaptionButtons[MINBUTTON], pt)) + return HTMINBUTTON; } } if (Point.x < WindowRect.left) return HTSYSMENU; - if (WindowRect.right <= Point.x) - return HTCLOSE; - if (wi.dwStyle & WS_MAXIMIZEBOX || wi.dwStyle & WS_MINIMIZEBOX) - WindowRect.right -= ButtonWidth; - if (Point.x >= WindowRect.right) - return HTMAXBUTTON; - if (wi.dwStyle & WS_MINIMIZEBOX) - WindowRect.right -= ButtonWidth; - if (Point.x >= WindowRect.right) - return HTMINBUTTON; return HTCAPTION; } } @@ -1111,8 +1146,12 @@ /* Paint the window on the preview hDC */ rcCurrent = context.wi.rcWindow; + OffsetRect( &rcCurrent, -context.wi.rcWindow.left, -context.wi.rcWindow.top); + SetViewportOrgEx(hDC, context.wi.rcWindow.left, context.wi.rcWindow.top, NULL); + ThemeCalculateCaptionButtonsPos(hwndDummy, context.theme); ThemePaintWindow(&context, &rcCurrent, FALSE); - + SetViewportOrgEx(hDC, 0, 0, NULL); + context.hDC = NULL; CloseThemeData (context.theme); CloseThemeData (context.scrolltheme); Modified: trunk/reactos/dll/win32/uxtheme/themehooks.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/uxtheme/themehoo…
============================================================================== --- trunk/reactos/dll/win32/uxtheme/themehooks.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/uxtheme/themehooks.c [iso-8859-1] Thu Jun 8 14:27:52 2017 @@ -286,6 +286,14 @@ { switch(Msg) { + case WM_CREATE: + case WM_STYLECHANGED: + case WM_SIZE: + case WM_WINDOWPOSCHANGED: + { + ThemeCalculateCaptionButtonsPos(hWnd, NULL); + break; + } case WM_THEMECHANGED: { PWND_DATA pwndData = ThemeGetWndData(hWnd); @@ -319,6 +327,8 @@ CloseThemeData(pwndData->hthemeScrollbar); pwndData->hthemeScrollbar = NULL; } + + ThemeCalculateCaptionButtonsPos(hWnd, NULL); } case WM_NCCREATE: { Modified: trunk/reactos/dll/win32/uxtheme/uxthemep.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/uxtheme/uxthemep…
============================================================================== --- trunk/reactos/dll/win32/uxtheme/uxthemep.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/uxtheme/uxthemep.h [iso-8859-1] Thu Jun 8 14:27:52 2017 @@ -151,6 +151,7 @@ HTHEME hthemeWindow; HTHEME hthemeScrollbar; + RECT rcCaptionButtons[4]; UINT lastHitTest; BOOL HasAppDefinedRgn; BOOL HasThemeRgn; @@ -239,6 +240,7 @@ #define SCROLL_MIN_RECT 4 LRESULT CALLBACK ThemeWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, WNDPROC DefWndProc); +void ThemeCalculateCaptionButtonsPos(HWND hWnd, HTHEME htheme); void ThemeDrawScrollBar(PDRAW_CONTEXT pcontext, INT Bar, POINT* pt); VOID NC_TrackScrollBar(HWND Wnd, WPARAM wParam, POINT Pt); void ThemeInitDrawContext(PDRAW_CONTEXT pcontext, HWND hWnd, HRGN hRgn);
[View Less]
7 years, 10 months
1
0
0
0
[rgampa] 74959: [USBXHCI] -defined register address offsets and elaborate naming given for register internals -XHCI_startController and intialise hardware functions are implementd. -in rothub.c XHC...
by rgampa@svn.reactos.org
Author: rgampa Date: Thu Jun 8 13:57:41 2017 New Revision: 74959 URL:
http://svn.reactos.org/svn/reactos?rev=74959&view=rev
Log: [USBXHCI] -defined register address offsets and elaborate naming given for register internals -XHCI_startController and intialise hardware functions are implementd. -in rothub.c XHCI_RH_GetRootHubData function is implemented. -In this version both usbport and usbxhci drivers are being loaded successfully. CORE-13344 Modified: branches/GSoC_2017/usbxhci/
…
[View More]
reactos/drivers/usb/usbxhci/hardware.h branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/roothub.c branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.c branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.h Modified: branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/hardware.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/usbxhci/reactos/drive…
============================================================================== --- branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/hardware.h [iso-8859-1] (original) +++ branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/hardware.h [iso-8859-1] Thu Jun 8 13:57:41 2017 @@ -1,11 +1,25 @@ /* XHCI hardware registers */ +#define XHCI_HCSP1 1 +#define XHCI_HCSP2 2 +#define XHCI_HCSP3 3 +#define XHCI_HCCP1 4 +#define XHCI_DBOFF 5 +#define XHCI_HCCP2 6 + +#define XHCI_USBCMD 0 +#define XHCI_USBSTS 1 +#define XHCI_DNCTRL 5 +#define XHCI_CRCR 6 +#define XHCI_DCBAAP 12 +#define XHCI_CONFIG 14 + typedef union _XHCI_HC_STRUCTURAL_PARAMS_1 { struct { - ULONG MaxDeviceSlots : 8; - ULONG MaxInterrupters : 11; - ULONG Rsvd : 5; - ULONG MaxPorts : 8; + ULONG NumberOfDeviceSlots : 8; + ULONG NumberOfInterrupters : 11; + ULONG Rsvd : 5; + ULONG NumberOfPorts : 8; }; ULONG AsULONG; } XHCI_HC_STRUCTURAL_PARAMS_1; @@ -82,37 +96,37 @@ typedef union _XHCI_USB_COMMAND { struct { - ULONG RunStop : 1; - ULONG HCReset : 1; - ULONG INTEnable : 1; - ULONG HSEEnable : 1; - ULONG RsvdP1 : 3; - ULONG LHCReset : 1; - ULONG CSS : 1; - ULONG CRS : 1; - ULONG EWE : 1; - ULONG EU3S : 1; - ULONG RsvdP2 : 1; - ULONG CME : 1; - ULONG RsvdP3 : 18; + ULONG RunStop : 1; + ULONG HCReset : 1; + ULONG InterrupterEnable : 1; + ULONG HostSystemErrorEnable : 1; + ULONG RsvdP1 : 3; + ULONG LightHCReset : 1; + ULONG ControllerSaveState : 1; + ULONG ControllerRestoreState : 1; + ULONG EnableWrapEvent : 1; + ULONG EnableU3Stop : 1; + ULONG RsvdP2 : 1; + ULONG CEMEnable : 1; + ULONG RsvdP3 : 18; }; ULONG AsULONG; } XHCI_USB_COMMAND; typedef union _XHCI_USB_STATUS { struct { - ULONG HCH : 1; - ULONG RsvdZ1 : 1; - ULONG HSE : 1; - ULONG EINT : 1; - ULONG PCD : 1; - ULONG RsvdZ2 : 3; - ULONG SSS : 1; - ULONG RSS : 1; - ULONG SRE : 1; - ULONG CNR : 1; - ULONG HCE : 1; - ULONG RsvdZ3 : 19; + ULONG HCHalted : 1; + ULONG RsvdZ1 : 1; + ULONG HostSystemError : 1; + ULONG EventInterrupt : 1; + ULONG PortChangeDetect : 1; + ULONG RsvdZ2 : 3; + ULONG SaveStateStatus : 1; + ULONG RestoreStateStatus : 1; + ULONG SaveRestoreError : 1; + ULONG ControllerNotReady : 1; + ULONG HCError : 1; + ULONG RsvdZ3 : 19; }; ULONG AsULONG; } XHCI_USB_STATUS; Modified: branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/roothub.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/usbxhci/reactos/drive…
============================================================================== --- branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/roothub.c [iso-8859-1] (original) +++ branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/roothub.c [iso-8859-1] Thu Jun 8 13:57:41 2017 @@ -11,7 +11,28 @@ XHCI_RH_GetRootHubData(IN PVOID xhciExtension, IN PVOID rootHubData) { - + PXHCI_EXTENSION XhciExtension; + PUSBPORT_ROOT_HUB_DATA RootHubData; + + XhciExtension = (PXHCI_EXTENSION)xhciExtension; + + DPRINT_RH("XHCI_RH_GetRootHubData: XhciExtension - %p, rootHubData - %p\n", + XhciExtension, + rootHubData); + + RootHubData = (PUSBPORT_ROOT_HUB_DATA)rootHubData; + + RootHubData->NumberOfPorts = XhciExtension->NumberOfPorts; + + + /* + Identifies a Compound Device: Hub is not part of a compound device. + Over-current Protection Mode: Global Over-current Protection. + */ + RootHubData->HubCharacteristics &= 3; + + RootHubData->PowerOnToPowerGood = 2; + RootHubData->HubControlCurrent = 0; } MPSTATUS Modified: branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.c URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/usbxhci/reactos/drive…
============================================================================== --- branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.c [iso-8859-1] (original) +++ branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.c [iso-8859-1] Thu Jun 8 13:57:41 2017 @@ -7,193 +7,6 @@ USBPORT_REGISTRATION_PACKET RegPacket; - -//---------------------------------------roothub functions copied over----------------------------------------------- - -/* -VOID -NTAPI -XHCI_RH_GetRootHubData(IN PVOID xhciExtension, - IN PVOID rootHubData) -{ - -} - -MPSTATUS -NTAPI -XHCI_RH_GetStatus(IN PVOID xhciExtension, - IN PUSHORT Status) -{ - - return 0; -} - -MPSTATUS -NTAPI -XHCI_RH_GetPortStatus(IN PVOID xhciExtension, - IN USHORT Port, - IN PULONG PortStatus) -{ - - - return 0; -} - -MPSTATUS -NTAPI -XHCI_RH_GetHubStatus(IN PVOID xhciExtension, - IN PULONG HubStatus) -{ - - return 0; -} - -VOID -NTAPI -XHCI_RH_FinishReset(IN PVOID xhciExtension, - IN PUSHORT Port) -{ - -} - -ULONG -NTAPI -XHCI_RH_PortResetComplete(IN PVOID xhciExtension, - IN PUSHORT Port) -{ - return 0; -} - -MPSTATUS -NTAPI -XHCI_RH_SetFeaturePortReset(IN PVOID xhciExtension, - IN USHORT Port) -{ - - return 0; -} - -MPSTATUS -NTAPI -XHCI_RH_SetFeaturePortPower(IN PVOID xhciExtension, - IN USHORT Port) -{ - - return 0; -} -MPSTATUS -NTAPI -XHCI_RH_SetFeaturePortEnable(IN PVOID xhciExtension, - IN USHORT Port) -{ - DPRINT_RH("XHCI_RH_SetFeaturePortEnable: Not supported\n"); - return 0; -} - -MPSTATUS -NTAPI -XHCI_RH_SetFeaturePortSuspend(IN PVOID xhciExtension, - IN USHORT Port) -{ - - return 0; -} - -MPSTATUS -NTAPI -XHCI_RH_ClearFeaturePortEnable(IN PVOID xhciExtension, - IN USHORT Port) -{ - - return 0; -} - -MPSTATUS -NTAPI -XHCI_RH_ClearFeaturePortPower(IN PVOID xhciExtension, - IN USHORT Port) -{ - - return 0; -} - -VOID -NTAPI -XHCI_RH_PortResumeComplete(IN PULONG xhciExtension, - IN PUSHORT Port) -{ - -} - -MPSTATUS -NTAPI -XHCI_RH_ClearFeaturePortSuspend(IN PVOID xhciExtension, - IN USHORT Port) -{ - - return 0; -} - -MPSTATUS -NTAPI -XHCI_RH_ClearFeaturePortEnableChange(IN PVOID xhciExtension, - IN USHORT Port) -{ - - return 0; -} - -MPSTATUS -NTAPI -XHCI_RH_ClearFeaturePortConnectChange(IN PVOID xhciExtension, - IN USHORT Port) -{ - return 0; -} - -MPSTATUS -NTAPI -XHCI_RH_ClearFeaturePortResetChange(IN PVOID xhciExtension, - IN USHORT Port) -{ - return 0; -} - -MPSTATUS -NTAPI -XHCI_RH_ClearFeaturePortSuspendChange(IN PVOID xhciExtension, - IN USHORT Port) -{ - - return 0; -} - -MPSTATUS -NTAPI -XHCI_RH_ClearFeaturePortOvercurrentChange(IN PVOID xhciExtension, - IN USHORT Port) -{ - - return 0; -} - -VOID -NTAPI -XHCI_RH_DisableIrq(IN PVOID xhciExtension) -{ - -} - -VOID -NTAPI -XHCI_RH_EnableIrq(IN PVOID xhciExtension) -{ - -} - -*/ - -//------------------------------------------------------------------------------------------------------------------- MPSTATUS NTAPI @@ -233,10 +46,133 @@ MPSTATUS NTAPI +XHCI_InitializeSchedule(IN PXHCI_EXTENSION XhciExtension, + IN PVOID resourcesStartVA, + IN PVOID resourcesStartPA) +{ + return MP_STATUS_SUCCESS; +} + +MPSTATUS +NTAPI +XHCI_InitializeHardware(IN PXHCI_EXTENSION XhciExtension) +{ + PULONG BaseIoAdress; + PULONG OperationalRegs; + XHCI_USB_COMMAND Command; + XHCI_USB_STATUS Status; + LARGE_INTEGER CurrentTime = {{0, 0}}; + LARGE_INTEGER LastTime = {{0, 0}}; + XHCI_HC_STRUCTURAL_PARAMS_1 StructuralParams_1; + + DPRINT1("EHCI_InitializeHardware: ... \n"); + + OperationalRegs = XhciExtension->OperationalRegs; + BaseIoAdress = XhciExtension->BaseIoAdress; + + + KeQuerySystemTime(&CurrentTime); + CurrentTime.QuadPart += 100 * 10000; // 100 msec + + Status.AsULONG = READ_REGISTER_ULONG(OperationalRegs + XHCI_USBSTS); + ASSERT(Status.ControllerNotReady != 1); // this is needed before writing anything to the operaational or doorbell registers + + Command.AsULONG = READ_REGISTER_ULONG(OperationalRegs + XHCI_USBCMD); + Command.HCReset = 1; + while(TRUE) + { + KeQuerySystemTime(&LastTime); + + Command.AsULONG = READ_REGISTER_ULONG(OperationalRegs + XHCI_USBCMD); + + if (Command.HCReset != 1) + { + break; + } + + if (LastTime.QuadPart >= CurrentTime.QuadPart) + { + if (Command.HCReset == 1) + { + DPRINT1("EHCI_InitializeHardware: Software Reset failed!\n"); + return 7; + } + + break; + } + } + DPRINT("EHCI_InitializeHardware: Reset - OK\n"); + + StructuralParams_1.AsULONG = READ_REGISTER_ULONG(BaseIoAdress + XHCI_HCSP1); // HCSPARAMS1 register + + XhciExtension->NumberOfPorts = StructuralParams_1.NumberOfPorts; + //EhciExtension->PortPowerControl = StructuralParams.PortPowerControl; + DbgBreakPoint(); + return MP_STATUS_SUCCESS; +} + +MPSTATUS +NTAPI XHCI_StartController(IN PVOID xhciExtension, IN PUSBPORT_RESOURCES Resources) { - DPRINT1("XHCI_StartController: UNIMPLEMENTED. FIXME\n"); + PXHCI_EXTENSION XhciExtension; + PULONG BaseIoAdress; + PULONG OperationalRegs; + MPSTATUS MPStatus; + XHCI_USB_COMMAND Command; + UCHAR CapabilityRegLength; + UCHAR Fladj; + + DPRINT1("XHCI_StartController: function initiated\n"); + + if ((Resources->TypesResources & (USBPORT_RESOURCES_MEMORY | USBPORT_RESOURCES_INTERRUPT)) != + (USBPORT_RESOURCES_MEMORY | USBPORT_RESOURCES_INTERRUPT)) + { + DPRINT1("XHCI_StartController: Resources->TypesResources - %x\n", + Resources->TypesResources); + + return MP_STATUS_ERROR; + } + XhciExtension = (PXHCI_EXTENSION)xhciExtension; + + BaseIoAdress = (PULONG)Resources->ResourceBase; + XhciExtension->BaseIoAdress = BaseIoAdress; + + CapabilityRegLength = (UCHAR)READ_REGISTER_ULONG(BaseIoAdress); + OperationalRegs = (PULONG)((ULONG)BaseIoAdress + CapabilityRegLength); + XhciExtension->OperationalRegs = OperationalRegs; + + DPRINT("XHCI_StartController: BaseIoAdress - %p\n", BaseIoAdress); + DPRINT("XHCI_StartController: OperationalRegs - %p\n", OperationalRegs); + + RegPacket.UsbPortReadWriteConfigSpace(XhciExtension, + 1, + &Fladj, + 0x61, + 1); + + XhciExtension->FrameLengthAdjustment = Fladj; + + MPStatus = XHCI_InitializeHardware(XhciExtension); + + if (MPStatus) + { + DPRINT1("XHCI_StartController: Unsuccessful InitializeHardware()\n"); + return MPStatus; + } + + MPStatus = XHCI_InitializeSchedule(XhciExtension, + Resources->StartVA, + Resources->StartPA); + + if (MPStatus) + { + DPRINT1("XHCI_StartController: Unsuccessful InitializeSchedule()\n"); + return MPStatus; + } + + //DPRINT1("XHCI_StartController: UNIMPLEMENTED. FIXME\n"); return MP_STATUS_SUCCESS; } Modified: branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.h URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/usbxhci/reactos/drive…
============================================================================== --- branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.h [iso-8859-1] (original) +++ branches/GSoC_2017/usbxhci/reactos/drivers/usb/usbxhci/usbxhci.h [iso-8859-1] Thu Jun 8 13:57:41 2017 @@ -19,6 +19,11 @@ PULONG BaseIoAdress; PULONG OperationalRegs; UCHAR FrameLengthAdjustment; + BOOLEAN IsStarted; + USHORT HcSystemErrors; + ULONG PortRoutingControl; + USHORT NumberOfPorts; // HCSPARAMS1 => N_PORTS + USHORT PortPowerControl; // HCSPARAMS => Port Power Control (PPC) } XHCI_EXTENSION, *PXHCI_EXTENSION;
[View Less]
7 years, 10 months
1
0
0
0
[ekohl] 74958: [NETAPI32] Add obsolete NetErrorLog and NetService functions.
by ekohl@svn.reactos.org
Author: ekohl Date: Thu Jun 8 09:34:31 2017 New Revision: 74958 URL:
http://svn.reactos.org/svn/reactos?rev=74958&view=rev
Log: [NETAPI32] Add obsolete NetErrorLog and NetService functions. Modified: trunk/reactos/dll/win32/netapi32/netapi32.spec trunk/reactos/dll/win32/netapi32/obsolete.c Modified: trunk/reactos/dll/win32/netapi32/netapi32.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netapi32/netapi3…
=====================================================
…
[View More]
========================= --- trunk/reactos/dll/win32/netapi32/netapi32.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netapi32/netapi32.spec [iso-8859-1] Thu Jun 8 09:34:31 2017 @@ -141,9 +141,9 @@ @ stub NetDfsSetStdContainerSecurity @ stub NetEnumerateComputerNames @ stdcall NetEnumerateTrustedDomains(wstr ptr) -@ stub NetErrorLogClear -@ stub NetErrorLogRead -@ stub NetErrorLogWrite +@ stdcall NetErrorLogClear(wstr wstr ptr) +@ stdcall NetErrorLogRead(wstr wstr ptr long ptr long long ptr long ptr ptr) +@ stdcall NetErrorLogWrite(ptr long wstr ptr long ptr long ptr) @ stdcall NetFileClose(wstr long) @ stdcall NetFileEnum(wstr wstr wstr long ptr long ptr ptr ptr) @ stdcall NetFileGetInfo(wstr long long ptr) @@ -216,10 +216,10 @@ @ stdcall NetServerTransportAddEx(wstr long ptr) @ stdcall NetServerTransportDel(wstr long ptr) @ stdcall NetServerTransportEnum(wstr long ptr long ptr ptr ptr) -@ stub NetServiceControl -@ stub NetServiceEnum -@ stub NetServiceGetInfo -@ stub NetServiceInstall +@ stdcall NetServiceControl(wstr wstr long long ptr) +@ stdcall NetServiceEnum(wstr long ptr long ptr ptr ptr) +@ stdcall NetServiceGetInfo(wstr wstr long ptr) +@ stdcall NetServiceInstall(wstr wstr long ptr ptr) @ stdcall NetSessionDel(wstr wstr wstr) @ stdcall NetSessionEnum(wstr wstr wstr long ptr long ptr ptr ptr) @ stdcall NetSessionGetInfo(wstr wstr wstr long ptr) Modified: trunk/reactos/dll/win32/netapi32/obsolete.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netapi32/obsolet…
============================================================================== --- trunk/reactos/dll/win32/netapi32/obsolete.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netapi32/obsolete.c [iso-8859-1] Thu Jun 8 09:34:31 2017 @@ -12,6 +12,9 @@ #include <lmalert.h> #include <lmaudit.h> #include <lmconfig.h> +#include <lmerrlog.h> +#include <lmmsg.h> +#include <lmsvc.h> WINE_DEFAULT_DEBUG_CHANNEL(netapi32); @@ -123,6 +126,52 @@ NET_API_STATUS WINAPI +NetErrorLogClear( + _In_opt_ LPCWSTR UncServerName, + _In_opt_ LPCWSTR BackupFile, + _In_opt_ LPBYTE Reserved) +{ + return ERROR_NOT_SUPPORTED; +} + + +NET_API_STATUS +WINAPI +NetErrorLogRead( + _In_opt_ LPCWSTR UncServerName, + _In_opt_ LPWSTR Reserved1, + _In_ LPHLOG ErrorLogHandle, + _In_ DWORD Offset, + _In_opt_ LPDWORD Reserved2, + _In_ DWORD Reserved3, + _In_ DWORD OffsetFlag, + _Deref_out_ LPBYTE *BufPtr, + _In_ DWORD PrefMaxSize, + _Out_ LPDWORD BytesRead, + _Out_ LPDWORD TotalAvailable) +{ + return ERROR_NOT_SUPPORTED; +} + + +NET_API_STATUS +WINAPI +NetErrorLogWrite( + _In_opt_ LPBYTE Reserved1, + _In_ DWORD Code, + _In_ LPCWSTR Component, + _In_ LPBYTE Buffer, + _In_ DWORD NumBytes, + _In_ LPBYTE MsgBuf, + _In_ DWORD StrCount, + _In_opt_ LPBYTE Reserved2) +{ + return ERROR_NOT_SUPPORTED; +} + + +NET_API_STATUS +WINAPI NetMessageBufferSend( _In_ LPCWSTR servername, _In_ LPCWSTR msgname, @@ -180,4 +229,57 @@ return ERROR_NOT_SUPPORTED; } + +NET_API_STATUS +WINAPI +NetServiceControl( + __in_opt LPCWSTR servername, + __in LPCWSTR service, + __in DWORD opcode, + __in DWORD arg, + __deref_out LPBYTE *bufptr) +{ + return ERROR_NOT_SUPPORTED; +} + + +NET_API_STATUS +WINAPI +NetServiceEnum( + __in_opt LPCWSTR servername, + __in DWORD level, + __deref_out LPBYTE *bufptr, + __in DWORD prefmaxlen, + __out LPDWORD entriesread, + __out LPDWORD totalentries, + __inout_opt LPDWORD resume_handle) +{ + return ERROR_NOT_SUPPORTED; +} + + +NET_API_STATUS +WINAPI +NetServiceGetInfo( + __in_opt LPCWSTR servername, + __in LPCWSTR service, + __in DWORD level, + __deref_out LPBYTE *bufptr) +{ + return ERROR_NOT_SUPPORTED; +} + + +NET_API_STATUS +WINAPI +NetServiceInstall( + __in_opt LPCWSTR servername, + __in LPCWSTR service, + __in DWORD argc, + __in_ecount(argc) LPCWSTR argv[], + __deref_out LPBYTE *bufptr) +{ + return ERROR_NOT_SUPPORTED; +} + /* EOF */
[View Less]
7 years, 10 months
1
0
0
0
[ekohl] 74957: [NETAPI32] Add obsolete NetAudit and NetConfig functions.
by ekohl@svn.reactos.org
Author: ekohl Date: Thu Jun 8 08:41:28 2017 New Revision: 74957 URL:
http://svn.reactos.org/svn/reactos?rev=74957&view=rev
Log: [NETAPI32] Add obsolete NetAudit and NetConfig functions. Modified: trunk/reactos/dll/win32/netapi32/netapi32.spec trunk/reactos/dll/win32/netapi32/obsolete.c Modified: trunk/reactos/dll/win32/netapi32/netapi32.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netapi32/netapi3…
=========================================================
…
[View More]
===================== --- trunk/reactos/dll/win32/netapi32/netapi32.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netapi32/netapi32.spec [iso-8859-1] Thu Jun 8 08:41:28 2017 @@ -106,13 +106,13 @@ @ stdcall NetApiBufferFree(ptr) @ stdcall NetApiBufferReallocate(ptr long ptr) @ stdcall NetApiBufferSize(ptr ptr) -@ stub NetAuditClear -@ stub NetAuditRead -@ stub NetAuditWrite +@ stdcall NetAuditClear(wstr wstr wstr) +@ stdcall NetAuditRead(wstr wstr ptr long ptr long long ptr long ptr ptr) +@ stdcall NetAuditWrite(long ptr long wstr ptr) @ stub NetBrowserStatisticsGet -@ stub NetConfigGet -@ stub NetConfigGetAll -@ stub NetConfigSet +@ stdcall NetConfigGet(wstr wstr wstr ptr) +@ stdcall NetConfigGetAll(wstr wstr ptr) +@ stdcall NetConfigSet(wstr wstr wstr long long ptr long) @ stub NetConnectionEnum @ stub NetDfsAdd @ stub NetDfsAddFtRoot Modified: trunk/reactos/dll/win32/netapi32/obsolete.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netapi32/obsolet…
============================================================================== --- trunk/reactos/dll/win32/netapi32/obsolete.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/netapi32/obsolete.c [iso-8859-1] Thu Jun 8 08:41:28 2017 @@ -9,6 +9,9 @@ /* INCLUDES ******************************************************************/ #include "netapi32.h" +#include <lmalert.h> +#include <lmaudit.h> +#include <lmconfig.h> WINE_DEFAULT_DEBUG_CHANNEL(netapi32); @@ -32,6 +35,87 @@ _In_ LPVOID VariableInfo, _In_ DWORD VariableInfoSize, _In_ LPCWSTR ServiceName) +{ + return ERROR_NOT_SUPPORTED; +} + + +NET_API_STATUS +WINAPI +NetAuditClear( + _In_opt_ LPCWSTR server, + _In_opt_ LPCWSTR backupfile, + _In_opt_ LPCWSTR service) +{ + return ERROR_NOT_SUPPORTED; +} + + +NET_API_STATUS +WINAPI +NetAuditRead( + _In_opt_ LPCWSTR server, + _In_opt_ LPCWSTR service, + _In_ LPHLOG auditloghandle, + _In_ DWORD offset, + _In_opt_ LPDWORD reserved1, + _In_ DWORD reserved2, + _In_ DWORD offsetflag, + _Out_ LPBYTE *bufptr, + _In_ DWORD prefmaxlen, + _Out_ LPDWORD bytesread, + _Out_ LPDWORD totalavailable) +{ + return ERROR_NOT_SUPPORTED; +} + + +NET_API_STATUS +WINAPI +NetAuditWrite( + _In_ DWORD type, + _In_ LPBYTE buf, + _In_ DWORD numbytes, + _In_opt_ LPCWSTR service, + _In_opt_ LPBYTE reserved) +{ + return ERROR_NOT_SUPPORTED; +} + + +NET_API_STATUS +WINAPI +NetConfigGet( + _In_opt_ LPCWSTR server, + _In_ LPCWSTR component, + _In_ LPCWSTR parameter, + _Out_ LPBYTE *bufptr) +{ + return ERROR_NOT_SUPPORTED; +} + + +NET_API_STATUS +WINAPI +NetConfigGetAll( + _In_opt_ LPCWSTR server, + _In_ LPCWSTR component, + _Out_ LPBYTE *bufptr) +{ + return ERROR_NOT_SUPPORTED; +} + + +NET_API_STATUS +WINAPI +NetConfigSet( + _In_opt_ LPCWSTR server, + _In_opt_ LPCWSTR reserved1, + _In_ LPCWSTR component, + _In_ DWORD level, + _In_ DWORD reserved2, + _In_ LPBYTE buf, + _In_ DWORD reserved3) { return ERROR_NOT_SUPPORTED; }
[View Less]
7 years, 10 months
1
0
0
0
[ekohl] 74956: [PSDK] Fix NetAuditRead and NetAuditWrite prototypes (LPTSTR->LPCWSTR).
by ekohl@svn.reactos.org
Author: ekohl Date: Thu Jun 8 08:37:59 2017 New Revision: 74956 URL:
http://svn.reactos.org/svn/reactos?rev=74956&view=rev
Log: [PSDK] Fix NetAuditRead and NetAuditWrite prototypes (LPTSTR->LPCWSTR). Modified: trunk/reactos/sdk/include/psdk/lmaudit.h Modified: trunk/reactos/sdk/include/psdk/lmaudit.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/lmaudit.h…
============================================================================== --- trunk/reactos/
…
[View More]
sdk/include/psdk/lmaudit.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/lmaudit.h [iso-8859-1] Thu Jun 8 08:37:59 2017 @@ -212,8 +212,8 @@ DWORD ae_ge_param9; } AE_GENERIC,*PAE_GENERIC,*LPAE_GENERIC; NET_API_STATUS WINAPI NetAuditClear(LPCWSTR,LPCWSTR,LPCWSTR); -NET_API_STATUS WINAPI NetAuditRead(LPTSTR,LPTSTR,LPHLOG,DWORD,PDWORD,DWORD,DWORD,PBYTE*,DWORD,PDWORD,PDWORD); -NET_API_STATUS WINAPI NetAuditWrite(DWORD,PBYTE,DWORD,LPTSTR,PBYTE); +NET_API_STATUS WINAPI NetAuditRead(LPCWSTR,LPCWSTR,LPHLOG,DWORD,PDWORD,DWORD,DWORD,PBYTE*,DWORD,PDWORD,PDWORD); +NET_API_STATUS WINAPI NetAuditWrite(DWORD,PBYTE,DWORD,LPCWSTR,PBYTE); /* These conflict with struct typedefs, why? */ #define AE_SRVSTATUS 0
[View Less]
7 years, 10 months
1
0
0
0
[pschweitzer] 74955: [KMTESTS:MM] Make MmMapLockedPagesSpecifyCache a bit more robust. Based on Thomas' suggestions
by pschweitzer@svn.reactos.org
Author: pschweitzer Date: Thu Jun 8 06:44:48 2017 New Revision: 74955 URL:
http://svn.reactos.org/svn/reactos?rev=74955&view=rev
Log: [KMTESTS:MM] Make MmMapLockedPagesSpecifyCache a bit more robust. Based on Thomas' suggestions Modified: trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_drv.c Modified: trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_drv.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/kmtests/ntos_mm/MmMapLock…
========================
…
[View More]
====================================================== --- trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_drv.c [iso-8859-1] (original) +++ trunk/rostests/kmtests/ntos_mm/MmMapLockedPagesSpecifyCache_drv.c [iso-8859-1] Thu Jun 8 06:44:48 2017 @@ -110,6 +110,9 @@ ok_eq_size(InLength, sizeof(QUERY_BUFFER)); ok_eq_size(*OutLength, sizeof(QUERY_BUFFER)); ok_eq_pointer(CurrentMdl, NULL); + + TestCleanEverything(); + ok(ExGetPreviousMode() == UserMode, "Not comming from umode!\n"); if (!skip(Buffer && InLength >= sizeof(QUERY_BUFFER) && *OutLength >= sizeof(QUERY_BUFFER), "Cannot read/write from/to buffer!\n")) { @@ -120,59 +123,66 @@ QueryBuffer = Buffer; CacheType = (QueryBuffer->Cached ? MmCached : MmNonCached); Length = QueryBuffer->Length; + CurrentUser = NULL; ok(Length > 0, "Null size!\n"); - CurrentBuffer = ExAllocatePoolWithTag(NonPagedPool, Length, 'MLPC'); - ok(CurrentBuffer != NULL, "ExAllocatePool failed!\n"); - CurrentUser = NULL; - if (!skip(CurrentBuffer != NULL, "ExAllocatePool failed!\n")) + if (!skip(Length > 0, "Null size!\n")) { - CurrentMdl = IoAllocateMdl(CurrentBuffer, Length, FALSE, FALSE, NULL); - ok(CurrentMdl != NULL, "IoAllocateMdl failed!\n"); - if (CurrentMdl) + CurrentBuffer = ExAllocatePoolWithTag(NonPagedPool, Length, 'MLPC'); + ok(CurrentBuffer != NULL, "ExAllocatePool failed!\n"); + if (!skip(CurrentBuffer != NULL, "ExAllocatePool failed!\n")) { - KIRQL Irql; - - SehStatus = STATUS_SUCCESS; - _SEH2_TRY + CurrentMdl = IoAllocateMdl(CurrentBuffer, Length, FALSE, FALSE, NULL); + ok(CurrentMdl != NULL, "IoAllocateMdl failed!\n"); + if (!skip(CurrentMdl != NULL, "IoAllocateMdl failed!\n")) { - MmProbeAndLockPages(CurrentMdl, KernelMode, IoWriteAccess); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - SehStatus = _SEH2_GetExceptionCode(); - } - _SEH2_END; - ok_eq_hex(SehStatus, STATUS_SUCCESS); - - Irql = KeGetCurrentIrql(); - ok(Irql <= APC_LEVEL, "IRQL > APC_LEVEL: %d\n", Irql); - - SehStatus = STATUS_SUCCESS; - _SEH2_TRY - { - CurrentUser = MmMapLockedPagesSpecifyCache(CurrentMdl, UserMode, CacheType, NULL, FALSE, NormalPagePriority); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - SehStatus = _SEH2_GetExceptionCode(); - } - _SEH2_END; - - if (QueryBuffer->Cached) - { + KIRQL Irql; + + SehStatus = STATUS_SUCCESS; + _SEH2_TRY + { + MmProbeAndLockPages(CurrentMdl, KernelMode, IoWriteAccess); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + SehStatus = _SEH2_GetExceptionCode(); + } + _SEH2_END; ok_eq_hex(SehStatus, STATUS_SUCCESS); - ok(CurrentUser != NULL, "MmMapLockedPagesSpecifyCache failed!\n"); + + Irql = KeGetCurrentIrql(); + ok(Irql <= APC_LEVEL, "IRQL > APC_LEVEL: %d\n", Irql); + + SehStatus = STATUS_SUCCESS; + _SEH2_TRY + { + CurrentUser = MmMapLockedPagesSpecifyCache(CurrentMdl, UserMode, CacheType, NULL, FALSE, NormalPagePriority); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + SehStatus = _SEH2_GetExceptionCode(); + } + _SEH2_END; + + if (QueryBuffer->Cached) + { + ok_eq_hex(SehStatus, STATUS_SUCCESS); + ok(CurrentUser != NULL, "MmMapLockedPagesSpecifyCache failed!\n"); + } + else + { + ok_eq_hex(SehStatus, STATUS_INVALID_ADDRESS); + ok_eq_pointer(CurrentUser, NULL); + } } else { - ok_eq_hex(SehStatus, STATUS_INVALID_ADDRESS); - ok_eq_pointer(CurrentUser, NULL); + ExFreePoolWithTag(CurrentBuffer, 'MLPC'); } } } + QueryBuffer->Buffer = CurrentUser; - *OutLength = sizeof(QUERY_BUFFER); }
[View Less]
7 years, 10 months
1
0
0
0
[hbelusca] 74954: [USETUP]: As evoked in r74943, adapt the code in bootsup.c to abstract the manipulation of freeldr.ini and boot.ini, and make it use the new features of bldrsup.c committed in r74...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Jun 8 02:43:51 2017 New Revision: 74954 URL:
http://svn.reactos.org/svn/reactos?rev=74954&view=rev
Log: [USETUP]: As evoked in r74943, adapt the code in bootsup.c to abstract the manipulation of freeldr.ini and boot.ini, and make it use the new features of bldrsup.c committed in r74952. In particular the helper functions CreateCommonFreeLdrSections() and (Un)protectBootIni() are now removed from there (they are used in bldrsup.c only). This should pave the way
…
[View More]
for future integration with other sorts of NT boot loaders (BootMgr and (u)EFI boot loader). Modified: branches/setup_improvements/base/setup/usetup/bootsup.c Modified: branches/setup_improvements/base/setup/usetup/bootsup.c URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/u…
============================================================================== --- branches/setup_improvements/base/setup/usetup/bootsup.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/bootsup.c [iso-8859-1] Thu Jun 8 02:43:51 2017 @@ -121,732 +121,389 @@ } } -static -VOID -CreateCommonFreeLoaderSections( - PINICACHE IniCache) -{ - PINICACHESECTION IniSection; - - /* Create "FREELOADER" section */ - IniSection = IniCacheAppendSection(IniCache, L"FREELOADER"); - -#if DBG - if (IsUnattendedSetup) - { - /* DefaultOS=ReactOS */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"DefaultOS", -#ifndef _WINKD_ - L"ReactOS_KdSerial"); -#else - L"ReactOS_Debug"); -#endif - } - else -#endif - { - /* DefaultOS=ReactOS */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"DefaultOS", - L"ReactOS"); - } - -#if DBG - if (IsUnattendedSetup) -#endif - { - /* Timeout=0 for unattended or non debug*/ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"TimeOut", - L"0"); - } -#if DBG - else - { - /* Timeout=0 or 10 */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"TimeOut", - L"10"); - } -#endif - - /* Create "Display" section */ - IniSection = IniCacheAppendSection(IniCache, L"Display"); - - /* TitleText=ReactOS Boot Manager */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"TitleText", - L"ReactOS Boot Manager"); - - /* StatusBarColor=Cyan */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"StatusBarColor", - L"Cyan"); - - /* StatusBarTextColor=Black */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"StatusBarTextColor", - L"Black"); - - /* BackdropTextColor=White */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"BackdropTextColor", - L"White"); - - /* BackdropColor=Blue */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"BackdropColor", - L"Blue"); - - /* BackdropFillStyle=Medium */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"BackdropFillStyle", - L"Medium"); - - /* TitleBoxTextColor=White */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"TitleBoxTextColor", - L"White"); - - /* TitleBoxColor=Red */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"TitleBoxColor", - L"Red"); - - /* MessageBoxTextColor=White */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"MessageBoxTextColor", - L"White"); - - /* MessageBoxColor=Blue */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"MessageBoxColor", - L"Blue"); - - /* MenuTextColor=White */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"MenuTextColor", - L"Gray"); - - /* MenuColor=Blue */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"MenuColor", - L"Black"); - - /* TextColor=Yellow */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"TextColor", - L"Gray"); - - /* SelectedTextColor=Black */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"SelectedTextColor", - L"Black"); - - /* SelectedColor=Gray */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"SelectedColor", - L"Gray"); - - /* SelectedColor=Gray */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"ShowTime", - L"No"); - - /* SelectedColor=Gray */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"MenuBox", - L"No"); - - /* SelectedColor=Gray */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"CenterMenu", - L"No"); - - /* SelectedColor=Gray */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"MinimalUI", - L"Yes"); - - /* SelectedColor=Gray */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"TimeText", - L"Seconds until highlighted choice will be started automatically: "); -} - -static -NTSTATUS -CreateNTOSEntry( - PINICACHE IniCache, - PINICACHESECTION OSSection, - PWCHAR Section, - PWCHAR Description, - PWCHAR BootType, - PWCHAR ArcPath, - PWCHAR Options) -{ - PINICACHESECTION IniSection; - - /* Insert entry into "Operating Systems" section */ - IniCacheInsertKey(OSSection, - NULL, - INSERT_LAST, - Section, - Description); - - /* Create new section */ - IniSection = IniCacheAppendSection(IniCache, Section); - - /* BootType= */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"BootType", - BootType); - - /* SystemPath= */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"SystemPath", - ArcPath); - - /* Options= */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"Options", - Options); - - return STATUS_SUCCESS; -} - -static -VOID + +static VOID CreateFreeLoaderReactOSEntries( - PINICACHE IniCache, - PWCHAR ArcPath) -{ - PINICACHESECTION IniSection; - - /* Create "Operating Systems" section */ - IniSection = IniCacheAppendSection(IniCache, L"Operating Systems"); + IN PVOID BootStoreHandle, + IN PCWSTR ArcPath) +{ + UCHAR xxBootEntry[FIELD_OFFSET(NTOS_BOOT_ENTRY, OsOptions) + sizeof(NTOS_OPTIONS)]; + PNTOS_BOOT_ENTRY BootEntry = (PNTOS_BOOT_ENTRY)&xxBootEntry; + PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions; + NTOS_BOOT_OPTIONS BootOptions; + + BootEntry->Version = L"Windows2003"; + BootEntry->BootFilePath = NULL; + + BootEntry->OsOptionsLength = sizeof(NTOS_OPTIONS); + RtlCopyMemory(Options->Signature, + NTOS_OPTIONS_SIGNATURE, + RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)); + + Options->OsLoadPath = ArcPath; /* ReactOS */ - CreateNTOSEntry(IniCache, IniSection, - L"ReactOS", L"\"ReactOS\"", - L"Windows2003", ArcPath, - L""); + // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS"); + BootEntry->FriendlyName = L"\"ReactOS\""; + Options->OsLoadOptions = NULL; // L""; + AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS")); /* ReactOS_Debug */ - CreateNTOSEntry(IniCache, IniSection, - L"ReactOS_Debug", L"\"ReactOS (Debug)\"", - L"Windows2003", ArcPath, - L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS"); + // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS_Debug"); + BootEntry->FriendlyName = L"\"ReactOS (Debug)\""; + Options->OsLoadOptions = L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS"; + AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_Debug")); + #ifdef _WINKD_ /* ReactOS_VBoxDebug */ - CreateNTOSEntry(IniCache, IniSection, - L"ReactOS_VBoxDebug", L"\"ReactOS (VBoxDebug)\"", - L"Windows2003", ArcPath, - L"/DEBUG /DEBUGPORT=VBOX /SOS"); + // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS_VBoxDebug"); + BootEntry->FriendlyName = L"\"ReactOS (VBoxDebug)\""; + Options->OsLoadOptions = L"/DEBUG /DEBUGPORT=VBOX /SOS"; + AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_VBoxDebug")); #endif #if DBG #ifndef _WINKD_ /* ReactOS_KdSerial */ - CreateNTOSEntry(IniCache, IniSection, - L"ReactOS_KdSerial", L"\"ReactOS (RosDbg)\"", - L"Windows2003", ArcPath, - L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /KDSERIAL"); + // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS_KdSerial"); + BootEntry->FriendlyName = L"\"ReactOS (RosDbg)\""; + Options->OsLoadOptions = L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /KDSERIAL"; + AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_KdSerial")); #endif /* ReactOS_Screen */ - CreateNTOSEntry(IniCache, IniSection, - L"ReactOS_Screen", L"\"ReactOS (Screen)\"", - L"Windows2003", ArcPath, - L"/DEBUG /DEBUGPORT=SCREEN /SOS"); + // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS_Screen"); + BootEntry->FriendlyName = L"\"ReactOS (Screen)\""; + Options->OsLoadOptions = L"/DEBUG /DEBUGPORT=SCREEN /SOS"; + AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_Screen")); /* ReactOS_LogFile */ - CreateNTOSEntry(IniCache, IniSection, - L"ReactOS_LogFile", L"\"ReactOS (Log file)\"", - L"Windows2003", ArcPath, - L"/DEBUG /DEBUGPORT=FILE /SOS"); + // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS_LogFile"); + BootEntry->FriendlyName = L"\"ReactOS (Log file)\""; + Options->OsLoadOptions = L"/DEBUG /DEBUGPORT=FILE /SOS"; + AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_LogFile")); /* ReactOS_Ram */ - CreateNTOSEntry(IniCache, IniSection, - L"ReactOS_Ram", L"\"ReactOS (RAM Disk)\"", - L"Windows2003", L"ramdisk(0)\\ReactOS", - L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /RDPATH=reactos.img /RDIMAGEOFFSET=32256"); + // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS_Ram"); + BootEntry->FriendlyName = L"\"ReactOS (RAM Disk)\""; + Options->OsLoadPath = L"ramdisk(0)\\ReactOS"; + Options->OsLoadOptions = L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /RDPATH=reactos.img /RDIMAGEOFFSET=32256"; + AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_Ram")); /* ReactOS_EMS */ - CreateNTOSEntry(IniCache, IniSection, - L"ReactOS_EMS", L"\"ReactOS (Emergency Management Services)\"", - L"Windows2003", ArcPath, - L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /redirect=com2 /redirectbaudrate=115200"); + // BootEntry->BootEntryKey = MAKESTRKEY(L"ReactOS_EMS"); + BootEntry->FriendlyName = L"\"ReactOS (Emergency Management Services)\""; + Options->OsLoadPath = ArcPath; + Options->OsLoadOptions = L"/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200 /SOS /redirect=com2 /redirectbaudrate=115200"; + AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(L"ReactOS_EMS")); #endif + + +#if DBG + if (IsUnattendedSetup) + { + /* DefaultOS=ReactOS */ +#ifndef _WINKD_ + BootOptions.CurrentBootEntryKey = MAKESTRKEY(L"ReactOS_KdSerial"); +#else + BootOptions.CurrentBootEntryKey = MAKESTRKEY(L"ReactOS_Debug"); +#endif + } + else +#endif + { + /* DefaultOS=ReactOS */ + BootOptions.CurrentBootEntryKey = MAKESTRKEY(L"ReactOS"); + } + +#if DBG + if (IsUnattendedSetup) +#endif + { + /* Timeout=0 for unattended or non debug */ + BootOptions.Timeout = 0; + } +#if DBG + else + { + /* Timeout=10 */ + BootOptions.Timeout = 10; + } +#endif + + SetNTOSBootOptions(BootStoreHandle, &BootOptions, 2 | 1); } -static -NTSTATUS +static NTSTATUS CreateFreeLoaderIniForReactOS( - PWCHAR IniPath, - PWCHAR ArcPath) -{ - PINICACHE IniCache; - - /* Initialize the INI file */ - IniCache = IniCacheCreate(); - - /* Create the common FreeLdr sections */ - CreateCommonFreeLoaderSections(IniCache); + IN PCWSTR IniPath, + IN PCWSTR ArcPath) +{ + NTSTATUS Status; + PVOID BootStoreHandle; + + /* Initialize the INI file and create the common FreeLdr sections */ + Status = OpenNTOSBootLoaderStore(&BootStoreHandle, IniPath, FreeLdr, TRUE); + if (!NT_SUCCESS(Status)) + return Status; /* Add the ReactOS entries */ - CreateFreeLoaderReactOSEntries(IniCache, ArcPath); - - /* Save the INI file */ - IniCacheSave(IniCache, IniPath); - IniCacheDestroy(IniCache); - + CreateFreeLoaderReactOSEntries(BootStoreHandle, ArcPath); + + /* Close the INI file */ + CloseNTOSBootLoaderStore(BootStoreHandle); return STATUS_SUCCESS; } -static -NTSTATUS +static NTSTATUS CreateFreeLoaderIniForReactOSAndBootSector( - PWCHAR IniPath, - PWCHAR ArcPath, - PWCHAR Section, - PWCHAR Description, - PWCHAR BootDrive, - PWCHAR BootPartition, - PWCHAR BootSector) -{ - PINICACHE IniCache; - PINICACHESECTION IniSection; - - /* Initialize the INI file */ - IniCache = IniCacheCreate(); - - /* Create the common FreeLdr sections */ - CreateCommonFreeLoaderSections(IniCache); + IN PCWSTR IniPath, + IN PCWSTR ArcPath, + IN PCWSTR Section, + IN PCWSTR Description, + IN PCWSTR BootDrive, + IN PCWSTR BootPartition, + IN PCWSTR BootSector) +{ + NTSTATUS Status; + PVOID BootStoreHandle; + UCHAR xxBootEntry[FIELD_OFFSET(NTOS_BOOT_ENTRY, OsOptions) + sizeof(BOOT_SECTOR_OPTIONS)]; + PNTOS_BOOT_ENTRY BootEntry = (PNTOS_BOOT_ENTRY)&xxBootEntry; + PBOOT_SECTOR_OPTIONS Options = (PBOOT_SECTOR_OPTIONS)&BootEntry->OsOptions; + + /* Initialize the INI file and create the common FreeLdr sections */ + Status = OpenNTOSBootLoaderStore(&BootStoreHandle, IniPath, FreeLdr, TRUE); + if (!NT_SUCCESS(Status)) + return Status; /* Add the ReactOS entries */ - CreateFreeLoaderReactOSEntries(IniCache, ArcPath); - - /* Get "Operating Systems" section */ - IniSection = IniCacheGetSection(IniCache, L"Operating Systems"); - - /* Insert entry into "Operating Systems" section */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - Section, - Description); - - /* Create new section */ - IniSection = IniCacheAppendSection(IniCache, Section); - - /* BootType=BootSector */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"BootType", - L"BootSector"); - - /* BootDrive= */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"BootDrive", - BootDrive); - - /* BootPartition= */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"BootPartition", - BootPartition); - - /* BootSector= */ - IniCacheInsertKey(IniSection, - NULL, - INSERT_LAST, - L"BootSectorFile", - BootSector); - - /* Save the INI file */ - IniCacheSave(IniCache, IniPath); - IniCacheDestroy(IniCache); - + CreateFreeLoaderReactOSEntries(BootStoreHandle, ArcPath); + + /**/BootEntry->Version = L"BootSector";/**/ + BootEntry->BootFilePath = NULL; + + BootEntry->OsOptionsLength = sizeof(BOOT_SECTOR_OPTIONS); + RtlCopyMemory(Options->Signature, + BOOT_SECTOR_OPTIONS_SIGNATURE, + RTL_FIELD_SIZE(BOOT_SECTOR_OPTIONS, Signature)); + + Options->Drive = BootDrive; + Options->Partition = BootPartition; + Options->BootSectorFileName = BootSector; + + // BootEntry->BootEntryKey = MAKESTRKEY(Section); + BootEntry->FriendlyName = Description; + AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(Section)); + + /* Close the INI file */ + CloseNTOSBootLoaderStore(BootStoreHandle); + return STATUS_SUCCESS; +} + +// +// I think this function can be generalizable as: +// "find the corresponding 'ReactOS' boot entry in this loader config file +// (here abstraction comes there), and if none, add a new one". +// + +typedef struct _ENUM_REACTOS_ENTRIES_DATA +{ + ULONG i; + BOOLEAN UseExistingEntry; + PCWSTR ArcPath; + WCHAR SectionName[80]; + WCHAR OsName[80]; +} ENUM_REACTOS_ENTRIES_DATA, *PENUM_REACTOS_ENTRIES_DATA; + +// PENUM_BOOT_ENTRIES_ROUTINE +static NTSTATUS +NTAPI +EnumerateReactOSEntries( + IN NTOS_BOOT_LOADER_TYPE Type, + IN PNTOS_BOOT_ENTRY BootEntry, + IN PVOID Parameter OPTIONAL) +{ + PENUM_REACTOS_ENTRIES_DATA Data = (PENUM_REACTOS_ENTRIES_DATA)Parameter; + PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions; + WCHAR SystemPath[MAX_PATH]; + + /* We have a boot entry */ + + /* Check for supported boot type "Windows2003" */ + if (BootEntry->OsOptionsLength < sizeof(NTOS_OPTIONS) || + RtlCompareMemory(&BootEntry->OsOptions /* Signature */, + NTOS_OPTIONS_SIGNATURE, + RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)) != + RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)) + { + /* This is not a ReactOS entry */ + DPRINT1(" An installation '%S' of unsupported type '%S'\n", + BootEntry->FriendlyName, + BootEntry->Version ? BootEntry->Version : L"n/a"); + /* Continue the enumeration */ + goto SkipThisEntry; + } + + /* BootType is Windows2003, now check OsLoadPath */ + if (!Options->OsLoadPath || !*Options->OsLoadPath) + { + /* Certainly not a ReactOS installation */ + DPRINT1(" A Win2k3 install '%S' without an ARC path?!\n", BootEntry->FriendlyName); + /* Continue the enumeration */ + goto SkipThisEntry; + } + + swprintf(SystemPath, L"\"%s\"", Data->ArcPath); + if ((_wcsicmp(Options->OsLoadPath, Data->ArcPath) != 0) && + (_wcsicmp(Options->OsLoadPath, SystemPath) != 0)) + { + /* + * This entry is a ReactOS entry, but the SystemRoot + * does not match the one we are looking for. + */ + /* Continue the enumeration */ + goto SkipThisEntry; + } + + DPRINT1(" Found a candidate Win2k3 install '%S' with ARC path '%S'\n", + BootEntry->FriendlyName, Options->OsLoadPath); + // DPRINT1(" Found a Win2k3 install '%S' with ARC path '%S'\n", + // BootEntry->FriendlyName, Options->OsLoadPath); + + DPRINT1("EnumerateReactOSEntries: OsLoadPath: '%S'\n", Options->OsLoadPath); + + Data->UseExistingEntry = TRUE; + StringCchCopyW(Data->OsName, ARRAYSIZE(Data->OsName), BootEntry->FriendlyName); + + /* We have found our entry, stop the enumeration now! */ + return STATUS_NO_MORE_ENTRIES; + +SkipThisEntry: + Data->UseExistingEntry = FALSE; + if (Type == FreeLdr && wcscmp(Data->SectionName, (PWSTR)BootEntry->BootEntryKey)== 0) + { + StringCchPrintfW(Data->SectionName, ARRAYSIZE(Data->SectionName), L"ReactOS_%lu", Data->i); + StringCchPrintfW(Data->OsName, ARRAYSIZE(Data->OsName), L"\"ReactOS %lu\"", Data->i); + Data->i++; + } return STATUS_SUCCESS; } static NTSTATUS UpdateFreeLoaderIni( - PWCHAR IniPath, - PWCHAR ArcPath) + IN PCWSTR IniPath, + IN PCWSTR ArcPath) { NTSTATUS Status; - PINICACHE IniCache; - PINICACHESECTION IniSection; - PINICACHESECTION OsIniSection; - WCHAR SectionName[80]; - WCHAR OsName[80]; - WCHAR SystemPath[200]; - WCHAR SectionName2[200]; - PWCHAR KeyData; - ULONG i,j; - - Status = IniCacheLoad(&IniCache, IniPath, FALSE); - if (!NT_SUCCESS(Status)) - return Status; - - /* Get "Operating Systems" section */ - IniSection = IniCacheGetSection(IniCache, L"Operating Systems"); - if (IniSection == NULL) - { - IniCacheDestroy(IniCache); - return STATUS_UNSUCCESSFUL; - } + PVOID BootStoreHandle; + ENUM_REACTOS_ENTRIES_DATA Data; + UCHAR xxBootEntry[FIELD_OFFSET(NTOS_BOOT_ENTRY, OsOptions) + sizeof(NTOS_OPTIONS)]; + PNTOS_BOOT_ENTRY BootEntry = (PNTOS_BOOT_ENTRY)&xxBootEntry; + PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions; + + /* Open the INI file */ + Status = OpenNTOSBootLoaderStore(&BootStoreHandle, IniPath, FreeLdr, /*TRUE*/ FALSE); + if (!NT_SUCCESS(Status)) + return Status; /* Find an existing usable or an unused section name */ - i = 1; - wcscpy(SectionName, L"ReactOS"); - wcscpy(OsName, L"\"ReactOS\""); - while(TRUE) - { - Status = IniCacheGetKey(IniSection, SectionName, &KeyData); - if (!NT_SUCCESS(Status)) - break; - - /* Get operation system section */ - if (KeyData[0] == '"') - { - wcscpy(SectionName2, &KeyData[1]); - j = wcslen(SectionName2); - if (j > 0) - { - SectionName2[j-1] = 0; - } - } - else - { - wcscpy(SectionName2, KeyData); - } - - /* Search for an existing ReactOS entry */ - OsIniSection = IniCacheGetSection(IniCache, SectionName2); - if (OsIniSection != NULL) - { - BOOLEAN UseExistingEntry = TRUE; - - /* Check for boot type "Windows2003" */ - Status = IniCacheGetKey(OsIniSection, L"BootType", &KeyData); - if (NT_SUCCESS(Status)) - { - if ((KeyData == NULL) || - ( (_wcsicmp(KeyData, L"Windows2003") != 0) && - (_wcsicmp(KeyData, L"\"Windows2003\"") != 0) )) - { - /* This is not a ReactOS entry */ - UseExistingEntry = FALSE; - } - } - else - { - UseExistingEntry = FALSE; - } - - if (UseExistingEntry) - { - /* BootType is Windows2003. Now check SystemPath. */ - Status = IniCacheGetKey(OsIniSection, L"SystemPath", &KeyData); - if (NT_SUCCESS(Status)) - { - swprintf(SystemPath, L"\"%s\"", ArcPath); - if ((KeyData == NULL) || - ( (_wcsicmp(KeyData, ArcPath) != 0) && - (_wcsicmp(KeyData, SystemPath) != 0) )) - { - /* This entry is a ReactOS entry, but the SystemRoot - does not match the one we are looking for. */ - UseExistingEntry = FALSE; - } - } - else - { - UseExistingEntry = FALSE; - } - } - - if (UseExistingEntry) - { - IniCacheDestroy(IniCache); - return STATUS_SUCCESS; - } - } - - swprintf(SectionName, L"ReactOS_%lu", i); - swprintf(OsName, L"\"ReactOS %lu\"", i); - i++; - } - - /* Create a new "ReactOS" entry */ - CreateNTOSEntry(IniCache, IniSection, - SectionName, OsName, - L"Windows2003", ArcPath, - L""); - - IniCacheSave(IniCache, IniPath); - IniCacheDestroy(IniCache); - + Data.UseExistingEntry = TRUE; + Data.i = 1; + Data.ArcPath = ArcPath; + StringCchCopyW(Data.SectionName, ARRAYSIZE(Data.SectionName), L"ReactOS"); + StringCchCopyW(Data.OsName, ARRAYSIZE(Data.OsName), L"\"ReactOS\""); + + // + // FIXME: We temporarily use EnumerateNTOSBootEntries, until + // both QueryNTOSBootEntry and ModifyNTOSBootEntry get implemented. + // + Status = EnumerateNTOSBootEntries(BootStoreHandle, EnumerateReactOSEntries, &Data); + + /* Create a new "ReactOS" entry if there is none already existing that suits us */ + if (!Data.UseExistingEntry) + { + // StringCchPrintfW(Data.SectionName, ARRAYSIZE(Data.SectionName), L"ReactOS_%lu", Data.i); + // StringCchPrintfW(Data.OsName, ARRAYSIZE(Data.OsName), L"\"ReactOS %lu\"", Data.i); + + BootEntry->Version = L"Windows2003"; + BootEntry->BootFilePath = NULL; + + BootEntry->OsOptionsLength = sizeof(NTOS_OPTIONS); + RtlCopyMemory(Options->Signature, + NTOS_OPTIONS_SIGNATURE, + RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)); + + Options->OsLoadPath = ArcPath; + + // BootEntry->BootEntryKey = MAKESTRKEY(Data.SectionName); + BootEntry->FriendlyName = Data.OsName; + Options->OsLoadOptions = NULL; // L""; + AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(Data.SectionName)); + } + + /* Close the INI file */ + CloseNTOSBootLoaderStore(BootStoreHandle); return STATUS_SUCCESS; -} - -static -NTSTATUS -UnprotectBootIni( - PWSTR FileName, - PULONG Attributes) -{ - NTSTATUS Status; - UNICODE_STRING Name; - OBJECT_ATTRIBUTES ObjectAttributes; - IO_STATUS_BLOCK IoStatusBlock; - FILE_BASIC_INFORMATION FileInfo; - HANDLE FileHandle; - - RtlInitUnicodeString(&Name, FileName); - - InitializeObjectAttributes(&ObjectAttributes, - &Name, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); - - Status = NtOpenFile(&FileHandle, - GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, - &ObjectAttributes, - &IoStatusBlock, - 0, - FILE_SYNCHRONOUS_IO_NONALERT); - if (Status == STATUS_NO_SUCH_FILE) - { - DPRINT1("NtOpenFile() failed (Status %lx)\n", Status); - *Attributes = 0; - return STATUS_SUCCESS; - } - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtOpenFile() failed (Status %lx)\n", Status); - return Status; - } - - Status = NtQueryInformationFile(FileHandle, - &IoStatusBlock, - &FileInfo, - sizeof(FILE_BASIC_INFORMATION), - FileBasicInformation); - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtQueryInformationFile() failed (Status %lx)\n", Status); - NtClose(FileHandle); - return Status; - } - - *Attributes = FileInfo.FileAttributes; - - /* Delete attributes SYSTEM, HIDDEN and READONLY */ - FileInfo.FileAttributes = FileInfo.FileAttributes & - ~(FILE_ATTRIBUTE_SYSTEM | - FILE_ATTRIBUTE_HIDDEN | - FILE_ATTRIBUTE_READONLY); - - Status = NtSetInformationFile(FileHandle, - &IoStatusBlock, - &FileInfo, - sizeof(FILE_BASIC_INFORMATION), - FileBasicInformation); - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtSetInformationFile() failed (Status %lx)\n", Status); - } - - NtClose(FileHandle); - return Status; -} - -static -NTSTATUS -ProtectBootIni( - PWSTR FileName, - ULONG Attributes) -{ - NTSTATUS Status; - UNICODE_STRING Name; - OBJECT_ATTRIBUTES ObjectAttributes; - IO_STATUS_BLOCK IoStatusBlock; - FILE_BASIC_INFORMATION FileInfo; - HANDLE FileHandle; - - RtlInitUnicodeString(&Name, FileName); - - InitializeObjectAttributes(&ObjectAttributes, - &Name, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); - - Status = NtOpenFile(&FileHandle, - GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, - &ObjectAttributes, - &IoStatusBlock, - 0, - FILE_SYNCHRONOUS_IO_NONALERT); - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtOpenFile() failed (Status %lx)\n", Status); - return Status; - } - - Status = NtQueryInformationFile(FileHandle, - &IoStatusBlock, - &FileInfo, - sizeof(FILE_BASIC_INFORMATION), - FileBasicInformation); - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtQueryInformationFile() failed (Status %lx)\n", Status); - NtClose(FileHandle); - return Status; - } - - FileInfo.FileAttributes = FileInfo.FileAttributes | Attributes; - - Status = NtSetInformationFile(FileHandle, - &IoStatusBlock, - &FileInfo, - sizeof(FILE_BASIC_INFORMATION), - FileBasicInformation); - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtSetInformationFile() failed (Status %lx)\n", Status); - } - - NtClose(FileHandle); - return Status; } static NTSTATUS UpdateBootIni( - PWSTR BootIniPath, - PWSTR EntryName, - PWSTR EntryValue) + IN PCWSTR IniPath, + IN PCWSTR EntryName, // ~= ArcPath + IN PCWSTR EntryValue) { NTSTATUS Status; - PINICACHE Cache = NULL; - PINICACHESECTION Section = NULL; - ULONG FileAttribute; - PWCHAR OldValue = NULL; - - Status = IniCacheLoad(&Cache, BootIniPath, FALSE); - if (!NT_SUCCESS(Status)) - { - return Status; - } - - Section = IniCacheGetSection(Cache, - L"operating systems"); - if (Section == NULL) - { - IniCacheDestroy(Cache); - return STATUS_UNSUCCESSFUL; - } - - /* Check - maybe record already exists */ - Status = IniCacheGetKey(Section, EntryName, &OldValue); - - /* If either key was not found, or contains something else - add new one */ - if (!NT_SUCCESS(Status) || wcscmp(OldValue, EntryValue)) - { - IniCacheInsertKey(Section, - NULL, - INSERT_LAST, - EntryName, - EntryValue); - } - - Status = UnprotectBootIni(BootIniPath, - &FileAttribute); - if (!NT_SUCCESS(Status)) - { - IniCacheDestroy(Cache); - return Status; - } - - Status = IniCacheSave(Cache, BootIniPath); - if (!NT_SUCCESS(Status)) - { - IniCacheDestroy(Cache); - return Status; - } - - FileAttribute |= (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY); - Status = ProtectBootIni(BootIniPath, FileAttribute); - - IniCacheDestroy(Cache); - - return Status; + PVOID BootStoreHandle; + ENUM_REACTOS_ENTRIES_DATA Data; + + // NOTE: Technically it would be "BootSector"... + UCHAR xxBootEntry[FIELD_OFFSET(NTOS_BOOT_ENTRY, OsOptions) + sizeof(NTOS_OPTIONS)]; + PNTOS_BOOT_ENTRY BootEntry = (PNTOS_BOOT_ENTRY)&xxBootEntry; + PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions; + + /* Open the INI file */ + Status = OpenNTOSBootLoaderStore(&BootStoreHandle, IniPath, NtLdr, FALSE); + if (!NT_SUCCESS(Status)) + return Status; + + /* Find an existing usable or an unused section name */ + Data.UseExistingEntry = TRUE; + // Data.i = 1; + Data.ArcPath = EntryName; + // StringCchCopyW(Data.SectionName, ARRAYSIZE(Data.SectionName), L"ReactOS"); + StringCchCopyW(Data.OsName, ARRAYSIZE(Data.OsName), L"\"ReactOS\""); + + // + // FIXME: We temporarily use EnumerateNTOSBootEntries, until + // both QueryNTOSBootEntry and ModifyNTOSBootEntry get implemented. + // + Status = EnumerateNTOSBootEntries(BootStoreHandle, EnumerateReactOSEntries, &Data); + + /* If either the key was not found, or contains something else, add a new one */ + if (!Data.UseExistingEntry /* || + ( (Status == STATUS_NO_MORE_ENTRIES) && wcscmp(Data.OsName, EntryValue) ) */) + { + BootEntry->Version = L"Windows2003"; // NOTE: See remark above + BootEntry->BootFilePath = NULL; + + BootEntry->OsOptionsLength = sizeof(NTOS_OPTIONS); + RtlCopyMemory(Options->Signature, + NTOS_OPTIONS_SIGNATURE, + RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)); + + Options->OsLoadPath = EntryName; + + // BootEntry->BootEntryKey = MAKESTRKEY(Data.SectionName); + // BootEntry->FriendlyName = Data.OsName; + BootEntry->FriendlyName = EntryValue; + Options->OsLoadOptions = NULL; // L""; + AddNTOSBootEntry(BootStoreHandle, BootEntry, MAKESTRKEY(0 /*Data.SectionName*/)); + } + + /* Close the INI file */ + CloseNTOSBootLoaderStore(BootStoreHandle); + return STATUS_SUCCESS; // Status; } @@ -2104,15 +1761,12 @@ } /* Prepare for possibly updating 'freeldr.ini' */ - CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini"); - - DoesFreeLdrExist = DoesFileExist(NULL, DstPath); + DoesFreeLdrExist = DoesFileExist_2(SystemRootPath->Buffer, L"freeldr.ini"); if (DoesFreeLdrExist) { /* Update existing 'freeldr.ini' */ DPRINT1("Update existing 'freeldr.ini'\n"); - - Status = UpdateFreeLoaderIni(DstPath, DestinationArcPath->Buffer); + Status = UpdateFreeLoaderIni(SystemRootPath->Buffer, DestinationArcPath->Buffer); if (!NT_SUCCESS(Status)) { DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status); @@ -2136,9 +1790,7 @@ { /* Create new 'freeldr.ini' */ DPRINT1("Create new 'freeldr.ini'\n"); - // CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini"); - - Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer); + Status = CreateFreeLoaderIniForReactOS(SystemRootPath->Buffer, DestinationArcPath->Buffer); if (!NT_SUCCESS(Status)) { DPRINT1("CreateFreeLoaderIniForReactOS() failed (Status %lx)\n", Status); @@ -2180,10 +1832,8 @@ } /* Update 'boot.ini' */ - CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"boot.ini"); - - DPRINT1("Update 'boot.ini': %S\n", DstPath); - Status = UpdateBootIni(DstPath, + DPRINT1("Update 'boot.ini'\n"); + Status = UpdateBootIni(SystemRootPath->Buffer, L"C:\\bootsect.ros", L"\"ReactOS\""); if (!NT_SUCCESS(Status)) @@ -2325,12 +1975,11 @@ { /* Create new 'freeldr.ini' */ DPRINT1("Create new 'freeldr.ini'\n"); - // CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini"); if (IsThereAValidBootSector(SystemRootPath->Buffer)) { Status = CreateFreeLoaderIniForReactOSAndBootSector( - DstPath, DestinationArcPath->Buffer, + SystemRootPath->Buffer, DestinationArcPath->Buffer, Section, Description, BootDrive, BootPartition, BootSector); if (!NT_SUCCESS(Status)) @@ -2352,7 +2001,7 @@ } else { - Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer); + Status = CreateFreeLoaderIniForReactOS(SystemRootPath->Buffer, DestinationArcPath->Buffer); if (!NT_SUCCESS(Status)) { DPRINT1("CreateFreeLoaderIniForReactOS() failed (Status %lx)\n", Status); @@ -2422,16 +2071,13 @@ return Status; } - /* Prepare for possibly copying 'freeldr.ini' */ - CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"freeldr.ini"); - - DoesFreeLdrExist = DoesFileExist(NULL, DstPath); + /* Prepare for possibly updating 'freeldr.ini' */ + DoesFreeLdrExist = DoesFileExist_2(SystemRootPath->Buffer, L"freeldr.ini"); if (DoesFreeLdrExist) { /* Update existing 'freeldr.ini' */ DPRINT1("Update existing 'freeldr.ini'\n"); - - Status = UpdateFreeLoaderIni(DstPath, DestinationArcPath->Buffer); + Status = UpdateFreeLoaderIni(SystemRootPath->Buffer, DestinationArcPath->Buffer); if (!NT_SUCCESS(Status)) { DPRINT1("UpdateFreeLoaderIni() failed (Status %lx)\n", Status); @@ -2446,7 +2092,6 @@ { /* Create new 'freeldr.ini' */ DPRINT1("Create new 'freeldr.ini'\n"); - CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"\\freeldr.ini"); /* Certainly SysLinux, GRUB, LILO... or an unknown boot loader */ DPRINT1("*nix or unknown boot loader found\n"); @@ -2456,7 +2101,7 @@ PCWSTR BootSector = L"BOOTSECT.OLD"; Status = CreateFreeLoaderIniForReactOSAndBootSector( - DstPath, DestinationArcPath->Buffer, + SystemRootPath->Buffer, DestinationArcPath->Buffer, L"Linux", L"\"Linux\"", L"hd0", L"1", BootSector); if (!NT_SUCCESS(Status)) @@ -2478,7 +2123,7 @@ } else { - Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer); + Status = CreateFreeLoaderIniForReactOS(SystemRootPath->Buffer, DestinationArcPath->Buffer); if (!NT_SUCCESS(Status)) { DPRINT1("CreateFreeLoaderIniForReactOS() failed (Status %lx)\n", Status); @@ -2592,10 +2237,8 @@ } /* Create new 'freeldr.ini' */ - CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, FloppyDevice.Buffer, L"freeldr.ini"); - DPRINT("Create new 'freeldr.ini'\n"); - Status = CreateFreeLoaderIniForReactOS(DstPath, DestinationArcPath->Buffer); + Status = CreateFreeLoaderIniForReactOS(FloppyDevice.Buffer, DestinationArcPath->Buffer); if (!NT_SUCCESS(Status)) { DPRINT1("CreateFreeLoaderIniForReactOS() failed (Status %lx)\n", Status); @@ -2604,7 +2247,7 @@ /* Install FAT12 boosector */ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin"); - StringCchCopyW(DstPath, ARRAYSIZE(DstPath), FloppyDevice.Buffer); + CombinePaths(DstPath, ARRAYSIZE(DstPath), 1, FloppyDevice.Buffer); DPRINT("Install FAT bootcode: %S ==> %S\n", SrcPath, DstPath); Status = InstallFat12BootCodeToFloppy(SrcPath, DstPath);
[View Less]
7 years, 10 months
1
0
0
0
[hbelusca] 74953: [SETUPLIB]: Adapt the code in osdetect.c to make it use the new features of bldrsup.c committed in r74952.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Jun 8 02:20:33 2017 New Revision: 74953 URL:
http://svn.reactos.org/svn/reactos?rev=74953&view=rev
Log: [SETUPLIB]: Adapt the code in osdetect.c to make it use the new features of bldrsup.c committed in r74952. Modified: branches/setup_improvements/base/setup/lib/osdetect.c Modified: branches/setup_improvements/base/setup/lib/osdetect.c URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
=======================================
…
[View More]
======================================= --- branches/setup_improvements/base/setup/lib/osdetect.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/lib/osdetect.c [iso-8859-1] Thu Jun 8 02:20:33 2017 @@ -74,6 +74,7 @@ IN PVOID Parameter OPTIONAL) { PENUM_INSTALLS_DATA Data = (PENUM_INSTALLS_DATA)Parameter; + PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions; PNTOS_INSTALLATION NtOsInstall; UNICODE_STRING SystemRootPath; @@ -88,10 +89,11 @@ /* We have a boot entry */ /* Check for supported boot type "Windows2003" */ - // TODO: What to do with "Windows" ; "WindowsNT40" ; "ReactOSSetup" ? - if ((BootEntry->Version == NULL) || - ( (_wcsicmp(BootEntry->Version, L"Windows2003") != 0) && - (_wcsicmp(BootEntry->Version, L"\"Windows2003\"") != 0) )) + if (BootEntry->OsOptionsLength < sizeof(NTOS_OPTIONS) || + RtlCompareMemory(&BootEntry->OsOptions /* Signature */, + NTOS_OPTIONS_SIGNATURE, + RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)) != + RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)) { /* This is not a ReactOS entry */ DPRINT1(" An installation '%S' of unsupported type '%S'\n", @@ -100,7 +102,8 @@ return STATUS_SUCCESS; } - if (!BootEntry->OsLoadPath || !*BootEntry->OsLoadPath) + /* BootType is Windows2003, now check OsLoadPath */ + if (!Options->OsLoadPath || !*Options->OsLoadPath) { /* Certainly not a ReactOS installation */ DPRINT1(" A Win2k3 install '%S' without an ARC path?!\n", BootEntry->FriendlyName); @@ -109,9 +112,9 @@ } DPRINT1(" Found a candidate Win2k3 install '%S' with ARC path '%S'\n", - BootEntry->FriendlyName, BootEntry->OsLoadPath); + BootEntry->FriendlyName, Options->OsLoadPath); // DPRINT1(" Found a Win2k3 install '%S' with ARC path '%S'\n", - // BootEntry->FriendlyName, BootEntry->OsLoadPath); + // BootEntry->FriendlyName, Options->OsLoadPath); // TODO: Normalize the ARC path. @@ -119,7 +122,7 @@ * Check whether we already have an installation with this ARC path. * If this is the case, stop there. */ - NtOsInstall = FindExistingNTOSInstall(Data->List, BootEntry->OsLoadPath, NULL); + NtOsInstall = FindExistingNTOSInstall(Data->List, Options->OsLoadPath, NULL); if (NtOsInstall) { DPRINT1(" An NTOS installation with name \"%S\" already exists in SystemRoot '%wZ'\n", @@ -134,21 +137,21 @@ * resides, as well verifying whether it is indeed an NTOS installation. */ RtlInitEmptyUnicodeString(&SystemRootPath, SystemRoot, sizeof(SystemRoot)); - if (!ArcPathToNtPath(&SystemRootPath, BootEntry->OsLoadPath, Data->PartList)) - { - DPRINT1("ArcPathToNtPath(%S) failed, skip the installation.\n", BootEntry->OsLoadPath); + if (!ArcPathToNtPath(&SystemRootPath, Options->OsLoadPath, Data->PartList)) + { + DPRINT1("ArcPathToNtPath(%S) failed, skip the installation.\n", Options->OsLoadPath); /* Continue the enumeration */ return STATUS_SUCCESS; } DPRINT1("ArcPathToNtPath() succeeded: '%S' --> '%wZ'\n", - BootEntry->OsLoadPath, &SystemRootPath); + Options->OsLoadPath, &SystemRootPath); /* * Check whether we already have an installation with this NT path. * If this is the case, stop there. */ - NtOsInstall = FindExistingNTOSInstall(Data->List, NULL /*BootEntry->OsLoadPath*/, &SystemRootPath); + NtOsInstall = FindExistingNTOSInstall(Data->List, NULL /*Options->OsLoadPath*/, &SystemRootPath); if (NtOsInstall) { DPRINT1(" An NTOS installation with name \"%S\" already exists in SystemRoot '%wZ'\n", @@ -167,7 +170,7 @@ } DPRINT1("Found a valid NTOS installation in SystemRoot ARC path '%S', NT path '%wZ'\n", - BootEntry->OsLoadPath, &SystemRootPath); + Options->OsLoadPath, &SystemRootPath); /* From the NT path, compute the disk, partition and path components */ if (NtPathToDiskPartComponents(SystemRootPath.Buffer, &DiskNumber, &PartitionNumber, &PathComponent)) @@ -200,7 +203,7 @@ StringCchPrintfW(InstallNameW, ARRAYSIZE(InstallNameW), L"%wZ \"%s\"", &SystemRootPath, BootEntry->FriendlyName); } - AddNTOSInstallation(Data->List, BootEntry->OsLoadPath, + AddNTOSInstallation(Data->List, Options->OsLoadPath, &SystemRootPath, PathComponent, DiskNumber, PartitionNumber, PartEntry, InstallNameW);
[View Less]
7 years, 10 months
1
0
0
0
[hbelusca] 74952: [SETUPLIB]: Make the NTOS_BOOT_ENTRY structure (that should actually be renamed...) more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Jun 8 02:19:14 2017 New Revision: 74952 URL:
http://svn.reactos.org/svn/reactos?rev=74952&view=rev
Log: [SETUPLIB]: Make the NTOS_BOOT_ENTRY structure (that should actually be renamed...) more generic, so that it can wrap around either actual NTOS boot entry options, or FreeLdr-like boot-sector options. In a sense, the NTOS_BOOT_ENTRY structure now looks much more like the NT structure "BOOT_ENTRY". - Adapt the code in bldrsup.c to these modifications, and re-
…
[View More]
enable FreeLdr-like boot-sector-file support code that was commented out. More code cleaning-up will follow later. Modified: branches/setup_improvements/base/setup/lib/bldrsup.c branches/setup_improvements/base/setup/lib/bldrsup.h Modified: branches/setup_improvements/base/setup/lib/bldrsup.c URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
============================================================================== --- branches/setup_improvements/base/setup/lib/bldrsup.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/lib/bldrsup.c [iso-8859-1] Thu Jun 8 02:19:14 2017 @@ -867,37 +867,52 @@ /* Create a new section */ IniSection = IniCacheAppendSection(BootStore->IniCache, Section); - /* BootType= */ - IniCacheInsertKey(IniSection, NULL, INSERT_LAST, - L"BootType", BootEntry->Version); - - if (_wcsicmp(BootEntry->Version, L"Windows2003") == 0) - { + // if (_wcsicmp(BootEntry->Version, L"Windows2003") == 0) + if (BootEntry->OsOptionsLength >= sizeof(NTOS_OPTIONS) && + RtlCompareMemory(&BootEntry->OsOptions /* Signature */, + NTOS_OPTIONS_SIGNATURE, + RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)) == + RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)) + { + PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions; + + /* BootType= */ + IniCacheInsertKey(IniSection, NULL, INSERT_LAST, + L"BootType", L"Windows2003"); + /* SystemPath= */ IniCacheInsertKey(IniSection, NULL, INSERT_LAST, - L"SystemPath", (PWSTR)BootEntry->OsLoadPath); + L"SystemPath", (PWSTR)Options->OsLoadPath); /* Options= */ IniCacheInsertKey(IniSection, NULL, INSERT_LAST, - L"Options", (PWSTR)BootEntry->OsLoadOptions); + L"Options", (PWSTR)Options->OsLoadOptions); } else - if (_wcsicmp(BootEntry->Version, L"BootSector") == 0) - { + // if (_wcsicmp(BootEntry->Version, L"BootSector") == 0) + if (BootEntry->OsOptionsLength >= sizeof(BOOT_SECTOR_OPTIONS) && + RtlCompareMemory(&BootEntry->OsOptions /* Signature */, + BOOT_SECTOR_OPTIONS_SIGNATURE, + RTL_FIELD_SIZE(BOOT_SECTOR_OPTIONS, Signature)) == + RTL_FIELD_SIZE(BOOT_SECTOR_OPTIONS, Signature)) + { + PBOOT_SECTOR_OPTIONS Options = (PBOOT_SECTOR_OPTIONS)&BootEntry->OsOptions; + + /* BootType= */ + IniCacheInsertKey(IniSection, NULL, INSERT_LAST, + L"BootType", L"BootSector"); + /* BootDrive= */ IniCacheInsertKey(IniSection, NULL, INSERT_LAST, - L"BootDrive", - /*BootDrive*/ (PWSTR)BootEntry->OsLoadPath); // OsLoadPath ?? - - // /* BootPartition= */ - // IniCacheInsertKey(IniSection, NULL, INSERT_LAST, - // L"BootPartition", - // BootPartition); // OsLoadPath + L"BootDrive", (PWSTR)Options->Drive); + + /* BootPartition= */ + IniCacheInsertKey(IniSection, NULL, INSERT_LAST, + L"BootPartition", (PWSTR)Options->Partition); /* BootSector= */ IniCacheInsertKey(IniSection, NULL, INSERT_LAST, - L"BootSectorFile", - /*BootSector*/ (PWSTR)BootEntry->BootFilePath); + L"BootSectorFile", (PWSTR)Options->BootSectorFileName); } else { @@ -940,19 +955,25 @@ else if (BootStore->Type == NtLdr) { + PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions; PWCHAR Buffer; ULONG BufferLength; PCWSTR InstallName, OsOptions; // ULONG InstallNameLength, OsOptionsLength; - if (_wcsicmp(BootEntry->Version, L"Windows2003") != 0) + // if (_wcsicmp(BootEntry->Version, L"Windows2003") != 0) + if (BootEntry->OsOptionsLength < sizeof(NTOS_OPTIONS) || + RtlCompareMemory(&BootEntry->OsOptions /* Signature */, + NTOS_OPTIONS_SIGNATURE, + RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)) != + RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)) { DPRINT1("Unsupported BootType '%S'\n", BootEntry->Version); return STATUS_SUCCESS; // STATUS_NOT_SUPPORTED; } InstallName = BootEntry->FriendlyName; - OsOptions = BootEntry->OsLoadOptions; + OsOptions = Options->OsLoadOptions; // if (InstallNameLength == 0) InstallName = NULL; // if (OsOptionsLength == 0) OsOptions = NULL; @@ -977,7 +998,7 @@ /* Insert the entry into the "Operating Systems" section */ IniCacheInsertKey(((PBOOT_STORE_INI_CONTEXT)BootStore)->OsIniSection, NULL, INSERT_LAST, - (PWSTR)BootEntry->OsLoadPath, Buffer); + (PWSTR)Options->OsLoadPath, Buffer); RtlFreeHeap(ProcessHeap, 0, Buffer); return STATUS_SUCCESS; @@ -1216,8 +1237,9 @@ PINICACHEITERATOR Iterator; PINICACHESECTION OsIniSection; PWCHAR SectionName, KeyData; -/**/NTOS_BOOT_ENTRY xxBootEntry;/**/ - PNTOS_BOOT_ENTRY BootEntry = &xxBootEntry; + UCHAR xxBootEntry[FIELD_OFFSET(NTOS_BOOT_ENTRY, OsOptions) + + max(sizeof(NTOS_OPTIONS), sizeof(BOOT_SECTOR_OPTIONS))]; + PNTOS_BOOT_ENTRY BootEntry = (PNTOS_BOOT_ENTRY)&xxBootEntry; PWCHAR Buffer; /* Enumerate all the valid installations listed in the "Operating Systems" section */ @@ -1272,10 +1294,8 @@ BootEntry->Version = NULL; BootEntry->BootEntryKey = MAKESTRKEY(SectionName); BootEntry->FriendlyName = InstallName; - BootEntry->OsLoadPath = NULL; BootEntry->BootFilePath = NULL; - // BootEntry->OsOptions = NULL; - BootEntry->OsLoadOptions = NULL; + BootEntry->OsOptionsLength = 0; /* Search for an existing boot entry section */ OsIniSection = IniCacheGetSection(BootStore->IniCache, SectionName); @@ -1296,50 +1316,70 @@ (_wcsicmp(KeyData, L"\"Windows2003\"") == 0)) { /* BootType is Windows2003 */ + PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions; + BootEntry->Version = L"Windows2003"; DPRINT1("This is a '%S' boot entry\n", BootEntry->Version); + + BootEntry->OsOptionsLength = sizeof(NTOS_OPTIONS); + RtlCopyMemory(Options->Signature, + NTOS_OPTIONS_SIGNATURE, + RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)); + + // BootEntry->BootFilePath = NULL; /* Check its SystemPath */ Status = IniCacheGetKey(OsIniSection, L"SystemPath", &KeyData); if (!NT_SUCCESS(Status)) - BootEntry->OsLoadPath = NULL; + Options->OsLoadPath = NULL; else - BootEntry->OsLoadPath = KeyData; + Options->OsLoadPath = KeyData; // KeyData == SystemRoot; - - BootEntry->BootFilePath = NULL; - // BootEntry->OsOptions = NULL; /* Check the optional Options */ Status = IniCacheGetKey(OsIniSection, L"Options", &KeyData); if (!NT_SUCCESS(Status)) - BootEntry->OsLoadOptions = NULL; + Options->OsLoadOptions = NULL; else - BootEntry->OsLoadOptions = KeyData; + Options->OsLoadOptions = KeyData; } else if ((_wcsicmp(KeyData, L"BootSector") == 0) || (_wcsicmp(KeyData, L"\"BootSector\"") == 0)) { /* BootType is BootSector */ + PBOOT_SECTOR_OPTIONS Options = (PBOOT_SECTOR_OPTIONS)&BootEntry->OsOptions; + BootEntry->Version = L"BootSector"; DPRINT1("This is a '%S' boot entry\n", BootEntry->Version); + + BootEntry->OsOptionsLength = sizeof(BOOT_SECTOR_OPTIONS); + RtlCopyMemory(Options->Signature, + BOOT_SECTOR_OPTIONS_SIGNATURE, + RTL_FIELD_SIZE(BOOT_SECTOR_OPTIONS, Signature)); + + // BootEntry->BootFilePath = NULL; /* Check its BootDrive */ Status = IniCacheGetKey(OsIniSection, L"BootDrive", &KeyData); if (!NT_SUCCESS(Status)) - BootEntry->OsLoadPath = NULL; + Options->Drive = NULL; else - BootEntry->OsLoadPath = KeyData; - - /* FIXME: Check its BootPartition ???? */ + Options->Drive = KeyData; + + /* Check its BootPartition */ + Status = IniCacheGetKey(OsIniSection, L"BootPartition", &KeyData); + if (!NT_SUCCESS(Status)) + Options->Partition = NULL; + else + Options->Partition = KeyData; /* Check its BootSector */ Status = IniCacheGetKey(OsIniSection, L"BootSectorFile", &KeyData); if (!NT_SUCCESS(Status)) - BootEntry->BootFilePath = NULL; + Options->BootSectorFileName = NULL; else - BootEntry->BootFilePath = KeyData; + Options->BootSectorFileName = KeyData; } else { @@ -1376,8 +1416,9 @@ NTSTATUS Status = STATUS_SUCCESS; PINICACHEITERATOR Iterator; PWCHAR SectionName, KeyData; -/**/NTOS_BOOT_ENTRY xxBootEntry;/**/ - PNTOS_BOOT_ENTRY BootEntry = &xxBootEntry; + UCHAR xxBootEntry[FIELD_OFFSET(NTOS_BOOT_ENTRY, OsOptions) + sizeof(NTOS_OPTIONS)]; + PNTOS_BOOT_ENTRY BootEntry = (PNTOS_BOOT_ENTRY)&xxBootEntry; + PNTOS_OPTIONS Options = (PNTOS_OPTIONS)&BootEntry->OsOptions; PWCHAR Buffer; ULONG BufferLength; @@ -1472,10 +1513,15 @@ BootEntry->Version = L"Windows2003"; BootEntry->BootEntryKey = 0; // FIXME?? BootEntry->FriendlyName = InstallName; - BootEntry->OsLoadPath = SectionName; BootEntry->BootFilePath = NULL; - // BootEntry->OsOptions = NULL; - BootEntry->OsLoadOptions = OsOptions; + + BootEntry->OsOptionsLength = sizeof(NTOS_OPTIONS); + RtlCopyMemory(Options->Signature, + NTOS_OPTIONS_SIGNATURE, + RTL_FIELD_SIZE(NTOS_OPTIONS, Signature)); + + Options->OsLoadPath = SectionName; + Options->OsLoadOptions = OsOptions; /* Call the user enumeration routine callback */ Status = EnumBootEntriesRoutine(NtLdr, BootEntry, Parameter); Modified: branches/setup_improvements/base/setup/lib/bldrsup.h URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/l…
============================================================================== --- branches/setup_improvements/base/setup/lib/bldrsup.h [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/lib/bldrsup.h [iso-8859-1] Thu Jun 8 02:19:14 2017 @@ -11,7 +11,7 @@ #pragma once -typedef enum _NTOS_BOOT_LOADER_TYPE +typedef enum _NTOS_BOOT_LOADER_TYPE // _BOOT_STORE_TYPE { FreeLdr, // ReactOS' FreeLoader NtLdr, // Windows <= 2k3 NT "FlexBoot" OS Loader NTLDR @@ -29,7 +29,7 @@ * This structure is inspired from the EFI boot entry structure * BOOT_OPTIONS that is defined in ndk/iotypes.h . */ -typedef struct _NTOS_BOOT_OPTIONS +typedef struct _NTOS_BOOT_OPTIONS // _BOOT_STORE_OPTIONS { // ULONG Version; // ULONG Length; @@ -60,7 +60,7 @@ * This structure is inspired from the EFI boot entry structures * BOOT_ENTRY and FILE_PATH that are defined in ndk/iotypes.h . */ -typedef struct _NTOS_BOOT_ENTRY +typedef struct _NTOS_BOOT_ENTRY // _BOOT_STORE_ENTRY { // ULONG Version; // Equivalent of the "BootType" in FreeLdr PWCHAR Version; // HACK!!! @@ -68,10 +68,50 @@ ULONG_PTR BootEntryKey; // Boot entry "key" PCWSTR FriendlyName; // Human-readable boot entry description // LoadIdentifier PCWSTR BootFilePath; // Path to e.g. osloader.exe, or winload.efi // EfiOsLoaderFilePath - PCWSTR OsLoadPath; // The OS SystemRoot path // OsLoaderFilePath - // PCWSTR OsOptions; // OsLoadOptions - PCWSTR OsLoadOptions; + ULONG OsOptionsLength; // Loader-specific options blob (can be a string, or a binary structure...) + UCHAR OsOptions[ANYSIZE_ARRAY]; +/* + * In packed form, this structure would contain offsets to 'FriendlyName' + * and 'BootFilePath' strings and, after the OsOptions blob, there would + * be the following data: + * + * WCHAR FriendlyName[ANYSIZE_ARRAY]; + * FILE_PATH BootFilePath; + */ } NTOS_BOOT_ENTRY, *PNTOS_BOOT_ENTRY; + +/* "NTOS" (aka. ReactOS or MS Windows NT) <= 5.x options */ +typedef struct _NTOS_OPTIONS +{ + UCHAR Signature[8]; // "NTOS_5\0\0" + // ULONG Version; + // ULONG Length; + PCWSTR OsLoadPath; // The OS SystemRoot path // OsLoaderFilePath // OsFilePath + PCWSTR OsLoadOptions; // OsLoadOptions +/* + * In packed form, this structure would contain an offset to the 'OsLoadPath' + * string, and the 'OsLoadOptions' member would be: + * WCHAR OsLoadOptions[ANYSIZE_ARRAY]; + * followed by: + * FILE_PATH OsLoadPath; + */ +} NTOS_OPTIONS, *PNTOS_OPTIONS; + +#define NTOS_OPTIONS_SIGNATURE "NTOS_5\0\0" + +/* Options for boot-sector boot entries */ +typedef struct _BOOT_SECTOR_OPTIONS +{ + UCHAR Signature[8]; // "BootSect" + // ULONG Version; + // ULONG Length; + PCWSTR Drive; + PCWSTR Partition; + PCWSTR BootSectorFileName; +} BOOT_SECTOR_OPTIONS, *PBOOT_SECTOR_OPTIONS; + +#define BOOT_SECTOR_OPTIONS_SIGNATURE "BootSect" + typedef NTSTATUS (NTAPI *PENUM_BOOT_ENTRIES_ROUTINE)(
[View Less]
7 years, 10 months
1
0
0
0
← Newer
1
...
27
28
29
30
31
32
33
...
53
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Results per page:
10
25
50
100
200