Using an icon from Windows DLL in autorun.inf

4

1

I want to set an icon for my removable drive as an icon from a built-in Windows DLL using autorun.inf. Since Wikipedia's page on Autorun.inf shows that an icon can be taken from a DLL and used with an index, I would think the following would work (#54 of imageres.dll is the full recycling bin icon):

[autorun]
label=USB Drive
icon=%WINDIR%\System32\imageres.dll,54

But it does not. The icon shows up as the default "icon not found" icon when I remove and plug the device in again. Even if I use the absolute path for my system C:\Windows\System32\imageres.dll,54, it doesn't work. Can this be done at all, and if so, how?

Sam McCreery

Posted 2016-01-27T23:15:26.517

Reputation: 143

Answers

2

I was completely wrong, you can use %WINDIR% I tried regenerating the issue and I was able to us windir and dll file index. the icon you're trying to use did not show for some reason. but I was able to use icons from shell32.dll, I tried multiple indexes and it seems to work.

enter image description here

I think the problem have to do with the icon it self or something with windows. I can confirm that you're inf file have the correct structure.

try using another icon and see what happens, Windows Icons: Full list with details, locations & images

Maher Fattouh

Posted 2016-01-27T23:15:26.517

Reputation: 649

"Even if I use the absolute path for my system C:\Windows\System32\imageres.dll,54, it doesn't work." – Sam McCreery – 2016-01-28T08:25:03.913

I apologize, I had my facts mixed and presented an untrue information. I updated my answer. – Maher Fattouh – 2016-01-28T14:12:59.583

That's interesting. shell32.dll works for me also, whereas imageres.dll does not. Weird, but luckily the icon I want is present in both. – Sam McCreery – 2016-01-28T16:14:29.627

5

Try to extract the .ico using "Resource Hacker", put the .ico onto the drive and use the icon= in autorun.inf to point to that instead.

Using Resource Hacker should be straightforward enough to do this!

Resource Hacker

sinni800

Posted 2016-01-27T23:15:26.517

Reputation: 3 048

Or this utility to extract images...http://www.nirsoft.net/utils/resources_extract.html

– Moab – 2016-01-27T23:31:33.107

The idea is that the icon corresponds to the operating system's default icon set, since icons in system DLLs change between versions. – Sam McCreery – 2016-01-27T23:32:20.263

@SamM It makes sense. I don't have a source on this but it might be a "security feature" that it's not allowed to point to system files in autorun.inf files. Things have been owned with autorun.inf in the past. EDIT: Actually people have used icons from System32 with success so I don't know what to say as to why it doesn't work for you. – sinni800 – 2016-01-27T23:35:43.717

@Moab Well that extracts everything like a big vacuum, though. – sinni800 – 2016-01-27T23:36:25.500

@sinni800 do you have a link for the successful attempts at using System32 icons? – Sam McCreery – 2016-01-27T23:43:35.547

@sinni800 you can choose what to extract. – Moab – 2016-01-28T15:42:32.807

@SamM http://superuser.com/questions/1032272/using-an-icon-from-windows-dll-in-autorun-inf/1032333 Actually right here

– sinni800 – 2016-01-28T18:54:54.407