Menu

#100 Remote desktop corupts async pro

open
nobody
None
5
2017-04-27
2008-09-05
Danny
No

One popular way to remotely access a PC is through
Windows remote desktop. It works like PC anywhere. I have noticed that using Remote desktop to connect to computer running XP and an async pro fax program can
randomly corupt async pro. What happens is you start getting some wierd read error exceptions. Closing your async pro application does no good. Try/Catch blocks do not capture the error. Running the windows terminal emulation program will allow you to access serial ports so it proves there is a problem with async pro. You have to reboot the computer to clear up the condition. Note that Remote desktop does let you map serial ports. However, I never enable that check box. Something else is that I am not sure how to reproduce the problem all the time.

Has anyone else notices this?

Any clues?

I suspect there is some code in windows that does something when there is a remote desktop connection. Async pro lib code is not looking for this and something causes resources and/or threads to get stuck forvever requiring a reboot.

Kinda a bummer because the video quality of remote desktop is so much better than pcanywhere.

Discussion

  • Rasmus Watjen

    Rasmus Watjen - 2008-09-29

    I am seeing a similar problem, but only on Windows 2008 remote desktops.
    My app does some initialization of the serial device in the OnPortOpen event, and when sending the first line of data to the port, we get an access violation. The AV comes from TApdWin32Dispatcher.WriteCom in the Move(Buf^, OBuffer^[OBufHead], Size); line.

    This is because OBuffer is free'd, due to the very first ReadFile call in TReadThread.ReadSerial (also lnswin32.pas) failing. The GetLastError code is 38 - ERROR_HANDLE_EOF.

    The same COM port can be connected to and communicated with using the Putty serial terminal program.

    The same program works locally on everything from Windows 2000 to Windows Vista, and server versions from 2000 to 2008. We only see this problem on remote desktop connections to Windows Server 2008.

     
  • Rasmus Watjen

    Rasmus Watjen - 2008-09-29

    I am not sure why ReadFile gets this EOF error, and what is means on a serial port.

    I have tried handling ERROR_HANDLE_EOF and letting ReadSerial return 0 (0 bytes read) on that occasion, and it seems to work fine. New code for TReadThread.ReadSerial:
    if (not ReadFile(ComHandle, Buf^, Size, bytesRead, ovl)) then
    begin
    istat := GetLastError;
    if (istat = ERROR_IO_PENDING) then
    begin
    Result := WaitForOverlapped(ovl);
    if (Result < 0) then
    begin
    istat := GetLastError;
    if (GetLastError = ERROR_OPERATION_ABORTED) then
    Result := 0
    else
    TApdBaseDispatcher(H).LastWinError := istat;
    end;
    end else if (istat = ERROR_HANDLE_EOF) then
    begin
    Result := 0;
    end else begin
    TApdBaseDispatcher(H).LastWinError := istat;
    Result := ecDeviceRead;
    end;
    end else
    Result := bytesRead;

    However, if somebody can enlighten me on what would cause an EOF on ReadFile, that would be great, since the above code could potentially break lots of stuff.

     
  • Alessandro Briosi

    I can also add that using a com port (the example provided too) in a remote desktop session (with Windows 7, but probably with other versions too), the application raises an exception when opening the port.

     
  • Alessandro Briosi

    BTW component comport (can be found on SF) works without any problem.

     

Log in to post a comment.