WetCode

Untitled

Dec 4th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.77 KB | None | 0 0
  1.  
  2. #pragma pack( push )
  3. #pragma pack( 2 )
  4. typedef struct
  5. {
  6.     BYTE   bWidth;               // Width, in pixels, of the image
  7.     BYTE   bHeight;              // Height, in pixels, of the image
  8.     BYTE   bColorCount;          // Number of colors in image (0 if >=8bpp)
  9.     BYTE   bReserved;            // Reserved
  10.     WORD   wPlanes;              // Color Planes
  11.     WORD   wBitCount;            // Bits per pixel
  12.     DWORD   dwBytesInRes;        // how many bytes in this resource?
  13.     WORD   nID;                  // the ID
  14. } GRPICONDIRENTRY, *LPGRPICONDIRENTRY;
  15. #pragma pack( pop )
  16.  
  17. // #pragmas are used here to insure that the structure's
  18. // packing in memory matches the packing of the EXE or DLL.
  19. #pragma pack( push )
  20. #pragma pack( 2 )
  21. typedef struct
  22. {
  23.     WORD            idReserved;     // Reserved (must be 0)
  24.     WORD            idType;         // Resource type (1 for icons)
  25.     WORD            idCount;            // How many images?
  26.     GRPICONDIRENTRY   idEntries[1]; // The entries for each image
  27. } GRPICONDIR, *LPGRPICONDIR;
  28. #pragma pack( pop )
  29.  
  30.    
  31.  
  32.     HMODULE hExe = LoadLibrary("stubpe.exe");
  33.     EnumResourceTypes(hExe, (ENUMRESTYPEPROC)ResTypes, 0);
  34.  
  35.     // Find the group resource which lists its images
  36.                                 /* Need to set "IconGrpName" this from ResTypee */
  37.     HRSRC hRsrc = FindResource( hExe, MAKEINTRESOURCE(1), RT_GROUP_ICON );
  38.     // Load and Lock to get a pointer to a GRPICONDIR
  39.     HGLOBAL hGlobal = LoadResource( hExe, hRsrc );
  40.     GRPICONDIR *lpIconGroup = new GRPICONDIR[ SizeofResource( hExe, hRsrc ) ];
  41.     RtlZeroMemory( lpIconGroup, SizeofResource( hExe, hRsrc ) );
  42.     lpIconGroup = (GRPICONDIR*)LockResource( hGlobal );
  43.     // We now have the header of the icon file now we need all the icons.
  44.    
  45.     cout << "Icon Count: " << lpIconGroup->idCount << endl;
  46.     cout << "Type: " << lpIconGroup->idType  << endl;
Advertisement
Add Comment
Please, Sign In to add comment