35 |
35 |
36 @param aCmdPtr - pointer to an processed CmdLineHandler object |
36 @param aCmdPtr - pointer to an processed CmdLineHandler object |
37 @param aImageReaderList - List of ImageReader insatance pointers |
37 @param aImageReaderList - List of ImageReader insatance pointers |
38 */ |
38 */ |
39 SidChecker::SidChecker(CmdLineHandler* aCmdPtr, ImageReaderPtrList& aImageReaderList) |
39 SidChecker::SidChecker(CmdLineHandler* aCmdPtr, ImageReaderPtrList& aImageReaderList) |
40 :Checker(aCmdPtr, aImageReaderList) |
40 :Checker(aCmdPtr, aImageReaderList) { |
41 { |
|
42 iSidAll = (iCmdLine->ReportFlag() & KSidAll) ? true : false; |
41 iSidAll = (iCmdLine->ReportFlag() & KSidAll) ? true : false; |
43 iE32Mode = (iCmdLine->ReportFlag() & KE32Input) ? true : false; |
42 iE32Mode = (iCmdLine->ReportFlag() & KE32Input) ? true : false; |
44 } |
43 } |
45 |
44 |
46 /** |
45 /** |
47 Destructor |
46 Destructor |
48 |
47 |
49 @internalComponent |
48 @internalComponent |
50 @released |
49 @released |
51 */ |
50 */ |
52 SidChecker::~SidChecker() |
51 SidChecker::~SidChecker() { |
53 { |
|
54 iSidVsExeMap.clear(); |
52 iSidVsExeMap.clear(); |
55 } |
53 } |
56 |
54 |
57 /** |
55 /** |
58 Function responsible to Prepare the ROM and ROFS image SID data |
56 Function responsible to Prepare the ROM and ROFS image SID data |
60 @internalComponent |
58 @internalComponent |
61 @released |
59 @released |
62 |
60 |
63 @param ImgVsExeStatus - Global integrated container which contains image, exes and attribute value status. |
61 @param ImgVsExeStatus - Global integrated container which contains image, exes and attribute value status. |
64 */ |
62 */ |
65 void SidChecker::Check(ImgVsExeStatus& aImgVsExeStatus) |
63 void SidChecker::Check(ImgVsExeStatus& aImgVsExeStatus) { |
66 { |
64 |
67 ImageReaderPtrList::iterator begin = iImageReaderList.begin(); |
65 int readerCount = iImageReaderList.size(); |
68 ImageReaderPtrList::iterator end = iImageReaderList.end(); |
66 for(int i = 0 ; i < readerCount ; i++) { |
69 |
67 ImageReader* imageReader = iImageReaderList.at(i); |
70 ExeVsIdDataMap::iterator exeBegin; |
68 const char* imageName = imageReader->ImageName(); |
71 ExeVsIdDataMap::iterator exeEnd; |
69 ExceptionReporter(GATHERINGIDDATA, KSid,imageName).Log(); |
72 ExeVsIdDataMap exeVsIdDataMap; |
|
73 ImageReader* imageReader = KNull; |
|
74 String imageName; |
|
75 while(begin != end) |
|
76 { |
|
77 imageReader = *begin; |
|
78 imageName = imageReader->ImageName(); |
|
79 ExceptionReporter(GATHERINGIDDATA, (char*)KSid.c_str(),(char*)imageName.c_str()).Log(); |
|
80 imageReader->PrepareExeVsIdMap(); |
70 imageReader->PrepareExeVsIdMap(); |
81 |
71 |
82 exeVsIdDataMap = imageReader->GetExeVsIdMap(); |
72 ExeVsIdDataMap& exeVsIdDataMap = const_cast<ExeVsIdDataMap&>(imageReader->GetExeVsIdMap()); |
83 exeBegin = exeVsIdDataMap.begin(); |
73 ImgVsExeStatus::iterator pos = aImgVsExeStatus.find(imageName); |
84 exeEnd = exeVsIdDataMap.end(); |
74 ExeVsMetaData* p = 0; |
85 if((aImgVsExeStatus[imageName].size() == 0) |
75 if(pos == aImgVsExeStatus.end()){ |
86 || (aImgVsExeStatus[imageName][exeBegin->first].iIdData == KNull)) |
76 p = new ExeVsMetaData(); |
87 { |
77 put_item_to_map(aImgVsExeStatus,imageName,p); |
88 while(exeBegin != exeEnd) |
78 } |
89 { |
79 else |
90 if(!iSidAll) |
80 p = pos->second ; |
91 { |
81 |
92 if(ReaderUtil::IsExe(&exeBegin->second->iUid)) |
82 for(ExeVsIdDataMap::iterator it = exeVsIdDataMap.begin() |
93 { |
83 ;it != exeVsIdDataMap.end(); it++) { |
94 iSidVsExeMap.insert(std::make_pair(exeBegin->second->iSid, exeBegin->first)); |
84 ExeVsMetaData::iterator i = p->find(it->first); |
|
85 if(i == p->end()){ |
|
86 ExeContainer container; |
|
87 container.iExeName = it->first; |
|
88 container.iIdData = KNull ; |
|
89 i = put_item_to_map(*p,it->first,container); |
|
90 } |
|
91 if(i->second.iIdData == KNull){ |
|
92 if(!iSidAll) { |
|
93 if(ReaderUtil::IsExe(&it->second->iUid)) { |
|
94 iSidVsExeMap.insert( |
|
95 pair<unsigned long, string>(it->second->iSid, it->first) |
|
96 ); |
95 } |
97 } |
96 } |
98 } |
97 else |
99 else { |
98 { |
100 iSidVsExeMap.insert( |
99 iSidVsExeMap.insert(std::make_pair(exeBegin->second->iSid, exeBegin->first)); |
101 pair<unsigned long, string>(it->second->iSid, it->first) |
|
102 ); |
100 } |
103 } |
101 aImgVsExeStatus[imageName][exeBegin->first].iIdData = exeBegin->second; |
104 i->second.iIdData = it->second; |
102 aImgVsExeStatus[imageName][exeBegin->first].iExeName = exeBegin->first; |
105 i->second.iExeName = it->first; |
103 ++exeBegin; |
|
104 } |
106 } |
105 } |
107 } |
106 ++begin; |
|
107 } |
108 } |
108 } |
109 } |
109 |
110 |
110 /** |
111 /** |
111 Function responsible to Validate and write the SID data into reporter. |
112 Function responsible to Validate and write the SID data into reporter. |
113 @internalComponent |
114 @internalComponent |
114 @released |
115 @released |
115 |
116 |
116 @param aExeContainer - Global integrated container which contains all the attribute, values and the status. |
117 @param aExeContainer - Global integrated container which contains all the attribute, values and the status. |
117 */ |
118 */ |
118 void SidChecker::PrepareAndWriteData(ExeContainer* aExeContainer) |
119 void SidChecker::PrepareAndWriteData(ExeContainer& aExeContainer) { |
119 { |
120 if(!iSidAll) { |
120 if(!iSidAll) |
|
121 { |
|
122 /**This map is used to find the uniqueness of the SID, instead of traversing through |
121 /**This map is used to find the uniqueness of the SID, instead of traversing through |
123 the iImgVsExeStatus again and again to get all Executables SID*/ |
122 the iImgVsExeStatus again and again to get all Executables SID*/ |
124 if(ReaderUtil::IsExe(&aExeContainer->iIdData->iUid)) |
123 if(ReaderUtil::IsExe(&aExeContainer.iIdData->iUid)) { |
125 { |
|
126 FillExeAttribute(aExeContainer); |
124 FillExeAttribute(aExeContainer); |
127 } |
125 } |
128 } |
126 } |
129 else |
127 else { |
130 { |
|
131 FillExeAttribute(aExeContainer); |
128 FillExeAttribute(aExeContainer); |
132 } |
129 } |
133 } |
130 } |
134 |
131 |
135 /** |
132 /** |
142 @internalComponent |
139 @internalComponent |
143 @released |
140 @released |
144 |
141 |
145 @param aExeContainer - Global integrated container which contains all the attribute, values and the status. |
142 @param aExeContainer - Global integrated container which contains all the attribute, values and the status. |
146 */ |
143 */ |
147 void SidChecker::FillExeSidStatus(ExeContainer* aExeContainer) |
144 void SidChecker::FillExeSidStatus(ExeContainer& aExeContainer) { |
148 { |
|
149 SidVsExeMap::iterator sidIter; |
145 SidVsExeMap::iterator sidIter; |
150 unsigned int cnt = iSidVsExeMap.count(aExeContainer->iIdData->iSid); |
146 unsigned int cnt = iSidVsExeMap.count(aExeContainer.iIdData->iSid); |
151 if(cnt > 1) //Is More than one SID exists? |
147 if(cnt > 1) {//Is More than one SID exists? |
152 { |
148 sidIter = iSidVsExeMap.find(aExeContainer.iIdData->iSid); |
153 sidIter = iSidVsExeMap.find(aExeContainer->iIdData->iSid); |
149 while(cnt > 0) { |
154 while(cnt > 0) |
150 if( aExeContainer.iExeName != sidIter->second) { |
155 { |
151 aExeContainer.iIdData->iSidStatus = KDuplicate; |
156 if( aExeContainer->iExeName != sidIter->second) |
152 |
157 { |
153 if(!iE32Mode) { |
158 aExeContainer->iIdData->iSidStatus = KDuplicate; |
154 unsigned int offset = GetExecutableOffset(sidIter->second.c_str()); |
159 |
155 if(aExeContainer.iIdData->iFileOffset == offset) { |
160 if(!iE32Mode) |
156 aExeContainer.iIdData->iSidStatus = KUniqueAlias; |
161 { |
|
162 unsigned int offset = GetExecutableOffset(sidIter->second); |
|
163 if(aExeContainer->iIdData->iFileOffset == offset) |
|
164 { |
|
165 aExeContainer->iIdData->iSidStatus = KUniqueAlias; |
|
166 break; |
157 break; |
167 } |
158 } |
168 } |
159 } |
169 } |
160 } |
170 --cnt; |
161 --cnt; |
171 ++sidIter; |
162 ++sidIter; |
172 } |
163 } |
173 } |
164 } |
174 else |
165 else { |
175 { |
166 aExeContainer.iIdData->iSidStatus = KUnique; |
176 aExeContainer->iIdData->iSidStatus = KUnique; |
|
177 } |
167 } |
178 } |
168 } |
179 |
169 |
180 /** |
170 /** |
181 Function to get an executable's Offset location. |
171 Function to get an executable's Offset location. |
186 @released |
176 @released |
187 |
177 |
188 @param aExeName - Executable's name. |
178 @param aExeName - Executable's name. |
189 |
179 |
190 @return - returns 0 upon failure to find the Executable. |
180 @return - returns 0 upon failure to find the Executable. |
191 - otherwise returns the Offset. |
181 - otherwise returns the Offset. |
192 */ |
182 */ |
193 const unsigned int SidChecker::GetExecutableOffset(const String& aExeName) |
183 const unsigned int SidChecker::GetExecutableOffset(const char* aExeName) { |
194 { |
|
195 Reporter* reporter = Reporter::Instance(iCmdLine->ReportFlag()); |
184 Reporter* reporter = Reporter::Instance(iCmdLine->ReportFlag()); |
196 ImgVsExeStatus& aImgVsExeStatus = reporter->GetContainerReference(); |
185 ImgVsExeStatus& aImgVsExeStatus = reporter->GetContainerReference(); |
197 |
186 |
198 ImgVsExeStatus::iterator imgBegin = aImgVsExeStatus.begin(); |
187 for(ImgVsExeStatus::iterator it = aImgVsExeStatus.begin(); |
199 ImgVsExeStatus::iterator imgEnd = aImgVsExeStatus.end(); |
188 it != aImgVsExeStatus.end() ; it++) { |
200 |
189 ExeVsMetaData* exeVsMetaData = it->second; |
201 ExeVsMetaData::iterator exeBegin; |
190 for(ExeVsMetaData::iterator i = exeVsMetaData->begin(); |
202 ExeVsMetaData::iterator exeEnd; |
191 i != exeVsMetaData->end() ; i++) { |
203 |
192 if(i->second.iExeName == aExeName ) { |
204 while(imgBegin != imgEnd) |
193 return (i->second).iIdData->iFileOffset; |
205 { |
194 } |
206 ExeVsMetaData& exeVsMetaData = imgBegin->second; |
195 } |
207 exeBegin = exeVsMetaData.begin(); |
|
208 exeEnd = exeVsMetaData.end(); |
|
209 |
|
210 while(exeBegin != exeEnd) |
|
211 { |
|
212 if(aExeName == (exeBegin->second).iExeName) |
|
213 { |
|
214 return (exeBegin->second).iIdData->iFileOffset; |
|
215 } |
|
216 ++exeBegin; |
|
217 } |
|
218 ++imgBegin; |
|
219 } |
196 } |
220 return 0; |
197 return 0; |
221 } |
198 } |
222 |
199 |
223 /** |
200 /** |
226 @internalComponent |
203 @internalComponent |
227 @released |
204 @released |
228 |
205 |
229 @param aExeContainer - Global integrated container which contains all the attribute, values and the status. |
206 @param aExeContainer - Global integrated container which contains all the attribute, values and the status. |
230 */ |
207 */ |
231 void SidChecker::FillExeAttribute(ExeContainer* aExeContainer) |
208 void SidChecker::FillExeAttribute(ExeContainer& aExeContainer) { |
232 { |
|
233 ExeAttribute* exeAtt = KNull; |
209 ExeAttribute* exeAtt = KNull; |
234 |
210 |
235 exeAtt = new ExeAttribute; |
211 exeAtt = new ExeAttribute; |
236 if(!exeAtt) |
212 if(!exeAtt) { |
237 { |
|
238 throw ExceptionReporter(NOMEMORY, __FILE__, __LINE__); |
213 throw ExceptionReporter(NOMEMORY, __FILE__, __LINE__); |
239 } |
214 } |
240 |
215 |
241 exeAtt->iAttName = KSid; |
216 exeAtt->iAttName = KSid; |
242 exeAtt->iAttValue = Common::IntToString(aExeContainer->iIdData->iSid); |
217 exeAtt->iAttValue = Common::IntToString(aExeContainer.iIdData->iSid); |
243 if(!iNoCheck) |
218 if(!iNoCheck) { |
244 { |
|
245 FillExeSidStatus(aExeContainer); |
219 FillExeSidStatus(aExeContainer); |
246 exeAtt->iAttStatus = aExeContainer->iIdData->iSidStatus; |
220 exeAtt->iAttStatus = aExeContainer.iIdData->iSidStatus; |
247 } |
221 } |
248 else |
222 else { |
249 { |
|
250 exeAtt->iAttStatus = KNull; |
223 exeAtt->iAttStatus = KNull; |
251 } |
224 } |
252 if((iAllExecutables |
225 if((iAllExecutables |
253 || (exeAtt->iAttStatus == KDuplicate)) && !exeAtt->iAttStatus.empty() |
226 || (exeAtt->iAttStatus == KDuplicate)) && !exeAtt->iAttStatus.empty() |
254 || iNoCheck) |
227 || iNoCheck) { |
255 { |
228 aExeContainer.iExeAttList.push_back(exeAtt); |
256 aExeContainer->iExeAttList.push_back(exeAtt); |
229 } |
257 } |
230 } |
258 } |
|