Author: cwittich
Date: Sat May 30 16:05:10 2015
New Revision: 67971
URL: http://svn.reactos.org/svn/reactos?rev=67971&view=rev
Log:
[NTVDM]
adjust VdmMenuPos in case the menu already exists
CORE-9487
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/ntvd…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c [iso-8859-1] Sat May 30 16:05:10 2015
@@ -126,7 +126,11 @@
for (i = 0; i <= MenuPos; i++)
{
if (GetMenuItemID(hConsoleMenu, i) == ID_SHOWHIDE_MOUSE)
+ {
+ /* set VdmMenuPos to the position of the existing menu */
+ VdmMenuPos = i - 1;
return TRUE;
+ }
}
return FALSE;
}
@@ -141,8 +145,6 @@
/* Get the position where we are going to insert our menu items */
VdmMenuPos = GetMenuItemCount(hConsoleMenu);
- // FIXME: What happens if the menu already exist?
- // VdmMenuPos points *after* the already existing menu!
/* Really add the menu if it doesn't already exist (in case eg. NTVDM crashed) */
if (!VdmMenuExists(hConsoleMenu))
Author: hbelusca
Date: Sat May 30 15:51:18 2015
New Revision: 67970
URL: http://svn.reactos.org/svn/reactos?rev=67970&view=rev
Log:
[NTVDM]: When ntvdm crashes and we restart it in the same console, do not add fresh new menu items but just keep the old ones.
Patch by Christoph von Wittich, with some added comments to think about.
CORE-9487 #resolve
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/ntvd…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c [iso-8859-1] Sat May 30 15:51:18 2015
@@ -116,6 +116,21 @@
} while (!(Items[i].uID == 0 && Items[i].SubMenu == NULL && Items[i].wCmdID == 0));
}
+BOOL
+VdmMenuExists(HMENU hConsoleMenu)
+{
+ INT MenuPos, i;
+ MenuPos = GetMenuItemCount(hConsoleMenu);
+
+ /* Check for the presence of one of the VDM menu items */
+ for (i = 0; i <= MenuPos; i++)
+ {
+ if (GetMenuItemID(hConsoleMenu, i) == ID_SHOWHIDE_MOUSE)
+ return TRUE;
+ }
+ return FALSE;
+}
+
/*static*/ VOID
CreateVdmMenu(HANDLE ConOutHandle)
{
@@ -124,9 +139,17 @@
ID_VDM_QUIT);
if (hConsoleMenu == NULL) return;
+ /* Get the position where we are going to insert our menu items */
VdmMenuPos = GetMenuItemCount(hConsoleMenu);
- AppendMenuItems(hConsoleMenu, VdmMainMenuItems);
- DrawMenuBar(GetConsoleWindow());
+ // FIXME: What happens if the menu already exist?
+ // VdmMenuPos points *after* the already existing menu!
+
+ /* Really add the menu if it doesn't already exist (in case eg. NTVDM crashed) */
+ if (!VdmMenuExists(hConsoleMenu))
+ {
+ AppendMenuItems(hConsoleMenu, VdmMainMenuItems);
+ DrawMenuBar(GetConsoleWindow());
+ }
}
/*static*/ VOID