mIRC Home    About    Download    Register    News    Help

Print Thread
$dll() filename vs filename.dll #265071 24/02/19 03:48 PM
Joined: Jan 2004
Posts: 1,173
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,173
$dll(filename.dll|$remove(filename.dll,.dll),function,data)

Loading a .dll with+without the .dll extension causes 2 references to same file to be loaded to the $dll(N) list, but memory data can be accessed from only 1 of them. Some of this issue can't be seen without creating a dll which has 1 function to stores a value into its own memory, then has another function to report that value.

When $dll(foobar,function,data) makes a dll call, if $1 does not contain .filetype, mIRC ignores the presence of filename "foobar" without a file extension and loads "foobar.dll".

If foobar.dll is called as both "foobar" and "foobar.dll", it gets loaded into the $dll(N) list twice, once under each load-name. However it's not possible to access/alter memory data of both instances. Regardless whether you use $dll(foobar,function,data) or $dll(foobar.dll,function,data), the same memory data is accessed, always reporting the last value stored into the dll memory, regardless which loaded-name is used to store it.

Assuming these are the only 2 .dll's loaded, you can only unload each instance by using the with/without filename shown in the $dll(1) or $dll(2) strings. No matter whether "foobar" or "foobar.dll" is unloaded from the $dll(N) list, the memory data accessed before the /dll -u is the same as the memory accessed after the unload.

After unloading 1 of the 2 references to the same dll diskfile, accessing the dll using the name-alias which had been unloaded from memory reloads that 2nd reference to the same diskfile, but returns data changed inside the dll prior to that 2nd reference-name being reloaded.

The auto-unload after 10 mins idle can cause the references-name called most recently to be unload from the $dll(N) later than the opposite reference name, but it doesn't seem possible to ever access the memory data of the 2nd reference to that same diskfile.

Re: $dll() filename vs filename.dll [Re: maroon] #265074 24/02/19 06:37 PM
Joined: Dec 2002
Posts: 4,519
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,519
Thanks for your bug report. As with your previous post, this is how this feature has worked for at least a decade. Ideally, $dll() would simply return an error if the ".dll" extension is not used, however this is not how it was implemented in 1999 and changing this now could break existing scripts.

Re: $dll() filename vs filename.dll [Re: Khaled] #265075 24/02/19 10:56 PM
Joined: Jul 2006
Posts: 3,555
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,555
Hello,

I believe there is a security concern, if you have both "test" and "test.dll" in a folder, a call to $dll(test,procname,) will call test.dll, so even when the file parameter corresponds exactly to a filename in the folder, it's not used.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $dll() filename vs filename.dll [Re: Wims] #265076 25/02/19 01:20 AM
Joined: Feb 2003
Posts: 2,641
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,641
I think it'd be a greater security risk otherwise. Scripts that may reference a common library by name only, excluding ".dll" may be vulnerable to a false dll dropping into higher priority spot, causing it to be loaded instead, and might not be scanned by a virus scanner given the lack of extension.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Re: $dll() filename vs filename.dll [Re: Raccoon] #265079 25/02/19 03:55 PM
Joined: Aug 2003
Posts: 236
P
Protopia Offline
Fjord artisan
Offline
Fjord artisan
P
Joined: Aug 2003
Posts: 236
IMO, "filename" vs "filename.dll" should be considered equivalent.

So if you load "filename" and then "filename.dll" or vice versa, the second load should be ignored.

Note: This does not address the dll hijacking security risk identified by Raccoon. The alternative would be to raise an error if you try to load the same DLL twice, once without and once with DLL.

Last edited by Protopia; 25/02/19 03:59 PM.