|
1 /* |
|
2 * Copyright (c) 2007 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: Functionality of analysis |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "appdep.hpp" |
|
20 |
|
21 |
|
22 // ---------------------------------------------------------------------------------------------------------- |
|
23 |
|
24 void DisplayProperties(const string& binary_name) |
|
25 { |
|
26 bool match_found = false; |
|
27 |
|
28 for (unsigned int i=0; i<_all_binary_infos.size(); i++) |
|
29 { |
|
30 if (StringICmp(_all_binary_infos.at(i).filename.c_str(), binary_name.c_str()) == 0) |
|
31 { |
|
32 binary_info b_info = _all_binary_infos.at(i); |
|
33 |
|
34 PrintOutputLn("Directory: " + b_info.directory); |
|
35 PrintOutputLn("Filename: " + b_info.filename); |
|
36 PrintOutputLn("Binary format: " + b_info.binary_format); |
|
37 PrintOutputLn("UID1: " + b_info.uid1); |
|
38 PrintOutputLn("UID2: " + b_info.uid2); |
|
39 PrintOutputLn("UID3: " + b_info.uid3); |
|
40 |
|
41 if (b_info.secureid.length() > 2 && b_info.secureid.at(0)=='0' && b_info.secureid.at(1)=='x') |
|
42 { |
|
43 PrintOutputLn("Secure ID: " + b_info.secureid); |
|
44 PrintOutputLn("Vendor ID: " + b_info.vendorid); |
|
45 |
|
46 vector<string> symbian_caps; |
|
47 symbian_caps.push_back("TCB"); |
|
48 symbian_caps.push_back("CommDD"); |
|
49 symbian_caps.push_back("PowerMgmt"); |
|
50 symbian_caps.push_back("MultimediaDD"); |
|
51 symbian_caps.push_back("ReadDeviceData"); |
|
52 symbian_caps.push_back("WriteDeviceData"); |
|
53 symbian_caps.push_back("DRM"); |
|
54 symbian_caps.push_back("TrustedUI"); |
|
55 symbian_caps.push_back("ProtServ"); |
|
56 symbian_caps.push_back("DiskAdmin"); |
|
57 symbian_caps.push_back("NetworkControl"); |
|
58 symbian_caps.push_back("AllFiles"); |
|
59 symbian_caps.push_back("SwEvent"); |
|
60 symbian_caps.push_back("NetworkServices"); |
|
61 symbian_caps.push_back("LocalServices"); |
|
62 symbian_caps.push_back("ReadUserData"); |
|
63 symbian_caps.push_back("WriteUserData"); |
|
64 symbian_caps.push_back("Location"); |
|
65 symbian_caps.push_back("SurroundingsDD"); |
|
66 symbian_caps.push_back("UserEnvironment"); |
|
67 |
|
68 PrintOutputLn("Capabilities:"); |
|
69 for (unsigned int x=0; x<symbian_caps.size(); x++) |
|
70 { |
|
71 if (b_info.capabilities&(1<<(x&31))) |
|
72 PrintOutputLn(" " + symbian_caps.at(x)); |
|
73 } |
|
74 } |
|
75 PrintOutputLn("Min Heap Size: " + Int2Str(b_info.min_heap_size)); |
|
76 PrintOutputLn("Max Heap Size: " + Int2Str(b_info.max_heap_size)); |
|
77 PrintOutputLn("Stack Size: " + Int2Str(b_info.stack_size)); |
|
78 PrintOutputLn("Dll ref table count: " + Int2Str(b_info.dependencies.size())); |
|
79 |
|
80 match_found = true; |
|
81 break; |
|
82 } |
|
83 } |
|
84 |
|
85 if (!match_found) |
|
86 { |
|
87 cerr << "Properties: " << binary_name << " not found from the release" << endl; |
|
88 exit(EXIT_COMPONENT_NOT_FOUND); |
|
89 } |
|
90 } |
|
91 |
|
92 // ---------------------------------------------------------------------------------------------------------- |
|
93 |
|
94 void DisplayStaticDependencies(const string& binary_name) |
|
95 { |
|
96 bool match_found = false; |
|
97 |
|
98 for (unsigned int i=0; i<_all_binary_infos.size(); i++) |
|
99 { |
|
100 if (StringICmp(_all_binary_infos.at(i).filename.c_str(), binary_name.c_str()) == 0) |
|
101 { |
|
102 PrintOutputLn(binary_name + " - static dependencies:"); |
|
103 |
|
104 vector<dependency> deps = _all_binary_infos.at(i).dependencies; |
|
105 |
|
106 for (unsigned int j=0; j<deps.size(); j++) |
|
107 { |
|
108 PrintOutputLn(deps.at(j).filename); |
|
109 } |
|
110 |
|
111 match_found = true; |
|
112 break; |
|
113 } |
|
114 } |
|
115 |
|
116 if (!match_found) |
|
117 { |
|
118 cerr << "Static deps: " << binary_name << " not found from the release" << endl; |
|
119 exit(EXIT_COMPONENT_NOT_FOUND); |
|
120 } |
|
121 } |
|
122 |
|
123 // ---------------------------------------------------------------------------------------------------------- |
|
124 |
|
125 void DisplayDependents(const string& binary_name) |
|
126 { |
|
127 PrintOutputLn(binary_name + " - components that depends on:"); |
|
128 |
|
129 for (unsigned int i=0; i<_all_binary_infos.size(); i++) |
|
130 { |
|
131 string component_name = _all_binary_infos.at(i).filename; |
|
132 |
|
133 vector<dependency> deps = _all_binary_infos.at(i).dependencies; |
|
134 |
|
135 for (unsigned int j=0; j<deps.size(); j++) |
|
136 { |
|
137 if (StringICmp(deps.at(j).filename.c_str(), binary_name.c_str()) == 0) |
|
138 { |
|
139 PrintOutputLn(component_name); |
|
140 break; |
|
141 } |
|
142 } |
|
143 } |
|
144 } |
|
145 |
|
146 // ---------------------------------------------------------------------------------------------------------- |
|
147 |
|
148 void DisplayFunctions(const string& binary_name) |
|
149 { |
|
150 bool match_found = false; |
|
151 |
|
152 for (unsigned int i=0; i<_all_binary_infos.size(); i++) |
|
153 { |
|
154 if (StringICmp(_all_binary_infos.at(i).filename.c_str(), binary_name.c_str()) == 0) |
|
155 { |
|
156 PrintOutputLn(binary_name + " - included functions:"); |
|
157 |
|
158 vector<dependency> deps = _all_binary_infos.at(i).dependencies; |
|
159 |
|
160 for (unsigned int j=0; j<deps.size(); j++) |
|
161 { |
|
162 vector<import> imps = deps.at(j).imports; |
|
163 |
|
164 for (unsigned int k=0; k<imps.size(); k++) |
|
165 { |
|
166 if (_cl_show_ordinals) |
|
167 { |
|
168 if (imps.at(k).is_vtable) |
|
169 PrintOutputLn(imps.at(k).funcname + " [virtual table offset by " + Int2Str(imps.at(k).vtable_offset) + "]" + " [" + deps.at(j).filename + "@" + Int2Str(imps.at(k).funcpos) + "]"); |
|
170 else |
|
171 PrintOutputLn(imps.at(k).funcname + " [" + deps.at(j).filename + "@" + Int2Str(imps.at(k).funcpos) + "]"); |
|
172 } |
|
173 else |
|
174 { |
|
175 if (imps.at(k).is_vtable) |
|
176 PrintOutputLn(imps.at(k).funcname + " [virtual table offset by " + Int2Str(imps.at(k).vtable_offset) + "]"); |
|
177 else |
|
178 PrintOutputLn(imps.at(k).funcname); |
|
179 } |
|
180 } |
|
181 } |
|
182 |
|
183 match_found = true; |
|
184 break; |
|
185 } |
|
186 } |
|
187 |
|
188 if (!match_found) |
|
189 { |
|
190 cerr << "Show functions: " << binary_name << " not found from the release" << endl; |
|
191 exit(EXIT_COMPONENT_NOT_FOUND); |
|
192 } |
|
193 } |
|
194 |
|
195 // ---------------------------------------------------------------------------------------------------------- |
|
196 |
|
197 void DisplayUsesFunction(const string& function_name) |
|
198 { |
|
199 // check if it's full function name or dll name with ordinal |
|
200 string::size_type marker_pos = function_name.find_last_of('@'); |
|
201 |
|
202 if (marker_pos == string::npos) |
|
203 { |
|
204 // it is a normal function name |
|
205 |
|
206 PrintOutputLn(function_name + " - is used by:"); |
|
207 |
|
208 for (unsigned int i=0; i<_all_binary_infos.size(); i++) |
|
209 { |
|
210 string component_name = _all_binary_infos.at(i).filename; |
|
211 |
|
212 vector<dependency> deps = _all_binary_infos.at(i).dependencies; |
|
213 |
|
214 for (unsigned int j=0; j<deps.size(); j++) |
|
215 { |
|
216 vector<import> imps = deps.at(j).imports; |
|
217 |
|
218 for (unsigned int k=0; k<imps.size(); k++) |
|
219 { |
|
220 if (StringICmp(imps.at(k).funcname.c_str(), function_name.c_str()) == 0) |
|
221 { |
|
222 if (_cl_show_ordinals) |
|
223 PrintOutputLn(component_name + " [" + deps.at(j).filename + "@" + Int2Str(imps.at(k).funcpos) + "]"); |
|
224 else |
|
225 PrintOutputLn(component_name); |
|
226 |
|
227 break; |
|
228 } |
|
229 } |
|
230 } |
|
231 } |
|
232 } |
|
233 |
|
234 else |
|
235 { |
|
236 // get dll name and ordinal number |
|
237 string dll_name = function_name.substr(0, marker_pos); |
|
238 unsigned int ordinal_number = Str2Int( function_name.substr(marker_pos+1, function_name.length()-marker_pos-1) ); |
|
239 |
|
240 if (ordinal_number == 0 || ordinal_number > 27500) |
|
241 { |
|
242 cerr << "Uses function: Given ordinal number is invalid: " << ordinal_number << endl; |
|
243 exit(EXIT_INVALID_ORDINAL); |
|
244 } |
|
245 |
|
246 PrintOutputLn(function_name + " - is used by:"); |
|
247 |
|
248 for (unsigned int i=0; i<_all_binary_infos.size(); i++) |
|
249 { |
|
250 string component_name = _all_binary_infos.at(i).filename; |
|
251 |
|
252 vector<dependency> deps = _all_binary_infos.at(i).dependencies; |
|
253 |
|
254 for (unsigned int j=0; j<deps.size(); j++) |
|
255 { |
|
256 string dependency_name = deps.at(j).filename; |
|
257 |
|
258 if (StringICmp(deps.at(j).filename.c_str(), dll_name.c_str()) == 0) |
|
259 { |
|
260 vector<import> imps = deps.at(j).imports; |
|
261 |
|
262 for (unsigned int k=0; k<imps.size(); k++) |
|
263 { |
|
264 if (imps.at(k).funcpos == ordinal_number) |
|
265 { |
|
266 PrintOutputLn(component_name); |
|
267 break; |
|
268 } |
|
269 } |
|
270 } |
|
271 } |
|
272 } |
|
273 } |
|
274 } |
|
275 |
|
276 // ---------------------------------------------------------------------------------------------------------- |
|
277 |