Introduction

A few years ago I was working at a software development company and one day my co-worker asked me if would be possible to use the Windows Net Send mechanism to send messages through the corporate network using some programming language like C++. I found the idea very interesting since we could implement this functionality in some of our applications so they could send messages to our computers when an exception occurs and/or something goes wrong.

After some time of MSDN and Google, learning about MailSlots, I could write the first test program and, for our surprise, worked like a charm.

With our program ready, we've started do create a generic function to send the messages, so we could make it avaliable at our "shared" directory, when I got an idea: "What if we use an invalid User Name to send the message?". Well, I think I don't need to tell you how this history ends

Background Information

The FakeSend (and Net Send) mechanism is very simple. It uses an Interprocess Communication (IPC) resource called "MailSlots". We can create MailSlots to swap messages between applications on a network environment just like we do with Sockets, Named Pipes, etc... The MailSlot internally uses a datagram socket, which means that we cannot be sure if the message has arrived. To learn more about MailSlots read the MailSlot Reference from MSDN Library.

Using the code

The code is very straightforward. We have the main function NetSend() that receives three values:

szSender - The name of the person who is sending the message (Any name you want);

szReceiver - The User Name (Network Login) or Machine name of the person who will receive the message;

History

2003-06-08 - First version of FakeSend. Bugs: Zero, I hope

2003-06-11 - Version 1.01. Just improving the code.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

I know that this program gives a fake name one the computer the message is sent to, but what about on the server. We have a server at my school that monitors all net send messages. Would it still have my real alias on that so I could be traced or would it also have the fake name? I just need to know if there is anyway for these messages to be traced back to me.

Well, I don't know how you program works but let me tell you what I think:

The mechanism presented in the article uses the CreateFile/WriteFile API for writing files to some mailslot from some computer. When you are doing this you are using some network protocol (Netbios I guess). So if you have some sniffer running in this network you probably could know what machine have sent the package and then identify the original sender.

So, if your program works like a sniffer, you probably can discover who is the original sender.

I was under the impression that a Net Send Message is a UDP packet in which case, it's pretty much impossible to tell... since UPD is "directionless" ... eg... has no... From address, TCP/IP has tho...

to 424 bytes (sender+1 +recipient+1 +msg+1). The message won't get send if size > 424.
Also tried multiple calls of WriteFile, but this does not work either: first part of the message is instantly received and next part must have a sender and recipient header again.

It's very simple... When you are "listening" a MailSlot, you can read any number of bytes you want. The NT/2000/XP Messenger Service, just read some bytes of the message and then stop... The WinPopup for Win9x reads the bytes until it gets to the end of the message.

Thank you for your reply. I just tried sending messages between WinXP and Win98SE through the mailslot "messngr":

Send Win98SE -> WinXP:
- messages >424 bytes are not received at all

Send WinXP -> Win98SE:
- messages >424 bytes are truncated

Send WinXP -> WinXP:
- messages >424 bytes are not received at all
- every received message is received twice

Send Win98SE -> Win98SE:
- messages >425(!) bytes are truncated

What I am looking for is a way to remotely "tell" the mailslot server
- how long the actual message will be(/get) or
- when the message ends (something like an EOF) or
- how big the message buffer should be

I do not want to write my own message server application, but rather use the messenger function of WinNT/2k/XP and WinPopup on Win9x systems.

No, It's not possible because the Windows Messenger Service just listen the mailslot and popup the message to the user when one arrives. To do a chat system, you'll have to write your own messenger service.

Please do! Perhaps I'm missing something, but never in the rest of the article did you mention what using a fake name gives you. At least, I didn't see it. I'm supposing from the title that it allows the message to be "anonymous" by virtue of the sender not really existing, but I think you should actually state that in your article. Yes, CodeProject readers are likely to be a smart bunch, but leading up to the main point of an article and not actually stating it is frustrating for a reader, who has to spend a lot more time than otherwise needed filling in the gaps. Treat readers like they're a little slow...we all have to do too much thinking at work anyway

Just my opinion. You should all be ashamed for not thinking the same thing

Your parameters should probably be const char * instead of just char *, because they are not modified.

You're declaring a array or characters to hold the generated message, but you're not checking to see if the combined sender+receiver+message actually fits in the array. You just copy the strings without checking for array overflow. This is pretty dangerous. It would be much better to either use snprintf(), or to manually check the size of the string and dynamically allocate a buffer large enough.

Other than that, well done

Ryan

Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)

Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"