Hack Forums
[.NET] Remote Desktop Serialization issue - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Remote Desktop Serialization issue (/showthread.php?tid=4835884)



Remote Desktop Serialization issue - blondedude092 - May 25, 2015

I'm having issues using code I obtained from another source.

The Client side sending...
Code
Private Sub startListening()
        Try
            listener = New TcpListener(Port)
            listener.Start()
            mainSocket = listener.AcceptSocket()
            s = New NetworkStream(mainSocket)
            eventWatcher = New Thread(New ThreadStart(AddressOf waitForKeys))
            eventWatcher.Start()


            While True
                Dim screeny As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb)
                Dim bFormat As New BinaryFormatter()
                bFormat.Serialize(s, screeny)
                screeny.Save(s, ImageFormat.Png)
                screeny.Save("image.bmp")

                Thread.Sleep(imageDelay)

                screeny.Dispose()
            End While


        Catch generatedExceptionName As Exception
            If mainSocket.IsBound Then
                mainSocket.Close()
            End If
            If listener IsNot Nothing Then
                listener.[Stop]()
                'MessageBox.Show(gay.ToString());
            End If
        End Try
    End Sub

The server side receiving

Code
Private Sub startRead()
        Try
            stream = client.GetStream()
            eventSender = New StreamWriter(stream)
            While True
                Dim bFormat As New BinaryFormatter()
                Dim inImage As Bitmap = bFormat.Deserialize(stream)
                resolutionX = inImage.Width
                resolutionY = inImage.Height

                theImage.Image = inImage
                theImage.BackgroundImage = inImage

            End While
        Catch ex As Exception
            Debug.WriteLine("Error " + ex.Message)
        End Try

    End Sub

I have been able to get the server side to get some of the images sometimes but never has it gotten to display on the imagebox.
I had to take inImage.Save to get the image.

I get a serialization error
Quote:Exception thrown: 'System.Runtime.Serialization.SerializationException' in mscorlib.dll
Error The input stream is not a valid binary format. The starting contents (in bytes) are: 89-50-4E-47-0D-0A-1A-0A-00-00-00-0D-49-48-44-52-00 ...


Please do not bash or be rude. I would like help not immaturity. Thank you.


* - Only3 - May 25, 2015

its hex u need to convert it back to bytes


* - blondedude092 - May 25, 2015

I don't understand why it's receiving hex. It's serialized on one end and deserialized on the other. I never converted it to hex in the first place.


* - Only3 - May 25, 2015

yhe didnt check ur code just the error
check https://hackforums.net/showthread.php?tid=4576866


* - blondedude092 - May 25, 2015

thank you I'll have to compare the difference and see if I can come up with the solution.


* - He B TeMy - May 25, 2015

Without seeing the bFormat class we can guess.
And the error is pretty explicit.


* - blondedude092 - May 29, 2015

(May 25, 2015 12:10 PM)He B TeMy Wrote:  Without seeing the bFormat class we can guess.
And the error is pretty explicit.

It's not a class... it's just a binary formatter