From fe68098da9643318f00014f7fc25072ce22fac95 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 14 Sep 2014 00:43:43 +0000 Subject: [PATCH 1/1] [NTVDM] - Add DPRINTs to the DumpMemory function. - Use a VgaSetActiveScreenBuffer function to change active screen buffers: it calls the SetConsoleActiveScreenBuffer API but also recreates the VDM console menus, because on windows custom console menus are per-screen-buffer, and not per-console, so that if you set menus when one screen buffer is activated, and if you change it, then your menus become unuseful because for this new active screenbuffer, they are not set. It's completely ridiculous but we need to live with that (on ReactOS we still don't have this behaviour). svn path=/trunk/; revision=64137 --- reactos/subsystems/ntvdm/emulator.c | 4 ++++ reactos/subsystems/ntvdm/hardware/vga.c | 20 +++++++++++++++----- reactos/subsystems/ntvdm/ntvdm.c | 4 ++-- reactos/subsystems/ntvdm/ntvdm.h | 5 +++++ 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/reactos/subsystems/ntvdm/emulator.c b/reactos/subsystems/ntvdm/emulator.c index 3bc60c0d3bb..78168a77e79 100644 --- a/reactos/subsystems/ntvdm/emulator.c +++ b/reactos/subsystems/ntvdm/emulator.c @@ -355,6 +355,8 @@ VOID DumpMemory(VOID) _snwprintf(FileName, MAX_PATH, L"memdump%lu.txt", DumpNumber); ++DumpNumber; + DPRINT1("Creating memory dump file '%S'...\n", FileName); + /* Always create the dump file */ hFile = CreateFileW(FileName, GENERIC_WRITE, @@ -415,6 +417,8 @@ VOID DumpMemory(VOID) /* Close the file */ CloseHandle(hFile); + + DPRINT1("Memory dump done\n"); } DWORD WINAPI PumpConsoleInput(LPVOID Parameter); diff --git a/reactos/subsystems/ntvdm/hardware/vga.c b/reactos/subsystems/ntvdm/hardware/vga.c index caa6332009c..af9c0e0f185 100644 --- a/reactos/subsystems/ntvdm/hardware/vga.c +++ b/reactos/subsystems/ntvdm/hardware/vga.c @@ -942,6 +942,16 @@ Cleanup: return Result; } +static VOID VgaSetActiveScreenBuffer(HANDLE ScreenBuffer) +{ + /* Set the active buffer */ + SetConsoleActiveScreenBuffer(ScreenBuffer); + + /* Reinitialize the VDM menu */ + DestroyVdmMenu(); + CreateVdmMenu(ScreenBuffer); +} + static BOOL VgaEnterGraphicsMode(PCOORD Resolution) { DWORD i; @@ -999,7 +1009,7 @@ static BOOL VgaEnterGraphicsMode(PCOORD Resolution) ZeroMemory(ConsoleFramebuffer, BitmapInfo->bmiHeader.biSizeImage); /* Set the active buffer */ - SetConsoleActiveScreenBuffer(GraphicsConsoleBuffer); + VgaSetActiveScreenBuffer(GraphicsConsoleBuffer); /* Set the graphics mode palette */ SetConsolePalette(GraphicsConsoleBuffer, @@ -1018,7 +1028,7 @@ static VOID VgaLeaveGraphicsMode(VOID) ReleaseMutex(ConsoleMutex); /* Switch back to the default console text buffer */ - // SetConsoleActiveScreenBuffer(TextConsoleBuffer); + // VgaSetActiveScreenBuffer(TextConsoleBuffer); /* Cleanup the video data */ CloseHandle(ConsoleMutex); @@ -1034,7 +1044,7 @@ static BOOL VgaEnterTextMode(PCOORD Resolution) DPRINT1("VgaEnterTextMode\n"); /* Switch to the text buffer */ - SetConsoleActiveScreenBuffer(TextConsoleBuffer); + VgaSetActiveScreenBuffer(TextConsoleBuffer); /* Adjust the text framebuffer if we changed the resolution */ if (TextResolution.X != Resolution->X || @@ -1950,7 +1960,7 @@ VOID VgaDetachFromConsole(BOOL ChangingMode) SMALL_RECT ConRect; /* Restore the old screen buffer */ - SetConsoleActiveScreenBuffer(TextConsoleBuffer); + VgaSetActiveScreenBuffer(TextConsoleBuffer); /* Restore the original console size */ ConRect.Left = 0; @@ -1988,7 +1998,7 @@ BOOLEAN VgaInitialize(HANDLE TextHandle) /***/ VgaResetPalette(); /***/ /* Switch to the text buffer */ - SetConsoleActiveScreenBuffer(TextConsoleBuffer); + VgaSetActiveScreenBuffer(TextConsoleBuffer); /* Clear the VGA memory */ VgaClearMemory(); diff --git a/reactos/subsystems/ntvdm/ntvdm.c b/reactos/subsystems/ntvdm/ntvdm.c index 9f630e18730..9fd9d4a2047 100644 --- a/reactos/subsystems/ntvdm/ntvdm.c +++ b/reactos/subsystems/ntvdm/ntvdm.c @@ -119,7 +119,7 @@ AppendMenuItems(HMENU hMenu, } while (!(Items[i].uID == 0 && Items[i].SubMenu == NULL && Items[i].wCmdID == 0)); } -static VOID +/*static*/ VOID CreateVdmMenu(HANDLE ConOutHandle) { hConsoleMenu = ConsoleMenuControl(ConOutHandle, @@ -132,7 +132,7 @@ CreateVdmMenu(HANDLE ConOutHandle) DrawMenuBar(GetConsoleWindow()); } -static VOID +/*static*/ VOID DestroyVdmMenu(VOID) { UINT i = 0; diff --git a/reactos/subsystems/ntvdm/ntvdm.h b/reactos/subsystems/ntvdm/ntvdm.h index 4686c05e77d..0a4ecc1b4d4 100644 --- a/reactos/subsystems/ntvdm/ntvdm.h +++ b/reactos/subsystems/ntvdm/ntvdm.h @@ -48,6 +48,11 @@ extern HANDLE VdmTaskEvent; VOID DisplayMessage(LPCWSTR Format, ...); +/*static*/ VOID +CreateVdmMenu(HANDLE ConOutHandle); +/*static*/ VOID +DestroyVdmMenu(VOID); + #endif // _NTVDM_H_ /* EOF */ -- 2.17.1