tags:

views:

481

answers:

1

While using VNC combined with RDP, I have noticed a behaviour which VNC do, that is when you have connected to a machine using RDP (mstsc), and then you want to connect to that machine using VNC, it will disconnects the RDP session, and you will see a screen blink(Black screen for a second) on the target machine and then you are connected via VNC, What I want to know is that How VNC is disconnecting the active RDP sessions, Any code snippet will be really help ful.. Thanks

+1  A: 

When you connect using VNC it tries to connect to the console session using WinStationConnectW (Which is undocumented) this will disconnect the RDP session.

Here is a snippet from TightVNC:

  void setConsoleSession(DWORD sessionId) {
#ifdef RFB_HAVE_WINSTATION_CONNECT
    if (!_WinStationConnect.isValid())
      throw rdr::Exception("WinSta APIs missing");
    if (sessionId == -1)
      sessionId = mySessionId.id;

    // Try to reconnect our session to the console
    ConsoleSessionId console;
    vlog.info("Console session is %d", console.id);
    if (!(*_WinStationConnect)(0, sessionId, console.id, L"", 0))
      throw rdr::SystemException("Unable to connect session to Console", GetLastError());

    // Lock the newly connected session, for security
    if (_LockWorkStation.isValid())
      (*_LockWorkStation)();
#else
    throw rdr::Exception("setConsoleSession not implemented");
#endif
  }
Shay Erlichmen