#include "global.h"
#include "persrc.h"
#include <stdexcept>
#include <list>
#include "utils/f77auto_ptr"
Go to the source code of this file.
Compounds | |
struct | iconinfo |
struct | WriteIconParam |
Typedefs | |
typedef std::list< iconinfo > | TIconInfos |
Functions | |
void | CollectIconInfos (ICFile &file, const PeResourceDirectoryData *data, const PeResourceDirectoryInfo *info, unsigned level, void *param) |
const iconinfo * | findIconInfo (const TIconInfos &infos, unsigned id) |
void | CopyFileToFile (const ICFile &from, ICFile &to, size_t bytes) |
void | WriteIcons (ICFile &file, const PeResourceDirectoryData *data, const PeResourceDirectoryInfo *info, unsigned level, void *param) |
|
Definition at line 43 of file persrc.cpp. Referenced by findIconInfo(). |
|
Definition at line 45 of file persrc.cpp. References _DEBUG_, PeResourceDirectoryData::data, PeResourceDirectoryInfo::highLevel, iconinfo::id, PeResourceId::id, PeResourceId::name, iconinfo::pos, _PE_IMAGE_RESOURCE_DATA_ENTRY::Size, iconinfo::size, and ICFile::Tell(). Referenced by ResourceExtract::ExtractIcons().
00046 { 00047 _DEBUG_(fprintf(stderr,"data %p level %d name %p id %d\n", data, level, info->name, info->id )); 00048 if (data != NULL && level == 3 && info->name == NULL && info->highLevel->id == 3) 00049 { 00050 _DEBUG_(fprintf(stderr,"---data %p level %d name %p id %d\n", data, level, info->name, info->highLevel->id)); 00051 iconinfo iinfo; 00052 iinfo.id = info->id; 00053 iinfo.pos = file.Tell(); 00054 iinfo.size = data->data.Size; 00055 _DEBUG_(fprintf(stderr,"---id %d pos %ld size %d\n", iinfo.id, iinfo.pos, iinfo.size)); 00056 00057 (*reinterpret_cast<TIconInfos*>(param)).push_back(iinfo); 00058 } 00059 } |
|
Definition at line 78 of file persrc.cpp. References f77_min(), ICFile::RawRead(), and ICFile::RawWrite(). Referenced by WriteIcons().
|
|
Definition at line 69 of file persrc.cpp. References TIconInfos. Referenced by WriteIcons().
00070 { 00071 TIconInfos::const_iterator end = infos.end(); 00072 for(TIconInfos::const_iterator i = infos.begin(); i != end; ++i) 00073 if ( (*i).id == id ) 00074 return &(*i); 00075 return NULL; 00076 } |
|
Definition at line 90 of file persrc.cpp. References RESDIR::BytesInRes, CopyFileToFile(), findIconInfo(), freddy77::auto_delete_ptr< _Ty >::get(), PeResourceDirectoryInfo::highLevel, RESDIR::IconCursorId, WriteIconParam::iconInfos, PeResourceId::id, WriteIconParam::n, iconinfo::pos, ICFile::RawRead(), RawRead(), CFile::RawWrite(), RawWrite(), NEWHEADER::ResCount, ICFile::Seek(), and iconinfo::size. Referenced by ResourceExtract::ExtractIcons().
00091 { 00092 static const char zeroes[2] = { 0, 0 }; 00093 if (data != NULL && level == 3 && info->highLevel->id == 14) 00094 { 00095 WriteIconParam *p = reinterpret_cast<WriteIconParam*>(param); 00096 00097 // ok, write this icon 00098 NEWHEADER hdr; 00099 RawRead(file,hdr); 00100 00101 char buffer[128]; 00102 sprintf(buffer,"resico%d.ico",p->n); 00103 ++p->n; 00104 CFile ico(buffer,"wb"); 00105 00106 // save header 00107 RawWrite(ico,hdr); 00108 00109 00110 freddy77::auto_delete_ptr<const iconinfo*> icons(new const iconinfo*[hdr.ResCount]); 00111 int i; 00112 for( i = 0; i < hdr.ResCount; ++i ) 00113 { 00114 RESDIR resico; 00115 // !!! fix pack problem 00116 file.RawRead(&resico,14); 00117 00118 // save icon header 00119 // !!! fix pack problem 00120 ico.RawWrite(&resico,14); 00121 ico.RawWrite(zeroes,2); 00122 00123 // find icon and save it 00124 const iconinfo* info = findIconInfo(p->iconInfos,resico.IconCursorId); 00125 *(icons.get()+i) = info; 00126 if (!info) 00127 throw std::runtime_error("icon not found for icon group"); 00128 if (resico.BytesInRes != info->size) 00129 throw std::runtime_error("icon with wrong size"); 00130 // !!! check icon dimension and colors 00131 } 00132 for( i = 0; i < hdr.ResCount; ++i ) 00133 { 00134 const iconinfo* info = *(icons.get()+i); 00135 file.Seek(info->pos); 00136 CopyFileToFile(file,ico,info->size); 00137 } 00138 } 00139 } |