ReactOS 0.4.16-dev-297-gc569aee
console.c File Reference
#include "resource.h"
Include dependency graph for console.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _VDM_MENUITEM
 

Typedefs

typedef struct _VDM_MENUITEM VDM_MENUITEM
 
typedef struct _VDM_MENUITEMPVDM_MENUITEM
 

Functions

static VOID AppendMenuItems (HMENU hMenu, const VDM_MENUITEM *Items)
 
static BOOL VdmMenuExists (HMENU hConsoleMenu)
 
static VOID UpdateVdmMenuMouse (VOID)
 
VOID UpdateVdmMenuDisks (VOID)
 
static VOID UpdateVdmMenu (VOID)
 
static VOID CreateVdmMenu (HANDLE ConOutHandle)
 
static VOID DestroyVdmMenu (VOID)
 
static VOID CaptureMousePointer (HANDLE ConOutHandle, BOOLEAN Capture)
 
static VOID EnableExtraHardware (HANDLE ConsoleInput)
 
VOID VdmShutdown (BOOLEAN Immediate)
 
static BOOL WINAPI ConsoleCtrlHandler (DWORD ControlType)
 
static VOID ConsoleInitUI (VOID)
 
static VOID ConsoleCleanupUI (VOID)
 
BOOL ConsoleAttach (VOID)
 
VOID ConsoleDetach (VOID)
 
VOID ConsoleReattach (HANDLE ConOutHandle)
 
static BOOL ConsoleInit (VOID)
 
static VOID ConsoleCleanup (VOID)
 
BOOL IsConsoleHandle (HANDLE hHandle)
 
VOID MenuEventHandler (PMENU_EVENT_RECORD MenuEvent)
 
VOID FocusEventHandler (PFOCUS_EVENT_RECORD FocusEvent)
 

Variables

static HANDLE CurrentConsoleOutput = INVALID_HANDLE_VALUE
 
static HANDLE ConsoleInput = INVALID_HANDLE_VALUE
 
static HANDLE ConsoleOutput = INVALID_HANDLE_VALUE
 
static DWORD OrgConsoleInputMode
 
static DWORD OrgConsoleOutputMode
 
HWND hConsoleWnd = NULL
 
static HMENU hConsoleMenu = NULL
 
static INT VdmMenuPos = -1
 
static BOOL CaptureMouse = FALSE
 
static const VDM_MENUITEM VdmMenuItems []
 
static const VDM_MENUITEM VdmMainMenuItems []
 

Typedef Documentation

◆ PVDM_MENUITEM

◆ VDM_MENUITEM

Function Documentation

◆ AppendMenuItems()

static VOID AppendMenuItems ( HMENU  hMenu,
const VDM_MENUITEM Items 
)
static

Definition at line 58 of file console.c.

60{
61 UINT i = 0;
62 WCHAR szMenuString[256];
63 HMENU hSubMenu;
64
65 do
66 {
67 if (Items[i].uID != (UINT)-1)
68 {
70 Items[i].uID,
71 szMenuString,
72 ARRAYSIZE(szMenuString)) > 0)
73 {
74 if (Items[i].SubMenu != NULL)
75 {
76 hSubMenu = CreatePopupMenu();
77 if (hSubMenu != NULL)
78 {
79 AppendMenuItems(hSubMenu, Items[i].SubMenu);
80
81 if (!AppendMenuW(hMenu,
83 (UINT_PTR)hSubMenu,
84 szMenuString))
85 {
86 DestroyMenu(hSubMenu);
87 }
88 }
89 }
90 else
91 {
92 AppendMenuW(hMenu,
94 Items[i].uCmdID,
95 szMenuString);
96 }
97 }
98 }
99 else
100 {
101 AppendMenuW(hMenu,
103 0,
104 NULL);
105 }
106 i++;
107 } while (!(Items[i].uID == 0 && Items[i].SubMenu == NULL && Items[i].uCmdID == 0));
108}
#define NULL
Definition: types.h:112
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
unsigned int UINT
Definition: ndis.h:50
static VOID AppendMenuItems(HMENU hMenu, const VDM_MENUITEM *Items)
Definition: console.c:58
#define GetModuleHandle
Definition: winbase.h:3852
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define MF_STRING
Definition: winuser.h:138
#define MF_POPUP
Definition: winuser.h:136
#define MF_SEPARATOR
Definition: winuser.h:137
BOOL WINAPI DestroyMenu(_In_ HMENU)
BOOL WINAPI AppendMenuW(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by AppendMenuItems(), and CreateVdmMenu().

◆ CaptureMousePointer()

static VOID CaptureMousePointer ( HANDLE  ConOutHandle,
BOOLEAN  Capture 
)
static

Definition at line 288 of file console.c.

289{
290 static BOOL IsClipped = FALSE; // For debugging purposes
291 UNREFERENCED_PARAMETER(IsClipped);
292
293 if (Capture)
294 {
295 RECT rcClip;
296
297 // if (IsClipped) return;
298
299 /* Be sure the cursor will be hidden */
300 while (ShowConsoleCursor(ConOutHandle, FALSE) >= 0) ;
301
302 GetClientRect(hConsoleWnd, &rcClip);
303 MapWindowPoints(hConsoleWnd, HWND_DESKTOP /*NULL*/, (LPPOINT)&rcClip, 2 /* Magic value when the LPPOINT parameter is a RECT */);
304 IsClipped = ClipCursor(&rcClip);
305 }
306 else
307 {
308 // if (!IsClipped) return;
309
311 IsClipped = FALSE;
312
313 /* Be sure the cursor will be shown */
314 while (ShowConsoleCursor(ConOutHandle, TRUE) < 0) ;
315 }
316}
struct _Capture Capture
Definition: capture.h:24
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
INT WINAPI DECLSPEC_HOTPATCH ShowConsoleCursor(HANDLE hConsoleOutput, BOOL bShow)
Definition: console.c:1073
unsigned int BOOL
Definition: ntddk_ex.h:94
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
HWND hConsoleWnd
Definition: console.c:20
BOOL WINAPI ClipCursor(_In_opt_ LPCRECT)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define HWND_DESKTOP
Definition: winuser.h:1212
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by ConsoleCleanupUI(), ConsoleReattach(), FocusEventHandler(), and MenuEventHandler().

◆ ConsoleAttach()

BOOL ConsoleAttach ( VOID  )

Definition at line 398 of file console.c.

399{
400 /* Save the original input and output console modes */
403 {
406 wprintf(L"FATAL: Cannot save console in/out modes\n");
407 return FALSE;
408 }
409
410 /* Set the console input mode */
413
414 /* Set the console output mode */
415 // SetConsoleMode(ConsoleOutput, ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT);
416
417 /* Initialize the UI */
419
420 return TRUE;
421}
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1569
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1606
#define L(x)
Definition: ntvdm.h:50
static DWORD OrgConsoleOutputMode
Definition: console.c:18
static VOID ConsoleInitUI(VOID)
Definition: console.c:382
static VOID EnableExtraHardware(HANDLE ConsoleInput)
Definition: console.c:318
static HANDLE ConsoleOutput
Definition: console.c:17
static DWORD OrgConsoleInputMode
Definition: console.c:18
#define wprintf(...)
Definition: whoami.c:18
#define ENABLE_WINDOW_INPUT
Definition: wincon.h:81

Referenced by ConsoleInit(), and DosProcessConsoleAttach().

◆ ConsoleCleanup()

static VOID ConsoleCleanup ( VOID  )
static

Definition at line 493 of file console.c.

494{
495 /* Detach from the console */
497
498 /* Close the console handles */
501}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
VOID ConsoleDetach(VOID)
Definition: console.c:424

◆ ConsoleCleanupUI()

static VOID ConsoleCleanupUI ( VOID  )
static

Definition at line 389 of file console.c.

390{
391 /* Display again properly the mouse pointer */
393
395}
static VOID DestroyVdmMenu(VOID)
Definition: console.c:274
static BOOL CaptureMouse
Definition: console.c:23
static VOID CaptureMousePointer(HANDLE ConOutHandle, BOOLEAN Capture)
Definition: console.c:288

Referenced by ConsoleDetach().

◆ ConsoleCtrlHandler()

static BOOL WINAPI ConsoleCtrlHandler ( DWORD  ControlType)
static

Definition at line 359 of file console.c.

360{
361 switch (ControlType)
362 {
364 {
365 /* Delayed shutdown */
366 DPRINT1("NTVDM delayed killing in the CTRL_LAST_CLOSE_EVENT CtrlHandler!\n");
368 break;
369 }
370
371 default:
372 {
373 /* Stop the VDM if the user logs out or closes the console */
374 DPRINT1("Killing NTVDM in the 'default' CtrlHandler!\n");
376 }
377 }
378 return TRUE;
379}
#define DPRINT1
Definition: precomp.h:8
VOID VdmShutdown(BOOLEAN Immediate)
Definition: ntvdm.c:317
#define CTRL_LAST_CLOSE_EVENT
Definition: wincon.h:71

Referenced by ConsoleInit().

◆ ConsoleDetach()

VOID ConsoleDetach ( VOID  )

Definition at line 424 of file console.c.

425{
426 /* Cleanup the UI */
428
429 /* Restore the original input and output console modes */
432}
static VOID ConsoleCleanupUI(VOID)
Definition: console.c:389

Referenced by ConsoleCleanup(), and DosProcessConsoleDetach().

◆ ConsoleInit()

static BOOL ConsoleInit ( VOID  )
static

Definition at line 446 of file console.c.

447{
448 /* Set the handler routine */
450
451 /* Enable the CTRL_LAST_CLOSE_EVENT */
453
454 /*
455 * NOTE: The CONIN$ and CONOUT$ "virtual" files
456 * always point to non-redirected console handles.
457 */
458
459 /* Get the input handle to the real console, and check for success */
460 ConsoleInput = CreateFileW(L"CONIN$",
463 NULL,
465 0,
466 NULL);
468 {
469 wprintf(L"FATAL: Cannot retrieve a handle to the console input\n");
470 return FALSE;
471 }
472
473 /* Get the output handle to the real console, and check for success */
474 ConsoleOutput = CreateFileW(L"CONOUT$",
477 NULL,
479 0,
480 NULL);
482 {
484 wprintf(L"FATAL: Cannot retrieve a handle to the console output\n");
485 return FALSE;
486 }
487
488 /* Effectively attach to the console */
489 return ConsoleAttach();
490}
#define OPEN_EXISTING
Definition: compat.h:775
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI SetLastConsoleEventActive(VOID)
Definition: console.c:3279
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, BOOL Add)
Definition: console.c:2109
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
BOOL ConsoleAttach(VOID)
Definition: console.c:398
static BOOL WINAPI ConsoleCtrlHandler(DWORD ControlType)
Definition: console.c:359

Referenced by wmain().

◆ ConsoleInitUI()

static VOID ConsoleInitUI ( VOID  )
static

Definition at line 382 of file console.c.

383{
386}
HWND WINAPI DECLSPEC_HOTPATCH GetConsoleWindow(VOID)
Definition: console.c:2729
static VOID CreateVdmMenu(HANDLE ConOutHandle)
Definition: console.c:203

Referenced by ConsoleAttach().

◆ ConsoleReattach()

VOID ConsoleReattach ( HANDLE  ConOutHandle)

Definition at line 435 of file console.c.

436{
438 CurrentConsoleOutput = ConOutHandle;
439 CreateVdmMenu(ConOutHandle);
440
441 /* Synchronize mouse cursor display with console screenbuffer switches */
443}
static HANDLE CurrentConsoleOutput
Definition: console.c:14

Referenced by SetActiveScreenBuffer().

◆ CreateVdmMenu()

static VOID CreateVdmMenu ( HANDLE  ConOutHandle)
static

Definition at line 203 of file console.c.

204{
205 HMENU hVdmSubMenu;
206 UINT_PTR ItemID;
207 UINT Pos;
208 USHORT i;
209 WCHAR szNoMedia[100];
210 WCHAR szMenuString1[256], szMenuString2[256];
211
212 hConsoleMenu = ConsoleMenuControl(ConOutHandle,
215 if (hConsoleMenu == NULL) return;
216
217 /* Get the position where we are going to insert our menu items */
219
220 /* Really add the menu if it doesn't already exist (in case eg. NTVDM crashed) */
222 {
223 /* Add all the menu entries */
225
226 /* Add the removable drives menu entries */
227 hVdmSubMenu = GetSubMenu(hConsoleMenu, VdmMenuPos + 2); // VdmMenuItems
228 Pos = 3; // After the 2 items and the separator in VdmMenuItems
229
232 szNoMedia,
233 ARRAYSIZE(szNoMedia));
234
237 szMenuString1,
238 ARRAYSIZE(szMenuString1));
239
240 /* Drive 'x' -- Mount */
241 for (i = 0; i < ARRAYSIZE(GlobalSettings.FloppyDisks); ++i)
242 {
243 ItemID = ID_VDM_DRIVES + (2 * i);
244
245 /* Add the item */
246 _snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i, szNoMedia);
247 szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL;
248 InsertMenuW(hVdmSubMenu, Pos++, MF_STRING | MF_BYPOSITION, ItemID, szMenuString2);
249 }
250
253 szMenuString1,
254 ARRAYSIZE(szMenuString1));
255
256 /* Drive 'x' -- Eject */
257 for (i = 0; i < ARRAYSIZE(GlobalSettings.FloppyDisks); ++i)
258 {
259 ItemID = ID_VDM_DRIVES + (2 * i);
260
261 /* Add the item */
262 _snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i);
263 szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL;
264 InsertMenuW(hVdmSubMenu, Pos++, MF_STRING | MF_BYPOSITION, ItemID + 1, szMenuString2);
265 }
266
267 /* Refresh the menu state */
270 }
271}
ush Pos
Definition: deflate.h:92
HMENU WINAPI DECLSPEC_HOTPATCH ConsoleMenuControl(HANDLE hConsoleOutput, DWORD dwCmdIdLow, DWORD dwCmdIdHigh)
Definition: console.c:396
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
#define UNICODE_NULL
NTVDM_SETTINGS GlobalSettings
Definition: ntvdm.c:28
unsigned short USHORT
Definition: pedump.c:61
UNICODE_STRING FloppyDisks[2]
Definition: ntvdm.h:88
static BOOL VdmMenuExists(HMENU hConsoleMenu)
Definition: console.c:111
static HMENU hConsoleMenu
Definition: console.c:21
static const VDM_MENUITEM VdmMainMenuItems[]
Definition: console.c:48
static INT VdmMenuPos
Definition: console.c:22
static VOID UpdateVdmMenu(VOID)
Definition: console.c:196
#define IDS_NO_MEDIA
Definition: resource.h:23
#define IDS_VDM_EJECT_FLOPPY
Definition: resource.h:20
#define ID_VDM_DRIVES
Definition: resource.h:10
#define ID_CAPTURE_MOUSE
Definition: resource.h:4
#define IDS_VDM_MOUNT_FLOPPY
Definition: resource.h:19
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
BOOL WINAPI InsertMenuW(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
BOOL WINAPI DrawMenuBar(_In_ HWND)
#define MF_BYPOSITION
Definition: winuser.h:203

Referenced by ConsoleInitUI(), and ConsoleReattach().

◆ DestroyVdmMenu()

static VOID DestroyVdmMenu ( VOID  )
static

Definition at line 274 of file console.c.

275{
276 UINT i = 0;
277 const VDM_MENUITEM *Items = VdmMainMenuItems;
278
279 do
280 {
282 i++;
283 } while (!(Items[i].uID == 0 && Items[i].SubMenu == NULL && Items[i].uCmdID == 0));
284
286}
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)

Referenced by ConsoleCleanupUI(), and ConsoleReattach().

◆ EnableExtraHardware()

static VOID EnableExtraHardware ( HANDLE  ConsoleInput)
static

Definition at line 318 of file console.c.

319{
320 DWORD ConInMode;
321
322 if (GetConsoleMode(ConsoleInput, &ConInMode))
323 {
324#if 0
325 // GetNumberOfConsoleMouseButtons();
326 // GetSystemMetrics(SM_CMOUSEBUTTONS);
327 // GetSystemMetrics(SM_MOUSEPRESENT);
328 if (MousePresent)
329 {
330#endif
331 /* Support mouse input events if there is a mouse on the system */
332 ConInMode |= ENABLE_MOUSE_INPUT;
333#if 0
334 }
335 else
336 {
337 /* Do not support mouse input events if there is no mouse on the system */
338 ConInMode &= ~ENABLE_MOUSE_INPUT;
339 }
340#endif
341
342 SetConsoleMode(ConsoleInput, ConInMode);
343 }
344}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ENABLE_MOUSE_INPUT
Definition: wincon.h:82

Referenced by ConsoleAttach().

◆ FocusEventHandler()

VOID FocusEventHandler ( PFOCUS_EVENT_RECORD  FocusEvent)

Definition at line 600 of file console.c.

601{
602 /*
603 * If the mouse is captured, release it or recapture it
604 * when we lose or regain focus, respectively.
605 */
606 if (!CaptureMouse) return;
608}

Referenced by ConsoleEventThread().

◆ IsConsoleHandle()

BOOL IsConsoleHandle ( HANDLE  hHandle)

Definition at line 503 of file console.c.

504{
505 DWORD dwMode;
506
507 /* Check whether the handle may be that of a console... */
508 if ((GetFileType(hHandle) & ~FILE_TYPE_REMOTE) != FILE_TYPE_CHAR)
509 return FALSE;
510
511 /*
512 * It may be. Perform another test... The idea comes from the
513 * MSDN description of the WriteConsole API:
514 *
515 * "WriteConsole fails if it is used with a standard handle
516 * that is redirected to a file. If an application processes
517 * multilingual output that can be redirected, determine whether
518 * the output handle is a console handle (one method is to call
519 * the GetConsoleMode function and check whether it succeeds).
520 * If the handle is a console handle, call WriteConsole. If the
521 * handle is not a console handle, the output is redirected and
522 * you should call WriteFile to perform the I/O."
523 */
524 return GetConsoleMode(hHandle, &dwMode);
525}
DWORD WINAPI GetFileType(HANDLE hFile)
Definition: fileinfo.c:269
#define FILE_TYPE_CHAR
Definition: winbase.h:286
#define FILE_TYPE_REMOTE
Definition: winbase.h:288

◆ MenuEventHandler()

VOID MenuEventHandler ( PMENU_EVENT_RECORD  MenuEvent)

Definition at line 527 of file console.c.

528{
529 switch (MenuEvent->dwCommandId)
530 {
531 /*
532 * System-defined menu commands
533 */
534
535 case WM_INITMENU:
536 case WM_MENUSELECT:
537 {
538 /*
539 * If the mouse is captured, release it or recapture it
540 * when the menu opens or closes, respectively.
541 */
542 if (!CaptureMouse) break;
544 break;
545 }
546
547
548 /*
549 * User-defined menu commands
550 */
551
552 case ID_CAPTURE_MOUSE:
556 break;
557
560 break;
561
564 break;
565
566 /* Drive 0 -- Mount */
567 /* Drive 1 -- Mount */
568 case ID_VDM_DRIVES + 0:
569 case ID_VDM_DRIVES + 2:
570 {
571 ULONG DiskNumber = (MenuEvent->dwCommandId - ID_VDM_DRIVES) / 2;
572 MountFloppy(DiskNumber);
573 break;
574 }
575
576 /* Drive 0 -- Eject */
577 /* Drive 1 -- Eject */
578 case ID_VDM_DRIVES + 1:
579 case ID_VDM_DRIVES + 3:
580 {
581 ULONG DiskNumber = (MenuEvent->dwCommandId - ID_VDM_DRIVES - 1) / 2;
582 EjectFloppy(DiskNumber);
583 break;
584 }
585
586 case ID_VDM_QUIT:
587 /* Stop the VDM */
588 // EmulatorTerminate();
589
590 /* Nothing runs, so exit immediately */
591 DPRINT1("Killing NTVDM via console menu!\n");
593 break;
594
595 default:
596 break;
597 }
598}
VOID DumpMemory(BOOLEAN TextFormat)
Definition: emulator.c:369
VOID EjectFloppy(IN ULONG DiskNumber)
Definition: emulator.c:467
VOID MountFloppy(IN ULONG DiskNumber)
Definition: emulator.c:413
static VOID UpdateVdmMenuMouse(VOID)
Definition: console.c:130
#define ID_VDM_DUMPMEM_BIN
Definition: resource.h:6
#define ID_VDM_QUIT
Definition: resource.h:7
#define ID_VDM_DUMPMEM_TXT
Definition: resource.h:5
uint32_t ULONG
Definition: typedefs.h:59
#define WM_INITMENU
Definition: winuser.h:1748
#define WM_MENUSELECT
Definition: winuser.h:1750

Referenced by ConsoleEventThread().

◆ UpdateVdmMenu()

static VOID UpdateVdmMenu ( VOID  )
static

Definition at line 196 of file console.c.

197{
200}
VOID UpdateVdmMenuDisks(VOID)
Definition: console.c:146

Referenced by CreateVdmMenu().

◆ UpdateVdmMenuDisks()

VOID UpdateVdmMenuDisks ( VOID  )

Definition at line 146 of file console.c.

147{
148 UINT_PTR ItemID;
149 USHORT i;
150
151 WCHAR szNoMedia[100];
152 WCHAR szMenuString1[256], szMenuString2[256];
153
154 /* Update the disks menu items */
155
158 szNoMedia,
159 ARRAYSIZE(szNoMedia));
160
163 szMenuString1,
164 ARRAYSIZE(szMenuString1));
165
166 for (i = 0; i < ARRAYSIZE(GlobalSettings.FloppyDisks); ++i)
167 {
168 ItemID = ID_VDM_DRIVES + (2 * i);
169
173 {
174 /* Update item text */
175 _snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i, GlobalSettings.FloppyDisks[i].Buffer);
176 szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL;
177 ModifyMenuW(hConsoleMenu, ItemID, MF_BYCOMMAND | MF_STRING, ItemID, szMenuString2);
178
179 /* Enable the eject item */
181 }
182 else
183 {
184 /* Update item text */
185 _snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i, szNoMedia);
186 szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL;
187 ModifyMenuW(hConsoleMenu, ItemID, MF_BYCOMMAND | MF_STRING, ItemID, szMenuString2);
188
189 /* Disable the eject item */
191 }
192 }
193}
#define MF_BYCOMMAND
Definition: winuser.h:202
#define MF_ENABLED
Definition: winuser.h:128
BOOL WINAPI ModifyMenuW(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_GRAYED
Definition: winuser.h:129

Referenced by EjectFloppy(), EmulatorInitialize(), MountFloppy(), and UpdateVdmMenu().

◆ UpdateVdmMenuMouse()

static VOID UpdateVdmMenuMouse ( VOID  )
static

Definition at line 130 of file console.c.

131{
132 WCHAR szMenuString[256];
133
134 /* Update "Capture/Release mouse" menu item */
137 szMenuString,
138 ARRAYSIZE(szMenuString)) > 0)
139 {
141 MF_BYCOMMAND, ID_CAPTURE_MOUSE, szMenuString);
142 }
143}
#define IDS_RELEASE_MOUSE
Definition: resource.h:14
#define IDS_CAPTURE_MOUSE
Definition: resource.h:13

Referenced by MenuEventHandler(), and UpdateVdmMenu().

◆ VdmMenuExists()

static BOOL VdmMenuExists ( HMENU  hConsoleMenu)
static

Definition at line 111 of file console.c.

112{
113 INT MenuPos, i;
115
116 /* Check for the presence of one of the VDM menu items */
117 for (i = 0; i <= MenuPos; i++)
118 {
120 {
121 /* Set VdmMenuPos to the position of the existing menu */
122 VdmMenuPos = i - 1;
123 return TRUE;
124 }
125 }
126 return FALSE;
127}
int32_t INT
Definition: typedefs.h:58
UINT WINAPI GetMenuItemID(_In_ HMENU, _In_ int)

Referenced by CreateVdmMenu().

◆ VdmShutdown()

VOID VdmShutdown ( BOOLEAN  Immediate)

HACK!! HACK!!

Definition at line 317 of file ntvdm.c.

318{
319 /*
320 * Immediate = TRUE: Immediate shutdown;
321 * FALSE: Delayed shutdown.
322 */
323 static BOOLEAN MustShutdown = FALSE;
324
325 /* If a shutdown is ongoing, just return */
326 if (MustShutdown)
327 {
328 DPRINT1("Shutdown is ongoing...\n");
330 return;
331 }
332
333 /* First notify DOS to see whether we can shut down now */
334 MustShutdown = DosShutdown(Immediate);
335 /*
336 * In case we perform an immediate shutdown, or the DOS says
337 * we can shut down, do it now.
338 */
339 MustShutdown = MustShutdown || Immediate;
340
341 if (MustShutdown)
342 {
344
345 BiosCleanup();
348
350
351 DPRINT1("\n\n\nNTVDM - Exiting...\n\n\n");
352 /* Some VDDs rely on the fact that NTVDM calls ExitProcess on Windows */
353 ExitProcess(0);
354 }
355}
unsigned char BOOLEAN
BOOLEAN DosShutdown(BOOLEAN Immediate)
Definition: dem.c:1331
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
#define INFINITE
Definition: serial.h:102
VOID EmulatorTerminate(VOID)
Definition: emulator.c:503
VOID EmulatorCleanup(VOID)
Definition: emulator.c:639
static VOID FreeGlobalSettings(IN PNTVDM_SETTINGS Settings)
Definition: ntvdm.c:284
static VOID ConsoleCleanup(VOID)
VOID BiosCleanup(VOID)
Definition: bios.c:153
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790

Referenced by ConsoleCtrlHandler(), MenuEventHandler(), and wmain().

Variable Documentation

◆ CaptureMouse

BOOL CaptureMouse = FALSE
static

◆ ConsoleInput

Definition at line 16 of file console.c.

◆ ConsoleOutput

◆ CurrentConsoleOutput

HANDLE CurrentConsoleOutput = INVALID_HANDLE_VALUE
static

Definition at line 14 of file console.c.

Referenced by ConsoleReattach(), FocusEventHandler(), and MenuEventHandler().

◆ hConsoleMenu

HMENU hConsoleMenu = NULL
static

◆ hConsoleWnd

HWND hConsoleWnd = NULL

◆ OrgConsoleInputMode

DWORD OrgConsoleInputMode
static

Definition at line 18 of file console.c.

Referenced by ConsoleAttach(), and ConsoleDetach().

◆ OrgConsoleOutputMode

DWORD OrgConsoleOutputMode
static

Definition at line 18 of file console.c.

Referenced by ConsoleAttach(), and ConsoleDetach().

◆ VdmMainMenuItems

const VDM_MENUITEM VdmMainMenuItems[]
static
Initial value:
=
{
{ -1, NULL, 0 },
{ 0, NULL, 0 }
}
static const VDM_MENUITEM VdmMenuItems[]
Definition: console.c:35
#define IDS_VDM_MENU
Definition: resource.h:15

Definition at line 48 of file console.c.

Referenced by CreateVdmMenu(), and DestroyVdmMenu().

◆ VdmMenuItems

const VDM_MENUITEM VdmMenuItems[]
static
Initial value:
=
{
{ -1, NULL, 0 },
{ -1, NULL, 0 },
{ 0, NULL, 0 }
}
#define IDS_VDM_QUIT
Definition: resource.h:21
#define IDS_VDM_DUMPMEM_TXT
Definition: resource.h:17
#define IDS_VDM_DUMPMEM_BIN
Definition: resource.h:18

Definition at line 35 of file console.c.

◆ VdmMenuPos

INT VdmMenuPos = -1
static

Definition at line 22 of file console.c.

Referenced by CreateVdmMenu(), DestroyVdmMenu(), and VdmMenuExists().