mIRC Homepage
Posted By: maroon $dll() filename vs filename.dll - 24/02/19 03:48 PM
$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.
Posted By: Khaled Re: $dll() filename vs filename.dll - 24/02/19 06:37 PM
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.
Posted By: Wims Re: $dll() filename vs filename.dll - 24/02/19 10:56 PM
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.
Posted By: Raccoon Re: $dll() filename vs filename.dll - 25/02/19 01:20 AM
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.
Posted By: Protopia Re: $dll() filename vs filename.dll - 25/02/19 03:55 PM
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.
© mIRC Discussion Forums