Hack Forums
[C] Send bitmap over socket - 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: [C] Send bitmap over socket (/showthread.php?tid=6020978)



Send bitmap over socket - SIM-3437924 - Oct 31, 2019

Anyone know how to send a bitmap handle over a socket? For context i'm trying to send a bitmap handle of a screenshot over a socket to be read by another computer to simulate a remote desktop.

Any advice appreciated!


RE: Send bitmap over socket - YouthInAsia - Oct 31, 2019

You need to read the hanldle into a buffer then send the buffer across.


RE: Send bitmap over socket - gua - Nov 1, 2019

first what sockets do u use, indy , winsock ...etc .. TCP or UDP ? Do you want to send image from client or server socket ? give us more info

It is similar for any of them but it would be nice if u provide that info..

Usually logic is simple as this ( assuming that you know how to establish connection, take screenshot etc ):

bitmap->assign(ScreenCapture.. bla bla bla)
bitmap->savetostream(bitmapstream)
if u use indy for example u will do something like
aconntext->connection->socket->write(bitmapstream->size)
aconntext->connection->socket->write(bitmapstream)


RE: Send bitmap over socket - 0xDEAD10CC - Nov 2, 2019

(Nov 1, 2019 02:49 AM)gua Wrote:  first what sockets do u use, indy , winsock ...etc .. TCP or UDP  ? Do you want to send image from client or server socket ? give us more info

It is similar for any of them but it would be nice if u provide that info..

Usually logic is simple as this ( assuming that you know how to establish connection, take screenshot etc ):

bitmap->assign(ScreenCapture.. bla bla bla)
bitmap->savetostream(bitmapstream)
if u use indy for example u will do something like
aconntext->connection->socket->write(bitmapstream->size)
aconntext->connection->socket->write(bitmapstream)

The questions you're asking do not matter at all whatsoever, and are a waste of time to answer; the process is the exact same, send x bytes from a buffer. If you're just going to spoonfeed him with his exact implementation that's your own prerogative, but I would advise against it. His misconception is asking how to send the handle.

@OP: Why would you send a bitmap handle over a socket connection? The handle is just a number that is completely useless to the far end, and it definitely isn't going to provide any bitmap data alone. You need to send the bytes of the actual bitmap itself... If you don't understand what handles are I can't see much success with creating remote desktop software.


RE: Send bitmap over socket - SIM-3437924 - Nov 2, 2019

(Nov 1, 2019 02:49 AM)gua Wrote:  first what sockets do u use, indy , winsock ...etc .. TCP or UDP  ? Do you want to send image from client or server socket ? give us more info

It is similar for any of them but it would be nice if u provide that info..

Usually logic is simple as this ( assuming that you know how to establish connection, take screenshot etc ):

bitmap->assign(ScreenCapture.. bla bla bla)
bitmap->savetostream(bitmapstream)
if u use indy for example u will do something like
aconntext->connection->socket->write(bitmapstream->size)
aconntext->connection->socket->write(bitmapstream)

I use winsock though TCP and I want to send the images from the server


(Nov 2, 2019 01:27 PM)0xDEAD10CC Wrote:  The questions you're asking do not matter at all whatsoever, and are a waste of time to answer; the process is the exact same, send x bytes from a buffer. If you're just going to spoonfeed him with his exact implementation that's your own prerogative, but I would advise against it. His misconception is asking how to send the handle.

@OP: Why would you send a bitmap handle over a socket connection? The handle is just a number that is completely useless to the far end, and it definitely isn't going to provide any bitmap data alone. You need to send the bytes of the actual bitmap itself... If you don't understand what handles are I can't see much success with creating remote desktop software.

Hi, I understand how a handle works, my main concern is what to do with the handle to send it across i.e. how do I convert it into bytes and then convert it back once sent across, "it" not meaning the handle but whatever I have to do with the handle to be able to send the bytes across.