Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Though it sounds simple, like most stuff in Win32 in practice it's not trivial. In particular this whole chunk of the codebase feels really, really old...and it's a royal pain to manipulate it. Aggravating this is the fact that there are multiple icon sizes per file, as well as multiple icons per size per file.</p> <p>Here's some old code which does a lot of what you need (but not all). This should get you well on your way by cracking EXEs and getting you at the icons themselves:</p> <p>Some setup:</p> <pre><code>static const int _MAX_ICONS = 2; typedef struct INTERNAL_ICON_INFO { HICON hIcon; int nSize; } INTERNAL_ICON_INFO; typedef struct TAG_ICON_BUNDLE_DETAILS { int nLargeIcons; INTERNAL_ICON_INFO aiiLargeIcons[_MAX_ICONS]; int nSmallIcons; INTERNAL_ICON_INFO aiiSmallIcons[_MAX_ICONS]; } ICON_BUNDLE_DETAILS; </code></pre> <p>The icon extraction code:</p> <pre><code>HINSTANCE hTargetModule = LoadLibrary((LPCTSTR)stTargetFile); if (NULL != hTargetModule) { int nIconCount = ExtractIconEx((LPCTSTR)stTargetFile, -1, NULL, NULL, 0); // get total icon count ICON_BUNDLE_DETAILS* priiArray = new ICON_BUNDLE_DETAILS[nIconCount]; int nExtracted = 0; for (int i = 0; i &lt; nIconCount; i++) { HICON* phiLargeIcons = new HICON[nIconCount]; HICON* phiSmallIcons = new HICON[nIconCount]; nExtracted = ExtractIconEx((LPCTSTR)stTargetFile, i, phiLargeIcons, phiSmallIcons, _MAX_ICONS); for (int j = 0; j &lt; nExtracted; j++) { ICONINFO ii; GetIconInfo(phiLargeIcons[j], &amp;ii); priiArray[i].nLargeIcons = nExtracted; priiArray[i].aiiLargeIcons[j].hIcon = phiLargeIcons[j]; priiArray[i].aiiLargeIcons[j].nSize = sizeof(ICONINFO); } for (j = 0; j &lt; nExtracted; j++) { priiArray[i].nSmallIcons = nExtracted; priiArray[i].aiiSmallIcons[j].hIcon = phiSmallIcons[j]; priiArray[i].aiiSmallIcons[j].nSize = sizeof(ICONINFO); } } if (nExtracted &gt; 0) { // process extracted icons } } </code></pre> <p>In short, this code opens up a target file, counts how many icons are therein, then grabs info regarding each instance of each ICONINFO. That's the struct I think you care about, as it contains the bitmaps themselves.</p> <p>Going from ICONINFO to new .ico file was not what we needed to do, so I can't help with that part...but how hard could it be? ;-)</p> <p>Good luck!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload