|
0
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
* This component and the accompanying materials are made available
|
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
|
6 |
* which accompanies this distribution, and is available
|
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
|
8 |
*
|
|
|
9 |
* Initial Contributors:
|
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
|
11 |
*
|
|
|
12 |
* Contributors:
|
|
|
13 |
*
|
|
|
14 |
* Description: Other non-categorized LibraryAnalyser functionality
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
#include "la.hpp"
|
|
|
20 |
|
|
|
21 |
// ----------------------------------------------------------------------------------------------------------
|
|
|
22 |
|
|
|
23 |
void ParseCommandLineParameters(int argc, char* argv[])
|
|
|
24 |
{
|
|
|
25 |
//for (int i=1; i<argc; i++)
|
|
|
26 |
// cerr << argv[i] << endl;
|
|
|
27 |
|
|
|
28 |
// loop through the command line parameters and check their usage
|
|
|
29 |
int i=1;
|
|
|
30 |
while (i<argc)
|
|
|
31 |
{
|
|
|
32 |
if (StringICmp("-?", argv[i])==0 ||
|
|
|
33 |
StringICmp("-h", argv[i])==0 ||
|
|
|
34 |
StringICmp("--help", argv[i])==0)
|
|
|
35 |
{
|
|
|
36 |
ShowCommandLineOptionsAndExit();
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
else if (StringICmp("GCC", argv[i])==0)
|
|
|
40 |
{
|
|
|
41 |
_cl_use_gcc = true;
|
|
|
42 |
_toolchain_name = "GCC";
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
else if (StringICmp("GCCE", argv[i])==0)
|
|
|
46 |
{
|
|
|
47 |
_cl_use_gcce = true;
|
|
|
48 |
_toolchain_name = "GCCE";
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
else if (StringICmp("RVCT", argv[i])==0)
|
|
|
52 |
{
|
|
|
53 |
_cl_use_rvct = true;
|
|
|
54 |
_toolchain_name = "RVCT";
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
else if (StringICmp("--uselibs", argv[i])==0)
|
|
|
58 |
{
|
|
|
59 |
_cl_use_libs = true;
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
else if (StringICmp("--debug", argv[i])==0)
|
|
|
63 |
{
|
|
|
64 |
_cl_print_debug = true;
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
else if (StringICmp("-baselinelibdir", argv[i])==0)
|
|
|
68 |
{
|
|
|
69 |
if (i+1<argc)
|
|
|
70 |
{
|
|
|
71 |
_cl_baselinelibdir = argv[i+1];
|
|
|
72 |
//create a vector from the ';' seperated string
|
|
|
73 |
_lib_dirs_baseline = splitString( _cl_baselinelibdir, ';');
|
|
|
74 |
i++;
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
else if (StringICmp("-currentlibdir", argv[i])==0)
|
|
|
79 |
{
|
|
|
80 |
if (i+1<argc)
|
|
|
81 |
{
|
|
|
82 |
_cl_currentlibdir = argv[i+1];
|
|
|
83 |
//create a vector from the ';' seperated string
|
|
|
84 |
_lib_dirs_current = splitString( _cl_currentlibdir, ';');
|
|
|
85 |
i++;
|
|
|
86 |
}
|
|
|
87 |
}
|
|
|
88 |
else if (StringICmp("-baselinedlldir", argv[i])==0)
|
|
|
89 |
{
|
|
|
90 |
if (i+1<argc)
|
|
|
91 |
{
|
|
|
92 |
_cl_baselinedlldir = argv[i+1];
|
|
|
93 |
i++;
|
|
|
94 |
}
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
else if (StringICmp("-currentdlldir", argv[i])==0)
|
|
|
98 |
{
|
|
|
99 |
if (i+1<argc)
|
|
|
100 |
{
|
|
|
101 |
_cl_currentdlldir = argv[i+1];
|
|
|
102 |
i++;
|
|
|
103 |
}
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
else if (StringICmp("-baselineversion", argv[i])==0)
|
|
|
107 |
{
|
|
|
108 |
if (i+1<argc) { _cl_baselineversion = argv[i+1]; i++; }
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
else if (StringICmp("-currentversion", argv[i])==0)
|
|
|
112 |
{
|
|
|
113 |
if (i+1<argc) { _cl_currentversion = argv[i+1]; i++; }
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
else if (StringICmp("-reportfile", argv[i])==0)
|
|
|
117 |
{
|
|
|
118 |
if (i+1<argc) { _cl_reportfile = argv[i+1]; i++; }
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
else if (StringICmp("-tools", argv[i])==0)
|
|
|
122 |
{
|
|
|
123 |
if (i+1<argc) { _cl_toolsdir = argv[i+1]; i++; }
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
else if (StringICmp("-temp", argv[i])==0)
|
|
|
127 |
{
|
|
|
128 |
if (i+1<argc) { _cl_tempdir = argv[i+1]; i++; }
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
else if (StringICmp("-cfilt", argv[i])==0)
|
|
|
132 |
{
|
|
|
133 |
if (i+1<argc) { _cl_cfiltloc = argv[i+1]; i++; }
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
else if (StringICmp("-set", argv[i])==0)
|
|
|
137 |
{
|
|
|
138 |
if (i+1<argc) { _cl_set = argv[i+1]; i++; }
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
// check if the parameter is illegal
|
|
|
142 |
else
|
|
|
143 |
{
|
|
|
144 |
string param = argv[i];
|
|
|
145 |
|
|
|
146 |
if (!param.empty() && param.at(0) == '-')
|
|
|
147 |
{
|
|
|
148 |
cerr << "ERROR: Illegal argument: " << param << endl;
|
|
|
149 |
cerr << "Type la -? for help" << endl;
|
|
|
150 |
exit(EXIT_INVALID_ARGUMENT);
|
|
|
151 |
}
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
i++;
|
|
|
155 |
}
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
// ----------------------------------------------------------------------------------------------------------
|
|
|
159 |
|
|
|
160 |
void ShowCommandLineOptionsAndExit()
|
|
|
161 |
{
|
|
|
162 |
cout << "LibraryAnalyser v" << LA_VERSION << " - " << LA_DATE << "\n"
|
|
|
163 |
"Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.\n"
|
|
|
164 |
"\n"
|
|
|
165 |
#ifdef WIN32
|
|
|
166 |
"Usage: la GCC|GCCE|RVCT [options]\n"
|
|
|
167 |
#else
|
|
|
168 |
"Usage: la GCCE|RVCT [options]\n"
|
|
|
169 |
#endif
|
|
|
170 |
"\n"
|
|
|
171 |
"Where:\n"
|
|
|
172 |
#ifdef WIN32
|
|
|
173 |
" GCC Use Symbian GCC tool chain\n"
|
|
|
174 |
#endif
|
|
|
175 |
" GCCE Use CSL ARM tool chain\n"
|
|
|
176 |
" RVCT Use RVCT tool chain\n"
|
|
|
177 |
"\n"
|
|
|
178 |
"Required options:\n"
|
|
|
179 |
" -baselinelibdir DIR;DIR Read baseline libraries from DIRECTORY\n"
|
|
|
180 |
" -currentlibdir DIR;DIR Read libraries of current release from DIRECTORY\n"
|
|
|
181 |
" -baselineversion NAME NAME of the baseline\n"
|
|
|
182 |
" -currentversion NAME NAME of the current release\n"
|
|
|
183 |
" -reportfile FILE Save report to FILE\n"
|
|
|
184 |
"\n"
|
|
|
185 |
"Required options when RVCT tool chain is used:\n"
|
|
|
186 |
" -cfilt FILE Location FILE of cfilt/c++filt\n"
|
|
|
187 |
"\n"
|
|
|
188 |
"Optional options:\n"
|
|
|
189 |
" -baselinedlldir Read baseline dlls from DIRECTORY or dll data from FILE\n"
|
|
|
190 |
" DIRECTORY|FILE\n"
|
|
|
191 |
" -currentdlldir Read dlls from DIRECTORY or dll data from FILE for current release\n"
|
|
|
192 |
" DIRECTORY|FILE\n"
|
|
|
193 |
" -tools DIRECTORY DIRECTORY where the used toolset is installed\n"
|
|
|
194 |
" -temp DIRECTORY DIRECTORY to store intermediate files\n"
|
|
|
195 |
" -set FILE Textfile FILE which has a list of libraries to check\n"
|
|
|
196 |
" --uselibs Always use LIBs instead of DSOs (not valid with GCC)\n"
|
|
|
197 |
"\n";
|
|
|
198 |
|
|
|
199 |
exit(EXIT_NORMAL);
|
|
|
200 |
}
|
|
|
201 |
|
|
|
202 |
// ----------------------------------------------------------------------------------------------------------
|
|
|
203 |
|
|
|
204 |
void DoInitialChecksAndPreparations()
|
|
|
205 |
{
|
|
|
206 |
// get the current date and time
|
|
|
207 |
time_t timenow_t = time(NULL);
|
|
|
208 |
_timenow = localtime(&timenow_t);
|
|
|
209 |
|
|
|
210 |
// check parameter correctness
|
|
|
211 |
#ifndef WIN32
|
|
|
212 |
if (_cl_use_gcc)
|
|
|
213 |
{
|
|
|
214 |
cerr << "ERROR: GCC tool chain is not supported in Linux" << endl;
|
|
|
215 |
exit(EXIT_GCC_NOT_SUPPORTED);
|
|
|
216 |
}
|
|
|
217 |
#endif
|
|
|
218 |
|
|
|
219 |
if (!_cl_use_gcc && !_cl_use_gcce && !_cl_use_rvct)
|
|
|
220 |
{
|
|
|
221 |
cerr << "ERROR: No tool chain defined!" << endl;
|
|
|
222 |
cerr << "Type la -? for help" << endl;
|
|
|
223 |
exit(EXIT_WRONG_USAGE);
|
|
|
224 |
}
|
|
|
225 |
|
|
|
226 |
if (_cl_use_rvct && _cl_cfiltloc.empty())
|
|
|
227 |
{
|
|
|
228 |
cerr << "ERROR: Specify -cfilt when RVCT is defined!" << endl;
|
|
|
229 |
cerr << "Type la -? for help" << endl;
|
|
|
230 |
exit(EXIT_WRONG_USAGE);
|
|
|
231 |
}
|
|
|
232 |
|
|
|
233 |
if ( (_cl_use_gcc && (_cl_use_gcce || _cl_use_rvct)) || (_cl_use_gcce && (_cl_use_gcc || _cl_use_rvct)) ||
|
|
|
234 |
(_cl_use_rvct && (_cl_use_gcc || _cl_use_gcce)) )
|
|
|
235 |
{
|
|
|
236 |
cerr << "ERROR: Specify only one tool chain!" << endl;
|
|
|
237 |
cerr << "Type la -? for help" << endl;
|
|
|
238 |
exit(EXIT_WRONG_USAGE);
|
|
|
239 |
}
|
|
|
240 |
|
|
|
241 |
if (_cl_baselinelibdir.empty() || _cl_currentlibdir.empty() || _cl_baselineversion.empty() || _cl_currentversion.empty() || _cl_reportfile.empty())
|
|
|
242 |
{
|
|
|
243 |
cerr << "ERROR: Not all required parameters specified!" << endl;
|
|
|
244 |
cerr << "Type la -? for help" << endl;
|
|
|
245 |
exit(EXIT_WRONG_USAGE);
|
|
|
246 |
}
|
|
|
247 |
|
|
|
248 |
// make sure the directory names have trailing directory markers
|
|
|
249 |
vector<string>::iterator i = _lib_dirs_baseline.begin();
|
|
|
250 |
for( ; i != _lib_dirs_baseline.end(); i++)
|
|
|
251 |
MakeSureTrailingDirectoryMarkerExists(*i);
|
|
|
252 |
|
|
|
253 |
for( i = _lib_dirs_current.begin(); i != _lib_dirs_current.end(); i++)
|
|
|
254 |
MakeSureTrailingDirectoryMarkerExists(*i);
|
|
|
255 |
|
|
|
256 |
MakeSureTrailingDirectoryMarkerExists(_cl_toolsdir);
|
|
|
257 |
MakeSureTrailingDirectoryMarkerExists(_cl_tempdir);
|
|
|
258 |
|
|
|
259 |
// check if baselinedir & currentdir exists
|
|
|
260 |
vector<string>::const_iterator j = _lib_dirs_baseline.begin();
|
|
|
261 |
for( ; j != _lib_dirs_baseline.end(); j++)
|
|
|
262 |
if (!DirectoryExists(*j))
|
|
|
263 |
{
|
|
|
264 |
cerr << "ERROR: " << *j << " not found!" << endl;
|
|
|
265 |
cerr << "Check -baselinelibdir parameter" << endl;
|
|
|
266 |
exit(EXIT_BASELINEDIR_NOT_FOUND);
|
|
|
267 |
}
|
|
|
268 |
for( j = _lib_dirs_current.begin(); j != _lib_dirs_current.end(); j++)
|
|
|
269 |
if (!DirectoryExists(*j))
|
|
|
270 |
{
|
|
|
271 |
cerr << "ERROR: " << *j << " not found!" << endl;
|
|
|
272 |
cerr << "Check -currentlibdir parameter" << endl;
|
|
|
273 |
exit(EXIT_CURRENTDIR_NOT_FOUND);
|
|
|
274 |
}
|
|
|
275 |
|
|
|
276 |
//if both -baselinedlldir & -currentdlldir are given, check the validity of their value
|
|
|
277 |
if (!_cl_baselinedlldir.empty() && !_cl_currentdlldir.empty())
|
|
|
278 |
{
|
|
|
279 |
if( !FileExists(_cl_baselinedlldir) )
|
|
|
280 |
{
|
|
|
281 |
//create a vector from the ';' seperated string
|
|
|
282 |
_dll_dirs_baseline = splitString( _cl_baselinedlldir, ';');
|
|
|
283 |
for( i = _dll_dirs_baseline.begin(); i != _dll_dirs_baseline.end(); i++)
|
|
|
284 |
{
|
|
|
285 |
MakeSureTrailingDirectoryMarkerExists(*i);
|
|
|
286 |
if ( !DirectoryExists(*i) )
|
|
|
287 |
{
|
|
|
288 |
cerr << "ERROR: " << *i << " not found!" << endl;
|
|
|
289 |
cerr << "Check -baselinedlldir parameter" << endl;
|
|
|
290 |
exit(EXIT_BASELINEDLLDIR_NOT_FOUND);
|
|
|
291 |
}
|
|
|
292 |
}
|
|
|
293 |
}
|
|
|
294 |
else
|
|
|
295 |
{
|
|
|
296 |
_baselinedllfile = _cl_baselinedlldir;
|
|
|
297 |
}
|
|
|
298 |
if( !FileExists(_cl_currentdlldir) )
|
|
|
299 |
{
|
|
|
300 |
//create a vector from the ';' seperated string
|
|
|
301 |
_dll_dirs_current = splitString( _cl_currentdlldir, ';');
|
|
|
302 |
for( i = _dll_dirs_current.begin(); i != _dll_dirs_current.end(); i++)
|
|
|
303 |
{
|
|
|
304 |
MakeSureTrailingDirectoryMarkerExists(*i);
|
|
|
305 |
if ( !DirectoryExists(*i) )
|
|
|
306 |
{
|
|
|
307 |
cerr << "ERROR: " << *i << " not found!" << endl;
|
|
|
308 |
cerr << "Check -currentdlldir parameter" << endl;
|
|
|
309 |
exit(EXIT_CURRENTDLLDIR_NOT_FOUND);
|
|
|
310 |
}
|
|
|
311 |
}
|
|
|
312 |
}
|
|
|
313 |
else
|
|
|
314 |
{
|
|
|
315 |
_currentdllfile = _cl_currentdlldir;
|
|
|
316 |
}
|
|
|
317 |
}
|
|
|
318 |
|
|
|
319 |
// check if user given filter set exists
|
|
|
320 |
if (!_cl_set.empty() && !FileExists(_cl_set))
|
|
|
321 |
{
|
|
|
322 |
cerr << "ERROR: " << _cl_set << " not found!" << endl;
|
|
|
323 |
cerr << "Check -set parameter" << endl;
|
|
|
324 |
exit(EXIT_SET_FILE_NOT_FOUND);
|
|
|
325 |
}
|
|
|
326 |
|
|
|
327 |
// if tools parameter is empty, try get it from path, otherwise check given parameter
|
|
|
328 |
if (_cl_toolsdir.empty())
|
|
|
329 |
{
|
|
|
330 |
GetToolsPathFromEnvironmentVariable();
|
|
|
331 |
}
|
|
|
332 |
else
|
|
|
333 |
{
|
|
|
334 |
// check the given tools directory parameter is valid
|
|
|
335 |
if (_cl_use_gcc)
|
|
|
336 |
{
|
|
|
337 |
_gcc_nm_location = _cl_toolsdir + GCC_NM_EXE;
|
|
|
338 |
|
|
|
339 |
if (!FileExists(_gcc_nm_location))
|
|
|
340 |
{
|
|
|
341 |
cerr << "ERROR: Unable to find " + _gcc_nm_location << ", check -tools parameter" << endl;
|
|
|
342 |
cerr << "Tip: GCC is typically installed to \\epoc32\\gcc\\bin directory" << endl;
|
|
|
343 |
exit(EXIT_TOOLCHAIN_NOT_FOUND);
|
|
|
344 |
}
|
|
|
345 |
|
|
|
346 |
// extra quotes needed to prevent white space problems while executing the tool
|
|
|
347 |
InsertQuotesToFilePath(_gcc_nm_location);
|
|
|
348 |
}
|
|
|
349 |
|
|
|
350 |
else if (_cl_use_gcce)
|
|
|
351 |
{
|
|
|
352 |
_gcce_nm_location = _cl_toolsdir + GCCE_NM_EXE;
|
|
|
353 |
_gcce_readelf_location = _cl_toolsdir + GCCE_READELF_EXE;
|
|
|
354 |
_gcce_cfilt_location = _cl_toolsdir + GCCE_CFILT_EXE;
|
|
|
355 |
|
|
|
356 |
if (!FileExists(_gcce_nm_location))
|
|
|
357 |
{
|
|
|
358 |
cerr << "ERROR: Unable to find " + _gcce_nm_location << ", check -tools param" << endl;
|
|
|
359 |
cerr << "Tip: GCCE is typically installed to C:\\Program Files\\CSL Arm Toolchain\\bin" << endl;
|
|
|
360 |
exit(EXIT_TOOLCHAIN_NOT_FOUND);
|
|
|
361 |
}
|
|
|
362 |
|
|
|
363 |
if (!FileExists(_gcce_readelf_location))
|
|
|
364 |
{
|
|
|
365 |
cerr << "ERROR: Unable to find " + _gcce_readelf_location << ", check -tools param" << endl;
|
|
|
366 |
cerr << "Tip: GCCE is typically installed to C:\\Program Files\\CSL Arm Toolchain\\bin" << endl;
|
|
|
367 |
exit(EXIT_TOOLCHAIN_NOT_FOUND);
|
|
|
368 |
}
|
|
|
369 |
|
|
|
370 |
if (!FileExists(_gcce_cfilt_location))
|
|
|
371 |
{
|
|
|
372 |
cerr << "ERROR: Unable to find " + _gcce_cfilt_location << ", check -tools param" << endl;
|
|
|
373 |
cerr << "Tip: GCCE is typically installed to C:\\Program Files\\CSL Arm Toolchain\\bin" << endl;
|
|
|
374 |
exit(EXIT_TOOLCHAIN_NOT_FOUND);
|
|
|
375 |
}
|
|
|
376 |
|
|
|
377 |
// extra quotes needed to prevent white space problems while executing the tool
|
|
|
378 |
InsertQuotesToFilePath(_gcce_nm_location);
|
|
|
379 |
InsertQuotesToFilePath(_gcce_readelf_location);
|
|
|
380 |
InsertQuotesToFilePath(_gcce_cfilt_location);
|
|
|
381 |
|
|
|
382 |
}
|
|
|
383 |
|
|
|
384 |
else if (_cl_use_rvct)
|
|
|
385 |
{
|
|
|
386 |
_rvct_armar_location = _cl_toolsdir + RVCT_ARMAR_EXE;
|
|
|
387 |
_rvct_fromelf_location = _cl_toolsdir + RVCT_FROMELF_EXE;
|
|
|
388 |
|
|
|
389 |
if (!FileExists(_rvct_armar_location))
|
|
|
390 |
{
|
|
|
391 |
cerr << "ERROR: Unable to find " + _rvct_armar_location << ", check -tools param" << endl;
|
|
|
392 |
cerr << "Tip: Check your environment variables to see the directory where RVCT has been installed" << endl;
|
|
|
393 |
exit(EXIT_TOOLCHAIN_NOT_FOUND);
|
|
|
394 |
}
|
|
|
395 |
|
|
|
396 |
if (!FileExists(_rvct_fromelf_location))
|
|
|
397 |
{
|
|
|
398 |
cerr << "ERROR: Unable to find " + _rvct_fromelf_location << ", check -tools param" << endl;
|
|
|
399 |
cerr << "Tip: Check your environment variables to see the directory where RVCT has been installed" << endl;
|
|
|
400 |
exit(EXIT_TOOLCHAIN_NOT_FOUND);
|
|
|
401 |
}
|
|
|
402 |
|
|
|
403 |
// extra quotes needed to prevent white space problems while executing the tool
|
|
|
404 |
InsertQuotesToFilePath(_rvct_armar_location);
|
|
|
405 |
InsertQuotesToFilePath(_rvct_fromelf_location);
|
|
|
406 |
}
|
|
|
407 |
} // else of if (!cl_toolsdir)
|
|
|
408 |
|
|
|
409 |
// check path of RVCT's cfilt is correct
|
|
|
410 |
if (_cl_use_rvct)
|
|
|
411 |
{
|
|
|
412 |
_rvct_cfilt_location = _cl_cfiltloc;
|
|
|
413 |
|
|
|
414 |
if (!FileExists(_rvct_cfilt_location))
|
|
|
415 |
{
|
|
|
416 |
cerr << "ERROR: Unable to find " + _rvct_cfilt_location << ", check -cfilt param" << endl;
|
|
|
417 |
cerr << "Tip: Working cfilt.exe can be found from the same directory where LibraryAnalyser has been installed" << endl;
|
|
|
418 |
exit(EXIT_CFILT_NOT_FOUND);
|
|
|
419 |
}
|
|
|
420 |
|
|
|
421 |
// extra quotes needed to prevent white space problems while executing the tool
|
|
|
422 |
InsertQuotesToFilePath(_rvct_cfilt_location);
|
|
|
423 |
}
|
|
|
424 |
|
|
|
425 |
|
|
|
426 |
// get temporary directory from environment variable if not specified by the user
|
|
|
427 |
if (_cl_tempdir.empty())
|
|
|
428 |
{
|
|
|
429 |
GetTempPathFromEnvironmentVariable();
|
|
|
430 |
}
|
|
|
431 |
// otherwise create path to user given parameter
|
|
|
432 |
else
|
|
|
433 |
{
|
|
|
434 |
MkDirAll(_cl_tempdir);
|
|
|
435 |
}
|
|
|
436 |
|
|
|
437 |
// check that it is possible to create the temporary file under the temp directory
|
|
|
438 |
_tempfile_location = _cl_tempdir + TEMP_FILENAME;
|
|
|
439 |
ofstream tempf(_tempfile_location.c_str(), ios::trunc);
|
|
|
440 |
if (!tempf.is_open())
|
|
|
441 |
{
|
|
|
442 |
tempf.close();
|
|
|
443 |
cerr << "ERROR: Cannot open " << _tempfile_location << " for writing!" << endl;
|
|
|
444 |
cerr << "Please check that are no write permission problems" << endl;
|
|
|
445 |
exit(EXIT_CANNOT_WRITE_TO_TEMP_FILE);
|
|
|
446 |
}
|
|
|
447 |
else
|
|
|
448 |
tempf.close();
|
|
|
449 |
|
|
|
450 |
|
|
|
451 |
//if -baselinedlldir or -currentdlldir or both not given, throw warning
|
|
|
452 |
if (_cl_baselinedlldir.empty() || _cl_currentdlldir.empty() )
|
|
|
453 |
{
|
|
|
454 |
cout << "WARNING: Required parameters for checking dll properties not specified. Breaks in dlls will not be checked!" << endl;
|
|
|
455 |
}
|
|
|
456 |
|
|
|
457 |
// check if analysing .dso or .lib files
|
|
|
458 |
if (_cl_use_gcc || _cl_use_libs) // for GCC use always .lib files
|
|
|
459 |
_lib_extension = ".lib";
|
|
|
460 |
else
|
|
|
461 |
_lib_extension = ".dso";
|
|
|
462 |
}
|
|
|
463 |
|
|
|
464 |
// ----------------------------------------------------------------------------------------------------------
|
|
|
465 |
|
|
|
466 |
void GetToolsPathFromEnvironmentVariable()
|
|
|
467 |
{
|
|
|
468 |
#ifdef WIN32
|
|
|
469 |
// get path environment variable
|
|
|
470 |
const char* env_path = getenv("PATH");
|
|
|
471 |
|
|
|
472 |
if (env_path != NULL)
|
|
|
473 |
{
|
|
|
474 |
string env_path_str = env_path;
|
|
|
475 |
|
|
|
476 |
string::size_type previous_delimpos = 0;
|
|
|
477 |
bool match_found(false);
|
|
|
478 |
string test_path;
|
|
|
479 |
|
|
|
480 |
for (unsigned int i=0; i<env_path_str.length(); i++)
|
|
|
481 |
{
|
|
|
482 |
// directories in %PATH% are separated with ';'-char
|
|
|
483 |
string::size_type delimpos = env_path_str.find(";", i);
|
|
|
484 |
|
|
|
485 |
if (delimpos != string::npos)
|
|
|
486 |
{
|
|
|
487 |
// get path
|
|
|
488 |
test_path = env_path_str.substr(previous_delimpos, delimpos-previous_delimpos);
|
|
|
489 |
|
|
|
490 |
//cerr << "Test_path: " << test_path << endl;
|
|
|
491 |
|
|
|
492 |
MakeSureTrailingDirectoryMarkerExists(test_path);
|
|
|
493 |
|
|
|
494 |
// remember found position
|
|
|
495 |
previous_delimpos = delimpos + 1;
|
|
|
496 |
i = delimpos;
|
|
|
497 |
|
|
|
498 |
// do check if path is correct
|
|
|
499 |
if (_cl_use_gcc)
|
|
|
500 |
{
|
|
|
501 |
_gcc_nm_location = test_path + GCC_NM_EXE;
|
|
|
502 |
|
|
|
503 |
if (FileExists(_gcc_nm_location))
|
|
|
504 |
{
|
|
|
505 |
match_found = true;
|
|
|
506 |
|
|
|
507 |
// extra quotes needed to prevent white space problems while executing the tool
|
|
|
508 |
InsertQuotesToFilePath(_gcc_nm_location);
|
|
|
509 |
}
|
|
|
510 |
}
|
|
|
511 |
|
|
|
512 |
else if (_cl_use_gcce)
|
|
|
513 |
{
|
|
|
514 |
_gcce_nm_location = test_path + GCCE_NM_EXE;
|
|
|
515 |
_gcce_readelf_location = test_path + GCCE_READELF_EXE;
|
|
|
516 |
_gcce_cfilt_location = test_path + GCCE_CFILT_EXE;
|
|
|
517 |
|
|
|
518 |
if (FileExists(_gcce_nm_location) && FileExists(_gcce_readelf_location) && FileExists(_gcce_cfilt_location))
|
|
|
519 |
{
|
|
|
520 |
match_found = true;
|
|
|
521 |
|
|
|
522 |
// extra quotes needed to prevent white space problems while executing the tool
|
|
|
523 |
InsertQuotesToFilePath(_gcce_nm_location);
|
|
|
524 |
InsertQuotesToFilePath(_gcce_readelf_location);
|
|
|
525 |
InsertQuotesToFilePath(_gcce_cfilt_location);
|
|
|
526 |
}
|
|
|
527 |
}
|
|
|
528 |
|
|
|
529 |
else if (_cl_use_rvct)
|
|
|
530 |
{
|
|
|
531 |
_rvct_armar_location = test_path + RVCT_ARMAR_EXE;
|
|
|
532 |
_rvct_fromelf_location = test_path + RVCT_FROMELF_EXE;
|
|
|
533 |
|
|
|
534 |
if (FileExists(_rvct_armar_location) && FileExists(_rvct_fromelf_location))
|
|
|
535 |
{
|
|
|
536 |
match_found = true;
|
|
|
537 |
|
|
|
538 |
// extra quotes needed to prevent white space problems while executing the tool
|
|
|
539 |
InsertQuotesToFilePath(_rvct_armar_location);
|
|
|
540 |
InsertQuotesToFilePath(_rvct_fromelf_location);
|
|
|
541 |
}
|
|
|
542 |
}
|
|
|
543 |
|
|
|
544 |
}
|
|
|
545 |
|
|
|
546 |
// first matching directory found, no need to loop anymore
|
|
|
547 |
if (match_found)
|
|
|
548 |
{
|
|
|
549 |
_cl_toolsdir = test_path;
|
|
|
550 |
cerr << "Tool chain found from %PATH% at " << test_path << endl;
|
|
|
551 |
break;
|
|
|
552 |
}
|
|
|
553 |
|
|
|
554 |
if (i>5000)
|
|
|
555 |
break; // something went wrong..
|
|
|
556 |
}
|
|
|
557 |
|
|
|
558 |
if (!match_found)
|
|
|
559 |
{
|
|
|
560 |
cerr << "ERROR: Cannot find specified compiler toolset from PATH environment" << endl;
|
|
|
561 |
cerr << "Fix PATH environment variable or specify -tools parameter" << endl;
|
|
|
562 |
exit(EXIT_TOOLCHAIN_NOT_FOUND_FROM_PATH);
|
|
|
563 |
}
|
|
|
564 |
|
|
|
565 |
}
|
|
|
566 |
else
|
|
|
567 |
{
|
|
|
568 |
cerr << "ERROR: PATH environment variable not available, please specify -tools parameter" << endl;
|
|
|
569 |
exit(EXIT_PATH_VARIABLE_NOT_FOUND);
|
|
|
570 |
}
|
|
|
571 |
|
|
|
572 |
#else
|
|
|
573 |
|
|
|
574 |
cerr << "ERROR: Optional -tools parameter is only supported in Windows environment " << endl;
|
|
|
575 |
exit(EXIT_ONLY_SUPPORTED_IN_WIN32);
|
|
|
576 |
|
|
|
577 |
#endif
|
|
|
578 |
|
|
|
579 |
}
|
|
|
580 |
|
|
|
581 |
// ----------------------------------------------------------------------------------------------------------
|
|
|
582 |
|
|
|
583 |
void GetTempPathFromEnvironmentVariable()
|
|
|
584 |
{
|
|
|
585 |
#ifdef WIN32
|
|
|
586 |
// get path environment variable
|
|
|
587 |
const char* env_path = getenv("TEMP");
|
|
|
588 |
|
|
|
589 |
if (env_path != NULL)
|
|
|
590 |
{
|
|
|
591 |
string env_path_str = env_path;
|
|
|
592 |
MakeSureTrailingDirectoryMarkerExists(env_path_str);
|
|
|
593 |
|
|
|
594 |
// check if the directory exists
|
|
|
595 |
if (DirectoryExists(env_path_str))
|
|
|
596 |
{
|
|
|
597 |
_cl_tempdir = env_path_str;
|
|
|
598 |
}
|
|
|
599 |
else
|
|
|
600 |
{
|
|
|
601 |
cerr << "ERROR: Directory specified in TEMP environment variable does not exist" << endl;
|
|
|
602 |
cerr << "Fix TEMP environment variable or specify -temp parameter" << endl;
|
|
|
603 |
exit(EXIT_TEMP_DIRECTORY_DOES_NOT_EXIST);
|
|
|
604 |
}
|
|
|
605 |
}
|
|
|
606 |
else
|
|
|
607 |
{
|
|
|
608 |
cerr << "ERROR: TEMP environment variable not available, please specify -temp parameter" << endl;
|
|
|
609 |
exit(EXIT_TEMP_VARIABLE_NOT_FOUND);
|
|
|
610 |
}
|
|
|
611 |
|
|
|
612 |
#else
|
|
|
613 |
|
|
|
614 |
cerr << "ERROR: Optional -temp parameter is only supported in Windows environment " << endl;
|
|
|
615 |
exit(EXIT_ONLY_SUPPORTED_IN_WIN32);
|
|
|
616 |
|
|
|
617 |
#endif
|
|
|
618 |
|
|
|
619 |
}
|
|
|
620 |
|
|
|
621 |
// ----------------------------------------------------------------------------------------------------------
|
|
|
622 |
|
|
|
623 |
void GetListsOfImportLibraries()
|
|
|
624 |
{
|
|
|
625 |
string lib_filter = "*" + _lib_extension;
|
|
|
626 |
|
|
|
627 |
GetFileNamesFromDirectory(_lib_dirs_baseline, lib_filter, _lib_files_baseline);
|
|
|
628 |
GetFileNamesFromDirectory(_lib_dirs_current, lib_filter, _lib_files_current);
|
|
|
629 |
}
|
|
|
630 |
|
|
|
631 |
// ----------------------------------------------------------------------------------------------------------
|
|
|
632 |
|
|
|
633 |
void GetFileNamesFromDirectory(const vector<string>& directories, const string& filter, vector<string>& resultset)
|
|
|
634 |
{
|
|
|
635 |
// get list of files from the directory by executing OS specific dir/ls command
|
|
|
636 |
string dir_command = DIR_COMMAND;
|
|
|
637 |
vector<string> tempVector;
|
|
|
638 |
vector<string> localVector;
|
|
|
639 |
unsigned int i = 0;
|
|
|
640 |
unsigned int j = 0;
|
|
|
641 |
string cmd;
|
|
|
642 |
|
|
|
643 |
// Get filter extension to compare with libname extension
|
|
|
644 |
string::size_type dot_loc = filter.find_last_of(".");
|
|
|
645 |
string filterExtensn;
|
|
|
646 |
if (dot_loc != string::npos)
|
|
|
647 |
filterExtensn = filter.substr(dot_loc,string::npos);
|
|
|
648 |
|
|
|
649 |
for(; i < directories.size(); i++)
|
|
|
650 |
{
|
|
|
651 |
cmd = dir_command + " \"" + directories.at(i) + "\"" + filter + " " + CERR_TO_NULL;
|
|
|
652 |
ExecuteCommand(cmd, localVector);
|
|
|
653 |
string fileExtn;
|
|
|
654 |
//append the list of files, along with directory names, to a common vector
|
|
|
655 |
for(j = 0;j < localVector.size(); j++)
|
|
|
656 |
{
|
|
|
657 |
// get lib name extensiion and compare with filter extension.
|
|
|
658 |
dot_loc = localVector.at(j).find_last_of(".");
|
|
|
659 |
if (dot_loc != string::npos)
|
|
|
660 |
fileExtn = localVector.at(j).substr(dot_loc,string::npos);
|
|
|
661 |
// if extensions are not matching , ignore the libname
|
|
|
662 |
if(stricmp(fileExtn.c_str(),filterExtensn.c_str()) == 0 )
|
|
|
663 |
{
|
|
|
664 |
#ifdef WIN32
|
|
|
665 |
tempVector.push_back( directories.at(i) + localVector.at(j) );
|
|
|
666 |
#else
|
|
|
667 |
tempVector.push_back( localVector.at(j) );
|
|
|
668 |
#endif
|
|
|
669 |
}
|
|
|
670 |
}
|
|
|
671 |
}
|
|
|
672 |
|
|
|
673 |
// loop through all returned files
|
|
|
674 |
for (unsigned int i=0; i<tempVector.size(); i++)
|
|
|
675 |
{
|
|
|
676 |
// remove any leading and trailing white spaces
|
|
|
677 |
string file_entry = tempVector.at(i);
|
|
|
678 |
TrimAll(file_entry);
|
|
|
679 |
|
|
|
680 |
if (!file_entry.empty())
|
|
|
681 |
{
|
|
|
682 |
resultset.push_back(file_entry);
|
|
|
683 |
}
|
|
|
684 |
|
|
|
685 |
}
|
|
|
686 |
}
|
|
|
687 |
|
|
|
688 |
// ----------------------------------------------------------------------------------------------------------
|
|
|
689 |
|
|
|
690 |
void FilterListsOfImportLibraries()
|
|
|
691 |
{
|
|
|
692 |
// if list filtering is enabled (-set param), use only those library files defined in the list
|
|
|
693 |
if (!_cl_set.empty())
|
|
|
694 |
{
|
|
|
695 |
// open the file for reading
|
|
|
696 |
ifstream set_f(_cl_set.c_str());
|
|
|
697 |
|
|
|
698 |
if (set_f.is_open())
|
|
|
699 |
{
|
|
|
700 |
if (_cl_print_debug)
|
|
|
701 |
{
|
|
|
702 |
cerr << "Filtering import libraries based on " << _cl_set << endl;
|
|
|
703 |
}
|
|
|
704 |
|
|
|
705 |
vector<string> lib_files_filter;
|
|
|
706 |
string item_str;
|
|
|
707 |
int i=0;
|
|
|
708 |
|
|
|
709 |
// read all names from the lib
|
|
|
710 |
while(!set_f.eof() && i<50000)
|
|
|
711 |
{
|
|
|
712 |
getline(set_f, item_str);
|
|
|
713 |
item_str = TrimAll(item_str);
|
|
|
714 |
|
|
|
715 |
if (!item_str.empty())
|
|
|
716 |
{
|
|
|
717 |
// strip any directory path, both Windows and Unix style
|
|
|
718 |
string::size_type sep_pos = item_str.find_last_of("\\");
|
|
|
719 |
if (sep_pos != string::npos)
|
|
|
720 |
item_str = item_str.substr(sep_pos+1, item_str.length()-sep_pos-1);
|
|
|
721 |
sep_pos = item_str.find_last_of("/");
|
|
|
722 |
if (sep_pos != string::npos)
|
|
|
723 |
item_str = item_str.substr(sep_pos+1, item_str.length()-sep_pos-1);
|
|
|
724 |
|
|
|
725 |
//cerr << "Set filter: " << item_str << endl;
|
|
|
726 |
|
|
|
727 |
// append the file name to the vector
|
|
|
728 |
lib_files_filter.push_back(item_str);
|
|
|
729 |
}
|
|
|
730 |
|
|
|
731 |
i++;
|
|
|
732 |
}
|
|
|
733 |
set_f.close();
|
|
|
734 |
|
|
|
735 |
|
|
|
736 |
// remove from _lib_files_baseline those strings which aren't in lib_files_filter
|
|
|
737 |
for (unsigned int j=0; j<_lib_files_baseline.size(); )
|
|
|
738 |
{
|
|
|
739 |
bool found = false;
|
|
|
740 |
|
|
|
741 |
for (unsigned int k=0; k<lib_files_filter.size(); k++)
|
|
|
742 |
{
|
|
|
743 |
if (StringICmpFileNamesWithoutExtension(getFilename(_lib_files_baseline.at(j)), lib_files_filter.at(k)) == 0)
|
|
|
744 |
{
|
|
|
745 |
// element found, no need to loop anymore
|
|
|
746 |
found = true;
|
|
|
747 |
break;
|
|
|
748 |
}
|
|
|
749 |
}
|
|
|
750 |
|
|
|
751 |
if (!found) // if not found, remove element j from the vector _lib_files_baseline
|
|
|
752 |
_lib_files_baseline.erase(_lib_files_baseline.begin()+j, _lib_files_baseline.begin()+j+1);
|
|
|
753 |
else
|
|
|
754 |
j++;
|
|
|
755 |
}
|
|
|
756 |
|
|
|
757 |
// remove from _lib_files_current those strings which aren't in lib_files_filter
|
|
|
758 |
for (unsigned int j=0; j<_lib_files_current.size(); )
|
|
|
759 |
{
|
|
|
760 |
bool found = false;
|
|
|
761 |
|
|
|
762 |
for (unsigned int k=0; k<lib_files_filter.size(); k++)
|
|
|
763 |
{
|
|
|
764 |
if (StringICmpFileNamesWithoutExtension(getFilename(_lib_files_current.at(j)), lib_files_filter.at(k)) == 0)
|
|
|
765 |
{
|
|
|
766 |
// element found, no need to loop anymore
|
|
|
767 |
found = true;
|
|
|
768 |
break;
|
|
|
769 |
}
|
|
|
770 |
}
|
|
|
771 |
|
|
|
772 |
if (!found) // if not found, remove element j from the vector _lib_files_current
|
|
|
773 |
_lib_files_current.erase(_lib_files_current.begin()+j, _lib_files_current.begin()+j+1);
|
|
|
774 |
else
|
|
|
775 |
j++;
|
|
|
776 |
}
|
|
|
777 |
}
|
|
|
778 |
else
|
|
|
779 |
{
|
|
|
780 |
cerr << "ERROR: Cannot open " << _cl_set << " for reading!" << endl;
|
|
|
781 |
cerr << "Check -set parameter" << endl;
|
|
|
782 |
exit(EXIT_CANNOT_OPEN_SET_FILE);
|
|
|
783 |
}
|
|
|
784 |
|
|
|
785 |
}
|
|
|
786 |
else
|
|
|
787 |
{
|
|
|
788 |
bool match = false;
|
|
|
789 |
boost::regex re("\\S*\\{\\S{8}\\}\\.[a-zA-Z]{3}");
|
|
|
790 |
|
|
|
791 |
// filter out any unwanted files from _lib_files_baseline ex:libcrypto{000a0000}.dso
|
|
|
792 |
for (unsigned int j=0; j<_lib_files_baseline.size(); )
|
|
|
793 |
{
|
|
|
794 |
match= boost::regex_match(_lib_files_baseline.at(j), re);
|
|
|
795 |
|
|
|
796 |
if (match)
|
|
|
797 |
_lib_files_baseline.erase(_lib_files_baseline.begin()+j, _lib_files_baseline.begin()+j+1);
|
|
|
798 |
else
|
|
|
799 |
j++;
|
|
|
800 |
}
|
|
|
801 |
|
|
|
802 |
// filter out any unwanted files from _lib_files_current ex:libcrypto{00000009}.lib
|
|
|
803 |
for (unsigned int j=0; j<_lib_files_current.size(); )
|
|
|
804 |
{
|
|
|
805 |
match= boost::regex_match(_lib_files_current.at(j), re);
|
|
|
806 |
|
|
|
807 |
if (match)
|
|
|
808 |
_lib_files_current.erase(_lib_files_current.begin()+j, _lib_files_current.begin()+j+1);
|
|
|
809 |
else
|
|
|
810 |
j++;
|
|
|
811 |
}
|
|
|
812 |
|
|
|
813 |
}
|
|
|
814 |
}
|
|
|
815 |
|
|
|
816 |
// ----------------------------------------------------------------------------------------------------------
|
|
|
817 |
|
|
|
818 |
void DoPreAnalysisChecks()
|
|
|
819 |
{
|
|
|
820 |
// report an error if nothing to analyse
|
|
|
821 |
if (_lib_files_baseline.size() == 0 && _lib_files_current.size() == 0)
|
|
|
822 |
{
|
|
|
823 |
cerr << "WARNING: Nothing to analyse!" << endl;
|
|
|
824 |
}
|
|
|
825 |
}
|
|
|
826 |
|
|
|
827 |
// ----------------------------------------------------------------------------------------------------------
|
|
|
828 |
|
|
|
829 |
void DoFinalTasks()
|
|
|
830 |
{
|
|
|
831 |
// delete the temporary file
|
|
|
832 |
if (!_tempfile_location.empty())
|
|
|
833 |
RemoveFile(_tempfile_location);
|
|
|
834 |
/*if (!_baselinedllfile.empty())
|
|
|
835 |
RemoveFile(_baselinedllfile);
|
|
|
836 |
if (!_currentdllfile.empty())
|
|
|
837 |
RemoveFile(_currentdllfile);*/
|
|
|
838 |
}
|
|
|
839 |
|
|
|
840 |
// ----------------------------------------------------------------------------------------------------------
|
|
|
841 |
|
|
|
842 |
void CreateDllDataFile(string dllDataFile, vector<string>& dllPath, string type)
|
|
|
843 |
{
|
|
|
844 |
string filter = "*.dll";
|
|
|
845 |
vector<string> dlls_done;
|
|
|
846 |
vector<string> resultset;
|
|
|
847 |
|
|
|
848 |
|
|
|
849 |
ofstream outputfile( dllDataFile.c_str());
|
|
|
850 |
if(!outputfile.is_open())
|
|
|
851 |
{
|
|
|
852 |
cerr << "ERROR: Cannot open " << dllDataFile << " for writing!" << endl;
|
|
|
853 |
exit(EXIT_CANNOT_OPEN_FILE);
|
|
|
854 |
}
|
|
|
855 |
|
|
|
856 |
WriteXMLLineOpeningTag(outputfile,0,"dll_list");
|
|
|
857 |
|
|
|
858 |
GetFileNamesFromDirectory(dllPath,filter,resultset);
|
|
|
859 |
vector<string>::iterator dll = resultset.begin();
|
|
|
860 |
for( ; dll != resultset.end(); dll++)
|
|
|
861 |
{
|
|
|
862 |
string dllname = getFilename(*dll);
|
|
|
863 |
//consider the dll only if the corresponding library is to be analysed
|
|
|
864 |
vector<string>::const_iterator i = _lib_files_baseline.begin();
|
|
|
865 |
for(; i != _lib_files_baseline.end(); ++i)
|
|
|
866 |
{
|
|
|
867 |
if(StringICmpFileNamesWithoutExtension(getFilename(*i),dllname)==0)
|
|
|
868 |
break;
|
|
|
869 |
}
|
|
|
870 |
|
|
|
871 |
if (i == _lib_files_baseline.end())
|
|
|
872 |
continue;
|
|
|
873 |
|
|
|
874 |
//consider the dll file only once
|
|
|
875 |
if(count(dlls_done.begin(),dlls_done.end(),dllname)==1)
|
|
|
876 |
{
|
|
|
877 |
cout<<"Warning: More than one files matches for the given filename '"<<dllname;
|
|
|
878 |
cout<<"' in the "<<type<<" sdk, only the first file is used."<<endl;
|
|
|
879 |
dlls_done.push_back(dllname);
|
|
|
880 |
continue;
|
|
|
881 |
}
|
|
|
882 |
|
|
|
883 |
if(count(dlls_done.begin(),dlls_done.end(),dllname)>1)
|
|
|
884 |
continue;
|
|
|
885 |
|
|
|
886 |
dlls_done.push_back(dllname);
|
|
|
887 |
|
|
|
888 |
|
|
|
889 |
WriteXMLLineOpeningTag(outputfile,0,"dll");
|
|
|
890 |
WriteXMLLineOpenClosed(outputfile,1,"dllname",dllname);
|
|
|
891 |
|
|
|
892 |
fstream dllFile((*dll).c_str(),ios::binary | ios::in);
|
|
|
893 |
|
|
|
894 |
if(!dllFile.is_open())
|
|
|
895 |
{
|
|
|
896 |
cerr << "ERROR: Cannot open " << *dll << " for reading!" << endl;
|
|
|
897 |
exit(EXIT_CANNOT_OPEN_FILE);
|
|
|
898 |
}
|
|
|
899 |
|
|
|
900 |
string value;
|
|
|
901 |
|
|
|
902 |
value=HexValueAt(dllFile, UID1_OFFSET); // 0x00 offset of UID1
|
|
|
903 |
WriteXMLLineOpenClosed(outputfile,1,"uid1",value);
|
|
|
904 |
|
|
|
905 |
value=HexValueAt(dllFile, UID2_OFFSET); // 0x04 offset of UID2
|
|
|
906 |
WriteXMLLineOpenClosed(outputfile,1,"uid2",value);
|
|
|
907 |
|
|
|
908 |
value=HexValueAt(dllFile, UID3_OFFSET); // 0x08 offset of UID3
|
|
|
909 |
WriteXMLLineOpenClosed(outputfile,1,"uid3",value);
|
|
|
910 |
|
|
|
911 |
value=HexValueAt(dllFile, SID_OFFSET); // 0x80 offset of Secure ID
|
|
|
912 |
WriteXMLLineOpenClosed(outputfile,1,"sid",value);
|
|
|
913 |
|
|
|
914 |
value=HexValueAt(dllFile, CAPABILITY_OFFSET); // 0x88 offset of Capabilities
|
|
|
915 |
WriteXMLLineOpenClosed(outputfile,1,"capability",value);
|
|
|
916 |
|
|
|
917 |
WriteXMLLineClosingTag(outputfile,0,"dll");
|
|
|
918 |
|
|
|
919 |
dllFile.close();
|
|
|
920 |
}
|
|
|
921 |
|
|
|
922 |
WriteXMLLineClosingTag(outputfile,0,"dll_list");
|
|
|
923 |
outputfile.close();
|
|
|
924 |
|
|
|
925 |
}
|
|
|
926 |
|
|
|
927 |
// ----------------------------------------------------------------------------------------------------------
|
|
|
928 |
void GetDllDataFiles()
|
|
|
929 |
{
|
|
|
930 |
if (!_cl_baselinedlldir.empty() && !_cl_currentdlldir.empty() )
|
|
|
931 |
{
|
|
|
932 |
//if -baselinedlldir value is path, construct the dll data xml file
|
|
|
933 |
if( _baselinedllfile.empty() )
|
|
|
934 |
{
|
|
|
935 |
_baselinedllfile = _cl_tempdir + "baselinedlldata.xml";
|
|
|
936 |
CreateDllDataFile(_baselinedllfile,_dll_dirs_baseline, "baseline");
|
|
|
937 |
}
|
|
|
938 |
//if -currentdlldir value is path, construct the dll data xml file
|
|
|
939 |
if( _currentdllfile.empty() )
|
|
|
940 |
{
|
|
|
941 |
_currentdllfile = _cl_tempdir + "currentdlldata.xml";
|
|
|
942 |
CreateDllDataFile(_currentdllfile,_dll_dirs_current, "current");
|
|
|
943 |
}
|
|
|
944 |
}
|
|
|
945 |
}
|