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
December 2018
----- 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
26 participants
322 discussions
Start a n
N
ew thread
[reactos] 01/01: [WIN32SS][USER32] Add Ghost codes (retrial of #1100) (#1112)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f469acacecfd3d215ebe5…
commit f469acacecfd3d215ebe5dde79517c45b92aa730 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Dec 11 12:30:59 2018 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Dec 11 12:30:59 2018 +0900 [WIN32SS][USER32] Add Ghost codes (retrial of #1100) (#1112) CORE-11944 --- win32ss/include/ghostwnd.h | 20 +++++ win32ss/user/ntuser/class.h | 8 ++ win32ss/user/ntuser/ghost.c | 167 +++++++++++++++++++++++++++++++++-- win32ss/user/ntuser/ghost.h | 2 +- win32ss/user/ntuser/message.c | 8 +- win32ss/user/user32/controls/ghost.c | 15 +--- 6 files changed, 199 insertions(+), 21 deletions(-) diff --git a/win32ss/include/ghostwnd.h b/win32ss/include/ghostwnd.h new file mode 100644 index 0000000000..6907580c79 --- /dev/null +++ b/win32ss/include/ghostwnd.h @@ -0,0 +1,20 @@ +/* + * PROJECT: ReactOS header + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Ghost window + * COPYRIGHT: Copyright 2018 Katayama Hirofumi MZ (katayama.hirofumi.mz(a)gmail.com) + */ +#ifndef REACTOS_GHOST_WND_INCLUDED +#define REACTOS_GHOST_WND_INCLUDED + +#define GHOSTCLASSNAME L"Ghost" +#define GHOST_PROP L"GhostProp" + +typedef struct GHOST_DATA +{ + HWND hwndTarget; + HBITMAP hbm32bpp; + BOOL bDestroyTarget; +} GHOST_DATA; + +#endif diff --git a/win32ss/user/ntuser/class.h b/win32ss/user/ntuser/class.h index c5b3e8308c..0c41dc3208 100644 --- a/win32ss/user/ntuser/class.h +++ b/win32ss/user/ntuser/class.h @@ -66,4 +66,12 @@ ProbeAndCaptureUnicodeStringOrAtom( _Out_ _When_(return>=0, _At_(pustrOut->Buffer, _Post_ _Notnull_)) PUNICODE_STRING pustrOut, __in_data_source(USER_MODE) _In_ PUNICODE_STRING pustrUnsafe); +BOOL FASTCALL LookupFnIdToiCls(int FnId, int *iCls); + +INT +UserGetClassName(IN PCLS Class, + IN OUT PUNICODE_STRING ClassName, + IN RTL_ATOM Atom, + IN BOOL Ansi); + /* EOF */ diff --git a/win32ss/user/ntuser/ghost.c b/win32ss/user/ntuser/ghost.c index 726fe8ff3d..efbc5d2a64 100644 --- a/win32ss/user/ntuser/ghost.c +++ b/win32ss/user/ntuser/ghost.c @@ -1,23 +1,178 @@ /* * PROJECT: ReactOS user32.dll * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) - * PURPOSE: Ghost window handling + * PURPOSE: Window ghosting feature * COPYRIGHT: Copyright 2018 Katayama Hirofumi MZ (katayama.hirofumi.mz(a)gmail.com) */ #include <win32k.h> +#include "ghostwnd.h" -BOOL FASTCALL IntGoGhost(PWND Window, BOOL bGo) +#define NDEBUG +#include <debug.h> + +static UNICODE_STRING GhostClass = RTL_CONSTANT_STRING(GHOSTCLASSNAME); +static UNICODE_STRING GhostProp = RTL_CONSTANT_STRING(GHOST_PROP); + +BOOL FASTCALL IntIsGhostWindow(PWND Window) +{ + BOOLEAN Ret = FALSE; + UNICODE_STRING ClassName; + INT iCls, Len; + RTL_ATOM Atom = 0; + + if (!Window) + return FALSE; + + if (Window->fnid && !(Window->fnid & FNID_DESTROY)) + { + if (LookupFnIdToiCls(Window->fnid, &iCls)) + { + Atom = gpsi->atomSysClass[iCls]; + } + } + + // check class name + RtlInitUnicodeString(&ClassName, NULL); + Len = UserGetClassName(Window->pcls, &ClassName, Atom, FALSE); + if (Len > 0) + { + Ret = RtlEqualUnicodeString(&ClassName, &GhostClass, TRUE); + } + else + { + DPRINT1("Unable to get class name\n"); + } + RtlFreeUnicodeString(&ClassName); + + return Ret; +} + +HWND FASTCALL IntGhostWindowFromHungWindow(PWND pHungWnd) +{ + RTL_ATOM Atom; + HWND hwndGhost; + + if (!IntGetAtomFromStringOrAtom(&GhostProp, &Atom)) + ASSERT(FALSE); + + hwndGhost = UserGetProp(pHungWnd, Atom, TRUE); + if (hwndGhost) + { + if (ValidateHwndNoErr(hwndGhost)) + return hwndGhost; + + DPRINT("Not a window\n"); + } + + return NULL; +} + +HWND FASTCALL UserGhostWindowFromHungWindow(HWND hwndHung) { + PWND pHungWnd = ValidateHwndNoErr(hwndHung); + if (!pHungWnd) + { + DPRINT("Not a window\n"); + return NULL; + } + return IntGhostWindowFromHungWindow(pHungWnd); +} + +HWND FASTCALL IntHungWindowFromGhostWindow(PWND pGhostWnd) +{ + const GHOST_DATA *UserData; + HWND hwndTarget; + + if (!IntIsGhostWindow(pGhostWnd)) + { + DPRINT("Not a ghost window\n"); + return NULL; + } + + UserData = (const GHOST_DATA *)pGhostWnd->dwUserData; + if (UserData) + { + _SEH2_TRY + { + ProbeForRead(UserData, sizeof(GHOST_DATA), 1); + hwndTarget = UserData->hwndTarget; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + DPRINT1("Exception!\n"); + hwndTarget = NULL; + } + _SEH2_END; + } + else + { + DPRINT("No user data\n"); + hwndTarget = NULL; + } + + if (hwndTarget) + { + if (ValidateHwndNoErr(hwndTarget)) + return hwndTarget; + + DPRINT1("Not a window\n"); + } + + return NULL; +} + +HWND FASTCALL UserHungWindowFromGhostWindow(HWND hwndGhost) +{ + PWND pGhostWnd = ValidateHwndNoErr(hwndGhost); + return IntHungWindowFromGhostWindow(pGhostWnd); +} + +BOOL FASTCALL IntMakeHungWindowGhosted(HWND hwndHung) +{ + PWND pHungWnd = ValidateHwndNoErr(hwndHung); + if (!pHungWnd) + { + DPRINT1("Not a window\n"); + return FALSE; // not a window + } + + if (!MsqIsHung(pHungWnd->head.pti)) + { + DPRINT1("Not hung window\n"); + return FALSE; // not hung window + } + + if (!(pHungWnd->style & WS_VISIBLE)) + return FALSE; // invisible + + if (pHungWnd->style & WS_CHILD) + return FALSE; // child + + if (IntIsGhostWindow(pHungWnd)) + { + DPRINT1("IntIsGhostWindow\n"); + return FALSE; // ghost window cannot be ghosted + } + + if (IntGhostWindowFromHungWindow(pHungWnd)) + { + DPRINT("Already ghosting\n"); + return FALSE; // already ghosting + } + // TODO: // 1. Create a thread. // 2. Create a ghost window in the thread. // 3. Do message loop in the thread - static int bWarnedOnce = 0; - if (!bWarnedOnce) { - bWarnedOnce++; - STUB; + static int bWarnedOnce = 0; + if (!bWarnedOnce) + { + bWarnedOnce++; + STUB; + } } + return FALSE; } diff --git a/win32ss/user/ntuser/ghost.h b/win32ss/user/ntuser/ghost.h index c348bf1417..cd7b45ce5c 100644 --- a/win32ss/user/ntuser/ghost.h +++ b/win32ss/user/ntuser/ghost.h @@ -1 +1 @@ -BOOL FASTCALL IntGoGhost(PWND Window, BOOL bGo); +BOOL FASTCALL IntMakeHungWindowGhosted(HWND hwndHung); diff --git a/win32ss/user/ntuser/message.c b/win32ss/user/ntuser/message.c index 0de5f3f260..7564109c47 100644 --- a/win32ss/user/ntuser/message.c +++ b/win32ss/user/ntuser/message.c @@ -1441,9 +1441,6 @@ co_IntSendMessageTimeoutSingle( HWND hWnd, /* FIXME: Set a LastError? */ RETURN( FALSE); } - - TRACE("Let's go Ghost!\n"); - IntGoGhost(Window, TRUE); } if (Window->state & WNDS_DESTROYED) @@ -1471,6 +1468,11 @@ co_IntSendMessageTimeoutSingle( HWND hWnd, if (Status == STATUS_TIMEOUT) { + if (MsqIsHung(ptiSendTo)) + { + TRACE("Let's go Ghost!\n"); + IntMakeHungWindowGhosted(hWnd); + } /* * MSDN says: * Microsoft Windows 2000: If GetLastError returns zero, then the function diff --git a/win32ss/user/user32/controls/ghost.c b/win32ss/user/user32/controls/ghost.c index ccc9a6c528..0abc064873 100644 --- a/win32ss/user/user32/controls/ghost.c +++ b/win32ss/user/user32/controls/ghost.c @@ -7,12 +7,12 @@ #include <user32.h> #include <strsafe.h> +#include "ghostwnd.h" WINE_DEFAULT_DEBUG_CHANNEL(ghost); #define GHOST_TIMER_ID 0xFACEDEAD #define GHOST_INTERVAL 1000 // one second -#define GHOST_PROP L"GhostProp" const struct builtin_class_descr GHOST_builtin_class = { @@ -105,13 +105,6 @@ IntMakeGhostImage(HBITMAP hbm) /****************************************************************************/ -typedef struct GHOST_DATA -{ - HWND hwndTarget; - HBITMAP hbm32bpp; - BOOL bDestroyTarget; -} GHOST_DATA; - static GHOST_DATA * Ghost_GetData(HWND hwnd) { @@ -188,9 +181,9 @@ Ghost_OnCreate(HWND hwnd, CREATESTRUCTW *lpcs) // get the target hwndTarget = (HWND)lpcs->lpCreateParams; - if (!IsWindowVisible(hwndTarget) || // invisible? - GetParent(hwndTarget) || // child? - !IsHungAppWindow(hwndTarget)) // not hung? + if (!IsWindowVisible(hwndTarget) || // invisible? + (GetWindowLongPtrW(hwndTarget, GWL_STYLE) & WS_CHILD) || // child? + !IsHungAppWindow(hwndTarget)) // not hung? { return FALSE; }
6 years
1
0
0
0
[reactos] 01/01: Revert "[WIN32SS][USER32] Add codes for Ghost Window (#1100)" (#1110)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=99b055a50603fde096540…
commit 99b055a50603fde0965404771ca09cb3158aa83d Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Dec 11 11:30:00 2018 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Dec 11 11:30:00 2018 +0900 Revert "[WIN32SS][USER32] Add codes for Ghost Window (#1100)" (#1110) This reverts commit 1adefd180c4b53e5dd713cb410e2c7a78c48dbb6. ReactOS wouldn't startup. --- win32ss/include/ghostwnd.h | 20 ----- win32ss/user/ntuser/class.h | 8 -- win32ss/user/ntuser/ghost.c | 167 ++--------------------------------- win32ss/user/ntuser/ghost.h | 2 +- win32ss/user/ntuser/message.c | 2 +- win32ss/user/user32/controls/ghost.c | 15 +++- 6 files changed, 19 insertions(+), 195 deletions(-) diff --git a/win32ss/include/ghostwnd.h b/win32ss/include/ghostwnd.h deleted file mode 100644 index 6907580c79..0000000000 --- a/win32ss/include/ghostwnd.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * PROJECT: ReactOS header - * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) - * PURPOSE: Ghost window - * COPYRIGHT: Copyright 2018 Katayama Hirofumi MZ (katayama.hirofumi.mz(a)gmail.com) - */ -#ifndef REACTOS_GHOST_WND_INCLUDED -#define REACTOS_GHOST_WND_INCLUDED - -#define GHOSTCLASSNAME L"Ghost" -#define GHOST_PROP L"GhostProp" - -typedef struct GHOST_DATA -{ - HWND hwndTarget; - HBITMAP hbm32bpp; - BOOL bDestroyTarget; -} GHOST_DATA; - -#endif diff --git a/win32ss/user/ntuser/class.h b/win32ss/user/ntuser/class.h index 0c41dc3208..c5b3e8308c 100644 --- a/win32ss/user/ntuser/class.h +++ b/win32ss/user/ntuser/class.h @@ -66,12 +66,4 @@ ProbeAndCaptureUnicodeStringOrAtom( _Out_ _When_(return>=0, _At_(pustrOut->Buffer, _Post_ _Notnull_)) PUNICODE_STRING pustrOut, __in_data_source(USER_MODE) _In_ PUNICODE_STRING pustrUnsafe); -BOOL FASTCALL LookupFnIdToiCls(int FnId, int *iCls); - -INT -UserGetClassName(IN PCLS Class, - IN OUT PUNICODE_STRING ClassName, - IN RTL_ATOM Atom, - IN BOOL Ansi); - /* EOF */ diff --git a/win32ss/user/ntuser/ghost.c b/win32ss/user/ntuser/ghost.c index 1db583c55a..726fe8ff3d 100644 --- a/win32ss/user/ntuser/ghost.c +++ b/win32ss/user/ntuser/ghost.c @@ -1,178 +1,23 @@ /* * PROJECT: ReactOS user32.dll * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) - * PURPOSE: Window ghosting feature + * PURPOSE: Ghost window handling * COPYRIGHT: Copyright 2018 Katayama Hirofumi MZ (katayama.hirofumi.mz(a)gmail.com) */ #include <win32k.h> -#include "ghostwnd.h" -#define NDEBUG -#include <debug.h> - -static UNICODE_STRING GhostClass = RTL_CONSTANT_STRING(GHOSTCLASSNAME); -static UNICODE_STRING GhostProp = RTL_CONSTANT_STRING(GHOST_PROP); - -BOOL FASTCALL IntIsGhostWindow(PWND Window) -{ - BOOLEAN Ret = FALSE; - UNICODE_STRING ClassName; - INT iCls, Len; - RTL_ATOM Atom = 0; - - if (!Window) - return FALSE; - - if (Window->fnid && !(Window->fnid & FNID_DESTROY)) - { - if (LookupFnIdToiCls(Window->fnid, &iCls)) - { - Atom = gpsi->atomSysClass[iCls]; - } - } - - // check class name - RtlInitUnicodeString(&ClassName, NULL); - Len = UserGetClassName(Window->pcls, &ClassName, Atom, FALSE); - if (Len > 0) - { - Ret = RtlEqualUnicodeString(&ClassName, &GhostClass, TRUE); - } - else - { - DPRINT1("Unable to get class name\n"); - } - RtlFreeUnicodeString(&ClassName); - - return Ret; -} - -HWND FASTCALL IntGhostWindowFromHungWindow(PWND pHungWnd) -{ - RTL_ATOM Atom; - HWND hwndGhost; - - if (!IntGetAtomFromStringOrAtom(&GhostProp, &Atom)) - ASSERT(FALSE); - - hwndGhost = UserGetProp(pHungWnd, Atom, TRUE); - if (hwndGhost) - { - if (ValidateHwndNoErr(hwndGhost)) - return hwndGhost; - - DPRINT("Not a window\n"); - } - - return NULL; -} - -HWND FASTCALL UserGhostWindowFromHungWindow(HWND hwndHung) +BOOL FASTCALL IntGoGhost(PWND Window, BOOL bGo) { - PWND pHungWnd = ValidateHwndNoErr(hwndHung); - if (!pHungWnd) - { - DPRINT("Not a window\n"); - return NULL; - } - return IntGhostWindowFromHungWindow(pHungWnd); -} - -HWND FASTCALL IntHungWindowFromGhostWindow(PWND pGhostWnd) -{ - const GHOST_DATA *UserData; - HWND hwndTarget; - - if (!IntIsGhostWindow(pGhostWnd)) - { - DPRINT("Not a ghost window\n"); - return NULL; - } - - UserData = (const GHOST_DATA *)pGhostWnd->dwUserData; - if (UserData) - { - _SEH2_TRY - { - ProbeForRead(UserData, sizeof(GHOST_DATA), 1); - hwndTarget = UserData->hwndTarget; - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - DPRINT1("Exception!\n"); - hwndTarget = NULL; - } - _SEH2_END; - } - else - { - DPRINT("No user data\n"); - hwndTarget = NULL; - } - - if (hwndTarget) - { - if (ValidateHwndNoErr(hwndTarget)) - return hwndTarget; - - DPRINT1("Not a window\n"); - } - - return NULL; -} - -HWND FASTCALL UserHungWindowFromGhostWindow(HWND hwndGhost) -{ - PWND pGhostWnd = ValidateHwndNoErr(hwndGhost); - return IntHungWindowFromGhostWindow(pGhostWnd); -} - -BOOL FASTCALL IntMakeHungWindowGhosted(HWND hwndHung) -{ - PWND pHungWnd = ValidateHwndNoErr(hwndHung); - if (!pHungWnd) - { - DPRINT1("Not a window\n"); - return FALSE; // not a window - } - - if (IntIsGhostWindow(pHungWnd)) - { - DPRINT1("IntIsGhostWindow\n"); - return FALSE; // ghost window cannot be ghosted - } - - if (!MsqIsHung(pHungWnd->head.pti)) - { - DPRINT1("Not hung window\n"); - return FALSE; // not hung window - } - - if (!(pHungWnd->style & WS_VISIBLE)) - return FALSE; // invisible - - if (pHungWnd->style & WS_CHILD) - return FALSE; // child - - if (IntGhostWindowFromHungWindow(pHungWnd)) - { - DPRINT("Already ghosting\n"); - return FALSE; // already ghosting - } - // TODO: // 1. Create a thread. // 2. Create a ghost window in the thread. // 3. Do message loop in the thread + static int bWarnedOnce = 0; + if (!bWarnedOnce) { - static int bWarnedOnce = 0; - if (!bWarnedOnce) - { - bWarnedOnce++; - STUB; - } + bWarnedOnce++; + STUB; } - return FALSE; } diff --git a/win32ss/user/ntuser/ghost.h b/win32ss/user/ntuser/ghost.h index cd7b45ce5c..c348bf1417 100644 --- a/win32ss/user/ntuser/ghost.h +++ b/win32ss/user/ntuser/ghost.h @@ -1 +1 @@ -BOOL FASTCALL IntMakeHungWindowGhosted(HWND hwndHung); +BOOL FASTCALL IntGoGhost(PWND Window, BOOL bGo); diff --git a/win32ss/user/ntuser/message.c b/win32ss/user/ntuser/message.c index 6f887b90a8..0de5f3f260 100644 --- a/win32ss/user/ntuser/message.c +++ b/win32ss/user/ntuser/message.c @@ -1443,7 +1443,7 @@ co_IntSendMessageTimeoutSingle( HWND hWnd, } TRACE("Let's go Ghost!\n"); - IntMakeHungWindowGhosted(hWnd); + IntGoGhost(Window, TRUE); } if (Window->state & WNDS_DESTROYED) diff --git a/win32ss/user/user32/controls/ghost.c b/win32ss/user/user32/controls/ghost.c index 0abc064873..ccc9a6c528 100644 --- a/win32ss/user/user32/controls/ghost.c +++ b/win32ss/user/user32/controls/ghost.c @@ -7,12 +7,12 @@ #include <user32.h> #include <strsafe.h> -#include "ghostwnd.h" WINE_DEFAULT_DEBUG_CHANNEL(ghost); #define GHOST_TIMER_ID 0xFACEDEAD #define GHOST_INTERVAL 1000 // one second +#define GHOST_PROP L"GhostProp" const struct builtin_class_descr GHOST_builtin_class = { @@ -105,6 +105,13 @@ IntMakeGhostImage(HBITMAP hbm) /****************************************************************************/ +typedef struct GHOST_DATA +{ + HWND hwndTarget; + HBITMAP hbm32bpp; + BOOL bDestroyTarget; +} GHOST_DATA; + static GHOST_DATA * Ghost_GetData(HWND hwnd) { @@ -181,9 +188,9 @@ Ghost_OnCreate(HWND hwnd, CREATESTRUCTW *lpcs) // get the target hwndTarget = (HWND)lpcs->lpCreateParams; - if (!IsWindowVisible(hwndTarget) || // invisible? - (GetWindowLongPtrW(hwndTarget, GWL_STYLE) & WS_CHILD) || // child? - !IsHungAppWindow(hwndTarget)) // not hung? + if (!IsWindowVisible(hwndTarget) || // invisible? + GetParent(hwndTarget) || // child? + !IsHungAppWindow(hwndTarget)) // not hung? { return FALSE; }
6 years
1
0
0
0
[reactos] 01/01: [WIN32SS][USER32] Add codes for Ghost Window (#1100)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1adefd180c4b53e5dd713…
commit 1adefd180c4b53e5dd713cb410e2c7a78c48dbb6 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Tue Dec 11 10:48:23 2018 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Tue Dec 11 10:48:23 2018 +0900 [WIN32SS][USER32] Add codes for Ghost Window (#1100) CORE-11944 --- win32ss/include/ghostwnd.h | 20 +++++ win32ss/user/ntuser/class.h | 8 ++ win32ss/user/ntuser/ghost.c | 167 +++++++++++++++++++++++++++++++++-- win32ss/user/ntuser/ghost.h | 2 +- win32ss/user/ntuser/message.c | 2 +- win32ss/user/user32/controls/ghost.c | 15 +--- 6 files changed, 195 insertions(+), 19 deletions(-) diff --git a/win32ss/include/ghostwnd.h b/win32ss/include/ghostwnd.h new file mode 100644 index 0000000000..6907580c79 --- /dev/null +++ b/win32ss/include/ghostwnd.h @@ -0,0 +1,20 @@ +/* + * PROJECT: ReactOS header + * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) + * PURPOSE: Ghost window + * COPYRIGHT: Copyright 2018 Katayama Hirofumi MZ (katayama.hirofumi.mz(a)gmail.com) + */ +#ifndef REACTOS_GHOST_WND_INCLUDED +#define REACTOS_GHOST_WND_INCLUDED + +#define GHOSTCLASSNAME L"Ghost" +#define GHOST_PROP L"GhostProp" + +typedef struct GHOST_DATA +{ + HWND hwndTarget; + HBITMAP hbm32bpp; + BOOL bDestroyTarget; +} GHOST_DATA; + +#endif diff --git a/win32ss/user/ntuser/class.h b/win32ss/user/ntuser/class.h index c5b3e8308c..0c41dc3208 100644 --- a/win32ss/user/ntuser/class.h +++ b/win32ss/user/ntuser/class.h @@ -66,4 +66,12 @@ ProbeAndCaptureUnicodeStringOrAtom( _Out_ _When_(return>=0, _At_(pustrOut->Buffer, _Post_ _Notnull_)) PUNICODE_STRING pustrOut, __in_data_source(USER_MODE) _In_ PUNICODE_STRING pustrUnsafe); +BOOL FASTCALL LookupFnIdToiCls(int FnId, int *iCls); + +INT +UserGetClassName(IN PCLS Class, + IN OUT PUNICODE_STRING ClassName, + IN RTL_ATOM Atom, + IN BOOL Ansi); + /* EOF */ diff --git a/win32ss/user/ntuser/ghost.c b/win32ss/user/ntuser/ghost.c index 726fe8ff3d..1db583c55a 100644 --- a/win32ss/user/ntuser/ghost.c +++ b/win32ss/user/ntuser/ghost.c @@ -1,23 +1,178 @@ /* * PROJECT: ReactOS user32.dll * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later
) - * PURPOSE: Ghost window handling + * PURPOSE: Window ghosting feature * COPYRIGHT: Copyright 2018 Katayama Hirofumi MZ (katayama.hirofumi.mz(a)gmail.com) */ #include <win32k.h> +#include "ghostwnd.h" -BOOL FASTCALL IntGoGhost(PWND Window, BOOL bGo) +#define NDEBUG +#include <debug.h> + +static UNICODE_STRING GhostClass = RTL_CONSTANT_STRING(GHOSTCLASSNAME); +static UNICODE_STRING GhostProp = RTL_CONSTANT_STRING(GHOST_PROP); + +BOOL FASTCALL IntIsGhostWindow(PWND Window) +{ + BOOLEAN Ret = FALSE; + UNICODE_STRING ClassName; + INT iCls, Len; + RTL_ATOM Atom = 0; + + if (!Window) + return FALSE; + + if (Window->fnid && !(Window->fnid & FNID_DESTROY)) + { + if (LookupFnIdToiCls(Window->fnid, &iCls)) + { + Atom = gpsi->atomSysClass[iCls]; + } + } + + // check class name + RtlInitUnicodeString(&ClassName, NULL); + Len = UserGetClassName(Window->pcls, &ClassName, Atom, FALSE); + if (Len > 0) + { + Ret = RtlEqualUnicodeString(&ClassName, &GhostClass, TRUE); + } + else + { + DPRINT1("Unable to get class name\n"); + } + RtlFreeUnicodeString(&ClassName); + + return Ret; +} + +HWND FASTCALL IntGhostWindowFromHungWindow(PWND pHungWnd) +{ + RTL_ATOM Atom; + HWND hwndGhost; + + if (!IntGetAtomFromStringOrAtom(&GhostProp, &Atom)) + ASSERT(FALSE); + + hwndGhost = UserGetProp(pHungWnd, Atom, TRUE); + if (hwndGhost) + { + if (ValidateHwndNoErr(hwndGhost)) + return hwndGhost; + + DPRINT("Not a window\n"); + } + + return NULL; +} + +HWND FASTCALL UserGhostWindowFromHungWindow(HWND hwndHung) { + PWND pHungWnd = ValidateHwndNoErr(hwndHung); + if (!pHungWnd) + { + DPRINT("Not a window\n"); + return NULL; + } + return IntGhostWindowFromHungWindow(pHungWnd); +} + +HWND FASTCALL IntHungWindowFromGhostWindow(PWND pGhostWnd) +{ + const GHOST_DATA *UserData; + HWND hwndTarget; + + if (!IntIsGhostWindow(pGhostWnd)) + { + DPRINT("Not a ghost window\n"); + return NULL; + } + + UserData = (const GHOST_DATA *)pGhostWnd->dwUserData; + if (UserData) + { + _SEH2_TRY + { + ProbeForRead(UserData, sizeof(GHOST_DATA), 1); + hwndTarget = UserData->hwndTarget; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + DPRINT1("Exception!\n"); + hwndTarget = NULL; + } + _SEH2_END; + } + else + { + DPRINT("No user data\n"); + hwndTarget = NULL; + } + + if (hwndTarget) + { + if (ValidateHwndNoErr(hwndTarget)) + return hwndTarget; + + DPRINT1("Not a window\n"); + } + + return NULL; +} + +HWND FASTCALL UserHungWindowFromGhostWindow(HWND hwndGhost) +{ + PWND pGhostWnd = ValidateHwndNoErr(hwndGhost); + return IntHungWindowFromGhostWindow(pGhostWnd); +} + +BOOL FASTCALL IntMakeHungWindowGhosted(HWND hwndHung) +{ + PWND pHungWnd = ValidateHwndNoErr(hwndHung); + if (!pHungWnd) + { + DPRINT1("Not a window\n"); + return FALSE; // not a window + } + + if (IntIsGhostWindow(pHungWnd)) + { + DPRINT1("IntIsGhostWindow\n"); + return FALSE; // ghost window cannot be ghosted + } + + if (!MsqIsHung(pHungWnd->head.pti)) + { + DPRINT1("Not hung window\n"); + return FALSE; // not hung window + } + + if (!(pHungWnd->style & WS_VISIBLE)) + return FALSE; // invisible + + if (pHungWnd->style & WS_CHILD) + return FALSE; // child + + if (IntGhostWindowFromHungWindow(pHungWnd)) + { + DPRINT("Already ghosting\n"); + return FALSE; // already ghosting + } + // TODO: // 1. Create a thread. // 2. Create a ghost window in the thread. // 3. Do message loop in the thread - static int bWarnedOnce = 0; - if (!bWarnedOnce) { - bWarnedOnce++; - STUB; + static int bWarnedOnce = 0; + if (!bWarnedOnce) + { + bWarnedOnce++; + STUB; + } } + return FALSE; } diff --git a/win32ss/user/ntuser/ghost.h b/win32ss/user/ntuser/ghost.h index c348bf1417..cd7b45ce5c 100644 --- a/win32ss/user/ntuser/ghost.h +++ b/win32ss/user/ntuser/ghost.h @@ -1 +1 @@ -BOOL FASTCALL IntGoGhost(PWND Window, BOOL bGo); +BOOL FASTCALL IntMakeHungWindowGhosted(HWND hwndHung); diff --git a/win32ss/user/ntuser/message.c b/win32ss/user/ntuser/message.c index 0de5f3f260..6f887b90a8 100644 --- a/win32ss/user/ntuser/message.c +++ b/win32ss/user/ntuser/message.c @@ -1443,7 +1443,7 @@ co_IntSendMessageTimeoutSingle( HWND hWnd, } TRACE("Let's go Ghost!\n"); - IntGoGhost(Window, TRUE); + IntMakeHungWindowGhosted(hWnd); } if (Window->state & WNDS_DESTROYED) diff --git a/win32ss/user/user32/controls/ghost.c b/win32ss/user/user32/controls/ghost.c index ccc9a6c528..0abc064873 100644 --- a/win32ss/user/user32/controls/ghost.c +++ b/win32ss/user/user32/controls/ghost.c @@ -7,12 +7,12 @@ #include <user32.h> #include <strsafe.h> +#include "ghostwnd.h" WINE_DEFAULT_DEBUG_CHANNEL(ghost); #define GHOST_TIMER_ID 0xFACEDEAD #define GHOST_INTERVAL 1000 // one second -#define GHOST_PROP L"GhostProp" const struct builtin_class_descr GHOST_builtin_class = { @@ -105,13 +105,6 @@ IntMakeGhostImage(HBITMAP hbm) /****************************************************************************/ -typedef struct GHOST_DATA -{ - HWND hwndTarget; - HBITMAP hbm32bpp; - BOOL bDestroyTarget; -} GHOST_DATA; - static GHOST_DATA * Ghost_GetData(HWND hwnd) { @@ -188,9 +181,9 @@ Ghost_OnCreate(HWND hwnd, CREATESTRUCTW *lpcs) // get the target hwndTarget = (HWND)lpcs->lpCreateParams; - if (!IsWindowVisible(hwndTarget) || // invisible? - GetParent(hwndTarget) || // child? - !IsHungAppWindow(hwndTarget)) // not hung? + if (!IsWindowVisible(hwndTarget) || // invisible? + (GetWindowLongPtrW(hwndTarget, GWL_STYLE) & WS_CHILD) || // child? + !IsHungAppWindow(hwndTarget)) // not hung? { return FALSE; }
6 years
1
0
0
0
[reactos] 01/01: [TRANSLATION] Update Simplified Chinese translation and notice. (#1108)
by Luo Yufan
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=acef266bc60cada13e51b…
commit acef266bc60cada13e51bb48b060ce3cb541331c Author: Luo Yufan <njlyf2011(a)hotmail.com> AuthorDate: Mon Dec 10 23:03:00 2018 +0800 Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org> CommitDate: Mon Dec 10 16:03:00 2018 +0100 [TRANSLATION] Update Simplified Chinese translation and notice. (#1108) --- base/system/chkdsk/chkdsk.rc | 3 ++ base/system/chkdsk/lang/zh-CN.rc | 33 +++++++++++++ base/system/diskpart/lang/zh-CN.rc | 90 +++++++++++++++++------------------ base/system/runonce/lang/zh-CN.rc | 5 +- base/system/subst/lang/zh-CN.rc | 6 +-- base/system/userinit/lang/zh-CN.rc | 10 ++-- dll/cpl/openglcfg/lang/zh-CN.rc | 4 +- media/doc/For_Chinese_Translation.txt | 2 +- 8 files changed, 95 insertions(+), 58 deletions(-) diff --git a/base/system/chkdsk/chkdsk.rc b/base/system/chkdsk/chkdsk.rc index 00a5373b53..8405c8623b 100644 --- a/base/system/chkdsk/chkdsk.rc +++ b/base/system/chkdsk/chkdsk.rc @@ -31,3 +31,6 @@ #ifdef LANGUAGE_TR_TR #include "lang/tr-TR.rc" #endif +#ifdef LANGUAGE_ZH_CN + #include "lang/zh-CN.rc" +#endif diff --git a/base/system/chkdsk/lang/zh-CN.rc b/base/system/chkdsk/lang/zh-CN.rc new file mode 100644 index 0000000000..d1402e6bc6 --- /dev/null +++ b/base/system/chkdsk/lang/zh-CN.rc @@ -0,0 +1,33 @@ +/* Translation has been created by Luo Yufan in 2018 (njlyf2011(a)hotmail.com) */ + +LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED + +STRINGTABLE +BEGIN + IDS_USAGE "\n\ +Usage: %s [drive:] [-F] [-V] [-R] [-C] \n\n\ +[drive:] 指定需要检查的驱动器。\n\ +-F 修复磁盘上的错误。\n\ +-V 显示每一个文件的完整路径。\n\ +-R 寻找坏扇区并修复里面的可读信息。\n\ +-C 仅在驱动器被标记为出错时检查驱动器。\n\ +\n" + + IDS_PERCENT_COMPL "百分之 %d 已完成。\r" + IDS_FILE_SYSTEM "文件系统类型为 %s。\n" + IDS_ABOUT "\n\ +Chkdskx v1.0.1 by Mark Russinovich\n\ +Systems Internals -
http://www.sysinternals.com\n\
+ReactOS 于 1999 年由 Emanuele Aliberti 改编" +END + +STRINGTABLE +BEGIN + IDS_VOLUME_IN_USE "卷正在被使用,无法锁定。\n" + IDS_CHKDSK_FAIL "Chkdsk 没有成功完成。\n\n" + IDS_NO_ENTRY_POINT "无法找到 FMIFS 入口点。\n\n" + IDS_BAD_ARGUMENT "未知参数: %s\n" + IDS_NO_CURRENT_DIR "无法获得当前目录。错误代码: " + IDS_NO_QUERY_VOL "无法查询卷。错误代码: " + IDS_VOLUME_IN_USE_PROC "Chkdsk 无法运行,因为该卷正在被另一个进程所使用。\n\n" +END diff --git a/base/system/diskpart/lang/zh-CN.rc b/base/system/diskpart/lang/zh-CN.rc index be87063393..9b035c1f53 100644 --- a/base/system/diskpart/lang/zh-CN.rc +++ b/base/system/diskpart/lang/zh-CN.rc @@ -1,5 +1,5 @@ /* Simplified Chinese translation by Henry Tang Ih 2016 (henrytang2(a)hotmail.com) */ -/* Improved by Luo Yufan 2018 <njlyf2011(a)hotmail.com> */ +/* Translation has been changed by Luo Yufan 2018 <njlyf2011(a)hotmail.com> */ LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED @@ -46,7 +46,7 @@ BEGIN IDS_LIST_PARTITION_HEAD "\n 分区 类型 大小 偏移量\n" IDS_LIST_PARTITION_LINE " ------------- ---------------- ------- -------\n" IDS_LIST_PARTITION_FORMAT "%c Partition %2lu %-16s %4I64u %-2s %4I64u %-2s\n" - IDS_LIST_PARTITION_NO_DISK "\n还有没有要列出分区的磁盘。\n请选择一个磁盘,再试一次。\n\n" + IDS_LIST_PARTITION_NO_DISK "\n这里没有要列出分区的磁盘。\n请选择一个磁盘,再试一次。\n\n" IDS_LIST_VOLUME_HEAD " 卷 ### Ltr 标签\n" END @@ -54,7 +54,7 @@ END STRINGTABLE BEGIN IDS_RESCAN_START "\nDiskPart 正在扫描您的配置,请稍候...\n" - IDS_RESCAN_END "\nDiskPart 完成扫描您的配置。\n\n" + IDS_RESCAN_END "\nDiskPart 已经完成扫描您的配置。\n\n" END /* Select command strings */ @@ -79,7 +79,7 @@ BEGIN IDS_STATUS_DISK_HEALTHY "健康" IDS_STATUS_DISK_SICK "生病" IDS_STATUS_UNAVAILABLE "不可用" - IDS_STATUS_ONLINE "在线" + IDS_STATUS_ONLINE "联机" IDS_STATUS_OFFLINE "脱机" IDS_STATUS_NO_MEDIA "没有媒体" END @@ -93,41 +93,41 @@ END /* Help Command Descripions */ STRINGTABLE BEGIN - IDS_HELP_CMD_DESC_ACTIVE "ACTIVE\t\t- 所选将分区标记为活动。\n" + IDS_HELP_CMD_DESC_ACTIVE "ACTIVE\t\t- 将所选分区标记为活动。\n" IDS_HELP_CMD_DESC_ADD "ADD\t\t- 将镜像添加到一个简单卷。\n" IDS_HELP_CMD_DESC_ASSIGN "ASSIGN\t\t- 为所选的卷分配一个驱动器号或装入点。\n" - IDS_HELP_CMD_DESC_ATTACH "ATTACH\t\t- 附加的虚拟磁盘文件。\n" + IDS_HELP_CMD_DESC_ATTACH "ATTACH\t\t- 附加虚拟磁盘文件。\n" IDS_HELP_CMD_DESC_ATTRIBUTES "ATTRIBUTES\t- 操纵卷或磁盘的属性。\n" IDS_HELP_CMD_DESC_AUTOMOUNT "AUTOMOUNT\t- 启用和禁用基本卷的自动装入。\n" IDS_HELP_CMD_DESC_BREAK "BREAK\t\t- 中断镜像集。\n" IDS_HELP_CMD_DESC_CLEAN "CLEAN\t\t- 清除配置信息或所有信息,关闭\n\t\t 磁盘。\n" - IDS_HELP_CMD_DESC_COMPACT "COMPACT\t\t- 企图减少文件的物理大小。\n" - IDS_HELP_CMD_DESC_CONVERT "CONVERT\t\t- 不同的磁盘格式之间进行转换。\n" - IDS_HELP_CMD_DESC_CREATE "CREATE\t\t- 创建卷、 分区或虚拟磁盘。\n" + IDS_HELP_CMD_DESC_COMPACT "COMPACT\t\t- 尝试减少文件的物理大小。\n" + IDS_HELP_CMD_DESC_CONVERT "CONVERT\t\t- 在不同的磁盘格式之间进行转换。\n" + IDS_HELP_CMD_DESC_CREATE "CREATE\t\t- 创建卷、分区或虚拟磁盘。\n" IDS_HELP_CMD_DESC_DELETE "DELETE\t\t- 删除对象。\n" - IDS_HELP_CMD_DESC_DETACH "DETACH\t\t- 分离一个虚拟磁盘文件。\n" + IDS_HELP_CMD_DESC_DETACH "DETACH\t\t- 分离虚拟磁盘文件。\n" IDS_HELP_CMD_DESC_DETAIL "DETAIL\t\t- 提供有关对象的详细信息。\n" IDS_HELP_CMD_DESC_EXIT "EXIT\t\t- 退出 DiskPart。\n" IDS_HELP_CMD_DESC_EXPAND "EXPAND\t\t- 扩展虚拟磁盘上的可用的最大大小。\n" IDS_HELP_CMD_DESC_EXTEND "EXTEND\t\t- 扩展卷。\n" - IDS_HELP_CMD_DESC_FS "FILESYSTEMS\t- 显示当前受支持的文件系统的卷上。\n" - IDS_HELP_CMD_DESC_FORMAT "FORMAT\t\t- 卷或分区进行格式化。\n" + IDS_HELP_CMD_DESC_FS "FILESYSTEMS\t- 显示卷上当前和支持的文件系统。\n" + IDS_HELP_CMD_DESC_FORMAT "FORMAT\t\t- 格式化卷或分区。\n" IDS_HELP_CMD_DESC_GPT "GPT\t\t- 将属性分配给所选的 GPT 分区。\n" - IDS_HELP_CMD_DESC_HELP "HELP\t\t- 显示命令的列表。\n" + IDS_HELP_CMD_DESC_HELP "HELP\t\t- 显示命令列表。\n" IDS_HELP_CMD_DESC_IMPORT "IMPORT\t\t- 导入磁盘组。\n" - IDS_HELP_CMD_DESC_INACTIVE "INACTIVE\t- 所选将分区标记为非活动状态。\n" - IDS_HELP_CMD_DESC_LIST "LIST\t\t- 显示对象的列表。\n" - IDS_HELP_CMD_DESC_MERGE "MERGE\t\t- 合并与它的双亲的子磁盘。\n" - IDS_HELP_CMD_DESC_OFFLINE "OFFLINE\t\t- 离线对象是当前标记作为在线。\n" - IDS_HELP_CMD_DESC_ONLINE "ONLINE\t\t- 在线当前标记为脱机对象。\n" - IDS_HELP_CMD_DESC_RECOVER "RECOVER\t\t- 刷新了无效的包中的所有磁盘的状态,\n\t\t 重新同步镜像卷和 RAID5 卷\n\t\t 那有陈旧的丛或奇偶校验数据。\n" - IDS_HELP_CMD_DESC_REM "REM\t\t- 无反应。这用来注解脚本。\n" - IDS_HELP_CMD_DESC_REMOVE "REMOVE\t\t- 删除驱动器号或装载点指派。\n" - IDS_HELP_CMD_DESC_REPAIR "REPAIR\t\t- 修复失败的成员与 RAID 5 卷。\n" + IDS_HELP_CMD_DESC_INACTIVE "INACTIVE\t- 将所选分区标记为非活动状态。\n" + IDS_HELP_CMD_DESC_LIST "LIST\t\t- 显示对象列表。\n" + IDS_HELP_CMD_DESC_MERGE "MERGE\t\t- 将子磁盘与父磁盘合并。\n" + IDS_HELP_CMD_DESC_OFFLINE "OFFLINE\t\t- 将当前标记为脱机的磁盘设置为联机。\n" + IDS_HELP_CMD_DESC_ONLINE "ONLINE\t\t- 将当前标记为联机的磁盘设置为脱机。\n" + IDS_HELP_CMD_DESC_RECOVER "RECOVER\t\t- 刷新无效包中的所有磁盘的状态,\n\t\t 并重新同步具有过时丛或奇偶校 \n\t\t 验数据的镜像卷和 RAID5 卷。\n" + IDS_HELP_CMD_DESC_REM "REM\t\t- 无作用。这用来注释脚本。\n" + IDS_HELP_CMD_DESC_REMOVE "REMOVE\t\t- 删除驱动器号或指派的装载点。\n" + IDS_HELP_CMD_DESC_REPAIR "REPAIR\t\t- 用失败的成员修复 RAID 5 卷。\n" IDS_HELP_CMD_DESC_RESCAN "RESCAN\t\t- 重新扫描计算机,查找磁盘和卷。\n" IDS_HELP_CMD_DESC_RETAIN "RETAIN\t\t- 放置在一个简单卷下的一个保留的分区。\n" IDS_HELP_CMD_DESC_SAN "SAN\t\t- 显示或设置当前引导 OS 的 SAN 策略。\n" - IDS_HELP_CMD_DESC_SELECT "SELECT\t\t- 重点转移到一个对象。\n" + IDS_HELP_CMD_DESC_SELECT "SELECT\t\t- 将重点转移到一个对象。\n" IDS_HELP_CMD_DESC_SETID "SETID\t\t- 更改分区类型。\n" IDS_HELP_CMD_DESC_SHRINK "SHRINK\t\t- 减小所选卷的大小。\n" IDS_HELP_CMD_DESC_UNIQUEID "UNIQUEID\t- 显示或设置 GUID 分区表 (GPT) 的标识符\n\t\t 或主引导记录 (MBR) 磁盘的签名。" @@ -145,14 +145,14 @@ END STRINGTABLE BEGIN IDS_HELP_CMD_ACTIVE "\n\ -<活动命令帮助在此处添加文本>\n\n" +<在此处添加活动命令帮助>\n\n" END /* Add help descriptions */ STRINGTABLE BEGIN IDS_HELP_CMD_ADD "\n\ -<添加命令帮助在此处添加文本>\n\n" +<在此添加命令帮助>\n\n" END /* Assign help descriptions */ @@ -173,21 +173,21 @@ END STRINGTABLE BEGIN IDS_HELP_CMD_ATTRIBUTES "\n\ -<属性命令帮助在此处添加文本>\n\n" +<属性在此处添加命令帮助>\n\n" END /* Automount help descriptions */ STRINGTABLE BEGIN IDS_HELP_CMD_AUTOMOUNT "\n\ -<自动挂载命令帮助在此处添加文本>\n\n" +<自动挂载在此处添加命令帮助>\n\n" END /* Break help descriptions */ STRINGTABLE BEGIN IDS_HELP_CMD_BREAK "\n\ -<自动挂载命令帮助在此处添加文本>\n\n" +<自动挂载在此处添加命令帮助>\n\n" END /* Clean help descriptions */ @@ -201,14 +201,14 @@ END STRINGTABLE BEGIN IDS_HELP_CMD_COMPACT "\n\ -<紧凑的命令帮助在此处添加文本>\n\n" +<紧凑的在此处添加命令帮助>\n\n" END /* Convert help description */ STRINGTABLE BEGIN IDS_HELP_CMD_CONVERT "\n\ -<转换命令帮助在此处添加文本>\n\n" +<转换在此处添加命令帮助>\n\n" END /* Convert help description */ @@ -229,7 +229,7 @@ END STRINGTABLE BEGIN IDS_HELP_CMD_DETAIL "\n\ -<详细命令帮助在此处添加文本>\n\n" +<详细在此处添加命令帮助>\n\n" END /* Detach help description */ @@ -264,14 +264,14 @@ END STRINGTABLE BEGIN IDS_HELP_CMD_FORMAT "\n\ -<格式命令帮助在此处添加文本>\n\n" +<格式在此处添加命令帮助>\n\n" END /* GPT help description */ STRINGTABLE BEGIN IDS_HELP_CMD_GPT "\n\ -<Gpt 命令帮助在此处添加文本>\n\n" +<Gpt 在此处添加命令帮助>\n\n" END /* Help help descriptions */ @@ -285,7 +285,7 @@ END STRINGTABLE BEGIN IDS_HELP_CMD_IMPORT "\n\ -<导入命令帮助在此处添加文本>\n\n" +<导入在此处添加命令帮助>\n\n" END /* Inactive help descriptions */ @@ -306,28 +306,28 @@ END STRINGTABLE BEGIN IDS_HELP_CMD_MERGE "\n\ -<合并命令帮助在此处添加文本>\n\n" +<合并在此处添加命令帮助>\n\n" END /* Offline help descriptions */ STRINGTABLE BEGIN IDS_HELP_CMD_OFFLINE "\n\ -<脱机命令帮助在此处添加文本>\n\n" +<脱机在此处添加命令帮助>\n\n" END /* Online help descriptions */ STRINGTABLE BEGIN IDS_HELP_CMD_ONLINE "\n\ -<在线的命令帮助在此处添加文本>\n\n" +<在线的在此处添加命令帮助>\n\n" END /* Recover help descriptions */ STRINGTABLE BEGIN IDS_HELP_CMD_RECOVER "\n\ -<恢复命令帮助在此处添加文本>\n\n" +<恢复在此处添加命令帮助>\n\n" END /* Remove help descriptions */ @@ -341,21 +341,21 @@ END STRINGTABLE BEGIN IDS_HELP_CMD_REPAIR "\n\ -<修复命令帮助在此处添加文本>\n\n" +<修复在此处添加命令帮助>\n\n" END /* Rescan help descriptions */ STRINGTABLE BEGIN IDS_HELP_CMD_RESCAN "\n\ -<重新扫描命令帮助在此处添加文本>\n\n" +<重新扫描在此处添加命令帮助>\n\n" END /* Retain help descriptions */ STRINGTABLE BEGIN IDS_HELP_CMD_RETAIN "\n\ -<保留命令帮助在此处添加文本>\n\n" +<保留在此处添加命令帮助>\n\n" END /* San help descriptions */ @@ -369,26 +369,26 @@ END STRINGTABLE BEGIN IDS_HELP_CMD_SELECT "\n\ -<选择命令帮助在此处添加文本>\n\n" +<选择在此处添加命令帮助>\n\n" END /* Setid help descriptions */ STRINGTABLE BEGIN IDS_HELP_CMD_SETID "\n\ -<SETID 命令帮助在此处添加文本>\n\n" +<SETID 在此处添加命令帮助>\n\n" END /* Setid help descriptions */ STRINGTABLE BEGIN IDS_HELP_CMD_SHRINK "\n\ -<收缩命令帮助在此处添加文本>\n\n" +<收缩在此处添加命令帮助>\n\n" END /* Uniqueid help descriptions */ STRINGTABLE BEGIN IDS_HELP_CMD_UNIQUEID "\n\ -<UNIQUEID 命令帮助在此处添加文本>\n\n" +<UNIQUEID 在此处添加命令帮助>\n\n" END diff --git a/base/system/runonce/lang/zh-CN.rc b/base/system/runonce/lang/zh-CN.rc index 7566ea23f2..5a6bcf1ea6 100644 --- a/base/system/runonce/lang/zh-CN.rc +++ b/base/system/runonce/lang/zh-CN.rc @@ -1,10 +1,11 @@ /* Simplified Chinese translation by Song Fuchang (0xfc) <sfc_0(a)yahoo.com.cn> 2011 */ - +/* Translation has been changed by Luo Yufan(njlyf2011(a)hotmail.com) in 2018 */ + LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED IDD_RUNONCE_DLG DIALOGEX 0, 0, 239, 170 STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "ReactOS 安装" +CAPTION "ReactOS 安装程序" FONT 9, "宋体" BEGIN LTEXT "ReactOS 正在设置以下的项目:", -1, 38, 8, 196, 18 diff --git a/base/system/subst/lang/zh-CN.rc b/base/system/subst/lang/zh-CN.rc index 208c170241..7187781203 100644 --- a/base/system/subst/lang/zh-CN.rc +++ b/base/system/subst/lang/zh-CN.rc @@ -1,5 +1,5 @@ /* Simplified Chinese translation by Song Fuchang (0xfc) <sfc_0(a)yahoo.com.cn> 2011 */ -/* Improved by Luo Yufan (njlyf2011(a)hotmail.com) 2018 */ +/* Translation has been changed by Luo Yufan (njlyf2011(a)hotmail.com) 2018 */ LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED @@ -11,12 +11,12 @@ BEGIN IDS_PATH_NOT_FOUND "找不到路径 - %s\n" IDS_ACCESS_DENIED "拒绝访问 - %s\n" IDS_DRIVE_ALREADY_SUBSTED "驱动器已经运行过 SUBST\n" - IDS_FAILED_WITH_ERRORCODE "操作失败!错误码 0x%x:%s\n" + IDS_FAILED_WITH_ERRORCODE "失败,错误代码为 0x%x:%s\n" IDS_USAGE "将一个路径与驱动器号关联。\n\n\ SUBST [驱动器1: [驱动器2:]路径]\n\ SUBST 驱动器1: /D\n\n\ 驱动器1: 指定一个您想要关联到一个路径的虚拟驱动器。\n\ [驱动器2:]路径 指定一个您想要关联到一个虚拟驱动器的物理驱动器和路径。\n\ /D 删除一个虚拟驱动器。\n\n\ -执行不带参数的 SUBST 将会显示当前虚拟驱动器的列表。\n" +执行没有参数的 SUBST 将会显示当前虚拟驱动器的列表。\n" END diff --git a/base/system/userinit/lang/zh-CN.rc b/base/system/userinit/lang/zh-CN.rc index 5535037c97..8f95a7f06d 100644 --- a/base/system/userinit/lang/zh-CN.rc +++ b/base/system/userinit/lang/zh-CN.rc @@ -1,5 +1,5 @@ /* Simpified Chinese translation by Song Fuchang (0xfc) <sfc_0(a)yahoo.com.cn> 2011 */ -/* Improved by Luo Yufan (njlyf2011(a)hotmail.com) */ +/* Translation has been changed by Luo Yufan in 2018 (njlyf2011(a)hotmail.com) */ LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED @@ -13,7 +13,7 @@ BEGIN COMBOBOX IDC_LANGUAGELIST, 132, 107, 176, 142, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_CHILD | WS_VISIBLE | WS_TABSTOP RTEXT "键盘布局(&K):", IDC_STATIC, 20, 132, 106, 11, WS_CHILD | WS_VISIBLE | WS_GROUP COMBOBOX IDC_LAYOUTLIST, 132, 130, 176, 81, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_CHILD | WS_VISIBLE | WS_TABSTOP - LTEXT "选择您的语言和键盘布局,请单击下一步继续。", IDC_STATIC, 7, 152, 300, 8 + LTEXT "请选择您的语言和键盘布局,请单击下一步继续。", IDC_STATIC, 7, 152, 300, 8 CONTROL "", IDC_STATIC, "STATIC", SS_ETCHEDHORZ, 0, 165, 317, 1 DEFPUSHBUTTON "下一步(&N)", IDOK, 205, 172, 50, 14 @@ -26,7 +26,7 @@ CAPTION "ReactOS LiveCD" FONT 9, "宋体" BEGIN CONTROL "IDB_LOGO", IDC_STARTLOGO, "Static", WS_CHILD | WS_VISIBLE | SS_OWNERDRAW, 18, 4, 290, 99 - DEFPUSHBUTTON "运行 ReactOS &Live CD", IDC_RUN, 71, 108, 175, 21 + DEFPUSHBUTTON "运行 ReactOS Live CD(&L)", IDC_RUN, 71, 108, 175, 21 PUSHBUTTON "安装 ReactOS(&I)", IDC_INSTALL, 71, 136, 175, 21 // LTEXT "", IDC_STATIC, 7, 152, 300, 8 @@ -38,9 +38,9 @@ END STRINGTABLE BEGIN - IDS_SHELL_FAIL "Userinit 无法启动 Shell!" + IDS_SHELL_FAIL "Userinit 无法启动外壳程序!" IDS_INSTALLER_FAIL "Userinit 启动安装程序失败!" - IDS_CANCEL_CONFIRM "你确定要退出 ReactOS LiveCD 吗?\n如果选择退出,您的计算机将重新启动。" + IDS_CANCEL_CONFIRM "您确定要退出 ReactOS LiveCD 吗?\n如果选择退出,您的计算机将重新启动。" END STRINGTABLE diff --git a/dll/cpl/openglcfg/lang/zh-CN.rc b/dll/cpl/openglcfg/lang/zh-CN.rc index 24a8316b5b..09991d7668 100644 --- a/dll/cpl/openglcfg/lang/zh-CN.rc +++ b/dll/cpl/openglcfg/lang/zh-CN.rc @@ -1,4 +1,4 @@ -/* Created by Luo Yufan (njlyf2011(a)hotmail.com) 2018-10-06 */ +/* Translation has been created by Luo Yufan in 2018 (njlyf2011(a)hotmail.com) */ LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED @@ -15,7 +15,7 @@ BEGIN GROUPBOX "调试", -1, 5, 125, 230, 90 LTEXT "调试频道:", -1, 15, 142, 65, 10 COMBOBOX IDC_DEBUG_OUTPUT, 80, 140, 135, 10, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWNLIST - LTEXT "Enables/disables debug output from opengl32.\n\nWARNING: Choosing ""Set"" or ""Clear"" will overwrite the content of the DEBUGCHANNEL environment variable!", -1, 15, 165, 210, 40 + LTEXT "启用或启用来自 opengl32 的调试输出。\n\n警告: 选择 ""Set"" or ""Clear"" 将会覆盖当前 DEBUGCHANNEL 环境变量的内容!", -1, 15, 165, 210, 40 END STRINGTABLE diff --git a/media/doc/For_Chinese_Translation.txt b/media/doc/For_Chinese_Translation.txt index 94429fcbb9..45c447383d 100644 --- a/media/doc/For_Chinese_Translation.txt +++ b/media/doc/For_Chinese_Translation.txt @@ -6,7 +6,7 @@ The following material is addressed (in Chinese) to Chinese translators. 1)Windows 的记事本会将 UTF-8 格式变成 UTF-8 BOM 格式。因此,请不要用记事本编辑 ReactOS 的文件,特别是翻译文件。您可以使用 Notepad++ 之类的第三方文本编辑器进行编辑。 2)请不要将 USERENV 和 SHELL32 里面所提到的路径擅自翻译成中文,里面一些路径是可以翻译的,但是也有很多的路径是不可以进行翻译的,翻译的话会产生程序兼容性问题。曾经有段时间 ReactOS 里的路径都变成了中文,笔者在运行某个程序的时候就出现了问题。 -3)为了翻译的准确性,您可以参考 Windows 中的对应条目的翻译,但是请不要照搬 Windows 的翻译,这样可能会产生版权争议导致法律问题。 +3)为了翻译的准确性,您可以适当参考 Windows 中的对应条目的翻译,但是请不要照搬 Windows 的翻译,或者大段抄袭。这样可能会产生版权争议导致法律问题。 4)如果您是在 macOS 下进行翻译工作的,因为 macOS 的特性,子目录下面可能会产生 .DS_Store,所以需要在 git 提交前在代码根目录中执行 find . -name ".DS_Store" -depth -exec rm {} \; 以删除 .DS_Store 祝您翻译愉快!
6 years
1
0
0
0
[reactos] 02/02: [OSK] Update French translation.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d0c8636d1b41e07f67546…
commit d0c8636d1b41e07f67546c7f4f07df6ddbedb2a1 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Mon Dec 10 00:56:25 2018 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Mon Dec 10 00:56:55 2018 +0100 [OSK] Update French translation. --- base/applications/osk/lang/fr-FR.rc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/base/applications/osk/lang/fr-FR.rc b/base/applications/osk/lang/fr-FR.rc index 4aecda50c1..0b3dee5d7f 100644 --- a/base/applications/osk/lang/fr-FR.rc +++ b/base/applications/osk/lang/fr-FR.rc @@ -129,13 +129,13 @@ END IDD_WARNINGDIALOG_OSK DIALOGEX 0, 0, 250, 97 STYLE DS_SHELLFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION -CAPTION "On-Screen Keyboard" +CAPTION "Clavier visuel" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "OK", IDOK, 193, 76, 50, 14 ICON IDI_OSK, IDC_STATIC, 7, 17, 20, 20 - LTEXT "On-Screen Keyboard provides a minimum level of functionality for mobility-impaired users. Mobility-impaired users will need a utility program with higher functionality for daily use.", IDC_STATIC, 36, 7, 207, 33 - CONTROL "Do not show this message again", IDC_SHOWWARNINGCHECK, "Button", + LTEXT "Le Clavier visuel fournit quelques fonctionnalités aux utilisateurs souffrant de déficiences visuelles. La majorité de ces utilisateurs aura besoin d'un utilitaire avec plus de fonctionnalités pour une utilisation quotidienne.", IDC_STATIC, 36, 7, 207, 33 + CONTROL "Ne plus montrer ce message", IDC_SHOWWARNINGCHECK, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 43, 80, 137, 10 END
6 years
1
0
0
0
[reactos] 01/02: [OSK] Set also the large icon (that appears in the App Switcher) and move the code in OSK_DlgInitDialog().
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=92763e2901a077177cecf…
commit 92763e2901a077177cecf6411fe81b6e9f2b5c45 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Mon Dec 10 00:56:08 2018 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Mon Dec 10 00:56:54 2018 +0100 [OSK] Set also the large icon (that appears in the App Switcher) and move the code in OSK_DlgInitDialog(). --- base/applications/osk/main.c | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/base/applications/osk/main.c b/base/applications/osk/main.c index 7f5a5e9869..463b72d38d 100644 --- a/base/applications/osk/main.c +++ b/base/applications/osk/main.c @@ -58,32 +58,6 @@ int OSK_SetImage(int IdDlgItem, int IdResource) return TRUE; } -/*********************************************************************** - * - * OSK_SetAppIcon - * - * Set the application's icon - */ -BOOL OSK_SetAppIcon() -{ - HICON hIconSmall; - - /* Load the icon */ - hIconSmall = LoadImageW(Globals.hInstance, MAKEINTRESOURCEW(IDI_OSK), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE); - - /* Send a message window indicating that the icon has to be set */ - SendMessageW(Globals.hMainWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIconSmall); - - if (!hIconSmall) - { - /* If we fail then return FALSE and bail out */ - DestroyIcon(hIconSmall); - return FALSE; - } - - return TRUE; -} - /*********************************************************************** * * OSK_WarningProc @@ -134,7 +108,8 @@ INT_PTR CALLBACK OSK_WarningProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lPar */ int OSK_DlgInitDialog(HWND hDlg) { - HMONITOR monitor; + HICON hIcon, hIconSm; + HMONITOR monitor; MONITORINFO info; POINT Pt; RECT rcWindow; @@ -146,11 +121,18 @@ int OSK_DlgInitDialog(HWND hDlg) LoadDataFromRegistry(); /* Set the application's icon */ - OSK_SetAppIcon(); + hIcon = LoadImageW(Globals.hInstance, MAKEINTRESOURCEW(IDI_OSK), IMAGE_ICON, 0, 0, LR_SHARED | LR_DEFAULTSIZE); + hIconSm = CopyImage(hIcon, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_COPYFROMRESOURCE); + if (hIcon || hIconSm) + { + /* Set the window icons (they are deleted when the process terminates) */ + SendMessageW(Globals.hMainWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon); + SendMessageW(Globals.hMainWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm); + } /* Get screen info */ memset(&Pt, 0, sizeof(Pt)); - monitor = MonitorFromPoint(Pt, MONITOR_DEFAULTTOPRIMARY ); + monitor = MonitorFromPoint(Pt, MONITOR_DEFAULTTOPRIMARY); info.cbSize = sizeof(info); GetMonitorInfoW(monitor, &info);
6 years
1
0
0
0
[reactos] 01/01: [NTOSKRNL] IopGetDeviceProperty: Send an IRP_MN_QUERY_CAPABILITIES request to the device in order to query the power capabilities.
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=12fdc129cf8185ddaa038…
commit 12fdc129cf8185ddaa038913de6d9479498b5841 Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Mon Dec 10 00:30:03 2018 +0100 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Mon Dec 10 00:37:04 2018 +0100 [NTOSKRNL] IopGetDeviceProperty: Send an IRP_MN_QUERY_CAPABILITIES request to the device in order to query the power capabilities. --- ntoskrnl/io/pnpmgr/plugplay.c | 79 +++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 29 deletions(-) diff --git a/ntoskrnl/io/pnpmgr/plugplay.c b/ntoskrnl/io/pnpmgr/plugplay.c index 83a4cb6000..9aafd07918 100644 --- a/ntoskrnl/io/pnpmgr/plugplay.c +++ b/ntoskrnl/io/pnpmgr/plugplay.c @@ -359,40 +359,61 @@ IopGetDeviceProperty(PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData) } else { -// DEVICE_CAPABILITIES DeviceCapabilities; + DEVICE_CAPABILITIES DeviceCapabilities; PCM_POWER_DATA PowerData; - -// Status = IopQueryDeviceCapabilities(DeviceNode, &DeviceCapabilities); + IO_STACK_LOCATION Stack; + IO_STATUS_BLOCK IoStatusBlock; PowerData = (PCM_POWER_DATA)Buffer; - RtlZeroMemory(PowerData, sizeof(CM_POWER_DATA)); PowerData->PD_Size = sizeof(CM_POWER_DATA); -// PowerData->PD_MostRecentPowerState; - PowerData->PD_Capabilities = PDCAP_D0_SUPPORTED | PDCAP_D3_SUPPORTED; -/* - if (DeviceCapabilities.DeviceD1) - PowerData->PD_Capabilities |= PDCAP_D1_SUPPORTED; - if (DeviceCapabilities.DeviceD2) - PowerData->PD_Capabilities |= PDCAP_D2_SUPPORTED; - if (DeviceCapabilities.WakeFromD0) - PowerData->PD_Capabilities |= PDCAP_WAKE_FROM_D0_SUPPORTED; - if (DeviceCapabilities.WakeFromD1) - PowerData->PD_Capabilities |= PDCAP_WAKE_FROM_D1_SUPPORTED; - if (DeviceCapabilities.WakeFromD2) - PowerData->PD_Capabilities |= PDCAP_WAKE_FROM_D2_SUPPORTED; - if (DeviceCapabilities.WakeFromD3) - PowerData->PD_Capabilities |= PDCAP_WAKE_FROM_D3_SUPPORTED; - if (DeviceCapabilities.WarmEjectSupported) - PowerData->PD_Capabilities |= PDCAP_WARM_EJECT_SUPPORTED; - PowerData->PD_D1Latency = DeviceCapabilities.D1Latency; - PowerData->PD_D2Latency = DeviceCapabilities.D2Latency; - PowerData->PD_D3Latency = DeviceCapabilities.D3Latency; - RtlCopyMemory(&PowerData->PD_PowerStateMapping, - &DeviceCapabilities.DeviceState, - sizeof(DeviceCapabilities.DeviceState)); - PowerData->PD_DeepestSystemWake = DeviceCapabilities.SystemWake; -*/ + + RtlZeroMemory(&DeviceCapabilities, sizeof(DEVICE_CAPABILITIES)); + DeviceCapabilities.Size = sizeof(DEVICE_CAPABILITIES); + DeviceCapabilities.Version = 1; + DeviceCapabilities.Address = -1; + DeviceCapabilities.UINumber = -1; + + Stack.Parameters.DeviceCapabilities.Capabilities = &DeviceCapabilities; + + Status = IopInitiatePnpIrp(DeviceObject, + &IoStatusBlock, + IRP_MN_QUERY_CAPABILITIES, + &Stack); + if (NT_SUCCESS(Status)) + { + DPRINT("Got device capabiliities\n"); + + PowerData->PD_MostRecentPowerState = PowerDeviceD0; // FIXME + if (DeviceCapabilities.DeviceD1) + PowerData->PD_Capabilities |= PDCAP_D1_SUPPORTED; + if (DeviceCapabilities.DeviceD2) + PowerData->PD_Capabilities |= PDCAP_D2_SUPPORTED; + if (DeviceCapabilities.WakeFromD0) + PowerData->PD_Capabilities |= PDCAP_WAKE_FROM_D0_SUPPORTED; + if (DeviceCapabilities.WakeFromD1) + PowerData->PD_Capabilities |= PDCAP_WAKE_FROM_D1_SUPPORTED; + if (DeviceCapabilities.WakeFromD2) + PowerData->PD_Capabilities |= PDCAP_WAKE_FROM_D2_SUPPORTED; + if (DeviceCapabilities.WakeFromD3) + PowerData->PD_Capabilities |= PDCAP_WAKE_FROM_D3_SUPPORTED; + if (DeviceCapabilities.WarmEjectSupported) + PowerData->PD_Capabilities |= PDCAP_WARM_EJECT_SUPPORTED; + PowerData->PD_D1Latency = DeviceCapabilities.D1Latency; + PowerData->PD_D2Latency = DeviceCapabilities.D2Latency; + PowerData->PD_D3Latency = DeviceCapabilities.D3Latency; + RtlCopyMemory(&PowerData->PD_PowerStateMapping, + &DeviceCapabilities.DeviceState, + sizeof(DeviceCapabilities.DeviceState)); + PowerData->PD_DeepestSystemWake = DeviceCapabilities.SystemWake; + } + else + { + DPRINT("IRP_MN_QUERY_CAPABILITIES failed (Status 0x%08lx)\n", Status); + + PowerData->PD_Capabilities = PDCAP_D0_SUPPORTED | PDCAP_D3_SUPPORTED; + PowerData->PD_MostRecentPowerState = PowerDeviceD0; + } } } else if (Property == PNP_PROPERTY_REMOVAL_POLICY_OVERRIDE)
6 years
1
0
0
0
[reactos] 03/03: [FREELDR] Add FreeLdr debug tool GUI program, and FreeLdr command-line installer to the bootcd.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dd11f4c34b66a6fe82291…
commit dd11f4c34b66a6fe8229127d03e01f33024e1b4b Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Dec 9 00:04:37 2018 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Mon Dec 10 00:27:58 2018 +0100 [FREELDR] Add FreeLdr debug tool GUI program, and FreeLdr command-line installer to the bootcd. --- boot/freeldr/fdebug/CMakeLists.txt | 1 + boot/freeldr/install/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/boot/freeldr/fdebug/CMakeLists.txt b/boot/freeldr/fdebug/CMakeLists.txt index 6fed62842f..61d94d8b78 100644 --- a/boot/freeldr/fdebug/CMakeLists.txt +++ b/boot/freeldr/fdebug/CMakeLists.txt @@ -2,3 +2,4 @@ add_executable(fdebug fdebug.c rs232.c fdebug.rc) set_module_type(fdebug win32gui UNICODE) add_importlibs(fdebug comdlg32 user32 gdi32 msvcrt kernel32) +add_cd_file(TARGET fdebug DESTINATION loader NO_CAB FOR bootcd) diff --git a/boot/freeldr/install/CMakeLists.txt b/boot/freeldr/install/CMakeLists.txt index d495a180fe..ed106f2a97 100644 --- a/boot/freeldr/install/CMakeLists.txt +++ b/boot/freeldr/install/CMakeLists.txt @@ -21,3 +21,4 @@ add_executable(installfreeldr EXCLUDE_FROM_ALL set_module_type(installfreeldr win32cui) add_importlibs(installfreeldr msvcrt kernel32) +add_cd_file(TARGET installfreeldr DESTINATION loader NO_CAB FOR bootcd)
6 years
1
0
0
0
[reactos] 02/03: [SETUPLIB] Use for-loops instead of while-loops to enumerate linked lists in the partition code.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8bed4adf56eb0d14e0c5e…
commit 8bed4adf56eb0d14e0c5e16d7e717ddc4ad3003c Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sun Dec 9 00:36:56 2018 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Mon Dec 10 00:27:58 2018 +0100 [SETUPLIB] Use for-loops instead of while-loops to enumerate linked lists in the partition code. --- base/setup/lib/utils/partlist.c | 242 ++++++++++++++++++---------------------- 1 file changed, 107 insertions(+), 135 deletions(-) diff --git a/base/setup/lib/utils/partlist.c b/base/setup/lib/utils/partlist.c index fc47c6376d..e0f16aa7a9 100644 --- a/base/setup/lib/utils/partlist.c +++ b/base/setup/lib/utils/partlist.c @@ -324,13 +324,15 @@ AssignDriveLetters( Letter = L'C'; /* Assign drive letters to primary partitions */ - Entry1 = List->DiskListHead.Flink; - while (Entry1 != &List->DiskListHead) + for (Entry1 = List->DiskListHead.Flink; + Entry1 != &List->DiskListHead; + Entry1 = Entry1->Flink) { DiskEntry = CONTAINING_RECORD(Entry1, DISKENTRY, ListEntry); - Entry2 = DiskEntry->PrimaryPartListHead.Flink; - while (Entry2 != &DiskEntry->PrimaryPartListHead) + for (Entry2 = DiskEntry->PrimaryPartListHead.Flink; + Entry2 != &DiskEntry->PrimaryPartListHead; + Entry2 = Entry2->Flink) { PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry); @@ -350,21 +352,19 @@ AssignDriveLetters( } } } - - Entry2 = Entry2->Flink; } - - Entry1 = Entry1->Flink; } /* Assign drive letters to logical drives */ - Entry1 = List->DiskListHead.Flink; - while (Entry1 != &List->DiskListHead) + for (Entry1 = List->DiskListHead.Flink; + Entry1 != &List->DiskListHead; + Entry1 = Entry1->Flink) { DiskEntry = CONTAINING_RECORD(Entry1, DISKENTRY, ListEntry); - Entry2 = DiskEntry->LogicalPartListHead.Flink; - while (Entry2 != &DiskEntry->LogicalPartListHead) + for (Entry2 = DiskEntry->LogicalPartListHead.Flink; + Entry2 != &DiskEntry->LogicalPartListHead; + Entry2 = Entry2->Flink) { PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry); @@ -383,11 +383,7 @@ AssignDriveLetters( } } } - - Entry2 = Entry2->Flink; } - - Entry1 = Entry1->Flink; } } @@ -1018,8 +1014,9 @@ ScanForUnpartitionedDiskSpace( LastSectorCount = 0ULL; LastUnusedSectorCount = 0ULL; - Entry = DiskEntry->PrimaryPartListHead.Flink; - while (Entry != &DiskEntry->PrimaryPartListHead) + for (Entry = DiskEntry->PrimaryPartListHead.Flink; + Entry != &DiskEntry->PrimaryPartListHead; + Entry = Entry->Flink) { PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry); @@ -1053,8 +1050,6 @@ ScanForUnpartitionedDiskSpace( LastStartSector = PartEntry->StartSector.QuadPart; LastSectorCount = PartEntry->SectorCount.QuadPart; } - - Entry = Entry->Flink; } /* Check for trailing unpartitioned disk space */ @@ -1114,8 +1109,9 @@ ScanForUnpartitionedDiskSpace( LastSectorCount = 0ULL; LastUnusedSectorCount = 0ULL; - Entry = DiskEntry->LogicalPartListHead.Flink; - while (Entry != &DiskEntry->LogicalPartListHead) + for (Entry = DiskEntry->LogicalPartListHead.Flink; + Entry != &DiskEntry->LogicalPartListHead; + Entry = Entry->Flink) { PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry); @@ -1150,8 +1146,6 @@ ScanForUnpartitionedDiskSpace( LastStartSector = PartEntry->StartSector.QuadPart; LastSectorCount = PartEntry->SectorCount.QuadPart; } - - Entry = Entry->Flink; } /* Check for trailing unpartitioned disk space */ @@ -1221,16 +1215,15 @@ SetDiskSignature( * Check also signatures from disks, which are * not visible (bootable) by the bios. */ - Entry2 = List->DiskListHead.Flink; - while (Entry2 != &List->DiskListHead) + for (Entry2 = List->DiskListHead.Flink; + Entry2 != &List->DiskListHead; + Entry2 = Entry2->Flink) { DiskEntry2 = CONTAINING_RECORD(Entry2, DISKENTRY, ListEntry); if (DiskEntry != DiskEntry2 && DiskEntry->LayoutBuffer->Signature == DiskEntry2->LayoutBuffer->Signature) break; - - Entry2 = Entry2->Flink; } if (Entry2 == &List->DiskListHead) @@ -1247,8 +1240,9 @@ UpdateDiskSignatures( PDISKENTRY DiskEntry; /* Print partition lines */ - Entry = List->DiskListHead.Flink; - while (Entry != &List->DiskListHead) + for (Entry = List->DiskListHead.Flink; + Entry != &List->DiskListHead; + Entry = Entry->Flink) { DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry); @@ -1258,8 +1252,6 @@ UpdateDiskSignatures( SetDiskSignature(List, DiskEntry); DiskEntry->LayoutBuffer->PartitionEntry[0].RewritePartition = TRUE; } - - Entry = Entry->Flink; } } @@ -1395,8 +1387,9 @@ AddDiskToList( RtlFreeHeap(ProcessHeap, 0, Mbr); - ListEntry = List->BiosDiskListHead.Flink; - while (ListEntry != &List->BiosDiskListHead) + for (ListEntry = List->BiosDiskListHead.Flink; + ListEntry != &List->BiosDiskListHead; + ListEntry = ListEntry->Flink) { BiosDiskEntry = CONTAINING_RECORD(ListEntry, BIOSDISKENTRY, ListEntry); /* FIXME: @@ -1420,7 +1413,6 @@ AddDiskToList( // FIXME: What to do? } } - ListEntry = ListEntry->Flink; } if (!DiskEntry->BiosFound) @@ -1761,11 +1753,11 @@ GetDiskByBiosNumber( PLIST_ENTRY Entry; /* Loop over the disks and find the correct one */ - Entry = List->DiskListHead.Flink; - while (Entry != &List->DiskListHead) + for (Entry = List->DiskListHead.Flink; + Entry != &List->DiskListHead; + Entry = Entry->Flink) { DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry); - Entry = Entry->Flink; if (DiskEntry->BiosDiskNumber == BiosDiskNumber) { @@ -1787,11 +1779,11 @@ GetDiskByNumber( PLIST_ENTRY Entry; /* Loop over the disks and find the correct one */ - Entry = List->DiskListHead.Flink; - while (Entry != &List->DiskListHead) + for (Entry = List->DiskListHead.Flink; + Entry != &List->DiskListHead; + Entry = Entry->Flink) { DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry); - Entry = Entry->Flink; if (DiskEntry->DiskNumber == DiskNumber) { @@ -1815,11 +1807,11 @@ GetDiskBySCSI( PLIST_ENTRY Entry; /* Loop over the disks and find the correct one */ - Entry = List->DiskListHead.Flink; - while (Entry != &List->DiskListHead) + for (Entry = List->DiskListHead.Flink; + Entry != &List->DiskListHead; + Entry = Entry->Flink) { DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry); - Entry = Entry->Flink; if (DiskEntry->Port == Port && DiskEntry->Bus == Bus && @@ -1843,11 +1835,11 @@ GetDiskBySignature( PLIST_ENTRY Entry; /* Loop over the disks and find the correct one */ - Entry = List->DiskListHead.Flink; - while (Entry != &List->DiskListHead) + for (Entry = List->DiskListHead.Flink; + Entry != &List->DiskListHead; + Entry = Entry->Flink) { DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry); - Entry = Entry->Flink; if (DiskEntry->LayoutBuffer->Signature == Signature) { @@ -1870,11 +1862,11 @@ GetPartition( PLIST_ENTRY Entry; /* Disk found, loop over the primary partitions first... */ - Entry = DiskEntry->PrimaryPartListHead.Flink; - while (Entry != &DiskEntry->PrimaryPartListHead) + for (Entry = DiskEntry->PrimaryPartListHead.Flink; + Entry != &DiskEntry->PrimaryPartListHead; + Entry = Entry->Flink) { PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry); - Entry = Entry->Flink; if (PartEntry->PartitionNumber == PartitionNumber) { @@ -1884,11 +1876,11 @@ GetPartition( } /* ... then over the logical partitions if needed */ - Entry = DiskEntry->LogicalPartListHead.Flink; - while (Entry != &DiskEntry->LogicalPartListHead) + for (Entry = DiskEntry->LogicalPartListHead.Flink; + Entry != &DiskEntry->LogicalPartListHead; + Entry = Entry->Flink) { PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry); - Entry = Entry->Flink; if (PartEntry->PartitionNumber == PartitionNumber) { @@ -2035,8 +2027,9 @@ GetNextPartition( } /* Search for the first partition entry on the next disk */ - DiskListEntry = List->CurrentDisk->ListEntry.Flink; - while (DiskListEntry != &List->DiskListHead) + for (DiskListEntry = List->CurrentDisk->ListEntry.Flink; + DiskListEntry != &List->DiskListHead; + DiskListEntry = DiskListEntry->Flink) { DiskEntry = CONTAINING_RECORD(DiskListEntry, DISKENTRY, ListEntry); @@ -2049,8 +2042,6 @@ GetNextPartition( List->CurrentPartition = PartEntry; return List->CurrentPartition; } - - DiskListEntry = DiskListEntry->Flink; } return NULL; @@ -2113,8 +2104,9 @@ GetPrevPartition( } /* Search for the last partition entry on the previous disk */ - DiskListEntry = List->CurrentDisk->ListEntry.Blink; - while (DiskListEntry != &List->DiskListHead) + for (DiskListEntry = List->CurrentDisk->ListEntry.Blink; + DiskListEntry != &List->DiskListHead; + DiskListEntry = DiskListEntry->Blink) { DiskEntry = CONTAINING_RECORD(DiskListEntry, DISKENTRY, ListEntry); @@ -2143,8 +2135,6 @@ GetPrevPartition( return List->CurrentPartition; } } - - DiskListEntry = DiskListEntry->Blink; } return NULL; @@ -2192,14 +2182,13 @@ GetPrimaryPartitionCount( PPARTENTRY PartEntry; ULONG Count = 0; - Entry = DiskEntry->PrimaryPartListHead.Flink; - while (Entry != &DiskEntry->PrimaryPartListHead) + for (Entry = DiskEntry->PrimaryPartListHead.Flink; + Entry != &DiskEntry->PrimaryPartListHead; + Entry = Entry->Flink) { PartEntry = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry); if (PartEntry->IsPartitioned) Count++; - - Entry = Entry->Flink; } return Count; @@ -2214,14 +2203,13 @@ GetLogicalPartitionCount( PPARTENTRY PartEntry; ULONG Count = 0; - ListEntry = DiskEntry->LogicalPartListHead.Flink; - while (ListEntry != &DiskEntry->LogicalPartListHead) + for (ListEntry = DiskEntry->LogicalPartListHead.Flink; + ListEntry != &DiskEntry->LogicalPartListHead; + ListEntry = ListEntry->Flink) { PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry); if (PartEntry->IsPartitioned) Count++; - - ListEntry = ListEntry->Flink; } return Count; @@ -2303,8 +2291,9 @@ UpdateDiskLayout( /* Update the primary partition table */ Index = 0; - ListEntry = DiskEntry->PrimaryPartListHead.Flink; - while (ListEntry != &DiskEntry->PrimaryPartListHead) + for (ListEntry = DiskEntry->PrimaryPartListHead.Flink; + ListEntry != &DiskEntry->PrimaryPartListHead; + ListEntry = ListEntry->Flink) { PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry); @@ -2338,16 +2327,15 @@ UpdateDiskLayout( Index++; } - - ListEntry = ListEntry->Flink; } ASSERT(Index <= 4); /* Update the logical partition table */ Index = 4; - ListEntry = DiskEntry->LogicalPartListHead.Flink; - while (ListEntry != &DiskEntry->LogicalPartListHead) + for (ListEntry = DiskEntry->LogicalPartListHead.Flink; + ListEntry != &DiskEntry->LogicalPartListHead; + ListEntry = ListEntry->Flink) { PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry); @@ -2393,8 +2381,6 @@ UpdateDiskLayout( PartitionNumber++; Index += 4; } - - ListEntry = ListEntry->Flink; } /* Wipe unused primary partition entries */ @@ -2989,10 +2975,11 @@ CheckActiveSystemPartition( * The disk is not new, check if any partition is initialized; * if not, the first one becomes the system partition. */ - ListEntry = DiskEntry->PrimaryPartListHead.Flink; - while (ListEntry != &DiskEntry->PrimaryPartListHead) + for (ListEntry = DiskEntry->PrimaryPartListHead.Flink; + ListEntry != &DiskEntry->PrimaryPartListHead; + ListEntry = ListEntry->Flink) { - /* Retrieve the partition and go to the next one */ + /* Retrieve the partition */ PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry); @@ -3002,9 +2989,6 @@ CheckActiveSystemPartition( { break; } - - /* Go to the next one */ - ListEntry = ListEntry->Flink; } if (ListEntry == &DiskEntry->PrimaryPartListHead) { @@ -3029,14 +3013,14 @@ CheckActiveSystemPartition( DPRINT1("We are here (3)!\n"); /* The disk is not new, scan all partitions to find the (active) system partition */ - ListEntry = DiskEntry->PrimaryPartListHead.Flink; - while (ListEntry != &DiskEntry->PrimaryPartListHead) + for (ListEntry = DiskEntry->PrimaryPartListHead.Flink; + ListEntry != &DiskEntry->PrimaryPartListHead; + ListEntry = ListEntry->Flink) { - /* Retrieve the partition and go to the next one */ + /* Retrieve the partition */ PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry); - ListEntry = ListEntry->Flink; /* Check if the partition is partitioned and used */ if (PartEntry->IsPartitioned && @@ -3235,8 +3219,9 @@ WritePartitions( /* Update the partition numbers */ /* Update the primary partition table */ - ListEntry = DiskEntry->PrimaryPartListHead.Flink; - while (ListEntry != &DiskEntry->PrimaryPartListHead) + for (ListEntry = DiskEntry->PrimaryPartListHead.Flink; + ListEntry != &DiskEntry->PrimaryPartListHead; + ListEntry = ListEntry->Flink) { PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry); @@ -3245,13 +3230,12 @@ WritePartitions( PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex]; PartEntry->PartitionNumber = PartitionInfo->PartitionNumber; } - - ListEntry = ListEntry->Flink; } /* Update the logical partition table */ - ListEntry = DiskEntry->LogicalPartListHead.Flink; - while (ListEntry != &DiskEntry->LogicalPartListHead) + for (ListEntry = DiskEntry->LogicalPartListHead.Flink; + ListEntry != &DiskEntry->LogicalPartListHead; + ListEntry = ListEntry->Flink) { PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry); @@ -3260,8 +3244,6 @@ WritePartitions( PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex]; PartEntry->PartitionNumber = PartitionInfo->PartitionNumber; } - - ListEntry = ListEntry->Flink; } // @@ -3289,8 +3271,9 @@ WritePartitionsToDisk( if (List == NULL) return TRUE; - Entry = List->DiskListHead.Flink; - while (Entry != &List->DiskListHead) + for (Entry = List->DiskListHead.Flink; + Entry != &List->DiskListHead; + Entry = Entry->Flink) { DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry); @@ -3299,8 +3282,6 @@ WritePartitionsToDisk( WritePartitions(List, DiskEntry); DiskEntry->Dirty = FALSE; } - - Entry = Entry->Flink; } return TRUE; @@ -3380,15 +3361,17 @@ SetMountedDeviceValues( if (List == NULL) return FALSE; - Entry1 = List->DiskListHead.Flink; - while (Entry1 != &List->DiskListHead) + for (Entry1 = List->DiskListHead.Flink; + Entry1 != &List->DiskListHead; + Entry1 = Entry1->Flink) { DiskEntry = CONTAINING_RECORD(Entry1, DISKENTRY, ListEntry); - Entry2 = DiskEntry->PrimaryPartListHead.Flink; - while (Entry2 != &DiskEntry->PrimaryPartListHead) + for (Entry2 = DiskEntry->PrimaryPartListHead.Flink; + Entry2 != &DiskEntry->PrimaryPartListHead; + Entry2 = Entry2->Flink) { PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry); if (PartEntry->IsPartitioned) @@ -3405,12 +3388,11 @@ SetMountedDeviceValues( } } } - - Entry2 = Entry2->Flink; } - Entry2 = DiskEntry->LogicalPartListHead.Flink; - while (Entry2 != &DiskEntry->LogicalPartListHead) + for (Entry2 = DiskEntry->LogicalPartListHead.Flink; + Entry2 != &DiskEntry->LogicalPartListHead; + Entry2 = Entry2->Flink) { PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry); if (PartEntry->IsPartitioned) @@ -3427,11 +3409,7 @@ SetMountedDeviceValues( } } } - - Entry2 = Entry2->Flink; } - - Entry1 = Entry1->Flink; } return TRUE; @@ -3525,15 +3503,17 @@ GetNextUnformattedPartition( PDISKENTRY DiskEntry; PPARTENTRY PartEntry; - Entry1 = List->DiskListHead.Flink; - while (Entry1 != &List->DiskListHead) + for (Entry1 = List->DiskListHead.Flink; + Entry1 != &List->DiskListHead; + Entry1 = Entry1->Flink) { DiskEntry = CONTAINING_RECORD(Entry1, DISKENTRY, ListEntry); - Entry2 = DiskEntry->PrimaryPartListHead.Flink; - while (Entry2 != &DiskEntry->PrimaryPartListHead) + for (Entry2 = DiskEntry->PrimaryPartListHead.Flink; + Entry2 != &DiskEntry->PrimaryPartListHead; + Entry2 = Entry2->Flink) { PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry); if (PartEntry->IsPartitioned && PartEntry->New) @@ -3543,12 +3523,11 @@ GetNextUnformattedPartition( *pPartEntry = PartEntry; return TRUE; } - - Entry2 = Entry2->Flink; } - Entry2 = DiskEntry->LogicalPartListHead.Flink; - while (Entry2 != &DiskEntry->LogicalPartListHead) + for (Entry2 = DiskEntry->LogicalPartListHead.Flink; + Entry2 != &DiskEntry->LogicalPartListHead; + Entry2 = Entry2->Flink) { PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry); if (PartEntry->IsPartitioned && PartEntry->New) @@ -3558,11 +3537,7 @@ GetNextUnformattedPartition( *pPartEntry = PartEntry; return TRUE; } - - Entry2 = Entry2->Flink; } - - Entry1 = Entry1->Flink; } if (pDiskEntry) *pDiskEntry = NULL; @@ -3581,15 +3556,17 @@ GetNextUncheckedPartition( PDISKENTRY DiskEntry; PPARTENTRY PartEntry; - Entry1 = List->DiskListHead.Flink; - while (Entry1 != &List->DiskListHead) + for (Entry1 = List->DiskListHead.Flink; + Entry1 != &List->DiskListHead; + Entry1 = Entry1->Flink) { DiskEntry = CONTAINING_RECORD(Entry1, DISKENTRY, ListEntry); - Entry2 = DiskEntry->PrimaryPartListHead.Flink; - while (Entry2 != &DiskEntry->PrimaryPartListHead) + for (Entry2 = DiskEntry->PrimaryPartListHead.Flink; + Entry2 != &DiskEntry->PrimaryPartListHead; + Entry2 = Entry2->Flink) { PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry); if (PartEntry->NeedsCheck == TRUE) @@ -3599,12 +3576,11 @@ GetNextUncheckedPartition( *pPartEntry = PartEntry; return TRUE; } - - Entry2 = Entry2->Flink; } - Entry2 = DiskEntry->LogicalPartListHead.Flink; - while (Entry2 != &DiskEntry->LogicalPartListHead) + for (Entry2 = DiskEntry->LogicalPartListHead.Flink; + Entry2 != &DiskEntry->LogicalPartListHead; + Entry2 = Entry2->Flink) { PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry); if (PartEntry->NeedsCheck == TRUE) @@ -3614,11 +3590,7 @@ GetNextUncheckedPartition( *pPartEntry = PartEntry; return TRUE; } - - Entry2 = Entry2->Flink; } - - Entry1 = Entry1->Flink; } if (pDiskEntry) *pDiskEntry = NULL;
6 years
1
0
0
0
[reactos] 01/03: [SETUPLIB] Partitioning code fixes and improvements.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7df92966921e4501d5a24…
commit 7df92966921e4501d5a24c0ca37078d6ec1b5057 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Thu Nov 22 03:26:47 2018 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Mon Dec 10 00:27:56 2018 +0100 [SETUPLIB] Partitioning code fixes and improvements. CORE-7749 - Correctly insert discovered partitions in sorted order of StartSector, and verify that they do not overlap (-> check for broken partitioning). May help for CORE-10898. - Use the correct reported partition numbers that may be modified after partitioning changes, and that need to be used when opening \Device\Harddisk'M'\Partition'N' files. This is achieving by retrieving the returned value of the IOCTL_DISK_SET_DRIVE_LAYOUT call. Distinguish them from the "on-disk" partition numbers that are the ones that enumerate the partition in partition-table order (and is the order known by e.g. the BIOS), and that should be used to construct the destination ARC path. May help for CORE-4870, CORE-13205. - Simplify a lot of duplicated code by using helper functions. --- base/setup/lib/setuplib.c | 2 +- base/setup/lib/utils/partlist.c | 776 +++++++++++++++++++++------------------- base/setup/lib/utils/partlist.h | 17 +- 3 files changed, 413 insertions(+), 382 deletions(-) diff --git a/base/setup/lib/setuplib.c b/base/setup/lib/setuplib.c index c63c5dfb87..1bbdaa8f3e 100644 --- a/base/setup/lib/setuplib.c +++ b/base/setup/lib/setuplib.c @@ -642,7 +642,7 @@ InitDestinationPaths( RtlStringCchPrintfW(PathBuffer, ARRAYSIZE(PathBuffer), L"multi(0)disk(0)rdisk(%lu)partition(%lu)\\", DiskEntry->BiosDiskNumber, - PartEntry->PartitionNumber); + PartEntry->OnDiskPartitionNumber); ConcatPaths(PathBuffer, ARRAYSIZE(PathBuffer), 1, InstallationDir); RtlCreateUnicodeString(&pSetupData->DestinationArcPath, PathBuffer); diff --git a/base/setup/lib/utils/partlist.c b/base/setup/lib/utils/partlist.c index 89178ae014..fc47c6376d 100644 --- a/base/setup/lib/utils/partlist.c +++ b/base/setup/lib/utils/partlist.c @@ -664,6 +664,187 @@ EnumerateBiosDiskEntries( #undef ROOT_NAME } + + +/* + * Inserts the disk region represented by PartEntry into either the primary + * or the logical partition list of the given disk. + * The lists are kept sorted by increasing order of start sectors. + * Of course no disk region should overlap at all with one another. + */ +static +VOID +InsertDiskRegion( + IN PDISKENTRY DiskEntry, + IN PPARTENTRY PartEntry, + IN BOOLEAN LogicalPartition) +{ + PLIST_ENTRY List; + PLIST_ENTRY Entry; + PPARTENTRY PartEntry2; + + /* Use the correct partition list */ + if (LogicalPartition) + List = &DiskEntry->LogicalPartListHead; + else + List = &DiskEntry->PrimaryPartListHead; + + /* Find the first disk region before which we need to insert the new one */ + for (Entry = List->Flink; Entry != List; Entry = Entry->Flink) + { + PartEntry2 = CONTAINING_RECORD(Entry, PARTENTRY, ListEntry); + + /* Ignore any unused empty region */ + if ((PartEntry2->PartitionType == PARTITION_ENTRY_UNUSED && + PartEntry2->StartSector.QuadPart == 0) || PartEntry2->SectorCount.QuadPart == 0) + { + continue; + } + + /* If the current region ends before the one to be inserted, try again */ + if (PartEntry2->StartSector.QuadPart + PartEntry2->SectorCount.QuadPart - 1 < PartEntry->StartSector.QuadPart) + continue; + + /* + * One of the disk region boundaries crosses the desired region + * (it starts after the desired region, or ends before the end + * of the desired region): this is an impossible situation because + * disk regions (partitions) cannot overlap! + * Throw an error and bail out. + */ + if (max(PartEntry->StartSector.QuadPart, PartEntry2->StartSector.QuadPart) + <= + min( PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1, + PartEntry2->StartSector.QuadPart + PartEntry2->SectorCount.QuadPart - 1)) + { + DPRINT1("Disk region overlap problem, stopping there!\n" + "Partition to be inserted:\n" + " StartSector = %I64u ; EndSector = %I64u\n" + "Existing disk region:\n" + " StartSector = %I64u ; EndSector = %I64u\n", + PartEntry->StartSector.QuadPart, + PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1, + PartEntry2->StartSector.QuadPart, + PartEntry2->StartSector.QuadPart + PartEntry2->SectorCount.QuadPart - 1); + return; + } + + /* We have found the first region before which the new one has to be inserted */ + break; + } + + /* Insert the disk region */ + InsertTailList(Entry, &PartEntry->ListEntry); +} + +static +PPARTENTRY +CreateInsertBlankRegion( + IN PDISKENTRY DiskEntry, + IN OUT PLIST_ENTRY ListHead, + IN ULONGLONG StartSector, + IN ULONGLONG SectorCount, + IN BOOLEAN LogicalSpace) +{ + PPARTENTRY NewPartEntry; + + NewPartEntry = RtlAllocateHeap(ProcessHeap, + HEAP_ZERO_MEMORY, + sizeof(PARTENTRY)); + if (NewPartEntry == NULL) + return NULL; + + NewPartEntry->DiskEntry = DiskEntry; + + NewPartEntry->IsPartitioned = FALSE; + NewPartEntry->FormatState = Unformatted; + NewPartEntry->FileSystem = NULL; + + NewPartEntry->StartSector.QuadPart = StartSector; + NewPartEntry->SectorCount.QuadPart = SectorCount; + + DPRINT1("First Sector : %I64u\n", NewPartEntry->StartSector.QuadPart); + DPRINT1("Last Sector : %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1); + DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart); + + /* Insert the table into the list */ + InsertTailList(ListHead, &NewPartEntry->ListEntry); + + return NewPartEntry; +} + +static +// BOOLEAN +PPARTENTRY +InitializePartitionEntry( + IN PDISKENTRY DiskEntry, + IN PPARTENTRY PartEntry, + IN ULONGLONG SectorCount, + IN BOOLEAN AutoCreate) +{ + PPARTENTRY NewPartEntry; + + DPRINT1("Current partition sector count: %I64u\n", PartEntry->SectorCount.QuadPart); + + if ((AutoCreate != FALSE) || + (AlignDown(PartEntry->StartSector.QuadPart + SectorCount, DiskEntry->SectorAlignment) - + PartEntry->StartSector.QuadPart == PartEntry->SectorCount.QuadPart)) + { + DPRINT1("Convert existing partition entry\n"); + + /* Convert current entry to 'new (unformatted)' */ + PartEntry->IsPartitioned = TRUE; + PartEntry->New = TRUE; + PartEntry->PartitionType = PARTITION_ENTRY_UNUSED; + PartEntry->FormatState = Unformatted; + PartEntry->FileSystem = NULL; + PartEntry->AutoCreate = AutoCreate; + PartEntry->BootIndicator = FALSE; + PartEntry->LogicalPartition = FALSE; + + NewPartEntry = PartEntry; + } + else + { + DPRINT1("Add new partition entry\n"); + + /* Insert and initialize a new partition entry */ + NewPartEntry = RtlAllocateHeap(ProcessHeap, + HEAP_ZERO_MEMORY, + sizeof(PARTENTRY)); + if (NewPartEntry == NULL) + return NULL; + + /* Insert the new entry into the list */ + InsertTailList(&PartEntry->ListEntry, + &NewPartEntry->ListEntry); + + NewPartEntry->DiskEntry = DiskEntry; + + NewPartEntry->IsPartitioned = TRUE; + NewPartEntry->New = TRUE; + NewPartEntry->PartitionType = PARTITION_ENTRY_UNUSED; + NewPartEntry->FormatState = Unformatted; + NewPartEntry->FileSystem = NULL; + NewPartEntry->BootIndicator = FALSE; + NewPartEntry->LogicalPartition = FALSE; + + NewPartEntry->StartSector.QuadPart = PartEntry->StartSector.QuadPart; + NewPartEntry->SectorCount.QuadPart = AlignDown(NewPartEntry->StartSector.QuadPart + SectorCount, DiskEntry->SectorAlignment) - + NewPartEntry->StartSector.QuadPart; + + PartEntry->StartSector.QuadPart = NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart; + PartEntry->SectorCount.QuadPart -= (PartEntry->StartSector.QuadPart - NewPartEntry->StartSector.QuadPart); + } + + DPRINT1("First Sector : %I64u\n", NewPartEntry->StartSector.QuadPart); + DPRINT1("Last Sector : %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1); + DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart); + + return NewPartEntry; +} + + static VOID AddPartitionToDisk( @@ -708,6 +889,7 @@ AddPartitionToDisk( PartEntry->LogicalPartition = LogicalPartition; PartEntry->IsPartitioned = TRUE; + PartEntry->OnDiskPartitionNumber = PartitionInfo->PartitionNumber; PartEntry->PartitionNumber = PartitionInfo->PartitionNumber; PartEntry->PartitionIndex = PartitionIndex; @@ -721,6 +903,8 @@ AddPartitionToDisk( } else if (IsRecognizedPartition(PartEntry->PartitionType)) { + ASSERT(PartitionInfo->RecognizedPartition); + PartEntry->FileSystem = GetFileSystem(PartEntry); if (PartEntry->FileSystem) PartEntry->FormatState = Preformatted; @@ -740,7 +924,8 @@ AddPartitionToDisk( /* Open the volume, ignore any errors */ RtlStringCchPrintfW(Buffer, ARRAYSIZE(Buffer), L"\\Device\\Harddisk%lu\\Partition%lu", - DiskEntry->DiskNumber, PartEntry->PartitionNumber); + DiskEntry->DiskNumber, + PartEntry->PartitionNumber); RtlInitUnicodeString(&Name, Buffer); InitializeObjectAttributes(&ObjectAttributes, @@ -783,12 +968,7 @@ AddPartitionToDisk( DPRINT1("NtOpenFile() failed, Status 0x%08lx\n", Status); } - if (LogicalPartition) - InsertTailList(&DiskEntry->LogicalPartListHead, - &PartEntry->ListEntry); - else - InsertTailList(&DiskEntry->PrimaryPartListHead, - &PartEntry->ListEntry); + InsertDiskRegion(DiskEntry, PartEntry, LogicalPartition); } static @@ -796,6 +976,8 @@ VOID ScanForUnpartitionedDiskSpace( IN PDISKENTRY DiskEntry) { + ULONGLONG StartSector; + ULONGLONG SectorCount; ULONGLONG LastStartSector; ULONGLONG LastSectorCount; ULONGLONG LastUnusedSectorCount; @@ -810,31 +992,20 @@ ScanForUnpartitionedDiskSpace( DPRINT1("No primary partition!\n"); /* Create a partition entry that represents the empty disk */ - NewPartEntry = RtlAllocateHeap(ProcessHeap, - HEAP_ZERO_MEMORY, - sizeof(PARTENTRY)); - if (NewPartEntry == NULL) - return; - - NewPartEntry->DiskEntry = DiskEntry; - NewPartEntry->IsPartitioned = FALSE; if (DiskEntry->SectorAlignment < 2048) - NewPartEntry->StartSector.QuadPart = 2048ULL; + StartSector = 2048ULL; else - NewPartEntry->StartSector.QuadPart = (ULONGLONG)DiskEntry->SectorAlignment; - NewPartEntry->SectorCount.QuadPart = AlignDown(DiskEntry->SectorCount.QuadPart, DiskEntry->SectorAlignment) - - NewPartEntry->StartSector.QuadPart; - - DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart); - DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1); - DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart); - - NewPartEntry->FormatState = Unformatted; - NewPartEntry->FileSystem = NULL; - - InsertTailList(&DiskEntry->PrimaryPartListHead, - &NewPartEntry->ListEntry); + StartSector = (ULONGLONG)DiskEntry->SectorAlignment; + SectorCount = AlignDown(DiskEntry->SectorCount.QuadPart, DiskEntry->SectorAlignment) - StartSector; + + NewPartEntry = CreateInsertBlankRegion(DiskEntry, + &DiskEntry->PrimaryPartListHead, + StartSector, + SectorCount, + FALSE); + if (NewPartEntry == NULL) + DPRINT1("Failed to create a new empty region for full disk space!\n"); return; } @@ -843,7 +1014,7 @@ ScanForUnpartitionedDiskSpace( if (DiskEntry->SectorAlignment < 2048) LastStartSector = 2048ULL; else - LastStartSector = DiskEntry->SectorAlignment; + LastStartSector = (ULONGLONG)DiskEntry->SectorAlignment; LastSectorCount = 0ULL; LastUnusedSectorCount = 0ULL; @@ -863,29 +1034,20 @@ ScanForUnpartitionedDiskSpace( { DPRINT("Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount); - NewPartEntry = RtlAllocateHeap(ProcessHeap, - HEAP_ZERO_MEMORY, - sizeof(PARTENTRY)); - if (NewPartEntry == NULL) - return; - - NewPartEntry->DiskEntry = DiskEntry; - - NewPartEntry->IsPartitioned = FALSE; - NewPartEntry->StartSector.QuadPart = LastStartSector + LastSectorCount; - NewPartEntry->SectorCount.QuadPart = AlignDown(NewPartEntry->StartSector.QuadPart + LastUnusedSectorCount, DiskEntry->SectorAlignment) - - NewPartEntry->StartSector.QuadPart; - - DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart); - DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1); - DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart); - - NewPartEntry->FormatState = Unformatted; - NewPartEntry->FileSystem = NULL; + StartSector = LastStartSector + LastSectorCount; + SectorCount = AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector; /* Insert the table into the list */ - InsertTailList(&PartEntry->ListEntry, - &NewPartEntry->ListEntry); + NewPartEntry = CreateInsertBlankRegion(DiskEntry, + &PartEntry->ListEntry, + StartSector, + SectorCount, + FALSE); + if (NewPartEntry == NULL) + { + DPRINT1("Failed to create a new empty region for disk space!\n"); + return; + } } LastStartSector = PartEntry->StartSector.QuadPart; @@ -904,29 +1066,20 @@ ScanForUnpartitionedDiskSpace( { DPRINT("Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount); - NewPartEntry = RtlAllocateHeap(ProcessHeap, - HEAP_ZERO_MEMORY, - sizeof(PARTENTRY)); - if (NewPartEntry == NULL) - return; - - NewPartEntry->DiskEntry = DiskEntry; - - NewPartEntry->IsPartitioned = FALSE; - NewPartEntry->StartSector.QuadPart = LastStartSector + LastSectorCount; - NewPartEntry->SectorCount.QuadPart = AlignDown(NewPartEntry->StartSector.QuadPart + LastUnusedSectorCount, DiskEntry->SectorAlignment) - - NewPartEntry->StartSector.QuadPart; - - DPRINT("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart); - DPRINT("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1); - DPRINT("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart); - - NewPartEntry->FormatState = Unformatted; - NewPartEntry->FileSystem = NULL; + StartSector = LastStartSector + LastSectorCount; + SectorCount = AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector; /* Append the table to the list */ - InsertTailList(&DiskEntry->PrimaryPartListHead, - &NewPartEntry->ListEntry); + NewPartEntry = CreateInsertBlankRegion(DiskEntry, + &DiskEntry->PrimaryPartListHead, + StartSector, + SectorCount, + FALSE); + if (NewPartEntry == NULL) + { + DPRINT1("Failed to create a new empty region for trailing disk space!\n"); + return; + } } } @@ -937,29 +1090,22 @@ ScanForUnpartitionedDiskSpace( DPRINT1("No logical partition!\n"); /* Create a partition entry that represents the empty extended partition */ - NewPartEntry = RtlAllocateHeap(ProcessHeap, - HEAP_ZERO_MEMORY, - sizeof(PARTENTRY)); + + StartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (ULONGLONG)DiskEntry->SectorAlignment; + SectorCount = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (ULONGLONG)DiskEntry->SectorAlignment; + + NewPartEntry = CreateInsertBlankRegion(DiskEntry, + &DiskEntry->LogicalPartListHead, + StartSector, + SectorCount, + TRUE); if (NewPartEntry == NULL) + { + DPRINT1("Failed to create a new empty region for full extended partition space!\n"); return; - - NewPartEntry->DiskEntry = DiskEntry; + } NewPartEntry->LogicalPartition = TRUE; - NewPartEntry->IsPartitioned = FALSE; - NewPartEntry->StartSector.QuadPart = DiskEntry->ExtendedPartition->StartSector.QuadPart + (ULONGLONG)DiskEntry->SectorAlignment; - NewPartEntry->SectorCount.QuadPart = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (ULONGLONG)DiskEntry->SectorAlignment; - - DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart); - DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1); - DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart); - - NewPartEntry->FormatState = Unformatted; - NewPartEntry->FileSystem = NULL; - - InsertTailList(&DiskEntry->LogicalPartListHead, - &NewPartEntry->ListEntry); - return; } @@ -984,30 +1130,21 @@ ScanForUnpartitionedDiskSpace( { DPRINT("Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount); - NewPartEntry = RtlAllocateHeap(ProcessHeap, - HEAP_ZERO_MEMORY, - sizeof(PARTENTRY)); + StartSector = LastStartSector + LastSectorCount; + SectorCount = AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector; + + /* Insert the table into the list */ + NewPartEntry = CreateInsertBlankRegion(DiskEntry, + &PartEntry->ListEntry, + StartSector, + SectorCount, + TRUE); if (NewPartEntry == NULL) + { + DPRINT1("Failed to create a new empty region for extended partition space!\n"); return; - - NewPartEntry->DiskEntry = DiskEntry; + } NewPartEntry->LogicalPartition = TRUE; - - NewPartEntry->IsPartitioned = FALSE; - NewPartEntry->StartSector.QuadPart = LastStartSector + LastSectorCount; - NewPartEntry->SectorCount.QuadPart = AlignDown(NewPartEntry->StartSector.QuadPart + LastUnusedSectorCount, DiskEntry->SectorAlignment) - - NewPartEntry->StartSector.QuadPart; - - DPRINT("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart); - DPRINT("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1); - DPRINT("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart); - - NewPartEntry->FormatState = Unformatted; - NewPartEntry->FileSystem = NULL; - - /* Insert the table into the list */ - InsertTailList(&PartEntry->ListEntry, - &NewPartEntry->ListEntry); } LastStartSector = PartEntry->StartSector.QuadPart; @@ -1020,36 +1157,29 @@ ScanForUnpartitionedDiskSpace( /* Check for trailing unpartitioned disk space */ if ((LastStartSector + LastSectorCount) < DiskEntry->ExtendedPartition->StartSector.QuadPart + DiskEntry->ExtendedPartition->SectorCount.QuadPart) { - LastUnusedSectorCount = AlignDown(DiskEntry->ExtendedPartition->StartSector.QuadPart + DiskEntry->ExtendedPartition->SectorCount.QuadPart - (LastStartSector + LastSectorCount), DiskEntry->SectorAlignment); + LastUnusedSectorCount = AlignDown(DiskEntry->ExtendedPartition->StartSector.QuadPart + + DiskEntry->ExtendedPartition->SectorCount.QuadPart - (LastStartSector + LastSectorCount), + DiskEntry->SectorAlignment); if (LastUnusedSectorCount >= (ULONGLONG)DiskEntry->SectorAlignment) { DPRINT("Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount); - NewPartEntry = RtlAllocateHeap(ProcessHeap, - HEAP_ZERO_MEMORY, - sizeof(PARTENTRY)); + StartSector = LastStartSector + LastSectorCount; + SectorCount = AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector; + + /* Append the table to the list */ + NewPartEntry = CreateInsertBlankRegion(DiskEntry, + &DiskEntry->LogicalPartListHead, + StartSector, + SectorCount, + TRUE); if (NewPartEntry == NULL) + { + DPRINT1("Failed to create a new empty region for extended partition space!\n"); return; - - NewPartEntry->DiskEntry = DiskEntry; + } NewPartEntry->LogicalPartition = TRUE; - - NewPartEntry->IsPartitioned = FALSE; - NewPartEntry->StartSector.QuadPart = LastStartSector + LastSectorCount; - NewPartEntry->SectorCount.QuadPart = AlignDown(NewPartEntry->StartSector.QuadPart + LastUnusedSectorCount, DiskEntry->SectorAlignment) - - NewPartEntry->StartSector.QuadPart; - - DPRINT("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart); - DPRINT("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1); - DPRINT("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart); - - NewPartEntry->FormatState = Unformatted; - NewPartEntry->FileSystem = NULL; - - /* Append the table to the list */ - InsertTailList(&DiskEntry->LogicalPartListHead, - &NewPartEntry->ListEntry); } } } @@ -1433,22 +1563,25 @@ AddDiskToList( DPRINT1("No valid partition table found! Use megabyte (%lu Sectors) alignment!\n", (1024 * 1024) / DiskEntry->BytesPerSector); } - if (DiskEntry->LayoutBuffer->PartitionCount == 0) { DiskEntry->NewDisk = TRUE; DiskEntry->LayoutBuffer->PartitionCount = 4; for (i = 0; i < 4; i++) + { DiskEntry->LayoutBuffer->PartitionEntry[i].RewritePartition = TRUE; + } } else { + /* Enumerate and add the first four primary partitions */ for (i = 0; i < 4; i++) { AddPartitionToDisk(DiskNumber, DiskEntry, i, FALSE); } + /* Enumerate and add the remaining partitions as logical ones */ for (i = 4; i < DiskEntry->LayoutBuffer->PartitionCount; i += 4) { AddPartitionToDisk(DiskNumber, DiskEntry, i, TRUE); @@ -1873,7 +2006,7 @@ GetNextPartition( { /* Primary or extended partition */ - if ((List->CurrentPartition->IsPartitioned != FALSE) && + if (List->CurrentPartition->IsPartitioned && IsContainerPartition(List->CurrentPartition->PartitionType)) { /* First logical partition */ @@ -1966,7 +2099,7 @@ GetPrevPartition( { PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry); - if ((PartEntry->IsPartitioned != FALSE) && + if (PartEntry->IsPartitioned && IsContainerPartition(PartEntry->PartitionType)) { PartListEntry = List->CurrentDisk->LogicalPartListHead.Blink; @@ -1990,7 +2123,7 @@ GetPrevPartition( { PartEntry = CONTAINING_RECORD(PartListEntry, PARTENTRY, ListEntry); - if ((PartEntry->IsPartitioned != FALSE) && + if (PartEntry->IsPartitioned && IsContainerPartition(PartEntry->PartitionType)) { PartListEntry = DiskEntry->LogicalPartListHead.Blink; @@ -2042,7 +2175,6 @@ IsSamePrimaryLayoutEntry( { if (PartitionInfo->StartingOffset.QuadPart == PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector && PartitionInfo->PartitionLength.QuadPart == PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector) -// PartitionInfo->PartitionNumber = PartEntry->PartitionNumber && // PartitionInfo->PartitionType == PartEntry->PartitionType { return TRUE; @@ -2113,7 +2245,7 @@ ReAllocateLayoutBuffer( if (DiskEntry->LayoutBuffer) CurrentPartitionCount = DiskEntry->LayoutBuffer->PartitionCount; - DPRINT1("CurrentPartitionCount: %lu NewPartitionCount: %lu\n", + DPRINT1("CurrentPartitionCount: %lu ; NewPartitionCount: %lu\n", CurrentPartitionCount, NewPartitionCount); if (CurrentPartitionCount == NewPartitionCount) @@ -2131,15 +2263,18 @@ ReAllocateLayoutBuffer( return FALSE; } + NewLayoutBuffer->PartitionCount = NewPartitionCount; + /* If the layout buffer grows, make sure the new (empty) entries are written to the disk */ if (NewPartitionCount > CurrentPartitionCount) { for (i = CurrentPartitionCount; i < NewPartitionCount; i++) + { NewLayoutBuffer->PartitionEntry[i].RewritePartition = TRUE; + } } DiskEntry->LayoutBuffer = NewLayoutBuffer; - DiskEntry->LayoutBuffer->PartitionCount = NewPartitionCount; return TRUE; } @@ -2173,9 +2308,16 @@ UpdateDiskLayout( { PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry); - if (PartEntry->IsPartitioned != FALSE) + if (PartEntry->IsPartitioned) { PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[Index]; + PartEntry->PartitionIndex = Index; + + /* Reset the current partition number only for newly-created partitions */ + if (PartEntry->New) + PartEntry->PartitionNumber = 0; + + PartEntry->OnDiskPartitionNumber = (!IsContainerPartition(PartEntry->PartitionType)) ? PartitionNumber : 0; if (!IsSamePrimaryLayoutEntry(PartitionInfo, DiskEntry, PartEntry)) { @@ -2184,16 +2326,13 @@ UpdateDiskLayout( PartitionInfo->StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector; PartitionInfo->PartitionLength.QuadPart = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector; PartitionInfo->HiddenSectors = PartEntry->StartSector.LowPart; - PartitionInfo->PartitionNumber = (!IsContainerPartition(PartEntry->PartitionType)) ? PartitionNumber : 0; + PartitionInfo->PartitionNumber = PartEntry->PartitionNumber; PartitionInfo->PartitionType = PartEntry->PartitionType; PartitionInfo->BootIndicator = PartEntry->BootIndicator; - PartitionInfo->RecognizedPartition = FALSE; + PartitionInfo->RecognizedPartition = IsRecognizedPartition(PartEntry->PartitionType); PartitionInfo->RewritePartition = TRUE; } - PartEntry->PartitionNumber = (!IsContainerPartition(PartEntry->PartitionType)) ? PartitionNumber : 0; - PartEntry->PartitionIndex = Index; - if (!IsContainerPartition(PartEntry->PartitionType)) PartitionNumber++; @@ -2215,21 +2354,25 @@ UpdateDiskLayout( if (PartEntry->IsPartitioned) { PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[Index]; + PartEntry->PartitionIndex = Index; DPRINT1("Updating logical partition entry %lu\n", Index); + /* Reset the current partition number only for newly-created partitions */ + if (PartEntry->New) + PartEntry->PartitionNumber = 0; + + PartEntry->OnDiskPartitionNumber = PartitionNumber; + PartitionInfo->StartingOffset.QuadPart = PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector; PartitionInfo->PartitionLength.QuadPart = PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector; PartitionInfo->HiddenSectors = DiskEntry->SectorAlignment; - PartitionInfo->PartitionNumber = PartitionNumber; + PartitionInfo->PartitionNumber = PartEntry->PartitionNumber; PartitionInfo->PartitionType = PartEntry->PartitionType; PartitionInfo->BootIndicator = FALSE; - PartitionInfo->RecognizedPartition = FALSE; + PartitionInfo->RecognizedPartition = IsRecognizedPartition(PartEntry->PartitionType); PartitionInfo->RewritePartition = TRUE; - PartEntry->PartitionNumber = PartitionNumber; - PartEntry->PartitionIndex = Index; - /* Fill the link entry of the previous partition entry */ if (LinkInfo != NULL) { @@ -2301,6 +2444,8 @@ UpdateDiskLayout( } } + DiskEntry->Dirty = TRUE; + #ifdef DUMP_PARTITION_TABLE DumpPartitionTable(DiskEntry); #endif @@ -2367,7 +2512,6 @@ CreatePrimaryPartition( ERROR_NUMBER Error; PDISKENTRY DiskEntry; PPARTENTRY PartEntry; - PPARTENTRY NewPartEntry; DPRINT1("CreatePrimaryPartition(%I64u)\n", SectorCount); @@ -2389,66 +2533,13 @@ CreatePrimaryPartition( DiskEntry = List->CurrentDisk; PartEntry = List->CurrentPartition; - DPRINT1("Current partition sector count: %I64u\n", PartEntry->SectorCount.QuadPart); - - if ((AutoCreate != FALSE) || - (AlignDown(PartEntry->StartSector.QuadPart + SectorCount, DiskEntry->SectorAlignment) - PartEntry->StartSector.QuadPart == PartEntry->SectorCount.QuadPart)) - { - DPRINT1("Convert existing partition entry\n"); - - /* Convert current entry to 'new (unformatted)' */ - PartEntry->IsPartitioned = TRUE; - PartEntry->PartitionType = PARTITION_ENTRY_UNUSED; - PartEntry->FormatState = Unformatted; - PartEntry->FileSystem = NULL; - PartEntry->AutoCreate = AutoCreate; - PartEntry->New = TRUE; - PartEntry->BootIndicator = FALSE; - - DPRINT1("First Sector: %I64u\n", PartEntry->StartSector.QuadPart); - DPRINT1("Last Sector: %I64u\n", PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1); - DPRINT1("Total Sectors: %I64u\n", PartEntry->SectorCount.QuadPart); - } - else - { - DPRINT1("Add new partition entry\n"); - - /* Insert and initialize a new partition entry */ - NewPartEntry = RtlAllocateHeap(ProcessHeap, - HEAP_ZERO_MEMORY, - sizeof(PARTENTRY)); - if (NewPartEntry == NULL) - return FALSE; - - /* Insert the new entry into the list */ - InsertTailList(&PartEntry->ListEntry, - &NewPartEntry->ListEntry); - - NewPartEntry->DiskEntry = DiskEntry; - - NewPartEntry->IsPartitioned = TRUE; - NewPartEntry->StartSector.QuadPart = PartEntry->StartSector.QuadPart; - NewPartEntry->SectorCount.QuadPart = AlignDown(NewPartEntry->StartSector.QuadPart + SectorCount, DiskEntry->SectorAlignment) - - NewPartEntry->StartSector.QuadPart; - NewPartEntry->PartitionType = PARTITION_ENTRY_UNUSED; - - DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart); - DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1); - DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart); - - NewPartEntry->New = TRUE; - NewPartEntry->FormatState = Unformatted; - NewPartEntry->FileSystem = NULL; - NewPartEntry->BootIndicator = FALSE; - - PartEntry->StartSector.QuadPart = NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart; - PartEntry->SectorCount.QuadPart -= (PartEntry->StartSector.QuadPart - NewPartEntry->StartSector.QuadPart); - } + /* Convert the current entry, or insert and initialize a new partition entry */ + PartEntry = InitializePartitionEntry(DiskEntry, PartEntry, SectorCount, AutoCreate); + if (PartEntry == NULL) + return FALSE; UpdateDiskLayout(DiskEntry); - DiskEntry->Dirty = TRUE; - AssignDriveLetters(List); return TRUE; @@ -2459,33 +2550,28 @@ VOID AddLogicalDiskSpace( IN PDISKENTRY DiskEntry) { + ULONGLONG StartSector; + ULONGLONG SectorCount; PPARTENTRY NewPartEntry; DPRINT1("AddLogicalDiskSpace()\n"); /* Create a partition entry that represents the empty space in the container partition */ - NewPartEntry = RtlAllocateHeap(ProcessHeap, - HEAP_ZERO_MEMORY, - sizeof(PARTENTRY)); + + StartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (ULONGLONG)DiskEntry->SectorAlignment; + SectorCount = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (ULONGLONG)DiskEntry->SectorAlignment; + + NewPartEntry = CreateInsertBlankRegion(DiskEntry, + &DiskEntry->LogicalPartListHead, + StartSector, + SectorCount, + TRUE); if (NewPartEntry == NULL) + { + DPRINT1("Failed to create a new empty region for extended partition space!\n"); return; - - NewPartEntry->DiskEntry = DiskEntry; + } NewPartEntry->LogicalPartition = TRUE; - - NewPartEntry->IsPartitioned = FALSE; - NewPartEntry->StartSector.QuadPart = DiskEntry->ExtendedPartition->StartSector.QuadPart + (ULONGLONG)DiskEntry->SectorAlignment; - NewPartEntry->SectorCount.QuadPart = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (ULONGLONG)DiskEntry->SectorAlignment; - - DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart); - DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1); - DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart); - - NewPartEntry->FormatState = Unformatted; - NewPartEntry->FileSystem = NULL; - - InsertTailList(&DiskEntry->LogicalPartListHead, - &NewPartEntry->ListEntry); } BOOLEAN @@ -2496,7 +2582,6 @@ CreateExtendedPartition( ERROR_NUMBER Error; PDISKENTRY DiskEntry; PPARTENTRY PartEntry; - PPARTENTRY NewPartEntry; DPRINT1("CreateExtendedPartition(%I64u)\n", SectorCount); @@ -2518,91 +2603,32 @@ CreateExtendedPartition( DiskEntry = List->CurrentDisk; PartEntry = List->CurrentPartition; - DPRINT1("Current partition sector count: %I64u\n", PartEntry->SectorCount.QuadPart); + /* Convert the current entry, or insert and initialize a new partition entry */ + PartEntry = InitializePartitionEntry(DiskEntry, PartEntry, SectorCount, FALSE); + if (PartEntry == NULL) + return FALSE; - if (AlignDown(PartEntry->StartSector.QuadPart + SectorCount, DiskEntry->SectorAlignment) - PartEntry->StartSector.QuadPart == PartEntry->SectorCount.QuadPart) + if (PartEntry->StartSector.QuadPart < 1450560) { - DPRINT1("Convert existing partition entry\n"); - - /* Convert current entry to 'new (unformatted)' */ - PartEntry->IsPartitioned = TRUE; - PartEntry->FormatState = Formatted; // FIXME? Possibly to make GetNextUnformattedPartition work (i.e. skip the extended partition container) - PartEntry->FileSystem = NULL; - PartEntry->AutoCreate = FALSE; - PartEntry->New = FALSE; - PartEntry->BootIndicator = FALSE; - - if (PartEntry->StartSector.QuadPart < 1450560) - { - /* Partition starts below the 8.4GB boundary ==> CHS partition */ - PartEntry->PartitionType = PARTITION_EXTENDED; - } - else - { - /* Partition starts above the 8.4GB boundary ==> LBA partition */ - PartEntry->PartitionType = PARTITION_XINT13_EXTENDED; - } - - DiskEntry->ExtendedPartition = PartEntry; - - DPRINT1("First Sector: %I64u\n", PartEntry->StartSector.QuadPart); - DPRINT1("Last Sector: %I64u\n", PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1); - DPRINT1("Total Sectors: %I64u\n", PartEntry->SectorCount.QuadPart); + /* Partition starts below the 8.4GB boundary ==> CHS partition */ + PartEntry->PartitionType = PARTITION_EXTENDED; } else { - DPRINT1("Add new partition entry\n"); - - /* Insert and initialize a new partition entry */ - NewPartEntry = RtlAllocateHeap(ProcessHeap, - HEAP_ZERO_MEMORY, - sizeof(PARTENTRY)); - if (NewPartEntry == NULL) - return FALSE; - - /* Insert the new entry into the list */ - InsertTailList(&PartEntry->ListEntry, - &NewPartEntry->ListEntry); - - NewPartEntry->DiskEntry = DiskEntry; - - NewPartEntry->IsPartitioned = TRUE; - NewPartEntry->StartSector.QuadPart = PartEntry->StartSector.QuadPart; - NewPartEntry->SectorCount.QuadPart = AlignDown(NewPartEntry->StartSector.QuadPart + SectorCount, DiskEntry->SectorAlignment) - - NewPartEntry->StartSector.QuadPart; - - NewPartEntry->New = FALSE; - NewPartEntry->FormatState = Formatted; // FIXME? Possibly to make GetNextUnformattedPartition work (i.e. skip the extended partition container) - NewPartEntry->FileSystem = NULL; - NewPartEntry->BootIndicator = FALSE; - - if (NewPartEntry->StartSector.QuadPart < 1450560) - { - /* Partition starts below the 8.4GB boundary ==> CHS partition */ - NewPartEntry->PartitionType = PARTITION_EXTENDED; - } - else - { - /* Partition starts above the 8.4GB boundary ==> LBA partition */ - NewPartEntry->PartitionType = PARTITION_XINT13_EXTENDED; - } - - DiskEntry->ExtendedPartition = NewPartEntry; + /* Partition starts above the 8.4GB boundary ==> LBA partition */ + PartEntry->PartitionType = PARTITION_XINT13_EXTENDED; + } - PartEntry->StartSector.QuadPart = NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart; - PartEntry->SectorCount.QuadPart -= (PartEntry->StartSector.QuadPart - NewPartEntry->StartSector.QuadPart); + // FIXME? Possibly to make GetNextUnformattedPartition work (i.e. skip the extended partition container) + PartEntry->New = FALSE; + PartEntry->FormatState = Formatted; - DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart); - DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1); - DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart); - } + DiskEntry->ExtendedPartition = PartEntry; AddLogicalDiskSpace(DiskEntry); UpdateDiskLayout(DiskEntry); - DiskEntry->Dirty = TRUE; - AssignDriveLetters(List); return TRUE; @@ -2617,7 +2643,6 @@ CreateLogicalPartition( ERROR_NUMBER Error; PDISKENTRY DiskEntry; PPARTENTRY PartEntry; - PPARTENTRY NewPartEntry; DPRINT1("CreateLogicalPartition(%I64u)\n", SectorCount); @@ -2639,68 +2664,15 @@ CreateLogicalPartition( DiskEntry = List->CurrentDisk; PartEntry = List->CurrentPartition; - DPRINT1("Current partition sector count: %I64u\n", PartEntry->SectorCount.QuadPart); - - if ((AutoCreate != FALSE) || - (AlignDown(PartEntry->StartSector.QuadPart + SectorCount, DiskEntry->SectorAlignment) - PartEntry->StartSector.QuadPart == PartEntry->SectorCount.QuadPart)) - { - DPRINT1("Convert existing partition entry\n"); - - /* Convert current entry to 'new (unformatted)' */ - PartEntry->IsPartitioned = TRUE; - PartEntry->PartitionType = PARTITION_ENTRY_UNUSED; - PartEntry->FormatState = Unformatted; - PartEntry->FileSystem = NULL; - PartEntry->AutoCreate = FALSE; - PartEntry->New = TRUE; - PartEntry->BootIndicator = FALSE; - PartEntry->LogicalPartition = TRUE; - - DPRINT1("First Sector: %I64u\n", PartEntry->StartSector.QuadPart); - DPRINT1("Last Sector: %I64u\n", PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1); - DPRINT1("Total Sectors: %I64u\n", PartEntry->SectorCount.QuadPart); - } - else - { - DPRINT1("Add new partition entry\n"); - - /* Insert and initialize a new partition entry */ - NewPartEntry = RtlAllocateHeap(ProcessHeap, - HEAP_ZERO_MEMORY, - sizeof(PARTENTRY)); - if (NewPartEntry == NULL) - return FALSE; - - /* Insert the new entry into the list */ - InsertTailList(&PartEntry->ListEntry, - &NewPartEntry->ListEntry); - - NewPartEntry->DiskEntry = DiskEntry; - - NewPartEntry->IsPartitioned = TRUE; - NewPartEntry->StartSector.QuadPart = PartEntry->StartSector.QuadPart; - NewPartEntry->SectorCount.QuadPart = AlignDown(NewPartEntry->StartSector.QuadPart + SectorCount, DiskEntry->SectorAlignment) - - NewPartEntry->StartSector.QuadPart; - NewPartEntry->PartitionType = PARTITION_ENTRY_UNUSED; - - DPRINT1("First Sector: %I64u\n", NewPartEntry->StartSector.QuadPart); - DPRINT1("Last Sector: %I64u\n", NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart - 1); - DPRINT1("Total Sectors: %I64u\n", NewPartEntry->SectorCount.QuadPart); - - NewPartEntry->New = TRUE; - NewPartEntry->FormatState = Unformatted; - NewPartEntry->FileSystem = NULL; - NewPartEntry->BootIndicator = FALSE; - NewPartEntry->LogicalPartition = TRUE; + /* Convert the current entry, or insert and initialize a new partition entry */ + PartEntry = InitializePartitionEntry(DiskEntry, PartEntry, SectorCount, AutoCreate); + if (PartEntry == NULL) + return FALSE; - PartEntry->StartSector.QuadPart = NewPartEntry->StartSector.QuadPart + NewPartEntry->SectorCount.QuadPart; - PartEntry->SectorCount.QuadPart -= (PartEntry->StartSector.QuadPart - NewPartEntry->StartSector.QuadPart); - } + PartEntry->LogicalPartition = TRUE; UpdateDiskLayout(DiskEntry); - DiskEntry->Dirty = TRUE; - AssignDriveLetters(List); return TRUE; @@ -2924,12 +2896,13 @@ DeleteCurrentPartition( PartEntry->FormatState = Unformatted; PartEntry->FileSystem = NULL; PartEntry->DriveLetter = 0; + PartEntry->OnDiskPartitionNumber = 0; + PartEntry->PartitionNumber = 0; + // PartEntry->PartitionIndex = 0; } UpdateDiskLayout(DiskEntry); - DiskEntry->Dirty = TRUE; - AssignDriveLetters(List); } @@ -3174,13 +3147,17 @@ WritePartitions( IN PPARTLIST List, IN PDISKENTRY DiskEntry) { - WCHAR DstPath[MAX_PATH]; + NTSTATUS Status; OBJECT_ATTRIBUTES ObjectAttributes; - IO_STATUS_BLOCK Iosb; UNICODE_STRING Name; + HANDLE FileHandle; + IO_STATUS_BLOCK Iosb; ULONG BufferSize; - HANDLE FileHandle = NULL; - NTSTATUS Status; + PPARTITION_INFORMATION PartitionInfo; + ULONG PartitionCount; + PLIST_ENTRY ListEntry; + PPARTENTRY PartEntry; + WCHAR DstPath[MAX_PATH]; DPRINT("WritePartitions() Disk: %lu\n", DiskEntry->DiskNumber); @@ -3217,8 +3194,12 @@ WritePartitions( // For this we must ask the user which format to use. // + /* Save the original partition count to be restored later (see comment below) */ + PartitionCount = DiskEntry->LayoutBuffer->PartitionCount; + + /* Set the new disk layout and retrieve its updated version with possibly modified partition numbers */ BufferSize = sizeof(DRIVE_LAYOUT_INFORMATION) + - ((DiskEntry->LayoutBuffer->PartitionCount - 1) * sizeof(PARTITION_INFORMATION)); + ((PartitionCount - 1) * sizeof(PARTITION_INFORMATION)); Status = NtDeviceIoControlFile(FileHandle, NULL, NULL, @@ -3227,15 +3208,61 @@ WritePartitions( IOCTL_DISK_SET_DRIVE_LAYOUT, DiskEntry->LayoutBuffer, BufferSize, - NULL, - 0); + DiskEntry->LayoutBuffer, + BufferSize); + NtClose(FileHandle); + + /* + * IOCTL_DISK_SET_DRIVE_LAYOUT calls IoWritePartitionTable(), which converts + * DiskEntry->LayoutBuffer->PartitionCount into a partition *table* count, + * where such a table is expected to enumerate up to 4 partitions: + * partition *table* count == ROUND_UP(PartitionCount, 4) / 4 . + * Due to this we need to restore the original PartitionCount number. + */ + DiskEntry->LayoutBuffer->PartitionCount = PartitionCount; + + /* Check whether the IOCTL_DISK_SET_DRIVE_LAYOUT call succeeded */ if (!NT_SUCCESS(Status)) { DPRINT1("IOCTL_DISK_SET_DRIVE_LAYOUT failed (Status 0x%08lx)\n", Status); + return Status; } - if (FileHandle != NULL) - NtClose(FileHandle); +#ifdef DUMP_PARTITION_TABLE + DumpPartitionTable(DiskEntry); +#endif + + /* Update the partition numbers */ + + /* Update the primary partition table */ + ListEntry = DiskEntry->PrimaryPartListHead.Flink; + while (ListEntry != &DiskEntry->PrimaryPartListHead) + { + PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry); + + if (PartEntry->IsPartitioned) + { + PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex]; + PartEntry->PartitionNumber = PartitionInfo->PartitionNumber; + } + + ListEntry = ListEntry->Flink; + } + + /* Update the logical partition table */ + ListEntry = DiskEntry->LogicalPartListHead.Flink; + while (ListEntry != &DiskEntry->LogicalPartListHead) + { + PartEntry = CONTAINING_RECORD(ListEntry, PARTENTRY, ListEntry); + + if (PartEntry->IsPartitioned) + { + PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex]; + PartEntry->PartitionNumber = PartitionInfo->PartitionNumber; + } + + ListEntry = ListEntry->Flink; + } // // NOTE: Originally (see r40437), we used to install here also a new MBR @@ -3247,6 +3274,8 @@ WritePartitions( // DiskEntry->NoMbr was TRUE (instead of NewDisk). // + // DiskEntry->Dirty = FALSE; + return Status; } @@ -3419,6 +3448,7 @@ SetPartitionType( DiskEntry->Dirty = TRUE; DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].PartitionType = PartitionType; + DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].RecognizedPartition = IsRecognizedPartition(PartitionType); DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].RewritePartition = TRUE; } diff --git a/base/setup/lib/utils/partlist.h b/base/setup/lib/utils/partlist.h index f2f856cda2..8e2c635bce 100644 --- a/base/setup/lib/utils/partlist.h +++ b/base/setup/lib/utils/partlist.h @@ -46,8 +46,9 @@ typedef struct _PARTENTRY BOOLEAN BootIndicator; UCHAR PartitionType; ULONG HiddenSectors; - ULONG PartitionNumber; /* Enumerated partition number (primary partitions first -- excluding the extended partition container --, then the logical partitions) */ - ULONG PartitionIndex; /* Index in the LayoutBuffer->PartitionEntry[] cached array of the corresponding DiskEntry */ + ULONG OnDiskPartitionNumber; /* Enumerated partition number (primary partitions first, excluding the extended partition container, then the logical partitions) */ + ULONG PartitionNumber; /* Current partition number, only valid for the currently running NTOS instance */ + ULONG PartitionIndex; /* Index in the LayoutBuffer->PartitionEntry[] cached array of the corresponding DiskEntry */ WCHAR DriveLetter; WCHAR VolumeLabel[20]; @@ -116,8 +117,8 @@ typedef struct _DISKENTRY /* Has the partition list been modified? */ BOOLEAN Dirty; - BOOLEAN NewDisk; - BOOLEAN NoMbr; /* MBR is absent */ // See r40437 + BOOLEAN NewDisk; /* If TRUE, the disk is uninitialized */ + BOOLEAN NoMbr; /* If TRUE, the MBR is absent */ // See r40437 UNICODE_STRING DriverName; @@ -127,11 +128,11 @@ typedef struct _DISKENTRY // the disk is MBR, GPT, or unknown (uninitialized). // Depending on the style, either use the MBR or GPT partition info. - /* Pointer to the unique extended partition on this disk */ - PPARTENTRY ExtendedPartition; + LIST_ENTRY PrimaryPartListHead; /* List of primary partitions */ + LIST_ENTRY LogicalPartListHead; /* List of logical partitions (Valid only for MBR-partitioned disks) */ - LIST_ENTRY PrimaryPartListHead; - LIST_ENTRY LogicalPartListHead; + /* Pointer to the unique extended partition on this disk (Valid only for MBR-partitioned disks) */ + PPARTENTRY ExtendedPartition; } DISKENTRY, *PDISKENTRY;
6 years
1
0
0
0
← Newer
1
...
22
23
24
25
26
27
28
...
33
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Results per page:
10
25
50
100
200