ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
March 2010
----- 2025 -----
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
19 participants
896 discussions
Start a n
N
ew thread
[cgutman] 46239: - Don't acquire the mutex in the ISR handler because we're at a raised IRQL - Fixes VirtualBox Additions with ACPI enabled
by cgutman@svn.reactos.org
Author: cgutman Date: Wed Mar 17 07:19:01 2010 New Revision: 46239 URL:
http://svn.reactos.org/svn/reactos?rev=46239&view=rev
Log: - Don't acquire the mutex in the ISR handler because we're at a raised IRQL - Fixes VirtualBox Additions with ACPI enabled Modified: trunk/reactos/drivers/bus/acpi/acpica/events/evgpe.c Modified: trunk/reactos/drivers/bus/acpi/acpica/events/evgpe.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/acpica/ev…
============================================================================== --- trunk/reactos/drivers/bus/acpi/acpica/events/evgpe.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/acpi/acpica/events/evgpe.c [iso-8859-1] Wed Mar 17 07:19:01 2010 @@ -505,7 +505,7 @@ UINT8 EnabledStatusByte; UINT32 StatusReg; UINT32 EnableReg; - ACPI_CPU_FLAGS Flags; + //ACPI_CPU_FLAGS Flags; UINT32 i; UINT32 j; @@ -524,7 +524,7 @@ * Note: Not necessary to obtain the hardware lock, since the GPE * registers are owned by the GpeLock. */ - Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + //Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); /* Examine all GPE blocks attached to this interrupt level */ @@ -596,7 +596,7 @@ UnlockAndExit: - AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + //AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); return (IntStatus); }
14 years, 9 months
1
0
0
0
[cgutman] 46238: - Define NDEBUG and demote several non-critical debug prints to DPRINT
by cgutman@svn.reactos.org
Author: cgutman Date: Wed Mar 17 06:30:22 2010 New Revision: 46238 URL:
http://svn.reactos.org/svn/reactos?rev=46238&view=rev
Log: - Define NDEBUG and demote several non-critical debug prints to DPRINT Modified: trunk/reactos/drivers/bus/acpi/acpienum.c trunk/reactos/drivers/bus/acpi/busmgr/bus.c trunk/reactos/drivers/bus/acpi/busmgr/power.c trunk/reactos/drivers/bus/acpi/busmgr/system.c trunk/reactos/drivers/bus/acpi/busmgr/utils.c trunk/reactos/drivers/bus/acpi/buspdo.c trunk/reactos/drivers/bus/acpi/main.c trunk/reactos/drivers/bus/acpi/osl.c trunk/reactos/drivers/bus/acpi/pnp.c trunk/reactos/drivers/bus/acpi/power.c Modified: trunk/reactos/drivers/bus/acpi/acpienum.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/acpienum.…
============================================================================== --- trunk/reactos/drivers/bus/acpi/acpienum.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/acpi/acpienum.c [iso-8859-1] Wed Mar 17 06:30:22 2010 @@ -13,7 +13,7 @@ #include <acpi_drivers.h> #include <list.h> -//#define NDEBUG +#define NDEBUG #include <debug.h> #define HAS_CHILDREN(d) ((d)->children.next != &((d)->children)) Modified: trunk/reactos/drivers/bus/acpi/busmgr/bus.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/busmgr/bu…
============================================================================== --- trunk/reactos/drivers/bus/acpi/busmgr/bus.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/acpi/busmgr/bus.c [iso-8859-1] Wed Mar 17 06:30:22 2010 @@ -34,7 +34,7 @@ #include <acpi_drivers.h> #include <glue.h> -//#define NDEBUG +#define NDEBUG #include <debug.h> #define _COMPONENT ACPI_BUS_COMPONENT Modified: trunk/reactos/drivers/bus/acpi/busmgr/power.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/busmgr/po…
============================================================================== --- trunk/reactos/drivers/bus/acpi/busmgr/power.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/acpi/busmgr/power.c [iso-8859-1] Wed Mar 17 06:30:22 2010 @@ -46,7 +46,7 @@ #include <acpi_drivers.h> #include <glue.h> -//#define NDEBUG +#define NDEBUG #include <debug.h> Modified: trunk/reactos/drivers/bus/acpi/busmgr/system.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/busmgr/sy…
============================================================================== --- trunk/reactos/drivers/bus/acpi/busmgr/system.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/acpi/busmgr/system.c [iso-8859-1] Wed Mar 17 06:30:22 2010 @@ -32,7 +32,7 @@ #include <acpi_drivers.h> #include "list.h" -//#define NDEBUG +#define NDEBUG #include <debug.h> ACPI_STATUS acpi_system_save_state(UINT32); Modified: trunk/reactos/drivers/bus/acpi/busmgr/utils.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/busmgr/ut…
============================================================================== --- trunk/reactos/drivers/bus/acpi/busmgr/utils.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/acpi/busmgr/utils.c [iso-8859-1] Wed Mar 17 06:30:22 2010 @@ -30,7 +30,7 @@ #include <acpi_drivers.h> #include <glue.h> -//#define NDEBUG +#define NDEBUG #include <debug.h> /* Modified for ReactOS and latest ACPICA Modified: trunk/reactos/drivers/bus/acpi/buspdo.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/buspdo.c?…
============================================================================== --- trunk/reactos/drivers/bus/acpi/buspdo.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/acpi/buspdo.c [iso-8859-1] Wed Mar 17 06:30:22 2010 @@ -8,7 +8,7 @@ #include <acpi_bus.h> #include <acpi_drivers.h> -//#define NDEBUG +#define NDEBUG #include <debug.h> #ifdef ALLOC_PRAGMA Modified: trunk/reactos/drivers/bus/acpi/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/main.c?re…
============================================================================== --- trunk/reactos/drivers/bus/acpi/main.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/acpi/main.c [iso-8859-1] Wed Mar 17 06:30:22 2010 @@ -6,7 +6,7 @@ #include <acpi_bus.h> #include <acpi_drivers.h> -//#define NDEBUG +#define NDEBUG #include <debug.h> #ifdef ALLOC_PRAGMA @@ -35,7 +35,7 @@ DPRINT("Add Device: 0x%p\n", PhysicalDeviceObject); - DPRINT1("#################### Bus_CreateClose Creating FDO Device ####################\n"); + DPRINT("#################### Bus_CreateClose Creating FDO Device ####################\n"); status = IoCreateDevice(DriverObject, sizeof(FDO_DEVICE_DATA), NULL, @@ -134,7 +134,7 @@ goto End; } - DPRINT1("AddDevice: %p to %p->%p (%ws) \n", + DPRINT("AddDevice: %p to %p->%p (%ws) \n", deviceObject, deviceData->NextLowerDriver, PhysicalDeviceObject, Modified: trunk/reactos/drivers/bus/acpi/osl.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/osl.c?rev…
============================================================================== --- trunk/reactos/drivers/bus/acpi/osl.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/acpi/osl.c [iso-8859-1] Wed Mar 17 06:30:22 2010 @@ -90,7 +90,7 @@ ACPI_STATUS AcpiOsTerminate(void) { - DPRINT1("AcpiOsTerminate() called\n"); + DPRINT("AcpiOsTerminate() called\n"); if (AcpiInterruptHandlerRegistered) AcpiOsRemoveInterruptHandler(AcpiIrqNumber, AcpiIrqHandler); @@ -329,7 +329,7 @@ void AcpiOsStall (UINT32 microseconds) { - DPRINT1("AcpiOsStall %d\n",microseconds); + DPRINT("AcpiOsStall %d\n",microseconds); KeStallExecutionProcessor(microseconds); return; } @@ -337,7 +337,7 @@ void AcpiOsSleep (ACPI_INTEGER milliseconds) { - DPRINT1("AcpiOsSleep %d\n", milliseconds); + DPRINT("AcpiOsSleep %d\n", milliseconds); KeStallExecutionProcessor(milliseconds*1000); return; } @@ -664,7 +664,7 @@ ACPI_OSD_EXEC_CALLBACK Function, void *Context) { - DPRINT1("AcpiOsExecute\n"); + DPRINT("AcpiOsExecute\n"); KeInsertQueueDpc(&AcpiDpc, (PVOID)Function, (PVOID)Context); Modified: trunk/reactos/drivers/bus/acpi/pnp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/pnp.c?rev…
============================================================================== --- trunk/reactos/drivers/bus/acpi/pnp.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/acpi/pnp.c [iso-8859-1] Wed Mar 17 06:30:22 2010 @@ -7,7 +7,7 @@ #include <acpi_drivers.h> #include <wdmguid.h> -//#define NDEBUG +#define NDEBUG #include <debug.h> #ifdef ALLOC_PRAGMA Modified: trunk/reactos/drivers/bus/acpi/power.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/power.c?r…
============================================================================== --- trunk/reactos/drivers/bus/acpi/power.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/acpi/power.c [iso-8859-1] Wed Mar 17 06:30:22 2010 @@ -6,7 +6,7 @@ #include <acpi_bus.h> #include <acpi_drivers.h> -//#define NDEBUG +#define NDEBUG #include <debug.h> NTSTATUS
14 years, 9 months
1
0
0
0
[cgutman] 46237: - Add a hack to disable ACPI if VMware is detected - This hack circumvents the main blocker that prevents enabling ACPI in trunk
by cgutman@svn.reactos.org
Author: cgutman Date: Wed Mar 17 06:02:06 2010 New Revision: 46237 URL:
http://svn.reactos.org/svn/reactos?rev=46237&view=rev
Log: - Add a hack to disable ACPI if VMware is detected - This hack circumvents the main blocker that prevents enabling ACPI in trunk Modified: trunk/reactos/drivers/bus/acpi/acpica/tables/tbutils.c Modified: trunk/reactos/drivers/bus/acpi/acpica/tables/tbutils.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/acpi/acpica/ta…
============================================================================== --- trunk/reactos/drivers/bus/acpi/acpica/tables/tbutils.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/acpi/acpica/tables/tbutils.c [iso-8859-1] Wed Mar 17 06:02:06 2010 @@ -592,6 +592,7 @@ UINT32 Length; UINT8 *TableEntry; ACPI_STATUS Status; + ACPI_TABLE_HEADER LocalHeader; ACPI_FUNCTION_TRACE (TbParseRootTable); @@ -645,6 +646,14 @@ } AcpiTbPrintTableHeader (Address, Table); + + AcpiTbCleanupTableHeader (&LocalHeader, Table); + if (strstr(LocalHeader.AslCompilerId, "VMW")) + { + ACPI_ERROR ((AE_INFO, "VMware detected; ACPI has been disabled\n")); + AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); + return_ACPI_STATUS (AE_ERROR); + } /* Get the length of the full table, verify length and map entire table */
14 years, 9 months
1
0
0
0
[cwittich] 46236: [USER32] reduce diff to wine
by cwittich@svn.reactos.org
Author: cwittich Date: Wed Mar 17 01:11:31 2010 New Revision: 46236 URL:
http://svn.reactos.org/svn/reactos?rev=46236&view=rev
Log: [USER32] reduce diff to wine Modified: trunk/reactos/dll/win32/user32/windows/menu.c Modified: trunk/reactos/dll/win32/user32/windows/menu.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/m…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/menu.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/menu.c [iso-8859-1] Wed Mar 17 01:11:31 2010 @@ -57,7 +57,7 @@ /* Use global popup window because there's no way 2 menus can * be tracked at the same time. */ -static HWND TopPopup; +static HWND top_popup; /* Flag set by EndMenu() to force an exit from menu tracking */ static BOOL fEndMenu = FALSE; @@ -347,6 +347,49 @@ SelectObject(dc, hOldFont); SetBkMode(dc, bkmode); DeleteObject(hFont); +} + +/*********************************************************************** + * MenuFindSubMenu + * + * Find a Sub menu. Return the position of the submenu, and modifies + * *hmenu in case it is found in another sub-menu. + * If the submenu cannot be found, NO_SELECTED_ITEM is returned. + */ +static UINT FASTCALL MenuFindSubMenu(HMENU *hmenu, HMENU hSubTarget ) +{ + ROSMENUINFO menu; + UINT i; + ROSMENUITEMINFO item; + + if (((*hmenu)==(HMENU)0xffff) || + (!MenuGetRosMenuInfo(&menu, *hmenu))) + return NO_SELECTED_ITEM; + + MenuInitRosMenuItemInfo(&item); + for (i = 0; i < menu.MenuItemCount; i++) + { + if (! MenuGetRosMenuItemInfo(menu.Self, i, &item)) + { + MenuCleanupRosMenuItemInfo(&item); + return NO_SELECTED_ITEM; + } + if (!(item.fType & MF_POPUP)) continue; + if (item.hSubMenu == hSubTarget) { + MenuCleanupRosMenuItemInfo(&item); + return i; + } + else { + HMENU hsubmenu = item.hSubMenu; + UINT pos = MenuFindSubMenu(&hsubmenu, hSubTarget ); + if (pos != NO_SELECTED_ITEM) { + *hmenu = hsubmenu; + return pos; + } + } + } + MenuCleanupRosMenuItemInfo(&item); + return NO_SELECTED_ITEM; } /*********************************************************************** @@ -1482,8 +1525,8 @@ hwndOwner, 0, (HINSTANCE) GetWindowLongPtrW(hwndOwner, GWLP_HINSTANCE), (LPVOID) MenuInfo.Self); if ( !MenuInfo.Wnd || ! MenuSetRosMenuInfo(&MenuInfo)) return FALSE; - if (!TopPopup) { - TopPopup = MenuInfo.Wnd; + if (!top_popup) { + top_popup = MenuInfo.Wnd; } /* Display the window */ @@ -1494,8 +1537,156 @@ return TRUE; } -LRESULT WINAPI -PopupMenuWndProcA(HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam) +/*********************************************************************** + * MenuSelectItem + */ +static void FASTCALL MenuSelectItem(HWND hwndOwner, PROSMENUINFO hmenu, UINT wIndex, + BOOL sendMenuSelect, HMENU topmenu) +{ + ROSMENUITEMINFO ItemInfo; + ROSMENUINFO TopMenuInfo; + HDC hdc; + + TRACE("owner=%p menu=%p index=0x%04x select=0x%04x\n", hwndOwner, hmenu, wIndex, sendMenuSelect); + + if (!hmenu || !hmenu->MenuItemCount || !hmenu->Wnd) return; + if (hmenu->FocusedItem == wIndex) return; + if (hmenu->Flags & MF_POPUP) hdc = GetDC(hmenu->Wnd); + else hdc = GetDCEx(hmenu->Wnd, 0, DCX_CACHE | DCX_WINDOW); + if (!top_popup) { + top_popup = hmenu->Wnd; + } + + SelectObject( hdc, hMenuFont ); + + MenuInitRosMenuItemInfo(&ItemInfo); + + /* Clear previous highlighted item */ + if (hmenu->FocusedItem != NO_SELECTED_ITEM) + { + if (MenuGetRosMenuItemInfo(hmenu->Self, hmenu->FocusedItem, &ItemInfo)) + { + ItemInfo.fMask |= MIIM_STATE; + ItemInfo.fState &= ~(MF_HILITE|MF_MOUSESELECT); + MenuSetRosMenuItemInfo(hmenu->Self, hmenu->FocusedItem, &ItemInfo); + } + MenuDrawMenuItem(hmenu->Wnd, hmenu, hwndOwner, hdc, &ItemInfo, + hmenu->Height, ! (hmenu->Flags & MF_POPUP), + ODA_SELECT); + } + + /* Highlight new item (if any) */ + hmenu->FocusedItem = wIndex; + MenuSetRosMenuInfo(hmenu); + if (hmenu->FocusedItem != NO_SELECTED_ITEM) + { + if (MenuGetRosMenuItemInfo(hmenu->Self, hmenu->FocusedItem, &ItemInfo)) + { + if (!(ItemInfo.fType & MF_SEPARATOR)) + { + ItemInfo.fMask |= MIIM_STATE; + ItemInfo.fState |= MF_HILITE; + MenuSetRosMenuItemInfo(hmenu->Self, hmenu->FocusedItem, &ItemInfo); + MenuDrawMenuItem(hmenu->Wnd, hmenu, hwndOwner, hdc, + &ItemInfo, hmenu->Height, ! (hmenu->Flags & MF_POPUP), + ODA_SELECT); + } + if (sendMenuSelect) + { + SendMessageW(hwndOwner, WM_MENUSELECT, + MAKELONG(ItemInfo.fType & MF_POPUP ? wIndex : ItemInfo.wID, + ItemInfo.fType | ItemInfo.fState | MF_MOUSESELECT | + (hmenu->Flags & MF_SYSMENU)), (LPARAM) hmenu->Self); + } + } + } + else if (sendMenuSelect) { + if(topmenu) { + int pos; + pos = MenuFindSubMenu(&topmenu, hmenu->Self); + if (pos != NO_SELECTED_ITEM) + { + if (MenuGetRosMenuInfo(&TopMenuInfo, topmenu) + && MenuGetRosMenuItemInfo(topmenu, pos, &ItemInfo)) + { + SendMessageW(hwndOwner, WM_MENUSELECT, + MAKELONG(Pos, ItemInfo.fType | ItemInfo.fState + | MF_MOUSESELECT + | (TopMenuInfo.Flags & MF_SYSMENU)), + (LPARAM) topmenu); + } + } + } + } + MenuCleanupRosMenuItemInfo(&ItemInfo); + ReleaseDC(hmenu->Wnd, hdc); +} + +/*********************************************************************** + * MenuMoveSelection + * + * Moves currently selected item according to the Offset parameter. + * If there is no selection then it should select the last item if + * Offset is ITEM_PREV or the first item if Offset is ITEM_NEXT. + */ +static void FASTCALL +MenuMoveSelection(HWND WndOwner, PROSMENUINFO MenuInfo, INT Offset) +{ + INT i; + ROSMENUITEMINFO ItemInfo; + INT OrigPos; + + TRACE("hwnd=%x menu=%x off=0x%04x\n", WndOwner, MenuInfo, Offset); + + /* Prevent looping */ + if (0 == MenuInfo->MenuItemCount || 0 == Offset) + return; + else if (Offset < -1) + Offset = -1; + else if (Offset > 1) + Offset = 1; + + MenuInitRosMenuItemInfo(&ItemInfo); + + OrigPos = MenuInfo->FocusedItem; + if (OrigPos == NO_SELECTED_ITEM) /* NO_SELECTED_ITEM is not -1 ! */ + { + OrigPos = 0; + i = -1; + } + else + { + i = MenuInfo->FocusedItem; + } + + do + { + /* Step */ + i += Offset; + /* Clip and wrap around */ + if (i < 0) + { + i = MenuInfo->MenuItemCount - 1; + } + else if (i >= MenuInfo->MenuItemCount) + { + i = 0; + } + /* If this is a good candidate; */ + if (MenuGetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo) && + 0 == (ItemInfo.fType & MF_SEPARATOR)) + { + MenuSelectItem(WndOwner, MenuInfo, i, TRUE, NULL); + MenuCleanupRosMenuItemInfo(&ItemInfo); + return; + } + } while (i != OrigPos); + + /* Not found */ + MenuCleanupRosMenuItemInfo(&ItemInfo); +} + +LRESULT WINAPI PopupMenuWndProcA(HWND Wnd, UINT Message, WPARAM wParam, LPARAM lParam) { TRACE("YES! hwnd=%x msg=0x%04x wp=0x%04lx lp=0x%08lx\n", Wnd, Message, wParam, lParam); @@ -1532,9 +1723,9 @@ case WM_DESTROY: /* zero out global pointer in case resident popup window was destroyed. */ - if (Wnd == TopPopup) - { - TopPopup = NULL; + if (Wnd == top_popup) + { + top_popup = NULL; } break; @@ -1604,9 +1795,9 @@ case WM_DESTROY: /* zero out global pointer in case resident popup window was destroyed. */ - if (Wnd == TopPopup) - { - TopPopup = NULL; + if (Wnd == top_popup) + { + top_popup = NULL; } break; @@ -1640,140 +1831,134 @@ } /********************************************************************** + * MENU_ParseResource + * + * Parse a standard menu resource and add items to the menu. + * Return a pointer to the end of the resource. + * + * NOTE: flags is equivalent to the mtOption field + */ +static LPCSTR MENU_ParseResource( LPCSTR res, HMENU hMenu, BOOL unicode ) +{ + WORD flags, id = 0; + HMENU hSubMenu; + LPCSTR str; + BOOL end = FALSE; + + do + { + flags = GET_WORD(res); + + /* remove MF_END flag before passing it to AppendMenu()! */ + end = (flags & MF_END); + if(end) flags ^= MF_END; + + res += sizeof(WORD); + if(!(flags & MF_POPUP)) + { + id = GET_WORD(res); + res += sizeof(WORD); + } + str = res; + if(!unicode) + res += strlen(str) + 1; + else + res += (strlenW((LPCWSTR)str) + 1) * sizeof(WCHAR); + if (flags & MF_POPUP) + { + hSubMenu = CreatePopupMenu(); + if(!hSubMenu) return NULL; + if(!(res = MENU_ParseResource(res, hSubMenu, unicode))) + return NULL; + if(!unicode) + AppendMenuA(hMenu, flags, (UINT)hSubMenu, str); + else + AppendMenuW(hMenu, flags, (UINT)hSubMenu, (LPCWSTR)str); + } + else /* Not a popup */ + { + if(!unicode) + { + if (*str == 0) + flags = MF_SEPARATOR; + } + else + { + if (*(LPCWSTR)str == 0) + flags = MF_SEPARATOR; + } + + if (flags & MF_SEPARATOR) + { + if (!(flags & (MF_GRAYED | MF_DISABLED))) + flags |= MF_GRAYED | MF_DISABLED; + } + + if(!unicode) + AppendMenuA(hMenu, flags, id, *str ? str : NULL); + else + AppendMenuW(hMenu, flags, id, + *(LPCWSTR)str ? (LPCWSTR)str : NULL); + } + } while(!end); + return res; +} + + +/********************************************************************** * MENUEX_ParseResource * * Parse an extended menu resource and add items to the menu. * Return a pointer to the end of the resource. - * - * FIXME - should we be passing an LPCSTR to a predominantly UNICODE function? */ static LPCSTR MENUEX_ParseResource( LPCSTR res, HMENU hMenu) { - WORD resinfo; - - do - { - MENUITEMINFOW mii; - - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_STATE | MIIM_ID | MIIM_FTYPE; - mii.fType = GET_DWORD(res); - res += sizeof(DWORD); - mii.fState = GET_DWORD(res); - res += sizeof(DWORD); - mii.wID = GET_DWORD(res); - res += sizeof(DWORD); - resinfo = GET_WORD(res); - res += sizeof(WORD); - /* Align the text on a word boundary. */ - res += (~((int)res - 1)) & 1; - mii.dwTypeData = (LPWSTR) res; - res += (1 + strlenW(mii.dwTypeData)) * sizeof(WCHAR); - /* Align the following fields on a dword boundary. */ - res += (~((int)res - 1)) & 3; - - if (resinfo & 1) /* Pop-up? */ - { - /* DWORD helpid = GET_DWORD(res); FIXME: use this. */ - res += sizeof(DWORD); - mii.hSubMenu = CreatePopupMenu(); - if (!mii.hSubMenu) - return NULL; - if (!(res = MENUEX_ParseResource(res, mii.hSubMenu))) - { - DestroyMenu(mii.hSubMenu); - return NULL; - } - mii.fMask |= MIIM_SUBMENU; - mii.fType |= MF_POPUP; - mii.wID = (UINT) mii.hSubMenu; - } - else if(!*mii.dwTypeData && !(mii.fType & MF_SEPARATOR)) - { - mii.fType |= MF_SEPARATOR; - } - InsertMenuItemW(hMenu, -1, MF_BYPOSITION, &mii); - } - while (!(resinfo & MF_END)); - return res; -} - - -/********************************************************************** - * MENU_ParseResource - * - * Parse a standard menu resource and add items to the menu. - * Return a pointer to the end of the resource. - * - * NOTE: flags is equivalent to the mtOption field - */ -static LPCSTR MENU_ParseResource( LPCSTR res, HMENU hMenu, BOOL unicode ) -{ - WORD flags, id = 0; - HMENU hSubMenu; - LPCSTR str; - BOOL end = FALSE; - - do - { - flags = GET_WORD(res); - - /* remove MF_END flag before passing it to AppendMenu()! */ - end = (flags & MF_END); - if(end) flags ^= MF_END; - - res += sizeof(WORD); - if(!(flags & MF_POPUP)) - { - id = GET_WORD(res); - res += sizeof(WORD); - } - str = res; - if(!unicode) - res += strlen(str) + 1; - else - res += (strlenW((LPCWSTR)str) + 1) * sizeof(WCHAR); - if (flags & MF_POPUP) - { - hSubMenu = CreatePopupMenu(); - if(!hSubMenu) return NULL; - if(!(res = MENU_ParseResource(res, hSubMenu, unicode))) - return NULL; - if(!unicode) - AppendMenuA(hMenu, flags, (UINT)hSubMenu, str); - else - AppendMenuW(hMenu, flags, (UINT)hSubMenu, (LPCWSTR)str); - } - else /* Not a popup */ - { - if(!unicode) - { - if (*str == 0) - flags = MF_SEPARATOR; - } - else - { - if (*(LPCWSTR)str == 0) - flags = MF_SEPARATOR; - } - - if (flags & MF_SEPARATOR) - { - if (!(flags & (MF_GRAYED | MF_DISABLED))) - flags |= MF_GRAYED | MF_DISABLED; - } - - if(!unicode) - AppendMenuA(hMenu, flags, id, *str ? str : NULL); - else - AppendMenuW(hMenu, flags, id, - *(LPCWSTR)str ? (LPCWSTR)str : NULL); - } - } while(!end); - - return res; -} - + WORD resinfo; + do { + MENUITEMINFOW mii; + + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_STATE | MIIM_ID | MIIM_FTYPE; + mii.fType = GET_DWORD(res); + res += sizeof(DWORD); + mii.fState = GET_DWORD(res); + res += sizeof(DWORD); + mii.wID = GET_DWORD(res); + res += sizeof(DWORD); + resinfo = GET_WORD(res); + res += sizeof(WORD); + /* Align the text on a word boundary. */ + res += (~((UINT_PTR)res - 1)) & 1; + mii.dwTypeData = (LPWSTR) res; + res += (1 + strlenW(mii.dwTypeData)) * sizeof(WCHAR); + /* Align the following fields on a dword boundary. */ + res += (~((UINT_PTR)res - 1)) & 3; + + TRACE("Menu item: [%08x,%08x,%04x,%04x,%S]\n", + mii.fType, mii.fState, mii.wID, resinfo, mii.dwTypeData); + + if (resinfo & 1) { /* Pop-up? */ + /* DWORD helpid = GET_DWORD(res); FIXME: use this. */ + res += sizeof(DWORD); + mii.hSubMenu = CreatePopupMenu(); + if (!mii.hSubMenu) + return NULL; + if (!(res = MENUEX_ParseResource(res, mii.hSubMenu))) { + DestroyMenu(mii.hSubMenu); + return NULL; + } + mii.fMask |= MIIM_SUBMENU; + mii.fType |= MF_POPUP; + mii.wID = (UINT) mii.hSubMenu; + } + else if(!*mii.dwTypeData && !(mii.fType & MF_SEPARATOR)) + { + mii.fType |= MF_SEPARATOR; + } + InsertMenuItemW(hMenu, -1, MF_BYPOSITION, &mii); + } while (!(resinfo & MF_END)); + return res; +} NTSTATUS WINAPI User32LoadSysMenuTemplateForKernel(PVOID Arguments, ULONG ArgumentLength) @@ -1936,272 +2121,6 @@ } /*********************************************************************** - * MenuInitTracking - */ -static BOOL FASTCALL -MenuInitTracking(HWND Wnd, HMENU Menu, BOOL Popup, UINT Flags) -{ - TRACE("Wnd=%p Menu=%p\n", Wnd, Menu); - - HideCaret(0); - - /* Send WM_ENTERMENULOOP and WM_INITMENU message only if TPM_NONOTIFY flag is not specified */ - if (0 == (Flags & TPM_NONOTIFY)) - { - SendMessageW(Wnd, WM_ENTERMENULOOP, Popup, 0); - } - - SendMessageW(Wnd, WM_SETCURSOR, (WPARAM) Wnd, HTCAPTION); - - if (0 == (Flags & TPM_NONOTIFY)) - { - ROSMENUINFO MenuInfo; - - SendMessageW(Wnd, WM_INITMENU, (WPARAM)Menu, 0); - - MenuGetRosMenuInfo(&MenuInfo, Menu); - - if (0 == MenuInfo.Height) - { - /* app changed/recreated menu bar entries in WM_INITMENU - Recalculate menu sizes else clicks will not work */ - SetWindowPos(Wnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | - SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); - - } - /* This makes the menus of applications built with Delphi work. - * It also enables menus to be displayed in more than one window, - * but there are some bugs left that need to be fixed in this case. - */ - if(MenuInfo.Self == Menu) - { - MenuInfo.Wnd = Wnd; - MenuSetRosMenuInfo(&MenuInfo); - } - } - - return TRUE; -} - -/*********************************************************************** - * MenuFindSubMenu - * - * Find a Sub menu. Return the position of the submenu, and modifies - * *hmenu in case it is found in another sub-menu. - * If the submenu cannot be found, NO_SELECTED_ITEM is returned. - */ -static UINT FASTCALL -MenuFindSubMenu(HMENU *Menu, HMENU SubTarget) -{ - ROSMENUINFO MenuInfo; - ROSMENUITEMINFO ItemInfo; - UINT i; - HMENU SubMenu; - UINT Pos; - - if ((HMENU) 0xffff == *Menu - || ! MenuGetRosMenuInfo(&MenuInfo, *Menu)) - { - return NO_SELECTED_ITEM; - } - - MenuInitRosMenuItemInfo(&ItemInfo); - for (i = 0; i < MenuInfo.MenuItemCount; i++) - { - if (! MenuGetRosMenuItemInfo(MenuInfo.Self, i, &ItemInfo)) - { - MenuCleanupRosMenuItemInfo(&ItemInfo); - return NO_SELECTED_ITEM; - } - if (0 == (ItemInfo.fType & MF_POPUP)) - { - continue; - } - if (ItemInfo.hSubMenu == SubTarget) - { - MenuCleanupRosMenuItemInfo(&ItemInfo); - return i; - } - SubMenu = ItemInfo.hSubMenu; - Pos = MenuFindSubMenu(&SubMenu, SubTarget); - if (NO_SELECTED_ITEM != Pos) - { - *Menu = SubMenu; - return Pos; - } - } - MenuCleanupRosMenuItemInfo(&ItemInfo); - - return NO_SELECTED_ITEM; -} - -/*********************************************************************** - * MenuSelectItem - */ -static void FASTCALL -MenuSelectItem(HWND WndOwner, PROSMENUINFO MenuInfo, UINT Index, - BOOL SendMenuSelect, HMENU TopMenu) -{ - HDC Dc; - ROSMENUITEMINFO ItemInfo; - ROSMENUINFO TopMenuInfo; - int Pos; - - TRACE("owner=%x menu=%p index=0x%04x select=0x%04x\n", WndOwner, MenuInfo, Index, SendMenuSelect); - - if (NULL == MenuInfo || 0 == MenuInfo->MenuItemCount || NULL == MenuInfo->Wnd) - { - return; - } - - if (MenuInfo->FocusedItem == Index) - { - return; - } - - if (0 != (MenuInfo->Flags & MF_POPUP)) - { - Dc = GetDC(MenuInfo->Wnd); - } - else - { - Dc = GetDCEx(MenuInfo->Wnd, 0, DCX_CACHE | DCX_WINDOW); - } - - if (NULL == TopPopup) - { - TopPopup = MenuInfo->Wnd; - } - - SelectObject(Dc, hMenuFont); - MenuInitRosMenuItemInfo(&ItemInfo); - /* Clear previous highlighted item */ - if (NO_SELECTED_ITEM != MenuInfo->FocusedItem) - { - if (MenuGetRosMenuItemInfo(MenuInfo->Self, MenuInfo->FocusedItem, &ItemInfo)) - { - ItemInfo.fMask |= MIIM_STATE; - ItemInfo.fState &= ~(MF_HILITE|MF_MOUSESELECT); - MenuSetRosMenuItemInfo(MenuInfo->Self, MenuInfo->FocusedItem, &ItemInfo); - } - MenuDrawMenuItem(MenuInfo->Wnd, MenuInfo, WndOwner, Dc, &ItemInfo, - MenuInfo->Height, ! (MenuInfo->Flags & MF_POPUP), - ODA_SELECT); - } - - /* Highlight new item (if any) */ - MenuInfo->FocusedItem = Index; - MenuSetRosMenuInfo(MenuInfo); - if (NO_SELECTED_ITEM != MenuInfo->FocusedItem) - { - if (MenuGetRosMenuItemInfo(MenuInfo->Self, MenuInfo->FocusedItem, &ItemInfo)) - { - if (0 == (ItemInfo.fType & MF_SEPARATOR)) - { - ItemInfo.fMask |= MIIM_STATE; - ItemInfo.fState |= MF_HILITE; - MenuSetRosMenuItemInfo(MenuInfo->Self, MenuInfo->FocusedItem, &ItemInfo); - MenuDrawMenuItem(MenuInfo->Wnd, MenuInfo, WndOwner, Dc, - &ItemInfo, MenuInfo->Height, ! (MenuInfo->Flags & MF_POPUP), - ODA_SELECT); - } - if (SendMenuSelect) - { - SendMessageW(WndOwner, WM_MENUSELECT, - MAKELONG(ItemInfo.fType & MF_POPUP ? Index : ItemInfo.wID, - ItemInfo.fType | ItemInfo.fState | MF_MOUSESELECT | - (MenuInfo->Flags & MF_SYSMENU)), (LPARAM) MenuInfo->Self); - } - } - } - else if (SendMenuSelect) - { - if (NULL != TopMenu) - { - Pos = MenuFindSubMenu(&TopMenu, MenuInfo->Self); - if (NO_SELECTED_ITEM != Pos) - { - if (MenuGetRosMenuInfo(&TopMenuInfo, TopMenu) - && MenuGetRosMenuItemInfo(TopMenu, Pos, &ItemInfo)) - { - SendMessageW(WndOwner, WM_MENUSELECT, - MAKELONG(Pos, ItemInfo.fType | ItemInfo.fState - | MF_MOUSESELECT - | (TopMenuInfo.Flags & MF_SYSMENU)), - (LPARAM) TopMenu); - } - } - } - } - MenuCleanupRosMenuItemInfo(&ItemInfo); - ReleaseDC(MenuInfo->Wnd, Dc); -} - -/*********************************************************************** - * MenuMoveSelection - * - * Moves currently selected item according to the Offset parameter. - * If there is no selection then it should select the last item if - * Offset is ITEM_PREV or the first item if Offset is ITEM_NEXT. - */ -static void FASTCALL -MenuMoveSelection(HWND WndOwner, PROSMENUINFO MenuInfo, INT Offset) -{ - INT i; - ROSMENUITEMINFO ItemInfo; - INT OrigPos; - - TRACE("hwnd=%x menu=%x off=0x%04x\n", WndOwner, MenuInfo, Offset); - - /* Prevent looping */ - if (0 == MenuInfo->MenuItemCount || 0 == Offset) - return; - else if (Offset < -1) - Offset = -1; - else if (Offset > 1) - Offset = 1; - - MenuInitRosMenuItemInfo(&ItemInfo); - - OrigPos = MenuInfo->FocusedItem; - if (OrigPos == NO_SELECTED_ITEM) /* NO_SELECTED_ITEM is not -1 ! */ - { - OrigPos = 0; - i = -1; - } - else - { - i = MenuInfo->FocusedItem; - } - - do - { - /* Step */ - i += Offset; - /* Clip and wrap around */ - if (i < 0) - { - i = MenuInfo->MenuItemCount - 1; - } - else if (i >= MenuInfo->MenuItemCount) - { - i = 0; - } - /* If this is a good candidate; */ - if (MenuGetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo) && - 0 == (ItemInfo.fType & MF_SEPARATOR)) - { - MenuSelectItem(WndOwner, MenuInfo, i, TRUE, NULL); - MenuCleanupRosMenuItemInfo(&ItemInfo); - return; - } - } while (i != OrigPos); - - /* Not found */ - MenuCleanupRosMenuItemInfo(&ItemInfo); -} - -/*********************************************************************** * MenuInitSysMenuPopup * * Grey the appropriate items in System menu. @@ -2400,7 +2319,7 @@ TRACE("owner=%x menu=%x 0x%04x\n", WndOwner, MenuInfo, SendMenuSelect); - if (NULL != MenuInfo && NULL != TopPopup && NO_SELECTED_ITEM != MenuInfo->FocusedItem) + if (NULL != MenuInfo && NULL != top_popup && NO_SELECTED_ITEM != MenuInfo->FocusedItem) { MenuInitRosMenuItemInfo(&ItemInfo); ItemInfo.fMask |= MIIM_FTYPE | MIIM_STATE; @@ -3150,36 +3069,29 @@ * * Handle a VK_RIGHT key event in a menu. */ -static void FASTCALL -MenuKeyRight(MTRACKER *Mt, UINT Flags) -{ - HMENU MenuTmp; - ROSMENUINFO MenuInfo; - ROSMENUINFO CurrentMenuInfo; - UINT NextCol; - - TRACE("MenuKeyRight called, cur %p, top %p.\n", +static void FASTCALL MenuKeyRight(MTRACKER *Mt, UINT Flags) +{ + HMENU hmenutmp; + ROSMENUINFO MenuInfo; + ROSMENUINFO CurrentMenuInfo; + UINT NextCol; + + TRACE("MenuKeyRight called, cur %p, top %p.\n", Mt->CurrentMenu, Mt->TopMenu); - if (! MenuGetRosMenuInfo(&MenuInfo, Mt->TopMenu)) - { - return; - } - if (0 != (MenuInfo.Flags & MF_POPUP) || (Mt->CurrentMenu != Mt->TopMenu)) + if (! MenuGetRosMenuInfo(&MenuInfo, Mt->TopMenu)) return; + if ((MenuInfo.Flags & MF_POPUP) || (Mt->CurrentMenu != Mt->TopMenu)) { /* If already displaying a popup, try to display sub-popup */ - MenuTmp = Mt->CurrentMenu; + hmenutmp = Mt->CurrentMenu; if (MenuGetRosMenuInfo(&CurrentMenuInfo, Mt->CurrentMenu)) { Mt->CurrentMenu = MenuShowSubPopup(Mt->OwnerWnd, &CurrentMenuInfo, TRUE, Flags); } /* if subpopup was displayed then we are done */ - if (MenuTmp != Mt->CurrentMenu) - { - return; - } + if (hmenutmp != Mt->CurrentMenu) return; } if (! MenuGetRosMenuInfo(&CurrentMenuInfo, Mt->CurrentMenu)) @@ -3203,20 +3115,18 @@ if (Mt->CurrentMenu != Mt->TopMenu) { MenuHideSubPopups(Mt->OwnerWnd, &MenuInfo, FALSE ); - MenuTmp = Mt->CurrentMenu = Mt->TopMenu; + hmenutmp = Mt->CurrentMenu = Mt->TopMenu; } else { - MenuTmp = NULL; + hmenutmp = NULL; } /* try to move to the next item */ - if (! MenuDoNextMenu(Mt, VK_RIGHT)) - { + if ( !MenuDoNextMenu(Mt, VK_RIGHT)) MenuMoveSelection(Mt->OwnerWnd, &MenuInfo, ITEM_NEXT); - } - - if (NULL != MenuTmp || 0 != (Mt->TrackFlags & TF_SUSPENDPOPUP)) + + if ( hmenutmp || Mt->TrackFlags & TF_SUSPENDPOPUP ) { if (! MenuSuspendPopup(Mt, WM_KEYDOWN) && MenuGetRosMenuInfo(&MenuInfo, Mt->TopMenu)) @@ -3233,220 +3143,211 @@ * * Menu tracking code. */ -static INT FASTCALL -MenuTrackMenu(HMENU Menu, UINT Flags, INT x, INT y, - HWND Wnd, const RECT *Rect ) -{ - MSG Msg; - ROSMENUINFO MenuInfo; - ROSMENUITEMINFO ItemInfo; - BOOL fRemove; - INT ExecutedMenuId = -1; - MTRACKER Mt; - BOOL EnterIdleSent = FALSE; - - Mt.TrackFlags = 0; - Mt.CurrentMenu = Menu; - Mt.TopMenu = Menu; - Mt.OwnerWnd = Wnd; - Mt.Pt.x = x; - Mt.Pt.y = y; - - TRACE("Menu=%x Flags=0x%08x (%d,%d) Wnd=%x (%ld,%ld)-(%ld,%ld)\n", - Menu, Flags, x, y, Wnd, Rect ? Rect->left : 0, Rect ? Rect->top : 0, - Rect ? Rect->right : 0, Rect ? Rect->bottom : 0); - - if (!IsMenu(Menu)) - { - SetLastError( ERROR_INVALID_MENU_HANDLE ); - return FALSE; - } - - fEndMenu = FALSE; - if (! MenuGetRosMenuInfo(&MenuInfo, Menu)) - { - return FALSE; - } - - if (0 != (Flags & TPM_BUTTONDOWN)) - { - /* Get the result in order to start the tracking or not */ - fRemove = MenuButtonDown(&Mt, Menu, Flags); - fEndMenu = ! fRemove; - } - - SetCapture(Mt.OwnerWnd); - (void)NtUserSetGUIThreadHandle(MSQ_STATE_MENUOWNER, Mt.OwnerWnd); - - ERR("MenuTrackMenu 1\n"); - while (! fEndMenu) - { - PVOID menu = ValidateHandle(Mt.CurrentMenu, VALIDATE_TYPE_MENU); - if (!menu) /* sometimes happens if I do a window manager close */ - break; - - /* we have to keep the message in the queue until it's - * clear that menu loop is not over yet. */ - - for (;;) - { - if (PeekMessageW(&Msg, 0, 0, 0, PM_NOREMOVE)) +static INT FASTCALL MenuTrackMenu(HMENU hmenu, UINT wFlags, INT x, INT y, + HWND hwnd, const RECT *lprect ) +{ + MSG msg; + ROSMENUINFO MenuInfo; + ROSMENUITEMINFO ItemInfo; + BOOL fRemove; + INT executedMenuId = -1; + MTRACKER mt; + BOOL enterIdleSent = FALSE; + + mt.TrackFlags = 0; + mt.CurrentMenu = hmenu; + mt.TopMenu = hmenu; + mt.OwnerWnd = hwnd; + mt.Pt.x = x; + mt.Pt.y = y; + + TRACE("hmenu=%p flags=0x%08x (%d,%d) hwnd=%x (%ld,%ld)-(%ld,%ld)\n", + hmenu, wFlags, x, y, hwnd, lprect ? lprect->left : 0, lprect ? lprect->top : 0, + lprect ? lprect->right : 0, lprect ? lprect->bottom : 0); + + if (!IsMenu(hmenu)) + { + SetLastError( ERROR_INVALID_MENU_HANDLE ); + return FALSE; + } + + fEndMenu = FALSE; + if (! MenuGetRosMenuInfo(&MenuInfo, hmenu)) + { + return FALSE; + } + + if (wFlags & TPM_BUTTONDOWN) + { + /* Get the result in order to start the tracking or not */ + fRemove = MenuButtonDown( &mt, hmenu, wFlags ); + fEndMenu = !fRemove; + } + + SetCapture(mt.OwnerWnd); + (void)NtUserSetGUIThreadHandle(MSQ_STATE_MENUOWNER, mt.OwnerWnd); + + ERR("MenuTrackMenu 1\n"); + while (! fEndMenu) + { + PVOID menu = ValidateHandle(mt.CurrentMenu, VALIDATE_TYPE_MENU); + if (!menu) /* sometimes happens if I do a window manager close */ + break; + + /* we have to keep the message in the queue until it's + * clear that menu loop is not over yet. */ + + for (;;) + { + if (PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE )) { - if (! CallMsgFilterW(&Msg, MSGF_MENU)) + if (!CallMsgFilterW( &msg, MSGF_MENU )) break; + /* remove the message from the queue */ + PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE ); + } + else + { + if (!enterIdleSent) { - break; + HWND win = (wFlags & TPM_ENTERIDLEEX) && (MenuInfo.Flags & MF_POPUP) ? MenuInfo.Wnd : NULL; + enterIdleSent = TRUE; + SendMessageW( mt.OwnerWnd, WM_ENTERIDLE, MSGF_MENU, (LPARAM) win); } - /* remove the message from the queue */ - PeekMessageW(&Msg, 0, Msg.message, Msg.message, PM_REMOVE ); + WaitMessage(); } - else + } + + /* check if EndMenu() tried to cancel us, by posting this message */ + if (msg.message == WM_CANCELMODE) + { + /* we are now out of the loop */ + fEndMenu = TRUE; + + /* remove the message from the queue */ + PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE ); + + /* break out of internal loop, ala ESCAPE */ + break; + } + + TranslateMessage( &msg ); + mt.Pt = msg.pt; + + if ( (msg.hwnd == MenuInfo.Wnd) || (msg.message!=WM_TIMER) ) + enterIdleSent=FALSE; + + fRemove = FALSE; + if ((msg.message >= WM_MOUSEFIRST) && (msg.message <= WM_MOUSELAST)) + { + /* + * Use the mouse coordinates in lParam instead of those in the MSG + * struct to properly handle synthetic messages. They are already + * in screen coordinates. + */ + mt.Pt.x = (short)LOWORD(msg.lParam); + mt.Pt.y = (short)HIWORD(msg.lParam); + + /* Find a menu for this mouse event */ + hmenu = MenuPtMenu(mt.TopMenu, mt.Pt); + + switch(msg.message) { - if (! EnterIdleSent) - { - HWND Win = (0 != (Flags & TPM_ENTERIDLEEX) - && 0 != (MenuInfo.Flags & MF_POPUP)) ? MenuInfo.Wnd : NULL; - EnterIdleSent = TRUE; - SendMessageW(Mt.OwnerWnd, WM_ENTERIDLE, MSGF_MENU, (LPARAM) Win); - } - WaitMessage(); - } - } - - /* check if EndMenu() tried to cancel us, by posting this message */ - if (Msg.message == WM_CANCELMODE) - { - /* we are now out of the loop */ - fEndMenu = TRUE; - - /* remove the message from the queue */ - PeekMessageW(&Msg, 0, Msg.message, Msg.message, PM_REMOVE); - - /* break out of internal loop, ala ESCAPE */ - break; - } - - TranslateMessage(&Msg); - Mt.Pt = Msg.pt; - - if (Msg.hwnd == MenuInfo.Wnd || Msg.message != WM_TIMER) - { - EnterIdleSent = FALSE; - } - - fRemove = FALSE; - if ((Msg.message >= WM_MOUSEFIRST) && (Msg.message <= WM_MOUSELAST)) - { - /* - * Use the mouse coordinates in lParam instead of those in the MSG - * struct to properly handle synthetic messages. They are already - * in screen coordinates. - */ - Mt.Pt.x = (short) LOWORD(Msg.lParam); - Mt.Pt.y = (short) HIWORD(Msg.lParam); - - /* Find a menu for this mouse event */ - Menu = MenuPtMenu(Mt.TopMenu, Mt.Pt); - - switch(Msg.message) - { - /* no WM_NC... messages in captured state */ - - case WM_RBUTTONDBLCLK: - case WM_RBUTTONDOWN: - if (!(Flags & TPM_RIGHTBUTTON)) break; + /* no WM_NC... messages in captured state */ + + case WM_RBUTTONDBLCLK: + case WM_RBUTTONDOWN: + if (!(wFlags & TPM_RIGHTBUTTON)) break; /* fall through */ - case WM_LBUTTONDBLCLK: - case WM_LBUTTONDOWN: + case WM_LBUTTONDBLCLK: + case WM_LBUTTONDOWN: /* If the message belongs to the menu, removes it from the queue */ /* Else, end menu tracking */ - fRemove = MenuButtonDown(&Mt, Menu, Flags); - fEndMenu = ! fRemove; + fRemove = MenuButtonDown(&mt, hmenu, wFlags); + fEndMenu = !fRemove; break; - case WM_RBUTTONUP: - if (0 == (Flags & TPM_RIGHTBUTTON)) break; + case WM_RBUTTONUP: + if (!(wFlags & TPM_RIGHTBUTTON)) break; /* fall through */ - case WM_LBUTTONUP: + case WM_LBUTTONUP: /* Check if a menu was selected by the mouse */ - if (Menu) - { - ExecutedMenuId = MenuButtonUp(&Mt, Menu, Flags); - - /* End the loop if ExecutedMenuId is an item ID */ - /* or if the job was done (ExecutedMenuId = 0). */ - fEndMenu = fRemove = (-1 != ExecutedMenuId); - } + if (hmenu) + { + executedMenuId = MenuButtonUp( &mt, hmenu, wFlags); + + /* End the loop if executedMenuId is an item ID */ + /* or if the job was done (executedMenuId = 0). */ + fEndMenu = fRemove = (executedMenuId != -1); + } else - { + { /* No menu was selected by the mouse */ /* if the function was called by TrackPopupMenu, continue with the menu tracking. If not, stop it */ - fEndMenu = (0 != (Flags & TPM_POPUPMENU) ? FALSE : TRUE); - } + fEndMenu = ((wFlags & TPM_POPUPMENU) ? FALSE : TRUE); + } break; - case WM_MOUSEMOVE: - if (Menu) - { - fEndMenu |= !MenuMouseMove(&Mt, Menu, Flags); - } + case WM_MOUSEMOVE: + if (hmenu) + fEndMenu |= !MenuMouseMove(&mt, hmenu, wFlags); break; - } /* switch(Msg.message) - mouse */ - } - else if ((Msg.message >= WM_KEYFIRST) && (Msg.message <= WM_KEYLAST)) + } /* switch(Msg.message) - mouse */ + } + else if ((msg.message >= WM_KEYFIRST) && (msg.message <= WM_KEYLAST)) { fRemove = TRUE; /* Keyboard messages are always removed */ - switch(Msg.message) + switch(msg.message) { case WM_SYSKEYDOWN: case WM_KEYDOWN: - switch(Msg.wParam) + switch(msg.wParam) { case VK_MENU: fEndMenu = TRUE; break; case VK_HOME: case VK_END: - if (MenuGetRosMenuInfo(&MenuInfo, Mt.CurrentMenu)) + if (MenuGetRosMenuInfo(&MenuInfo, mt.CurrentMenu)) { - MenuSelectItem(Mt.OwnerWnd, &MenuInfo, NO_SELECTED_ITEM, + MenuSelectItem(mt.OwnerWnd, &MenuInfo, NO_SELECTED_ITEM, FALSE, 0 ); - MenuMoveSelection(Mt.OwnerWnd, &MenuInfo, - VK_HOME == Msg.wParam ? ITEM_NEXT : ITEM_PREV); + MenuMoveSelection(mt.OwnerWnd, &MenuInfo, + VK_HOME == msg.wParam ? ITEM_NEXT : ITEM_PREV); } break; case VK_UP: case VK_DOWN: /* If on menu bar, pull-down the menu */ - if (MenuGetRosMenuInfo(&MenuInfo, Mt.CurrentMenu)) + if (MenuGetRosMenuInfo(&MenuInfo, mt.CurrentMenu)) { - if (0 == (MenuInfo.Flags & MF_POPUP)) + if (!(MenuInfo.Flags & MF_POPUP)) { - if (MenuGetRosMenuInfo(&MenuInfo, Mt.TopMenu)) + if (MenuGetRosMenuInfo(&MenuInfo, mt.TopMenu)) { - Mt.CurrentMenu = MenuShowSubPopup(Mt.OwnerWnd, &MenuInfo, - TRUE, Flags); + mt.CurrentMenu = MenuShowSubPopup(mt.OwnerWnd, &MenuInfo, + TRUE, wFlags); } } else /* otherwise try to move selection */ { - MenuMoveSelection(Mt.OwnerWnd, &MenuInfo, - VK_DOWN == Msg.wParam ? ITEM_NEXT : ITEM_PREV); + MenuMoveSelection(mt.OwnerWnd, &MenuInfo, + VK_DOWN == msg.wParam ? ITEM_NEXT : ITEM_PREV); } } break; case VK_LEFT: - MenuKeyLeft(&Mt, Flags); + MenuKeyLeft(&mt, wFlags); break; case VK_RIGHT: - MenuKeyRight(&Mt, Flags); + MenuKeyRight(&mt, wFlags); break; case VK_ESCAPE: - fEndMenu = MenuKeyEscape(&Mt, Flags); + fEndMenu = MenuKeyEscape(&mt, wFlags); break; case VK_F1: @@ -3454,12 +3355,9 @@ HELPINFO hi; hi.cbSize = sizeof(HELPINFO); hi.iContextType = HELPINFO_MENUITEM; - if (MenuGetRosMenuInfo(&MenuInfo, Mt.CurrentMenu)) + if (MenuGetRosMenuInfo(&MenuInfo, mt.CurrentMenu)) { - if (NO_SELECTED_ITEM == MenuInfo.FocusedItem) - { - hi.iCtrlId = 0; - } + if (MenuInfo.FocusedItem == NO_SELECTED_ITEM) hi.iCtrlId = 0; else { MenuInitRosMenuItemInfo(&ItemInfo); @@ -3476,10 +3374,10 @@ MenuCleanupRosMenuItemInfo(&ItemInfo); } } - hi.hItemHandle = Menu; - hi.dwContextId = MenuInfo.dwContextHelpID; - hi.MousePos = Msg.pt; - SendMessageW(Wnd, WM_HELP, 0, (LPARAM) &hi); + hi.hItemHandle = hmenu; + hi.dwContextId = MenuInfo.dwContextHelpID; + hi.MousePos = msg.pt; + SendMessageW(hwnd, WM_HELP, 0, (LPARAM) &hi); break; } @@ -3488,187 +3386,218 @@ } break; /* WM_KEYDOWN */ - case WM_CHAR: - case WM_SYSCHAR: + case WM_CHAR: + case WM_SYSCHAR: { - UINT Pos; - - if (! MenuGetRosMenuInfo(&MenuInfo, Mt.CurrentMenu)) + UINT pos; + + if (! MenuGetRosMenuInfo(&MenuInfo, mt.CurrentMenu)) break; + if (msg.wParam == L'\r' || msg.wParam == L' ') { - break; + executedMenuId = MenuExecFocusedItem(&mt, &MenuInfo, wFlags); + fEndMenu = (executedMenuId != -2); + break; } - if (L'\r' == Msg.wParam || L' ' == Msg.wParam) + + /* Hack to avoid control chars. */ + /* We will find a better way real soon... */ + if (msg.wParam < 32) break; + + pos = MenuFindItemByKey(mt.OwnerWnd, &MenuInfo, + LOWORD(msg.wParam), FALSE); + if (pos == (UINT)-2) fEndMenu = TRUE; + else if (pos == (UINT)-1) MessageBeep(0); + else { - ExecutedMenuId = MenuExecFocusedItem(&Mt, &MenuInfo, Flags); - fEndMenu = (ExecutedMenuId != -2); - break; + MenuSelectItem(mt.OwnerWnd, &MenuInfo, pos, + TRUE, 0); + executedMenuId = MenuExecFocusedItem(&mt, &MenuInfo, wFlags); + fEndMenu = (executedMenuId != -2); } - - /* Hack to avoid control chars. */ - /* We will find a better way real soon... */ - if (Msg.wParam < 32) - { - break; - } - - Pos = MenuFindItemByKey(Mt.OwnerWnd, &MenuInfo, - LOWORD(Msg.wParam), FALSE); - if ((UINT) -2 == Pos) - { - fEndMenu = TRUE; - } - else if ((UINT) -1 == Pos) - { - MessageBeep(0); - } - else - { - MenuSelectItem(Mt.OwnerWnd, &MenuInfo, Pos, TRUE, 0); - ExecutedMenuId = MenuExecFocusedItem(&Mt, &MenuInfo, Flags); - fEndMenu = (-2 != ExecutedMenuId); - } - } - break; + } + break; } /* switch(msg.message) - kbd */ } - else - { - PeekMessageW( &Msg, 0, Msg.message, Msg.message, PM_REMOVE ); - DispatchMessageW(&Msg); - continue; - } - - if (! fEndMenu) - { - fRemove = TRUE; - } - - /* finally remove message from the queue */ - - if (fRemove && 0 == (Mt.TrackFlags & TF_SKIPREMOVE)) - { - PeekMessageW(&Msg, 0, Msg.message, Msg.message, PM_REMOVE); - } - else - { - Mt.TrackFlags &= ~TF_SKIPREMOVE; - } - } - ERR("MenuTrackMenu 2\n"); - - (void)NtUserSetGUIThreadHandle(MSQ_STATE_MENUOWNER, NULL); - SetCapture(NULL); /* release the capture */ - - /* If dropdown is still painted and the close box is clicked on - then the menu will be destroyed as part of the DispatchMessage above. - This will then invalidate the menu handle in Mt.hTopMenu. We should - check for this first. */ - if (IsMenu(Mt.TopMenu)) - { - if (IsWindow(Mt.OwnerWnd)) - { - if (MenuGetRosMenuInfo(&MenuInfo, Mt.TopMenu)) + else + { + PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE ); + DispatchMessageW( &msg ); + continue; + } + + if (!fEndMenu) fRemove = TRUE; + + /* finally remove message from the queue */ + + if (fRemove && !(mt.TrackFlags & TF_SKIPREMOVE) ) + PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE ); + else mt.TrackFlags &= ~TF_SKIPREMOVE; + } + + (void)NtUserSetGUIThreadHandle(MSQ_STATE_MENUOWNER, NULL); + SetCapture(NULL); /* release the capture */ + + /* If dropdown is still painted and the close box is clicked on + then the menu will be destroyed as part of the DispatchMessage above. + This will then invalidate the menu handle in mt.hTopMenu. We should + check for this first. */ + if( IsMenu( mt.TopMenu ) ) + { + if (IsWindow(mt.OwnerWnd)) + { + if (MenuGetRosMenuInfo(&MenuInfo, mt.TopMenu)) { - MenuHideSubPopups(Mt.OwnerWnd, &MenuInfo, FALSE); - - if (0 != (MenuInfo.Flags & MF_POPUP)) + MenuHideSubPopups(mt.OwnerWnd, &MenuInfo, FALSE); + + if (MenuInfo.Flags & MF_POPUP) { - DestroyWindow(MenuInfo.Wnd); - MenuInfo.Wnd = NULL; - - if (!(MenuInfo.Flags & TPM_NONOTIFY)) - SendMessageW( Mt.OwnerWnd, WM_UNINITMENUPOPUP, (WPARAM)Mt.TopMenu, + DestroyWindow(MenuInfo.Wnd); + MenuInfo.Wnd = NULL; + + if (!(MenuInfo.Flags & TPM_NONOTIFY)) + SendMessageW( mt.OwnerWnd, WM_UNINITMENUPOPUP, (WPARAM)mt.TopMenu, MAKELPARAM(0, IS_SYSTEM_MENU(&MenuInfo)) ); } - MenuSelectItem(Mt.OwnerWnd, &MenuInfo, NO_SELECTED_ITEM, FALSE, NULL); + MenuSelectItem( mt.OwnerWnd, &MenuInfo, NO_SELECTED_ITEM, FALSE, 0 ); } - SendMessageW(Mt.OwnerWnd, WM_MENUSELECT, MAKELONG(0, 0xffff), 0); - } - - if (MenuGetRosMenuInfo(&MenuInfo, Mt.TopMenu)) - { - /* Reset the variable for hiding menu */ - MenuInfo.TimeToHide = FALSE; - MenuSetRosMenuInfo(&MenuInfo); - } - } - - /* The return value is only used by TrackPopupMenu */ - if (!(Flags & TPM_RETURNCMD)) return TRUE; - if (ExecutedMenuId < 0) ExecutedMenuId = 0; - return ExecutedMenuId; -} - + SendMessageW( mt.OwnerWnd, WM_MENUSELECT, MAKEWPARAM(0, 0xffff), 0 ); + } + + /* Reset the variable for hiding menu */ + if (MenuGetRosMenuInfo(&MenuInfo, mt.TopMenu)) + { + MenuInfo.TimeToHide = FALSE; + MenuSetRosMenuInfo(&MenuInfo); + } + } + + /* The return value is only used by TrackPopupMenu */ + if (!(wFlags & TPM_RETURNCMD)) return TRUE; + if (executedMenuId == -1) executedMenuId = 0; + return executedMenuId; +} + +/*********************************************************************** + * MenuInitTracking + */ +static BOOL FASTCALL MenuInitTracking(HWND hWnd, HMENU hMenu, BOOL bPopup, UINT wFlags) +{ + ROSMENUINFO MenuInfo; + + TRACE("hwnd=%p hmenu=%p\n", hWnd, hMenu); + + HideCaret(0); + + /* Send WM_ENTERMENULOOP and WM_INITMENU message only if TPM_NONOTIFY flag is not specified */ + if (!(wFlags & TPM_NONOTIFY)) + SendMessageW( hWnd, WM_ENTERMENULOOP, bPopup, 0 ); + + SendMessageW( hWnd, WM_SETCURSOR, (WPARAM)hWnd, HTCAPTION ); + + if (!(wFlags & TPM_NONOTIFY)) + { + SendMessageW( hWnd, WM_INITMENU, (WPARAM)hMenu, 0 ); + + MenuGetRosMenuInfo(&MenuInfo, hMenu); + + if (!MenuInfo.Height) + { + /* app changed/recreated menu bar entries in WM_INITMENU + Recalculate menu sizes else clicks will not work */ + SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | + SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED ); + + } + /* This makes the menus of applications built with Delphi work. + * It also enables menus to be displayed in more than one window, + * but there are some bugs left that need to be fixed in this case. + */ + if(MenuInfo.Self == hMenu) + { + MenuInfo.Wnd = hWnd; + MenuSetRosMenuInfo(&MenuInfo); + } + } + + return TRUE; +} /*********************************************************************** * MenuExitTracking */ -static BOOL FASTCALL -MenuExitTracking(HWND Wnd) -{ - TRACE("hwnd=%p\n", Wnd); - - SendMessageW(Wnd, WM_EXITMENULOOP, 0, 0); - ShowCaret(0); - return TRUE; -} - - -VOID -MenuTrackMouseMenuBar(HWND Wnd, ULONG Ht, POINT Pt) -{ - HMENU Menu = (HTSYSMENU == Ht) ? NtUserGetSystemMenu(Wnd, FALSE) : GetMenu(Wnd); - UINT Flags = TPM_ENTERIDLEEX | TPM_BUTTONDOWN | TPM_LEFTALIGN | TPM_LEFTBUTTON; - - TRACE("wnd=%p ht=0x%04x (%ld,%ld)\n", Wnd, Ht, Pt.x, Pt.y); - - if (IsMenu(Menu)) - { - /* map point to parent client coordinates */ - HWND Parent = GetAncestor(Wnd, GA_PARENT ); - if (Parent != GetDesktopWindow()) - { - ScreenToClient(Parent, &Pt); - } - - MenuInitTracking(Wnd, Menu, FALSE, Flags); - MenuTrackMenu(Menu, Flags, Pt.x, Pt.y, Wnd, NULL); - MenuExitTracking(Wnd); - } -} - - -VOID -MenuTrackKbdMenuBar(HWND hWnd, UINT wParam, WCHAR wChar) +static BOOL FASTCALL MenuExitTracking(HWND hWnd) +{ + TRACE("hwnd=%p\n", hWnd); + + SendMessageW( hWnd, WM_EXITMENULOOP, 0, 0 ); + ShowCaret(0); + top_popup = 0; + return TRUE; +} + +/*********************************************************************** + * MenuTrackMouseMenuBar + * + * Menu-bar tracking upon a mouse event. Called from NC_HandleSysCommand(). + */ +VOID MenuTrackMouseMenuBar( HWND hWnd, ULONG ht, POINT pt) +{ + HMENU hMenu = (ht == HTSYSMENU) ? NtUserGetSystemMenu( hWnd, FALSE) : GetMenu(hWnd); + UINT wFlags = TPM_ENTERIDLEEX | TPM_BUTTONDOWN | TPM_LEFTALIGN | TPM_LEFTBUTTON; + + TRACE("wnd=%p ht=0x%04x (%ld,%ld)\n", hWnd, ht, pt.x, pt.y); + + if (IsMenu(hMenu)) + { + /* map point to parent client coordinates */ + HWND Parent = GetAncestor(hWnd, GA_PARENT ); + if (Parent != GetDesktopWindow()) + { + ScreenToClient(Parent, &pt); + } + + MenuInitTracking(hWnd, hMenu, FALSE, wFlags); + MenuTrackMenu(hMenu, wFlags, pt.x, pt.y, hWnd, NULL); + MenuExitTracking(hWnd); + } +} + + +/*********************************************************************** + * MenuTrackKbdMenuBar + * + * Menu-bar tracking upon a keyboard event. Called from NC_HandleSysCommand(). + */ +VOID MenuTrackKbdMenuBar(HWND hwnd, UINT wParam, WCHAR wChar) { UINT uItem = NO_SELECTED_ITEM; HMENU hTrackMenu; ROSMENUINFO MenuInfo; UINT wFlags = TPM_ENTERIDLEEX | TPM_LEFTALIGN | TPM_LEFTBUTTON; - TRACE("hwnd %p wParam 0x%04x wChar 0x%04x\n", hWnd, wParam, wChar); + TRACE("hwnd %p wParam 0x%04x wChar 0x%04x\n", hwnd, wParam, wChar); /* find window that has a menu */ - while (!((GetWindowLongPtrW( hWnd, GWL_STYLE ) & + while (!((GetWindowLongPtrW( hwnd, GWL_STYLE ) & (WS_CHILD | WS_POPUP)) != WS_CHILD)) - if (!(hWnd = GetAncestor( hWnd, GA_PARENT ))) return; + if (!(hwnd = GetAncestor( hwnd, GA_PARENT ))) return; /* check if we have to track a system menu */ - hTrackMenu = GetMenu( hWnd ); - if (!hTrackMenu || IsIconic(hWnd) || wChar == ' ' ) - { - if (!(GetWindowLongPtrW( hWnd, GWL_STYLE ) & WS_SYSMENU)) return; - hTrackMenu = NtUserGetSystemMenu(hWnd, FALSE); + hTrackMenu = GetMenu( hwnd ); + if (!hTrackMenu || IsIconic(hwnd) || wChar == ' ' ) + { + if (!(GetWindowLongPtrW( hwnd, GWL_STYLE ) & WS_SYSMENU)) return; + hTrackMenu = NtUserGetSystemMenu(hwnd, FALSE); uItem = 0; wParam |= HTSYSMENU; /* prevent item lookup */ } if (!IsMenu( hTrackMenu )) return; - MenuInitTracking( hWnd, hTrackMenu, FALSE, wFlags ); + MenuInitTracking( hwnd, hTrackMenu, FALSE, wFlags ); if (! MenuGetRosMenuInfo(&MenuInfo, hTrackMenu)) { @@ -3677,7 +3606,7 @@ if( wChar && wChar != ' ' ) { - uItem = MenuFindItemByKey( hWnd, &MenuInfo, wChar, (wParam & HTSYSMENU) ); + uItem = MenuFindItemByKey( hwnd, &MenuInfo, wChar, (wParam & HTSYSMENU) ); if ( uItem >= (UINT)(-2) ) { if( uItem == (UINT)(-1) ) MessageBeep(0); @@ -3687,7 +3616,7 @@ } } - MenuSelectItem( hWnd, &MenuInfo, uItem, TRUE, 0 ); + MenuSelectItem( hwnd, &MenuInfo, uItem, TRUE, 0 ); if (wParam & HTSYSMENU) { @@ -3698,14 +3627,14 @@ else { if( uItem == NO_SELECTED_ITEM ) - MenuMoveSelection( hWnd, &MenuInfo, ITEM_NEXT ); + MenuMoveSelection( hwnd, &MenuInfo, ITEM_NEXT ); else - PostMessageW( hWnd, WM_KEYDOWN, VK_DOWN, 0L ); + PostMessageW( hwnd, WM_KEYDOWN, VK_DOWN, 0L ); } track_menu: - MenuTrackMenu( hTrackMenu, wFlags, 0, 0, hWnd, NULL ); - MenuExitTracking( hWnd ); + MenuTrackMenu( hTrackMenu, wFlags, 0, 0, hwnd, NULL ); + MenuExitTracking( hwnd ); }
14 years, 9 months
1
0
0
0
[akhaldi] 46235: [NTDDK] - Group related definitions - Add several missing Mm* and Se*
by akhaldi@svn.reactos.org
Author: akhaldi Date: Wed Mar 17 01:01:55 2010 New Revision: 46235 URL:
http://svn.reactos.org/svn/reactos?rev=46235&view=rev
Log: [NTDDK] - Group related definitions - Add several missing Mm* and Se* Modified: branches/header-work/include/ddk/ntddk.h Modified: branches/header-work/include/ddk/ntddk.h URL:
http://svn.reactos.org/svn/reactos/branches/header-work/include/ddk/ntddk.h…
============================================================================== --- branches/header-work/include/ddk/ntddk.h [iso-8859-1] (original) +++ branches/header-work/include/ddk/ntddk.h [iso-8859-1] Wed Mar 17 01:01:55 2010 @@ -2220,14 +2220,6 @@ (NTAPI *PEXPAND_STACK_CALLOUT) ( IN PVOID Parameter OPTIONAL); - - - - - - - - /* Kernel Functions */ #if (NTDDI_VERSION >= NTDDI_WIN2K) && defined(SINGLE_GROUP_LEGACY_API) @@ -2432,6 +2424,377 @@ KeInvalidateRangeAllCaches( IN PVOID BaseAddress, IN ULONG Length); + +typedef GUID UUID; + +/* Executive Types */ + +typedef struct _ZONE_SEGMENT_HEADER { + SINGLE_LIST_ENTRY SegmentList; + PVOID Reserved; +} ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER; + +typedef struct _ZONE_HEADER { + SINGLE_LIST_ENTRY FreeList; + SINGLE_LIST_ENTRY SegmentList; + ULONG BlockSize; + ULONG TotalSegmentSize; +} ZONE_HEADER, *PZONE_HEADER; + +#if defined(POOL_TAGGING) +#define ExFreePool(a) ExFreePoolWithTag(a,0) +#endif + +#define PROTECTED_POOL 0x80000000 + +/* Executive Functions */ + +static __inline PVOID +ExAllocateFromZone( + IN PZONE_HEADER Zone) +{ + if (Zone->FreeList.Next) + Zone->FreeList.Next = Zone->FreeList.Next->Next; + return (PVOID) Zone->FreeList.Next; +} + +static __inline PVOID +ExFreeToZone( + IN PZONE_HEADER Zone, + IN PVOID Block) +{ + ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next; + Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block); + return ((PSINGLE_LIST_ENTRY) Block)->Next; +} + +/* + * PVOID + * ExInterlockedAllocateFromZone( + * IN PZONE_HEADER Zone, + * IN PKSPIN_LOCK Lock) + */ +#define ExInterlockedAllocateFromZone(Zone, Lock) \ + ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock)) + +/* PVOID + * ExInterlockedFreeToZone( + * IN PZONE_HEADER Zone, + * IN PVOID Block, + * IN PKSPIN_LOCK Lock); + */ +#define ExInterlockedFreeToZone(Zone, Block, Lock) \ + ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock) + +/* + * BOOLEAN + * ExIsFullZone( + * IN PZONE_HEADER Zone) + */ +#define ExIsFullZone(Zone) \ + ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL) + +/* BOOLEAN + * ExIsObjectInFirstZoneSegment( + * IN PZONE_HEADER Zone, + * IN PVOID Object); + */ +#define ExIsObjectInFirstZoneSegment(Zone,Object) \ + ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \ + ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \ + (Zone)->TotalSegmentSize)) ) + +#define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite +#define ExAcquireResourceShared ExAcquireResourceSharedLite +#define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite +#define ExDeleteResource ExDeleteResourceLite +#define ExInitializeResource ExInitializeResourceLite +#define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite +#define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite +#define ExIsResourceAcquired ExIsResourceAcquiredSharedLite +#define ExReleaseResourceForThread ExReleaseResourceForThreadLite + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +NTSTATUS +NTAPI +ExExtendZone( + IN OUT PZONE_HEADER Zone, + IN OUT PVOID Segment, + IN ULONG SegmentSize); + +NTKERNELAPI +NTSTATUS +NTAPI +ExInitializeZone( + OUT PZONE_HEADER Zone, + IN ULONG BlockSize, + IN OUT PVOID InitialSegment, + IN ULONG InitialSegmentSize); + +NTKERNELAPI +NTSTATUS +NTAPI +ExInterlockedExtendZone( + IN OUT PZONE_HEADER Zone, + IN OUT PVOID Segment, + IN ULONG SegmentSize, + IN OUT PKSPIN_LOCK Lock); + +NTKERNELAPI +NTSTATUS +NTAPI +ExUuidCreate( + OUT UUID *Uuid); + +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +ExRaiseAccessViolation(VOID); + +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +ExRaiseDatatypeMisalignment(VOID); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +/* Memory Manager Types */ + +typedef struct _PHYSICAL_MEMORY_RANGE { + PHYSICAL_ADDRESS BaseAddress; + LARGE_INTEGER NumberOfBytes; +} PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE; + +typedef NTSTATUS +(*PMM_ROTATE_COPY_CALLBACK_FUNCTION) ( + IN PMDL DestinationMdl, + IN PMDL SourceMdl, + IN PVOID Context); + +typedef enum _MM_ROTATE_DIRECTION { + MmToFrameBuffer, + MmToFrameBufferNoCopy, + MmToRegularMemory, + MmToRegularMemoryNoCopy, + MmMaximumRotateDirection +} MM_ROTATE_DIRECTION, *PMM_ROTATE_DIRECTION; + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +typedef ULONG NODE_REQUIREMENT; +#define MM_ANY_NODE_OK 0x80000000 +#endif + +/* Memory Manager Functions */ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +PPHYSICAL_MEMORY_RANGE +NTAPI +MmGetPhysicalMemoryRanges(VOID); + +NTKERNELAPI +PHYSICAL_ADDRESS +NTAPI +MmGetPhysicalAddress( + IN PVOID BaseAddress); + +NTKERNELAPI +BOOLEAN +NTAPI +MmIsNonPagedSystemAddressValid( + IN PVOID VirtualAddress); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateNonCachedMemory( + IN SIZE_T NumberOfBytes); + +NTKERNELAPI +VOID +NTAPI +MmFreeNonCachedMemory( + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes); + +NTKERNELAPI +PVOID +NTAPI +MmGetVirtualForPhysical( + IN PHYSICAL_ADDRESS PhysicalAddress); + +NTKERNELAPI +NTSTATUS +NTAPI +MmMapUserAddressesToPage( + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes, + IN PVOID PageAddress); + +NTKERNELAPI +PVOID +NTAPI +MmMapVideoDisplay( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheType); + +NTKERNELAPI +NTSTATUS +NTAPI +MmMapViewInSessionSpace( + IN PVOID Section, + OUT PVOID *MappedBase, + IN OUT PSIZE_T ViewSize); + +NTKERNELAPI +NTSTATUS +NTAPI +MmMapViewInSystemSpace( + IN PVOID Section, + OUT PVOID *MappedBase, + IN OUT PSIZE_T ViewSize); + +NTKERNELAPI +BOOLEAN +NTAPI +MmIsAddressValid( + IN PVOID VirtualAddress); + +NTKERNELAPI +BOOLEAN +NTAPI +MmIsThisAnNtAsSystem(VOID); + +NTKERNELAPI +VOID +NTAPI +MmLockPagableSectionByHandle( + IN PVOID ImageSectionHandle); + +NTKERNELAPI +NTSTATUS +NTAPI +MmUnmapViewInSessionSpace( + IN PVOID MappedBase); + +NTKERNELAPI +NTSTATUS +NTAPI +MmUnmapViewInSystemSpace( + IN PVOID MappedBase); + +NTKERNELAPI +VOID +NTAPI +MmUnsecureVirtualMemory( + IN HANDLE SecureHandle); + +NTKERNELAPI +NTSTATUS +NTAPI +MmRemovePhysicalMemory( + IN PPHYSICAL_ADDRESS StartAddress, + IN OUT PLARGE_INTEGER NumberOfBytes); + +NTKERNELAPI +HANDLE +NTAPI +MmSecureVirtualMemory( + IN PVOID Address, + IN SIZE_T Size, + IN ULONG ProbeMode); + +NTKERNELAPI +VOID +NTAPI +MmUnmapVideoDisplay( + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes); + +NTKERNELAPI +NTSTATUS +NTAPI +MmAddPhysicalMemory( + IN PPHYSICAL_ADDRESS StartAddress, + IN OUT PLARGE_INTEGER NumberOfBytes); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemory( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS HighestAcceptableAddress); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCache( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCacheNode( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType, + IN NODE_REQUIREMENT PreferredNode); + +NTKERNELAPI +VOID +NTAPI +MmFreeContiguousMemory( + IN PVOID BaseAddress); + +NTKERNELAPI +VOID +NTAPI +MmFreeContiguousMemorySpecifyCache( + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheType); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +NTSTATUS +NTAPI +MmCreateMirror(VOID); +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTSTATUS +NTAPI +MmRotatePhysicalView( + IN PVOID VirtualAddress, + IN OUT PSIZE_T NumberOfBytes, + IN PMDLX NewMdl OPTIONAL, + IN MM_ROTATE_DIRECTION Direction, + IN PMM_ROTATE_COPY_CALLBACK_FUNCTION CopyFunction, + IN PVOID Context OPTIONAL); +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTKERNELAPI +BOOLEAN +NTAPI +SeSinglePrivilegeCheck( + IN LUID PrivilegeValue, + IN KPROCESSOR_MODE PreviousMode); +#endif struct _LOADER_PARAMETER_BLOCK; struct _CREATE_DISK; @@ -2444,7 +2807,6 @@ #ifndef GUID_DEFINED #include <guiddef.h> #endif -typedef GUID UUID; /* ** IRP function codes @@ -3251,139 +3613,6 @@ ResultPositive = RESULT_POSITIVE } INTERLOCKED_RESULT; -/* Executive Types */ - -#define PROTECTED_POOL 0x80000000 - -typedef struct _ZONE_SEGMENT_HEADER { - SINGLE_LIST_ENTRY SegmentList; - PVOID Reserved; -} ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER; - -typedef struct _ZONE_HEADER { - SINGLE_LIST_ENTRY FreeList; - SINGLE_LIST_ENTRY SegmentList; - ULONG BlockSize; - ULONG TotalSegmentSize; -} ZONE_HEADER, *PZONE_HEADER; - -/* Executive Functions */ - -static __inline PVOID -ExAllocateFromZone( - IN PZONE_HEADER Zone) -{ - if (Zone->FreeList.Next) - Zone->FreeList.Next = Zone->FreeList.Next->Next; - return (PVOID) Zone->FreeList.Next; -} - -static __inline PVOID -ExFreeToZone( - IN PZONE_HEADER Zone, - IN PVOID Block) -{ - ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next; - Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block); - return ((PSINGLE_LIST_ENTRY) Block)->Next; -} - -/* - * PVOID - * ExInterlockedAllocateFromZone( - * IN PZONE_HEADER Zone, - * IN PKSPIN_LOCK Lock) - */ -#define ExInterlockedAllocateFromZone(Zone, Lock) \ - ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock)) - -/* PVOID - * ExInterlockedFreeToZone( - * IN PZONE_HEADER Zone, - * IN PVOID Block, - * IN PKSPIN_LOCK Lock); - */ -#define ExInterlockedFreeToZone(Zone, Block, Lock) \ - ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock) - -/* - * BOOLEAN - * ExIsFullZone( - * IN PZONE_HEADER Zone) - */ -#define ExIsFullZone(Zone) \ - ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL) - -/* BOOLEAN - * ExIsObjectInFirstZoneSegment( - * IN PZONE_HEADER Zone, - * IN PVOID Object); - */ -#define ExIsObjectInFirstZoneSegment(Zone,Object) \ - ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \ - ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \ - (Zone)->TotalSegmentSize)) ) - -#define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite -#define ExAcquireResourceShared ExAcquireResourceSharedLite -#define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite -#define ExDeleteResource ExDeleteResourceLite -#define ExInitializeResource ExInitializeResourceLite -#define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite -#define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite -#define ExIsResourceAcquired ExIsResourceAcquiredSharedLite -#define ExReleaseResourceForThread ExReleaseResourceForThreadLite - -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTKERNELAPI -NTSTATUS -NTAPI -ExExtendZone( - IN OUT PZONE_HEADER Zone, - IN OUT PVOID Segment, - IN ULONG SegmentSize); - -NTKERNELAPI -NTSTATUS -NTAPI -ExInitializeZone( - OUT PZONE_HEADER Zone, - IN ULONG BlockSize, - IN OUT PVOID InitialSegment, - IN ULONG InitialSegmentSize); - -NTKERNELAPI -NTSTATUS -NTAPI -ExInterlockedExtendZone( - IN OUT PZONE_HEADER Zone, - IN OUT PVOID Segment, - IN ULONG SegmentSize, - IN OUT PKSPIN_LOCK Lock); - -NTKERNELAPI -NTSTATUS -NTAPI -ExUuidCreate( - OUT UUID *Uuid); - -NTKERNELAPI -DECLSPEC_NORETURN -VOID -NTAPI -ExRaiseAccessViolation( - VOID); - -NTKERNELAPI -DECLSPEC_NORETURN -VOID -NTAPI -ExRaiseDatatypeMisalignment( - VOID); - -#endif - #ifdef _X86_ NTKERNELAPI @@ -4010,146 +4239,6 @@ #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ -/* Memory Manager Types */ - -typedef struct _PHYSICAL_MEMORY_RANGE { - PHYSICAL_ADDRESS BaseAddress; - LARGE_INTEGER NumberOfBytes; -} PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE; - -/* Memory Manager Functions */ - -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTKERNELAPI -PPHYSICAL_MEMORY_RANGE -NTAPI -MmGetPhysicalMemoryRanges( - VOID); - -NTKERNELAPI -PHYSICAL_ADDRESS -NTAPI -MmGetPhysicalAddress( - IN PVOID BaseAddress); - -NTKERNELAPI -BOOLEAN -NTAPI -MmIsNonPagedSystemAddressValid( - IN PVOID VirtualAddress); - -NTKERNELAPI -PVOID -NTAPI -MmAllocateNonCachedMemory( - IN SIZE_T NumberOfBytes); - -NTKERNELAPI -VOID -NTAPI -MmFreeNonCachedMemory( - IN PVOID BaseAddress, - IN SIZE_T NumberOfBytes); - -NTKERNELAPI -PVOID -NTAPI -MmGetVirtualForPhysical( - IN PHYSICAL_ADDRESS PhysicalAddress); - -NTKERNELAPI -NTSTATUS -NTAPI -MmMapUserAddressesToPage( - IN PVOID BaseAddress, - IN SIZE_T NumberOfBytes, - IN PVOID PageAddress); - -NTKERNELAPI -PVOID -NTAPI -MmMapVideoDisplay( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN SIZE_T NumberOfBytes, - IN MEMORY_CACHING_TYPE CacheType); - -NTKERNELAPI -NTSTATUS -NTAPI -MmMapViewInSessionSpace( - IN PVOID Section, - OUT PVOID *MappedBase, - IN OUT PSIZE_T ViewSize); - -NTKERNELAPI -NTSTATUS -NTAPI -MmMapViewInSystemSpace( - IN PVOID Section, - OUT PVOID *MappedBase, - IN OUT PSIZE_T ViewSize); - -NTKERNELAPI -BOOLEAN -NTAPI -MmIsAddressValid( - IN PVOID VirtualAddress); - -NTKERNELAPI -BOOLEAN -NTAPI -MmIsThisAnNtAsSystem( - VOID); - -NTKERNELAPI -VOID -NTAPI -MmLockPagableSectionByHandle( - IN PVOID ImageSectionHandle); - -NTKERNELAPI -NTSTATUS -NTAPI -MmUnmapViewInSessionSpace( - IN PVOID MappedBase); - -NTKERNELAPI -NTSTATUS -NTAPI -MmUnmapViewInSystemSpace( - IN PVOID MappedBase); - -NTKERNELAPI -VOID -NTAPI -MmUnsecureVirtualMemory( - IN HANDLE SecureHandle); - -NTKERNELAPI -NTSTATUS -NTAPI -MmRemovePhysicalMemory( - IN PPHYSICAL_ADDRESS StartAddress, - IN OUT PLARGE_INTEGER NumberOfBytes); - -NTKERNELAPI -HANDLE -NTAPI -MmSecureVirtualMemory( - IN PVOID Address, - IN SIZE_T Size, - IN ULONG ProbeMode); - -NTKERNELAPI -VOID -NTAPI -MmUnmapVideoDisplay( - IN PVOID BaseAddress, - IN SIZE_T NumberOfBytes); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ - /** Process manager types **/ typedef VOID @@ -4239,17 +4328,6 @@ #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ extern NTKERNELAPI PEPROCESS PsInitialSystemProcess; - -/* Security reference monitor routines */ - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTKERNELAPI -BOOLEAN -NTAPI -SeSinglePrivilegeCheck( - IN LUID PrivilegeValue, - IN KPROCESSOR_MODE PreviousMode); -#endif /* ZwXxx Functions */
14 years, 9 months
1
0
0
0
[akhaldi] 46234: [NTDDK] - Group related definitions - Add CmResourceTypeMaximum, SINGLE_GROUP_LEGACY_API, MAXIMUM_EXPANSION_SIZE, EXPAND_STACK_CALLOUT and several SYSTEM_*, TIMER_SET_*, XSTATE_*, SHARED_*, EX_*, PCCARD_*, PAUSE_PROCESSOR and Ke*
by akhaldi@svn.reactos.org
Author: akhaldi Date: Wed Mar 17 00:33:28 2010 New Revision: 46234 URL:
http://svn.reactos.org/svn/reactos?rev=46234&view=rev
Log: [NTDDK] - Group related definitions - Add CmResourceTypeMaximum, SINGLE_GROUP_LEGACY_API, MAXIMUM_EXPANSION_SIZE, EXPAND_STACK_CALLOUT and several SYSTEM_*, TIMER_SET_*, XSTATE_*, SHARED_*, EX_*, PCCARD_*, PAUSE_PROCESSOR and Ke* Modified: branches/header-work/include/ddk/ntddk.h Modified: branches/header-work/include/ddk/ntddk.h URL:
http://svn.reactos.org/svn/reactos/branches/header-work/include/ddk/ntddk.h…
============================================================================== --- branches/header-work/include/ddk/ntddk.h [iso-8859-1] (original) +++ branches/header-work/include/ddk/ntddk.h [iso-8859-1] Wed Mar 17 00:33:28 2010 @@ -1893,665 +1893,52 @@ IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL); -struct _LOADER_PARAMETER_BLOCK; -struct _CREATE_DISK; -struct _DRIVE_LAYOUT_INFORMATION_EX; -struct _SET_PARTITION_INFORMATION_EX; - -// -// GUID and UUID -// -#ifndef GUID_DEFINED -#include <guiddef.h> -#endif -typedef GUID UUID; - -#define MAX_WOW64_SHARED_ENTRIES 16 - -#define NX_SUPPORT_POLICY_ALWAYSOFF 0 -#define NX_SUPPORT_POLICY_ALWAYSON 1 -#define NX_SUPPORT_POLICY_OPTIN 2 -#define NX_SUPPORT_POLICY_OPTOUT 3 - -/* -** IRP function codes -*/ - -#define IRP_MN_QUERY_DIRECTORY 0x01 -#define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02 - -#define IRP_MN_USER_FS_REQUEST 0x00 -#define IRP_MN_MOUNT_VOLUME 0x01 -#define IRP_MN_VERIFY_VOLUME 0x02 -#define IRP_MN_LOAD_FILE_SYSTEM 0x03 -#define IRP_MN_TRACK_LINK 0x04 -#define IRP_MN_KERNEL_CALL 0x04 - -#define IRP_MN_LOCK 0x01 -#define IRP_MN_UNLOCK_SINGLE 0x02 -#define IRP_MN_UNLOCK_ALL 0x03 -#define IRP_MN_UNLOCK_ALL_BY_KEY 0x04 - -#define IRP_MN_FLUSH_AND_PURGE 0x01 - -#define IRP_MN_NORMAL 0x00 -#define IRP_MN_DPC 0x01 -#define IRP_MN_MDL 0x02 -#define IRP_MN_COMPLETE 0x04 -#define IRP_MN_COMPRESSED 0x08 - -#define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC) -#define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL) -#define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC) - -#define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18 - -/* DEVICE_OBJECT.Flags */ - -#define DO_DEVICE_HAS_NAME 0x00000040 -#define DO_SYSTEM_BOOT_PARTITION 0x00000100 -#define DO_LONG_TERM_REQUESTS 0x00000200 -#define DO_NEVER_LAST_DEVICE 0x00000400 -#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000 -#define DO_SUPPORTS_TRANSACTIONS 0x00040000 -#define DO_FORCE_NEITHER_IO 0x00080000 -#define DO_VOLUME_DEVICE_OBJECT 0x00100000 -#define DO_SYSTEM_SYSTEM_PARTITION 0x00200000 -#define DO_SYSTEM_CRITICAL_PARTITION 0x00400000 -#define DO_DISALLOW_EXECUTE 0x00800000 - -#define DRVO_REINIT_REGISTERED 0x00000008 -#define DRVO_INITIALIZED 0x00000010 -#define DRVO_BOOTREINIT_REGISTERED 0x00000020 -#define DRVO_LEGACY_RESOURCES 0x00000040 - -typedef enum _ARBITER_REQUEST_SOURCE { - ArbiterRequestUndefined = -1, - ArbiterRequestLegacyReported, - ArbiterRequestHalReported, - ArbiterRequestLegacyAssigned, - ArbiterRequestPnpDetected, - ArbiterRequestPnpEnumerated -} ARBITER_REQUEST_SOURCE; - -typedef enum _ARBITER_RESULT { - ArbiterResultUndefined = -1, - ArbiterResultSuccess, - ArbiterResultExternalConflict, - ArbiterResultNullRequest -} ARBITER_RESULT; - -typedef enum _ARBITER_ACTION { - ArbiterActionTestAllocation, - ArbiterActionRetestAllocation, - ArbiterActionCommitAllocation, - ArbiterActionRollbackAllocation, - ArbiterActionQueryAllocatedResources, - ArbiterActionWriteReservedResources, - ArbiterActionQueryConflict, - ArbiterActionQueryArbitrate, - ArbiterActionAddReserved, - ArbiterActionBootAllocation -} ARBITER_ACTION, *PARBITER_ACTION; - -typedef struct _ARBITER_CONFLICT_INFO { - PDEVICE_OBJECT OwningObject; - ULONGLONG Start; - ULONGLONG End; -} ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO; - -typedef struct _ARBITER_PARAMETERS { - union { - struct { - IN OUT PLIST_ENTRY ArbitrationList; - IN ULONG AllocateFromCount; - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; - } TestAllocation; - struct { - IN OUT PLIST_ENTRY ArbitrationList; - IN ULONG AllocateFromCount; - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; - } RetestAllocation; - struct { - IN OUT PLIST_ENTRY ArbitrationList; - } BootAllocation; - struct { - OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources; - } QueryAllocatedResources; - struct { - IN PDEVICE_OBJECT PhysicalDeviceObject; - IN PIO_RESOURCE_DESCRIPTOR ConflictingResource; - OUT PULONG ConflictCount; - OUT PARBITER_CONFLICT_INFO *Conflicts; - } QueryConflict; - struct { - IN PLIST_ENTRY ArbitrationList; - } QueryArbitrate; - struct { - IN PDEVICE_OBJECT ReserveDevice; - } AddReserved; - } Parameters; -} ARBITER_PARAMETERS, *PARBITER_PARAMETERS; - -#define ARBITER_FLAG_BOOT_CONFIG 0x00000001 - -typedef struct _ARBITER_LIST_ENTRY { - LIST_ENTRY ListEntry; - ULONG AlternativeCount; - PIO_RESOURCE_DESCRIPTOR Alternatives; - PDEVICE_OBJECT PhysicalDeviceObject; - ARBITER_REQUEST_SOURCE RequestSource; - ULONG Flags; - LONG_PTR WorkSpace; - INTERFACE_TYPE InterfaceType; - ULONG SlotNumber; - ULONG BusNumber; - PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment; - PIO_RESOURCE_DESCRIPTOR SelectedAlternative; - ARBITER_RESULT Result; -} ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY; +typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION { + SystemFirmwareTable_Enumerate, + SystemFirmwareTable_Get +} SYSTEM_FIRMWARE_TABLE_ACTION; + +typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION { + ULONG ProviderSignature; + SYSTEM_FIRMWARE_TABLE_ACTION Action; + ULONG TableID; + ULONG TableBufferLength; + UCHAR TableBuffer[ANYSIZE_ARRAY]; +} SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION; typedef NTSTATUS -(NTAPI *PARBITER_HANDLER)( - IN OUT PVOID Context, - IN ARBITER_ACTION Action, - IN OUT PARBITER_PARAMETERS Parameters); - -#define ARBITER_PARTIAL 0x00000001 - -typedef struct _ARBITER_INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PARBITER_HANDLER ArbiterHandler; - ULONG Flags; -} ARBITER_INTERFACE, *PARBITER_INTERFACE; - -typedef enum _HAL_QUERY_INFORMATION_CLASS { - HalInstalledBusInformation, - HalProfileSourceInformation, - HalInformationClassUnused1, - HalPowerInformation, - HalProcessorSpeedInformation, - HalCallbackInformation, - HalMapRegisterInformation, - HalMcaLogInformation, - HalFrameBufferCachingInformation, - HalDisplayBiosInformation, - HalProcessorFeatureInformation, - HalNumaTopologyInterface, - HalErrorInformation, - HalCmcLogInformation, - HalCpeLogInformation, - HalQueryMcaInterface, - HalQueryAMLIIllegalIOPortAddresses, - HalQueryMaxHotPlugMemoryAddress, - HalPartitionIpiInterface, - HalPlatformInformation, - HalQueryProfileSourceList, - HalInitLogInformation, - HalFrequencyInformation, - HalProcessorBrandString, - HalHypervisorInformation, - HalPlatformTimerInformation, - HalAcpiAuditInformation -} HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS; - -typedef enum _HAL_SET_INFORMATION_CLASS { - HalProfileSourceInterval, - HalProfileSourceInterruptHandler, - HalMcaRegisterDriver, - HalKernelErrorHandler, - HalCmcRegisterDriver, - HalCpeRegisterDriver, - HalMcaLog, - HalCmcLog, - HalCpeLog, - HalGenerateCmcInterrupt, - HalProfileSourceTimerHandler, - HalEnlightenment, - HalProfileDpgoSourceInterruptHandler -} HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS; - -typedef struct _HAL_PROFILE_SOURCE_INTERVAL { - KPROFILE_SOURCE Source; - ULONG_PTR Interval; -} HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL; - -typedef struct _HAL_PROFILE_SOURCE_INFORMATION { - KPROFILE_SOURCE Source; - BOOLEAN Supported; - ULONG Interval; -} HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION; - -typedef struct _MAP_REGISTER_ENTRY { - PVOID MapRegister; - BOOLEAN WriteToDevice; -} MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY; - -typedef struct _DEBUG_DEVICE_ADDRESS { - UCHAR Type; - BOOLEAN Valid; - UCHAR Reserved[2]; - PUCHAR TranslatedAddress; - ULONG Length; -} DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS; - -typedef struct _DEBUG_MEMORY_REQUIREMENTS { - PHYSICAL_ADDRESS Start; - PHYSICAL_ADDRESS MaxEnd; - PVOID VirtualAddress; - ULONG Length; - BOOLEAN Cached; - BOOLEAN Aligned; -} DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS; - -typedef struct _DEBUG_DEVICE_DESCRIPTOR { - ULONG Bus; - ULONG Slot; - USHORT Segment; - USHORT VendorID; - USHORT DeviceID; - UCHAR BaseClass; - UCHAR SubClass; - UCHAR ProgIf; - BOOLEAN Initialized; - BOOLEAN Configured; - DEBUG_DEVICE_ADDRESS BaseAddress[6]; - DEBUG_MEMORY_REQUIREMENTS Memory; -} DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR; - -typedef struct _PM_DISPATCH_TABLE { - ULONG Signature; - ULONG Version; - PVOID Function[1]; -} PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE; - -typedef enum _RESOURCE_TRANSLATION_DIRECTION { - TranslateChildToParent, - TranslateParentToChild -} RESOURCE_TRANSLATION_DIRECTION; - -typedef NTSTATUS -(NTAPI *PTRANSLATE_RESOURCE_HANDLER)( - IN OUT PVOID Context, - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, - IN RESOURCE_TRANSLATION_DIRECTION Direction, - IN ULONG AlternativesCount OPTIONAL, - IN IO_RESOURCE_DESCRIPTOR Alternatives[], - IN PDEVICE_OBJECT PhysicalDeviceObject, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target); - -typedef NTSTATUS -(NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)( - IN PVOID Context OPTIONAL, - IN PIO_RESOURCE_DESCRIPTOR Source, - IN PDEVICE_OBJECT PhysicalDeviceObject, - OUT PULONG TargetCount, - OUT PIO_RESOURCE_DESCRIPTOR *Target); - -typedef struct _TRANSLATOR_INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PTRANSLATE_RESOURCE_HANDLER TranslateResources; - PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements; -} TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE; +(__cdecl *PFNFTH) ( + IN OUT PSYSTEM_FIRMWARE_TABLE_INFORMATION SystemFirmwareTableInfo); + +typedef struct _SYSTEM_FIRMWARE_TABLE_HANDLER { + ULONG ProviderSignature; + BOOLEAN Register; + PFNFTH FirmwareTableHandler; + PVOID DriverObject; +} SYSTEM_FIRMWARE_TABLE_HANDLER, *PSYSTEM_FIRMWARE_TABLE_HANDLER; typedef VOID -(FASTCALL *pHalExamineMBR)( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG MBRTypeIdentifier, - OUT PVOID *Buffer); - -typedef NTSTATUS -(FASTCALL *pHalIoReadPartitionTable)( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN BOOLEAN ReturnRecognizedPartitions, - OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer); - -typedef NTSTATUS -(FASTCALL *pHalIoSetPartitionInformation)( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG PartitionNumber, - IN ULONG PartitionType); - -typedef NTSTATUS -(FASTCALL *pHalIoWritePartitionTable)( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG SectorsPerTrack, - IN ULONG NumberOfHeads, - IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); - -typedef PBUS_HANDLER -(FASTCALL *pHalHandlerForBus)( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber); - -typedef VOID -(FASTCALL *pHalReferenceBusHandler)( - IN PBUS_HANDLER BusHandler); - -typedef NTSTATUS -(NTAPI *pHalQuerySystemInformation)( - IN HAL_QUERY_INFORMATION_CLASS InformationClass, - IN ULONG BufferSize, - IN OUT PVOID Buffer, - OUT PULONG ReturnedLength); - -typedef NTSTATUS -(NTAPI *pHalSetSystemInformation)( - IN HAL_SET_INFORMATION_CLASS InformationClass, - IN ULONG BufferSize, - IN PVOID Buffer); - -typedef NTSTATUS -(NTAPI *pHalQueryBusSlots)( - IN PBUS_HANDLER BusHandler, - IN ULONG BufferSize, - OUT PULONG SlotNumbers, - OUT PULONG ReturnedLength); - -typedef NTSTATUS -(NTAPI *pHalInitPnpDriver)( - VOID); - -typedef NTSTATUS -(NTAPI *pHalInitPowerManagement)( - IN PPM_DISPATCH_TABLE PmDriverDispatchTable, - OUT PPM_DISPATCH_TABLE *PmHalDispatchTable); - -typedef struct _DMA_ADAPTER* -(NTAPI *pHalGetDmaAdapter)( - IN PVOID Context, - IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, - OUT PULONG NumberOfMapRegisters); - -typedef NTSTATUS -(NTAPI *pHalGetInterruptTranslator)( - IN INTERFACE_TYPE ParentInterfaceType, - IN ULONG ParentBusNumber, - IN INTERFACE_TYPE BridgeInterfaceType, - IN USHORT Size, - IN USHORT Version, - OUT PTRANSLATOR_INTERFACE Translator, - OUT PULONG BridgeBusNumber); - -typedef NTSTATUS -(NTAPI *pHalStartMirroring)( - VOID); - -typedef NTSTATUS -(NTAPI *pHalEndMirroring)( - IN ULONG PassNumber); - -typedef NTSTATUS -(NTAPI *pHalMirrorPhysicalMemory)( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN LARGE_INTEGER NumberOfBytes); - -typedef NTSTATUS -(NTAPI *pHalMirrorVerify)( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN LARGE_INTEGER NumberOfBytes); - -typedef VOID -(NTAPI *pHalEndOfBoot)( - VOID); - -typedef -BOOLEAN -(NTAPI *pHalTranslateBusAddress)( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber, - IN PHYSICAL_ADDRESS BusAddress, - IN OUT PULONG AddressSpace, - OUT PPHYSICAL_ADDRESS TranslatedAddress); - -typedef -NTSTATUS -(NTAPI *pHalAssignSlotResources)( - IN PUNICODE_STRING RegistryPath, - IN PUNICODE_STRING DriverClassName OPTIONAL, - IN PDRIVER_OBJECT DriverObject, - IN PDEVICE_OBJECT DeviceObject, - IN INTERFACE_TYPE BusType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN OUT PCM_RESOURCE_LIST *AllocatedResources); - -typedef -VOID -(NTAPI *pHalHaltSystem)( - VOID); - -typedef -BOOLEAN -(NTAPI *pHalResetDisplay)( - VOID); - -typedef -UCHAR -(NTAPI *pHalVectorToIDTEntry)( - ULONG Vector); - -typedef -BOOLEAN -(NTAPI *pHalFindBusAddressTranslation)( - IN PHYSICAL_ADDRESS BusAddress, - IN OUT PULONG AddressSpace, - OUT PPHYSICAL_ADDRESS TranslatedAddress, - IN OUT PULONG_PTR Context, - IN BOOLEAN NextBus); - -typedef -NTSTATUS -(NTAPI *pKdSetupPciDeviceForDebugging)( - IN PVOID LoaderBlock OPTIONAL, - IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); - -typedef -NTSTATUS -(NTAPI *pKdReleasePciDeviceForDebugging)( - IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); - -typedef -PVOID -(NTAPI *pKdGetAcpiTablePhase0)( - IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, - IN ULONG Signature); - -typedef -PVOID -(NTAPI *pHalGetAcpiTable)( - IN ULONG Signature, - IN PCSTR OemId OPTIONAL, - IN PCSTR OemTableId OPTIONAL); - -typedef -VOID -(NTAPI *pKdCheckPowerButton)( - VOID); - -#if (NTDDI_VERSION >= NTDDI_VISTA) -typedef -PVOID -(NTAPI *pKdMapPhysicalMemory64)( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN ULONG NumberPages, - IN BOOLEAN FlushCurrentTLB); - -typedef -VOID -(NTAPI *pKdUnmapVirtualAddress)( - IN PVOID VirtualAddress, - IN ULONG NumberPages, - IN BOOLEAN FlushCurrentTLB); -#else -typedef -PVOID -(NTAPI *pKdMapPhysicalMemory64)( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN ULONG NumberPages); - -typedef -VOID -(NTAPI *pKdUnmapVirtualAddress)( - IN PVOID VirtualAddress, - IN ULONG NumberPages); -#endif - - -typedef -ULONG -(NTAPI *pKdGetPciDataByOffset)( - IN ULONG BusNumber, - IN ULONG SlotNumber, - OUT PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -typedef -ULONG -(NTAPI *pKdSetPciDataByOffset)( - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -typedef BOOLEAN -(NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)( - IN ULONG Columns, - IN ULONG Rows); - -typedef -VOID -(NTAPI *PCI_ERROR_HANDLER_CALLBACK)( - VOID); - -typedef -VOID -(NTAPI *pHalSetPciErrorHandlerCallback)( - IN PCI_ERROR_HANDLER_CALLBACK Callback); - -#if 1 /* Not present in WDK 7600 */ -typedef VOID -(FASTCALL *pHalIoAssignDriveLetters)( - IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, - IN PSTRING NtDeviceName, - OUT PUCHAR NtSystemPath, - OUT PSTRING NtSystemPathString); -#endif - -typedef struct { - ULONG Version; - pHalQuerySystemInformation HalQuerySystemInformation; - pHalSetSystemInformation HalSetSystemInformation; - pHalQueryBusSlots HalQueryBusSlots; - ULONG Spare1; - pHalExamineMBR HalExamineMBR; -#if 1 /* Not present in WDK 7600 */ - pHalIoAssignDriveLetters HalIoAssignDriveLetters; -#endif - pHalIoReadPartitionTable HalIoReadPartitionTable; - pHalIoSetPartitionInformation HalIoSetPartitionInformation; - pHalIoWritePartitionTable HalIoWritePartitionTable; - pHalHandlerForBus HalReferenceHandlerForBus; - pHalReferenceBusHandler HalReferenceBusHandler; - pHalReferenceBusHandler HalDereferenceBusHandler; - pHalInitPnpDriver HalInitPnpDriver; - pHalInitPowerManagement HalInitPowerManagement; - pHalGetDmaAdapter HalGetDmaAdapter; - pHalGetInterruptTranslator HalGetInterruptTranslator; - pHalStartMirroring HalStartMirroring; - pHalEndMirroring HalEndMirroring; - pHalMirrorPhysicalMemory HalMirrorPhysicalMemory; - pHalEndOfBoot HalEndOfBoot; - pHalMirrorVerify HalMirrorVerify; - pHalGetAcpiTable HalGetCachedAcpiTable; - pHalSetPciErrorHandlerCallback HalSetPciErrorHandlerCallback; -#if defined(_IA64_) - pHalGetErrorCapList HalGetErrorCapList; - pHalInjectError HalInjectError; -#endif -} HAL_DISPATCH, *PHAL_DISPATCH; - -/* GCC/MSVC and WDK compatible declaration */ -extern NTKERNELAPI HAL_DISPATCH HalDispatchTable; - -#if defined(_NTOSKRNL_) || defined(_BLDR_) -#define HALDISPATCH (&HalDispatchTable) -#else -/* This is a WDK compatibility definition */ -#define HalDispatchTable (&HalDispatchTable) -#define HALDISPATCH HalDispatchTable -#endif - -#define HAL_DISPATCH_VERSION 3 /* FIXME: when to use 4? */ -#define HalDispatchTableVersion HALDISPATCH->Version -#define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation -#define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation -#define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots -#define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus -#define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler -#define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler -#define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver -#define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement -#define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter -#define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator -#define HalStartMirroring HALDISPATCH->HalStartMirroring -#define HalEndMirroring HALDISPATCH->HalEndMirroring -#define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory -#define HalEndOfBoot HALDISPATCH->HalEndOfBoot -#define HalMirrorVerify HALDISPATCH->HalMirrorVerify - -typedef struct _IMAGE_INFO { - _ANONYMOUS_UNION union { - ULONG Properties; - _ANONYMOUS_STRUCT struct { - ULONG ImageAddressingMode:8; - ULONG SystemModeImage:1; - ULONG ImageMappedToAllPids:1; - ULONG ExtendedInfoPresent:1; - ULONG Reserved:22; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - PVOID ImageBase; - ULONG ImageSelector; - SIZE_T ImageSize; - ULONG ImageSectionNumber; -} IMAGE_INFO, *PIMAGE_INFO; - -#define IMAGE_ADDRESSING_MODE_32BIT 3 - -typedef enum _IO_QUERY_DEVICE_DATA_FORMAT { - IoQueryDeviceIdentifier = 0, - IoQueryDeviceConfigurationData, - IoQueryDeviceComponentInformation, - IoQueryDeviceMaxData -} IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT; - -typedef struct _DISK_SIGNATURE { - ULONG PartitionStyle; - _ANONYMOUS_UNION union { - struct { - ULONG Signature; - ULONG CheckSum; - } Mbr; - struct { - GUID DiskId; - } Gpt; - } DUMMYUNIONNAME; -} DISK_SIGNATURE, *PDISK_SIGNATURE; +(NTAPI *PTIMER_APC_ROUTINE)( + IN PVOID TimerContext, + IN ULONG TimerLowValue, + IN LONG TimerHighValue); + +typedef enum _TIMER_SET_INFORMATION_CLASS { + TimerSetCoalescableTimer, + MaxTimerInfoClass +} TIMER_SET_INFORMATION_CLASS; + +#if (NTDDI_VERSION >= NTDDI_WIN7) +typedef struct _TIMER_SET_COALESCABLE_TIMER_INFO { + IN LARGE_INTEGER DueTime; + IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL; + IN PVOID TimerContext OPTIONAL; + IN struct _COUNTED_REASON_CONTEXT *WakeContext OPTIONAL; + IN ULONG Period OPTIONAL; + IN ULONG TolerableDelay; + OUT PBOOLEAN PreviousState OPTIONAL; +} TIMER_SET_COALESCABLE_TIMER_INFO, *PTIMER_SET_COALESCABLE_TIMER_INFO; +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ typedef ULONG_PTR (NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)( @@ -2568,447 +1955,206 @@ #define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008 #define DRIVER_VERIFIER_IO_CHECKING 0x0010 -typedef VOID -(NTAPI *PTIMER_APC_ROUTINE)( - IN PVOID TimerContext, - IN ULONG TimerLowValue, - IN LONG TimerHighValue); - -typedef struct _KUSER_SHARED_DATA -{ - ULONG TickCountLowDeprecated; - ULONG TickCountMultiplier; - volatile KSYSTEM_TIME InterruptTime; - volatile KSYSTEM_TIME SystemTime; - volatile KSYSTEM_TIME TimeZoneBias; - USHORT ImageNumberLow; - USHORT ImageNumberHigh; - WCHAR NtSystemRoot[260]; - ULONG MaxStackTraceDepth; - ULONG CryptoExponent; - ULONG TimeZoneId; - ULONG LargePageMinimum; - ULONG Reserved2[7]; - NT_PRODUCT_TYPE NtProductType; - BOOLEAN ProductTypeIsValid; - ULONG NtMajorVersion; - ULONG NtMinorVersion; - BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX]; - ULONG Reserved1; - ULONG Reserved3; - volatile ULONG TimeSlip; - ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture; - ULONG AltArchitecturePad[1]; - LARGE_INTEGER SystemExpirationDate; - ULONG SuiteMask; - BOOLEAN KdDebuggerEnabled; +#define XSTATE_LEGACY_FLOATING_POINT 0 +#define XSTATE_LEGACY_SSE 1 +#define XSTATE_GSSE 2 + +#define XSTATE_MASK_LEGACY_FLOATING_POINT (1i64 << (XSTATE_LEGACY_FLOATING_POINT)) +#define XSTATE_MASK_LEGACY_SSE (1i64 << (XSTATE_LEGACY_SSE)) +#define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE) +#define XSTATE_MASK_GSSE (1i64 << (XSTATE_GSSE)) + +#define MAXIMUM_XSTATE_FEATURES 64 + +typedef struct _XSTATE_FEATURE { + ULONG Offset; + ULONG Size; +} XSTATE_FEATURE, *PXSTATE_FEATURE; + +typedef struct _XSTATE_CONFIGURATION { + ULONG64 EnabledFeatures; + ULONG Size; + ULONG OptimizedSave:1; + XSTATE_FEATURE Features[MAXIMUM_XSTATE_FEATURES]; +} XSTATE_CONFIGURATION, *PXSTATE_CONFIGURATION; + +#define MAX_WOW64_SHARED_ENTRIES 16 + +#define NX_SUPPORT_POLICY_ALWAYSOFF 0 +#define NX_SUPPORT_POLICY_ALWAYSON 1 +#define NX_SUPPORT_POLICY_OPTIN 2 +#define NX_SUPPORT_POLICY_OPTOUT 3 + +#define SHARED_GLOBAL_FLAGS_ERROR_PORT_V 0x0 +#define SHARED_GLOBAL_FLAGS_ERROR_PORT (1UL << SHARED_GLOBAL_FLAGS_ERROR_PORT_V) + +#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V 0x1 +#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED (1UL << SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V 0x2 +#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED (1UL << SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V 0x3 +#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_SPARE_V 0x4 +#define SHARED_GLOBAL_FLAGS_SPARE \ + (1UL << SHARED_GLOBAL_FLAGS_SPARE_V) + +#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V 0x5 +#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V 0x6 +#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V) + +#define EX_INIT_BITS(Flags, Bit) \ + *((Flags)) |= (Bit) // Safe to use before concurrently accessible + +#define EX_TEST_SET_BIT(Flags, Bit) \ + InterlockedBitTestAndSet ((PLONG)(Flags), (Bit)) + +#define EX_TEST_CLEAR_BIT(Flags, Bit) \ + InterlockedBitTestAndReset ((PLONG)(Flags), (Bit)) + +typedef struct _KUSER_SHARED_DATA { + ULONG TickCountLowDeprecated; + ULONG TickCountMultiplier; + volatile KSYSTEM_TIME InterruptTime; + volatile KSYSTEM_TIME SystemTime; + volatile KSYSTEM_TIME TimeZoneBias; + USHORT ImageNumberLow; + USHORT ImageNumberHigh; + WCHAR NtSystemRoot[260]; + ULONG MaxStackTraceDepth; + ULONG CryptoExponent; + ULONG TimeZoneId; + ULONG LargePageMinimum; + ULONG Reserved2[7]; + NT_PRODUCT_TYPE NtProductType; + BOOLEAN ProductTypeIsValid; + ULONG NtMajorVersion; + ULONG NtMinorVersion; + BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX]; + ULONG Reserved1; + ULONG Reserved3; + volatile ULONG TimeSlip; + ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture; + ULONG AltArchitecturePad[1]; + LARGE_INTEGER SystemExpirationDate; + ULONG SuiteMask; + BOOLEAN KdDebuggerEnabled; #if (NTDDI_VERSION >= NTDDI_WINXPSP2) - UCHAR NXSupportPolicy; + UCHAR NXSupportPolicy; #endif - volatile ULONG ActiveConsoleId; - volatile ULONG DismountCount; - ULONG ComPlusPackage; - ULONG LastSystemRITEventTickCount; - ULONG NumberOfPhysicalPages; - BOOLEAN SafeBootMode; + volatile ULONG ActiveConsoleId; + volatile ULONG DismountCount; + ULONG ComPlusPackage; + ULONG LastSystemRITEventTickCount; + ULONG NumberOfPhysicalPages; + BOOLEAN SafeBootMode; #if (NTDDI_VERSION >= NTDDI_WIN7) - union { - UCHAR TscQpcData; - struct { - UCHAR TscQpcEnabled:1; - UCHAR TscQpcSpareFlag:1; - UCHAR TscQpcShift:6; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - UCHAR TscQpcPad[2]; + union { + UCHAR TscQpcData; + struct { + UCHAR TscQpcEnabled:1; + UCHAR TscQpcSpareFlag:1; + UCHAR TscQpcShift:6; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UCHAR TscQpcPad[2]; #endif #if (NTDDI_VERSION >= NTDDI_VISTA) - union { - ULONG SharedDataFlags; - struct { - ULONG DbgErrorPortPresent:1; - ULONG DbgElevationEnabled:1; - ULONG DbgVirtEnabled:1; - ULONG DbgInstallerDetectEnabled:1; - ULONG DbgSystemDllRelocated:1; - ULONG DbgDynProcessorEnabled:1; - ULONG DbgSEHValidationEnabled:1; - ULONG SpareBits:25; - } DUMMYSTRUCTNAME2; - } DUMMYUNIONNAME2; + union { + ULONG SharedDataFlags; + struct { + ULONG DbgErrorPortPresent:1; + ULONG DbgElevationEnabled:1; + ULONG DbgVirtEnabled:1; + ULONG DbgInstallerDetectEnabled:1; + ULONG DbgSystemDllRelocated:1; + ULONG DbgDynProcessorEnabled:1; + ULONG DbgSEHValidationEnabled:1; + ULONG SpareBits:25; + } DUMMYSTRUCTNAME2; + } DUMMYUNIONNAME2; #else - ULONG TraceLogging; + ULONG TraceLogging; #endif - ULONG DataFlagsPad[1]; - ULONGLONG TestRetInstruction; - ULONG SystemCall; - ULONG SystemCallReturn; - ULONGLONG SystemCallPad[3]; - _ANONYMOUS_UNION union { - volatile KSYSTEM_TIME TickCount; - volatile ULONG64 TickCountQuad; - _ANONYMOUS_STRUCT struct { - ULONG ReservedTickCountOverlay[3]; - ULONG TickCountPad[1]; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME3; - ULONG Cookie; - ULONG CookiePad[1]; + ULONG DataFlagsPad[1]; + ULONGLONG TestRetInstruction; + ULONG SystemCall; + ULONG SystemCallReturn; + ULONGLONG SystemCallPad[3]; + _ANONYMOUS_UNION union { + volatile KSYSTEM_TIME TickCount; + volatile ULONG64 TickCountQuad; + _ANONYMOUS_STRUCT struct { + ULONG ReservedTickCountOverlay[3]; + ULONG TickCountPad[1]; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME3; + ULONG Cookie; + ULONG CookiePad[1]; #if (NTDDI_VERSION >= NTDDI_WS03) - LONGLONG ConsoleSessionForegroundProcessId; - ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES]; + LONGLONG ConsoleSessionForegroundProcessId; + ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES]; #endif #if (NTDDI_VERSION >= NTDDI_VISTA) #if (NTDDI_VERSION >= NTDDI_WIN7) - USHORT UserModeGlobalLogger[16]; + USHORT UserModeGlobalLogger[16]; #else - USHORT UserModeGlobalLogger[8]; - ULONG HeapTracingPid[2]; - ULONG CritSecTracingPid[2]; + USHORT UserModeGlobalLogger[8]; + ULONG HeapTracingPid[2]; + ULONG CritSecTracingPid[2]; #endif - ULONG ImageFileExecutionOptions; + ULONG ImageFileExecutionOptions; #if (NTDDI_VERSION >= NTDDI_VISTASP1) - ULONG LangGenerationCount; + ULONG LangGenerationCount; #else - /* 4 bytes padding */ + /* 4 bytes padding */ #endif - ULONGLONG Reserved5; - volatile ULONG64 InterruptTimeBias; + ULONGLONG Reserved5; + volatile ULONG64 InterruptTimeBias; #endif #if (NTDDI_VERSION >= NTDDI_WIN7) - volatile ULONG64 TscQpcBias; - volatile ULONG ActiveProcessorCount; - volatile USHORT ActiveGroupCount; - USHORT Reserved4; - volatile ULONG AitSamplingValue; - volatile ULONG AppCompatFlag; - ULONGLONG SystemDllNativeRelocation; - ULONG SystemDllWowRelocation; - ULONG XStatePad[1]; - XSTATE_CONFIGURATION XState; + volatile ULONG64 TscQpcBias; + volatile ULONG ActiveProcessorCount; + volatile USHORT ActiveGroupCount; + USHORT Reserved4; + volatile ULONG AitSamplingValue; + volatile ULONG AppCompatFlag; + ULONGLONG SystemDllNativeRelocation; + ULONG SystemDllWowRelocation; + ULONG XStatePad[1]; + XSTATE_CONFIGURATION XState; #endif } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA; -extern NTKERNELAPI PVOID MmHighestUserAddress; -extern NTKERNELAPI PVOID MmSystemRangeStart; -extern NTKERNELAPI ULONG MmUserProbeAddress; - - -#ifdef _X86_ - -#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress -#define MM_SYSTEM_RANGE_START MmSystemRangeStart -#if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_) -#define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_ -extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_; -#else -#define MM_USER_PROBE_ADDRESS MmUserProbeAddress -#endif -#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 -#define MM_KSEG0_BASE MM_SYSTEM_RANGE_START -#define MM_SYSTEM_SPACE_END 0xFFFFFFFF -#if !defined (_X86PAE_) -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000 -#else -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000 -#endif - -#define KeGetPcr() PCR - -#define PCR_MINOR_VERSION 1 -#define PCR_MAJOR_VERSION 1 - -typedef struct _KPCR { - union { - NT_TIB NtTib; - struct { - struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList; - PVOID Used_StackBase; - PVOID Spare2; - PVOID TssCopy; - ULONG ContextSwitches; - KAFFINITY SetMemberCopy; - PVOID Used_Self; - }; - }; - struct _KPCR *SelfPcr; - struct _KPRCB *Prcb; - KIRQL Irql; - ULONG IRR; - ULONG IrrActive; - ULONG IDR; - PVOID KdVersionBlock; - struct _KIDTENTRY *IDT; - struct _KGDTENTRY *GDT; - struct _KTSS *TSS; - USHORT MajorVersion; - USHORT MinorVersion; - KAFFINITY SetMember; - ULONG StallScaleFactor; - UCHAR SpareUnused; - UCHAR Number; - UCHAR Spare0; - UCHAR SecondLevelCacheAssociativity; - ULONG VdmAlert; - ULONG KernelReserved[14]; - ULONG SecondLevelCacheSize; - ULONG HalReserved[16]; -} KPCR, *PKPCR; - -FORCEINLINE -ULONG -KeGetCurrentProcessorNumber(VOID) -{ - return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number)); -} - -#endif /* _X86_ */ - -#ifdef _AMD64_ - -#define PTI_SHIFT 12L -#define PDI_SHIFT 21L -#define PPI_SHIFT 30L -#define PXI_SHIFT 39L -#define PTE_PER_PAGE 512 -#define PDE_PER_PAGE 512 -#define PPE_PER_PAGE 512 -#define PXE_PER_PAGE 512 -#define PTI_MASK_AMD64 (PTE_PER_PAGE - 1) -#define PDI_MASK_AMD64 (PDE_PER_PAGE - 1) -#define PPI_MASK (PPE_PER_PAGE - 1) -#define PXI_MASK (PXE_PER_PAGE - 1) - -#define PXE_BASE 0xFFFFF6FB7DBED000ULL -#define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL -#define PPE_BASE 0xFFFFF6FB7DA00000ULL -#define PDE_BASE 0xFFFFF6FB40000000ULL -#define PTE_BASE 0xFFFFF68000000000ULL -#define PXE_TOP 0xFFFFF6FB7DBEDFFFULL -#define PPE_TOP 0xFFFFF6FB7DBFFFFFULL -#define PDE_TOP 0xFFFFF6FB7FFFFFFFULL -#define PTE_TOP 0xFFFFF6FFFFFFFFFFULL - -#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress -#define MM_SYSTEM_RANGE_START MmSystemRangeStart -#define MM_USER_PROBE_ADDRESS MmUserProbeAddress -#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL -#define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL - -typedef struct _KPCR -{ - _ANONYMOUS_UNION union - { - NT_TIB NtTib; - _ANONYMOUS_STRUCT struct - { - union _KGDTENTRY64 *GdtBase; - struct _KTSS64 *TssBase; - ULONG64 UserRsp; - struct _KPCR *Self; - struct _KPRCB *CurrentPrcb; - PKSPIN_LOCK_QUEUE LockArray; - PVOID Used_Self; - }; - }; - union _KIDTENTRY64 *IdtBase; - ULONG64 Unused[2]; - KIRQL Irql; - UCHAR SecondLevelCacheAssociativity; - UCHAR ObsoleteNumber; - UCHAR Fill0; - ULONG Unused0[3]; - USHORT MajorVersion; - USHORT MinorVersion; - ULONG StallScaleFactor; - PVOID Unused1[3]; - ULONG KernelReserved[15]; - ULONG SecondLevelCacheSize; - ULONG HalReserved[16]; - ULONG Unused2; - PVOID KdVersionBlock; - PVOID Unused3; - ULONG PcrAlign1[24]; -} KPCR, *PKPCR; - -FORCEINLINE -PKPCR -KeGetPcr(VOID) -{ - return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self)); -} - -FORCEINLINE -ULONG -KeGetCurrentProcessorNumber(VOID) -{ - return (ULONG)__readgsword(0x184); -} - -#endif /* _AMD64_ */ - -typedef enum _INTERLOCKED_RESULT { - ResultNegative = RESULT_NEGATIVE, - ResultZero = RESULT_ZERO, - ResultPositive = RESULT_POSITIVE -} INTERLOCKED_RESULT; - -/* Executive Types */ - -#define PROTECTED_POOL 0x80000000 - -typedef struct _ZONE_SEGMENT_HEADER { - SINGLE_LIST_ENTRY SegmentList; - PVOID Reserved; -} ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER; - -typedef struct _ZONE_HEADER { - SINGLE_LIST_ENTRY FreeList; - SINGLE_LIST_ENTRY SegmentList; - ULONG BlockSize; - ULONG TotalSegmentSize; -} ZONE_HEADER, *PZONE_HEADER; - -/* Executive Functions */ - -static __inline PVOID -ExAllocateFromZone( - IN PZONE_HEADER Zone) -{ - if (Zone->FreeList.Next) - Zone->FreeList.Next = Zone->FreeList.Next->Next; - return (PVOID) Zone->FreeList.Next; -} - -static __inline PVOID -ExFreeToZone( - IN PZONE_HEADER Zone, - IN PVOID Block) -{ - ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next; - Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block); - return ((PSINGLE_LIST_ENTRY) Block)->Next; -} - -/* - * PVOID - * ExInterlockedAllocateFromZone( - * IN PZONE_HEADER Zone, - * IN PKSPIN_LOCK Lock) - */ -#define ExInterlockedAllocateFromZone(Zone, Lock) \ - ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock)) - -/* PVOID - * ExInterlockedFreeToZone( - * IN PZONE_HEADER Zone, - * IN PVOID Block, - * IN PKSPIN_LOCK Lock); - */ -#define ExInterlockedFreeToZone(Zone, Block, Lock) \ - ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock) - -/* - * BOOLEAN - * ExIsFullZone( - * IN PZONE_HEADER Zone) - */ -#define ExIsFullZone(Zone) \ - ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL) - -/* BOOLEAN - * ExIsObjectInFirstZoneSegment( - * IN PZONE_HEADER Zone, - * IN PVOID Object); - */ -#define ExIsObjectInFirstZoneSegment(Zone,Object) \ - ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \ - ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \ - (Zone)->TotalSegmentSize)) ) - -#define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite -#define ExAcquireResourceShared ExAcquireResourceSharedLite -#define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite -#define ExDeleteResource ExDeleteResourceLite -#define ExInitializeResource ExInitializeResourceLite -#define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite -#define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite -#define ExIsResourceAcquired ExIsResourceAcquiredSharedLite -#define ExReleaseResourceForThread ExReleaseResourceForThreadLite - -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTKERNELAPI -NTSTATUS -NTAPI -ExExtendZone( - IN OUT PZONE_HEADER Zone, - IN OUT PVOID Segment, - IN ULONG SegmentSize); - -NTKERNELAPI -NTSTATUS -NTAPI -ExInitializeZone( - OUT PZONE_HEADER Zone, - IN ULONG BlockSize, - IN OUT PVOID InitialSegment, - IN ULONG InitialSegmentSize); - -NTKERNELAPI -NTSTATUS -NTAPI -ExInterlockedExtendZone( - IN OUT PZONE_HEADER Zone, - IN OUT PVOID Segment, - IN ULONG SegmentSize, - IN OUT PKSPIN_LOCK Lock); - -NTKERNELAPI -NTSTATUS -NTAPI -ExUuidCreate( - OUT UUID *Uuid); - -NTKERNELAPI -DECLSPEC_NORETURN -VOID -NTAPI -ExRaiseAccessViolation( - VOID); - -NTKERNELAPI -DECLSPEC_NORETURN -VOID -NTAPI -ExRaiseDatatypeMisalignment( - VOID); - -#endif - -#ifdef _X86_ - -NTKERNELAPI -INTERLOCKED_RESULT -FASTCALL -Exfi386InterlockedIncrementLong( - IN OUT LONG volatile *Addend); - -NTKERNELAPI -INTERLOCKED_RESULT -FASTCALL -Exfi386InterlockedDecrementLong( - IN PLONG Addend); - -NTKERNELAPI -ULONG -FASTCALL -Exfi386InterlockedExchangeUlong( - IN PULONG Target, - IN ULONG Value); - -#endif /* _X86_ */ +#define CmResourceTypeMaximum 8 + +typedef struct _CM_PCCARD_DEVICE_DATA { + UCHAR Flags; + UCHAR ErrorCode; + USHORT Reserved; + ULONG BusData; + ULONG DeviceId; + ULONG LegacyBaseAddress; + UCHAR IRQMap[16]; +} CM_PCCARD_DEVICE_DATA, *PCM_PCCARD_DEVICE_DATA; + +#define PCCARD_MAP_ERROR 0x01 +#define PCCARD_DEVICE_PCI 0x10 + +#define PCCARD_SCAN_DISABLED 0x01 +#define PCCARD_MAP_ZERO 0x02 +#define PCCARD_NO_TIMER 0x03 +#define PCCARD_NO_PIC 0x04 +#define PCCARD_NO_LEGACY_BASE 0x05 +#define PCCARD_DUP_LEGACY_BASE 0x06 +#define PCCARD_NO_CONTROLLERS 0x07 #ifndef _ARC_DDK_ #define _ARC_DDK_ @@ -3058,6 +2204,1209 @@ } CONFIGURATION_TYPE, *PCONFIGURATION_TYPE; #endif /* !_ARC_DDK_ */ +#if (NTDDI_VERSION < NTDDI_WIN7) || defined(_X86_) || !defined(NT_PROCESSOR_GROUPS) +#define SINGLE_GROUP_LEGACY_API 1 +#endif + +#if defined(_X86_) || defined(_AMD64_) +#define PAUSE_PROCESSOR YieldProcessor(); +#elif defined(_IA64_) +#define PAUSE_PROCESSOR __yield(); +#endif + +#define MAXIMUM_EXPANSION_SIZE (KERNEL_LARGE_STACK_SIZE - (PAGE_SIZE / 2)) + +typedef VOID +(NTAPI *PEXPAND_STACK_CALLOUT) ( + IN PVOID Parameter OPTIONAL); + + + + + + + + + +/* Kernel Functions */ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) && defined(SINGLE_GROUP_LEGACY_API) + +NTKERNELAPI +VOID +NTAPI +KeSetTargetProcessorDpc( + IN OUT PRKDPC Dpc, + IN CCHAR Number); + +NTKERNELAPI +KAFFINITY +NTAPI +KeQueryActiveProcessors(VOID); + +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +VOID +NTAPI +KeSetImportanceDpc( + IN OUT PRKDPC Dpc, + IN KDPC_IMPORTANCE Importance); + +NTKERNELAPI +LONG +NTAPI +KePulseEvent( + IN OUT PRKEVENT Event, + IN KPRIORITY Increment, + IN BOOLEAN Wait); + +NTKERNELAPI +LONG +NTAPI +KeSetBasePriorityThread( + IN OUT PRKTHREAD Thread, + IN LONG Increment); + +NTKERNELAPI +VOID +NTAPI +KeEnterCriticalRegion(VOID); + +NTKERNELAPI +VOID +NTAPI +KeLeaveCriticalRegion(VOID); + +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +KeBugCheck( + IN ULONG BugCheckCode); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +BOOLEAN +NTAPI +KeAreApcsDisabled(VOID); +#endif + +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +BOOLEAN +NTAPI +KeInvalidateAllCaches(VOID); +#endif + +#if (NTDDI_VERSION >= NTDDI_WS03SP1) + +NTKERNELAPI +NTSTATUS +NTAPI +KeExpandKernelStackAndCallout( + IN PEXPAND_STACK_CALLOUT Callout, + IN PVOID Parameter OPTIONAL, + IN SIZE_T Size); + +NTKERNELAPI +VOID +NTAPI +KeEnterGuardedRegion(VOID); + +NTKERNELAPI +VOID +NTAPI +KeLeaveGuardedRegion(VOID); + +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) && defined(SINGLE_GROUP_LEGACY_API) + +NTKERNELAPI +ULONG +NTAPI +KeQueryActiveProcessorCount( + OUT PKAFFINITY ActiveProcessors OPTIONAL); + +NTKERNELAPI +ULONG +NTAPI +KeQueryMaximumProcessorCount(VOID); + +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +ULONG +NTAPI +KeQueryActiveProcessorCountEx( + IN USHORT GroupNumber); + +NTKERNELAPI +ULONG +NTAPI +KeQueryMaximumProcessorCountEx( + IN USHORT GroupNumber); + +NTKERNELAPI +USHORT +NTAPI +KeQueryActiveGroupCount(VOID); + +NTKERNELAPI +USHORT +NTAPI +KeQueryMaximumGroupCount(VOID); + +NTKERNELAPI +KAFFINITY +NTAPI +KeQueryGroupAffinity( + IN USHORT GroupNumber); + +NTKERNELAPI +ULONG +NTAPI +KeGetCurrentProcessorNumberEx( + OUT PPROCESSOR_NUMBER ProcNumber OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +KeQueryNodeActiveAffinity( + IN USHORT NodeNumber, + OUT PGROUP_AFFINITY Affinity OPTIONAL, + OUT PUSHORT Count OPTIONAL); + +NTKERNELAPI +USHORT +NTAPI +KeQueryNodeMaximumProcessorCount( + IN USHORT NodeNumber); + +NTKERNELAPI +USHORT +NTAPI +KeQueryHighestNodeNumber(VOID); + +NTKERNELAPI +USHORT +NTAPI +KeGetCurrentNodeNumber(VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +KeQueryLogicalProcessorRelationship( + IN PPROCESSOR_NUMBER ProcessorNumber OPTIONAL, + IN LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType, + OUT PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Information OPTIONAL, + IN OUT PULONG Length); + +NTKERNELAPI +NTSTATUS +NTAPI +KeSetHardwareCounterConfiguration( + IN PHARDWARE_COUNTER CounterArray, + IN ULONG Count); + +NTKERNELAPI +NTSTATUS +NTAPI +KeQueryHardwareCounterConfiguration( + OUT PHARDWARE_COUNTER CounterArray, + IN ULONG MaximumCount, + OUT PULONG Count); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +NTKERNELAPI +VOID +FASTCALL +KeInvalidateRangeAllCaches( + IN PVOID BaseAddress, + IN ULONG Length); + +struct _LOADER_PARAMETER_BLOCK; +struct _CREATE_DISK; +struct _DRIVE_LAYOUT_INFORMATION_EX; +struct _SET_PARTITION_INFORMATION_EX; + +// +// GUID and UUID +// +#ifndef GUID_DEFINED +#include <guiddef.h> +#endif +typedef GUID UUID; + +/* +** IRP function codes +*/ + +#define IRP_MN_QUERY_DIRECTORY 0x01 +#define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02 + +#define IRP_MN_USER_FS_REQUEST 0x00 +#define IRP_MN_MOUNT_VOLUME 0x01 +#define IRP_MN_VERIFY_VOLUME 0x02 +#define IRP_MN_LOAD_FILE_SYSTEM 0x03 +#define IRP_MN_TRACK_LINK 0x04 +#define IRP_MN_KERNEL_CALL 0x04 + +#define IRP_MN_LOCK 0x01 +#define IRP_MN_UNLOCK_SINGLE 0x02 +#define IRP_MN_UNLOCK_ALL 0x03 +#define IRP_MN_UNLOCK_ALL_BY_KEY 0x04 + +#define IRP_MN_FLUSH_AND_PURGE 0x01 + +#define IRP_MN_NORMAL 0x00 +#define IRP_MN_DPC 0x01 +#define IRP_MN_MDL 0x02 +#define IRP_MN_COMPLETE 0x04 +#define IRP_MN_COMPRESSED 0x08 + +#define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC) +#define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL) +#define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC) + +#define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18 + +/* DEVICE_OBJECT.Flags */ + +#define DO_DEVICE_HAS_NAME 0x00000040 +#define DO_SYSTEM_BOOT_PARTITION 0x00000100 +#define DO_LONG_TERM_REQUESTS 0x00000200 +#define DO_NEVER_LAST_DEVICE 0x00000400 +#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000 +#define DO_SUPPORTS_TRANSACTIONS 0x00040000 +#define DO_FORCE_NEITHER_IO 0x00080000 +#define DO_VOLUME_DEVICE_OBJECT 0x00100000 +#define DO_SYSTEM_SYSTEM_PARTITION 0x00200000 +#define DO_SYSTEM_CRITICAL_PARTITION 0x00400000 +#define DO_DISALLOW_EXECUTE 0x00800000 + +#define DRVO_REINIT_REGISTERED 0x00000008 +#define DRVO_INITIALIZED 0x00000010 +#define DRVO_BOOTREINIT_REGISTERED 0x00000020 +#define DRVO_LEGACY_RESOURCES 0x00000040 + +typedef enum _ARBITER_REQUEST_SOURCE { + ArbiterRequestUndefined = -1, + ArbiterRequestLegacyReported, + ArbiterRequestHalReported, + ArbiterRequestLegacyAssigned, + ArbiterRequestPnpDetected, + ArbiterRequestPnpEnumerated +} ARBITER_REQUEST_SOURCE; + +typedef enum _ARBITER_RESULT { + ArbiterResultUndefined = -1, + ArbiterResultSuccess, + ArbiterResultExternalConflict, + ArbiterResultNullRequest +} ARBITER_RESULT; + +typedef enum _ARBITER_ACTION { + ArbiterActionTestAllocation, + ArbiterActionRetestAllocation, + ArbiterActionCommitAllocation, + ArbiterActionRollbackAllocation, + ArbiterActionQueryAllocatedResources, + ArbiterActionWriteReservedResources, + ArbiterActionQueryConflict, + ArbiterActionQueryArbitrate, + ArbiterActionAddReserved, + ArbiterActionBootAllocation +} ARBITER_ACTION, *PARBITER_ACTION; + +typedef struct _ARBITER_CONFLICT_INFO { + PDEVICE_OBJECT OwningObject; + ULONGLONG Start; + ULONGLONG End; +} ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO; + +typedef struct _ARBITER_PARAMETERS { + union { + struct { + IN OUT PLIST_ENTRY ArbitrationList; + IN ULONG AllocateFromCount; + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; + } TestAllocation; + struct { + IN OUT PLIST_ENTRY ArbitrationList; + IN ULONG AllocateFromCount; + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; + } RetestAllocation; + struct { + IN OUT PLIST_ENTRY ArbitrationList; + } BootAllocation; + struct { + OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources; + } QueryAllocatedResources; + struct { + IN PDEVICE_OBJECT PhysicalDeviceObject; + IN PIO_RESOURCE_DESCRIPTOR ConflictingResource; + OUT PULONG ConflictCount; + OUT PARBITER_CONFLICT_INFO *Conflicts; + } QueryConflict; + struct { + IN PLIST_ENTRY ArbitrationList; + } QueryArbitrate; + struct { + IN PDEVICE_OBJECT ReserveDevice; + } AddReserved; + } Parameters; +} ARBITER_PARAMETERS, *PARBITER_PARAMETERS; + +#define ARBITER_FLAG_BOOT_CONFIG 0x00000001 + +typedef struct _ARBITER_LIST_ENTRY { + LIST_ENTRY ListEntry; + ULONG AlternativeCount; + PIO_RESOURCE_DESCRIPTOR Alternatives; + PDEVICE_OBJECT PhysicalDeviceObject; + ARBITER_REQUEST_SOURCE RequestSource; + ULONG Flags; + LONG_PTR WorkSpace; + INTERFACE_TYPE InterfaceType; + ULONG SlotNumber; + ULONG BusNumber; + PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment; + PIO_RESOURCE_DESCRIPTOR SelectedAlternative; + ARBITER_RESULT Result; +} ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY; + +typedef NTSTATUS +(NTAPI *PARBITER_HANDLER)( + IN OUT PVOID Context, + IN ARBITER_ACTION Action, + IN OUT PARBITER_PARAMETERS Parameters); + +#define ARBITER_PARTIAL 0x00000001 + +typedef struct _ARBITER_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PARBITER_HANDLER ArbiterHandler; + ULONG Flags; +} ARBITER_INTERFACE, *PARBITER_INTERFACE; + +typedef enum _HAL_QUERY_INFORMATION_CLASS { + HalInstalledBusInformation, + HalProfileSourceInformation, + HalInformationClassUnused1, + HalPowerInformation, + HalProcessorSpeedInformation, + HalCallbackInformation, + HalMapRegisterInformation, + HalMcaLogInformation, + HalFrameBufferCachingInformation, + HalDisplayBiosInformation, + HalProcessorFeatureInformation, + HalNumaTopologyInterface, + HalErrorInformation, + HalCmcLogInformation, + HalCpeLogInformation, + HalQueryMcaInterface, + HalQueryAMLIIllegalIOPortAddresses, + HalQueryMaxHotPlugMemoryAddress, + HalPartitionIpiInterface, + HalPlatformInformation, + HalQueryProfileSourceList, + HalInitLogInformation, + HalFrequencyInformation, + HalProcessorBrandString, + HalHypervisorInformation, + HalPlatformTimerInformation, + HalAcpiAuditInformation +} HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS; + +typedef enum _HAL_SET_INFORMATION_CLASS { + HalProfileSourceInterval, + HalProfileSourceInterruptHandler, + HalMcaRegisterDriver, + HalKernelErrorHandler, + HalCmcRegisterDriver, + HalCpeRegisterDriver, + HalMcaLog, + HalCmcLog, + HalCpeLog, + HalGenerateCmcInterrupt, + HalProfileSourceTimerHandler, + HalEnlightenment, + HalProfileDpgoSourceInterruptHandler +} HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS; + +typedef struct _HAL_PROFILE_SOURCE_INTERVAL { + KPROFILE_SOURCE Source; + ULONG_PTR Interval; +} HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL; + +typedef struct _HAL_PROFILE_SOURCE_INFORMATION { + KPROFILE_SOURCE Source; + BOOLEAN Supported; + ULONG Interval; +} HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION; + +typedef struct _MAP_REGISTER_ENTRY { + PVOID MapRegister; + BOOLEAN WriteToDevice; +} MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY; + +typedef struct _DEBUG_DEVICE_ADDRESS { + UCHAR Type; + BOOLEAN Valid; + UCHAR Reserved[2]; + PUCHAR TranslatedAddress; + ULONG Length; +} DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS; + +typedef struct _DEBUG_MEMORY_REQUIREMENTS { + PHYSICAL_ADDRESS Start; + PHYSICAL_ADDRESS MaxEnd; + PVOID VirtualAddress; + ULONG Length; + BOOLEAN Cached; + BOOLEAN Aligned; +} DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS; + +typedef struct _DEBUG_DEVICE_DESCRIPTOR { + ULONG Bus; + ULONG Slot; + USHORT Segment; + USHORT VendorID; + USHORT DeviceID; + UCHAR BaseClass; + UCHAR SubClass; + UCHAR ProgIf; + BOOLEAN Initialized; + BOOLEAN Configured; + DEBUG_DEVICE_ADDRESS BaseAddress[6]; + DEBUG_MEMORY_REQUIREMENTS Memory; +} DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR; + +typedef struct _PM_DISPATCH_TABLE { + ULONG Signature; + ULONG Version; + PVOID Function[1]; +} PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE; + +typedef enum _RESOURCE_TRANSLATION_DIRECTION { + TranslateChildToParent, + TranslateParentToChild +} RESOURCE_TRANSLATION_DIRECTION; + +typedef NTSTATUS +(NTAPI *PTRANSLATE_RESOURCE_HANDLER)( + IN OUT PVOID Context, + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, + IN RESOURCE_TRANSLATION_DIRECTION Direction, + IN ULONG AlternativesCount OPTIONAL, + IN IO_RESOURCE_DESCRIPTOR Alternatives[], + IN PDEVICE_OBJECT PhysicalDeviceObject, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target); + +typedef NTSTATUS +(NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)( + IN PVOID Context OPTIONAL, + IN PIO_RESOURCE_DESCRIPTOR Source, + IN PDEVICE_OBJECT PhysicalDeviceObject, + OUT PULONG TargetCount, + OUT PIO_RESOURCE_DESCRIPTOR *Target); + +typedef struct _TRANSLATOR_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PTRANSLATE_RESOURCE_HANDLER TranslateResources; + PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements; +} TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE; + +typedef VOID +(FASTCALL *pHalExamineMBR)( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG MBRTypeIdentifier, + OUT PVOID *Buffer); + +typedef NTSTATUS +(FASTCALL *pHalIoReadPartitionTable)( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN BOOLEAN ReturnRecognizedPartitions, + OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer); + +typedef NTSTATUS +(FASTCALL *pHalIoSetPartitionInformation)( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG PartitionNumber, + IN ULONG PartitionType); + +typedef NTSTATUS +(FASTCALL *pHalIoWritePartitionTable)( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG SectorsPerTrack, + IN ULONG NumberOfHeads, + IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); + +typedef PBUS_HANDLER +(FASTCALL *pHalHandlerForBus)( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber); + +typedef VOID +(FASTCALL *pHalReferenceBusHandler)( + IN PBUS_HANDLER BusHandler); + +typedef NTSTATUS +(NTAPI *pHalQuerySystemInformation)( + IN HAL_QUERY_INFORMATION_CLASS InformationClass, + IN ULONG BufferSize, + IN OUT PVOID Buffer, + OUT PULONG ReturnedLength); + +typedef NTSTATUS +(NTAPI *pHalSetSystemInformation)( + IN HAL_SET_INFORMATION_CLASS InformationClass, + IN ULONG BufferSize, + IN PVOID Buffer); + +typedef NTSTATUS +(NTAPI *pHalQueryBusSlots)( + IN PBUS_HANDLER BusHandler, + IN ULONG BufferSize, + OUT PULONG SlotNumbers, + OUT PULONG ReturnedLength); + +typedef NTSTATUS +(NTAPI *pHalInitPnpDriver)( + VOID); + +typedef NTSTATUS +(NTAPI *pHalInitPowerManagement)( + IN PPM_DISPATCH_TABLE PmDriverDispatchTable, + OUT PPM_DISPATCH_TABLE *PmHalDispatchTable); + +typedef struct _DMA_ADAPTER* +(NTAPI *pHalGetDmaAdapter)( + IN PVOID Context, + IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, + OUT PULONG NumberOfMapRegisters); + +typedef NTSTATUS +(NTAPI *pHalGetInterruptTranslator)( + IN INTERFACE_TYPE ParentInterfaceType, + IN ULONG ParentBusNumber, + IN INTERFACE_TYPE BridgeInterfaceType, + IN USHORT Size, + IN USHORT Version, + OUT PTRANSLATOR_INTERFACE Translator, + OUT PULONG BridgeBusNumber); + +typedef NTSTATUS +(NTAPI *pHalStartMirroring)( + VOID); + +typedef NTSTATUS +(NTAPI *pHalEndMirroring)( + IN ULONG PassNumber); + +typedef NTSTATUS +(NTAPI *pHalMirrorPhysicalMemory)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN LARGE_INTEGER NumberOfBytes); + +typedef NTSTATUS +(NTAPI *pHalMirrorVerify)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN LARGE_INTEGER NumberOfBytes); + +typedef VOID +(NTAPI *pHalEndOfBoot)( + VOID); + +typedef +BOOLEAN +(NTAPI *pHalTranslateBusAddress)( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress); + +typedef +NTSTATUS +(NTAPI *pHalAssignSlotResources)( + IN PUNICODE_STRING RegistryPath, + IN PUNICODE_STRING DriverClassName OPTIONAL, + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT DeviceObject, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN OUT PCM_RESOURCE_LIST *AllocatedResources); + +typedef +VOID +(NTAPI *pHalHaltSystem)( + VOID); + +typedef +BOOLEAN +(NTAPI *pHalResetDisplay)( + VOID); + +typedef +UCHAR +(NTAPI *pHalVectorToIDTEntry)( + ULONG Vector); + +typedef +BOOLEAN +(NTAPI *pHalFindBusAddressTranslation)( + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress, + IN OUT PULONG_PTR Context, + IN BOOLEAN NextBus); + +typedef +NTSTATUS +(NTAPI *pKdSetupPciDeviceForDebugging)( + IN PVOID LoaderBlock OPTIONAL, + IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); + +typedef +NTSTATUS +(NTAPI *pKdReleasePciDeviceForDebugging)( + IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); + +typedef +PVOID +(NTAPI *pKdGetAcpiTablePhase0)( + IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, + IN ULONG Signature); + +typedef +PVOID +(NTAPI *pHalGetAcpiTable)( + IN ULONG Signature, + IN PCSTR OemId OPTIONAL, + IN PCSTR OemTableId OPTIONAL); + +typedef +VOID +(NTAPI *pKdCheckPowerButton)( + VOID); + +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef +PVOID +(NTAPI *pKdMapPhysicalMemory64)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG NumberPages, + IN BOOLEAN FlushCurrentTLB); + +typedef +VOID +(NTAPI *pKdUnmapVirtualAddress)( + IN PVOID VirtualAddress, + IN ULONG NumberPages, + IN BOOLEAN FlushCurrentTLB); +#else +typedef +PVOID +(NTAPI *pKdMapPhysicalMemory64)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG NumberPages); + +typedef +VOID +(NTAPI *pKdUnmapVirtualAddress)( + IN PVOID VirtualAddress, + IN ULONG NumberPages); +#endif + + +typedef +ULONG +(NTAPI *pKdGetPciDataByOffset)( + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef +ULONG +(NTAPI *pKdSetPciDataByOffset)( + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef BOOLEAN +(NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)( + IN ULONG Columns, + IN ULONG Rows); + +typedef +VOID +(NTAPI *PCI_ERROR_HANDLER_CALLBACK)( + VOID); + +typedef +VOID +(NTAPI *pHalSetPciErrorHandlerCallback)( + IN PCI_ERROR_HANDLER_CALLBACK Callback); + +#if 1 /* Not present in WDK 7600 */ +typedef VOID +(FASTCALL *pHalIoAssignDriveLetters)( + IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, + IN PSTRING NtDeviceName, + OUT PUCHAR NtSystemPath, + OUT PSTRING NtSystemPathString); +#endif + +typedef struct { + ULONG Version; + pHalQuerySystemInformation HalQuerySystemInformation; + pHalSetSystemInformation HalSetSystemInformation; + pHalQueryBusSlots HalQueryBusSlots; + ULONG Spare1; + pHalExamineMBR HalExamineMBR; +#if 1 /* Not present in WDK 7600 */ + pHalIoAssignDriveLetters HalIoAssignDriveLetters; +#endif + pHalIoReadPartitionTable HalIoReadPartitionTable; + pHalIoSetPartitionInformation HalIoSetPartitionInformation; + pHalIoWritePartitionTable HalIoWritePartitionTable; + pHalHandlerForBus HalReferenceHandlerForBus; + pHalReferenceBusHandler HalReferenceBusHandler; + pHalReferenceBusHandler HalDereferenceBusHandler; + pHalInitPnpDriver HalInitPnpDriver; + pHalInitPowerManagement HalInitPowerManagement; + pHalGetDmaAdapter HalGetDmaAdapter; + pHalGetInterruptTranslator HalGetInterruptTranslator; + pHalStartMirroring HalStartMirroring; + pHalEndMirroring HalEndMirroring; + pHalMirrorPhysicalMemory HalMirrorPhysicalMemory; + pHalEndOfBoot HalEndOfBoot; + pHalMirrorVerify HalMirrorVerify; + pHalGetAcpiTable HalGetCachedAcpiTable; + pHalSetPciErrorHandlerCallback HalSetPciErrorHandlerCallback; +#if defined(_IA64_) + pHalGetErrorCapList HalGetErrorCapList; + pHalInjectError HalInjectError; +#endif +} HAL_DISPATCH, *PHAL_DISPATCH; + +/* GCC/MSVC and WDK compatible declaration */ +extern NTKERNELAPI HAL_DISPATCH HalDispatchTable; + +#if defined(_NTOSKRNL_) || defined(_BLDR_) +#define HALDISPATCH (&HalDispatchTable) +#else +/* This is a WDK compatibility definition */ +#define HalDispatchTable (&HalDispatchTable) +#define HALDISPATCH HalDispatchTable +#endif + +#define HAL_DISPATCH_VERSION 3 /* FIXME: when to use 4? */ +#define HalDispatchTableVersion HALDISPATCH->Version +#define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation +#define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation +#define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots +#define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus +#define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler +#define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler +#define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver +#define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement +#define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter +#define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator +#define HalStartMirroring HALDISPATCH->HalStartMirroring +#define HalEndMirroring HALDISPATCH->HalEndMirroring +#define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory +#define HalEndOfBoot HALDISPATCH->HalEndOfBoot +#define HalMirrorVerify HALDISPATCH->HalMirrorVerify + +typedef struct _IMAGE_INFO { + _ANONYMOUS_UNION union { + ULONG Properties; + _ANONYMOUS_STRUCT struct { + ULONG ImageAddressingMode:8; + ULONG SystemModeImage:1; + ULONG ImageMappedToAllPids:1; + ULONG ExtendedInfoPresent:1; + ULONG Reserved:22; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + PVOID ImageBase; + ULONG ImageSelector; + SIZE_T ImageSize; + ULONG ImageSectionNumber; +} IMAGE_INFO, *PIMAGE_INFO; + +#define IMAGE_ADDRESSING_MODE_32BIT 3 + +typedef enum _IO_QUERY_DEVICE_DATA_FORMAT { + IoQueryDeviceIdentifier = 0, + IoQueryDeviceConfigurationData, + IoQueryDeviceComponentInformation, + IoQueryDeviceMaxData +} IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT; + +typedef struct _DISK_SIGNATURE { + ULONG PartitionStyle; + _ANONYMOUS_UNION union { + struct { + ULONG Signature; + ULONG CheckSum; + } Mbr; + struct { + GUID DiskId; + } Gpt; + } DUMMYUNIONNAME; +} DISK_SIGNATURE, *PDISK_SIGNATURE; + +extern NTKERNELAPI PVOID MmHighestUserAddress; +extern NTKERNELAPI PVOID MmSystemRangeStart; +extern NTKERNELAPI ULONG MmUserProbeAddress; + + +#ifdef _X86_ + +#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress +#define MM_SYSTEM_RANGE_START MmSystemRangeStart +#if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_) +#define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_ +extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_; +#else +#define MM_USER_PROBE_ADDRESS MmUserProbeAddress +#endif +#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 +#define MM_KSEG0_BASE MM_SYSTEM_RANGE_START +#define MM_SYSTEM_SPACE_END 0xFFFFFFFF +#if !defined (_X86PAE_) +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000 +#else +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000 +#endif + +#define KeGetPcr() PCR + +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 + +typedef struct _KPCR { + union { + NT_TIB NtTib; + struct { + struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList; + PVOID Used_StackBase; + PVOID Spare2; + PVOID TssCopy; + ULONG ContextSwitches; + KAFFINITY SetMemberCopy; + PVOID Used_Self; + }; + }; + struct _KPCR *SelfPcr; + struct _KPRCB *Prcb; + KIRQL Irql; + ULONG IRR; + ULONG IrrActive; + ULONG IDR; + PVOID KdVersionBlock; + struct _KIDTENTRY *IDT; + struct _KGDTENTRY *GDT; + struct _KTSS *TSS; + USHORT MajorVersion; + USHORT MinorVersion; + KAFFINITY SetMember; + ULONG StallScaleFactor; + UCHAR SpareUnused; + UCHAR Number; + UCHAR Spare0; + UCHAR SecondLevelCacheAssociativity; + ULONG VdmAlert; + ULONG KernelReserved[14]; + ULONG SecondLevelCacheSize; + ULONG HalReserved[16]; +} KPCR, *PKPCR; + +FORCEINLINE +ULONG +KeGetCurrentProcessorNumber(VOID) +{ + return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number)); +} + +#endif /* _X86_ */ + +#ifdef _AMD64_ + +#define PTI_SHIFT 12L +#define PDI_SHIFT 21L +#define PPI_SHIFT 30L +#define PXI_SHIFT 39L +#define PTE_PER_PAGE 512 +#define PDE_PER_PAGE 512 +#define PPE_PER_PAGE 512 +#define PXE_PER_PAGE 512 +#define PTI_MASK_AMD64 (PTE_PER_PAGE - 1) +#define PDI_MASK_AMD64 (PDE_PER_PAGE - 1) +#define PPI_MASK (PPE_PER_PAGE - 1) +#define PXI_MASK (PXE_PER_PAGE - 1) + +#define PXE_BASE 0xFFFFF6FB7DBED000ULL +#define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL +#define PPE_BASE 0xFFFFF6FB7DA00000ULL +#define PDE_BASE 0xFFFFF6FB40000000ULL +#define PTE_BASE 0xFFFFF68000000000ULL +#define PXE_TOP 0xFFFFF6FB7DBEDFFFULL +#define PPE_TOP 0xFFFFF6FB7DBFFFFFULL +#define PDE_TOP 0xFFFFF6FB7FFFFFFFULL +#define PTE_TOP 0xFFFFF6FFFFFFFFFFULL + +#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress +#define MM_SYSTEM_RANGE_START MmSystemRangeStart +#define MM_USER_PROBE_ADDRESS MmUserProbeAddress +#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL +#define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL + +typedef struct _KPCR +{ + _ANONYMOUS_UNION union + { + NT_TIB NtTib; + _ANONYMOUS_STRUCT struct + { + union _KGDTENTRY64 *GdtBase; + struct _KTSS64 *TssBase; + ULONG64 UserRsp; + struct _KPCR *Self; + struct _KPRCB *CurrentPrcb; + PKSPIN_LOCK_QUEUE LockArray; + PVOID Used_Self; + }; + }; + union _KIDTENTRY64 *IdtBase; + ULONG64 Unused[2]; + KIRQL Irql; + UCHAR SecondLevelCacheAssociativity; + UCHAR ObsoleteNumber; + UCHAR Fill0; + ULONG Unused0[3]; + USHORT MajorVersion; + USHORT MinorVersion; + ULONG StallScaleFactor; + PVOID Unused1[3]; + ULONG KernelReserved[15]; + ULONG SecondLevelCacheSize; + ULONG HalReserved[16]; + ULONG Unused2; + PVOID KdVersionBlock; + PVOID Unused3; + ULONG PcrAlign1[24]; +} KPCR, *PKPCR; + +FORCEINLINE +PKPCR +KeGetPcr(VOID) +{ + return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self)); +} + +FORCEINLINE +ULONG +KeGetCurrentProcessorNumber(VOID) +{ + return (ULONG)__readgsword(0x184); +} + +#endif /* _AMD64_ */ + +typedef enum _INTERLOCKED_RESULT { + ResultNegative = RESULT_NEGATIVE, + ResultZero = RESULT_ZERO, + ResultPositive = RESULT_POSITIVE +} INTERLOCKED_RESULT; + +/* Executive Types */ + +#define PROTECTED_POOL 0x80000000 + +typedef struct _ZONE_SEGMENT_HEADER { + SINGLE_LIST_ENTRY SegmentList; + PVOID Reserved; +} ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER; + +typedef struct _ZONE_HEADER { + SINGLE_LIST_ENTRY FreeList; + SINGLE_LIST_ENTRY SegmentList; + ULONG BlockSize; + ULONG TotalSegmentSize; +} ZONE_HEADER, *PZONE_HEADER; + +/* Executive Functions */ + +static __inline PVOID +ExAllocateFromZone( + IN PZONE_HEADER Zone) +{ + if (Zone->FreeList.Next) + Zone->FreeList.Next = Zone->FreeList.Next->Next; + return (PVOID) Zone->FreeList.Next; +} + +static __inline PVOID +ExFreeToZone( + IN PZONE_HEADER Zone, + IN PVOID Block) +{ + ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next; + Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block); + return ((PSINGLE_LIST_ENTRY) Block)->Next; +} + +/* + * PVOID + * ExInterlockedAllocateFromZone( + * IN PZONE_HEADER Zone, + * IN PKSPIN_LOCK Lock) + */ +#define ExInterlockedAllocateFromZone(Zone, Lock) \ + ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock)) + +/* PVOID + * ExInterlockedFreeToZone( + * IN PZONE_HEADER Zone, + * IN PVOID Block, + * IN PKSPIN_LOCK Lock); + */ +#define ExInterlockedFreeToZone(Zone, Block, Lock) \ + ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock) + +/* + * BOOLEAN + * ExIsFullZone( + * IN PZONE_HEADER Zone) + */ +#define ExIsFullZone(Zone) \ + ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL) + +/* BOOLEAN + * ExIsObjectInFirstZoneSegment( + * IN PZONE_HEADER Zone, + * IN PVOID Object); + */ +#define ExIsObjectInFirstZoneSegment(Zone,Object) \ + ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \ + ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \ + (Zone)->TotalSegmentSize)) ) + +#define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite +#define ExAcquireResourceShared ExAcquireResourceSharedLite +#define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite +#define ExDeleteResource ExDeleteResourceLite +#define ExInitializeResource ExInitializeResourceLite +#define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite +#define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite +#define ExIsResourceAcquired ExIsResourceAcquiredSharedLite +#define ExReleaseResourceForThread ExReleaseResourceForThreadLite + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +NTSTATUS +NTAPI +ExExtendZone( + IN OUT PZONE_HEADER Zone, + IN OUT PVOID Segment, + IN ULONG SegmentSize); + +NTKERNELAPI +NTSTATUS +NTAPI +ExInitializeZone( + OUT PZONE_HEADER Zone, + IN ULONG BlockSize, + IN OUT PVOID InitialSegment, + IN ULONG InitialSegmentSize); + +NTKERNELAPI +NTSTATUS +NTAPI +ExInterlockedExtendZone( + IN OUT PZONE_HEADER Zone, + IN OUT PVOID Segment, + IN ULONG SegmentSize, + IN OUT PKSPIN_LOCK Lock); + +NTKERNELAPI +NTSTATUS +NTAPI +ExUuidCreate( + OUT UUID *Uuid); + +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +ExRaiseAccessViolation( + VOID); + +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +ExRaiseDatatypeMisalignment( + VOID); + +#endif + +#ifdef _X86_ + +NTKERNELAPI +INTERLOCKED_RESULT +FASTCALL +Exfi386InterlockedIncrementLong( + IN OUT LONG volatile *Addend); + +NTKERNELAPI +INTERLOCKED_RESULT +FASTCALL +Exfi386InterlockedDecrementLong( + IN PLONG Addend); + +NTKERNELAPI +ULONG +FASTCALL +Exfi386InterlockedExchangeUlong( + IN PULONG Target, + IN ULONG Value); + +#endif /* _X86_ */ + typedef struct _CONTROLLER_OBJECT { CSHORT Type; CSHORT Size; @@ -3661,34 +4010,6 @@ #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ -/* Kernel Functions */ - -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTKERNELAPI -DECLSPEC_NORETURN -VOID -NTAPI -KeBugCheck( - IN ULONG BugCheckCode); - -NTKERNELAPI -LONG -NTAPI -KePulseEvent( - IN OUT PRKEVENT Event, - IN KPRIORITY Increment, - IN BOOLEAN Wait); - -NTKERNELAPI -LONG -NTAPI -KeSetBasePriorityThread( - IN OUT PRKTHREAD Thread, - IN LONG Increment); - -#endif - /* Memory Manager Types */ typedef struct _PHYSICAL_MEMORY_RANGE {
14 years, 9 months
1
0
0
0
[ekohl] 46233: [ADVAPI32] - Create a service status handle when a service starts and destroy it after it has been stopped.
by ekohl@svn.reactos.org
Author: ekohl Date: Wed Mar 17 00:10:03 2010 New Revision: 46233 URL:
http://svn.reactos.org/svn/reactos?rev=46233&view=rev
Log: [ADVAPI32] - Create a service status handle when a service starts and destroy it after it has been stopped. Modified: trunk/reactos/dll/win32/advapi32/service/scm.c trunk/reactos/dll/win32/advapi32/service/sctrl.c Modified: trunk/reactos/dll/win32/advapi32/service/scm.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service…
============================================================================== --- trunk/reactos/dll/win32/advapi32/service/scm.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/service/scm.c [iso-8859-1] Wed Mar 17 00:10:03 2010 @@ -122,61 +122,6 @@ RPC_STATUS status; TRACE("SVCCTL_HANDLEW_unbind() called\n"); - - status = RpcBindingFree(&hBinding); - if (status != RPC_S_OK) - { - ERR("RpcBindingFree returned 0x%x\n", status); - } -} - - -handle_t __RPC_USER -RPC_SERVICE_STATUS_HANDLE_bind(RPC_SERVICE_STATUS_HANDLE hServiceStatus) -{ - handle_t hBinding = NULL; - LPWSTR pszStringBinding; - RPC_STATUS status; - - TRACE("RPC_SERVICE_STATUS_HANDLE_bind() called\n"); - - status = RpcStringBindingComposeW(NULL, - L"ncacn_np", - NULL, - L"\\pipe\\ntsvcs", - NULL, - &pszStringBinding); - if (status != RPC_S_OK) - { - ERR("RpcStringBindingCompose returned 0x%x\n", status); - return NULL; - } - - /* Set the binding handle that will be used to bind to the server. */ - status = RpcBindingFromStringBindingW(pszStringBinding, - &hBinding); - if (status != RPC_S_OK) - { - ERR("RpcBindingFromStringBinding returned 0x%x\n", status); - } - - status = RpcStringFreeW(&pszStringBinding); - if (status != RPC_S_OK) - { - ERR("RpcStringFree returned 0x%x\n", status); - } - - return hBinding; -} - - -void __RPC_USER -RPC_SERVICE_STATUS_HANDLE_unbind(RPC_SERVICE_STATUS_HANDLE hServiceStatus, - handle_t hBinding) -{ - RPC_STATUS status; - - TRACE("RPC_SERVICE_STATUS_HANDLE_unbind() called\n"); status = RpcBindingFree(&hBinding); if (status != RPC_S_OK) Modified: trunk/reactos/dll/win32/advapi32/service/sctrl.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service…
============================================================================== --- trunk/reactos/dll/win32/advapi32/service/sctrl.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/service/sctrl.c [iso-8859-1] Wed Mar 17 00:10:03 2010 @@ -41,9 +41,86 @@ static DWORD dwActiveServiceCount = 0; static PACTIVE_SERVICE lpActiveServices = NULL; +static handle_t hStatusBinding = NULL; /* FUNCTIONS *****************************************************************/ + +handle_t __RPC_USER +RPC_SERVICE_STATUS_HANDLE_bind(RPC_SERVICE_STATUS_HANDLE hServiceStatus) +{ + return hStatusBinding; +} + + +void __RPC_USER +RPC_SERVICE_STATUS_HANDLE_unbind(RPC_SERVICE_STATUS_HANDLE hServiceStatus, + handle_t hBinding) +{ +} + + +static RPC_STATUS +ScCreateStatusBinding(VOID) +{ + LPWSTR pszStringBinding; + RPC_STATUS status; + + TRACE("ScCreateStatusBinding() called\n"); + + status = RpcStringBindingComposeW(NULL, + L"ncacn_np", + NULL, + L"\\pipe\\ntsvcs", + NULL, + &pszStringBinding); + if (status != RPC_S_OK) + { + ERR("RpcStringBindingCompose returned 0x%x\n", status); + return status; + } + + /* Set the binding handle that will be used to bind to the server. */ + status = RpcBindingFromStringBindingW(pszStringBinding, + &hStatusBinding); + if (status != RPC_S_OK) + { + ERR("RpcBindingFromStringBinding returned 0x%x\n", status); + } + + status = RpcStringFreeW(&pszStringBinding); + if (status != RPC_S_OK) + { + ERR("RpcStringFree returned 0x%x\n", status); + } + + return status; +} + + +static RPC_STATUS +ScDestroyStatusBinding(VOID) +{ + RPC_STATUS status; + + TRACE("ScDestroyStatusBinding() called\n"); + + if (hStatusBinding == NULL) + return RPC_S_OK; + + status = RpcBindingFree(&hStatusBinding); + if (status != RPC_S_OK) + { + ERR("RpcBindingFree returned 0x%x\n", status); + } + else + { + hStatusBinding = NULL; + } + + return status; +} + static PACTIVE_SERVICE ScLookupServiceByServiceName(LPCWSTR lpServiceName) @@ -259,7 +336,6 @@ TRACE("Sent Process ID %lu\n", dwProcessId); - return ERROR_SUCCESS; } @@ -403,7 +479,7 @@ } else { - dwError = ERROR_NOT_FOUND; + dwError = ERROR_SERVICE_DOES_NOT_EXIST; } ReplyPacket.dwError = dwError; @@ -747,7 +823,12 @@ return FALSE; } + ScCreateStatusBinding(); + ScServiceDispatcher(hPipe, lpMessageBuffer, 256); + + ScDestroyStatusBinding(); + CloseHandle(hPipe); /* Free the message buffer */ @@ -837,7 +918,12 @@ return FALSE; } + ScCreateStatusBinding(); + ScServiceDispatcher(hPipe, lpMessageBuffer, 256); + + ScDestroyStatusBinding(); + CloseHandle(hPipe); /* Free the message buffer */
14 years, 9 months
1
0
0
0
[dreimer] 46232: Update some more apps. (OpenOffice 3.2.0, SciTE 2.03)
by dreimer@svn.reactos.org
Author: dreimer Date: Tue Mar 16 23:37:53 2010 New Revision: 46232 URL:
http://svn.reactos.org/svn/reactos?rev=46232&view=rev
Log: Update some more apps. (OpenOffice 3.2.0, SciTE 2.03) Modified: trunk/reactos/base/applications/rapps/rapps/openoffice3.0.txt trunk/reactos/base/applications/rapps/rapps/scite.txt Modified: trunk/reactos/base/applications/rapps/rapps/openoffice3.0.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps/ra…
============================================================================== --- trunk/reactos/base/applications/rapps/rapps/openoffice3.0.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/rapps/rapps/openoffice3.0.txt [iso-8859-1] Tue Mar 16 23:37:53 2010 @@ -2,30 +2,30 @@ [Section] Name = OpenOffice 3.0 -Version = 3.1.1 +Version = 3.2.0 Licence = LGPL Description = THE Open Source Office Suite. -Size = 134.3MB +Size = 135.4MB Category = 6 URLSite =
http://www.openoffice.org/
-URLDownload =
http://ftp.tu-chemnitz.de/pub/openoffice/stable/3.1.1/OOo_3.1.1_Win32Intel_…
+URLDownload =
http://ftp.tu-chemnitz.de/pub/openoffice/stable/3.2.0/OOo_3.2.0_Win32Intel_…
CDPath = none [Section.0407] Description = DIE Open Source Office Suite. URLSite =
http://de.openoffice.org/
-Size = 142.9MB -URLDownload =
http://ftp.tu-chemnitz.de/pub/openoffice/localized/de/3.1.1/OOo_3.1.1_Win32…
+Size = 145.8MB +URLDownload =
http://ftp.tu-chemnitz.de/pub/openoffice/localized/de/3.2.0/OOo_3.2.0_Win32…
[Section.040a] Description = La suite de ofimática de código abierto. URLSite =
http://es.openoffice.org/
Version = 3.1.0 -Size = 130.0MB -URLDownload =
http://ftp.tu-chemnitz.de/pub/openoffice/localized/es/3.1.0/OOo_3.1.0_Win32…
+Size = 119.4MB +URLDownload =
http://ftp.tu-chemnitz.de/pub/openoffice/localized/es/3.2.0/OOo_3.2.0_Win32…
[Section.0415] Description = Otwarty pakiet biurowy. URLSite =
http://pl.openoffice.org/
-Size = 147.1MB -URLDownload =
http://ftp.tu-chemnitz.de/pub/openoffice/localized/pl/3.1.1/OOo_3.1.1_Win32…
+Size = 133.2MB +URLDownload =
http://ftp.tu-chemnitz.de/pub/openoffice/localized/pl/3.2.0/OOo_3.2.0_Win32…
Modified: trunk/reactos/base/applications/rapps/rapps/scite.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps/ra…
============================================================================== --- trunk/reactos/base/applications/rapps/rapps/scite.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/rapps/rapps/scite.txt [iso-8859-1] Tue Mar 16 23:37:53 2010 @@ -2,13 +2,13 @@ [Section] Name = SciTE -Version = 2.02 +Version = 2.03 Licence = Freeware Description = SciTE is a SCIntilla based Text Editor. Originally built to demonstrate Scintilla, it has grown to be a generally useful editor with facilities for building and running programs. Size = 0.6M Category = 7 URLSite =
http://www.scintilla.org/
-URLDownload =
http://ovh.dl.sourceforge.net/sourceforge/scintilla/Sc202.exe
+URLDownload =
http://ovh.dl.sourceforge.net/sourceforge/scintilla/Sc203.exe
CDPath = none [Section.0407]
14 years, 9 months
1
0
0
0
[cwittich] 46231: [USER32] reduce diff to wine
by cwittich@svn.reactos.org
Author: cwittich Date: Tue Mar 16 23:21:20 2010 New Revision: 46231 URL:
http://svn.reactos.org/svn/reactos?rev=46231&view=rev
Log: [USER32] reduce diff to wine Modified: trunk/reactos/dll/win32/user32/windows/menu.c Modified: trunk/reactos/dll/win32/user32/windows/menu.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/m…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/menu.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/menu.c [iso-8859-1] Tue Mar 16 23:21:20 2010 @@ -12,15 +12,25 @@ /* INCLUDES ******************************************************************/ #include <user32.h> - #include <wine/debug.h> -WINE_DEFAULT_DEBUG_CHANNEL(user32); LRESULT DefWndNCPaint(HWND hWnd, HRGN hRgn, BOOL Active); +WINE_DEFAULT_DEBUG_CHANNEL(menu); + /* internal popup menu window messages */ -#define MM_SETMENUHANDLE (WM_USER + 0) -#define MM_GETMENUHANDLE (WM_USER + 1) + +#define MM_SETMENUHANDLE (WM_USER + 0) +#define MM_GETMENUHANDLE (WM_USER + 1) + +/* internal flags for menu tracking */ + +#define TF_ENDMENU 0x10000 +#define TF_SUSPENDPOPUP 0x20000 +#define TF_SKIPREMOVE 0x40000 + +#define ITEM_PREV -1 +#define ITEM_NEXT 1 /* Internal MenuTrackMenu() flags */ #define TPM_INTERNAL 0xF0000000 @@ -28,13 +38,14 @@ #define TPM_BUTTONDOWN 0x40000000 /* menu was clicked before tracking */ #define TPM_POPUPMENU 0x20000000 /* menu is a popup menu */ -/* TYPES *********************************************************************/ #define MENU_TYPE_MASK (MF_STRING | MF_BITMAP | MF_OWNERDRAW | MF_SEPARATOR) #define MENU_ITEM_TYPE(flags) ((flags) & MENU_TYPE_MASK) + +/* macro to test that flags do not indicate bitmap, ownerdraw or separator */ #define IS_STRING_ITEM(flags) (MF_STRING == MENU_ITEM_TYPE(flags)) -#define IS_BITMAP_ITEM(flags) (MF_BITMAP == MENU_ITEM_TYPE(flags)) +#define IS_MAGIC_BITMAP(id) ((id) && ((INT_PTR)(id) < 12) && ((INT_PTR)(id) >= -1)) #define IS_SYSTEM_MENU(MenuInfo) \ (0 == ((MenuInfo)->Flags & MF_POPUP) && 0 != ((MenuInfo)->Flags & MF_SYSMENU)) @@ -42,26 +53,24 @@ #define IS_SYSTEM_POPUP(MenuInfo) \ (0 != ((MenuInfo)->Flags & MF_POPUP) && 0 != ((MenuInfo)->Flags & MF_SYSMENU)) -#define IS_MAGIC_BITMAP(id) ((id) && ((INT_PTR)(id) < 12) && ((INT_PTR)(id) >= -1)) +#define IS_BITMAP_ITEM(flags) (MF_BITMAP == MENU_ITEM_TYPE(flags)) + +/* Use global popup window because there's no way 2 menus can + * be tracked at the same time. */ +static HWND TopPopup; + +/* Flag set by EndMenu() to force an exit from menu tracking */ +static BOOL fEndMenu = FALSE; #define MENU_ITEM_HBMP_SPACE (5) #define MENU_BAR_ITEMS_SPACE (12) #define SEPARATOR_HEIGHT (5) #define MENU_TAB_SPACE (8) -#define ITEM_PREV -1 -#define ITEM_NEXT 1 - #define MAKEINTATOMA(atom) ((LPCSTR)((ULONG_PTR)((WORD)(atom)))) #define MAKEINTATOMW(atom) ((LPCWSTR)((ULONG_PTR)((WORD)(atom)))) #define POPUPMENU_CLASS_ATOMA MAKEINTATOMA(32768) /* PopupMenu */ #define POPUPMENU_CLASS_ATOMW MAKEINTATOMW(32768) /* PopupMenu */ - -/* internal flags for menu tracking */ - -#define TF_ENDMENU 0x0001 -#define TF_SUSPENDPOPUP 0x0002 -#define TF_SKIPREMOVE 0x0004 typedef struct { @@ -72,8 +81,6 @@ POINT Pt; } MTRACKER; -//static LRESULT WINAPI PopupMenuWndProcA(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam); -//static LRESULT WINAPI PopupMenuWndProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); /********************************************************************* * PopupMenu class descriptor @@ -89,14 +96,6 @@ (HBRUSH)(COLOR_MENU + 1) /* brush */ }; - -/* INTERNAL FUNCTIONS ********************************************************/ - -/* Rip the fun and easy to use and fun WINE unicode string manipulation routines. - * Of course I didnt copy the ASM code because we want this to be portable - * and it needs to go away. - */ - #ifndef GET_WORD #define GET_WORD(ptr) (*(WORD *)(ptr)) #endif @@ -107,13 +106,6 @@ HFONT hMenuFont = NULL; HFONT hMenuFontBold = NULL; -/* Flag set by EndMenu() to force an exit from menu tracking */ -static BOOL fEndMenu = FALSE; - -/* Use global popup window because there's no way 2 menus can - * be tracked at the same time. */ -static HWND TopPopup; - /* Dimension of the menu bitmaps */ static HBITMAP BmpSysMenu = NULL; @@ -290,71 +282,6 @@ if (NULL == BmpSysMenu) { BmpSysMenu = LoadBitmapW(0, MAKEINTRESOURCEW(OBM_CLOSE)); - } -} - -/*********************************************************************** - * MenuGetBitmapItemSize - * - * Get the size of a bitmap item. - */ -static void FASTCALL -MenuGetBitmapItemSize(PROSMENUITEMINFO lpitem, SIZE *Size, HWND WndOwner) -{ - BITMAP Bm; - HBITMAP Bmp = lpitem->hbmpItem; - - Size->cx = Size->cy = 0; - - /* check if there is a magic menu item associated with this item */ - if (IS_MAGIC_BITMAP(Bmp)) - { - switch((INT_PTR) Bmp) - { - case (INT_PTR)HBMMENU_CALLBACK: - { - MEASUREITEMSTRUCT measItem; - measItem.CtlType = ODT_MENU; - measItem.CtlID = 0; - measItem.itemID = lpitem->wID; - measItem.itemWidth = lpitem->Rect.right - lpitem->Rect.left; - measItem.itemHeight = lpitem->Rect.bottom - lpitem->Rect.top; - measItem.itemData = lpitem->dwItemData; - SendMessageW( WndOwner, WM_MEASUREITEM, lpitem->wID, (LPARAM)&measItem); - Size->cx = measItem.itemWidth; - Size->cy = measItem.itemHeight; - return; - } - break; - - case (INT_PTR) HBMMENU_SYSTEM: - if (0 != lpitem->dwItemData) - { - Bmp = (HBITMAP) lpitem->dwItemData; - break; - } - /* fall through */ - case (INT_PTR) HBMMENU_MBAR_RESTORE: - case (INT_PTR) HBMMENU_MBAR_MINIMIZE: - case (INT_PTR) HBMMENU_MBAR_CLOSE: - case (INT_PTR) HBMMENU_MBAR_MINIMIZE_D: - case (INT_PTR) HBMMENU_MBAR_CLOSE_D: - case (INT_PTR) HBMMENU_POPUP_CLOSE: - case (INT_PTR) HBMMENU_POPUP_RESTORE: - case (INT_PTR) HBMMENU_POPUP_MAXIMIZE: - case (INT_PTR) HBMMENU_POPUP_MINIMIZE: - /* FIXME: Why we need to subtract these magic values? */ - /* to make them smaller than the menu bar? */ - Size->cx = GetSystemMetrics(SM_CXSIZE) - 2; - Size->cy = GetSystemMetrics(SM_CYSIZE) - 4; - return; - } - } - - if (GetObjectW(Bmp, sizeof(BITMAP), &Bm)) - { - Size->cx = Bm.bmWidth; - Size->cy = Bm.bmHeight; } } @@ -423,95 +350,224 @@ } /*********************************************************************** + * MenuFindItemByKey + * + * Find the menu item selected by a key press. + * Return item id, -1 if none, -2 if we should close the menu. + */ +static UINT FASTCALL MenuFindItemByKey(HWND WndOwner, PROSMENUINFO MenuInfo, + WCHAR Key, BOOL ForceMenuChar) +{ + ROSMENUINFO SysMenuInfo; + PROSMENUITEMINFO Items, ItemInfo; + LRESULT MenuChar; + UINT i; + + TRACE("\tlooking for '%c' (0x%02x) in [%p]\n", (char) Key, Key, MenuInfo); + + if (NULL == MenuInfo || ! IsMenu(MenuInfo->Self)) + { + if (MenuGetRosMenuInfo(&SysMenuInfo, GetSystemMenu(WndOwner, FALSE))) + { + MenuInfo = &SysMenuInfo; + } + else + { + MenuInfo = NULL; + } + } + + if (NULL != MenuInfo) + { + if (MenuGetAllRosMenuItemInfo(MenuInfo->Self, &Items) <= 0) + { + return -1; + } + if (! ForceMenuChar) + { + Key = toupperW(Key); + ItemInfo = Items; + for (i = 0; i < MenuInfo->MenuItemCount; i++, ItemInfo++) + { + if ((ItemInfo->Text) && NULL != ItemInfo->dwTypeData) + { + WCHAR *p = (WCHAR *) ItemInfo->dwTypeData - 2; + do + { + p = strchrW(p + 2, '&'); + } + while (NULL != p && L'&' == p[1]); + if (NULL != p && (toupperW(p[1]) == Key)) + { + return i; + } + } + } + } + + MenuChar = SendMessageW(WndOwner, WM_MENUCHAR, + MAKEWPARAM(Key, MenuInfo->Flags), (LPARAM) MenuInfo->Self); + if (2 == HIWORD(MenuChar)) + { + return LOWORD(MenuChar); + } + if (1 == HIWORD(MenuChar)) + { + return (UINT) (-2); + } + } + + return (UINT)(-1); +} + +/*********************************************************************** + * MenuGetBitmapItemSize + * + * Get the size of a bitmap item. + */ +static void FASTCALL MenuGetBitmapItemSize(PROSMENUITEMINFO lpitem, SIZE *size, + HWND WndOwner) +{ + BITMAP bm; + HBITMAP bmp = lpitem->hbmpItem; + + size->cx = size->cy = 0; + + /* check if there is a magic menu item associated with this item */ + if (IS_MAGIC_BITMAP(bmp)) + { + switch((INT_PTR) bmp) + { + case (INT_PTR)HBMMENU_CALLBACK: + { + MEASUREITEMSTRUCT measItem; + measItem.CtlType = ODT_MENU; + measItem.CtlID = 0; + measItem.itemID = lpitem->wID; + measItem.itemWidth = lpitem->Rect.right - lpitem->Rect.left; + measItem.itemHeight = lpitem->Rect.bottom - lpitem->Rect.top; + measItem.itemData = lpitem->dwItemData; + SendMessageW( WndOwner, WM_MEASUREITEM, lpitem->wID, (LPARAM)&measItem); + size->cx = measItem.itemWidth; + size->cy = measItem.itemHeight; + return; + } + break; + + case (INT_PTR) HBMMENU_SYSTEM: + if (0 != lpitem->dwItemData) + { + bmp = (HBITMAP) lpitem->dwItemData; + break; + } + /* fall through */ + case (INT_PTR) HBMMENU_MBAR_RESTORE: + case (INT_PTR) HBMMENU_MBAR_MINIMIZE: + case (INT_PTR) HBMMENU_MBAR_CLOSE: + case (INT_PTR) HBMMENU_MBAR_MINIMIZE_D: + case (INT_PTR) HBMMENU_MBAR_CLOSE_D: + case (INT_PTR) HBMMENU_POPUP_CLOSE: + case (INT_PTR) HBMMENU_POPUP_RESTORE: + case (INT_PTR) HBMMENU_POPUP_MAXIMIZE: + case (INT_PTR) HBMMENU_POPUP_MINIMIZE: + /* FIXME: Why we need to subtract these magic values? */ + /* to make them smaller than the menu bar? */ + size->cx = GetSystemMetrics(SM_CXSIZE) - 2; + size->cy = GetSystemMetrics(SM_CYSIZE) - 4; + return; + } + } + + if (GetObjectW(bmp, sizeof(BITMAP), &bm)) + { + size->cx = bm.bmWidth; + size->cy = bm.bmHeight; + } +} + +/*********************************************************************** * MenuDrawBitmapItem * * Draw a bitmap item. */ -static void FASTCALL -MenuDrawBitmapItem(HDC Dc, PROSMENUITEMINFO Item, const RECT *Rect, +static void FASTCALL MenuDrawBitmapItem(HDC hdc, PROSMENUITEMINFO lpitem, const RECT *rect, HMENU hmenu, HWND WndOwner, UINT odaction, BOOL MenuBar) { - BITMAP Bm; - DWORD Rop; - HDC DcMem; - HBITMAP Bmp; - int w = Rect->right - Rect->left; - int h = Rect->bottom - Rect->top; - int BmpXoffset = 0; - int Left, Top; - HBITMAP hbmpToDraw = (HBITMAP) Item->hbmpItem; - Bmp = hbmpToDraw; - - /* Check if there is a magic menu item associated with this item */ - if (IS_MAGIC_BITMAP(hbmpToDraw)) - { - UINT Flags = 0; - RECT r; - - r = *Rect; - switch ((INT_PTR)hbmpToDraw) - { - case (INT_PTR) HBMMENU_SYSTEM: - if (NULL != Item->dwTypeData) - { - Bmp = (HBITMAP)Item->dwTypeData; - if (! GetObjectW(Bmp, sizeof(BITMAP), &Bm)) - { - return; - } - } + BITMAP bm; + DWORD rop; + HDC hdcMem; + HBITMAP bmp; + int w = rect->right - rect->left; + int h = rect->bottom - rect->top; + int bmp_xoffset = 0; + int left, top; + HBITMAP hbmToDraw = lpitem->hbmpItem; + bmp = hbmToDraw; + + /* Check if there is a magic menu item associated with this item */ + if (IS_MAGIC_BITMAP(hbmToDraw)) + { + UINT flags = 0; + RECT r; + + r = *rect; + switch ((INT_PTR)hbmToDraw) + { + case (INT_PTR)HBMMENU_SYSTEM: + if (lpitem->dwTypeData) + { + bmp = (HBITMAP)lpitem->dwTypeData; + if (!GetObjectW( bmp, sizeof(bm), &bm )) return; + } else - { + { if (!BmpSysMenu) BmpSysMenu = LoadBitmapW(0, MAKEINTRESOURCEW(OBM_CLOSE)); - Bmp = BmpSysMenu; - if (! GetObjectW(Bmp, sizeof(BITMAP), &Bm)) - { - return; - } + bmp = BmpSysMenu; + if (! GetObjectW(bmp, sizeof(bm), &bm)) return; /* only use right half of the bitmap */ - BmpXoffset = Bm.bmWidth / 2; - Bm.bmWidth -= BmpXoffset; - } + bmp_xoffset = bm.bmWidth / 2; + bm.bmWidth -= bmp_xoffset; + } goto got_bitmap; - case (INT_PTR) HBMMENU_MBAR_RESTORE: - Flags = DFCS_CAPTIONRESTORE; + case (INT_PTR)HBMMENU_MBAR_RESTORE: + flags = DFCS_CAPTIONRESTORE; break; - case (INT_PTR) HBMMENU_MBAR_MINIMIZE: + case (INT_PTR)HBMMENU_MBAR_MINIMIZE: r.right += 1; - Flags = DFCS_CAPTIONMIN; + flags = DFCS_CAPTIONMIN; break; - case (INT_PTR) HBMMENU_MBAR_MINIMIZE_D: + case (INT_PTR)HBMMENU_MBAR_MINIMIZE_D: r.right += 1; - Flags = DFCS_CAPTIONMIN | DFCS_INACTIVE; + flags = DFCS_CAPTIONMIN | DFCS_INACTIVE; break; - case (INT_PTR) HBMMENU_MBAR_CLOSE: - Flags = DFCS_CAPTIONCLOSE; + case (INT_PTR)HBMMENU_MBAR_CLOSE: + flags = DFCS_CAPTIONCLOSE; break; - case (INT_PTR) HBMMENU_MBAR_CLOSE_D: - Flags = DFCS_CAPTIONCLOSE | DFCS_INACTIVE; + case (INT_PTR)HBMMENU_MBAR_CLOSE_D: + flags = DFCS_CAPTIONCLOSE | DFCS_INACTIVE; break; - case (INT_PTR) HBMMENU_CALLBACK: + case (INT_PTR)HBMMENU_CALLBACK: { DRAWITEMSTRUCT drawItem; POINT origorg; drawItem.CtlType = ODT_MENU; drawItem.CtlID = 0; - drawItem.itemID = Item->wID; + drawItem.itemID = lpitem->wID; drawItem.itemAction = odaction; - drawItem.itemState = (Item->fState & MF_CHECKED)?ODS_CHECKED:0; - drawItem.itemState |= (Item->fState & MF_DEFAULT)?ODS_DEFAULT:0; - drawItem.itemState |= (Item->fState & MF_DISABLED)?ODS_DISABLED:0; - drawItem.itemState |= (Item->fState & MF_GRAYED)?ODS_GRAYED|ODS_DISABLED:0; - drawItem.itemState |= (Item->fState & MF_HILITE)?ODS_SELECTED:0; + drawItem.itemState = (lpitem->fState & MF_CHECKED)?ODS_CHECKED:0; + drawItem.itemState |= (lpitem->fState & MF_DEFAULT)?ODS_DEFAULT:0; + drawItem.itemState |= (lpitem->fState & MF_DISABLED)?ODS_DISABLED:0; + drawItem.itemState |= (lpitem->fState & MF_GRAYED)?ODS_GRAYED|ODS_DISABLED:0; + drawItem.itemState |= (lpitem->fState & MF_HILITE)?ODS_SELECTED:0; drawItem.hwndItem = (HWND)hmenu; - drawItem.hDC = Dc; - drawItem.rcItem = *Rect; - drawItem.itemData = Item->dwItemData; + drawItem.hDC = hdc; + drawItem.rcItem = *rect; + drawItem.itemData = lpitem->dwItemData; /* some applications make this assumption on the DC's origin */ - SetViewportOrgEx( Dc, Item->Rect.left, Item->Rect.top, &origorg); - OffsetRect( &drawItem.rcItem, - Item->Rect.left, - Item->Rect.top); + SetViewportOrgEx( hdc, lpitem->Rect.left, lpitem->Rect.top, &origorg); + OffsetRect( &drawItem.rcItem, - lpitem->Rect.left, - lpitem->Rect.top); SendMessageW( WndOwner, WM_DRAWITEM, 0, (LPARAM)&drawItem); - SetViewportOrgEx( Dc, origorg.x, origorg.y, NULL); + SetViewportOrgEx( hdc, origorg.x, origorg.y, NULL); return; } break; @@ -520,37 +576,413 @@ case (INT_PTR) HBMMENU_POPUP_RESTORE: case (INT_PTR) HBMMENU_POPUP_MAXIMIZE: case (INT_PTR) HBMMENU_POPUP_MINIMIZE: - MenuDrawPopupGlyph(Dc, &r, (INT_PTR)hbmpToDraw, Item->fState & MF_GRAYED, Item->fState & MF_HILITE); + MenuDrawPopupGlyph(hdc, &r, (INT_PTR)hbmToDraw, lpitem->fState & MF_GRAYED, lpitem->fState & MF_HILITE); return; } InflateRect(&r, -1, -1); - if (0 != (Item->fState & MF_HILITE)) - { - Flags |= DFCS_PUSHED; - } - DrawFrameControl(Dc, &r, DFC_CAPTION, Flags); + if (0 != (lpitem->fState & MF_HILITE)) + { + flags |= DFCS_PUSHED; + } + DrawFrameControl(hdc, &r, DFC_CAPTION, flags); return; } - if (NULL == Bmp || ! GetObjectW(Bmp, sizeof(BITMAP), &Bm)) - { - return; - } - -got_bitmap: - DcMem = CreateCompatibleDC(Dc); - SelectObject(DcMem, Bmp); - - /* handle fontsize > bitmap_height */ - Top = (Bm.bmHeight < h) ? Rect->top + (h - Bm.bmHeight) / 2 : Rect->top; - Left = Rect->left; - Rop= ((Item->fState & MF_HILITE) && !IS_MAGIC_BITMAP(hbmpToDraw)) ? NOTSRCCOPY : SRCCOPY; - if ((Item->fState & MF_HILITE) && Item->hbmpItem) - { - SetBkColor(Dc, GetSysColor(COLOR_HIGHLIGHT)); - } - BitBlt(Dc, Left, Top, w, h, DcMem, BmpXoffset, 0, Rop); - DeleteDC(DcMem); + if (!bmp || !GetObjectW( bmp, sizeof(bm), &bm )) return; + + got_bitmap: + hdcMem = CreateCompatibleDC( hdc ); + SelectObject( hdcMem, bmp ); + + /* handle fontsize > bitmap_height */ + top = (h>bm.bmHeight) ? rect->top+(h-bm.bmHeight)/2 : rect->top; + left=rect->left; + rop=((lpitem->fState & MF_HILITE) && !IS_MAGIC_BITMAP(hbmToDraw)) ? NOTSRCCOPY : SRCCOPY; + if ((lpitem->fState & MF_HILITE) && lpitem->hbmpItem) + SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT)); + BitBlt( hdc, left, top, w, h, hdcMem, bmp_xoffset, 0, rop ); + DeleteDC( hdcMem ); +} + +/*********************************************************************** + * MenuCalcItemSize + * + * Calculate the size of the menu item and store it in lpitem->rect. + */ +static void FASTCALL MenuCalcItemSize( HDC hdc, PROSMENUITEMINFO lpitem, PROSMENUINFO MenuInfo, HWND hwndOwner, + INT orgX, INT orgY, BOOL menuBar) +{ + WCHAR *p; + UINT check_bitmap_width = GetSystemMetrics( SM_CXMENUCHECK ); + INT itemheight = 0; + + TRACE("dc=%x owner=%x (%d,%d)\n", hdc, hwndOwner, orgX, orgY); + + MenuCharSize.cx = GdiGetCharDimensions( hdc, NULL, &MenuCharSize.cy ); + + SetRect( &lpitem->Rect, orgX, orgY, orgX, orgY ); + + if (lpitem->fType & MF_OWNERDRAW) + { + MEASUREITEMSTRUCT mis; + mis.CtlType = ODT_MENU; + mis.CtlID = 0; + mis.itemID = lpitem->wID; + mis.itemData = lpitem->dwItemData; + mis.itemHeight = HIWORD( GetDialogBaseUnits()); + mis.itemWidth = 0; + SendMessageW( hwndOwner, WM_MEASUREITEM, 0, (LPARAM)&mis ); + /* Tests reveal that Windows ( Win95 thru WinXP) adds twice the average + * width of a menufont character to the width of an owner-drawn menu. + */ + lpitem->Rect.right += mis.itemWidth + 2 * MenuCharSize.cx; + + if (menuBar) { + /* under at least win95 you seem to be given a standard + height for the menu and the height value is ignored */ + lpitem->Rect.bottom += GetSystemMetrics(SM_CYMENUSIZE); + } else + lpitem->Rect.bottom += mis.itemHeight; + + TRACE("id=%04lx size=%dx%d\n", + lpitem->wID, mis.itemWidth, mis.itemHeight); + return; + } + + if (lpitem->fType & MF_SEPARATOR) + { + lpitem->Rect.bottom += SEPARATOR_HEIGHT; + if( !menuBar) + lpitem->Rect.right += check_bitmap_width + MenuCharSize.cx; + return; + } + + lpitem->XTab = 0; + + if (lpitem->hbmpItem) + { + SIZE size; + + if (!menuBar) { + MenuGetBitmapItemSize(lpitem, &size, hwndOwner ); + /* Keep the size of the bitmap in callback mode to be able + * to draw it correctly */ + lpitem->Rect.right = lpitem->Rect.left + size.cx; + if (MenuInfo->maxBmpSize.cx < abs(size.cx) + MENU_ITEM_HBMP_SPACE || + MenuInfo->maxBmpSize.cy < abs(size.cy)) + { + MenuInfo->maxBmpSize.cx = abs(size.cx) + MENU_ITEM_HBMP_SPACE; + MenuInfo->maxBmpSize.cy = abs(size.cy); + } + MenuSetRosMenuInfo(MenuInfo); + itemheight = size.cy + 2; + + if( !(MenuInfo->dwStyle & MNS_NOCHECK)) + lpitem->Rect.right += 2 * check_bitmap_width; + lpitem->Rect.right += 4 + MenuCharSize.cx; + lpitem->XTab = lpitem->Rect.right; + lpitem->Rect.right += check_bitmap_width; + } else /* hbmpItem & MenuBar */ { + MenuGetBitmapItemSize(lpitem, &size, hwndOwner ); + lpitem->Rect.right += size.cx; + if( lpitem->Text) lpitem->Rect.right += 2; + itemheight = size.cy; + + /* Special case: Minimize button doesn't have a space behind it. */ + if (lpitem->hbmpItem == (HBITMAP)HBMMENU_MBAR_MINIMIZE || + lpitem->hbmpItem == (HBITMAP)HBMMENU_MBAR_MINIMIZE_D) + lpitem->Rect.right -= 1; + } + } + else if (!menuBar) { + if( !(MenuInfo->dwStyle & MNS_NOCHECK)) + lpitem->Rect.right += check_bitmap_width; + lpitem->Rect.right += 4 + MenuCharSize.cx; + lpitem->XTab = lpitem->Rect.right; + lpitem->Rect.right += check_bitmap_width; + } + + /* it must be a text item - unless it's the system menu */ + if (!(lpitem->fType & MF_SYSMENU) && lpitem->Text) { + HFONT hfontOld = NULL; + RECT rc = lpitem->Rect; + LONG txtheight, txtwidth; + + if ( lpitem->fState & MFS_DEFAULT ) { + hfontOld = SelectObject( hdc, hMenuFontBold ); + } + if (menuBar) { + txtheight = DrawTextW( hdc, lpitem->dwTypeData, -1, &rc, + DT_SINGLELINE|DT_CALCRECT); + lpitem->Rect.right += rc.right - rc.left; + itemheight = max( max( itemheight, txtheight), + GetSystemMetrics( SM_CYMENU) - 1); + lpitem->Rect.right += 2 * MenuCharSize.cx; + } else { + if ((p = strchrW( lpitem->dwTypeData, '\t' )) != NULL) { + RECT tmprc = rc; + LONG tmpheight; + int n = (int)( p - lpitem->dwTypeData); + /* Item contains a tab (only meaningful in popup menus) */ + /* get text size before the tab */ + txtheight = DrawTextW( hdc, lpitem->dwTypeData, n, &rc, + DT_SINGLELINE|DT_CALCRECT); + txtwidth = rc.right - rc.left; + p += 1; /* advance past the Tab */ + /* get text size after the tab */ + tmpheight = DrawTextW( hdc, p, -1, &tmprc, + DT_SINGLELINE|DT_CALCRECT); + lpitem->XTab += txtwidth; + txtheight = max( txtheight, tmpheight); + txtwidth += MenuCharSize.cx + /* space for the tab */ + tmprc.right - tmprc.left; /* space for the short cut */ + } else { + txtheight = DrawTextW( hdc, lpitem->dwTypeData, -1, &rc, + DT_SINGLELINE|DT_CALCRECT); + txtwidth = rc.right - rc.left; + lpitem->XTab += txtwidth; + } + lpitem->Rect.right += 2 + txtwidth; + itemheight = max( itemheight, + max( txtheight + 2, MenuCharSize.cy + 4)); + } + if (hfontOld) SelectObject (hdc, hfontOld); + } else if( menuBar) { + itemheight = max( itemheight, GetSystemMetrics(SM_CYMENU)-1); + } + lpitem->Rect.bottom += itemheight; + TRACE("(%ld,%ld)-(%ld,%ld)\n", lpitem->Rect.left, lpitem->Rect.top, lpitem->Rect.right, lpitem->Rect.bottom); +} + +/*********************************************************************** + * MenuPopupMenuCalcSize + * + * Calculate the size of a popup menu. + */ +static void FASTCALL MenuPopupMenuCalcSize(PROSMENUINFO MenuInfo, HWND WndOwner) +{ + ROSMENUITEMINFO lpitem; + HDC hdc; + int start, i; + int orgX, orgY, maxX, maxTab, maxTabWidth; + + MenuInfo->Width = MenuInfo->Height = 0; + if (MenuInfo->MenuItemCount == 0) + { + MenuSetRosMenuInfo(MenuInfo); + return; + } + + hdc = GetDC(NULL); + SelectObject( hdc, hMenuFont ); + + start = 0; + maxX = 2 + 1; + + MenuInfo->maxBmpSize.cx = 0; + MenuInfo->maxBmpSize.cy = 0; + + MenuInitRosMenuItemInfo(&lpitem); + while (start < MenuInfo->MenuItemCount) + { + orgX = maxX; + orgY = 2; + + maxTab = maxTabWidth = 0; + + /* Parse items until column break or end of menu */ + for (i = start; i < MenuInfo->MenuItemCount; i++) + { + if (! MenuGetRosMenuItemInfo(MenuInfo->Self, i, &lpitem)) + { + MenuCleanupRosMenuItemInfo(&lpitem); + MenuSetRosMenuInfo(MenuInfo); + return; + } + if (i != start && + (lpitem.fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break; + + MenuCalcItemSize(hdc, &lpitem, MenuInfo, WndOwner, orgX, orgY, FALSE); + if (! MenuSetRosMenuItemInfo(MenuInfo->Self, i, &lpitem)) + { + MenuCleanupRosMenuItemInfo(&lpitem); + MenuSetRosMenuInfo(MenuInfo); + return; + } +// Not sure here,, The patch from wine removes this. +// if ((lpitem.fType & MF_MENUBARBREAK) != 0) +// { +// OrgX++; +// } + maxX = max(maxX, lpitem.Rect.right); + orgY = lpitem.Rect.bottom; + if ((lpitem.Text) && lpitem.XTab ) + { + maxTab = max( maxTab, lpitem.XTab ); + maxTabWidth = max(maxTabWidth, lpitem.Rect.right - lpitem.XTab); + } + } + + /* Finish the column (set all items to the largest width found) */ + maxX = max( maxX, maxTab + maxTabWidth ); + while (start < i) + { + if (MenuGetRosMenuItemInfo(MenuInfo->Self, start, &lpitem)) + { + lpitem.Rect.right = maxX; + if ((lpitem.Text) && 0 != lpitem.XTab) + { + lpitem.XTab = maxTab; + } + MenuSetRosMenuItemInfo(MenuInfo->Self, start, &lpitem); + } + start++; + } + MenuInfo->Height = max(MenuInfo->Height, orgY); + } + + MenuInfo->Width = maxX; + + /* space for 3d border */ + MenuInfo->Height += 2; + MenuInfo->Width += 2; + + MenuCleanupRosMenuItemInfo(&lpitem); + MenuSetRosMenuInfo(MenuInfo); + ReleaseDC( 0, hdc ); +} + +/*********************************************************************** + * MenuMenuBarCalcSize + * + * FIXME: Word 6 implements its own MDI and its own 'close window' bitmap + * height is off by 1 pixel which causes lengthy window relocations when + * active document window is maximized/restored. + * + * Calculate the size of the menu bar. + */ +static void FASTCALL MenuMenuBarCalcSize( HDC hdc, LPRECT lprect, + PROSMENUINFO MenuInfo, HWND hwndOwner ) +{ + ROSMENUITEMINFO ItemInfo; + int start, i, orgX, orgY, maxY, helpPos; + + if ((lprect == NULL) || (MenuInfo == NULL)) return; + if (MenuInfo->MenuItemCount == 0) return; + TRACE("left=%ld top=%ld right=%ld bottom=%ld\n", lprect->left, lprect->top, lprect->right, lprect->bottom); + MenuInfo->Width = lprect->right - lprect->left; + MenuInfo->Height = 0; + maxY = lprect->top + 1; + start = 0; + helpPos = -1; + + MenuInfo->maxBmpSize.cx = 0; + MenuInfo->maxBmpSize.cy = 0; + + MenuInitRosMenuItemInfo(&ItemInfo); + while (start < MenuInfo->MenuItemCount) + { + if (! MenuGetRosMenuItemInfo(MenuInfo->Self, start, &ItemInfo)) + { + MenuCleanupRosMenuItemInfo(&ItemInfo); + return; + } + orgX = lprect->left; + orgY = maxY; + + /* Parse items until line break or end of menu */ + for (i = start; i < MenuInfo->MenuItemCount; i++) + { + if ((helpPos == -1) && (ItemInfo.fType & MF_RIGHTJUSTIFY)) helpPos = i; + if ((i != start) && + (ItemInfo.fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break; + + TRACE("calling MENU_CalcItemSize org=(%d, %d)\n", orgX, orgY); + MenuCalcItemSize(hdc, &ItemInfo, MenuInfo, hwndOwner, orgX, orgY, TRUE); + if (! MenuSetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo)) + { + MenuCleanupRosMenuItemInfo(&ItemInfo); + return; + } + + if (ItemInfo.Rect.right > lprect->right) + { + if (i != start) break; + else ItemInfo.Rect.right = lprect->right; + } + maxY = max( maxY, ItemInfo.Rect.bottom ); + orgX = ItemInfo.Rect.right; + if (i + 1 < MenuInfo->MenuItemCount) + { + if (! MenuGetRosMenuItemInfo(MenuInfo->Self, i + 1, &ItemInfo)) + { + MenuCleanupRosMenuItemInfo(&ItemInfo); + return; + } + } + } + +/* FIXME: Is this really needed? */ /*NO! it is not needed, why make the +HBMMENU_MBAR_CLOSE, MINIMIZE & RESTORE, look the same size as the menu bar! */ +#if 0 + /* Finish the line (set all items to the largest height found) */ + while (start < i) + { + if (MenuGetRosMenuItemInfo(MenuInfo->Self, start, &ItemInfo)) + { + ItemInfo.Rect.bottom = maxY; + MenuSetRosMenuItemInfo(MenuInfo->Self, start, &ItemInfo); + } + start++; + } +#else + start = i; /* This works! */ +#endif + } + + lprect->bottom = maxY; + MenuInfo->Height = lprect->bottom - lprect->top; + MenuSetRosMenuInfo(MenuInfo); + + if (helpPos != -1) + { + /* Flush right all items between the MF_RIGHTJUSTIFY and */ + /* the last item (if several lines, only move the last line) */ + if (! MenuGetRosMenuItemInfo(MenuInfo->Self, MenuInfo->MenuItemCount - 1, &ItemInfo)) + { + MenuCleanupRosMenuItemInfo(&ItemInfo); + return; + } + orgY = ItemInfo.Rect.top; + orgX = lprect->right; + for (i = MenuInfo->MenuItemCount - 1; helpPos <= i; i--) + { + if (i < helpPos) + { + break; /* done */ + } + if (ItemInfo.Rect.top != orgY) + { + break; /* Other line */ + } + if (orgX <= ItemInfo.Rect.right) + { + break; /* Too far right already */ + } + ItemInfo.Rect.left += orgX - ItemInfo.Rect.right; + ItemInfo.Rect.right = orgX; + orgX = ItemInfo.Rect.left; + MenuSetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo); + if (helpPos + 1 <= i && + ! MenuGetRosMenuItemInfo(MenuInfo->Self, i - 1, &ItemInfo)) + { + MenuCleanupRosMenuItemInfo(&ItemInfo); + return; + } + } + } + + MenuCleanupRosMenuItemInfo(&ItemInfo); } /*********************************************************************** @@ -558,358 +990,322 @@ * * Draw a single menu item. */ -static void FASTCALL -MenuDrawMenuItem(HWND hWnd, PROSMENUINFO MenuInfo, HWND WndOwner, HDC Dc, - PROSMENUITEMINFO Item, UINT Height, BOOL MenuBar, UINT Action) -{ - RECT Rect; - PWCHAR Text; - BOOL flat_menu = FALSE; - int bkgnd; - PWND Wnd = ValidateHwnd(hWnd); - - if (!Wnd) +static void FASTCALL MenuDrawMenuItem(HWND hWnd, PROSMENUINFO MenuInfo, HWND WndOwner, HDC hdc, + PROSMENUITEMINFO lpitem, UINT Height, BOOL menuBar, UINT odaction) +{ + RECT rect; + PWCHAR Text; + BOOL flat_menu = FALSE; + int bkgnd; + PWND Wnd = ValidateHwnd(hWnd); + + if (!Wnd) return; - if (0 != (Item->fType & MF_SYSMENU)) - { - if ( (Wnd->style & WS_MINIMIZE)) - { - UserGetInsideRectNC(Wnd, &Rect); - UserDrawSysMenuButton(hWnd, Dc, &Rect, - Item->fState & (MF_HILITE | MF_MOUSESELECT)); - } - return; + if (lpitem->fType & MF_SYSMENU) + { + if ( (Wnd->style & WS_MINIMIZE)) + { + UserGetInsideRectNC(Wnd, &rect); + UserDrawSysMenuButton(hWnd, hdc, &rect, + lpitem->fState & (MF_HILITE | MF_MOUSESELECT)); + } + return; } SystemParametersInfoW (SPI_GETFLATMENU, 0, &flat_menu, 0); - bkgnd = (MenuBar && flat_menu) ? COLOR_MENUBAR : COLOR_MENU; - - /* Setup colors */ - - if (0 != (Item->fState & MF_HILITE)) - { - if (MenuBar && !flat_menu) - { - SetTextColor(Dc, GetSysColor(COLOR_MENUTEXT)); - SetBkColor(Dc, GetSysColor(COLOR_MENU)); - } - else - { - if (0 != (Item->fState & MF_GRAYED)) + bkgnd = (menuBar && flat_menu) ? COLOR_MENUBAR : COLOR_MENU; + + /* Setup colors */ + + if (lpitem->fState & MF_HILITE) + { + if(menuBar && !flat_menu) { + SetTextColor(hdc, GetSysColor(COLOR_MENUTEXT)); + SetBkColor(hdc, GetSysColor(COLOR_MENU)); + } else { + if (lpitem->fState & MF_GRAYED) + SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); + else + SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); + SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT)); + } + } + else + { + if (lpitem->fState & MF_GRAYED) + SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) ); + else + SetTextColor( hdc, GetSysColor( COLOR_MENUTEXT ) ); + SetBkColor( hdc, GetSysColor( bkgnd ) ); + } + + rect = lpitem->Rect; + + if (lpitem->fType & MF_OWNERDRAW) + { + /* + ** Experimentation under Windows reveals that an owner-drawn + ** menu is given the rectangle which includes the space it requested + ** in its response to WM_MEASUREITEM _plus_ width for a checkmark + ** and a popup-menu arrow. This is the value of lpitem->rect. + ** Windows will leave all drawing to the application except for + ** the popup-menu arrow. Windows always draws that itself, after + ** the menu owner has finished drawing. + */ + DRAWITEMSTRUCT dis; + + dis.CtlType = ODT_MENU; + dis.CtlID = 0; + dis.itemID = lpitem->wID; + dis.itemData = (DWORD)lpitem->dwItemData; + dis.itemState = 0; + if (lpitem->fState & MF_CHECKED) dis.itemState |= ODS_CHECKED; + if (lpitem->fState & MF_GRAYED) dis.itemState |= ODS_GRAYED | ODS_DISABLED; + if (lpitem->fState & MF_HILITE) dis.itemState |= ODS_SELECTED; + dis.itemAction = odaction; /* ODA_DRAWENTIRE | ODA_SELECT | ODA_FOCUS; */ + dis.hwndItem = (HWND) MenuInfo->Self; + dis.hDC = hdc; + dis.rcItem = rect; + TRACE("Ownerdraw: owner=%p itemID=%d, itemState=%d, itemAction=%d, " + "hwndItem=%p, hdc=%p, rcItem={%ld,%ld,%ld,%ld}\n", hWnd, + dis.itemID, dis.itemState, dis.itemAction, dis.hwndItem, + dis.hDC, dis.rcItem.left, dis.rcItem.top, dis.rcItem.right, + dis.rcItem.bottom); + SendMessageW(WndOwner, WM_DRAWITEM, 0, (LPARAM) &dis); + /* Draw the popup-menu arrow */ + if (lpitem->fType & MF_POPUP) + { + RECT rectTemp; + CopyRect(&rectTemp, &rect); + rectTemp.left = rectTemp.right - GetSystemMetrics(SM_CXMENUCHECK); + DrawFrameControl(hdc, &rectTemp, DFC_MENU, DFCS_MENUARROW); + } + return; + } + + if (menuBar && (lpitem->fType & MF_SEPARATOR)) return; + + if (lpitem->fState & MF_HILITE) + { + if (flat_menu) + { + InflateRect (&rect, -1, -1); + FillRect(hdc, &rect, GetSysColorBrush(COLOR_MENUHILIGHT)); + InflateRect (&rect, 1, 1); + FrameRect(hdc, &rect, GetSysColorBrush(COLOR_HIGHLIGHT)); + } + else + { + if(menuBar) + DrawEdge(hdc, &rect, BDR_SUNKENOUTER, BF_RECT); + else + FillRect(hdc, &rect, GetSysColorBrush(COLOR_HIGHLIGHT)); + } + } + else + FillRect( hdc, &rect, GetSysColorBrush(bkgnd) ); + + SetBkMode( hdc, TRANSPARENT ); + + /* vertical separator */ + if (!menuBar && (lpitem->fType & MF_MENUBARBREAK)) + { + HPEN oldPen; + RECT rc = rect; + + rc.left -= 3; + rc.top = 3; + rc.bottom = Height - 3; + if (flat_menu) + { + oldPen = SelectObject( hdc, GetStockObject(DC_PEN) ); + SetDCPenColor(hdc, GetSysColor(COLOR_BTNSHADOW)); + MoveToEx( hdc, rc.left, rc.top, NULL ); + LineTo( hdc, rc.left, rc.bottom ); + SelectObject( hdc, oldPen ); + } + else + DrawEdge (hdc, &rc, EDGE_ETCHED, BF_LEFT); + } + + /* horizontal separator */ + if (lpitem->fType & MF_SEPARATOR) + { + HPEN oldPen; + RECT rc = rect; + + rc.left++; + rc.right--; + rc.top += SEPARATOR_HEIGHT / 2; + if (flat_menu) + { + oldPen = SelectObject( hdc, GetStockObject(DC_PEN) ); + SetDCPenColor( hdc, GetSysColor(COLOR_BTNSHADOW)); + MoveToEx( hdc, rc.left, rc.top, NULL ); + LineTo( hdc, rc.right, rc.top ); + SelectObject( hdc, oldPen ); + } + else + DrawEdge (hdc, &rc, EDGE_ETCHED, BF_TOP); + return; + } + +#if 0 + /* helper lines for debugging */ + /* This is a very good test tool when hacking menus! (JT) 07/16/2006 */ + FrameRect(hdc, &rect, GetStockObject(BLACK_BRUSH)); + SelectObject(hdc, GetStockObject(DC_PEN)); + SetDCPenColor(hdc, GetSysColor(COLOR_WINDOWFRAME)); + MoveToEx(hdc, rect.left, (rect.top + rect.bottom) / 2, NULL); + LineTo(hdc, rect.right, (rect.top + rect.bottom) / 2); +#endif + + if (!menuBar) + { + HBITMAP bm; + INT y = rect.top + rect.bottom; + RECT rc = rect; + int checked = FALSE; + UINT check_bitmap_width = GetSystemMetrics( SM_CXMENUCHECK ); + UINT check_bitmap_height = GetSystemMetrics( SM_CYMENUCHECK ); + /* Draw the check mark + * + * FIXME: + * Custom checkmark bitmaps are monochrome but not always 1bpp. + */ + if( !(MenuInfo->dwStyle & MNS_NOCHECK)) { + bm = (lpitem->fState & MF_CHECKED) ? lpitem->hbmpChecked : + lpitem->hbmpUnchecked; + if (bm) /* we have a custom bitmap */ { - SetTextColor(Dc, GetSysColor(COLOR_GRAYTEXT)); + HDC hdcMem = CreateCompatibleDC( hdc ); + + SelectObject( hdcMem, bm ); + BitBlt( hdc, rc.left, (y - check_bitmap_height) / 2, + check_bitmap_width, check_bitmap_height, + hdcMem, 0, 0, SRCCOPY ); + DeleteDC( hdcMem ); + checked = TRUE; } - else + else if (lpitem->fState & MF_CHECKED) /* standard bitmaps */ { - SetTextColor(Dc, GetSysColor(COLOR_HIGHLIGHTTEXT)); + RECT r; + CopyRect(&r, &rect); + r.right = r.left + GetSystemMetrics(SM_CXMENUCHECK); + DrawFrameControl( hdc, &r, DFC_MENU, + (lpitem->fType & MFT_RADIOCHECK) ? + DFCS_MENUBULLET : DFCS_MENUCHECK); + checked = TRUE; } - SetBkColor(Dc, GetSysColor(COLOR_HIGHLIGHT)); - } - } - else - { - if (0 != (Item->fState & MF_GRAYED)) - { - SetTextColor(Dc, GetSysColor(COLOR_GRAYTEXT)); - } - else - { - SetTextColor(Dc, GetSysColor(COLOR_MENUTEXT)); - } - SetBkColor(Dc, GetSysColor(bkgnd)); - } - - Rect = Item->Rect; - - if (Item->fType & MF_OWNERDRAW) - { - /* - ** Experimentation under Windows reveals that an owner-drawn - ** menu is given the rectangle which includes the space it requested - ** in its response to WM_MEASUREITEM _plus_ width for a checkmark - ** and a popup-menu arrow. This is the value of lpitem->rect. - ** Windows will leave all drawing to the application except for - ** the popup-menu arrow. Windows always draws that itself, after - ** the menu owner has finished drawing. - */ - DRAWITEMSTRUCT dis; - - dis.CtlType = ODT_MENU; - dis.CtlID = 0; - dis.itemID = Item->wID; - dis.itemData = (DWORD)Item->dwItemData; - dis.itemState = 0; - if (0 != (Item->fState & MF_CHECKED)) - { - dis.itemState |= ODS_CHECKED; - } - if (0 != (Item->fState & MF_GRAYED)) - { - dis.itemState |= ODS_GRAYED | ODS_DISABLED; - } - if (0 != (Item->fState & MF_HILITE)) - { - dis.itemState |= ODS_SELECTED; - } - dis.itemAction = Action; /* ODA_DRAWENTIRE | ODA_SELECT | ODA_FOCUS; */ - dis.hwndItem = (HWND) MenuInfo->Self; - dis.hDC = Dc; - dis.rcItem = Rect; - TRACE("Ownerdraw: owner=%p itemID=%d, itemState=%d, itemAction=%d, " - "hwndItem=%p, hdc=%p, rcItem={%ld,%ld,%ld,%ld}\n", hWnd, - dis.itemID, dis.itemState, dis.itemAction, dis.hwndItem, - dis.hDC, dis.rcItem.left, dis.rcItem.top, dis.rcItem.right, - dis.rcItem.bottom); - SendMessageW(WndOwner, WM_DRAWITEM, 0, (LPARAM) &dis); - /* Draw the popup-menu arrow */ - if (0 != (Item->fType & MF_POPUP)) - { - RECT rectTemp; - CopyRect(&rectTemp, &Rect); - rectTemp.left = rectTemp.right - GetSystemMetrics(SM_CXMENUCHECK); - DrawFrameControl(Dc, &rectTemp, DFC_MENU, DFCS_MENUARROW); - } - return; - } - - TRACE("rect={%ld,%ld,%ld,%ld}\n", Item->Rect.left, Item->Rect.top, - Item->Rect.right, Item->Rect.bottom); - - if (MenuBar && 0 != (Item->fType & MF_SEPARATOR)) - { - return; - } - - if (Item->fState & MF_HILITE) - { - if (flat_menu) - { - InflateRect (&Rect, -1, -1); - FillRect(Dc, &Rect, GetSysColorBrush(COLOR_MENUHILIGHT)); - InflateRect (&Rect, 1, 1); - FrameRect(Dc, &Rect, GetSysColorBrush(COLOR_HIGHLIGHT)); - } - else - { - if (MenuBar) - { - DrawEdge(Dc, &Rect, BDR_SUNKENOUTER, BF_RECT); - } - else - { - FillRect(Dc, &Rect, GetSysColorBrush(COLOR_HIGHLIGHT)); - } - } - } - else - { - FillRect(Dc, &Rect, GetSysColorBrush(bkgnd)); - } - - SetBkMode(Dc, TRANSPARENT); - - /* vertical separator */ - if (! MenuBar && 0 != (Item->fType & MF_MENUBARBREAK)) - { - HPEN oldPen; - RECT rc = Rect; - rc.left -= 3; - rc.top = 3; - rc.bottom = Height - 3; - if (flat_menu) - { - oldPen = SelectObject( Dc, GetStockObject(DC_PEN) ); - SetDCPenColor(Dc, GetSysColor(COLOR_BTNSHADOW)); - MoveToEx( Dc, rc.left, rc.top, NULL ); - LineTo( Dc, rc.left, rc.bottom ); - SelectObject( Dc, oldPen ); - } - else - DrawEdge(Dc, &rc, EDGE_ETCHED, BF_LEFT); - } - - /* horizontal separator */ - if (0 != (Item->fType & MF_SEPARATOR)) - { - HPEN oldPen; - RECT rc = Rect; - rc.left++; - rc.right--; - rc.top += SEPARATOR_HEIGHT / 2; - if (flat_menu) - { - oldPen = SelectObject( Dc, GetStockObject(DC_PEN) ); - SetDCPenColor(Dc, GetSysColor(COLOR_BTNSHADOW)); - MoveToEx( Dc, rc.left, rc.top, NULL ); - LineTo( Dc, rc.right, rc.top ); - SelectObject( Dc, oldPen ); - } - else - DrawEdge(Dc, &rc, EDGE_ETCHED, BF_TOP); - return; - } - -#if 0 - /* helper lines for debugging */ - /* This is a very good test tool when hacking menus! (JT) 07/16/2006 */ - FrameRect(Dc, &Rect, GetStockObject(BLACK_BRUSH)); - SelectObject(Dc, GetStockObject(DC_PEN)); - SetDCPenColor(Dc, GetSysColor(COLOR_WINDOWFRAME)); - MoveToEx(Dc, Rect.left, (Rect.top + Rect.bottom) / 2, NULL); - LineTo(Dc, Rect.right, (Rect.top + Rect.bottom) / 2); -#endif - - if (! MenuBar) - { - INT y = Rect.top + Rect.bottom; - RECT Rc = Rect; - UINT CheckBitmapWidth = GetSystemMetrics(SM_CXMENUCHECK); - UINT CheckBitmapHeight = GetSystemMetrics(SM_CYMENUCHECK); - int checked = FALSE; - /* Draw the check mark - * - * FIXME: - * Custom checkmark bitmaps are monochrome but not always 1bpp. - */ - if( !(MenuInfo->dwStyle & MNS_NOCHECK)) - { - HBITMAP bm = 0 != (Item->fState & MF_CHECKED) ? Item->hbmpChecked : Item->hbmpUnchecked; - if (NULL != bm) /* we have a custom bitmap */ - { - HDC DcMem = CreateCompatibleDC(Dc); - SelectObject(DcMem, bm); - BitBlt(Dc, Rc.left, (y - CheckBitmapHeight) / 2, - CheckBitmapWidth, CheckBitmapHeight, - DcMem, 0, 0, SRCCOPY); - DeleteDC(DcMem); - checked = TRUE; - } - else if (0 != (Item->fState & MF_CHECKED)) /* standard bitmaps */ - { - RECT rectTemp; - CopyRect(&rectTemp, &Rect); - rectTemp.right = rectTemp.left + GetSystemMetrics(SM_CXMENUCHECK); - DrawFrameControl(Dc, &rectTemp, DFC_MENU, - 0 != (Item->fType & MFT_RADIOCHECK) ? - DFCS_MENUBULLET : DFCS_MENUCHECK); - checked = TRUE; - } - } - if (Item->hbmpItem) - { - RECT bmpRect; - CopyRect(&bmpRect, &Rect); - if (!(MenuInfo->dwStyle & MNS_CHECKORBMP) && !(MenuInfo->dwStyle & MNS_NOCHECK)) - bmpRect.left += CheckBitmapWidth + 2; - if (!(checked && (MenuInfo->dwStyle & MNS_CHECKORBMP))) - { - bmpRect.right = bmpRect.left + MenuInfo->maxBmpSize.cx; - MenuDrawBitmapItem(Dc, Item, &bmpRect, MenuInfo->Self, WndOwner, Action, MenuBar); - } - } - /* Draw the popup-menu arrow */ - if (0 != (Item->fType & MF_POPUP)) - { - RECT rectTemp; - CopyRect(&rectTemp, &Rect); - rectTemp.left = rectTemp.right - GetSystemMetrics(SM_CXMENUCHECK); - DrawFrameControl(Dc, &rectTemp, DFC_MENU, DFCS_MENUARROW); - } - Rect.left += 4; - if( !(MenuInfo->dwStyle & MNS_NOCHECK)) - Rect.left += CheckBitmapWidth; - Rect.right -= CheckBitmapWidth; - } - else if (Item->hbmpItem) /* Draw the bitmap */ - { - MenuDrawBitmapItem(Dc, Item, &Rect, MenuInfo->Self, WndOwner, Action, MenuBar); - } - - /* No bitmap - process text if present */ - if (Item->Text) - { - register int i = 0; - HFONT FontOld = NULL; - - UINT uFormat = MenuBar ? DT_CENTER | DT_VCENTER | DT_SINGLELINE - : DT_LEFT | DT_VCENTER | DT_SINGLELINE; - - if(MenuInfo->dwStyle & MNS_CHECKORBMP) - Rect.left += max(0, MenuInfo->maxBmpSize.cx - GetSystemMetrics(SM_CXMENUCHECK)); - else - Rect.left += MenuInfo->maxBmpSize.cx; - - if (0 != (Item->fState & MFS_DEFAULT)) - { - FontOld = SelectObject(Dc, hMenuFontBold); - } - - if (MenuBar) - { - Rect.left += MENU_BAR_ITEMS_SPACE / 2; - Rect.right -= MENU_BAR_ITEMS_SPACE / 2; - } - - Text = (PWCHAR) Item->dwTypeData; - if(Text) - { - for (i = 0; L'\0' != Text[i]; i++) - { - if (L'\t' == Text[i] || L'\b' == Text[i]) + } + if ( lpitem->hbmpItem ) + { + RECT bmpRect; + CopyRect(&bmpRect, &rect); + if (!(MenuInfo->dwStyle & MNS_CHECKORBMP) && !(MenuInfo->dwStyle & MNS_NOCHECK)) + bmpRect.left += check_bitmap_width + 2; + if (!(checked && (MenuInfo->dwStyle & MNS_CHECKORBMP))) { - break; + bmpRect.right = bmpRect.left + MenuInfo->maxBmpSize.cx; + MenuDrawBitmapItem(hdc, lpitem, &bmpRect, MenuInfo->Self, WndOwner, odaction, menuBar); } } - } - - if (0 != (Item->fState & MF_GRAYED)) - { - if (0 == (Item->fState & MF_HILITE)) - { - ++Rect.left; ++Rect.top; ++Rect.right; ++Rect.bottom; - SetTextColor(Dc, RGB(0xff, 0xff, 0xff)); - DrawTextW(Dc, Text, i, &Rect, uFormat); - --Rect.left; --Rect.top; --Rect.right; --Rect.bottom; - } - SetTextColor(Dc, RGB(0x80, 0x80, 0x80)); - } - - DrawTextW(Dc, Text, i, &Rect, uFormat); - - /* paint the shortcut text */ - if (! MenuBar && L'\0' != Text[i]) /* There's a tab or flush-right char */ - { - if (L'\t' == Text[i]) + /* Draw the popup-menu arrow */ + if (lpitem->fType & MF_POPUP) + { + RECT rectTemp; + CopyRect(&rectTemp, &rect); + rectTemp.left = rectTemp.right - GetSystemMetrics(SM_CXMENUCHECK); + DrawFrameControl(hdc, &rectTemp, DFC_MENU, DFCS_MENUARROW); + } + rect.left += 4; + if( !(MenuInfo->dwStyle & MNS_NOCHECK)) + rect.left += check_bitmap_width; + rect.right -= check_bitmap_width; + } + else if( lpitem->hbmpItem) + { /* Draw the bitmap */ + MenuDrawBitmapItem(hdc, lpitem, &rect, MenuInfo->Self, WndOwner, odaction, menuBar); + } + + /* process text if present */ + if (lpitem->Text) + { + register int i = 0; + HFONT hfontOld = 0; + + UINT uFormat = menuBar ? DT_CENTER | DT_VCENTER | DT_SINGLELINE + : DT_LEFT | DT_VCENTER | DT_SINGLELINE; + + if(MenuInfo->dwStyle & MNS_CHECKORBMP) + rect.left += max(0, MenuInfo->maxBmpSize.cx - GetSystemMetrics(SM_CXMENUCHECK)); + else + rect.left += MenuInfo->maxBmpSize.cx; + + if ( lpitem->fState & MFS_DEFAULT ) + { + hfontOld = SelectObject(hdc, hMenuFontBold); + } + + if (menuBar) { + rect.left += MENU_BAR_ITEMS_SPACE / 2; + rect.right -= MENU_BAR_ITEMS_SPACE / 2; + } + + Text = (PWCHAR) lpitem->dwTypeData; + if(Text) + { + for (i = 0; L'\0' != Text[i]; i++) + if (Text[i] == L'\t' || Text[i] == L'\b') + break; + } + + if(lpitem->fState & MF_GRAYED) + { + if (!(lpitem->fState & MF_HILITE) ) { - Rect.left = Item->XTab; - uFormat = DT_LEFT | DT_VCENTER | DT_SINGLELINE; + ++rect.left; ++rect.top; ++rect.right; ++rect.bottom; + SetTextColor(hdc, RGB(0xff, 0xff, 0xff)); + DrawTextW( hdc, Text, i, &rect, uFormat ); + --rect.left; --rect.top; --rect.right; --rect.bottom; + } + SetTextColor(hdc, RGB(0x80, 0x80, 0x80)); + } + + DrawTextW( hdc, Text, i, &rect, uFormat); + + /* paint the shortcut text */ + if (!menuBar && L'\0' != Text[i]) /* There's a tab or flush-right char */ + { + if (L'\t' == Text[i]) + { + rect.left = lpitem->XTab; + uFormat = DT_LEFT | DT_VCENTER | DT_SINGLELINE; } - else + else { - Rect.right = Item->XTab; - uFormat = DT_RIGHT | DT_VCENTER | DT_SINGLELINE; + rect.right = lpitem->XTab; + uFormat = DT_RIGHT | DT_VCENTER | DT_SINGLELINE; } - if (0 != (Item->fState & MF_GRAYED)) + if (lpitem->fState & MF_GRAYED) { - if (0 == (Item->fState & MF_HILITE)) + if (!(lpitem->fState & MF_HILITE) ) { - ++Rect.left; ++Rect.top; ++Rect.right; ++Rect.bottom; - SetTextColor(Dc, RGB(0xff, 0xff, 0xff)); - DrawTextW(Dc, Text + i + 1, -1, &Rect, uFormat); - --Rect.left; --Rect.top; --Rect.right; --Rect.bottom; + ++rect.left; ++rect.top; ++rect.right; ++rect.bottom; + SetTextColor(hdc, RGB(0xff, 0xff, 0xff)); + DrawTextW( hdc, Text + i + 1, -1, &rect, uFormat); + --rect.left; --rect.top; --rect.right; --rect.bottom; } - SetTextColor(Dc, RGB(0x80, 0x80, 0x80)); - } - DrawTextW(Dc, Text + i + 1, -1, &Rect, uFormat); - } - - if (NULL != FontOld) - { - SelectObject(Dc, FontOld); - } - } + SetTextColor(hdc, RGB(0x80, 0x80, 0x80)); + } + DrawTextW( hdc, Text + i + 1, -1, &rect, uFormat ); + } + + if (hfontOld) + SelectObject (hdc, hfontOld); + } } /*********************************************************************** @@ -917,59 +1313,185 @@ * * Paint a popup menu. */ -static void FASTCALL -MenuDrawPopupMenu(HWND Wnd, HDC Dc, HMENU Menu) -{ - HBRUSH PrevBrush = NULL; - HPEN PrevPen; - RECT Rect; - ROSMENUINFO MenuInfo; - ROSMENUITEMINFO ItemInfo; - UINT u; - - TRACE("wnd=%x dc=%x menu=%x\n", Wnd, Dc, Menu); - - GetClientRect(Wnd, &Rect); - - if (NULL != (PrevBrush = SelectObject(Dc, GetSysColorBrush(COLOR_MENU))) - && NULL != SelectObject(Dc, hMenuFont)) - { - Rectangle(Dc, Rect.left, Rect.top, Rect.right, Rect.bottom); - - PrevPen = SelectObject(Dc, GetStockObject(NULL_PEN)); - if (NULL != PrevPen) - { - BOOL flat_menu = FALSE; - - SystemParametersInfoW (SPI_GETFLATMENU, 0, &flat_menu, 0); - if (flat_menu) - FrameRect(Dc, &Rect, GetSysColorBrush(COLOR_BTNSHADOW)); - else - DrawEdge(Dc, &Rect, EDGE_RAISED, BF_RECT); - - /* draw menu items */ - - if (MenuGetRosMenuInfo(&MenuInfo, Menu) && 0 != MenuInfo.MenuItemCount) +static void FASTCALL MenuDrawPopupMenu(HWND hwnd, HDC hdc, HMENU hmenu ) +{ + HBRUSH hPrevBrush = 0; + RECT rect; + + TRACE("wnd=%p dc=%p menu=%p\n", hwnd, hdc, hmenu); + + GetClientRect( hwnd, &rect ); + + if((hPrevBrush = SelectObject( hdc, GetSysColorBrush(COLOR_MENU) )) + && (SelectObject( hdc, hMenuFont))) + { + HPEN hPrevPen; + + Rectangle( hdc, rect.left, rect.top, rect.right, rect.bottom ); + + hPrevPen = SelectObject( hdc, GetStockObject( NULL_PEN ) ); + if ( hPrevPen ) + { + BOOL flat_menu = FALSE; + ROSMENUINFO MenuInfo; + ROSMENUITEMINFO ItemInfo; + + SystemParametersInfoW (SPI_GETFLATMENU, 0, &flat_menu, 0); + if (flat_menu) + FrameRect(hdc, &rect, GetSysColorBrush(COLOR_BTNSHADOW)); + else + DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT); + + /* draw menu items */ + if (MenuGetRosMenuInfo(&MenuInfo, hmenu) && MenuInfo.MenuItemCount) { - MenuInitRosMenuItemInfo(&ItemInfo); - - for (u = 0; u < MenuInfo.MenuItemCount; u++) + UINT u; + + MenuInitRosMenuItemInfo(&ItemInfo); + + for (u = 0; u < MenuInfo.MenuItemCount; u++) { - if (MenuGetRosMenuItemInfo(MenuInfo.Self, u, &ItemInfo)) + if (MenuGetRosMenuItemInfo(MenuInfo.Self, u, &ItemInfo)) { - MenuDrawMenuItem(Wnd, &MenuInfo, MenuInfo.WndOwner, Dc, &ItemInfo, - MenuInfo.Height, FALSE, ODA_DRAWENTIRE); + MenuDrawMenuItem(hwnd, &MenuInfo, MenuInfo.WndOwner, hdc, &ItemInfo, + MenuInfo.Height, FALSE, ODA_DRAWENTIRE); } } - MenuCleanupRosMenuItemInfo(&ItemInfo); - } - } - else - { - SelectObject(Dc, PrevBrush); - } - } + MenuCleanupRosMenuItemInfo(&ItemInfo); + } + } else + { + SelectObject( hdc, hPrevBrush ); + } + } +} + +/*********************************************************************** + * MenuDrawMenuBar + * + * Paint a menu bar. Returns the height of the menu bar. + * called from [windows/nonclient.c] + */ +UINT MenuDrawMenuBar( HDC hDC, LPRECT lprect, HWND hwnd, + BOOL suppress_draw) +{ + ROSMENUINFO lppop; + HFONT hfontOld = 0; + HMENU hMenu = GetMenu(hwnd); + + if (! MenuGetRosMenuInfo(&lppop, hMenu) || lprect == NULL) + { + return GetSystemMetrics(SM_CYMENU); + } + + if (suppress_draw) + { + hfontOld = SelectObject(hDC, hMenuFont); + + MenuMenuBarCalcSize(hDC, lprect, &lppop, hwnd); + + lprect->bottom = lprect->top + lppop.Height; + + if (hfontOld) SelectObject( hDC, hfontOld); + return lppop.Height; + } + else + return DrawMenuBarTemp(hwnd, hDC, lprect, hMenu, NULL); +} + +/*********************************************************************** + * MenuShowPopup + * + * Display a popup menu. + */ +static BOOL FASTCALL MenuShowPopup(HWND hwndOwner, HMENU hmenu, UINT id, UINT flags, + INT x, INT y, INT xanchor, INT yanchor ) +{ + ROSMENUINFO MenuInfo; + ROSMENUITEMINFO ItemInfo; + UINT width, height; + POINT pt; + HMONITOR monitor; + MONITORINFO info; + + TRACE("owner=%p hmenu=%p id=0x%04x x=0x%04x y=0x%04x xa=0x%04x ya=0x%04x\n", + hwndOwner, hmenu, id, x, y, xanchor, yanchor); + + if (! MenuGetRosMenuInfo(&MenuInfo, hmenu)) return FALSE; + if (MenuInfo.FocusedItem != NO_SELECTED_ITEM) + { + MenuInitRosMenuItemInfo(&ItemInfo); + if (MenuGetRosMenuItemInfo(MenuInfo.Self, MenuInfo.FocusedItem, &ItemInfo)) + { + ItemInfo.fMask |= MIIM_STATE; + ItemInfo.fState &= ~(MF_HILITE|MF_MOUSESELECT); + MenuSetRosMenuItemInfo(MenuInfo.Self, MenuInfo.FocusedItem, &ItemInfo); + } + MenuCleanupRosMenuItemInfo(&ItemInfo); + MenuInfo.FocusedItem = NO_SELECTED_ITEM; + } + + /* store the owner for DrawItem */ + MenuInfo.WndOwner = hwndOwner; + MenuSetRosMenuInfo(&MenuInfo); + + MenuPopupMenuCalcSize(&MenuInfo, hwndOwner); + + /* adjust popup menu pos so that it fits within the desktop */ + + width = MenuInfo.Width + GetSystemMetrics(SM_CXBORDER); + height = MenuInfo.Height + GetSystemMetrics(SM_CYBORDER); + + /* FIXME: should use item rect */ + pt.x = x; + pt.y = y; + monitor = MonitorFromPoint( pt, MONITOR_DEFAULTTONEAREST ); + info.cbSize = sizeof(info); + GetMonitorInfoW( monitor, &info ); + + if( flags & TPM_RIGHTALIGN ) x -= width; + if( flags & TPM_CENTERALIGN ) x -= width / 2; + + if( flags & TPM_BOTTOMALIGN ) y -= height; + if( flags & TPM_VCENTERALIGN ) y -= height / 2; + + if( x + width > info.rcWork.right) + { + if( xanchor && x >= width - xanchor ) + x -= width - xanchor; + + if( x + width > info.rcWork.right) + x = info.rcWork.right - width; + } + if( x < info.rcWork.left ) x = info.rcWork.left; + + if( y + height > info.rcWork.bottom) + { + if( yanchor && y >= height + yanchor ) + y -= height + yanchor; + + if( y + height > info.rcWork.bottom) + y = info.rcWork.bottom - height; + } + if( y < info.rcWork.top ) y = info.rcWork.top; + + /* NOTE: In Windows, top menu popup is not owned. */ + MenuInfo.Wnd = CreateWindowExW( 0, POPUPMENU_CLASS_ATOMW, NULL, + WS_POPUP, x, y, width, height, + hwndOwner, 0, (HINSTANCE) GetWindowLongPtrW(hwndOwner, GWLP_HINSTANCE), + (LPVOID) MenuInfo.Self); + if ( !MenuInfo.Wnd || ! MenuSetRosMenuInfo(&MenuInfo)) return FALSE; + if (!TopPopup) { + TopPopup = MenuInfo.Wnd; + } + + /* Display the window */ + + SetWindowPos( MenuInfo.Wnd, HWND_TOPMOST, 0, 0, 0, 0, + SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); + UpdateWindow( MenuInfo.Wnd ); + return TRUE; } LRESULT WINAPI @@ -1320,7 +1842,6 @@ return TRUE; } - VOID MenuCleanup(VOID) { @@ -1337,435 +1858,6 @@ } } - - -/*********************************************************************** - * MenuCalcItemSize - * - * Calculate the size of the menu item and store it in ItemInfo->rect. - */ -static void FASTCALL -MenuCalcItemSize(HDC Dc, PROSMENUITEMINFO ItemInfo, PROSMENUINFO MenuInfo, HWND WndOwner, - INT OrgX, INT OrgY, BOOL MenuBar) -{ - PWCHAR p; - INT itemheight = 0; - UINT CheckBitmapWidth = GetSystemMetrics(SM_CXMENUCHECK); - - TRACE("dc=%x owner=%x (%d,%d)\n", Dc, WndOwner, OrgX, OrgY); - - MenuCharSize.cx = GdiGetCharDimensions( Dc, NULL, &MenuCharSize.cy ); - - SetRect(&ItemInfo->Rect, OrgX, OrgY, OrgX, OrgY); - - if (0 != (ItemInfo->fType & MF_OWNERDRAW)) - { - /* - ** Experimentation under Windows reveals that an owner-drawn - ** menu is expected to return the size of the content part of - ** the menu item, not including the checkmark nor the submenu - ** arrow. Windows adds those values itself and returns the - ** enlarged rectangle on subsequent WM_DRAWITEM messages. - */ - MEASUREITEMSTRUCT mis; - mis.CtlType = ODT_MENU; - mis.CtlID = 0; - mis.itemID = ItemInfo->wID; - mis.itemData = (DWORD)ItemInfo->dwItemData; - mis.itemHeight = HIWORD( GetDialogBaseUnits()); - mis.itemWidth = 0; - SendMessageW(WndOwner, WM_MEASUREITEM, 0, (LPARAM) &mis); - /* Tests reveal that Windows ( Win95 thru WinXP) adds twice the average - * width of a menufont character to the width of an owner-drawn menu. - */ - ItemInfo->Rect.right += mis.itemWidth + 2 * MenuCharSize.cx; - - if (MenuBar) - { - /* under at least win95 you seem to be given a standard - height for the menu and the height value is ignored */ - ItemInfo->Rect.bottom += GetSystemMetrics(SM_CYMENUSIZE); - } - else - { - ItemInfo->Rect.bottom += mis.itemHeight; - } - - TRACE("id=%04x size=%dx%d\n", ItemInfo->wID, mis.itemWidth, mis.itemHeight); - return; - } - - if (0 != (ItemInfo->fType & MF_SEPARATOR)) - { - ItemInfo->Rect.bottom += SEPARATOR_HEIGHT; - if( !MenuBar) - ItemInfo->Rect.right += CheckBitmapWidth + MenuCharSize.cx; - return; - } - - ItemInfo->XTab = 0; - - if (ItemInfo->hbmpItem) - { - SIZE Size; - - if (!MenuBar) /* hbmpItem */ - { - MenuGetBitmapItemSize(ItemInfo, &Size, WndOwner ); - /* Keep the size of the bitmap in callback mode to be able - * to draw it correctly */ - ItemInfo->Rect.right = ItemInfo->Rect.left + Size.cx; - if (MenuInfo->maxBmpSize.cx < abs(Size.cx) + MENU_ITEM_HBMP_SPACE || - MenuInfo->maxBmpSize.cy < abs(Size.cy)) - { - MenuInfo->maxBmpSize.cx = abs(Size.cx) + MENU_ITEM_HBMP_SPACE; - MenuInfo->maxBmpSize.cy = abs(Size.cy); - } - MenuSetRosMenuInfo(MenuInfo); - itemheight = Size.cy + 2; - - if( !(MenuInfo->dwStyle & MNS_NOCHECK)) - ItemInfo->Rect.right += 2 * CheckBitmapWidth; - ItemInfo->Rect.right += 4 + MenuCharSize.cx; - ItemInfo->XTab = ItemInfo->Rect.right; - ItemInfo->Rect.right += CheckBitmapWidth; - } - else /* hbmpItem & MenuBar */ - { - MenuGetBitmapItemSize(ItemInfo, &Size, WndOwner ); - ItemInfo->Rect.right += Size.cx; - if( ItemInfo->Text) ItemInfo->Rect.right += 2; - itemheight = Size.cy; - - /* Special case: Minimize button doesn't have a space behind it. */ - if (ItemInfo->hbmpItem == (HBITMAP)HBMMENU_MBAR_MINIMIZE || - ItemInfo->hbmpItem == (HBITMAP)HBMMENU_MBAR_MINIMIZE_D) - ItemInfo->Rect.right -= 1; - } - } - else if (!MenuBar) - { - if( !(MenuInfo->dwStyle & MNS_NOCHECK)) - ItemInfo->Rect.right += CheckBitmapWidth; - ItemInfo->Rect.right += 4 + MenuCharSize.cx; - ItemInfo->XTab = ItemInfo->Rect.right; - ItemInfo->Rect.right += CheckBitmapWidth; - } - - /* it must be a text item - unless it's the system menu */ - if (0 == (ItemInfo->fType & MF_SYSMENU) && ItemInfo->Text) - { - HFONT hfontOld = NULL; - RECT rc = ItemInfo->Rect; - LONG txtheight, txtwidth; - - if ( ItemInfo->fState & MFS_DEFAULT ) - { - hfontOld = SelectObject( Dc, hMenuFontBold ); - } - if (MenuBar) - { - txtheight = DrawTextW( Dc, ItemInfo->dwTypeData, -1, &rc, - DT_SINGLELINE|DT_CALCRECT); - ItemInfo->Rect.right += rc.right - rc.left; - itemheight = max( max( itemheight, txtheight), - GetSystemMetrics( SM_CYMENU) - 1); - ItemInfo->Rect.right += 2 * MenuCharSize.cx; - } - else - { - if ((p = strchrW( ItemInfo->dwTypeData, '\t' )) != NULL) - { - RECT tmprc = rc; - LONG tmpheight; - int n = (int)( p - ItemInfo->dwTypeData); - /* Item contains a tab (only meaningful in popup menus) */ - /* get text size before the tab */ - txtheight = DrawTextW( Dc, ItemInfo->dwTypeData, n, &rc, - DT_SINGLELINE|DT_CALCRECT); - txtwidth = rc.right - rc.left; - p += 1; /* advance past the Tab */ - /* get text size after the tab */ - tmpheight = DrawTextW( Dc, p, -1, &tmprc, DT_SINGLELINE|DT_CALCRECT); - ItemInfo->XTab += txtwidth; - txtheight = max( txtheight, tmpheight); - txtwidth += MenuCharSize.cx + /* space for the tab */ - tmprc.right - tmprc.left; /* space for the short cut */ - } - else - { - txtheight = DrawTextW( Dc, ItemInfo->dwTypeData, -1, &rc, - DT_SINGLELINE|DT_CALCRECT); - txtwidth = rc.right - rc.left; - ItemInfo->XTab += txtwidth; - } - ItemInfo->Rect.right += 2 + txtwidth; - itemheight = max( itemheight, max( txtheight + 2, MenuCharSize.cy + 4)); - } - if (hfontOld) SelectObject (Dc, hfontOld); - } - else if( MenuBar) - { - itemheight = max( itemheight, GetSystemMetrics(SM_CYMENU)-1); - } - ItemInfo->Rect.bottom += itemheight; - TRACE("(%ld,%ld)-(%ld,%ld)\n", ItemInfo->Rect.left, ItemInfo->Rect.top, ItemInfo->Rect.right, ItemInfo->Rect.bottom); -} - -/*********************************************************************** - * MenuPopupMenuCalcSize - * - * Calculate the size of a popup menu. - */ -static void FASTCALL -MenuPopupMenuCalcSize(PROSMENUINFO MenuInfo, HWND WndOwner) -{ - ROSMENUITEMINFO ItemInfo; - HDC Dc; - int Start, i; - int OrgX, OrgY, MaxX, MaxTab, MaxTabWidth; - - MenuInfo->Width = MenuInfo->Height = 0; - if (0 == MenuInfo->MenuItemCount) - { - MenuSetRosMenuInfo(MenuInfo); - return; - } - - Dc = GetDC(NULL); - SelectObject(Dc, hMenuFont); - - Start = 0; - MaxX = 2 + 1; - - MenuInfo->maxBmpSize.cx = 0; - MenuInfo->maxBmpSize.cy = 0; - - MenuInitRosMenuItemInfo(&ItemInfo); - while (Start < MenuInfo->MenuItemCount) - { - OrgX = MaxX; - OrgY = 2; - - MaxTab = MaxTabWidth = 0; - - /* Parse items until column break or end of menu */ - for (i = Start; i < MenuInfo->MenuItemCount; i++) - { - if (! MenuGetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo)) - { - MenuCleanupRosMenuItemInfo(&ItemInfo); - MenuSetRosMenuInfo(MenuInfo); - return; - } - if (i != Start && - 0 != (ItemInfo.fType & (MF_MENUBREAK | MF_MENUBARBREAK))) - { - break; - } - MenuCalcItemSize(Dc, &ItemInfo, MenuInfo, WndOwner, OrgX, OrgY, FALSE); - if (! MenuSetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo)) - { - MenuCleanupRosMenuItemInfo(&ItemInfo); - MenuSetRosMenuInfo(MenuInfo); - return; - } -// Not sure here,, The patch from wine removes this. -// if (0 != (ItemInfo.fType & MF_MENUBARBREAK)) -// { -// OrgX++; -// } - MaxX = max(MaxX, ItemInfo.Rect.right); - OrgY = ItemInfo.Rect.bottom; - if ((ItemInfo.Text) && 0 != ItemInfo.XTab) - { - MaxTab = max(MaxTab, ItemInfo.XTab); - MaxTabWidth = max(MaxTabWidth, ItemInfo.Rect.right - ItemInfo.XTab); - } - } - - /* Finish the column (set all items to the largest width found) */ - MaxX = max(MaxX, MaxTab + MaxTabWidth); - while (Start < i) - { - if (MenuGetRosMenuItemInfo(MenuInfo->Self, Start, &ItemInfo)) - { - ItemInfo.Rect.right = MaxX; - if ((ItemInfo.Text) && 0 != ItemInfo.XTab) - { - ItemInfo.XTab = MaxTab; - } - MenuSetRosMenuItemInfo(MenuInfo->Self, Start, &ItemInfo); - } - Start++; - } - MenuInfo->Height = max(MenuInfo->Height, OrgY); - } - - MenuInfo->Width = MaxX; - - /* space for 3d border */ - MenuInfo->Height += 2; - MenuInfo->Width += 2; - - ReleaseDC(NULL, Dc); - MenuCleanupRosMenuItemInfo(&ItemInfo); - MenuSetRosMenuInfo(MenuInfo); -} - -/*********************************************************************** - * MenuMenuBarCalcSize - * - * FIXME: Word 6 implements its own MDI and its own 'close window' bitmap - * height is off by 1 pixel which causes lengthy window relocations when - * active document window is maximized/restored. - * - * Calculate the size of the menu bar. - */ -static void FASTCALL -MenuMenuBarCalcSize(HDC Dc, LPRECT Rect, PROSMENUINFO MenuInfo, HWND WndOwner) -{ - ROSMENUITEMINFO ItemInfo; - int Start, i, OrgX, OrgY, MaxY, HelpPos; - - if (NULL == Rect || NULL == MenuInfo) - { - return; - } - if (0 == MenuInfo->MenuItemCount) - { - return; - } - - TRACE("left=%ld top=%ld right=%ld bottom=%ld\n", - Rect->left, Rect->top, Rect->right, Rect->bottom); - MenuInfo->Width = Rect->right - Rect->left; - MenuInfo->Height = 0; - MaxY = Rect->top + 1; - Start = 0; - HelpPos = -1; - - MenuInfo->maxBmpSize.cx = 0; - MenuInfo->maxBmpSize.cy = 0; - - MenuInitRosMenuItemInfo(&ItemInfo); - while (Start < MenuInfo->MenuItemCount) - { - if (! MenuGetRosMenuItemInfo(MenuInfo->Self, Start, &ItemInfo)) - { - MenuCleanupRosMenuItemInfo(&ItemInfo); - return; - } - OrgX = Rect->left; - OrgY = MaxY; - - /* Parse items until line break or end of menu */ - for (i = Start; i < MenuInfo->MenuItemCount; i++) - { - if (-1 == HelpPos && 0 != (ItemInfo.fType & MF_RIGHTJUSTIFY)) - { - HelpPos = i; - } - if (i != Start && - 0 != (ItemInfo.fType & (MF_MENUBREAK | MF_MENUBARBREAK))) - { - break; - } - - TRACE("calling MENU_CalcItemSize org=(%d, %d)\n", OrgX, OrgY); - MenuCalcItemSize(Dc, &ItemInfo, MenuInfo, WndOwner, OrgX, OrgY, TRUE); - if (! MenuSetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo)) - { - MenuCleanupRosMenuItemInfo(&ItemInfo); - return; - } - - if (ItemInfo.Rect.right > Rect->right) - { - if (i != Start) - { - break; - } - else - { - ItemInfo.Rect.right = Rect->right; - } - } - MaxY = max(MaxY, ItemInfo.Rect.bottom ); - OrgX = ItemInfo.Rect.right; - if (i + 1 < MenuInfo->MenuItemCount) - { - if (! MenuGetRosMenuItemInfo(MenuInfo->Self, i + 1, &ItemInfo)) - { - MenuCleanupRosMenuItemInfo(&ItemInfo); - return; - } - } - } - -/* FIXME: Is this really needed? */ /*NO! it is not needed, why make the -HBMMENU_MBAR_CLOSE, MINIMIZE & RESTORE, look the same size as the menu bar! */ -#if 0 - /* Finish the line (set all items to the largest height found) */ - while (Start < i) - { - if (MenuGetRosMenuItemInfo(MenuInfo->Self, Start, &ItemInfo)) - { - ItemInfo.Rect.bottom = MaxY; - MenuSetRosMenuItemInfo(MenuInfo->Self, Start, &ItemInfo); - } - Start++; - } -#else - Start = i; /* This works! */ -#endif - } - - Rect->bottom = MaxY; - MenuInfo->Height = Rect->bottom - Rect->top; - MenuSetRosMenuInfo(MenuInfo); - - if (-1 != HelpPos) - { - /* Flush right all items between the MF_RIGHTJUSTIFY and */ - /* the last item (if several lines, only move the last line) */ - if (! MenuGetRosMenuItemInfo(MenuInfo->Self, MenuInfo->MenuItemCount - 1, &ItemInfo)) - { - MenuCleanupRosMenuItemInfo(&ItemInfo); - return; - } - OrgY = ItemInfo.Rect.top; - OrgX = Rect->right; - for (i = MenuInfo->MenuItemCount - 1; HelpPos <= i; i--) - { - if (i < HelpPos) - { - break; /* done */ - } - if (ItemInfo.Rect.top != OrgY) - { - break; /* Other line */ - } - if (OrgX <= ItemInfo.Rect.right) - { - break; /* Too far right already */ - } - ItemInfo.Rect.left += OrgX - ItemInfo.Rect.right; - ItemInfo.Rect.right = OrgX; - OrgX = ItemInfo.Rect.left; - MenuSetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo); - if (HelpPos + 1 <= i && - ! MenuGetRosMenuItemInfo(MenuInfo->Self, i - 1, &ItemInfo)) - { - MenuCleanupRosMenuItemInfo(&ItemInfo); - return; - } - } - } - - MenuCleanupRosMenuItemInfo(&ItemInfo); -} - /*********************************************************************** * DrawMenuBarTemp (USER32.@) * @@ -1841,44 +1933,6 @@ SelectObject(DC, FontOld); return MenuInfo.Height; -} - - -/*********************************************************************** - * MenuDrawMenuBar - * - * Paint a menu bar. Returns the height of the menu bar. - * called from [windows/nonclient.c] - */ -UINT MenuDrawMenuBar(HDC DC, LPRECT Rect, HWND Wnd, BOOL SuppressDraw) -{ - ROSMENUINFO MenuInfo; - HFONT FontOld = NULL; - HMENU Menu = GetMenu(Wnd); - - if (NULL == Rect || ! MenuGetRosMenuInfo(&MenuInfo, Menu)) - { - return GetSystemMetrics(SM_CYMENU); - } - - if (SuppressDraw) - { - FontOld = SelectObject(DC, hMenuFont); - - MenuMenuBarCalcSize(DC, Rect, &MenuInfo, Wnd); - - Rect->bottom = Rect->top + MenuInfo.Height; - - if (NULL != FontOld) - { - SelectObject(DC, FontOld); - } - return MenuInfo.Height; - } - else - { - return DrawMenuBarTemp(Wnd, DC, Rect, Menu, NULL); - } } /*********************************************************************** @@ -1925,112 +1979,6 @@ MenuSetRosMenuInfo(&MenuInfo); } } - - return TRUE; -} - - -/*********************************************************************** - * MenuShowPopup - * - * Display a popup menu. - */ -static BOOL FASTCALL -MenuShowPopup(HWND WndOwner, HMENU Menu, UINT Id, UINT flags, - INT X, INT Y, INT XAnchor, INT YAnchor ) -{ - ROSMENUINFO MenuInfo; - ROSMENUITEMINFO ItemInfo; - UINT Width, Height; - POINT pt; - HMONITOR monitor; - MONITORINFO info; - - TRACE("owner=%x hmenu=%x id=0x%04x x=0x%04x y=0x%04x xa=0x%04x ya=0x%04x\n", - WndOwner, Menu, Id, X, Y, XAnchor, YAnchor); - - if (! MenuGetRosMenuInfo(&MenuInfo, Menu)) - { - return FALSE; - } - - if (NO_SELECTED_ITEM != MenuInfo.FocusedItem) - { - MenuInitRosMenuItemInfo(&ItemInfo); - if (MenuGetRosMenuItemInfo(MenuInfo.Self, MenuInfo.FocusedItem, &ItemInfo)) - { - ItemInfo.fMask |= MIIM_STATE; - ItemInfo.fState &= ~(MF_HILITE|MF_MOUSESELECT); - MenuSetRosMenuItemInfo(MenuInfo.Self, MenuInfo.FocusedItem, &ItemInfo); - } - MenuCleanupRosMenuItemInfo(&ItemInfo); - MenuInfo.FocusedItem = NO_SELECTED_ITEM; - } - - /* store the owner for DrawItem */ - MenuInfo.WndOwner = WndOwner; - MenuSetRosMenuInfo(&MenuInfo); - - MenuPopupMenuCalcSize(&MenuInfo, WndOwner); - - /* adjust popup menu pos so that it fits within the desktop */ - - Width = MenuInfo.Width + GetSystemMetrics(SM_CXBORDER); - Height = MenuInfo.Height + GetSystemMetrics(SM_CYBORDER); - - /* FIXME: should use item rect */ - pt.x = X; - pt.y = Y; - monitor = MonitorFromPoint( pt, MONITOR_DEFAULTTONEAREST ); - info.cbSize = sizeof(info); - GetMonitorInfoW( monitor, &info ); - - if( flags & TPM_RIGHTALIGN ) X -= Width; - if( flags & TPM_CENTERALIGN ) X -= Width / 2; - - if( flags & TPM_BOTTOMALIGN ) Y -= Height; - if( flags & TPM_VCENTERALIGN ) Y -= Height / 2; - - if (X + Width > info.rcWork.right) - { - if ( XAnchor && X >= Width - XAnchor) - X -= Width - XAnchor; - - if ( X + Width > info.rcWork.right) - X = info.rcWork.right - Width; - } - - if ( X < info.rcWork.left ) X = info.rcWork.left; - - if (Y + Height > info.rcWork.bottom) - { - if ( YAnchor && Y >= Height + YAnchor) - Y -= Height + YAnchor; - - if ( Y + Height > info.rcWork.bottom) - Y = info.rcWork.bottom - Height; - } - - if ( Y < info.rcWork.top ) Y = info.rcWork.top; - - /* NOTE: In Windows, top menu popup is not owned. */ - MenuInfo.Wnd = CreateWindowExW(0, POPUPMENU_CLASS_ATOMW, NULL, - WS_POPUP, X, Y, Width, Height, - WndOwner, 0, (HINSTANCE) GetWindowLongPtrW(WndOwner, GWLP_HINSTANCE), - (LPVOID) MenuInfo.Self); - if (NULL == MenuInfo.Wnd || ! MenuSetRosMenuInfo(&MenuInfo)) - { - return FALSE; - } - if (NULL == TopPopup) - { - TopPopup = MenuInfo.Wnd; - } - - /* Display the window */ - SetWindowPos(MenuInfo.Wnd, HWND_TOPMOST, 0, 0, 0, 0, - SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); - UpdateWindow(MenuInfo.Wnd); return TRUE; } @@ -3281,78 +3229,6 @@ } /*********************************************************************** - * MenuFindItemByKey - * - * Find the menu item selected by a key press. - * Return item id, -1 if none, -2 if we should close the menu. - */ -static UINT FASTCALL -MenuFindItemByKey(HWND WndOwner, PROSMENUINFO MenuInfo, - WCHAR Key, BOOL ForceMenuChar) -{ - ROSMENUINFO SysMenuInfo; - PROSMENUITEMINFO Items, ItemInfo; - LRESULT MenuChar; - UINT i; - - TRACE("\tlooking for '%c' (0x%02x) in [%p]\n", (char) Key, Key, MenuInfo); - - if (NULL == MenuInfo || ! IsMenu(MenuInfo->Self)) - { - if (MenuGetRosMenuInfo(&SysMenuInfo, GetSystemMenu(WndOwner, FALSE))) - { - MenuInfo = &SysMenuInfo; - } - else - { - MenuInfo = NULL; - } - } - - if (NULL != MenuInfo) - { - if (MenuGetAllRosMenuItemInfo(MenuInfo->Self, &Items) <= 0) - { - return -1; - } - if (! ForceMenuChar) - { - Key = toupperW(Key); - ItemInfo = Items; - for (i = 0; i < MenuInfo->MenuItemCount; i++, ItemInfo++) - { - if ((ItemInfo->Text) && NULL != ItemInfo->dwTypeData) - { - WCHAR *p = (WCHAR *) ItemInfo->dwTypeData - 2; - do - { - p = strchrW(p + 2, '&'); - } - while (NULL != p && L'&' == p[1]); - if (NULL != p && (toupperW(p[1]) == Key)) - { - return i; - } - } - } - } - - MenuChar = SendMessageW(WndOwner, WM_MENUCHAR, - MAKEWPARAM(Key, MenuInfo->Flags), (LPARAM) MenuInfo->Self); - if (2 == HIWORD(MenuChar)) - { - return LOWORD(MenuChar); - } - if (1 == HIWORD(MenuChar)) - { - return (UINT) (-2); - } - } - - return (UINT)(-1); -} - -/*********************************************************************** * MenuTrackMenu * * Menu tracking code. @@ -3437,7 +3313,7 @@ } /* check if EndMenu() tried to cancel us, by posting this message */ - if (WM_CANCELMODE == Msg.message) + if (Msg.message == WM_CANCELMODE) { /* we are now out of the loop */ fEndMenu = TRUE; @@ -3452,13 +3328,13 @@ TranslateMessage(&Msg); Mt.Pt = Msg.pt; - if (Msg.hwnd == MenuInfo.Wnd || WM_TIMER != Msg.message) + if (Msg.hwnd == MenuInfo.Wnd || Msg.message != WM_TIMER) { EnterIdleSent = FALSE; } fRemove = FALSE; - if (WM_MOUSEFIRST <= Msg.message && Msg.message <= WM_MOUSELAST) + if ((Msg.message >= WM_MOUSEFIRST) && (Msg.message <= WM_MOUSELAST)) { /* * Use the mouse coordinates in lParam instead of those in the MSG @@ -3477,10 +3353,7 @@ case WM_RBUTTONDBLCLK: case WM_RBUTTONDOWN: - if (0 == (Flags & TPM_RIGHTBUTTON)) - { - break; - } + if (!(Flags & TPM_RIGHTBUTTON)) break; /* fall through */ case WM_LBUTTONDBLCLK: case WM_LBUTTONDOWN: @@ -3491,14 +3364,11 @@ break; case WM_RBUTTONUP: - if (0 == (Flags & TPM_RIGHTBUTTON)) - { - break; - } + if (0 == (Flags & TPM_RIGHTBUTTON)) break; /* fall through */ case WM_LBUTTONUP: /* Check if a menu was selected by the mouse */ - if (NULL != Menu) + if (Menu) { ExecutedMenuId = MenuButtonUp(&Mt, Menu, Flags); @@ -3518,13 +3388,13 @@ case WM_MOUSEMOVE: if (Menu) { - fEndMenu |= ! MenuMouseMove(&Mt, Menu, Flags); + fEndMenu |= !MenuMouseMove(&Mt, Menu, Flags); } break; } /* switch(Msg.message) - mouse */ } - else if (WM_KEYFIRST <= Msg.message && Msg.message <= WM_KEYLAST) + else if ((Msg.message >= WM_KEYFIRST) && (Msg.message <= WM_KEYLAST)) { fRemove = TRUE; /* Keyboard messages are always removed */ switch(Msg.message)
14 years, 9 months
1
0
0
0
[dreimer] 46230: Update openoffice 2.4 Links to a new and working mirror
by dreimer@svn.reactos.org
Author: dreimer Date: Tue Mar 16 23:08:44 2010 New Revision: 46230 URL:
http://svn.reactos.org/svn/reactos?rev=46230&view=rev
Log: Update openoffice 2.4 Links to a new and working mirror Modified: trunk/reactos/base/applications/rapps/rapps/openoffice2.4.txt Modified: trunk/reactos/base/applications/rapps/rapps/openoffice2.4.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/rapps/ra…
============================================================================== --- trunk/reactos/base/applications/rapps/rapps/openoffice2.4.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/rapps/rapps/openoffice2.4.txt [iso-8859-1] Tue Mar 16 23:08:44 2010 @@ -8,23 +8,23 @@ Size = 127MB Category = 6 URLSite =
http://www.openoffice.org/
-URLDownload =
http://ftp.plusline.de/OpenOffice/stable/2.4.3/OOo_2.4.3_Win32Intel_install…
+URLDownload =
ftp://archive.services.openoffice.org/pub/openoffice-archive/stable/2.4.3/O…
CDPath = none [Section.0407] Description = DIE Open Source Office Suite. URLSite =
http://de.openoffice.org/
Size = 114.2MB -URLDownload =
http://ftp.tu-chemnitz.de/pub/openoffice/localized/de/2.4.3/OOo_2.4.3_Win32…
+URLDownload =
ftp://archive.services.openoffice.org/pub/openoffice-archive/localized/de/2…
[Section.040a] Description = La suite de ofimática de código abierto. URLSite =
http://es.openoffice.org/
Size = 113.9MB -URLDownload =
http://ftp.tu-chemnitz.de/pub/openoffice/localized/es/2.4.3/OOo_2.4.3_Win32…
+URLDownload =
ftp://archive.services.openoffice.org/pub/openoffice-archive/localized/es/2…
[Section.0415] URLSite =
http://pl.openoffice.org/
Description = Otwarty pakiet biurowy. -URLDownload =
http://ftp.tu-chemnitz.de/pub/openoffice/localized/pl/2.4.2/OOo_2.4.2_Win32…
+URLDownload =
ftp://archive.services.openoffice.org/pub/openoffice-archive/localized/pl/2…
Size = 113.9M
14 years, 9 months
1
0
0
0
← Newer
1
...
37
38
39
40
41
42
43
...
90
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
Results per page:
10
25
50
100
200