mIRC Home    About    Download    Register    News    Help

Topic Options
#265071 - 24/02/19 03:48 PM $dll() filename vs filename.dll
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1149
$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.

Top
#265074 - 24/02/19 06:37 PM Re: $dll() filename vs filename.dll [Re: maroon]
Khaled Offline


Planetary brain

Registered: 04/12/02
Posts: 4445
Loc: London, UK
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.

Top
#265075 - 24/02/19 10:56 PM Re: $dll() filename vs filename.dll [Re: Khaled]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3509
Loc: France
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

Top
#265076 - 25/02/19 01:20 AM Re: $dll() filename vs filename.dll [Re: Wims]
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2597
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!

Top
#265079 - 25/02/19 03:55 PM Re: $dll() filename vs filename.dll [Re: Raccoon]
Protopia Offline
Fjord artisan

Registered: 30/08/03
Posts: 226
Loc: UK
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.


Edited by Protopia (25/02/19 03:59 PM)

Top