NetSend the 'Mailslots-Way'

Share your advanced PureBasic knowledge/code with the community.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

NetSend the 'Mailslots-Way'

Post by Rings »

Code updated for 5.20+

I do not know if this works under Win89, but its a cool way to send messages over the network :)

Code: Select all

Sender.s="srings";Source (ME)

Reciepent.s="Ringsnb2" ;Destination, here my Notebook
Reciepent.s="*" ;BroadCast to all in network :)

Message.s="This is a Testmessage ! " ;The Message

Needed=Len(Sender.s)+Len(Reciepent.s)+Len(Message.s)+4 ;Calculate the needed Memory
buff = AllocateMemory(needed);and allocate them
If Buff
 ;Set the Data to our buffer
 PokeS(Buff,Sender)
 PokeS(Buff+Len(Sender.s)+1,Reciepent.s)
 PokeS(Buff+Len(Sender.s)+Len(Reciepent)+2,Message.s)
 
 SlotName.s = "\\" + Reciepent.s + "\mailslot\messngr"
 hFile = CreateFile_(@SlotName.s, #GENERIC_WRITE, #FILE_SHARE_READ, 0, #OPEN_EXISTING, #FILE_ATTRIBUTE_NORMAL, 0)
 byteswritten=0
 If HFile
  Result=WriteFile_(hFile, buff, Needed, @byteswritten, 0)
  If Result
   MessageRequester("Info","Message written  to "+Slotname.s+" : "+ Str(byteswritten),0)
  EndIf     
  CloseHandle_(hFile)
 Else
  MessageRequester("Info","problem with Slotname:"+Slotname.s,0);Error
 EndIf
 FreeMemory(Buff);Free Memory
EndIf  
SPAMINATOR NR.1
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4790
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

This is good stuff

Post by Fangbeast »

Thanks for this Rings...I have been annoying my teenage daughter all day with it as she sits on her bum and does nothing (ROFL)

Now to give it a window and really make her mad:):)
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Excellent

Post by LJ »

Excellent Rings. Your code is the first 'net' code that works on my network configuration (no base, peer to peer, linksys wireless). It seems other network code that has been posted requires a server/client configuration. I like the simple yet direct approach. I wonder if your code sends a message over any network regardless of the configuration of the network? Nice one. Lj
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: Excellent

Post by Rings »

LJ wrote:Excellent Rings. Your code is the first 'net' code that works on my network configuration (no base, peer to peer, linksys wireless). It seems other network code that has been posted requires a server/client configuration. I like the simple yet direct approach. I wonder if your code sends a message over any network regardless of the configuration of the network? Nice one. Lj
mmh.... so did it work under w89 and derivates ?
SPAMINATOR NR.1
dige
Addict
Addict
Posts: 1406
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

Damn cool Rings! :D
But why this works?

cya dige

PS: tested on win2ksp4
hypervox
User
User
Posts: 48
Joined: Mon Apr 28, 2003 10:02 am
Location: UK
Contact:

Post by hypervox »

In days of old, when knights were bold etc.., microsoft had it's own brand of networking known as "workgroups", which uses the netbeui protocol (from 3.11 i believe). This protocol is non-routable, and relies on broadcasts to work. It's so fundamental to how windows networks that it's often enabled by default. The messages you are seeing are sent on this protocol, and are picked up the messenger service (or it's equivilent if you're on a old version of windows).

it's only problem is the fact that is does broadcast! On a NT network, you may see messages from servers who broadcast administrative messages to everybody, so it's not very secure.
PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 :D
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000 :)
Registered Purebasic User :D

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Don't undestand the thing :oops:, but it works :D !
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

have anyone tested these snippet on older machines (Win95, Win98 or WinME ) ?
thx for you interrest.
SPAMINATOR NR.1
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Win98se - says message written but no pop-up.
hypervox
User
User
Posts: 48
Joined: Mon Apr 28, 2003 10:02 am
Location: UK
Contact:

Post by hypervox »

I think on older machines, you need to run "winpopup" to see the messages (NT/Win2000/XP have it built in)
PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 :D
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000 :)
Registered Purebasic User :D

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Yep, winpopup gets the message.

PS: Whadaya mean "older machines"!? My PIII-600MHz Win98se is state-of-the-art :wink:
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

dmoc wrote:Yep, winpopup gets the message.

PS: Whadaya mean "older machines"!? My PIII-600MHz Win98se is state-of-the-art :wink:
nop :twisted:
SPAMINATOR NR.1
hypervox
User
User
Posts: 48
Joined: Mon Apr 28, 2003 10:02 am
Location: UK
Contact:

Post by hypervox »

Sorry - for older machines read "older O/S".
PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 :D
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000 :)
Registered Purebasic User :D

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
LJ
Enthusiast
Enthusiast
Posts: 177
Joined: Wed Apr 30, 2003 4:00 pm

Windows XP

Post by LJ »

Rings:
I'm running two machines on Windows XP.

Hypervox:
So this is the same technology that a company called MessageHammer was using to spam millions by. As soon as I got the company shutdown, they opened up another web site and started over again. Basically they broadcast a message saying that this form of advertising was coming and if you want to stop it from happening, you must go and purchase their product for $10. Sleezy and cheezy. They targeted entire ISP blocks. Anyways, as soon as I put up my firewall, it blocked these pop ups.
hypervox
User
User
Posts: 48
Joined: Mon Apr 28, 2003 10:02 am
Location: UK
Contact:

Post by hypervox »

Yup. The problem is that all of the NT based versions of windows have the ports that use this messenger service OPEN BY DEFAULT. The only safe way to stop the messages (as you've discovered) is to block them using a firewall. You can (if you want) disable the messenger service itself, but it's a poor fix. On the older windows O/S's, you just didn't run WinPopUp :wink:
PC 1:AMD Athlon XP 2000,Geforce 2 MX400 64Mb, Windows 2000 :D
PC 2:Intel P3 1ghz, Nvidia Vanta 16Gb, Windows 2000 :)
Registered Purebasic User :D

PureBasic Game Creation Site
http://www.hypervox.co.uk/PureBasic/
Post Reply