[Program] Icon - Extract Icons from DLLEXEICL (Processing of 16 Bit ICL files)

xiaoxiao2021-03-06  18

Always use Axicon Workshop to handle icons, but Axicon Workshop is a bit problematic. It does not support duplicate icons filtering, and it is easy to respond when processing a large amount of icon! ()

To this end, I wrote an icon processing tool that automatically extracts icons in files such as DLL / EXE / ICL, and performs automatic icon automatic filtering, icon scans, etc., which is more difficult to process the ICL file, ICL The file is essentially a 16-bit DLL resource file, but in Windows 2000, it seems that there is no function to do it directly. At least I don't know, I have checked Google, I didn't find relevant information, there is no way, only hills, Checked 16 BIT's exe file structure, combined with some read and write code snippets that can be found on the Internet, and then explore and explore, and finally successfully separate ICON from ICL. The key code is as follows: I hope to help you.

TYPEDEF uint16 handle16; typedef handle16 * lphandle16;

Declare_handle (farProc16);

#pragma pack (push) #pragma Pack (2)

Typedef struct {word offset; Word length; Word ID; handle16 handle; word usage;

typedef struct {WORD type_id; / * Type identifier * / WORD count; / * Number of resources of this type * / FARPROC16 resloader;. / * SetResourceHandler () * / / * * Name info array * /} NE_TYPEINFO;

Typedef struct {word iduthved; // reserved (must be 0) word idtype; // resource type (1 for icons) word idcount; // how Many images? Byte bwidth; // width, in pixels, of the image byte BHEIGHT ; // h = 8bpp) Byte breserved; // reserved (must be 0) Word Word Word; // Color Planes Word Wbit; / / BITS Per Pixel DWORD DWBYTESINRES; // How Many Bytes in this Resource? DWORD DWIMAGEOFFSET; // Where in the file is this image?} Ne_icondirentry, * LPNE_ICONDIRENTRY

// icon catalog TypeDef struct {word idreserved; // reserved (must be 0) Word iDTYPE; // resource type (1 for icons) Word IDCount; // How Many images?} Grpicondir, * lpgrpicondir; // icon type Typedef Struct {byte bwidth; // width, in pixels, of the image byte bheight; // Height, in pixels, of the image byte bcolorcount; // Number of Colors in Image (0 if> = 8bpp) Byte breserved; // Reserved Word Word Wbit; // Bits Per Pixel DWORD DWBYTESINRES; / / HOW MANY BYTES in this resource? Word NID; // the id} GRPNE_ICONDIRENTRY, * LPGRPNE_ICONDIRENTRY

#pragma pack (POP)

#define NE_RT_CURSOR 0x8001 # define NE_RT_BITMAP 0x8002 # define NE_RT_ICON 0x8003 # define NE_RT_MENU 0x8004 # define NE_RT_DIALOG 0x8005 # define NE_RT_STRING 0x8006 # define NE_RT_FONTDIR 0x8007 # define NE_RT_FONT 0x8008 # define NE_RT_ACCELERATOR 0x8009 # define NE_RT_RCDATA 0x800a # define NE_RT_GROUP_CURSOR 0x800c # define NE_RT_GROUP_ICON 0x800e

// ICL icon enumeration HRESULT ICL_ENUMRESOURCENAMES (In Const Handle Hfile, In uint NTYPE, IN NE_ENUM_RES_NAME_PROC PFUNC, IN LPARAM LPARAM) {DWORD dwread = 0;

// read DOS file header region IMAGE_DOS_HEADER oDOSHeader; if (:: ReadFile (hFile, & oDOSHeader, sizeof (IMAGE_DOS_HEADER), & dwRead, NULL)!) {Return :: GetLastError ();} // read the file header region NE IMAGE_OS2_HEADER oNEHeader; :: setfilepointer (Hfile, OdosHeader.e_Lfanew, Null, File_Begin); if (! :: readfile (Hfile, & OneHeader, Sizeof (Image_OS2_HEADER), & DWREAD, NULL) {Return :: getLastError ();}

// read zone RSRC resource table DWORD nPos = oDOSHeader.e_lfanew oNEHeader.ne_rsrctab; :: SetFilePointer (hFile, nPos, NULL, FILE_BEGIN); WORD nSizeShift;! If (:: ReadFile (hFile, & nSizeShift, sizeof (WORD), & dwread, null) {RETURN :: getLastError ();

Ne_TypeInfo OInfo; if (! :: readfile (Hfile, & OInfo, Sizeof (ne_typeinfo), & dwread, null) {return :: getLastError ();

// Enumerate all resources dword nposend = odosheader.e_lfanew oneheader.ne_restab; dword nposName = nposend 4;

NE_NAMEINFO ONAME; uint nindex = 0; while (oinfo.type_id! = 0 && npos 0; ncount--) {if (! :: readfile (hfile, & oname Sizeof (ne_nameinfo), & dwread, null) {return :: getLastError ();} if (oinfo.type_id == ntype) {// Save File Location Dword Nposold = :: setFilePointer (HFile, 0, Null, File_Current) ; // resource name Byte nsize; :: setfilepointer (hfile, nposname, null, file_begin); if (! :: readfile (hfile, hfile) {return :: getLastError (); } IF (nsize> 255) Return E_FAIL;

NposName = SizeOf (byte) nsize;

Achar sname [255 1]; if (! :: readfile (hfile, null) {return :: getLastError ();} if (nsize == 1 && sname [0] == __a ( '@')) nsize = 0; sname [nsize] = ACHR_NULL;

// Resource Group GRPICONDIR oDir; DWORD nPosGroup = oName.offset << nSizeShift; :: SetFilePointer (hFile, nPosGroup, NULL, FILE_BEGIN); if (:: ReadFile (hFile, & oDir, sizeof (GRPICONDIR), & dwRead, NULL)! ) {Return :: getLastError ();

// handle STK_CONVERSIONU; pFunc (hFile, nIndex , STK_A2T (sName), & lParam oDir,); // restore file location :: SetFilePointer (hFile, nPosOld, NULL, FILE_BEGIN);!}} If (:: hFile ReadFile (, & oinfo, SizeOf (Ne_TypeInfo), & dwread, null) {Return :: getLastError ();}} Return S_OK;

转载请注明原文地址:https://www.9cbs.com/read-40066.html

New Post(0)