mIRC Homepage
Posted By: Qb_Master Blue Screen of Death, when I use my script - 17/03/06 09:37 PM
I'm in the process of writing an ftp server in mIRC Script (mainly out of boredom lol), and everything seemed to be running well. I have an XP machine that I'm running it from, and another computer that I have networked to the XP machine.

It seems that when I just do a loopback connection (, the server works great. I try it from the other computer, and it still works great to a point...this is where the strange part comes in. When the other computer does a LIST command, my computer starts sending the shared folder and filenames. In the middle of sending the filenames, my XP machine recieves the following Blue Screen of Death (STOP screen):

A problem has been detected and Windows has been shut down to prevent damage to your computer.


If this is the first time you've seen this Stop error screen, restart your computer. If this screen appears again, follow these steps:

Check to make sure any new hardware or software is properly installed. If this is a new installation, ask your hardware or software manufacturer for any Windows updates you might need.

If problems continue, disable or remove any newly installed hardware or software. Disable BIOS memory options such as caching or shadowing. If you need to use Safe Mode to remove r disable components, restart your computer, press F8 to select Advances Startup Options, and then select Safe Mode.

Technical information:

*** STOP: 0x000000D1 (0x00000010, 0x00000002, 0x00000000, 0xB9C098CD)
*** rtl8180.SYS - Address B9C098CD base at B9BF9000, Datestamp 3ecb351a

Beginning dump of physical memory
Physical memory dump complete.
Contact your system administrator or technical support group for further assistance.

The code I currently have is (note it isn't complete yet!):
alias ftpnew {
window -l15 @ftpmon
window @ftpd
socklisten ftp $1-
on 1:socklisten:ftp:{
var %ranum = ftpa $+ $rand(10000,99999)
if ($exists($mircdir $+ ftp) == $false) { mkdir $mircdir $+ ftp }
write ftp\connect.txt %ranum $sock(%ranum).ip
sockaccept %ranum
write ftp\log.txt «< $+ $date - $time $+ >» Connection from $sock(%ranum).ip accepted
echo -ti2 @ftpmon 9«<7 $+ $date 9 $+ -7 $time $+ 9>» Connection from $sock(%ranum).ip accepted
iline -l @ftpmon 1 $sock(%ranum).ip
cline -l4 @ftpmon 1
sockwrite %ranum 220 Welcome to Qb's FTP Server. $+ $crlf
on 1:sockread:ftpa*:{
sockread %ftpd
echo -ti2 @ftpd 10 $+ << %ftpd
write ftp\logall.txt << %ftpd
var %ranum = $sockname
var %rapla = $remove(%ranum, ftpa)
if ($gettok(%ftpd, 1, 32) == USER) {
sockwrite $sockname 331 Username set to $gettok(%ftpd, 2, 32). Now enter your password. $+ $crlf
; writeini ftp\data.ini userlogin %ranum $gettok(%ftpd, 2, 32)
; writeini ftp\data.ini userlogin %ranum $+ logon 1
if ($gettok(%ftpd, 1, 32) == PASS) {
if ($gettok(%ftpd, 2, 32) == anonymous) {
;-motd here-;
var %ln = $calc($lines(ftp\motd.txt) - 1)
var %ln2 = 0
while (%ln2 <= %ln) {
inc %ln2 1
sockwrite %ranum 230 $read(ftp\motd.txt, %ln2) $+ $crlf
if ($gettok(%ftpd, 2, 32) != anonymous) {
sockwrite %ranum 530 Login incorrect. Please try again. $+ $crlf
dline @ftpmon $fline(@ftpmon, $sock(%ranum).ip, 1, 1)
sockclose %ranum
if ($gettok(%ftpd, 1, 32) == QUIT) {
sockwrite %ranum 221 Bye Bye, Thanks for using the test server! $+ $crlf
dline -l @ftpmon $fline(@ftpmon, $sock(%ranum).ip, 1, 1)
sockclose %ranum
if ($gettok(%ftpd, 1, 32) == PASV) {
;//echo -s $calc($rand(1,255) * 256 + $rand(1, 255))
var %ro = $rand(1,255)
var %rt = $rand(1, 255)
var %rport = $calc(%ro * 256 + %rt)
socklisten ftpb $+ %rapla %rport
sockwrite %ranum 227 Entering Passive Mode $+ $chr(40) $+ 192,168,2,4, $+ %ro $+ , $+ %rt $+ $chr(41) $+ $crlf
if ($gettok(%ftpd, 1, 32) == SYST) {
sockwrite %ranum 215 UNIX Type: L8 $+ $crlf
if ($gettok(%ftpd, 1, 32) == PORT) {
tokenize 44 $remove(%ftpd, PORT)
sockopen ftpb $+ %rapla $1 $+ . $+ $2 $+ . $+ $3 $+ . $+ $4 $calc($5 * 256 + $6)
sockwrite %ranum 200 Port command successful. $+ $crlf
if ($gettok(%ftpd, 1, 32) == LIST) {
sockwrite %ranum 150 Opening data connection for directory list. $+ $crlf
; sendshares
var %temp = $finddir($read(ftp\share.txt, 1), *, *, 1, sockwrite ftpb $+ %rapla $lastdir($1-) $+ $crlf )
;----WARNING: $nopath HAS BEEN CAUSING A Blue Screen Of Death!!!!----;
var %temp2 = $findfile($read(ftp\share.txt, 1), *, *, 1, sockwrite ftpb $+ %rapla $lastfile($1-) $+ $crlf )
; sockwrite ftpb $+ %rapla Down for the momento $+ $crlf
; sockwrite ftpb $+ %rapla Down for the momento $+ $crlf
var %raplip = $sock(ftpb $+ %rapla).ip
var %raplpo = $sock(ftpb $+ %rapla).port
sockclose ftpb $+ %rapla
; sockopen ftpb $+ %rapla %raplip %raplpo
sockwrite %ranum 226 Transfer ok $+ $crlf

alias lastdir {
var %gt = $numtok($1-, 92)
return $chr(92) $+ $gettok($1-, %gt, 92)
alias lastfile {
var %gt = $numtok($1-, 92)
return $gettok($1-, %gt, 92)

on 1:sockopen:ftpb*:{
var %ranum = $sockname
var %rapla = $remove(%ranum, ftpb)
; sockwrite ftpa $+ %rapla 150 Data connection accepted from $sock($sockname).ip $+ $chr(59) transfer starting. $+ $crlf
on 1:sockread:ftpb*:{
sockread %ajw
write ftp\logall.txt ftpb: %ajw
The line that is causing problems is the var %temp2 = $findfile($read(ftp\share.txt, 1), *, *, 1, sockwrite ftpb $+ %rapla $lastfile($1-) $+ $crlf ). This works PERFECTLY fine if I don't have any kind of identifier in front of the $1-. If I have any identifier in front of it, however, it sends me the BSOD. This current code only sends me the BSOD if I request a LIST several times quickly, the last one, which was just a $nopath, would just crash my computer every time (that's why I made the $lastfile identifier).

If I send it as just $1-, like I mentioned, it works fine every time. Obviously, though, I only want to send the filename from there, and not the whole folder.

If anybody has any ideas why this code would be crashing my system with that blue screen of death, please post.
Posted By: DaveC Re: Blue Screen of Death, when I use my script - 17/03/06 10:01 PM
Check to make sure any new hardware or software is properly installed. If this is a new installation, ask your hardware or software manufacturer for any Windows updates you might need.

*** rtl8180.SYS - Address B9C098CD base at B9BF9000, Datestamp 3ecb351a

I would have just said "You have a faulty/bugged driver file for the RTL8180.SYS (i think thats a network card, but dont really know)"

However you seem to have done some checking, and it only occurs when u use an identifier as u said.

So speculating here, It sounds like it might be a buffer overrun in mirc, something that mirc checks for after each command, however becuase the /var %temp2 = $findfile is one command if you use internal identifiers, that buffer just floods up and overruns. How about u try using $nopath2( ) (see below) this maybe all thats needed, so mirc reaches out to a custom identifier, thus also tripping the safe guards to stop buffer overruns.
alias nopath2 { return $nopath($1-) }

I base this speculation on that it works if u do only one (buffer doenst over run), and that if u use custom identifiers it doesnt do it as well. likely doesnt fail becuase despooling time is instant as its the same pc.
First of all, thanks for not just leaving it at the driver laugh I had already checked into that as it was my first suspicion as well, and had tried finding an updated version of it. I believe that it has to do with my wireless networking card. Anyways while it still may be part of the problem, I don't think the error is entirely based on that. (I was a bit worried that when I posted, that's what everybody was going to say).

I tried your $nopath2, and it still crashed frown. My next path I guess, is to maybe try slowing down the rate that it sends the data over the socket using timers. I think it may be a problem with the findfile, like you said, that maybe it isn't checked for buffer overflows. If that's the case, well I'll just have to write around it wink

By the way, one of the other things I suspected when I was first testing the problem, was the operating systems of the machines: The one that wasn't an XP machine is basically my test box - when I was working with that the first time, I had Debian Linux installed on it. I tried this time though with Windows 2000 on it, and the problem still persisted, so I've outruled remote-OS's (thinking maybe the linux drivers read data slightly differently) being the problem. I forgot to mention this in the earlier post.

thanks for your quick response and help, if you have any other ideas please go ahead and post them. I'll be happy to come across any possible solutions!
Posted By: DaveC Re: Blue Screen of Death, when I use my script - 18/03/06 12:13 AM
Maybe its becuase your in the find file, cant think why using one custome alias would be ok while another is not, unless its actually a problem in $nopath?????

Try this as a test

var %temp2 = $findfile($read(ftp\share.txt, 1), *, *, 1, sockwrite ftpb $+ %rapla $lastfile($1-) $+ $crlf )

window -c @temp.win | window -h @temp.win
var %temp2 = $findfile($read(ftp\share.txt, 1), *, *, 1, @temp.win)
while ($line(@temp.win,1)) { sockwrite ftpb $+ %rapla $nopath($v1) $+ $crlf | dline @temp.win 1 }
window -c @temp.win

Simply storing the findfile results, then flushing them to the sockwrite, if this causes the problem to disapear, it could well be that doing sockwrites inside the $findfile is problamatic.

If this also fails I would suggest, creating a text file of exactly what is being sent, and then using another directive "TEST" send the contents of the file, by simply looping through it reading and sockwriting, if this also fails, then it may well be back to looking at the driver, as that would infer any large scale burst to the socket caueses the driver to fail.

* another option is to replace the nic card with another (maybe hardwired) and see if it goes away, in which case it points to drivers as well.

I must say that i have trown some huge loads of data out a socket and its never had a problem, however i dont think if i ever did it from inside a $findfile
I tried to get your script to work, but I couldn't. I wrote this test script instead to see if I could reproducte the problem.

on *:SockListen:Test: {
  sockaccept t2
  var %temp = $finddir(f:\, *, *, 1, sockwrite t2 $nopath($1-) $+ $crlf )
  var %temp2 = $findfile(f:\, *, *, 1, sockwrite t2 $nopath($1-) $+ $crlf )
  sockclose t2

It worked as expected, so Im thinking its go something to do with your network card drivers.
Posted By: DaveC Re: Blue Screen of Death, when I use my script - 18/03/06 09:00 AM
I must admit i wrote that short part in the thread reply editor so might haqve a fault in it. As i have said, i have thrown bulk stuff out never having a problem, i guess it might be a unchecked boundry in the driver, when mirc passes alot of data at one time.
Posted By: Ook Re: Blue Screen of Death, when I use my script - 18/03/06 06:54 PM
This is a drivers problem that I've had myself with some network cards, the problem is solved by making sure the network card has its own IRQ thats not shared with anything else.
The documentation usually mentions this.
© mIRC Discussion Forums