ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
February 2022
----- 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
17 participants
108 discussions
Start a n
N
ew thread
[reactos] 02/02: [PORTCLS] Don't leak CPortWaveCyclic.
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7db9fb3ba6d798f7ab294…
commit 7db9fb3ba6d798f7ab2946aa83bd6bb75aa3f88d Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Tue Feb 15 08:40:20 2022 -0500 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Tue Feb 15 08:43:08 2022 -0500 [PORTCLS] Don't leak CPortWaveCyclic. --- drivers/wdm/audio/backpln/portcls/port_wavecyclic.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/wdm/audio/backpln/portcls/port_wavecyclic.cpp b/drivers/wdm/audio/backpln/portcls/port_wavecyclic.cpp index f7c0afcb30c..cb54dcc275b 100644 --- a/drivers/wdm/audio/backpln/portcls/port_wavecyclic.cpp +++ b/drivers/wdm/audio/backpln/portcls/port_wavecyclic.cpp @@ -33,7 +33,7 @@ public: InterlockedDecrement(&m_Ref); if (!m_Ref) { - //delete this; + delete this; return 0; } return m_Ref; @@ -41,7 +41,7 @@ public: IMP_IPortWaveCyclic; IMP_ISubdevice; IMP_IPortEvents; - CPortWaveCyclic(IUnknown *OuterUnknown){} + CPortWaveCyclic(IUnknown *OuterUnknown) : m_Ref(0) {} virtual ~CPortWaveCyclic(){} protected:
2 years, 10 months
1
0
0
0
[reactos] 01/02: [PORTCLS] Do not rely on operator new to zero memory.
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ec1eb52ebf3cf8ff62a0e…
commit ec1eb52ebf3cf8ff62a0e1ea8f9dfa1e7b6c33dd Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Sun Jan 16 23:02:39 2022 -0500 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Tue Feb 15 08:43:05 2022 -0500 [PORTCLS] Do not rely on operator new to zero memory. The standard operator new does not do this, and GCC will in fact optimize out any zeroing done in the operator. --- drivers/wdm/audio/backpln/portcls/dma_slave.cpp | 24 +++++++++++---- .../wdm/audio/backpln/portcls/pin_wavecyclic.cpp | 35 ++++++++++++++++++---- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/drivers/wdm/audio/backpln/portcls/dma_slave.cpp b/drivers/wdm/audio/backpln/portcls/dma_slave.cpp index 4a0553b3ba8..40d5132f6f4 100644 --- a/drivers/wdm/audio/backpln/portcls/dma_slave.cpp +++ b/drivers/wdm/audio/backpln/portcls/dma_slave.cpp @@ -24,10 +24,7 @@ public: POOL_TYPE PoolType, ULONG Tag) { - PVOID P = ExAllocatePoolWithTag(PoolType, Size, Tag); - if (P) - RtlZeroMemory(P, Size); - return P; + return ExAllocatePoolWithTag(PoolType, Size, Tag); } STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); @@ -49,7 +46,24 @@ public: return m_Ref; } IMP_IDmaChannelInit; - CDmaChannelInit(IUnknown * OuterUnknown){} + CDmaChannelInit(IUnknown * OuterUnknown) : + m_pDeviceObject(nullptr), + m_pAdapter(nullptr), + m_DmaStarted(FALSE), + m_MapSize(0), + m_MapRegisterBase(nullptr), + m_LastTransferCount(0), + m_MaximumBufferSize(0), + m_MaxMapRegisters(0), + m_AllocatedBufferSize(0), + m_BufferSize(0), + m_Address({0}), + m_Buffer(nullptr), + m_Mdl(nullptr), + m_WriteToDevice(FALSE), + m_Ref(0) + { + } virtual ~CDmaChannelInit(){} protected: diff --git a/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp b/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp index 56eba19a438..07451f6190a 100644 --- a/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp +++ b/drivers/wdm/audio/backpln/portcls/pin_wavecyclic.cpp @@ -25,10 +25,7 @@ public: POOL_TYPE PoolType, ULONG Tag) { - PVOID P = ExAllocatePoolWithTag(PoolType, Size, Tag); - if (P) - RtlZeroMemory(P, Size); - return P; + return ExAllocatePoolWithTag(PoolType, Size, Tag); } STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); @@ -51,7 +48,35 @@ public: } IMP_IPortPinWaveCyclic; IMP_IServiceSink; - CPortPinWaveCyclic(IUnknown *OuterUnknown){} + CPortPinWaveCyclic(IUnknown *OuterUnknown) : + m_Port(nullptr), + m_Filter(nullptr), + m_KsPinDescriptor(nullptr), + m_Miniport(nullptr), + m_ServiceGroup(nullptr), + m_DmaChannel(nullptr), + m_Stream(nullptr), + m_State(KSSTATE_STOP), + m_Format(nullptr), + m_ConnectDetails(nullptr), + m_CommonBuffer(nullptr), + m_CommonBufferSize(0), + m_CommonBufferOffset(0), + m_IrpQueue(nullptr), + m_FrameSize(0), + m_Capture(FALSE), + m_TotalPackets(0), + m_StopCount(0), + m_Position({0}), + m_AllocatorFraming({{0}}), + m_Descriptor(nullptr), + m_EventListLock(0), + m_EventList({nullptr}), + m_ResetState(KSRESET_BEGIN), + m_Delay(0), + m_Ref(0) + { + } virtual ~CPortPinWaveCyclic(){} protected:
2 years, 10 months
1
0
0
0
[reactos] 01/01: [SHELL32_APITEST] ShellExecCmdLine: Close newly-opened windows
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=418edcd2bf95b5c9ca6fd…
commit 418edcd2bf95b5c9ca6fd3710323e2b1e821aee4 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Feb 15 20:15:36 2022 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Tue Feb 15 20:15:36 2022 +0900 [SHELL32_APITEST] ShellExecCmdLine: Close newly-opened windows ROSTESTS-378 --- .../rostests/apitests/shell32/ShellExecCmdLine.cpp | 49 ++++++++++++++-------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/modules/rostests/apitests/shell32/ShellExecCmdLine.cpp b/modules/rostests/apitests/shell32/ShellExecCmdLine.cpp index 699def5e114..e869e6deee5 100644 --- a/modules/rostests/apitests/shell32/ShellExecCmdLine.cpp +++ b/modules/rostests/apitests/shell32/ShellExecCmdLine.cpp @@ -594,6 +594,33 @@ static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) return TRUE; } +static void CleanupNewlyCreatedWindows(void) +{ + EnumWindows(EnumWindowsProc, (LPARAM)&s_wi1); + for (UINT i1 = 0; i1 < s_wi1.count; ++i1) + { + BOOL bFound = FALSE; + for (UINT i0 = 0; i0 < s_wi0.count; ++i0) + { + if (s_wi1.phwnd[i1] == s_wi0.phwnd[i0]) + { + bFound = TRUE; + break; + } + } + if (!bFound) + { + DWORD dwPID; + GetWindowThreadProcessId(s_wi1.phwnd[i1], &dwPID); + HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, TRUE, dwPID); + TerminateProcess(hProcess, -1); + CloseHandle(hProcess); + } + } + free(s_wi1.phwnd); + ZeroMemory(&s_wi1, sizeof(s_wi1)); +} + static void DoEntry(const TEST_ENTRY *pEntry) { HRESULT hr; @@ -632,24 +659,7 @@ static void DoEntry(const TEST_ENTRY *pEntry) ok(result == pEntry->result, "Line %d: result expected %d, was %d\n", pEntry->lineno, pEntry->result, result); - // close newly opened windows - EnumWindows(EnumWindowsProc, (LPARAM)&s_wi1); - for (UINT i1 = 0; i1 < s_wi1.count; ++i1) - { - BOOL bFound = FALSE; - for (UINT i0 = 0; i0 < s_wi0.count; ++i0) - { - if (s_wi1.phwnd[i1] == s_wi0.phwnd[i0]) - { - bFound = TRUE; - break; - } - } - if (!bFound) - PostMessageW(s_wi1.phwnd[i1], WM_CLOSE, 0, 0); - } - free(s_wi1.phwnd); - ZeroMemory(&s_wi1, sizeof(s_wi1)); + CleanupNewlyCreatedWindows(); } START_TEST(ShellExecCmdLine) @@ -733,6 +743,9 @@ START_TEST(ShellExecCmdLine) DoEntry(&s_entries_2[i]); } + Sleep(2000); + CleanupNewlyCreatedWindows(); + // clean up ok(DeleteFileW(s_win_test_exe), "failed to delete the test file\n"); ok(DeleteFileW(s_sys_bat_file), "failed to delete the test file\n");
2 years, 10 months
1
0
0
0
[reactos] 01/01: [NTUSER] Improve UserFreeInputContext and UserDestroyInputContext
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2b2366ab9012d4464e5de…
commit 2b2366ab9012d4464e5de88e5877e3e6f2a429eb Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Feb 15 19:07:50 2022 +0900 Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> CommitDate: Tue Feb 15 19:07:50 2022 +0900 [NTUSER] Improve UserFreeInputContext and UserDestroyInputContext CORE-18044 --- win32ss/user/ntuser/ime.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c index 14771e828ac..f29f4e4cfa4 100644 --- a/win32ss/user/ntuser/ime.c +++ b/win32ss/user/ntuser/ime.c @@ -1218,13 +1218,22 @@ AllocInputContextObject(PDESKTOP pDesk, VOID UserFreeInputContext(PVOID Object) { - PIMC pIMC = Object; + PIMC pIMC = Object, *ppIMC; PTHREADINFO pti; if (!pIMC) return; + /* Find the IMC in the list and remove it */ pti = pIMC->head.pti; + for (ppIMC = &pti->spDefaultImc; *ppIMC; ppIMC = &(*ppIMC)->pImcNext) + { + if (*ppIMC == pIMC) + { + *ppIMC = pIMC->pImcNext; + break; + } + } ExFreePoolWithTag(pIMC, USERTAG_IME); @@ -1234,25 +1243,13 @@ VOID UserFreeInputContext(PVOID Object) BOOLEAN UserDestroyInputContext(PVOID Object) { - PIMC pIMC = Object, pImc0; - PTHREADINFO pti; + PIMC pIMC = Object; if (!pIMC) return TRUE; UserMarkObjectDestroy(pIMC); - /* Find the IMC in the list and remove it */ - pti = pIMC->head.pti; - for (pImc0 = pti->spDefaultImc; pImc0; pImc0 = pImc0->pImcNext) - { - if (pImc0->pImcNext == pIMC) - { - pImc0->pImcNext = pIMC->pImcNext; - break; - } - } - return UserDeleteObject(pIMC->head.h, TYPE_INPUTCONTEXT); }
2 years, 10 months
1
0
0
0
[reactos] 01/01: [MSPAINT] Implement skew (#4362)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dfd06ee8fc53882a6ef3d…
commit dfd06ee8fc53882a6ef3d7a126aff809cea811f7 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Mon Feb 14 16:18:18 2022 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Mon Feb 14 16:18:18 2022 +0900 [MSPAINT] Implement skew (#4362) - Add SkewDIB helper function in dib.cpp. - Implement Stretch and Skew feature by SelectionModel::StretchSkew and ImageModel::StretchSkew. - Move ColorKeyedMaskBlt function. CORE-16634 --- base/applications/mspaint/dib.cpp | 56 ++++++++++++++++++++++++++++ base/applications/mspaint/dib.h | 2 + base/applications/mspaint/drawing.cpp | 33 ++++++++++++++++ base/applications/mspaint/drawing.h | 5 +++ base/applications/mspaint/history.cpp | 16 +++++++- base/applications/mspaint/selection.cpp | 33 ---------------- base/applications/mspaint/selectionmodel.cpp | 46 +++++++++++++++++++++-- base/applications/mspaint/selectionmodel.h | 1 + base/applications/mspaint/winproc.cpp | 12 +++++- 9 files changed, 165 insertions(+), 39 deletions(-) diff --git a/base/applications/mspaint/dib.cpp b/base/applications/mspaint/dib.cpp index 711071752ad..01c23fa84bf 100644 --- a/base/applications/mspaint/dib.cpp +++ b/base/applications/mspaint/dib.cpp @@ -9,6 +9,7 @@ /* INCLUDES *********************************************************/ #include "precomp.h" +#include <math.h> /* FUNCTIONS ********************************************************/ @@ -243,3 +244,58 @@ HBITMAP Rotate90DegreeBlt(HDC hDC1, INT cx, INT cy, BOOL bRight) DeleteDC(hDC2); return hbm2; } + +#ifndef M_PI + #define M_PI 3.14159265 +#endif + +HBITMAP SkewDIB(HDC hDC1, HBITMAP hbm, INT nDegree, BOOL bVertical) +{ + if (nDegree == 0) + return CopyDIBImage(hbm); + + const double eTan = tan(abs(nDegree) * M_PI / 180); + + BITMAP bm; + GetObjectW(hbm, sizeof(bm), &bm); + INT cx = bm.bmWidth, cy = bm.bmHeight, dx = 0, dy = 0; + if (bVertical) + dy = INT(cx * eTan); + else + dx = INT(cy * eTan); + + if (dx == 0 && dy == 0) + return CopyDIBImage(hbm); + + HBITMAP hbmNew = CreateColorDIB(cx + dx, cy + dy, RGB(255, 255, 255)); + if (!hbmNew) + return NULL; + + HDC hDC2 = CreateCompatibleDC(NULL); + HGDIOBJ hbm2Old = SelectObject(hDC2, hbmNew); + if (bVertical) + { + for (INT x = 0; x < cx; ++x) + { + INT delta = INT(x * eTan); + if (nDegree > 0) + BitBlt(hDC2, x, (dy - delta), 1, cy, hDC1, x, 0, SRCCOPY); + else + BitBlt(hDC2, x, delta, 1, cy, hDC1, x, 0, SRCCOPY); + } + } + else + { + for (INT y = 0; y < cy; ++y) + { + INT delta = INT(y * eTan); + if (nDegree > 0) + BitBlt(hDC2, (dx - delta), y, cx, 1, hDC1, 0, y, SRCCOPY); + else + BitBlt(hDC2, delta, y, cx, 1, hDC1, 0, y, SRCCOPY); + } + } + SelectObject(hDC2, hbm2Old); + DeleteDC(hDC2); + return hbmNew; +} diff --git a/base/applications/mspaint/dib.h b/base/applications/mspaint/dib.h index b045be15a50..e0f8d14f19a 100644 --- a/base/applications/mspaint/dib.h +++ b/base/applications/mspaint/dib.h @@ -29,3 +29,5 @@ void ShowFileLoadError(LPCTSTR name); HBITMAP SetBitmapAndInfo(HBITMAP hBitmap, LPCTSTR name, DWORD dwFileSize, BOOL isFile); HBITMAP Rotate90DegreeBlt(HDC hDC1, INT cx, INT cy, BOOL bRight); + +HBITMAP SkewDIB(HDC hDC1, HBITMAP hbm, INT nDegree, BOOL bVertical); diff --git a/base/applications/mspaint/drawing.cpp b/base/applications/mspaint/drawing.cpp index 059559252b9..490ff9a0a62 100644 --- a/base/applications/mspaint/drawing.cpp +++ b/base/applications/mspaint/drawing.cpp @@ -307,3 +307,36 @@ Text(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LPCT RestoreDC(hdc, iSaveDC); // Restore } + +BOOL +ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, + HDC hdcSrc, int nXSrc, int nYSrc, HBITMAP hbmMask, int xMask, int yMask, + DWORD dwRop, COLORREF keyColor) +{ + HDC hTempDC; + HDC hTempDC2; + HBITMAP hTempBm; + HBRUSH hTempBrush; + HBITMAP hTempMask; + + hTempDC = CreateCompatibleDC(hdcSrc); + hTempDC2 = CreateCompatibleDC(hdcSrc); + hTempBm = CreateCompatibleBitmap(hTempDC, nWidth, nHeight); + SelectObject(hTempDC, hTempBm); + hTempBrush = CreateSolidBrush(keyColor); + SelectObject(hTempDC, hTempBrush); + BitBlt(hTempDC, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, SRCCOPY); + PatBlt(hTempDC, 0, 0, nWidth, nHeight, PATINVERT); + hTempMask = CreateBitmap(nWidth, nHeight, 1, 1, NULL); + SelectObject(hTempDC2, hTempMask); + BitBlt(hTempDC2, 0, 0, nWidth, nHeight, hTempDC, 0, 0, SRCCOPY); + SelectObject(hTempDC, hbmMask); + BitBlt(hTempDC2, 0, 0, nWidth, nHeight, hTempDC, xMask, yMask, SRCAND); + MaskBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, hTempMask, xMask, yMask, dwRop); + DeleteDC(hTempDC); + DeleteDC(hTempDC2); + DeleteObject(hTempBm); + DeleteObject(hTempBrush); + DeleteObject(hTempMask); + return TRUE; +} diff --git a/base/applications/mspaint/drawing.h b/base/applications/mspaint/drawing.h index 017b71f6ddb..26178a83395 100644 --- a/base/applications/mspaint/drawing.h +++ b/base/applications/mspaint/drawing.h @@ -35,3 +35,8 @@ void RectSel(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2); void SelectionFrame(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF system_selection_color); void Text(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LPCTSTR lpchText, HFONT font, LONG style); + +extern BOOL +ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, + HDC hdcSrc, int nXSrc, int nYSrc, HBITMAP hbmMask, int xMask, int yMask, + DWORD dwRop, COLORREF keyColor); diff --git a/base/applications/mspaint/history.cpp b/base/applications/mspaint/history.cpp index d771fd37225..f0a3691ed5e 100644 --- a/base/applications/mspaint/history.cpp +++ b/base/applications/mspaint/history.cpp @@ -192,7 +192,21 @@ void ImageModel::StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSk int oldHeight = GetHeight(); INT newWidth = oldWidth * nStretchPercentX / 100; INT newHeight = oldHeight * nStretchPercentY / 100; - Insert(CopyDIBImage(hBms[currInd], newWidth, newHeight)); + if (oldWidth != newWidth || oldHeight != newHeight) + { + HBITMAP hbm0 = CopyDIBImage(hBms[currInd], newWidth, newHeight); + Insert(hbm0); + } + if (nSkewDegX) + { + HBITMAP hbm1 = SkewDIB(hDrawingDC, hBms[currInd], nSkewDegX, FALSE); + Insert(hbm1); + } + if (nSkewDegY) + { + HBITMAP hbm2 = SkewDIB(hDrawingDC, hBms[currInd], nSkewDegY, TRUE); + Insert(hbm2); + } if (GetWidth() != oldWidth || GetHeight() != oldHeight) NotifyDimensionsChanged(); NotifyImageChanged(); diff --git a/base/applications/mspaint/selection.cpp b/base/applications/mspaint/selection.cpp index 992b946a28a..3a87a21f19d 100644 --- a/base/applications/mspaint/selection.cpp +++ b/base/applications/mspaint/selection.cpp @@ -21,39 +21,6 @@ const LPCTSTR CSelectionWindow::m_lpszCursorLUT[9] = { /* action to mouse cursor IDC_SIZENESW, IDC_SIZENS, IDC_SIZENWSE }; -BOOL -ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, - HDC hdcSrc, int nXSrc, int nYSrc, HBITMAP hbmMask, int xMask, int yMask, - DWORD dwRop, COLORREF keyColor) -{ - HDC hTempDC; - HDC hTempDC2; - HBITMAP hTempBm; - HBRUSH hTempBrush; - HBITMAP hTempMask; - - hTempDC = CreateCompatibleDC(hdcSrc); - hTempDC2 = CreateCompatibleDC(hdcSrc); - hTempBm = CreateCompatibleBitmap(hTempDC, nWidth, nHeight); - SelectObject(hTempDC, hTempBm); - hTempBrush = CreateSolidBrush(keyColor); - SelectObject(hTempDC, hTempBrush); - BitBlt(hTempDC, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, SRCCOPY); - PatBlt(hTempDC, 0, 0, nWidth, nHeight, PATINVERT); - hTempMask = CreateBitmap(nWidth, nHeight, 1, 1, NULL); - SelectObject(hTempDC2, hTempMask); - BitBlt(hTempDC2, 0, 0, nWidth, nHeight, hTempDC, 0, 0, SRCCOPY); - SelectObject(hTempDC, hbmMask); - BitBlt(hTempDC2, 0, 0, nWidth, nHeight, hTempDC, xMask, yMask, SRCAND); - MaskBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, hTempMask, xMask, yMask, dwRop); - DeleteDC(hTempDC); - DeleteDC(hTempDC2); - DeleteObject(hTempBm); - DeleteObject(hTempBrush); - DeleteObject(hTempMask); - return TRUE; -} - void CSelectionWindow::ForceRefreshSelectionContents() { if (::IsWindowVisible(selectionWindow)) diff --git a/base/applications/mspaint/selectionmodel.cpp b/base/applications/mspaint/selectionmodel.cpp index c65ae21ac84..3cd41e1f64f 100644 --- a/base/applications/mspaint/selectionmodel.cpp +++ b/base/applications/mspaint/selectionmodel.cpp @@ -124,9 +124,6 @@ void SelectionModel::DrawBackgroundRect(HDC hDCImage, COLORREF crBg) Rect(hDCImage, m_rcSrc.left, m_rcSrc.top, m_rcSrc.right, m_rcSrc.bottom, crBg, crBg, 0, 1); } -extern BOOL -ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, HBITMAP hbmMask, int xMask, int yMask, DWORD dwRop, COLORREF keyColor); - void SelectionModel::DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTransparent) { if (!bBgTransparent) @@ -239,6 +236,49 @@ void SelectionModel::RotateNTimes90Degrees(int iN) NotifyRefreshNeeded(); } +void SelectionModel::StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX, int nSkewDegY) +{ + if (nStretchPercentX == 100 && nStretchPercentY == 100 && nSkewDegX == 0 && nSkewDegY == 0) + return; + + imageModel.DeleteSelection(); + imageModel.CopyPrevious(); + + INT oldWidth = RECT_WIDTH(m_rcDest); + INT oldHeight = RECT_HEIGHT(m_rcDest); + INT newWidth = oldWidth * nStretchPercentX / 100; + INT newHeight = oldHeight * nStretchPercentY / 100; + + if (oldWidth != newWidth || oldHeight != newHeight) + { + SelectObject(m_hDC, m_hBm); + HBITMAP hbm0 = CopyDIBImage(m_hBm, newWidth, newHeight); + InsertFromHBITMAP(hbm0, m_rcDest.left, m_rcDest.top); + DeleteObject(hbm0); + } + + if (nSkewDegX) + { + SelectObject(m_hDC, m_hBm); + HBITMAP hbm1 = SkewDIB(m_hDC, m_hBm, nSkewDegX, FALSE); + InsertFromHBITMAP(hbm1, m_rcDest.left, m_rcDest.top); + DeleteObject(hbm1); + } + + if (nSkewDegY) + { + SelectObject(m_hDC, m_hBm); + HBITMAP hbm2 = SkewDIB(m_hDC, m_hBm, nSkewDegY, TRUE); + InsertFromHBITMAP(hbm2, m_rcDest.left, m_rcDest.top); + DeleteObject(hbm2); + } + + selectionWindow.ShowWindow(SW_SHOWNOACTIVATE); + selectionWindow.ForceRefreshSelectionContents(); + placeSelWin(); + NotifyRefreshNeeded(); +} + HBITMAP SelectionModel::GetBitmap() const { return m_hBm; diff --git a/base/applications/mspaint/selectionmodel.h b/base/applications/mspaint/selectionmodel.h index b3a6982dffe..fbb208fed4b 100644 --- a/base/applications/mspaint/selectionmodel.h +++ b/base/applications/mspaint/selectionmodel.h @@ -54,6 +54,7 @@ public: void FlipHorizontally(); void FlipVertically(); void RotateNTimes90Degrees(int iN); + void StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX = 0, int nSkewDegY = 0); HBITMAP GetBitmap() const; int PtStackSize() const; void DrawFramePoly(HDC hDCImage); diff --git a/base/applications/mspaint/winproc.cpp b/base/applications/mspaint/winproc.cpp index 3bc14f6ae72..74e27a67661 100644 --- a/base/applications/mspaint/winproc.cpp +++ b/base/applications/mspaint/winproc.cpp @@ -695,8 +695,16 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH { if (stretchSkewDialog.DoModal(mainWindow.m_hWnd)) { - imageModel.StretchSkew(stretchSkewDialog.percentage.x, stretchSkewDialog.percentage.y, - stretchSkewDialog.angle.x, stretchSkewDialog.angle.y); + if (::IsWindowVisible(selectionWindow)) + { + selectionModel.StretchSkew(stretchSkewDialog.percentage.x, stretchSkewDialog.percentage.y, + stretchSkewDialog.angle.x, stretchSkewDialog.angle.y); + } + else + { + imageModel.StretchSkew(stretchSkewDialog.percentage.x, stretchSkewDialog.percentage.y, + stretchSkewDialog.angle.x, stretchSkewDialog.angle.y); + } } break; }
2 years, 10 months
1
0
0
0
[reactos] 01/01: [MSPAINT] Implement canvas rotation (#4360)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2d9091904730fcec3b743…
commit 2d9091904730fcec3b743d8af3cba0aa8aae1553 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Mon Feb 14 12:08:34 2022 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Mon Feb 14 12:08:34 2022 +0900 [MSPAINT] Implement canvas rotation (#4360) - Add Rotate90DegreeBlt function to dib.cpp. - Implement ImageModel::RotateNTimes90Degrees and SelectionModel::RotateNTimes90Degrees. - Improve ToolsModel::SetBackgroundTransparent. - Extend and improve SelectionModel::InsertFromHBITMAP. CORE-16634 --- base/applications/mspaint/dib.cpp | 35 ++++++++++++++++++++++++++++ base/applications/mspaint/dib.h | 2 ++ base/applications/mspaint/history.cpp | 16 ++++++++++++- base/applications/mspaint/main.cpp | 3 ++- base/applications/mspaint/selection.cpp | 1 + base/applications/mspaint/selectionmodel.cpp | 24 +++++++++++++++---- base/applications/mspaint/selectionmodel.h | 2 +- base/applications/mspaint/toolsmodel.cpp | 2 ++ base/applications/mspaint/winproc.cpp | 8 +++++++ 9 files changed, 86 insertions(+), 7 deletions(-) diff --git a/base/applications/mspaint/dib.cpp b/base/applications/mspaint/dib.cpp index 53a12f71602..711071752ad 100644 --- a/base/applications/mspaint/dib.cpp +++ b/base/applications/mspaint/dib.cpp @@ -208,3 +208,38 @@ HBITMAP DoLoadImageFile(HWND hwnd, LPCTSTR name, BOOL fIsMainFile) return hBitmap; } + +HBITMAP Rotate90DegreeBlt(HDC hDC1, INT cx, INT cy, BOOL bRight) +{ + HBITMAP hbm2 = CreateDIBWithProperties(cy, cx); + if (!hbm2) + return NULL; + + HDC hDC2 = CreateCompatibleDC(NULL); + HGDIOBJ hbm2Old = SelectObject(hDC2, hbm2); + if (bRight) + { + for (INT y = 0; y < cy; ++y) + { + for (INT x = 0; x < cx; ++x) + { + COLORREF rgb = GetPixel(hDC1, x, y); + SetPixelV(hDC2, cy - (y + 1), x, rgb); + } + } + } + else + { + for (INT y = 0; y < cy; ++y) + { + for (INT x = 0; x < cx; ++x) + { + COLORREF rgb = GetPixel(hDC1, x, y); + SetPixelV(hDC2, y, cx - (x + 1), rgb); + } + } + } + SelectObject(hDC2, hbm2Old); + DeleteDC(hDC2); + return hbm2; +} diff --git a/base/applications/mspaint/dib.h b/base/applications/mspaint/dib.h index 21c73a7dd13..b045be15a50 100644 --- a/base/applications/mspaint/dib.h +++ b/base/applications/mspaint/dib.h @@ -27,3 +27,5 @@ HBITMAP DoLoadImageFile(HWND hwnd, LPCTSTR name, BOOL fIsMainFile); void ShowFileLoadError(LPCTSTR name); HBITMAP SetBitmapAndInfo(HBITMAP hBitmap, LPCTSTR name, DWORD dwFileSize, BOOL isFile); + +HBITMAP Rotate90DegreeBlt(HDC hDC1, INT cx, INT cy, BOOL bRight); diff --git a/base/applications/mspaint/history.cpp b/base/applications/mspaint/history.cpp index bc0749148fa..d771fd37225 100644 --- a/base/applications/mspaint/history.cpp +++ b/base/applications/mspaint/history.cpp @@ -245,11 +245,25 @@ void ImageModel::FlipVertically() void ImageModel::RotateNTimes90Degrees(int iN) { - if (iN == 2) + switch (iN) { + case 1: + case 3: + DeleteObject(hBms[(currInd + 1) % HISTORYSIZE]); + hBms[(currInd + 1) % HISTORYSIZE] = Rotate90DegreeBlt(hDrawingDC, GetWidth(), GetHeight(), iN == 1); + currInd = (currInd + 1) % HISTORYSIZE; + if (undoSteps < HISTORYSIZE - 1) + undoSteps++; + redoSteps = 0; + SelectObject(hDrawingDC, hBms[currInd]); + imageSaved = FALSE; + NotifyDimensionsChanged(); + break; + case 2: CopyPrevious(); StretchBlt(hDrawingDC, GetWidth() - 1, GetHeight() - 1, -GetWidth(), -GetHeight(), GetDC(), 0, 0, GetWidth(), GetHeight(), SRCCOPY); + break; } NotifyImageChanged(); } diff --git a/base/applications/mspaint/main.cpp b/base/applications/mspaint/main.cpp index 4d285c2874d..f040ad7d300 100644 --- a/base/applications/mspaint/main.cpp +++ b/base/applications/mspaint/main.cpp @@ -344,7 +344,8 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument if (fontsDialog.IsWindow() && IsDialogMessage(fontsDialog, &messages)) continue; - TranslateAccelerator(hwnd, haccel, &messages); + if (TranslateAccelerator(hwnd, haccel, &messages)) + continue; /* Translate virtual-key messages into character messages */ TranslateMessage(&messages); diff --git a/base/applications/mspaint/selection.cpp b/base/applications/mspaint/selection.cpp index d3e7fe6065a..992b946a28a 100644 --- a/base/applications/mspaint/selection.cpp +++ b/base/applications/mspaint/selection.cpp @@ -266,6 +266,7 @@ LRESULT CSelectionWindow::OnToolsModelSettingsChanged(UINT nMsg, WPARAM wParam, LRESULT CSelectionWindow::OnSelectionModelRefreshNeeded(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + ForceRefreshSelectionContents(); return 0; } diff --git a/base/applications/mspaint/selectionmodel.cpp b/base/applications/mspaint/selectionmodel.cpp index 86d34dbd86d..c65ae21ac84 100644 --- a/base/applications/mspaint/selectionmodel.cpp +++ b/base/applications/mspaint/selectionmodel.cpp @@ -165,7 +165,7 @@ void SelectionModel::ScaleContentsToFit() DeleteDC(hTempDC); } -void SelectionModel::InsertFromHBITMAP(HBITMAP hBm) +void SelectionModel::InsertFromHBITMAP(HBITMAP hBm, INT x, INT y) { HDC hTempDC; HBITMAP hTempMask; @@ -174,14 +174,15 @@ void SelectionModel::InsertFromHBITMAP(HBITMAP hBm) DeleteObject(SelectObject(m_hDC, m_hBm)); SetRectEmpty(&m_rcSrc); - m_rcDest.left = m_rcDest.top = 0; + m_rcDest.left = x; + m_rcDest.top = y; m_rcDest.right = m_rcDest.left + GetDIBWidth(m_hBm); m_rcDest.bottom = m_rcDest.top + GetDIBHeight(m_hBm); hTempDC = CreateCompatibleDC(m_hDC); hTempMask = CreateBitmap(RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), 1, 1, NULL); SelectObject(hTempDC, hTempMask); - Rect(hTempDC, m_rcDest.left, m_rcDest.top, m_rcDest.right, m_rcDest.bottom, 0x00ffffff, 0x00ffffff, 1, 1); + Rect(hTempDC, 0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), 0x00ffffff, 0x00ffffff, 1, 1); DeleteObject(m_hMask); m_hMask = hTempMask; DeleteDC(hTempDC); @@ -211,14 +212,29 @@ void SelectionModel::FlipVertically() void SelectionModel::RotateNTimes90Degrees(int iN) { - if (iN == 2) + HBITMAP hbm; + switch (iN) { + case 1: + case 3: + imageModel.DeleteSelection(); + imageModel.CopyPrevious(); + SelectObject(m_hDC, m_hBm); + hbm = Rotate90DegreeBlt(m_hDC, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), iN == 1); + InsertFromHBITMAP(hbm, m_rcDest.left, m_rcDest.top); + DeleteObject(hbm); + selectionWindow.ShowWindow(SW_SHOWNOACTIVATE); + selectionWindow.ForceRefreshSelectionContents(); + placeSelWin(); + break; + case 2: SelectObject(m_hDC, m_hMask); StretchBlt(m_hDC, RECT_WIDTH(m_rcDest) - 1, RECT_HEIGHT(m_rcDest) - 1, -RECT_WIDTH(m_rcDest), -RECT_HEIGHT(m_rcDest), m_hDC, 0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), SRCCOPY); SelectObject(m_hDC, m_hBm); StretchBlt(m_hDC, RECT_WIDTH(m_rcDest) - 1, RECT_HEIGHT(m_rcDest) - 1, -RECT_WIDTH(m_rcDest), -RECT_HEIGHT(m_rcDest), m_hDC, 0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), SRCCOPY); + break; } NotifyRefreshNeeded(); } diff --git a/base/applications/mspaint/selectionmodel.h b/base/applications/mspaint/selectionmodel.h index 0243bc08f96..b3a6982dffe 100644 --- a/base/applications/mspaint/selectionmodel.h +++ b/base/applications/mspaint/selectionmodel.h @@ -50,7 +50,7 @@ public: void DrawSelection(HDC hDCImage, COLORREF crBg = 0, BOOL bBgTransparent = FALSE); void DrawSelectionStretched(HDC hDCImage); void ScaleContentsToFit(); - void InsertFromHBITMAP(HBITMAP hBm); + void InsertFromHBITMAP(HBITMAP hBm, INT x = 0, INT y = 0); void FlipHorizontally(); void FlipVertically(); void RotateNTimes90Degrees(int iN); diff --git a/base/applications/mspaint/toolsmodel.cpp b/base/applications/mspaint/toolsmodel.cpp index e42b04c6230..5d5c7fecd0d 100644 --- a/base/applications/mspaint/toolsmodel.cpp +++ b/base/applications/mspaint/toolsmodel.cpp @@ -141,6 +141,8 @@ void ToolsModel::SetBackgroundTransparent(BOOL bTransparent) { m_transpBg = bTransparent; NotifyToolSettingsChanged(); + if (selectionWindow.IsWindow()) + selectionWindow.ForceRefreshSelectionContents(); } int ToolsModel::GetZoom() const diff --git a/base/applications/mspaint/winproc.cpp b/base/applications/mspaint/winproc.cpp index b76a310070b..3bc14f6ae72 100644 --- a/base/applications/mspaint/winproc.cpp +++ b/base/applications/mspaint/winproc.cpp @@ -664,6 +664,10 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH imageModel.FlipVertically(); break; case 3: /* rotate 90 degrees */ + if (::IsWindowVisible(selectionWindow)) + selectionModel.RotateNTimes90Degrees(1); + else + imageModel.RotateNTimes90Degrees(1); break; case 4: /* rotate 180 degrees */ if (::IsWindowVisible(selectionWindow)) @@ -672,6 +676,10 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH imageModel.RotateNTimes90Degrees(2); break; case 5: /* rotate 270 degrees */ + if (::IsWindowVisible(selectionWindow)) + selectionModel.RotateNTimes90Degrees(3); + else + imageModel.RotateNTimes90Degrees(3); break; } break;
2 years, 10 months
1
0
0
0
[reactos] 01/01: [HAL:APIC] Ensure the interrupt gets requested immediately in ApicRequestSelfInterrupt. CORE-17663
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6eccbe27ec9268e257df6…
commit 6eccbe27ec9268e257df6aaca80d2496afb52d0e Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Mon Jan 3 22:19:35 2022 -0500 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sun Feb 13 17:15:00 2022 -0500 [HAL:APIC] Ensure the interrupt gets requested immediately in ApicRequestSelfInterrupt. CORE-17663 --- hal/halx86/apic/apic.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/hal/halx86/apic/apic.c b/hal/halx86/apic/apic.c index 0d152539c33..0fe921149f6 100644 --- a/hal/halx86/apic/apic.c +++ b/hal/halx86/apic/apic.c @@ -138,7 +138,18 @@ FORCEINLINE VOID ApicRequestSelfInterrupt(IN UCHAR Vector, UCHAR TriggerMode) { + ULONG Flags; APIC_INTERRUPT_COMMAND_REGISTER Icr; + APIC_INTERRUPT_COMMAND_REGISTER IcrStatus; + + /* + * The IRR registers are spaced 16 bytes apart and hold 32 status bits each. + * Pre-compute the register and bit that match our vector. + */ + ULONG VectorHigh = Vector / 32; + ULONG VectorLow = Vector % 32; + ULONG Irr = APIC_IRR + 0x10 * VectorHigh; + ULONG IrrBit = 1UL << VectorLow; /* Setup the command register */ Icr.Long0 = 0; @@ -147,8 +158,32 @@ ApicRequestSelfInterrupt(IN UCHAR Vector, UCHAR TriggerMode) Icr.TriggerMode = TriggerMode; Icr.DestinationShortHand = APIC_DSH_Self; + /* Disable interrupts so that we can change IRR without being interrupted */ + Flags = __readeflags(); + _disable(); + + /* Wait for the APIC to be idle */ + do + { + IcrStatus.Long0 = ApicRead(APIC_ICR0); + } while (IcrStatus.DeliveryStatus); + /* Write the low dword to send the interrupt */ ApicWrite(APIC_ICR0, Icr.Long0); + + /* Wait until we see the interrupt request. + * It will stay in requested state until we re-enable interrupts. + */ + while (!(ApicRead(Irr) & IrrBit)) + { + NOTHING; + } + + /* Finally, restore the original interrupt state */ + if (Flags & EFLAGS_INTERRUPT_MASK) + { + _enable(); + } } FORCEINLINE
2 years, 10 months
1
0
0
0
[reactos] 01/01: [RUNAS] Initial version of the runas utility
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5811da1ec5c7fe377e28d…
commit 5811da1ec5c7fe377e28dc207b250d771fade5e3 Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Sun Feb 13 21:45:10 2022 +0100 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Sun Feb 13 21:45:10 2022 +0100 [RUNAS] Initial version of the runas utility - Work in progress - Please do not translate it yet because the resources will change significantly --- base/applications/CMakeLists.txt | 1 + base/applications/runas/CMakeLists.txt | 8 ++ base/applications/runas/lang/de-DE.rc | 12 ++ base/applications/runas/lang/en-US.rc | 12 ++ base/applications/runas/resource.h | 7 ++ base/applications/runas/runas.c | 210 +++++++++++++++++++++++++++++++++ base/applications/runas/runas.rc | 24 ++++ 7 files changed, 274 insertions(+) diff --git a/base/applications/CMakeLists.txt b/base/applications/CMakeLists.txt index 7c18212ed4f..c363430f0cb 100644 --- a/base/applications/CMakeLists.txt +++ b/base/applications/CMakeLists.txt @@ -33,6 +33,7 @@ add_subdirectory(rapps) add_subdirectory(rapps_com) add_subdirectory(regedit) add_subdirectory(regedt32) +add_subdirectory(runas) add_subdirectory(sc) add_subdirectory(screensavers) add_subdirectory(sdbinst) diff --git a/base/applications/runas/CMakeLists.txt b/base/applications/runas/CMakeLists.txt new file mode 100644 index 00000000000..0bc636230f3 --- /dev/null +++ b/base/applications/runas/CMakeLists.txt @@ -0,0 +1,8 @@ + +include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/conutils) + +add_executable(runas runas.c runas.rc) +set_module_type(runas win32cui UNICODE) +target_link_libraries(runas conutils ${PSEH_LIB}) +add_importlibs(runas advapi32 msvcrt kernel32 ntdll) +add_cd_file(TARGET runas DESTINATION reactos/system32 FOR all) diff --git a/base/applications/runas/lang/de-DE.rc b/base/applications/runas/lang/de-DE.rc new file mode 100644 index 00000000000..53f50974495 --- /dev/null +++ b/base/applications/runas/lang/de-DE.rc @@ -0,0 +1,12 @@ +LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL + +STRINGTABLE +BEGIN + IDS_USAGE01 "Syntax für RUNAS:\n\n" + IDS_USAGE02 "RUNAS [ [/noprofile | /profile] [/env] [/savecred | /netonly] ]\n" + IDS_USAGE03 " /user:<Benutzername> Programm\n\n" + IDS_USAGE04 "RUNAS [ [/noprofile | /profile] [/env] [/savecred | /netonly] ]\n" + IDS_USAGE05 " /smartcard [/user:<Benutzername>] Programm\n\n" + IDS_USAGE06 "/noprofile" + IDS_USAGE07 "/profile" +END diff --git a/base/applications/runas/lang/en-US.rc b/base/applications/runas/lang/en-US.rc new file mode 100644 index 00000000000..815319ea936 --- /dev/null +++ b/base/applications/runas/lang/en-US.rc @@ -0,0 +1,12 @@ +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +STRINGTABLE +BEGIN + IDS_USAGE01 "RUNAS USAGE\n\n" + IDS_USAGE02 "RUNAS [ [/noprofile | /profile] [/env] [/savecred | /netonly] ]\n" + IDS_USAGE03 " /user:<UserName> program\n\n" + IDS_USAGE04 "RUNAS [ [/noprofile | /profile] [/env] [/savecred | /netonly] ]\n" + IDS_USAGE05 " /smartcard [/user:<UserName>] program\n\n" + IDS_USAGE06 "/noprofile" + IDS_USAGE07 "/profile" +END diff --git a/base/applications/runas/resource.h b/base/applications/runas/resource.h new file mode 100644 index 00000000000..11ad5ad8fa3 --- /dev/null +++ b/base/applications/runas/resource.h @@ -0,0 +1,7 @@ +#define IDS_USAGE01 7000 +#define IDS_USAGE02 7001 +#define IDS_USAGE03 7002 +#define IDS_USAGE04 7003 +#define IDS_USAGE05 7004 +#define IDS_USAGE06 7005 +#define IDS_USAGE07 7006 diff --git a/base/applications/runas/runas.c b/base/applications/runas/runas.c new file mode 100644 index 00000000000..581f24e2d00 --- /dev/null +++ b/base/applications/runas/runas.c @@ -0,0 +1,210 @@ +/* + * PROJECT: ReactOS runas utility + * LICENSE: GPL - See COPYING in the top level directory + * FILE: base/applications/runas/runas.c + * COPYRIGHT: Copyright 2022 Eric Kohl <eric.kohl(a)reactos.org> + */ + +#include <stdio.h> +#include <stdlib.h> +#include <limits.h> +#include <stdarg.h> + +#define WIN32_NO_STATUS +#include <windef.h> +#include <winbase.h> +#include <winnls.h> +#include <wincon.h> +#include <winsvc.h> +#include <conutils.h> + +#include "resource.h" + +#define NDEBUG +#include <debug.h> + +static +void +Usage(void) +{ + ConResPuts(StdOut, IDS_USAGE01); + ConResPuts(StdOut, IDS_USAGE02); + ConResPuts(StdOut, IDS_USAGE03); + ConResPuts(StdOut, IDS_USAGE04); + ConResPuts(StdOut, IDS_USAGE05); + ConResPuts(StdOut, IDS_USAGE06); + ConResPuts(StdOut, IDS_USAGE07); +} + + +int +wmain( + int argc, + LPCWSTR argv[]) +{ + LPCWSTR pszArg; + int i, result = 0; + BOOL bProfile = FALSE, bNoProfile = FALSE; + BOOL bEnv = FALSE; + PWSTR pszUserName = NULL; + PWSTR pszDomain = NULL; + PWSTR pszCommandLine = NULL; + PWSTR pszPassword = NULL; + PWSTR ptr; + STARTUPINFOW StartupInfo; + PROCESS_INFORMATION ProcessInfo; + DWORD dwLogonFlags = 0; + BOOL rc; + + /* Initialize the Console Standard Streams */ + ConInitStdStreams(); + + if (argc == 1) + { + Usage(); + return 0; + } + + ZeroMemory(&StartupInfo, sizeof(StartupInfo)); + ZeroMemory(&ProcessInfo, sizeof(ProcessInfo)); + + for (i = 1; i < argc; i++) + { + pszArg = argv[i]; + if (*pszArg == L'-' || *pszArg == L'/') + { + pszArg++; + if (wcscmp(pszArg, L"?") == 0) + { + Usage(); + } + else if (wcsicmp(pszArg, L"profile") == 0) + { + bProfile = TRUE; + } + else if (wcsicmp(pszArg, L"noprofile") == 0) + { + bNoProfile = TRUE; + } + else if (wcsicmp(pszArg, L"env") == 0) + { + bEnv = TRUE; + } + else if (_wcsnicmp(pszArg, L"user:", 5) == 0) + { + pszArg += 5; + ptr = wcschr(pszArg, L'@'); + if (ptr != NULL) + { + /* User@Domain */ + pszUserName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ((ptr - pszArg) + 1) * sizeof(WCHAR)); + if (pszUserName) + wcsncpy(pszUserName, pszArg, (ptr - pszArg)); + + ptr++; + pszDomain = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (wcslen(ptr) + 1) * sizeof(WCHAR)); + if (pszDomain) + wcscpy(pszDomain, ptr); + } + else + { + ptr = wcschr(pszArg, L'\\'); + if (ptr != NULL) + { + /* Domain\User */ + pszUserName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (wcslen(ptr + 1) + 1)* sizeof(WCHAR)); + if (pszUserName) + wcscpy(pszUserName, (ptr + 1)); + + pszDomain = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ((ptr - pszArg) + 1) * sizeof(WCHAR)); + if (pszDomain) + wcsncpy(pszDomain, pszArg, (ptr - pszArg)); + } + else + { + /* User */ + pszUserName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (wcslen(pszArg) + 1) * sizeof(WCHAR)); + if (pszUserName) + wcscpy(pszUserName, pszArg); + } + } + } + else + { + Usage(); + result = -1; + } + } + else + { + if (pszCommandLine == NULL) + { + pszCommandLine = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (wcslen(pszArg) + 1) * sizeof(WCHAR)); + if (pszCommandLine != NULL) + wcscpy(pszCommandLine, pszArg); + break; + } + } + } + + if (bProfile && bNoProfile) + { + Usage(); + result = -1; + goto done; + } + + if (bProfile) + dwLogonFlags |= LOGON_WITH_PROFILE; + + if (bNoProfile) + dwLogonFlags &= ~LOGON_WITH_PROFILE; + + if (bEnv) + { + DPRINT("env\n"); + } + + DPRINT("User: %S\n", pszUserName); + DPRINT("Domain: %S\n", pszDomain); + DPRINT("CommandLine: %S\n", pszCommandLine); + + /* FIXME: Query the password: */ + + rc = CreateProcessWithLogonW(pszUserName, + pszDomain, + pszPassword, + dwLogonFlags, + NULL, //[in, optional] LPCWSTR lpApplicationName, + pszCommandLine, + 0, //[in] DWORD dwCreationFlags, + bEnv ? GetEnvironmentStringsW() : NULL, + NULL, //[in, optional] LPCWSTR lpCurrentDirectory, + &StartupInfo, + &ProcessInfo); + if (rc == FALSE) + { + DPRINT("Error: %lu\n", GetLastError()); + } + +done: + if (ProcessInfo.hThread) + CloseHandle(ProcessInfo.hThread); + + if (ProcessInfo.hProcess) + CloseHandle(ProcessInfo.hProcess); + + if (pszPassword) + HeapFree(GetProcessHeap(), 0, pszPassword); + + if (pszCommandLine) + HeapFree(GetProcessHeap(), 0, pszCommandLine); + + if (pszUserName) + HeapFree(GetProcessHeap(), 0, pszUserName); + + if (pszDomain) + HeapFree(GetProcessHeap(), 0, pszDomain); + + return result; +} diff --git a/base/applications/runas/runas.rc b/base/applications/runas/runas.rc new file mode 100644 index 00000000000..ebf9f255cd9 --- /dev/null +++ b/base/applications/runas/runas.rc @@ -0,0 +1,24 @@ +#include <windef.h> +#include <winuser.h> + +#include "resource.h" + +/* Define language neutral resources */ +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +#define REACTOS_STR_FILE_DESCRIPTION "Run As Utility" +#define REACTOS_STR_INTERNAL_NAME "runas" +#define REACTOS_STR_ORIGINAL_FILENAME "runas.exe" +#include <reactos/version.rc> + +#include <reactos/manifest_exe.rc> + +/* UTF-8 */ +#pragma code_page(65001) + +#ifdef LANGUAGE_DE_DE + #include "lang/de-DE.rc" +#endif +#ifdef LANGUAGE_EN_US + #include "lang/en-US.rc" +#endif
2 years, 10 months
1
0
0
0
[reactos] 05/05: [NTOS:INBV] Code refactoring: Move all the boot animation-specific code out of inbv.c and into the new bootanim.c file.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f7e8214b5551b67880f3d…
commit f7e8214b5551b67880f3de188d67df26ff9ed2c2 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Feb 13 20:57:12 2022 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Feb 13 21:29:14 2022 +0100 [NTOS:INBV] Code refactoring: Move all the boot animation-specific code out of inbv.c and into the new bootanim.c file. - inbv.c now only contains the Inbv-specific API and nothing else. - It will make easier for people to write their own boot themes & animations, by just copying/adapting the bootanim.c file (and the resources). - Add SAL annotations. - All INBV progress bar functions (except for InbvIndicateProgress()) should not be INIT-only functions, since they can be (not yet in ROS) used at later times -- namely, for feedback during hibernation. --- ntoskrnl/ex/init.c | 2 + ntoskrnl/inbv/bootanim.c | 894 ++++-------------------------------- ntoskrnl/inbv/inbv.c | 962 ++++++--------------------------------- ntoskrnl/inbv/logo.h | 40 ++ ntoskrnl/include/internal/inbv.h | 87 ++-- ntoskrnl/ntos.cmake | 1 + sdk/include/ndk/inbvtypes.h | 6 +- 7 files changed, 336 insertions(+), 1656 deletions(-) diff --git a/ntoskrnl/ex/init.c b/ntoskrnl/ex/init.c index fc98cccd430..4dadddaa0c7 100644 --- a/ntoskrnl/ex/init.c +++ b/ntoskrnl/ex/init.c @@ -11,6 +11,8 @@ #include <ntoskrnl.h> #include <reactos/buildno.h> +#include "inbv/logo.h" + #define NDEBUG #include <debug.h> diff --git a/ntoskrnl/inbv/bootanim.c b/ntoskrnl/inbv/bootanim.c index 4f6a8df1e0f..0f962956918 100644 --- a/ntoskrnl/inbv/bootanim.c +++ b/ntoskrnl/inbv/bootanim.c @@ -1,10 +1,17 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Boot Theme & Animation + * COPYRIGHT: Copyright 2007 Alex Ionescu (alex.ionescu(a)reactos.org) + * Copyright 2007 Hervé Poussineau (hpoussin(a)reactos.org) + * Copyright 2012-2022 Hermès Bélusca-Maïto + * Copyright 2017-2018 Stanislav Motylkov + * Copyright 2019-2020 Yaroslav Kibysh + */ + /* INCLUDES ******************************************************************/ #include <ntoskrnl.h> - -#define NDEBUG -#include <debug.h> - #include "inbv/logo.h" /* See also mm/ARM3/miarm.h */ @@ -13,35 +20,14 @@ /* GLOBALS *******************************************************************/ -/* - * Enable this define if you want Inbv to use coloured headless mode. - */ -// #define INBV_HEADLESS_COLORS - /* * ReactOS uses the same boot screen for all the products. - */ - -/* + * * Enable this define when ReactOS will have different SKUs * (Workstation, Server, Storage Server, Cluster Server, etc...). */ // #define REACTOS_SKUS -typedef struct _INBV_PROGRESS_STATE -{ - ULONG Floor; - ULONG Ceiling; - ULONG Bias; -} INBV_PROGRESS_STATE; - -typedef struct _BT_PROGRESS_INDICATOR -{ - ULONG Count; - ULONG Expected; - ULONG Percentage; -} BT_PROGRESS_INDICATOR, *PBT_PROGRESS_INDICATOR; - typedef enum _ROT_BAR_TYPE { RB_UNSPECIFIED, @@ -71,20 +57,8 @@ typedef enum _BBLT_HORZ_ALIGNMENT */ #define INBV_ROTBAR_IMPLEMENTED -static KSPIN_LOCK BootDriverLock; -static KIRQL InbvOldIrql; -static INBV_DISPLAY_STATE InbvDisplayState = INBV_DISPLAY_STATE_DISABLED; -BOOLEAN InbvBootDriverInstalled = FALSE; -static BOOLEAN InbvDisplayDebugStrings = FALSE; -static INBV_DISPLAY_STRING_FILTER InbvDisplayFilter = NULL; -static ULONG ProgressBarLeft = 0, ProgressBarTop = 0; -static ULONG ProgressBarWidth = 0, ProgressBarHeight = 0; -static BOOLEAN ShowProgressBar = FALSE; -static INBV_PROGRESS_STATE InbvProgressState; -static BT_PROGRESS_INDICATOR InbvProgressIndicator = {0, 25, 0}; -static INBV_RESET_DISPLAY_PARAMETERS InbvResetDisplayParameters = NULL; -static ULONG ResourceCount = 0; -static PUCHAR ResourceList[1 + IDB_MAX_RESOURCE]; // First entry == NULL, followed by 'ResourceCount' entries. +extern ULONG ProgressBarLeft, ProgressBarTop; +extern BOOLEAN ShowProgressBar; #ifdef INBV_ROTBAR_IMPLEMENTED /* @@ -115,86 +89,40 @@ static UCHAR RotLineBuffer[SCREEN_WIDTH * 6]; #endif -/* - * Headless terminal text colors - */ - -#ifdef INBV_HEADLESS_COLORS - -// Conversion table CGA to ANSI color index -static const UCHAR CGA_TO_ANSI_COLOR_TABLE[16] = -{ - 0, // Black - 4, // Blue - 2, // Green - 6, // Cyan - 1, // Red - 5, // Magenta - 3, // Brown/Yellow - 7, // Grey/White - - 60, // Bright Black - 64, // Bright Blue - 62, // Bright Green - 66, // Bright Cyan - 61, // Bright Red - 65, // Bright Magenta - 63, // Bright Yellow - 67 // Bright Grey (White) -}; - -#define CGA_TO_ANSI_COLOR(CgaColor) \ - CGA_TO_ANSI_COLOR_TABLE[CgaColor & 0x0F] - -#endif +/* FADE-IN FUNCTION **********************************************************/ -// Default colors: text in white, background in black -static ULONG InbvTerminalTextColor = 37; -static ULONG InbvTerminalBkgdColor = 40; - - -/* FADING FUNCTION ***********************************************************/ - -/** From include/psdk/wingdi.h **/ +/** From include/psdk/wingdi.h and bootvid/precomp.h **/ typedef struct tagRGBQUAD { - UCHAR rgbBlue; - UCHAR rgbGreen; - UCHAR rgbRed; - UCHAR rgbReserved; -} RGBQUAD,*LPRGBQUAD; -/*******************************/ - -static RGBQUAD MainPalette[16]; + UCHAR rgbBlue; + UCHAR rgbGreen; + UCHAR rgbRed; + UCHAR rgbReserved; +} RGBQUAD, *LPRGBQUAD; -#define PALETTE_FADE_STEPS 12 -#define PALETTE_FADE_TIME (15 * 1000) /* 15 ms */ - -/** From bootvid/precomp.h **/ // // Bitmap Header // typedef struct tagBITMAPINFOHEADER { - ULONG biSize; - LONG biWidth; - LONG biHeight; + ULONG biSize; + LONG biWidth; + LONG biHeight; USHORT biPlanes; USHORT biBitCount; - ULONG biCompression; - ULONG biSizeImage; - LONG biXPelsPerMeter; - LONG biYPelsPerMeter; - ULONG biClrUsed; - ULONG biClrImportant; + ULONG biCompression; + ULONG biSizeImage; + LONG biXPelsPerMeter; + LONG biYPelsPerMeter; + ULONG biClrUsed; + ULONG biClrImportant; } BITMAPINFOHEADER, *PBITMAPINFOHEADER; -/****************************/ +/*******************************/ -// -// Needed prototypes -// -VOID NTAPI InbvAcquireLock(VOID); -VOID NTAPI InbvReleaseLock(VOID); +static RGBQUAD MainPalette[16]; + +#define PALETTE_FADE_STEPS 12 +#define PALETTE_FADE_TIME (15 * 1000) /* 15 ms */ static VOID BootLogoFadeIn(VOID) @@ -209,7 +137,7 @@ BootLogoFadeIn(VOID) /* Check if we are installed and we own the display */ if (!InbvBootDriverInstalled || - (InbvDisplayState != INBV_DISPLAY_STATE_OWNED)) + (InbvGetDisplayState() != INBV_DISPLAY_STATE_OWNED)) { return; } @@ -341,694 +269,71 @@ BitBltAligned( /* FUNCTIONS *****************************************************************/ -CODE_SEG("INIT") -PVOID -NTAPI -FindBitmapResource(IN PLOADER_PARAMETER_BLOCK LoaderBlock, - IN ULONG ResourceId) -{ - UNICODE_STRING UpString = RTL_CONSTANT_STRING(L"ntoskrnl.exe"); - UNICODE_STRING MpString = RTL_CONSTANT_STRING(L"ntkrnlmp.exe"); - PLIST_ENTRY NextEntry, ListHead; - PLDR_DATA_TABLE_ENTRY LdrEntry; - PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry; - LDR_RESOURCE_INFO ResourceInfo; - NTSTATUS Status; - PVOID Data = NULL; - - /* Loop the driver list */ - ListHead = &LoaderBlock->LoadOrderListHead; - NextEntry = ListHead->Flink; - while (NextEntry != ListHead) - { - /* Get the entry */ - LdrEntry = CONTAINING_RECORD(NextEntry, - LDR_DATA_TABLE_ENTRY, - InLoadOrderLinks); - - /* Check for a match */ - if (RtlEqualUnicodeString(&LdrEntry->BaseDllName, &UpString, TRUE) || - RtlEqualUnicodeString(&LdrEntry->BaseDllName, &MpString, TRUE)) - { - /* Break out */ - break; - } - } - - /* Check if we found it */ - if (NextEntry != ListHead) - { - /* Try to find the resource */ - ResourceInfo.Type = 2; // RT_BITMAP; - ResourceInfo.Name = ResourceId; - ResourceInfo.Language = 0; - Status = LdrFindResource_U(LdrEntry->DllBase, - &ResourceInfo, - RESOURCE_DATA_LEVEL, - &ResourceDataEntry); - if (NT_SUCCESS(Status)) - { - /* Access the resource */ - ULONG Size = 0; - Status = LdrAccessResource(LdrEntry->DllBase, - ResourceDataEntry, - &Data, - &Size); - if ((Data) && (ResourceId < 3)) - { - KiBugCheckData[4] ^= RtlComputeCrc32(0, Data, Size); - } - if (!NT_SUCCESS(Status)) Data = NULL; - } - } - - /* Return the pointer */ - return Data; -} - CODE_SEG("INIT") BOOLEAN NTAPI -InbvDriverInitialize(IN PLOADER_PARAMETER_BLOCK LoaderBlock, - IN ULONG Count) +BootAnimInitialize( + _In_ PLOADER_PARAMETER_BLOCK LoaderBlock, + _In_ ULONG Count) { - PCHAR CommandLine; - BOOLEAN ResetMode = FALSE; // By default do not reset the video mode +#if 0 ULONG i; /* Quit if we're already installed */ if (InbvBootDriverInstalled) return TRUE; - /* Initialize the lock and check the current display state */ - KeInitializeSpinLock(&BootDriverLock); - if (InbvDisplayState == INBV_DISPLAY_STATE_OWNED) - { - /* Reset the video mode in case we do not have a custom boot logo */ - CommandLine = (LoaderBlock->LoadOptions ? _strupr(LoaderBlock->LoadOptions) : NULL); - ResetMode = (CommandLine == NULL) || (strstr(CommandLine, "BOOTLOGO") == NULL); - } - - /* Initialize the video */ - InbvBootDriverInstalled = VidInitialize(ResetMode); - if (InbvBootDriverInstalled) - { - /* Find bitmap resources in the kernel */ - ResourceCount = min(Count, RTL_NUMBER_OF(ResourceList) - 1); - for (i = 1; i <= ResourceCount; i++) - { - /* Do the lookup */ - ResourceList[i] = FindBitmapResource(LoaderBlock, i); - } - - /* Set the progress bar ranges */ - InbvSetProgressBarSubset(0, 100); - } - - /* Return install state */ - return InbvBootDriverInstalled; -} - -VOID -NTAPI -InbvAcquireLock(VOID) -{ - KIRQL OldIrql; - - /* Check if we're at dispatch level or lower */ - OldIrql = KeGetCurrentIrql(); - if (OldIrql <= DISPATCH_LEVEL) - { - /* Loop until the lock is free */ - while (!KeTestSpinLock(&BootDriverLock)); - - /* Raise IRQL to dispatch level */ - KeRaiseIrql(DISPATCH_LEVEL, &OldIrql); - } - - /* Acquire the lock */ - KiAcquireSpinLock(&BootDriverLock); - InbvOldIrql = OldIrql; -} - -VOID -NTAPI -InbvReleaseLock(VOID) -{ - KIRQL OldIrql; - - /* Capture the old IRQL */ - OldIrql = InbvOldIrql; - - /* Release the driver lock */ - KiReleaseSpinLock(&BootDriverLock); - - /* If we were at dispatch level or lower, restore the old IRQL */ - if (InbvOldIrql <= DISPATCH_LEVEL) KeLowerIrql(OldIrql); -} - -VOID -NTAPI -InbvEnableBootDriver(IN BOOLEAN Enable) -{ - /* Check if we're installed */ - if (InbvBootDriverInstalled) - { - /* Check for lost state */ - if (InbvDisplayState >= INBV_DISPLAY_STATE_LOST) return; - - /* Acquire the lock */ - InbvAcquireLock(); - - /* Cleanup the screen if we own it */ - if (InbvDisplayState == INBV_DISPLAY_STATE_OWNED) VidCleanUp(); - - /* Set the new display state */ - InbvDisplayState = Enable ? INBV_DISPLAY_STATE_OWNED : - INBV_DISPLAY_STATE_DISABLED; - - /* Release the lock */ - InbvReleaseLock(); - } - else - { - /* Set the new display state */ - InbvDisplayState = Enable ? INBV_DISPLAY_STATE_OWNED : - INBV_DISPLAY_STATE_DISABLED; - } -} - -VOID -NTAPI -InbvAcquireDisplayOwnership(VOID) -{ - /* Check if we have a callback and we're just acquiring it now */ - if ((InbvResetDisplayParameters) && - (InbvDisplayState == INBV_DISPLAY_STATE_LOST)) - { - /* Call the callback */ - InbvResetDisplayParameters(80, 50); - } - - /* Acquire the display */ - InbvDisplayState = INBV_DISPLAY_STATE_OWNED; -} - -VOID -NTAPI -InbvSetDisplayOwnership(IN BOOLEAN DisplayOwned) -{ - /* Set the new display state */ - InbvDisplayState = DisplayOwned ? INBV_DISPLAY_STATE_OWNED : - INBV_DISPLAY_STATE_LOST; -} - -BOOLEAN -NTAPI -InbvCheckDisplayOwnership(VOID) -{ - /* Return if we own it or not */ - return InbvDisplayState != INBV_DISPLAY_STATE_LOST; -} - -INBV_DISPLAY_STATE -NTAPI -InbvGetDisplayState(VOID) -{ - /* Return the actual state */ - return InbvDisplayState; -} - -BOOLEAN -NTAPI -InbvDisplayString(IN PCHAR String) -{ - /* Make sure we own the display */ - if (InbvDisplayState == INBV_DISPLAY_STATE_OWNED) - { - /* If we're not allowed, return success anyway */ - if (!InbvDisplayDebugStrings) return TRUE; - - /* Check if a filter is installed */ - if (InbvDisplayFilter) InbvDisplayFilter(&String); - - /* Acquire the lock */ - InbvAcquireLock(); - - /* Make sure we're installed and display the string */ - if (InbvBootDriverInstalled) VidDisplayString((PUCHAR)String); - - /* Print the string on the EMS port */ - HeadlessDispatch(HeadlessCmdPutString, - String, - strlen(String) + sizeof(ANSI_NULL), - NULL, - NULL); - - /* Release the lock */ - InbvReleaseLock(); - - /* All done */ - return TRUE; - } - - /* We don't own it, fail */ - return FALSE; -} - -BOOLEAN -NTAPI -InbvEnableDisplayString(IN BOOLEAN Enable) -{ - BOOLEAN OldSetting; - - /* Get the old setting */ - OldSetting = InbvDisplayDebugStrings; - - /* Update it */ - InbvDisplayDebugStrings = Enable; - - /* Return the old setting */ - return OldSetting; -} - -VOID -NTAPI -InbvInstallDisplayStringFilter(IN INBV_DISPLAY_STRING_FILTER Filter) -{ - /* Save the filter */ - InbvDisplayFilter = Filter; -} - -BOOLEAN -NTAPI -InbvIsBootDriverInstalled(VOID) -{ - /* Return driver state */ - return InbvBootDriverInstalled; -} - -VOID -NTAPI -InbvNotifyDisplayOwnershipLost(IN INBV_RESET_DISPLAY_PARAMETERS Callback) -{ - /* Check if we're installed */ - if (InbvBootDriverInstalled) - { - /* Acquire the lock and cleanup if we own the screen */ - InbvAcquireLock(); - if (InbvDisplayState != INBV_DISPLAY_STATE_LOST) VidCleanUp(); - - /* Set the reset callback and display state */ - InbvResetDisplayParameters = Callback; - InbvDisplayState = INBV_DISPLAY_STATE_LOST; - - /* Release the lock */ - InbvReleaseLock(); - } - else - { - /* Set the reset callback and display state */ - InbvResetDisplayParameters = Callback; - InbvDisplayState = INBV_DISPLAY_STATE_LOST; - } -} - -BOOLEAN -NTAPI -InbvResetDisplay(VOID) -{ - /* Check if we're installed and we own it */ - if (InbvBootDriverInstalled && - (InbvDisplayState == INBV_DISPLAY_STATE_OWNED)) + /* Find bitmap resources in the kernel */ + ResourceCount = min(Count, RTL_NUMBER_OF(ResourceList) - 1); + for (i = 1; i <= ResourceCount; i++) { - /* Do the reset */ - VidResetDisplay(TRUE); - return TRUE; + /* Do the lookup */ + ResourceList[i] = FindBitmapResource(LoaderBlock, i); } - /* Nothing to reset */ - return FALSE; -} - -VOID -NTAPI -InbvSetScrollRegion(IN ULONG Left, - IN ULONG Top, - IN ULONG Right, - IN ULONG Bottom) -{ - /* Just call bootvid */ - VidSetScrollRegion(Left, Top, Right, Bottom); -} - -VOID -NTAPI -InbvSetTextColor(IN ULONG Color) -{ - HEADLESS_CMD_SET_COLOR HeadlessSetColor; - - /* Set color for EMS port */ -#ifdef INBV_HEADLESS_COLORS - InbvTerminalTextColor = 30 + CGA_TO_ANSI_COLOR(Color); -#else - InbvTerminalTextColor = 37; + /* Set the progress bar ranges */ + InbvSetProgressBarSubset(0, 100); #endif - HeadlessSetColor.TextColor = InbvTerminalTextColor; - HeadlessSetColor.BkgdColor = InbvTerminalBkgdColor; - HeadlessDispatch(HeadlessCmdSetColor, - &HeadlessSetColor, - sizeof(HeadlessSetColor), - NULL, - NULL); - - /* Update the text color */ - VidSetTextColor(Color); -} - -VOID -NTAPI -InbvSolidColorFill(IN ULONG Left, - IN ULONG Top, - IN ULONG Right, - IN ULONG Bottom, - IN ULONG Color) -{ - HEADLESS_CMD_SET_COLOR HeadlessSetColor; - - /* Make sure we own it */ - if (InbvDisplayState == INBV_DISPLAY_STATE_OWNED) - { - /* Acquire the lock */ - InbvAcquireLock(); - - /* Check if we're installed */ - if (InbvBootDriverInstalled) - { - /* Call bootvid */ - VidSolidColorFill(Left, Top, Right, Bottom, (UCHAR)Color); - } - /* Set color for EMS port and clear display */ -#ifdef INBV_HEADLESS_COLORS - InbvTerminalBkgdColor = 40 + CGA_TO_ANSI_COLOR(Color); -#else - InbvTerminalBkgdColor = 40; -#endif - HeadlessSetColor.TextColor = InbvTerminalTextColor; - HeadlessSetColor.BkgdColor = InbvTerminalBkgdColor; - HeadlessDispatch(HeadlessCmdSetColor, - &HeadlessSetColor, - sizeof(HeadlessSetColor), - NULL, - NULL); - HeadlessDispatch(HeadlessCmdClearDisplay, - NULL, 0, - NULL, NULL); - - /* Release the lock */ - InbvReleaseLock(); - } + /* Return install state */ + return TRUE; } /** * @brief - * Updates the progress bar percentage, relative to the current - * percentage sub-range previously set by InbvSetProgressBarSubset(). + * Ticks the progress bar. Used by InbvUpdateProgressBar() and related. * - * @param[in] Percentage - * The progress percentage, relative to the current sub-range. + * @param[in] SubPercentTimes100 + * The progress percentage, scaled up by 100. * * @return None. **/ -CODE_SEG("INIT") VOID NTAPI -InbvUpdateProgressBar( - _In_ ULONG Percentage) +BootAnimTickProgressBar( + _In_ ULONG SubPercentTimes100) { - ULONG TotalProgress, FillCount; + ULONG FillCount; /* Make sure the progress bar is enabled, that we own and are installed */ - if (ShowProgressBar && - InbvBootDriverInstalled && - (InbvDisplayState == INBV_DISPLAY_STATE_OWNED)) - { - /* Compute fill count */ - TotalProgress = InbvProgressState.Floor + (Percentage * InbvProgressState.Bias); - FillCount = ProgressBarWidth * TotalProgress / (100 * 100); - - /* Acquire the lock */ - InbvAcquireLock(); - - /* Fill the progress bar */ - VidSolidColorFill(ProgressBarLeft, - ProgressBarTop, - ProgressBarLeft + FillCount, - ProgressBarTop + ProgressBarHeight, - BV_COLOR_WHITE); - - /* Release the lock */ - InbvReleaseLock(); - } -} - -VOID -NTAPI -InbvBufferToScreenBlt(IN PUCHAR Buffer, - IN ULONG X, - IN ULONG Y, - IN ULONG Width, - IN ULONG Height, - IN ULONG Delta) -{ - /* Check if we're installed and we own it */ - if (InbvBootDriverInstalled && - (InbvDisplayState == INBV_DISPLAY_STATE_OWNED)) - { - /* Do the blit */ - VidBufferToScreenBlt(Buffer, X, Y, Width, Height, Delta); - } -} - -VOID -NTAPI -InbvBitBlt(IN PUCHAR Buffer, - IN ULONG X, - IN ULONG Y) -{ - /* Check if we're installed and we own it */ - if (InbvBootDriverInstalled && - (InbvDisplayState == INBV_DISPLAY_STATE_OWNED)) - { - /* Acquire the lock */ - InbvAcquireLock(); - - /* Do the blit */ - VidBitBlt(Buffer, X, Y); - - /* Release the lock */ - InbvReleaseLock(); - } -} - -VOID -NTAPI -InbvScreenToBufferBlt(OUT PUCHAR Buffer, - IN ULONG X, - IN ULONG Y, - IN ULONG Width, - IN ULONG Height, - IN ULONG Delta) -{ - /* Check if we're installed and we own it */ - if (InbvBootDriverInstalled && - (InbvDisplayState == INBV_DISPLAY_STATE_OWNED)) - { - /* Do the blit */ - VidScreenToBufferBlt(Buffer, X, Y, Width, Height, Delta); - } -} - -/** - * @brief - * Sets the screen coordinates of the loading progress bar and enable it. - * - * @param[in] Left - * @param[in] Top - * The left/top coordinates. - * - * (ReactOS-specific) - * @param[in] Width - * @param[in] Height - * The width/height of the progress bar. - * - * @return None. - **/ -CODE_SEG("INIT") -VOID -NTAPI -InbvSetProgressBarCoordinates( - _In_ ULONG Left, - _In_ ULONG Top, - _In_ ULONG Width, - _In_ ULONG Height) -{ - /* Update the coordinates */ - ProgressBarLeft = Left; - ProgressBarTop = Top; - ProgressBarWidth = Width; - ProgressBarHeight = Height; - - /* Enable the progress bar */ - ShowProgressBar = TRUE; -} - -/** - * @brief - * Specifies a progress percentage sub-range. - * Further calls to InbvIndicateProgress() or InbvUpdateProgressBar() - * will update the progress percentage relative to this sub-range. - * In particular, the percentage provided to InbvUpdateProgressBar() - * is relative to this sub-range. - * - * @param[in] Floor - * The lower bound percentage of the sub-range (default: 0). - * - * @param[in] Ceiling - * The upper bound percentage of the sub-range (default: 100). - * - * @return None. - **/ -CODE_SEG("INIT") -VOID -NTAPI -InbvSetProgressBarSubset( - _In_ ULONG Floor, - _In_ ULONG Ceiling) -{ - /* Sanity checks */ - ASSERT(Floor < Ceiling); - ASSERT(Ceiling <= 100); - - /* Update the progress bar state */ - InbvProgressState.Floor = Floor * 100; - InbvProgressState.Ceiling = Ceiling * 100; - InbvProgressState.Bias = Ceiling - Floor; -} - -/** - * @brief - * Gives some progress feedback, without specifying any explicit number - * of progress steps or percentage. - * The corresponding percentage is derived from the progress indicator's - * current count, capped to the number of expected calls to be made to - * this function (default: 25, see @b InbvProgressIndicator.Expected). - * - * @return None. - **/ -CODE_SEG("INIT") -VOID -NTAPI -InbvIndicateProgress(VOID) -{ - ULONG Percentage; + ASSERT(ShowProgressBar && + InbvBootDriverInstalled && + (InbvGetDisplayState() == INBV_DISPLAY_STATE_OWNED)); - /* Increase progress */ - InbvProgressIndicator.Count++; - - /* Compute the new percentage - Don't go over 100% */ - Percentage = 100 * InbvProgressIndicator.Count / - InbvProgressIndicator.Expected; - Percentage = min(Percentage, 99); - - if (Percentage != InbvProgressIndicator.Percentage) - { - /* Percentage has changed, update the progress bar */ - InbvProgressIndicator.Percentage = Percentage; - InbvUpdateProgressBar(Percentage); - } -} - -PUCHAR -NTAPI -InbvGetResourceAddress(IN ULONG ResourceNumber) -{ - /* Validate the resource number */ - if (ResourceNumber > ResourceCount) return NULL; - - /* Return the address */ - return ResourceList[ResourceNumber]; -} - -NTSTATUS -NTAPI -NtDisplayString(IN PUNICODE_STRING DisplayString) -{ - NTSTATUS Status; - UNICODE_STRING CapturedString; - OEM_STRING OemString; - ULONG OemLength; - KPROCESSOR_MODE PreviousMode; + /* Compute fill count */ + FillCount = VID_PROGRESS_BAR_WIDTH * SubPercentTimes100 / (100 * 100); - PAGED_CODE(); - - PreviousMode = ExGetPreviousMode(); - - /* We require the TCB privilege */ - if (!SeSinglePrivilegeCheck(SeTcbPrivilege, PreviousMode)) - return STATUS_PRIVILEGE_NOT_HELD; - - /* Capture the string */ - Status = ProbeAndCaptureUnicodeString(&CapturedString, PreviousMode, DisplayString); - if (!NT_SUCCESS(Status)) - return Status; - - /* Do not display the string if it is empty */ - if (CapturedString.Length == 0 || CapturedString.Buffer == NULL) - { - Status = STATUS_SUCCESS; - goto Quit; - } - - /* - * Convert the string since INBV understands only ANSI/OEM. Allocate the - * string buffer in non-paged pool because INBV passes it down to BOOTVID. - * We cannot perform the allocation using RtlUnicodeStringToOemString() - * since its allocator uses PagedPool. - */ - OemLength = RtlUnicodeStringToOemSize(&CapturedString); - if (OemLength > MAXUSHORT) - { - Status = STATUS_BUFFER_OVERFLOW; - goto Quit; - } - RtlInitEmptyAnsiString((PANSI_STRING)&OemString, NULL, (USHORT)OemLength); - OemString.Buffer = ExAllocatePoolWithTag(NonPagedPool, OemLength, TAG_OSTR); - if (OemString.Buffer == NULL) - { - Status = STATUS_NO_MEMORY; - goto Quit; - } - Status = RtlUnicodeStringToOemString(&OemString, &CapturedString, FALSE); - if (!NT_SUCCESS(Status)) - { - ExFreePoolWithTag(OemString.Buffer, TAG_OSTR); - goto Quit; - } - - /* Display the string */ - InbvDisplayString(OemString.Buffer); - - /* Free the string buffer */ - ExFreePoolWithTag(OemString.Buffer, TAG_OSTR); - - Status = STATUS_SUCCESS; + /* Acquire the lock */ + InbvAcquireLock(); -Quit: - /* Free the captured string */ - ReleaseCapturedUnicodeString(&CapturedString, PreviousMode); + /* Fill the progress bar */ + VidSolidColorFill(ProgressBarLeft, + ProgressBarTop, + ProgressBarLeft + FillCount, + ProgressBarTop + VID_PROGRESS_BAR_HEIGHT, + BV_COLOR_WHITE); - return Status; + /* Release the lock */ + InbvReleaseLock(); } #ifdef INBV_ROTBAR_IMPLEMENTED @@ -1054,7 +359,7 @@ InbvRotationThread( Y = ProgressBarTop + 2; InbvReleaseLock(); - while (InbvDisplayState == INBV_DISPLAY_STATE_OWNED) + while (InbvGetDisplayState() == INBV_DISPLAY_STATE_OWNED) { /* Wait for a bit */ KeDelayExecutionThread(KernelMode, FALSE, &Delay); @@ -1135,9 +440,36 @@ InbvRotBarInit(VOID) #endif CODE_SEG("INIT") +static VOID NTAPI -DisplayBootBitmap(IN BOOLEAN TextMode) +DisplayFilter( + _Inout_ PCHAR* String) +{ + /* Windows hack to skip first dots displayed by AUTOCHK */ + static BOOLEAN DotHack = TRUE; + + /* If "." is given set *String to empty string */ + if (DotHack && strcmp(*String, ".") == 0) + *String = ""; + + if (**String) + { + /* Remove the filter */ + InbvInstallDisplayStringFilter(NULL); + + DotHack = FALSE; + + /* Draw text screen */ + DisplayBootBitmap(TRUE); + } +} + +CODE_SEG("INIT") +VOID +NTAPI +DisplayBootBitmap( + _In_ BOOLEAN TextMode) { PVOID BootCopy = NULL, BootProgress = NULL, BootLogo = NULL, Header = NULL, Footer = NULL; @@ -1296,9 +628,7 @@ DisplayBootBitmap(IN BOOLEAN TextMode) /* Set progress bar coordinates and display it */ InbvSetProgressBarCoordinates(VID_PROGRESS_BAR_LEFT, - VID_PROGRESS_BAR_TOP, - VID_PROGRESS_BAR_WIDTH, - VID_PROGRESS_BAR_HEIGHT); + VID_PROGRESS_BAR_TOP); #ifdef REACTOS_SKUS /* Check for non-workstation products */ @@ -1418,30 +748,6 @@ DisplayBootBitmap(IN BOOLEAN TextMode) #endif } -CODE_SEG("INIT") -VOID -NTAPI -DisplayFilter(PCHAR *String) -{ - /* Windows hack to skip first dots */ - static BOOLEAN DotHack = TRUE; - - /* If "." is given set *String to empty string */ - if (DotHack && strcmp(*String, ".") == 0) - *String = ""; - - if (**String) - { - /* Remove the filter */ - InbvInstallDisplayStringFilter(NULL); - - DotHack = FALSE; - - /* Draw text screen */ - DisplayBootBitmap(TRUE); - } -} - CODE_SEG("INIT") VOID NTAPI diff --git a/ntoskrnl/inbv/inbv.c b/ntoskrnl/inbv/inbv.c index 4f6a8df1e0f..69f40d5444c 100644 --- a/ntoskrnl/inbv/inbv.c +++ b/ntoskrnl/inbv/inbv.c @@ -1,16 +1,17 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: BSD - See COPYING.ARM in the top level directory + * PURPOSE: Boot Video Driver support + * COPYRIGHT: Copyright 2007 Alex Ionescu (alex.ionescu(a)reactos.org) + * Copyright 2010 Aleksey Bragin (aleksey(a)reactos.org) + * Copyright 2015-2022 Hermès Bélusca-Maïto + */ + /* INCLUDES ******************************************************************/ #include <ntoskrnl.h> - -#define NDEBUG -#include <debug.h> - #include "inbv/logo.h" -/* See also mm/ARM3/miarm.h */ -#define MM_READONLY 1 // PAGE_READONLY -#define MM_READWRITE 4 // PAGE_WRITECOPY - /* GLOBALS *******************************************************************/ /* @@ -18,16 +19,6 @@ */ // #define INBV_HEADLESS_COLORS -/* - * ReactOS uses the same boot screen for all the products. - */ - -/* - * Enable this define when ReactOS will have different SKUs - * (Workstation, Server, Storage Server, Cluster Server, etc...). - */ -// #define REACTOS_SKUS - typedef struct _INBV_PROGRESS_STATE { ULONG Floor; @@ -42,78 +33,23 @@ typedef struct _BT_PROGRESS_INDICATOR ULONG Percentage; } BT_PROGRESS_INDICATOR, *PBT_PROGRESS_INDICATOR; -typedef enum _ROT_BAR_TYPE -{ - RB_UNSPECIFIED, - RB_SQUARE_CELLS, - RB_PROGRESS_BAR -} ROT_BAR_TYPE; - -/* - * BitBltAligned() alignments - */ -typedef enum _BBLT_VERT_ALIGNMENT -{ - AL_VERTICAL_TOP = 0, - AL_VERTICAL_CENTER, - AL_VERTICAL_BOTTOM -} BBLT_VERT_ALIGNMENT; - -typedef enum _BBLT_HORZ_ALIGNMENT -{ - AL_HORIZONTAL_LEFT = 0, - AL_HORIZONTAL_CENTER, - AL_HORIZONTAL_RIGHT -} BBLT_HORZ_ALIGNMENT; - -/* - * Enable this define when Inbv will support rotating progress bar. - */ -#define INBV_ROTBAR_IMPLEMENTED - static KSPIN_LOCK BootDriverLock; static KIRQL InbvOldIrql; static INBV_DISPLAY_STATE InbvDisplayState = INBV_DISPLAY_STATE_DISABLED; BOOLEAN InbvBootDriverInstalled = FALSE; +static INBV_RESET_DISPLAY_PARAMETERS InbvResetDisplayParameters = NULL; + static BOOLEAN InbvDisplayDebugStrings = FALSE; static INBV_DISPLAY_STRING_FILTER InbvDisplayFilter = NULL; -static ULONG ProgressBarLeft = 0, ProgressBarTop = 0; -static ULONG ProgressBarWidth = 0, ProgressBarHeight = 0; -static BOOLEAN ShowProgressBar = FALSE; + +ULONG ProgressBarLeft = 0, ProgressBarTop = 0; +BOOLEAN ShowProgressBar = FALSE; static INBV_PROGRESS_STATE InbvProgressState; static BT_PROGRESS_INDICATOR InbvProgressIndicator = {0, 25, 0}; -static INBV_RESET_DISPLAY_PARAMETERS InbvResetDisplayParameters = NULL; + static ULONG ResourceCount = 0; static PUCHAR ResourceList[1 + IDB_MAX_RESOURCE]; // First entry == NULL, followed by 'ResourceCount' entries. -#ifdef INBV_ROTBAR_IMPLEMENTED -/* - * Change this to modify progress bar behaviour - */ -#define ROT_BAR_DEFAULT_MODE RB_PROGRESS_BAR - -/* - * Values for PltRotBarStatus: - * - PltRotBarStatus == 1, do palette fading-in (done elsewhere in ReactOS); - * - PltRotBarStatus == 2, do rotation bar animation; - * - PltRotBarStatus == 3, stop the animation thread. - * - Any other value is ignored and the animation thread continues to run. - */ -typedef enum _ROT_BAR_STATUS -{ - RBS_FADEIN = 1, - RBS_ANIMATE, - RBS_STOP_ANIMATE, - RBS_STATUS_MAX -} ROT_BAR_STATUS; - -static BOOLEAN RotBarThreadActive = FALSE; -static ROT_BAR_TYPE RotBarSelection = RB_UNSPECIFIED; -static ROT_BAR_STATUS PltRotBarStatus = 0; -static UCHAR RotBarBuffer[24 * 9]; -static UCHAR RotLineBuffer[SCREEN_WIDTH * 6]; -#endif - /* * Headless terminal text colors @@ -153,199 +89,14 @@ static ULONG InbvTerminalTextColor = 37; static ULONG InbvTerminalBkgdColor = 40; -/* FADING FUNCTION ***********************************************************/ - -/** From include/psdk/wingdi.h **/ -typedef struct tagRGBQUAD -{ - UCHAR rgbBlue; - UCHAR rgbGreen; - UCHAR rgbRed; - UCHAR rgbReserved; -} RGBQUAD,*LPRGBQUAD; -/*******************************/ - -static RGBQUAD MainPalette[16]; - -#define PALETTE_FADE_STEPS 12 -#define PALETTE_FADE_TIME (15 * 1000) /* 15 ms */ - -/** From bootvid/precomp.h **/ -// -// Bitmap Header -// -typedef struct tagBITMAPINFOHEADER -{ - ULONG biSize; - LONG biWidth; - LONG biHeight; - USHORT biPlanes; - USHORT biBitCount; - ULONG biCompression; - ULONG biSizeImage; - LONG biXPelsPerMeter; - LONG biYPelsPerMeter; - ULONG biClrUsed; - ULONG biClrImportant; -} BITMAPINFOHEADER, *PBITMAPINFOHEADER; -/****************************/ - -// -// Needed prototypes -// -VOID NTAPI InbvAcquireLock(VOID); -VOID NTAPI InbvReleaseLock(VOID); - -static VOID -BootLogoFadeIn(VOID) -{ - UCHAR PaletteBitmapBuffer[sizeof(BITMAPINFOHEADER) + sizeof(MainPalette)]; - PBITMAPINFOHEADER PaletteBitmap = (PBITMAPINFOHEADER)PaletteBitmapBuffer; - LPRGBQUAD Palette = (LPRGBQUAD)(PaletteBitmapBuffer + sizeof(BITMAPINFOHEADER)); - ULONG Iteration, Index, ClrUsed; - - LARGE_INTEGER Delay; - Delay.QuadPart = -(PALETTE_FADE_TIME * 10); - - /* Check if we are installed and we own the display */ - if (!InbvBootDriverInstalled || - (InbvDisplayState != INBV_DISPLAY_STATE_OWNED)) - { - return; - } - - /* - * Build a bitmap containing the fade-in palette. The palette entries - * are then processed in a loop and set using VidBitBlt function. - */ - ClrUsed = RTL_NUMBER_OF(MainPalette); - RtlZeroMemory(PaletteBitmap, sizeof(BITMAPINFOHEADER)); - PaletteBitmap->biSize = sizeof(BITMAPINFOHEADER); - PaletteBitmap->biBitCount = 4; - PaletteBitmap->biClrUsed = ClrUsed; - - /* - * Main animation loop. - */ - for (Iteration = 0; Iteration <= PALETTE_FADE_STEPS; ++Iteration) - { - for (Index = 0; Index < ClrUsed; Index++) - { - Palette[Index].rgbRed = (UCHAR) - (MainPalette[Index].rgbRed * Iteration / PALETTE_FADE_STEPS); - Palette[Index].rgbGreen = (UCHAR) - (MainPalette[Index].rgbGreen * Iteration / PALETTE_FADE_STEPS); - Palette[Index].rgbBlue = (UCHAR) - (MainPalette[Index].rgbBlue * Iteration / PALETTE_FADE_STEPS); - } - - /* Do the animation */ - InbvAcquireLock(); - VidBitBlt(PaletteBitmapBuffer, 0, 0); - InbvReleaseLock(); - - /* Wait for a bit */ - KeDelayExecutionThread(KernelMode, FALSE, &Delay); - } -} - -static VOID -BitBltPalette( - IN PVOID Image, - IN BOOLEAN NoPalette, - IN ULONG X, - IN ULONG Y) -{ - LPRGBQUAD Palette; - RGBQUAD OrigPalette[RTL_NUMBER_OF(MainPalette)]; - - /* If requested, remove the palette from the image */ - if (NoPalette) - { - /* Get bitmap header and palette */ - PBITMAPINFOHEADER BitmapInfoHeader = Image; - Palette = (LPRGBQUAD)((PUCHAR)Image + BitmapInfoHeader->biSize); - - /* Save the image original palette and remove palette information */ - RtlCopyMemory(OrigPalette, Palette, sizeof(OrigPalette)); - RtlZeroMemory(Palette, sizeof(OrigPalette)); - } - - /* Draw the image */ - InbvBitBlt(Image, X, Y); - - /* Restore the image original palette */ - if (NoPalette) - { - RtlCopyMemory(Palette, OrigPalette, sizeof(OrigPalette)); - } -} - -static VOID -BitBltAligned( - IN PVOID Image, - IN BOOLEAN NoPalette, - IN BBLT_HORZ_ALIGNMENT HorizontalAlignment, - IN BBLT_VERT_ALIGNMENT VerticalAlignment, - IN ULONG MarginLeft, - IN ULONG MarginTop, - IN ULONG MarginRight, - IN ULONG MarginBottom) -{ - PBITMAPINFOHEADER BitmapInfoHeader = Image; - ULONG X, Y; - - /* Calculate X */ - switch (HorizontalAlignment) - { - case AL_HORIZONTAL_LEFT: - X = MarginLeft - MarginRight; - break; - - case AL_HORIZONTAL_CENTER: - X = MarginLeft - MarginRight + (SCREEN_WIDTH - BitmapInfoHeader->biWidth + 1) / 2; - break; - - case AL_HORIZONTAL_RIGHT: - X = MarginLeft - MarginRight + SCREEN_WIDTH - BitmapInfoHeader->biWidth; - break; - - default: - /* Unknown */ - return; - } - - /* Calculate Y */ - switch (VerticalAlignment) - { - case AL_VERTICAL_TOP: - Y = MarginTop - MarginBottom; - break; - - case AL_VERTICAL_CENTER: - Y = MarginTop - MarginBottom + (SCREEN_HEIGHT - BitmapInfoHeader->biHeight + 1) / 2; - break; - - case AL_VERTICAL_BOTTOM: - Y = MarginTop - MarginBottom + SCREEN_HEIGHT - BitmapInfoHeader->biHeight; - break; - - default: - /* Unknown */ - return; - } - - /* Finally draw the image */ - BitBltPalette(Image, NoPalette, X, Y); -} - /* FUNCTIONS *****************************************************************/ CODE_SEG("INIT") +static PVOID -NTAPI -FindBitmapResource(IN PLOADER_PARAMETER_BLOCK LoaderBlock, - IN ULONG ResourceId) +FindBitmapResource( + _In_ PLOADER_PARAMETER_BLOCK LoaderBlock, + _In_ ULONG ResourceId) { UNICODE_STRING UpString = RTL_CONSTANT_STRING(L"ntoskrnl.exe"); UNICODE_STRING MpString = RTL_CONSTANT_STRING(L"ntkrnlmp.exe"); @@ -406,11 +157,24 @@ FindBitmapResource(IN PLOADER_PARAMETER_BLOCK LoaderBlock, return Data; } +PUCHAR +NTAPI +InbvGetResourceAddress( + _In_ ULONG ResourceNumber) +{ + /* Validate the resource number */ + if (ResourceNumber > ResourceCount) return NULL; + + /* Return the address */ + return ResourceList[ResourceNumber]; +} + CODE_SEG("INIT") BOOLEAN NTAPI -InbvDriverInitialize(IN PLOADER_PARAMETER_BLOCK LoaderBlock, - IN ULONG Count) +InbvDriverInitialize( + _In_ PLOADER_PARAMETER_BLOCK LoaderBlock, + _In_ ULONG Count) { PCHAR CommandLine; BOOLEAN ResetMode = FALSE; // By default do not reset the video mode @@ -442,6 +206,8 @@ InbvDriverInitialize(IN PLOADER_PARAMETER_BLOCK LoaderBlock, /* Set the progress bar ranges */ InbvSetProgressBarSubset(0, 100); + + // BootAnimInitialize(LoaderBlock, Count); } /* Return install state */ @@ -488,7 +254,8 @@ InbvReleaseLock(VOID) VOID NTAPI -InbvEnableBootDriver(IN BOOLEAN Enable) +InbvEnableBootDriver( + _In_ BOOLEAN Enable) { /* Check if we're installed */ if (InbvBootDriverInstalled) @@ -535,7 +302,8 @@ InbvAcquireDisplayOwnership(VOID) VOID NTAPI -InbvSetDisplayOwnership(IN BOOLEAN DisplayOwned) +InbvSetDisplayOwnership( + _In_ BOOLEAN DisplayOwned) { /* Set the new display state */ InbvDisplayState = DisplayOwned ? INBV_DISPLAY_STATE_OWNED : @@ -560,7 +328,8 @@ InbvGetDisplayState(VOID) BOOLEAN NTAPI -InbvDisplayString(IN PCHAR String) +InbvDisplayString( + _In_ PCHAR String) { /* Make sure we own the display */ if (InbvDisplayState == INBV_DISPLAY_STATE_OWNED) @@ -597,7 +366,8 @@ InbvDisplayString(IN PCHAR String) BOOLEAN NTAPI -InbvEnableDisplayString(IN BOOLEAN Enable) +InbvEnableDisplayString( + _In_ BOOLEAN Enable) { BOOLEAN OldSetting; @@ -613,10 +383,11 @@ InbvEnableDisplayString(IN BOOLEAN Enable) VOID NTAPI -InbvInstallDisplayStringFilter(IN INBV_DISPLAY_STRING_FILTER Filter) +InbvInstallDisplayStringFilter( + _In_ INBV_DISPLAY_STRING_FILTER DisplayFilter) { /* Save the filter */ - InbvDisplayFilter = Filter; + InbvDisplayFilter = DisplayFilter; } BOOLEAN @@ -629,7 +400,8 @@ InbvIsBootDriverInstalled(VOID) VOID NTAPI -InbvNotifyDisplayOwnershipLost(IN INBV_RESET_DISPLAY_PARAMETERS Callback) +InbvNotifyDisplayOwnershipLost( + _In_ INBV_RESET_DISPLAY_PARAMETERS Callback) { /* Check if we're installed */ if (InbvBootDriverInstalled) @@ -672,10 +444,11 @@ InbvResetDisplay(VOID) VOID NTAPI -InbvSetScrollRegion(IN ULONG Left, - IN ULONG Top, - IN ULONG Right, - IN ULONG Bottom) +InbvSetScrollRegion( + _In_ ULONG Left, + _In_ ULONG Top, + _In_ ULONG Right, + _In_ ULONG Bottom) { /* Just call bootvid */ VidSetScrollRegion(Left, Top, Right, Bottom); @@ -683,7 +456,8 @@ InbvSetScrollRegion(IN ULONG Left, VOID NTAPI -InbvSetTextColor(IN ULONG Color) +InbvSetTextColor( + _In_ ULONG Color) { HEADLESS_CMD_SET_COLOR HeadlessSetColor; @@ -707,11 +481,12 @@ InbvSetTextColor(IN ULONG Color) VOID NTAPI -InbvSolidColorFill(IN ULONG Left, - IN ULONG Top, - IN ULONG Right, - IN ULONG Bottom, - IN ULONG Color) +InbvSolidColorFill( + _In_ ULONG Left, + _In_ ULONG Top, + _In_ ULONG Right, + _In_ ULONG Bottom, + _In_ ULONG Color) { HEADLESS_CMD_SET_COLOR HeadlessSetColor; @@ -750,42 +525,22 @@ InbvSolidColorFill(IN ULONG Left, } } -/** - * @brief - * Updates the progress bar percentage, relative to the current - * percentage sub-range previously set by InbvSetProgressBarSubset(). - * - * @param[in] Percentage - * The progress percentage, relative to the current sub-range. - * - * @return None. - **/ -CODE_SEG("INIT") VOID NTAPI -InbvUpdateProgressBar( - _In_ ULONG Percentage) +InbvBitBlt( + _In_ PUCHAR Buffer, + _In_ ULONG X, + _In_ ULONG Y) { - ULONG TotalProgress, FillCount; - - /* Make sure the progress bar is enabled, that we own and are installed */ - if (ShowProgressBar && - InbvBootDriverInstalled && + /* Check if we're installed and we own it */ + if (InbvBootDriverInstalled && (InbvDisplayState == INBV_DISPLAY_STATE_OWNED)) { - /* Compute fill count */ - TotalProgress = InbvProgressState.Floor + (Percentage * InbvProgressState.Bias); - FillCount = ProgressBarWidth * TotalProgress / (100 * 100); - /* Acquire the lock */ InbvAcquireLock(); - /* Fill the progress bar */ - VidSolidColorFill(ProgressBarLeft, - ProgressBarTop, - ProgressBarLeft + FillCount, - ProgressBarTop + ProgressBarHeight, - BV_COLOR_WHITE); + /* Do the blit */ + VidBitBlt(Buffer, X, Y); /* Release the lock */ InbvReleaseLock(); @@ -794,12 +549,13 @@ InbvUpdateProgressBar( VOID NTAPI -InbvBufferToScreenBlt(IN PUCHAR Buffer, - IN ULONG X, - IN ULONG Y, - IN ULONG Width, - IN ULONG Height, - IN ULONG Delta) +InbvBufferToScreenBlt( + _In_ PUCHAR Buffer, + _In_ ULONG X, + _In_ ULONG Y, + _In_ ULONG Width, + _In_ ULONG Height, + _In_ ULONG Delta) { /* Check if we're installed and we own it */ if (InbvBootDriverInstalled && @@ -812,33 +568,13 @@ InbvBufferToScreenBlt(IN PUCHAR Buffer, VOID NTAPI -InbvBitBlt(IN PUCHAR Buffer, - IN ULONG X, - IN ULONG Y) -{ - /* Check if we're installed and we own it */ - if (InbvBootDriverInstalled && - (InbvDisplayState == INBV_DISPLAY_STATE_OWNED)) - { - /* Acquire the lock */ - InbvAcquireLock(); - - /* Do the blit */ - VidBitBlt(Buffer, X, Y); - - /* Release the lock */ - InbvReleaseLock(); - } -} - -VOID -NTAPI -InbvScreenToBufferBlt(OUT PUCHAR Buffer, - IN ULONG X, - IN ULONG Y, - IN ULONG Width, - IN ULONG Height, - IN ULONG Delta) +InbvScreenToBufferBlt( + _Out_ PUCHAR Buffer, + _In_ ULONG X, + _In_ ULONG Y, + _In_ ULONG Width, + _In_ ULONG Height, + _In_ ULONG Delta) { /* Check if we're installed and we own it */ if (InbvBootDriverInstalled && @@ -857,32 +593,55 @@ InbvScreenToBufferBlt(OUT PUCHAR Buffer, * @param[in] Top * The left/top coordinates. * - * (ReactOS-specific) - * @param[in] Width - * @param[in] Height - * The width/height of the progress bar. - * * @return None. **/ -CODE_SEG("INIT") VOID NTAPI InbvSetProgressBarCoordinates( _In_ ULONG Left, - _In_ ULONG Top, - _In_ ULONG Width, - _In_ ULONG Height) + _In_ ULONG Top) { /* Update the coordinates */ - ProgressBarLeft = Left; - ProgressBarTop = Top; - ProgressBarWidth = Width; - ProgressBarHeight = Height; + ProgressBarLeft = Left; + ProgressBarTop = Top; /* Enable the progress bar */ ShowProgressBar = TRUE; } +/** + * @brief + * Gives some progress feedback, without specifying any explicit number + * of progress steps or percentage. + * The corresponding percentage is derived from the progress indicator's + * current count, capped to the number of expected calls to be made to + * this function (default: 25, see @b InbvProgressIndicator.Expected). + * + * @return None. + **/ +CODE_SEG("INIT") +VOID +NTAPI +InbvIndicateProgress(VOID) +{ + ULONG Percentage; + + /* Increase progress */ + InbvProgressIndicator.Count++; + + /* Compute the new percentage - Don't go over 100% */ + Percentage = 100 * InbvProgressIndicator.Count / + InbvProgressIndicator.Expected; + Percentage = min(Percentage, 99); + + if (Percentage != InbvProgressIndicator.Percentage) + { + /* Percentage has changed, update the progress bar */ + InbvProgressIndicator.Percentage = Percentage; + InbvUpdateProgressBar(Percentage); + } +} + /** * @brief * Specifies a progress percentage sub-range. @@ -899,7 +658,6 @@ InbvSetProgressBarCoordinates( * * @return None. **/ -CODE_SEG("INIT") VOID NTAPI InbvSetProgressBarSubset( @@ -918,46 +676,32 @@ InbvSetProgressBarSubset( /** * @brief - * Gives some progress feedback, without specifying any explicit number - * of progress steps or percentage. - * The corresponding percentage is derived from the progress indicator's - * current count, capped to the number of expected calls to be made to - * this function (default: 25, see @b InbvProgressIndicator.Expected). + * Updates the progress bar percentage, relative to the current + * percentage sub-range previously set by InbvSetProgressBarSubset(). + * + * @param[in] Percentage + * The progress percentage, relative to the current sub-range. * * @return None. **/ -CODE_SEG("INIT") VOID NTAPI -InbvIndicateProgress(VOID) +InbvUpdateProgressBar( + _In_ ULONG Percentage) { - ULONG Percentage; + ULONG TotalProgress; - /* Increase progress */ - InbvProgressIndicator.Count++; - - /* Compute the new percentage - Don't go over 100% */ - Percentage = 100 * InbvProgressIndicator.Count / - InbvProgressIndicator.Expected; - Percentage = min(Percentage, 99); - - if (Percentage != InbvProgressIndicator.Percentage) + /* Make sure the progress bar is enabled, that we own and are installed */ + if (ShowProgressBar && + InbvBootDriverInstalled && + (InbvDisplayState == INBV_DISPLAY_STATE_OWNED)) { - /* Percentage has changed, update the progress bar */ - InbvProgressIndicator.Percentage = Percentage; - InbvUpdateProgressBar(Percentage); - } -} - -PUCHAR -NTAPI -InbvGetResourceAddress(IN ULONG ResourceNumber) -{ - /* Validate the resource number */ - if (ResourceNumber > ResourceCount) return NULL; + /* Compute the total progress and tick the progress bar */ + TotalProgress = InbvProgressState.Floor + (Percentage * InbvProgressState.Bias); + // TotalProgress /= (100 * 100); - /* Return the address */ - return ResourceList[ResourceNumber]; + BootAnimTickProgressBar(TotalProgress); + } } NTSTATUS @@ -1030,435 +774,3 @@ Quit: return Status; } - -#ifdef INBV_ROTBAR_IMPLEMENTED -static -VOID -NTAPI -InbvRotationThread( - _In_ PVOID Context) -{ - ULONG X, Y, Index, Total; - LARGE_INTEGER Delay = {{0}}; - - InbvAcquireLock(); - if (RotBarSelection == RB_SQUARE_CELLS) - { - Index = 0; - } - else - { - Index = 32; - } - X = ProgressBarLeft + 2; - Y = ProgressBarTop + 2; - InbvReleaseLock(); - - while (InbvDisplayState == INBV_DISPLAY_STATE_OWNED) - { - /* Wait for a bit */ - KeDelayExecutionThread(KernelMode, FALSE, &Delay); - - InbvAcquireLock(); - - /* Unknown unexpected command */ - ASSERT(PltRotBarStatus < RBS_STATUS_MAX); - - if (PltRotBarStatus == RBS_STOP_ANIMATE) - { - /* Stop the thread */ - InbvReleaseLock(); - break; - } - - if (RotBarSelection == RB_SQUARE_CELLS) - { - Delay.QuadPart = -800000; // 80 ms - Total = 18; - Index %= Total; - - if (Index >= 3) - { - /* Fill previous bar position */ - VidSolidColorFill(X + ((Index - 3) * 8), Y, (X + ((Index - 3) * 8)) + 8 - 1, Y + 9 - 1, BV_COLOR_BLACK); - } - if (Index < Total - 1) - { - /* Draw the progress bar bit */ - if (Index < 2) - { - /* Appearing from the left */ - VidBufferToScreenBlt(RotBarBuffer + 8 * (2 - Index) / 2, X, Y, 22 - 8 * (2 - Index), 9, 24); - } - else if (Index >= Total - 3) - { - /* Hiding to the right */ - VidBufferToScreenBlt(RotBarBuffer, X + ((Index - 2) * 8), Y, 22 - 8 * (4 - (Total - Index)), 9, 24); - } - else - { - VidBufferToScreenBlt(RotBarBuffer, X + ((Index - 2) * 8), Y, 22, 9, 24); - } - } - Index++; - } - else if (RotBarSelection == RB_PROGRESS_BAR) - { - Delay.QuadPart = -600000; // 60 ms - Total = SCREEN_WIDTH; - Index %= Total; - - /* Right part */ - VidBufferToScreenBlt(RotLineBuffer, Index, SCREEN_HEIGHT-6, SCREEN_WIDTH - Index, 6, SCREEN_WIDTH); - if (Index > 0) - { - /* Left part */ - VidBufferToScreenBlt(RotLineBuffer + (SCREEN_WIDTH - Index) / 2, 0, SCREEN_HEIGHT-6, Index - 2, 6, SCREEN_WIDTH); - } - Index += 32; - } - - InbvReleaseLock(); - } - - PsTerminateSystemThread(STATUS_SUCCESS); -} - -CODE_SEG("INIT") -VOID -NTAPI -InbvRotBarInit(VOID) -{ - PltRotBarStatus = RBS_FADEIN; - /* Perform other initialization if needed */ -} -#endif - -CODE_SEG("INIT") -VOID -NTAPI -DisplayBootBitmap(IN BOOLEAN TextMode) -{ - PVOID BootCopy = NULL, BootProgress = NULL, BootLogo = NULL, Header = NULL, Footer = NULL; - -#ifdef INBV_ROTBAR_IMPLEMENTED - UCHAR Buffer[24 * 9]; - PVOID Bar = NULL, LineBmp = NULL; - ROT_BAR_TYPE TempRotBarSelection = RB_UNSPECIFIED; - NTSTATUS Status; - HANDLE ThreadHandle = NULL; -#endif - -#ifdef REACTOS_SKUS - PVOID Text = NULL; -#endif - -#ifdef INBV_ROTBAR_IMPLEMENTED - /* Check if the animation thread has already been created */ - if (RotBarThreadActive) - { - /* Yes, just reset the progress bar but keep the thread alive */ - InbvAcquireLock(); - RotBarSelection = RB_UNSPECIFIED; - InbvReleaseLock(); - } -#endif - - ShowProgressBar = FALSE; - - /* Check if this is text mode */ - if (TextMode) - { - /* - * Make the kernel resource section temporarily writable, - * as we are going to change the bitmaps' palette in place. - */ - MmChangeKernelResourceSectionProtection(MM_READWRITE); - - /* Check the type of the OS: workstation or server */ - if (SharedUserData->NtProductType == NtProductWinNt) - { - /* Workstation; set colors */ - InbvSetTextColor(BV_COLOR_WHITE); - InbvSolidColorFill(0, 0, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, BV_COLOR_DARK_GRAY); - InbvSolidColorFill(0, VID_FOOTER_BG_TOP, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, BV_COLOR_RED); - - /* Get resources */ - Header = InbvGetResourceAddress(IDB_WKSTA_HEADER); - Footer = InbvGetResourceAddress(IDB_WKSTA_FOOTER); - } - else - { - /* Server; set colors */ - InbvSetTextColor(BV_COLOR_LIGHT_CYAN); - InbvSolidColorFill(0, 0, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, BV_COLOR_CYAN); - InbvSolidColorFill(0, VID_FOOTER_BG_TOP, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, BV_COLOR_RED); - - /* Get resources */ - Header = InbvGetResourceAddress(IDB_SERVER_HEADER); - Footer = InbvGetResourceAddress(IDB_SERVER_FOOTER); - } - - /* Set the scrolling region */ - InbvSetScrollRegion(VID_SCROLL_AREA_LEFT, VID_SCROLL_AREA_TOP, - VID_SCROLL_AREA_RIGHT, VID_SCROLL_AREA_BOTTOM); - - /* Make sure we have resources */ - if (Header && Footer) - { - /* BitBlt them on the screen */ - BitBltAligned(Footer, - TRUE, - AL_HORIZONTAL_CENTER, - AL_VERTICAL_BOTTOM, - 0, 0, 0, 59); - BitBltAligned(Header, - FALSE, - AL_HORIZONTAL_CENTER, - AL_VERTICAL_TOP, - 0, 0, 0, 0); - } - - /* Restore the kernel resource section protection to be read-only */ - MmChangeKernelResourceSectionProtection(MM_READONLY); - } - else - { - /* Is the boot driver installed? */ - if (!InbvBootDriverInstalled) return; - - /* - * Make the kernel resource section temporarily writable, - * as we are going to change the bitmaps' palette in place. - */ - MmChangeKernelResourceSectionProtection(MM_READWRITE); - - /* Load boot screen logo */ - BootLogo = InbvGetResourceAddress(IDB_LOGO_DEFAULT); - -#ifdef REACTOS_SKUS - Text = NULL; - if (SharedUserData->NtProductType == NtProductWinNt) - { -#ifdef INBV_ROTBAR_IMPLEMENTED - /* Workstation product, use appropriate status bar color */ - Bar = InbvGetResourceAddress(IDB_BAR_WKSTA); -#endif - } - else - { - /* Display correct branding based on server suite */ - if (ExVerifySuite(StorageServer)) - { - /* Storage Server Edition */ - Text = InbvGetResourceAddress(IDB_STORAGE_SERVER); - } - else if (ExVerifySuite(ComputeServer)) - { - /* Compute Cluster Edition */ - Text = InbvGetResourceAddress(IDB_CLUSTER_SERVER); - } - else - { - /* Normal edition */ - Text = InbvGetResourceAddress(IDB_SERVER_LOGO); - } - -#ifdef INBV_ROTBAR_IMPLEMENTED - /* Server product, use appropriate status bar color */ - Bar = InbvGetResourceAddress(IDB_BAR_DEFAULT); -#endif - } -#else - /* Use default status bar */ - Bar = InbvGetResourceAddress(IDB_BAR_WKSTA); -#endif - - /* Make sure we have a logo */ - if (BootLogo) - { - /* Save the main image palette for implementing the fade-in effect */ - PBITMAPINFOHEADER BitmapInfoHeader = BootLogo; - LPRGBQUAD Palette = (LPRGBQUAD)((PUCHAR)BootLogo + BitmapInfoHeader->biSize); - RtlCopyMemory(MainPalette, Palette, sizeof(MainPalette)); - - /* Draw the logo at the center of the screen */ - BitBltAligned(BootLogo, - TRUE, - AL_HORIZONTAL_CENTER, - AL_VERTICAL_CENTER, - 0, 0, 0, 34); - -#ifdef INBV_ROTBAR_IMPLEMENTED - /* Choose progress bar */ - TempRotBarSelection = ROT_BAR_DEFAULT_MODE; -#endif - - /* Set progress bar coordinates and display it */ - InbvSetProgressBarCoordinates(VID_PROGRESS_BAR_LEFT, - VID_PROGRESS_BAR_TOP, - VID_PROGRESS_BAR_WIDTH, - VID_PROGRESS_BAR_HEIGHT); - -#ifdef REACTOS_SKUS - /* Check for non-workstation products */ - if (SharedUserData->NtProductType != NtProductWinNt) - { - /* Overwrite part of the logo for a server product */ - InbvScreenToBufferBlt(Buffer, VID_SKU_SAVE_AREA_LEFT, - VID_SKU_SAVE_AREA_TOP, 7, 7, 8); - InbvSolidColorFill(VID_SKU_AREA_LEFT, VID_SKU_AREA_TOP, - VID_SKU_AREA_RIGHT, VID_SKU_AREA_BOTTOM, BV_COLOR_BLACK); - InbvBufferToScreenBlt(Buffer, VID_SKU_SAVE_AREA_LEFT, - VID_SKU_SAVE_AREA_TOP, 7, 7, 8); - - /* In setup mode, you haven't selected a SKU yet */ - if (ExpInTextModeSetup) Text = NULL; - } -#endif - } - - /* Load and draw progress bar bitmap */ - BootProgress = InbvGetResourceAddress(IDB_PROGRESS_BAR); - BitBltAligned(BootProgress, - TRUE, - AL_HORIZONTAL_CENTER, - AL_VERTICAL_CENTER, - 0, 118, 0, 0); - - /* Load and draw copyright text bitmap */ - BootCopy = InbvGetResourceAddress(IDB_COPYRIGHT); - BitBltAligned(BootCopy, - TRUE, - AL_HORIZONTAL_LEFT, - AL_VERTICAL_BOTTOM, - 22, 0, 0, 20); - -#ifdef REACTOS_SKUS - /* Draw the SKU text if it exits */ - if (Text) - BitBltPalette(Text, TRUE, VID_SKU_TEXT_LEFT, VID_SKU_TEXT_TOP); -#endif - -#ifdef INBV_ROTBAR_IMPLEMENTED - if ((TempRotBarSelection == RB_SQUARE_CELLS) && Bar) - { - /* Save previous screen pixels to buffer */ - InbvScreenToBufferBlt(Buffer, 0, 0, 22, 9, 24); - /* Draw the progress bar bit */ - BitBltPalette(Bar, TRUE, 0, 0); - /* Store it in global buffer */ - InbvScreenToBufferBlt(RotBarBuffer, 0, 0, 22, 9, 24); - /* Restore screen pixels */ - InbvBufferToScreenBlt(Buffer, 0, 0, 22, 9, 24); - } - - /* - * Add a rotating bottom horizontal bar when using a progress bar, - * to show that ReactOS can be still alive when the bar does not - * appear to progress. - */ - if (TempRotBarSelection == RB_PROGRESS_BAR) - { - LineBmp = InbvGetResourceAddress(IDB_ROTATING_LINE); - if (LineBmp) - { - /* Draw the line and store it in global buffer */ - BitBltPalette(LineBmp, TRUE, 0, SCREEN_HEIGHT-6); - InbvScreenToBufferBlt(RotLineBuffer, 0, SCREEN_HEIGHT-6, SCREEN_WIDTH, 6, SCREEN_WIDTH); - } - } - else - { - /* Hide the simple progress bar if not used */ - ShowProgressBar = FALSE; - } -#endif - - /* Restore the kernel resource section protection to be read-only */ - MmChangeKernelResourceSectionProtection(MM_READONLY); - - /* Display the boot logo and fade it in */ - BootLogoFadeIn(); - -#ifdef INBV_ROTBAR_IMPLEMENTED - if (!RotBarThreadActive && TempRotBarSelection != RB_UNSPECIFIED) - { - /* Start the animation thread */ - Status = PsCreateSystemThread(&ThreadHandle, - 0, - NULL, - NULL, - NULL, - InbvRotationThread, - NULL); - if (NT_SUCCESS(Status)) - { - /* The thread has started, close the handle as we don't need it */ - RotBarThreadActive = TRUE; - ObCloseHandle(ThreadHandle, KernelMode); - } - } -#endif - - /* Set filter which will draw text display if needed */ - InbvInstallDisplayStringFilter(DisplayFilter); - } - -#ifdef INBV_ROTBAR_IMPLEMENTED - /* Do we have the animation thread? */ - if (RotBarThreadActive) - { - /* We do, initialize the progress bar */ - InbvAcquireLock(); - RotBarSelection = TempRotBarSelection; - InbvRotBarInit(); - InbvReleaseLock(); - } -#endif -} - -CODE_SEG("INIT") -VOID -NTAPI -DisplayFilter(PCHAR *String) -{ - /* Windows hack to skip first dots */ - static BOOLEAN DotHack = TRUE; - - /* If "." is given set *String to empty string */ - if (DotHack && strcmp(*String, ".") == 0) - *String = ""; - - if (**String) - { - /* Remove the filter */ - InbvInstallDisplayStringFilter(NULL); - - DotHack = FALSE; - - /* Draw text screen */ - DisplayBootBitmap(TRUE); - } -} - -CODE_SEG("INIT") -VOID -NTAPI -FinalizeBootLogo(VOID) -{ - /* Acquire lock and check the display state */ - InbvAcquireLock(); - if (InbvGetDisplayState() == INBV_DISPLAY_STATE_OWNED) - { - /* Clear the screen */ - VidSolidColorFill(0, 0, SCREEN_WIDTH-1, SCREEN_HEIGHT-1, BV_COLOR_BLACK); - } - - /* Reset progress bar and lock */ -#ifdef INBV_ROTBAR_IMPLEMENTED - PltRotBarStatus = RBS_STOP_ANIMATE; - RotBarThreadActive = FALSE; -#endif - InbvReleaseLock(); -} diff --git a/ntoskrnl/inbv/logo.h b/ntoskrnl/inbv/logo.h index caecbf3dd4f..2f270d05ab4 100644 --- a/ntoskrnl/inbv/logo.h +++ b/ntoskrnl/inbv/logo.h @@ -1,3 +1,10 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Boot Theme & Animation header + * COPYRIGHT: Copyright 2020 Dmitry Borisov (di.sean(a)protonmail.com) + */ + #pragma once // @@ -32,3 +39,36 @@ #define VID_SKU_TEXT_TOP 121 #define VID_FOOTER_BG_TOP (SCREEN_HEIGHT - 59) + + +// +// Boot Splash-Screen Functions +// + +CODE_SEG("INIT") +BOOLEAN +NTAPI +BootAnimInitialize( + _In_ PLOADER_PARAMETER_BLOCK LoaderBlock, + _In_ ULONG Count); + +VOID +NTAPI +BootAnimTickProgressBar( + _In_ ULONG SubPercentTimes100); + +CODE_SEG("INIT") +VOID +NTAPI +InbvRotBarInit(VOID); + +CODE_SEG("INIT") +VOID +NTAPI +DisplayBootBitmap( + _In_ BOOLEAN TextMode); + +CODE_SEG("INIT") +VOID +NTAPI +FinalizeBootLogo(VOID); diff --git a/ntoskrnl/include/internal/inbv.h b/ntoskrnl/include/internal/inbv.h index 0fb7042c71c..31a5e85e561 100644 --- a/ntoskrnl/include/internal/inbv.h +++ b/ntoskrnl/include/internal/inbv.h @@ -1,6 +1,14 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: BSD - See COPYING.ARM in the top level directory + * PURPOSE: Boot Video Driver support header + * COPYRIGHT: Copyright 2007 Alex Ionescu (alex.ionescu(a)reactos.org) + * Copyright 2019-2022 Hermès Bélusca-Maïto + */ + #pragma once -// Native definitions from BOOTVID (Boot Video Driver). +/* Native definitions from BOOTVID (Boot Video Driver) */ #include "bootvid/bootvid.h" // @@ -10,78 +18,89 @@ CODE_SEG("INIT") BOOLEAN NTAPI InbvDriverInitialize( - IN PLOADER_PARAMETER_BLOCK LoaderBlock, - IN ULONG Count + _In_ PLOADER_PARAMETER_BLOCK LoaderBlock, + _In_ ULONG Count ); extern BOOLEAN InbvBootDriverInstalled; -PUCHAR +INBV_DISPLAY_STATE NTAPI -InbvGetResourceAddress( - IN ULONG ResourceNumber -); +InbvGetDisplayState(VOID); VOID NTAPI -InbvBitBlt( - IN PUCHAR Buffer, - IN ULONG X, - IN ULONG Y +InbvAcquireLock(VOID); + +VOID +NTAPI +InbvReleaseLock(VOID); + +PUCHAR +NTAPI +InbvGetResourceAddress( + _In_ ULONG ResourceNumber ); // -// Progress-Bar Functions +// Display Functions // -CODE_SEG("INIT") VOID NTAPI -InbvIndicateProgress(VOID); +InbvBitBlt( + _In_ PUCHAR Buffer, + _In_ ULONG X, + _In_ ULONG Y +); -CODE_SEG("INIT") VOID NTAPI -InbvSetProgressBarSubset( - _In_ ULONG Floor, - _In_ ULONG Ceiling +InbvBufferToScreenBlt( + _In_ PUCHAR Buffer, + _In_ ULONG X, + _In_ ULONG Y, + _In_ ULONG Width, + _In_ ULONG Height, + _In_ ULONG Delta ); -CODE_SEG("INIT") VOID NTAPI -InbvUpdateProgressBar( - _In_ ULONG Percentage +InbvScreenToBufferBlt( + _Out_ PUCHAR Buffer, + _In_ ULONG X, + _In_ ULONG Y, + _In_ ULONG Width, + _In_ ULONG Height, + _In_ ULONG Delta ); // -// Boot Splash-Screen Functions +// Progress-Bar Functions // -CODE_SEG("INIT") VOID NTAPI -InbvRotBarInit( - VOID +InbvSetProgressBarCoordinates( + _In_ ULONG Left, + _In_ ULONG Top ); CODE_SEG("INIT") VOID NTAPI -DisplayBootBitmap( - IN BOOLEAN TextMode -); +InbvIndicateProgress(VOID); -CODE_SEG("INIT") VOID NTAPI -DisplayFilter( - IN PCHAR *String +InbvSetProgressBarSubset( + _In_ ULONG Floor, + _In_ ULONG Ceiling ); -CODE_SEG("INIT") VOID NTAPI -FinalizeBootLogo( - VOID +InbvUpdateProgressBar( + _In_ ULONG Percentage ); // diff --git a/ntoskrnl/ntos.cmake b/ntoskrnl/ntos.cmake index 89802e07c41..31d65884253 100644 --- a/ntoskrnl/ntos.cmake +++ b/ntoskrnl/ntos.cmake @@ -124,6 +124,7 @@ list(APPEND SOURCE ${REACTOS_SOURCE_DIR}/ntoskrnl/fstub/fstubex.c ${REACTOS_SOURCE_DIR}/ntoskrnl/fstub/halstub.c ${REACTOS_SOURCE_DIR}/ntoskrnl/fstub/translate.c + ${REACTOS_SOURCE_DIR}/ntoskrnl/inbv/bootanim.c ${REACTOS_SOURCE_DIR}/ntoskrnl/inbv/inbv.c ${REACTOS_SOURCE_DIR}/ntoskrnl/inbv/inbvport.c ${REACTOS_SOURCE_DIR}/ntoskrnl/io/iomgr/adapter.c diff --git a/sdk/include/ndk/inbvtypes.h b/sdk/include/ndk/inbvtypes.h index 06479287663..20b0cf7f476 100644 --- a/sdk/include/ndk/inbvtypes.h +++ b/sdk/include/ndk/inbvtypes.h @@ -41,14 +41,14 @@ typedef enum _INBV_DISPLAY_STATE typedef BOOLEAN (NTAPI *INBV_RESET_DISPLAY_PARAMETERS)( - ULONG Cols, - ULONG Rows + _In_ ULONG Cols, + _In_ ULONG Rows ); typedef VOID (NTAPI *INBV_DISPLAY_STRING_FILTER)( - PCHAR *Str + _Inout_ PCHAR* String ); #endif
2 years, 10 months
1
0
0
0
[reactos] 04/05: [NTOS:INBV] Duplicate inbv.c to bootanim.c -- the Git way >_>
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=17bd71b57056d56dcbf45…
commit 17bd71b57056d56dcbf45aa7f9c33516caadf0e3 Merge: e17f7d6994e 8fd64d636d5 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Feb 13 21:19:13 2022 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Feb 13 21:19:13 2022 +0100 [NTOS:INBV] Duplicate inbv.c to bootanim.c -- the Git way >_> ntoskrnl/inbv/bootanim.c | 1464 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1464 insertions(+)
2 years, 10 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
...
11
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
Results per page:
10
25
50
100
200