Skip to content

VM class

David Simunič edited this page Nov 23, 2019 · 6 revisions

The VM class (in VM.cs) defines an object that holds important information about a particular virtual machine. This includes:

  • name (Name)
  • description (Desc)
  • path (Path)
  • window handle (hWnd)
  • status (Status)
  • and PID (Pid)

The first three should be obvious in meaning. hWnd is a Win32 window handle (actually an IntPtr) that allows the Manager to interact with the main 86Box window that belongs to the specific VM. Status is an integer that tells us the status that the VM is currently in. Pid is also an integer and tells us which process ID represents the current VM.

The class also defines four constant integers to make the status more friendly.

  • STATUS_STOPPED (0) - VM is stopped
  • STATUS_RUNNING (1) - VM is running
  • STATUS_WAITING (2) - VM is running, but it's waiting for user input
  • STATUS_PAUSED (3) - VM is running, but it's paused

STATUS_WAITING is used whenever a child dialog window is opened in 86Box, such as the settings dialog or the confirmation dialogs for hard reset and exit.

Please note: if Status is 0 (STATUS_STOPPED), the values stored in hWnd and Pid are not guaranteed to be accurate and must not be used! They're updated once status changes from 0 to something else and then should be accurate. It's possible to enter an undefined state where a running VM may have an invalid hWnd and/or Pid, or even a wrong status, though this is rare and I actively work on preventing such scenarios.

There are two constructors: the default one and one that takes four arguments (first three values above + Status). There's also a ToString() override and a GetStatusString() method, which returns an appropriate string for each of the possible statuses (this is useful in the UI).