Click here to Skip to main content
13,769,357 members
Click here to Skip to main content
Add your own
alternative version


33 bookmarked
Posted 7 Jun 2003

Fake (or Anonymous) NetSend for Windows NT/2000/XP

, 17 Jun 2003
Rate this:
Please Sign up or sign in to vote.
The Fake NetSend is a little utility that can be used to send anonymous (or fake) messages through your Windows Network.


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;
  • szMessage - The Message you want to send.
<PRE lang=c++>bool NetSend(const char * szSender, const char * szReceiver, const char * szMessage) { // Our main variables char * pszMailSlot = NULL; unsigned char * pucMessage = NULL; unsigned int nMailSlotLen, nMsgFormatLen; HANDLE hHandle; DWORD dwBytesWritten; bool bRet = false; // Get the length of the strings nMailSlotLen = strlen(szReceiver) + sizeof(szMailSlotPath); nMsgFormatLen = strlen(szSender) + strlen(szReceiver) + strlen(szMessage) + sizeof(szMsgFormat); // Allocate necessary memory pszMailSlot = new char[nMailSlotLen]; pucMessage = new unsigned char[nMsgFormatLen]; // Network path for <Receiver> MailSlot: // "\\Receiver\MAILSLOT\messngr" sprintf(pszMailSlot, szMailSlotPath, szReceiver); // Message Format: // "Sender\0Receiver\0Message\0" // sprintf doesn't work with \0 so here I'm using \r sprintf((char *)pucMessage, szMsgFormat, szSender, szReceiver, szMessage); // Replace all '\r' characters with '\0' for (unsigned short i = 0; i < nMsgFormatLen; i++) { if (pucMessage[i] == '\r') pucMessage[i] = '\0'; else if (pucMessage[i] == '\0') break; } // Create the file into Receiver's MailSlot and get a Handle to this file hHandle = CreateFile(pszMailSlot, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); // Do we have a valid handle? if (hHandle) { // Write the message to file bRet = (WriteFile(hHandle, pucMessage, (DWORD)nMsgFormatLen, &dwBytesWritten, NULL) == TRUE); // Free the handle CloseHandle(hHandle); } return bRet; }


  • 2003-06-08 - First version of FakeSend. Bugs: Zero, I hope :)
  • 2003-06-11 - Version 1.01. Just improving the code.


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.

A list of licenses authors might use can be found here


About the Author

Caio Proiete
Team Leader Arch Capital Group
Bermuda Bermuda
Caio Proiete has been programming for over 10 years, having first started with Clipper Summer'87.

He loves software development and reverse engineering. Today his main development technologies includes ASP .NET MVC, jQuery, HTML5, Silverlight, and WCF. He also has the following titles:

MVP - Microsoft Most Valuable Professional;
MCT - Microsoft Certified Trainer;
MCPD - Microsoft Certified Professional Developer;
MCTS - Microsoft Certified Technology Specialist;
MCSD - Microsoft Certified Solution Developer;
MCDBA - Microsoft Certified Database Administrator.

Technical blog:

You may also be interested in...

Comments and Discussions

Questionvirtual ip on remote side? Pin
*scenera*8-Feb-04 20:15
member*scenera*8-Feb-04 20:15 
AnswerRe: virtual ip on remote side? Pin
Caio Proiete14-Feb-04 17:16
memberCaio Proiete14-Feb-04 17:16 
QuestionHow to get the message in the other computer Pin
Fad B29-Jan-04 2:11
memberFad B29-Jan-04 2:11 
AnswerRe: How to get the message in the other computer Pin
Caio Proiete14-Feb-04 17:10
memberCaio Proiete14-Feb-04 17:10 
GeneralVB Code for FakeSend Pin
asdfgafasfdasf19-Dec-03 17:19
memberasdfgafasfdasf19-Dec-03 17:19 
GeneralRe: VB Code for FakeSend Pin
Caio Proiete14-Feb-04 17:05
memberCaio Proiete14-Feb-04 17:05 
GeneralRe: VB Code for FakeSend Pin
VB newbie18-Mar-04 19:36
memberVB newbie18-Mar-04 19:36 
Generaldon't know how to work it Pin
Johnny B6-Dec-03 17:37
memberJohnny B6-Dec-03 17:37 
I dont know if I am supposed to use the command prompt or if when i open the application it should stay open, but i am running windows XP and it does not seem to be working. If you could please tell me what I am doing wrong or am supposed to do that would be great.Cry | :((
GeneralRe: don't know how to work it Pin
Caio Proiete7-Dec-03 0:18
memberCaio Proiete7-Dec-03 0:18 
GeneralRe: don't know how to work it Pin
Anonymous7-Dec-03 6:20
memberAnonymous7-Dec-03 6:20 
QuestionWhy does it send 2 messages out? Pin
asdfgafasfdasf5-Dec-03 20:41
memberasdfgafasfdasf5-Dec-03 20:41 
AnswerRe: Why does it send 2 messages out? Pin
Caio Proiete7-Dec-03 0:23
memberCaio Proiete7-Dec-03 0:23 
GeneralWhy can't send msg to a IP Address. Pin
clonesheep1-Nov-03 21:42
memberclonesheep1-Nov-03 21:42 
GeneralRe: Why can't send msg to a IP Address. Pin
Caio Proiete7-Dec-03 0:26
memberCaio Proiete7-Dec-03 0:26 
QuestionHow do i put ICONS on it Pin
Osrald6-Oct-03 4:31
memberOsrald6-Oct-03 4:31 
AnswerRe: How do i put ICONS on it Pin
Caio Proiete7-Dec-03 0:29
memberCaio Proiete7-Dec-03 0:29 
GeneralPlease Give Me Code VB6 Or C++ To Net Send Anonymous Pin
Anonymous3-Oct-03 18:32
memberAnonymous3-Oct-03 18:32 
GeneralRe: Please Give Me Code VB6 Or C++ To Net Send Anonymous Pin
Caio Proiete3-Oct-03 18:38
memberCaio Proiete3-Oct-03 18:38 
GeneralRe: Please Give Me Code VB6 Or C++ To Net Send Anonymous Pin
mattwright21-Dec-05 10:59
membermattwright21-Dec-05 10:59 
GeneralTRACING Pin
jettajeff8724-Sep-03 15:59
memberjettajeff8724-Sep-03 15:59 
GeneralRe: TRACING Pin
Caio Proiete3-Oct-03 18:44
memberCaio Proiete3-Oct-03 18:44 
QuestionIs there a way to really know who is the sender? Pin
Bandu Patil27-Aug-03 3:10
memberBandu Patil27-Aug-03 3:10 
AnswerRe: Is there a way to really know who is the sender? Pin
Caio Proiete3-Oct-03 18:48
memberCaio Proiete3-Oct-03 18:48 
GeneralRe: Is there a way to really know who is the sender? Pin
Anonymous25-Jan-04 22:40
memberAnonymous25-Jan-04 22:40 
GeneralMessage size is limited Pin
otwesten8-Aug-03 5:54
memberotwesten8-Aug-03 5:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.181117.1 | Last Updated 18 Jun 2003
Article Copyright 2003 by Caio Proiete
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid