mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2010
Posts: 5
N
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
N
Joined: Aug 2010
Posts: 5
I wrote a DLL that searches for a word within given file.
Everything works fine when I call it (or any alias that's making the DLL call) by typing //echo $dll(...) or /aliasname. However when the DLL is called from any remote event, eg:

Code:
on *:text:!dll:*: echo -a $dll(...)


mIRC crashes. The same thing happens when I initialize a timer that makes the DLL call:

Code:
on *:text:!dll:*: timer1 1 1 echo -a $dll(...)


This is the part of C++ code that causes a crash (the while loop, to be exact):
Code:
  CHAR buffer[8192];
  HANDLE fin = ::CreateFile(afilename,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
  DWORD dwFilePos = 0;
  DWORD indexin = 0;
  DWORD dwRead = 0;
  ::ReadFile(fin,buffer+indexin,4096,&dwRead,NULL);
  while ( dwRead > 0 )
  {
    dwFilePos = dwFilePos + 4096;
    indexin += dwRead;
    dwRead = 0;
    ::ReadFile(fin,buffer+indexin,4096,&dwRead,NULL);
  }


Any ideas about what's causing the crash and how to get rid of it?
Thanks in advance smile

Joined: Aug 2010
Posts: 5
N
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
N
Joined: Aug 2010
Posts: 5
OK, I solved the problem. smile It was some kind of "buffer overflow" error (though I still have no idea why mIRC was crashing only when the DLL was called "remotely").

If someone find it useful, here's the link: mircfs.dll

The function is called by:
Code:
$dll("mircfs_2.dll",Memory,"path_to_textfile" "some word")

The path and word must be given in quotes.
This function searches a text file in this form:
Code:
word1
word2
word3
...

for a given word (note that first line in the file should be empty), and returns "found", "not found", "file not found" (if there's any error opening the file) or "unknown error". It is based on the code downloaded from this site: http://www.arstdesign.com/articles/fastsearch.html

On my computer, searching for the last from a list of over 2,700,000 words takes ~220ms smile


Link Copied to Clipboard