author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 09 Jun 2010 11:10:19 +0300 | |
branch | RCL_3 |
changeset 36 | bbf8bed59bcb |
parent 23 | 1df514389a47 |
child 43 | c1f20ce4abcf |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// f32\sfile\sf_cache.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include <e32std.h> |
|
19 |
#include <e32std_private.h> |
|
20 |
#include "sf_std.h" |
|
21 |
#include <e32uid.h> |
|
22 |
#include <e32wins.h> |
|
23 |
#include <f32file.h> |
|
24 |
#include "sf_cache.h" |
|
25 |
||
26 |
const TInt KMaxCachedDirectories=6; |
|
27 |
||
28 |
TInt RefreshDriveInfo(); |
|
29 |
void DestroyCachedDirectories(TPathListRecord* aPathRec); |
|
30 |
void DestroyCachedDirectory(TDriveNumber aDrive, TDirectoryCacheHeader* aDirCache); |
|
31 |
void DestroyCachedDirectory(TDriveNumber aDrive, TPathListRecord* aPathRec); |
|
32 |
||
33 |
const TInt KCacheHeapGranularity=0x0800; // Allocate heap in 2K chunks |
|
34 |
||
35 |
||
36 |
TBool gInitCacheCheckDrivesAndAddNotifications = EFalse; |
|
37 |
TBool gCacheCheckDrives = ETrue; |
|
38 |
||
39 |
||
40 |
// Cache per drive |
|
41 |
TDriveCacheHeader* gDriveFileNamesCache[KMaxDrives]; |
|
42 |
||
43 |
TPathListRecord* TPathListRecord::First; |
|
44 |
TPathListRecord* TPathListRecord::LastStatic; |
|
45 |
||
46 |
||
47 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
48 |
void dumpCache() |
|
49 |
{ |
|
50 |
TDriveNumber drive; |
|
51 |
for (drive=EDriveA; drive<=EDriveZ; ((TInt&)drive)++) |
|
52 |
{ |
|
53 |
TDriveCacheHeader* pDH = gDriveFileNamesCache[drive]; |
|
54 |
RDebug::Printf("Dumping Drive %d", drive); |
|
55 |
if (!pDH) |
|
56 |
{ |
|
57 |
RDebug::Printf("Drive %d not cached",drive); |
|
58 |
continue; |
|
59 |
} |
|
60 |
TDirectoryCacheHeader* p = pDH->iDirectoryList; |
|
61 |
for (; p; p=p->iNext) |
|
62 |
{ |
|
63 |
RDebug::Printf(" Dumping directory %S", p->iPath->PathName()); |
|
64 |
TFileCacheRecord** pIndexes = p->iCache; |
|
65 |
TInt j; |
|
66 |
for(j=0; j<p->iRecordCount; j++) |
|
67 |
{ |
|
68 |
TFileCacheRecord& f = *pIndexes[j]; |
|
69 |
TBuf8<20> en = _S8("Entry "); |
|
70 |
en.AppendNum(j); |
|
71 |
f.Dump((const char*)en.Ptr()); |
|
72 |
} |
|
73 |
} |
|
74 |
} |
|
75 |
} |
|
76 |
#endif |
|
77 |
||
78 |
CCacheNotifyDirChange::CCacheNotifyDirChange(TDriveNumber aDrive, TDirectoryCacheHeader& aDirHead) |
|
79 |
: CActive(EPriorityHigh), iDrive(aDrive), iDirHead(&aDirHead) |
|
80 |
{} |
|
81 |
||
82 |
CCacheNotifyDirChange::~CCacheNotifyDirChange() |
|
83 |
{ |
|
84 |
__IF_DEBUG(Printf("~CCacheNotifyDirChange")); |
|
85 |
Cancel(); |
|
86 |
} |
|
87 |
||
88 |
void CCacheNotifyDirChange::DoCancel() |
|
89 |
{ |
|
90 |
__IF_DEBUG(Printf("DoCancel")); |
|
91 |
gTheLoaderFs.NotifyChangeCancel(iStatus); |
|
92 |
} |
|
93 |
||
94 |
void CCacheNotifyDirChange::RunL() |
|
95 |
{ |
|
96 |
__IF_DEBUG(Printf("Pop!! for drive %d path %S (%d)", iDrive, iDirHead->iPath->PathName(), iStatus.Int())); |
|
97 |
||
98 |
// unlink directory & delete it |
|
99 |
DestroyCachedDirectory(iDrive, iDirHead); |
|
100 |
gCacheCheckDrives = ETrue; |
|
101 |
} |
|
102 |
||
103 |
TInt CCacheNotifyDirChange::RegisterNotification(TPathListRecord* aPathRec, TNotifyType aType) |
|
104 |
// |
|
105 |
// Notification that a card has been mounted/removed |
|
106 |
// |
|
107 |
{ |
|
108 |
TDriveUnit drive(iDrive); |
|
109 |
TFileName pathName(drive.Name()); |
|
110 |
pathName.Append('\\'); |
|
111 |
TInt dl = pathName.Length(); |
|
112 |
const TText* ppp = pathName.Ptr() + dl; |
|
113 |
const TDesC8& p8 = *aPathRec->PathName(); |
|
114 |
TInt p8l = p8.Length(); |
|
115 |
pathName.SetLength(dl + p8l); |
|
116 |
TPtr pp((TText*)ppp, 0, KMaxFileName - dl); |
|
117 |
pp.Copy(p8); |
|
118 |
if (pathName[dl + p8l -1] != '\\') |
|
119 |
pathName.Append('\\'); |
|
120 |
||
121 |
__IF_DEBUG(Printf("RegisterNotification for drive %d path %S", iDrive, &p8)); |
|
122 |
__IF_DEBUG(Print(_L("register notification for %S"), &pathName)); |
|
123 |
gTheLoaderFs.NotifyChange(aType, iStatus, pathName); |
|
124 |
SetActive(); |
|
125 |
__LDRTRACE({ \ |
|
126 |
if (iStatus != KRequestPending) \ |
|
127 |
RDebug::Printf("Notifier Immediate Complete %d", iStatus.Int()); \ |
|
128 |
}); |
|
129 |
return KErrNone; |
|
130 |
} |
|
131 |
||
132 |
TInt SetupNotify(TDriveNumber aDrive, TDirectoryCacheHeader& aDirHead) |
|
133 |
{ |
|
134 |
if (aDirHead.iNotify != NULL) |
|
135 |
{ |
|
136 |
__IF_DEBUG(Printf("SetupNotify!! notification already registered on drive %d path %S", aDrive, aDirHead.iPath->PathName())); |
|
137 |
return KErrNone; |
|
138 |
} |
|
139 |
||
140 |
__IF_DEBUG(Printf("SetupNotify!! on drive %d path %S", aDrive, aDirHead.iPath->PathName())); |
|
141 |
CCacheNotifyDirChange* pNotifier = new CCacheNotifyDirChange(aDrive, aDirHead); |
|
142 |
if (!pNotifier) |
|
143 |
return KErrNoMemory; |
|
144 |
aDirHead.iNotify = pNotifier; |
|
145 |
CActiveSchedulerLoader::Add(pNotifier); |
|
146 |
return pNotifier->RegisterNotification(aDirHead.iPath, ENotifyFile); |
|
147 |
} |
|
148 |
||
149 |
TInt AddNotifications() |
|
150 |
{ |
|
151 |
TDriveNumber drive; |
|
152 |
for (drive=EDriveA; drive<EDriveZ; ((TInt&)drive)++) // Z always read-only so no notifiers required |
|
153 |
{ |
|
154 |
TDriveCacheHeader* pDH = gDriveFileNamesCache[drive]; |
|
155 |
if (!pDH) |
|
156 |
continue; |
|
157 |
||
158 |
__IF_DEBUG(Printf("AddNotifications on drive %d att=0x%08x", drive, pDH->iDriveAtt)); |
|
159 |
||
160 |
TDirectoryCacheHeader* p = pDH->iDirectoryList; |
|
161 |
for (; p; p=p->iNext) |
|
162 |
{ |
|
163 |
TInt r = SetupNotify(drive, *p); |
|
164 |
if (r != KErrNone) |
|
165 |
{ |
|
166 |
DestroyCachedDirectory(drive, p); |
|
167 |
return r; |
|
168 |
} |
|
169 |
} |
|
170 |
} |
|
171 |
gCacheCheckDrives = EFalse; |
|
172 |
return KErrNone; |
|
173 |
} |
|
174 |
||
175 |
//=============================== TFileCacheRecord ================================== |
|
176 |
// |
|
177 |
TInt TFileCacheRecord::Order(const TFileCacheRecord& aL, const TFileCacheRecord& aR) |
|
178 |
{ |
|
179 |
return aL.Name().CompareF(aR.Name()); |
|
180 |
} |
|
181 |
||
182 |
//=============================== TPathListRecord ================================== |
|
183 |
// |
|
184 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
185 |
void dumpPathList() |
|
186 |
{ |
|
187 |
RDebug::Printf("Dumping Pathlist"); |
|
188 |
TPathListRecord* p = TPathListRecord::First; |
|
189 |
TInt count=0; |
|
190 |
for (; p; p=p->iNext, ++count) |
|
191 |
RDebug::Printf("Pathlist pos %d %S",count,p->PathName()); |
|
192 |
} |
|
193 |
#endif |
|
194 |
||
195 |
_LIT8(KDirSystemPrograms, "System\\Programs"); |
|
196 |
_LIT8(KDirSystemLibs, "System\\Libs"); |
|
197 |
_LIT8(KDirSystemBin, "System\\Bin"); |
|
198 |
_LIT8(KDirSysBin, "Sys\\Bin"); |
|
199 |
||
200 |
TInt TPathListRecord::Init() |
|
201 |
{ |
|
202 |
if (!AddToPathList(KDirSysBin, ETrue)) |
|
203 |
return KErrNoMemory; |
|
204 |
if(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) |
|
205 |
{ |
|
206 |
if (!AddToPathList(KDirSystemPrograms, ETrue)) |
|
207 |
return KErrNoMemory; |
|
208 |
if (!AddToPathList(KDirSystemLibs, ETrue)) |
|
209 |
return KErrNoMemory; |
|
210 |
if (!AddToPathList(KDirSystemBin, ETrue)) |
|
211 |
return KErrNoMemory; |
|
212 |
} |
|
213 |
return KErrNone; |
|
214 |
} |
|
215 |
||
216 |
void TPathListRecord::MoveToHead() |
|
217 |
{ |
|
218 |
if (iKeep || this == LastStatic->iNext) |
|
219 |
return; |
|
220 |
TPathListRecord* p = First; |
|
221 |
// the record is always in the list |
|
222 |
for (; p && p->iNext!=this; p=p->iNext) {} |
|
223 |
__ASSERT_DEBUG(p, User::Invariant()); |
|
224 |
p->iNext = iNext; |
|
225 |
iNext = LastStatic->iNext; |
|
226 |
LastStatic->iNext = this; |
|
227 |
} |
|
228 |
||
229 |
TPathListRecord* TPathListRecord::FindPathNameInList(const TDesC8& aPath) |
|
230 |
{ |
|
231 |
__IF_DEBUG(Printf("TPathListRecord::FindPathNameInList %S",&aPath)); |
|
232 |
TPathListRecord* p = DoFindPathNameInList(aPath); |
|
233 |
if (!p) |
|
234 |
p = AddToPathList(aPath, EFalse); |
|
235 |
return p; |
|
236 |
} |
|
237 |
||
238 |
TPathListRecord* TPathListRecord::DoFindPathNameInList(const TDesC8& aPath) |
|
239 |
{ |
|
240 |
// Accesses pathname list to retrieve pathname record |
|
241 |
TPathListRecord* p = First; |
|
242 |
for (; p; p=p->iNext) |
|
243 |
{ |
|
244 |
if (p->PathName()->CompareF(aPath) == 0) |
|
245 |
{ |
|
246 |
p->MoveToHead(); |
|
247 |
return p; |
|
248 |
} |
|
249 |
} |
|
250 |
return NULL; |
|
251 |
} |
|
252 |
||
253 |
TPathListRecord* TPathListRecord::AddToPathList(const TDesC8& aPath, TBool aKeep) |
|
254 |
{ |
|
255 |
__LDRTRACE(dumpPathList()); |
|
256 |
__IF_DEBUG(Printf("Pathlist adding path %S keep %d",&aPath,aKeep)); |
|
257 |
||
258 |
TPathListRecord* n = TPathListRecord::New(aPath, aKeep); |
|
259 |
if (!n) |
|
260 |
return NULL; |
|
261 |
TPathListRecord* p = First; |
|
262 |
TPathListRecord* q = NULL; |
|
263 |
TInt count = 0; |
|
264 |
for (; p && ++count<KMaxCachedDirectories; q=p, p=p->iNext) {} |
|
265 |
if (p) |
|
266 |
{ |
|
267 |
// need to kill off entry pointed to by p |
|
268 |
__IF_DEBUG(Printf("In AddToPathList killing %S", p->PathName())); |
|
269 |
__ASSERT_ALWAYS(!aKeep, User::Invariant()); |
|
270 |
q->iNext = NULL; |
|
271 |
DestroyCachedDirectories(p); |
|
272 |
delete p; |
|
273 |
} |
|
274 |
||
275 |
if (aKeep) |
|
276 |
{ |
|
277 |
// add to front of list |
|
278 |
n->iNext = First; |
|
279 |
First = n; |
|
280 |
if (!LastStatic) |
|
281 |
LastStatic = n; |
|
282 |
} |
|
283 |
else |
|
284 |
{ |
|
285 |
// add new entry to front of dynamic list |
|
286 |
n->iNext = LastStatic->iNext; |
|
287 |
LastStatic->iNext = n; |
|
288 |
} |
|
289 |
||
290 |
// Refresh cache now we've added a new path |
|
291 |
gCacheCheckDrives = ETrue; |
|
292 |
||
293 |
__LDRTRACE(dumpPathList()); |
|
294 |
return n; |
|
295 |
} |
|
296 |
||
297 |
TPathListRecord* TPathListRecord::New(const TDesC8& aPath, TBool aKeep) |
|
298 |
{ |
|
299 |
TInt l = aPath.Length(); |
|
300 |
TInt size = sizeof(TPathListRecord) + Align4(l) + sizeof(TDesC8); |
|
301 |
TPathListRecord* p = (TPathListRecord*)User::Alloc(size); |
|
302 |
if (p) |
|
303 |
{ |
|
304 |
p->iNext = NULL; |
|
305 |
p->iKeep = aKeep; |
|
306 |
TInt* pb = (TInt*)(p+1); |
|
307 |
*pb = l; |
|
308 |
memcpy(pb+1, aPath.Ptr(), l); |
|
309 |
} |
|
310 |
return p; |
|
311 |
} |
|
312 |
||
313 |
void DestroyCachedDirectory(TDriveNumber aDrive, TPathListRecord* aPathRec) |
|
314 |
{ |
|
315 |
__IF_DEBUG(Printf("DestroyCachedDirectory drive=%d path=%S",aDrive,aPathRec->PathName())); |
|
316 |
TDriveCacheHeader* pDH = gDriveFileNamesCache[aDrive]; |
|
317 |
TDirectoryCacheHeader* p = pDH->iDirectoryList; |
|
318 |
TDirectoryCacheHeader* q = 0; |
|
319 |
for (; p && p->iPath!=aPathRec; q=p, p=p->iNext) {} |
|
320 |
if (p) |
|
321 |
{ |
|
322 |
__IF_DEBUG(Printf(" unlinking directory %S",p->iPath->PathName())); |
|
323 |
if (q) |
|
324 |
q->iNext = p->iNext; |
|
325 |
else |
|
326 |
pDH->iDirectoryList = p->iNext; |
|
327 |
__IF_DEBUG(Printf(" deleting directory %S",p->iPath->PathName())); |
|
328 |
delete p; |
|
329 |
} |
|
330 |
} |
|
331 |
||
332 |
void DestroyCachedDirectory(TDriveNumber aDrive, TDirectoryCacheHeader* aDirCache) |
|
333 |
{ |
|
334 |
// First see if it contained in our list |
|
335 |
__IF_DEBUG(Printf("DestroyCachedDirectory drive=%d path=%S", aDrive, aDirCache->iPath->PathName())); |
|
336 |
||
337 |
TDriveCacheHeader* pDH = gDriveFileNamesCache[aDrive]; |
|
338 |
TDirectoryCacheHeader* p = pDH->iDirectoryList; |
|
339 |
TDirectoryCacheHeader* q = 0; |
|
340 |
for (; p && p!=aDirCache; q=p, p=p->iNext) {} |
|
341 |
if (p) |
|
342 |
{ |
|
343 |
__IF_DEBUG(Printf(" unlinking directory %S",p->iPath->PathName())); |
|
344 |
if (q) |
|
345 |
q->iNext = p->iNext; |
|
346 |
else |
|
347 |
pDH->iDirectoryList = p->iNext; |
|
348 |
} |
|
349 |
__IF_DEBUG(Printf(" deleting directory %S", aDirCache->iPath->PathName())); |
|
350 |
delete aDirCache; |
|
351 |
} |
|
352 |
||
353 |
void DestroyCachedDirectories(TPathListRecord* aPathRec) |
|
354 |
{ |
|
355 |
__IF_DEBUG(Printf("DestroyCachedDirectories %S",aPathRec->PathName())); |
|
356 |
TDriveNumber drive; |
|
357 |
for (drive=EDriveA; drive<=EDriveZ; ((TInt&)drive)++) |
|
358 |
{ |
|
359 |
TDriveCacheHeader* pDH = gDriveFileNamesCache[drive]; |
|
360 |
if (pDH) |
|
361 |
{ |
|
362 |
__IF_DEBUG(Printf("DestroyCachedDirectories drive=%d driveatt=0x%08x",drive,pDH->iDriveAtt)); |
|
363 |
DestroyCachedDirectory(drive, aPathRec); |
|
364 |
} |
|
365 |
} |
|
366 |
} |
|
367 |
||
368 |
//=============================== TCacheHeapList ================================== |
|
369 |
// |
|
370 |
TCacheHeapList::TCacheHeapList(TInt aSize) |
|
371 |
: iAllocated(Align4(sizeof(TCacheHeapList))), |
|
372 |
iSize(aSize) |
|
373 |
{} |
|
374 |
||
375 |
TAny* TCacheHeapList::Allocate(TInt aBytes) |
|
376 |
{ |
|
377 |
__IF_DEBUG(Printf("TCacheHeapList::Allocate used=%d request=%d",iAllocated,aBytes)); |
|
378 |
TInt req = Align4(aBytes); |
|
379 |
if (iAllocated+req > iSize) |
|
380 |
return NULL; |
|
381 |
TAny* p = PtrAdd(this, iAllocated); |
|
382 |
iAllocated+=req; |
|
383 |
return p; |
|
384 |
} |
|
385 |
||
386 |
||
387 |
//=============================== TDriveCacheHeader================================== |
|
388 |
// |
|
389 |
TDriveCacheHeader::TDriveCacheHeader() |
|
390 |
: iDirectoryList(NULL) |
|
391 |
{} |
|
392 |
||
393 |
TDriveCacheHeader::~TDriveCacheHeader() |
|
394 |
{ |
|
395 |
__IF_DEBUG(Printf("~TDriveCacheHeader")); |
|
396 |
while (iDirectoryList) |
|
397 |
{ |
|
398 |
TDirectoryCacheHeader* p = iDirectoryList; |
|
399 |
iDirectoryList = p->iNext; |
|
400 |
__IF_DEBUG(Printf(" deleting directory %S",p->iPath->PathName())); |
|
401 |
delete p; |
|
402 |
} |
|
403 |
} |
|
404 |
||
405 |
TDirectoryCacheHeader* TDriveCacheHeader::FindDirCache(TPathListRecord* aPath) |
|
406 |
{ |
|
407 |
TDirectoryCacheHeader* p = iDirectoryList; |
|
408 |
for (; p && p->iPath!=aPath; p=p->iNext) {} |
|
409 |
return p; |
|
410 |
} |
|
411 |
||
412 |
TInt TDriveCacheHeader::GetDirCache(TDirectoryCacheHeader*& aCache, TPathListRecord* aPath, const TDesC8& aDriveAndPath) |
|
413 |
{ |
|
414 |
__IF_DEBUG(Printf(">GetDirCache %S", &aDriveAndPath)); |
|
415 |
aCache = FindDirCache(aPath); |
|
416 |
if (aCache) |
|
417 |
{ |
|
418 |
__IF_DEBUG(Printf("<GetDirCache already exists %08x", aCache)); |
|
419 |
return KErrNone; |
|
420 |
} |
|
421 |
TDirectoryCacheHeader* p = new TDirectoryCacheHeader(aPath); |
|
422 |
if (!p) |
|
423 |
return KErrNoMemory; |
|
424 |
TInt r = p->PopulateFromDrive(aDriveAndPath); |
|
425 |
__IF_DEBUG(Printf("PopulateFromDrive ret %d", r)); |
|
426 |
if (r != KErrNoMemory && r != KErrLocked && iDriveNumber != EDriveZ) |
|
427 |
r = SetupNotify((TDriveNumber)iDriveNumber, *p); |
|
428 |
if (r == KErrNoMemory || r == KErrLocked) |
|
429 |
{ |
|
430 |
delete p; |
|
431 |
return r; |
|
432 |
} |
|
433 |
// Ignore other errors and keep created entry anyway, so for things like 'path not found' |
|
434 |
// we have an empty directory cache which will get updated (via notification) if it get created. |
|
435 |
// This empty entry also allows for a quicker check the second time around. |
|
436 |
||
437 |
p->iNext = iDirectoryList; |
|
438 |
iDirectoryList = p; |
|
439 |
__IF_DEBUG(Printf("<GetDirCache new %08x", p)); |
|
440 |
aCache = p; |
|
441 |
return KErrNone; |
|
442 |
} |
|
443 |
||
444 |
//============================= TDirectoryCacheHeader================================ |
|
445 |
// |
|
446 |
TDirectoryCacheHeader::TDirectoryCacheHeader(TPathListRecord* aPath) |
|
447 |
: iFirstHeapBlock(NULL), iPath(aPath), iRecordCount(0), iCache(NULL), |
|
448 |
iNotPresent(ETrue), iNotify(NULL) |
|
449 |
{} |
|
450 |
||
451 |
TDirectoryCacheHeader::~TDirectoryCacheHeader() |
|
452 |
{ |
|
453 |
__IF_DEBUG(Printf("~TDirectoryCacheHeader %S",iPath->PathName())); |
|
454 |
User::Free(iCache); |
|
455 |
delete iNotify; |
|
456 |
||
457 |
while (iFirstHeapBlock) |
|
458 |
{ |
|
459 |
TCacheHeapList* p = iFirstHeapBlock; |
|
460 |
iFirstHeapBlock = p->iNext; |
|
461 |
User::Free(p); |
|
462 |
} |
|
463 |
} |
|
464 |
||
465 |
TInt TDirectoryCacheHeader::GetMoreHeap() |
|
466 |
{ |
|
467 |
TAny* mem = User::Alloc(KCacheHeapGranularity); |
|
468 |
if (!mem) |
|
469 |
return KErrNoMemory; |
|
470 |
TCacheHeapList* n = new (mem) TCacheHeapList(KCacheHeapGranularity); |
|
471 |
n->iNext = iFirstHeapBlock; |
|
472 |
iFirstHeapBlock = n; |
|
473 |
return KErrNone; |
|
474 |
} |
|
475 |
||
476 |
TAny* TDirectoryCacheHeader::Allocate(const TInt aBytes) |
|
477 |
{ |
|
478 |
TAny* p = iFirstHeapBlock ? iFirstHeapBlock->Allocate(aBytes) : NULL; |
|
479 |
if (!p) |
|
480 |
{ |
|
481 |
if (GetMoreHeap()!=KErrNone) |
|
482 |
return NULL; |
|
483 |
p = iFirstHeapBlock->Allocate(aBytes); |
|
484 |
} |
|
485 |
return p; |
|
486 |
} |
|
487 |
||
488 |
TFileCacheRecord* TDirectoryCacheHeader::NewRecord(const TDesC8& aName, TUint32 aAttr, TUint32 aVer, const TEntry& aEntry) |
|
489 |
{ |
|
490 |
TInt l = aName.Length(); |
|
491 |
TInt minsize = l + sizeof(TFileCacheRecord); |
|
492 |
TInt extra = aEntry.iSize >> 12; // allow for 8 exports per 4K of file |
|
493 |
if(extra>128) |
|
494 |
extra = 128; |
|
495 |
TInt size = (minsize + extra + 15) &~ 15; |
|
496 |
||
497 |
TFileCacheRecord* p = (TFileCacheRecord*)Allocate(size); |
|
498 |
if (p) |
|
499 |
{ |
|
500 |
memclr(p, sizeof(TFileCacheRecord)); |
|
501 |
p->iAttr = aAttr; |
|
502 |
p->iModuleVersion = aVer; |
|
503 |
p->iExportDirCount = size - minsize; |
|
504 |
p->iNameLength = l; |
|
505 |
p->iExportDescType = (aEntry.iAtt & KEntryAttXIP) ? KImageHdr_ExpD_Xip : KImageHdr_ExpD_NoHoles; // for now |
|
506 |
p->iCacheStatus = 0; |
|
507 |
memcpy(p+1, aName.Ptr(), l); |
|
508 |
} |
|
509 |
return p; |
|
510 |
} |
|
511 |
||
512 |
TFileCacheRecord* TDirectoryCacheHeader::NewRecord(const TFileCacheRecord& aRecord, TInt aEDS) |
|
513 |
{ |
|
514 |
TInt l = aRecord.Name().Length(); |
|
515 |
TInt minsize = l + sizeof(TFileCacheRecord); |
|
516 |
TInt extra = aEDS + 2; |
|
517 |
TInt size = (minsize + extra + 15) &~ 15; |
|
518 |
||
519 |
TFileCacheRecord* p = (TFileCacheRecord*)Allocate(size); |
|
520 |
if (p) |
|
521 |
{ |
|
522 |
memcpy(p, &aRecord, minsize); |
|
523 |
memclr((TUint8*)p + minsize, size - minsize); |
|
524 |
} |
|
525 |
return p; |
|
526 |
} |
|
527 |
||
528 |
TInt TDirectoryCacheHeader::PopulateFromDrive(const TDesC8& aPathName) |
|
529 |
{ |
|
530 |
// Wildcard searches through a named directory on a drive. |
|
531 |
// Creates and fills records to newly populate the drive cache.. |
|
532 |
||
533 |
// only want gen-u-ine files |
|
534 |
RDir d; |
|
535 |
TFileName dp; |
|
536 |
dp.Copy(aPathName); |
|
537 |
__IF_DEBUG(Print(_L("Opening Directory %S"), &dp)); |
|
538 |
||
539 |
iNotPresent=ETrue; |
|
540 |
TInt r=d.Open(gTheLoaderFs, dp, KEntryAttMatchExclude|KEntryAttDir|KEntryAttVolume); |
|
541 |
__IF_DEBUG(Printf("Returns %d", r)); |
|
542 |
if (r != KErrNone) |
|
543 |
{ |
|
544 |
return r; |
|
545 |
} |
|
546 |
||
547 |
TEntryArray array; |
|
548 |
TInt sizeofIndexArray=0; |
|
549 |
TFileCacheRecord** pIndexes=NULL; |
|
550 |
TInt currentIndex=0; |
|
551 |
do { |
|
552 |
r=d.Read(array); |
|
553 |
if (r==KErrNone || r==KErrEof) |
|
554 |
{ |
|
555 |
TInt count=array.Count(); |
|
556 |
if (count==0) |
|
557 |
break; |
|
558 |
TInt newSize=currentIndex+count; |
|
559 |
// Round alloc granularity up to the size of the cache cells, to avoid heap fragmentation when |
|
560 |
// indexing large dirs (z:\sys\bin) - interference effect is minimised by allocating in larger blocks and by |
|
561 |
// ensuring the freed memory can be reused for cache cells. See INC065949 for original defect. |
|
562 |
const TInt arrayGranularity = KCacheHeapGranularity + RHeap::EAllocCellSize; |
|
563 |
sizeofIndexArray = (sizeof(TFileCacheRecord*)*newSize + arrayGranularity - 1) / arrayGranularity * arrayGranularity; |
|
564 |
TFileCacheRecord** p=(TFileCacheRecord**)User::ReAlloc(pIndexes,sizeofIndexArray); |
|
565 |
if (!p) |
|
566 |
{ |
|
567 |
r=KErrNoMemory; |
|
568 |
break; |
|
569 |
} |
|
570 |
pIndexes=p; |
|
571 |
TInt i=0; |
|
572 |
while (i<count) |
|
573 |
{ |
|
574 |
const TEntry& e = array[i++]; |
|
575 |
TInt nl = e.iName.Length(); |
|
576 |
if (nl > KMaxKernelName) |
|
577 |
{ |
|
578 |
__IF_DEBUG(Printf("Name length %d - too long", nl)); |
|
579 |
continue; |
|
580 |
} |
|
581 |
TBuf8<KMaxKernelName> n8; |
|
582 |
r = CheckedCollapse(n8, e.iName); |
|
583 |
if (r != KErrNone) |
|
584 |
{ |
|
585 |
__IF_DEBUG(Printf("Non-ASCII name")); |
|
586 |
continue; |
|
587 |
} |
|
588 |
TFileNameInfo fni; |
|
589 |
r = fni.Set(n8, 0); |
|
590 |
if (r != KErrNone) |
|
591 |
{ |
|
592 |
__IF_DEBUG(Printf("Bad name")); |
|
593 |
continue; |
|
594 |
} |
|
595 |
TBuf8<KMaxKernelName> rootname; |
|
596 |
fni.GetName(rootname, TFileNameInfo::EIncludeBaseExt); |
|
597 |
TUint32 attr = fni.VerLen() ? ECodeSegAttExpVer : 0; |
|
598 |
TFileCacheRecord* pR = NewRecord(rootname, attr, fni.Version(), e); |
|
599 |
if (!pR) |
|
600 |
{ |
|
601 |
r=KErrNoMemory; |
|
602 |
break; |
|
603 |
} |
|
604 |
pIndexes[currentIndex] = pR; |
|
605 |
currentIndex++; |
|
606 |
} |
|
607 |
} |
|
608 |
} while (r==KErrNone); |
|
609 |
d.Close(); |
|
610 |
if(r==KErrNoMemory) |
|
611 |
return r; |
|
612 |
||
23
1df514389a47
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
613 |
iCache = (TFileCacheRecord**)User::ReAlloc(pIndexes,sizeof(TFileCacheRecord*)*currentIndex); |
1df514389a47
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
614 |
if(!iCache) |
1df514389a47
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
615 |
return KErrNoMemory; |
1df514389a47
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
616 |
|
0 | 617 |
iNotPresent = EFalse; |
618 |
iRecordCount = currentIndex; |
|
619 |
if (currentIndex>1) |
|
620 |
{ |
|
621 |
// don't sort an empty list, or a list with only 1 element |
|
622 |
RPointerArray<TFileCacheRecord> rarray(iCache, iRecordCount); |
|
623 |
rarray.Sort(&TFileCacheRecord::Order); |
|
624 |
} |
|
625 |
||
626 |
__LDRTRACE( { \ |
|
627 |
RDebug::Printf("RArray sorted"); \ |
|
628 |
TInt i; \ |
|
629 |
for (i=0; i<iRecordCount; i++) \ |
|
630 |
{ \ |
|
631 |
TFileCacheRecord* f = iCache[i]; \ |
|
632 |
const TDesC8& name = f->Name(); \ |
|
633 |
RDebug::Printf("%d: Entry=%S att %08x ver %08x", i, &name, f->iAttr, f->iModuleVersion); \ |
|
634 |
} \ |
|
635 |
}); |
|
636 |
return KErrNone; |
|
637 |
} |
|
638 |
||
639 |
TInt RefreshDriveInfo() |
|
640 |
{ |
|
641 |
// Find out what drives are present |
|
642 |
__IF_DEBUG(Printf(">RefreshDriveInfo")); |
|
643 |
TDriveList list; |
|
644 |
TInt r = gTheLoaderFs.DriveList(list); |
|
645 |
if (r!=KErrNone) |
|
646 |
{ |
|
647 |
return r; |
|
648 |
} |
|
649 |
TDriveInfo d; |
|
650 |
TDriveNumber drive; |
|
651 |
for (drive=EDriveA; drive<=EDriveZ; ((TInt&)drive)++) |
|
652 |
{ |
|
653 |
TInt att = list[drive]; |
|
654 |
if (att) |
|
655 |
{ |
|
656 |
r = gTheLoaderFs.Drive(d,drive); |
|
657 |
if (r != KErrNone) |
|
658 |
continue; |
|
659 |
if ((d.iDriveAtt & KDriveAttRemote) || (d.iDriveAtt & KDriveAttSubsted)) |
|
660 |
continue; //Don't cache remote or substituted drives |
|
661 |
if (gDriveFileNamesCache[drive] == NULL) |
|
662 |
{ |
|
663 |
__IF_DEBUG(Printf("In RefreshDriveInfo adding drive %d, drive= 0x%08x media=0x%08x", drive, d.iDriveAtt, d.iMediaAtt)); |
|
664 |
TDriveCacheHeader* pDH = new TDriveCacheHeader; |
|
665 |
if (!pDH) |
|
666 |
return KErrNoMemory; |
|
667 |
gDriveFileNamesCache[drive] = pDH; |
|
668 |
pDH->iDriveAtt = d.iDriveAtt; |
|
669 |
pDH->iDriveNumber = drive; |
|
670 |
} |
|
671 |
continue; |
|
672 |
} |
|
673 |
TDriveCacheHeader* pDH = gDriveFileNamesCache[drive]; |
|
674 |
delete pDH; |
|
675 |
gDriveFileNamesCache[drive] = NULL; |
|
676 |
} |
|
677 |
__IF_DEBUG(Printf("<RefreshDriveInfo")); |
|
678 |
return KErrNone; |
|
679 |
} |
|
680 |
||
681 |
// |
|
682 |
void InitializeFileNameCache() |
|
683 |
{ |
|
684 |
__IF_DEBUG(Printf("InitializeFileNameCache")); |
|
685 |
gInitCacheCheckDrivesAndAddNotifications = EFalse; |
|
686 |
gCacheCheckDrives = ETrue; |
|
687 |
__ASSERT_ALWAYS(TPathListRecord::Init()==KErrNone, User::Invariant()); |
|
688 |
} |
|
689 |
||
690 |
TInt CheckLoaderCacheInit() |
|
691 |
{ |
|
692 |
TInt r=KErrNone; |
|
693 |
if(RefreshZDriveCache) |
|
694 |
{ |
|
695 |
// force z: drive cache to be refreshed |
|
696 |
__IF_DEBUG(Print(_L("Deleting z: drive cache\r\n"))); |
|
697 |
TDriveCacheHeader* pDH=gDriveFileNamesCache[EDriveZ]; |
|
698 |
delete pDH; |
|
699 |
gDriveFileNamesCache[EDriveZ]=NULL; |
|
700 |
gCacheCheckDrives=ETrue; |
|
701 |
RefreshZDriveCache=EFalse; |
|
702 |
} |
|
703 |
if (gCacheCheckDrives) |
|
704 |
{ |
|
705 |
__IF_DEBUG(Printf("Refreshing cache")); |
|
706 |
r = RefreshDriveInfo(); // refreshing is a 'once-only' operation after setting |
|
707 |
gCacheCheckDrives = EFalse; // gCacheCheckDrives so as to prevent excessive refreshing |
|
708 |
} |
|
709 |
if (!gInitCacheCheckDrivesAndAddNotifications && StartupInitCompleted) |
|
710 |
{ |
|
711 |
__IF_DEBUG(Printf("Refreshing cache and adding notifications after FS initialisation")); |
|
712 |
r = RefreshDriveInfo(); // this is to provide an extra refresh to explicitly find |
|
713 |
r = AddNotifications(); // all drives set up during FS initialisation |
|
714 |
gInitCacheCheckDrivesAndAddNotifications = ETrue; |
|
715 |
} |
|
716 |
return r; |
|
717 |
} |
|
718 |
||
719 |
TFileCacheRecordSearch::TFileCacheRecordSearch(const TDesC8& aSearchName) |
|
720 |
{ |
|
721 |
iNameLength = aSearchName.Length(); |
|
722 |
if(iNameLength>sizeof(iSearchName)) |
|
723 |
User::Invariant(); |
|
724 |
memcpy(iSearchName, aSearchName.Ptr(), iNameLength); |
|
725 |
} |
|
726 |
||
727 |
TInt RImageFinder::SearchSingleDir() |
|
728 |
{ |
|
729 |
__IF_DEBUG(Printf("SearchSingleDir %S drive %d", &iCurrentPath, iCurrentDrive)); |
|
730 |
||
731 |
TDriveCacheHeader* pDH = gDriveFileNamesCache[iCurrentDrive]; |
|
732 |
if (!pDH) |
|
733 |
{ |
|
734 |
__IF_DEBUG(Printf("No such drive")); |
|
735 |
return KErrNone; |
|
736 |
} |
|
737 |
||
738 |
TInt pl = iCurrentPath.Length(); |
|
739 |
TInt start = 0; |
|
740 |
TInt len = pl; |
|
741 |
if (pl) |
|
742 |
{ |
|
743 |
if (iCurrentPath[0] == '\\') |
|
744 |
start = 1, --len; |
|
745 |
if (len>0 && iCurrentPath[start + len - 1] == '\\') |
|
746 |
--len; |
|
747 |
} |
|
748 |
TPtrC8 path(iCurrentPath.Mid(start, len)); |
|
749 |
__IF_DEBUG(Printf("Normalised path %S", &path)); |
|
750 |
TChar c; |
|
751 |
RFs::DriveToChar(iCurrentDrive, c); |
|
752 |
TBuf8<KMaxFileName> drive_and_path = _S8("?:\\"); |
|
753 |
drive_and_path[0] = (TText8)c; |
|
754 |
drive_and_path.Append(path); |
|
755 |
if (drive_and_path[drive_and_path.Length()-1] != '\\') |
|
756 |
drive_and_path.Append('\\'); |
|
757 |
||
758 |
TPathListRecord* prec = TPathListRecord::FindPathNameInList(path); |
|
759 |
if (!prec) |
|
760 |
return KErrNoMemory; |
|
761 |
TDirectoryCacheHeader* dch = NULL; |
|
762 |
TInt r = pDH->GetDirCache(dch, prec, drive_and_path); |
|
763 |
if (r != KErrNone || dch->iNotPresent || dch->iRecordCount==0) |
|
764 |
{ |
|
765 |
return r; |
|
766 |
} |
|
767 |
||
768 |
// set up to search for root name |
|
769 |
__IF_DEBUG(Printf("Search directory for %S", &iRootName)); |
|
770 |
TFileCacheRecordSearch search(iRootName); |
|
771 |
__LDRTRACE({const TDesC8& sr = search.Name(); RDebug::Printf("Search record %S", &sr);}); |
|
772 |
RPointerArray<TFileCacheRecord> rarray(dch->iCache, dch->iRecordCount); |
|
773 |
TInt first = rarray.SpecificFindInOrder(&search, &TFileCacheRecord::Order, EArrayFindMode_First); |
|
774 |
TInt last = rarray.SpecificFindInOrder(&search, &TFileCacheRecord::Order, EArrayFindMode_Last); |
|
775 |
__IF_DEBUG(Printf("First %d Last %d", first, last)); |
|
776 |
TInt ix; |
|
777 |
for (ix = first; ix < last; ++ix) |
|
778 |
{ |
|
779 |
TFileCacheRecord* f = dch->iCache[ix]; |
|
780 |
RImageInfo img_info; |
|
781 |
r = KErrNone; |
|
782 |
if (!f->ExtrasValid()) |
|
783 |
{ |
|
784 |
r = f->GetImageInfo(img_info, drive_and_path, dch, ix); |
|
785 |
if (r == KErrNoMemory) |
|
786 |
return r; |
|
787 |
f = dch->iCache[ix]; // may have been moved |
|
788 |
} |
|
789 |
if (r==KErrNone) |
|
790 |
{ |
|
791 |
img_info = *f; |
|
792 |
r = Try(img_info, f->Name(), drive_and_path); |
|
793 |
if (r == KErrNoMemory) |
|
794 |
{ |
|
795 |
img_info.Close(); |
|
796 |
return r; |
|
797 |
} |
|
798 |
f->iCacheStatus = img_info.iCacheStatus; |
|
799 |
} |
|
800 |
else |
|
801 |
RecordCorruptFile(); |
|
802 |
img_info.Close(); |
|
803 |
if (r==KErrCompletion) |
|
804 |
break; |
|
805 |
} |
|
806 |
return KErrNone; |
|
807 |
} |
|
808 |
||
809 |
// Populate the 'extras' in the cache record by reading the file header |
|
810 |
// aPathName must be of the form ?:\dir\...\dir\ so that a fully qualified file name is obtained by |
|
811 |
// appending the file name. |
|
812 |
TInt TFileCacheRecord::GetImageInfo(RImageInfo& aInfo, const TDesC8& aPathName, TDirectoryCacheHeader* aDirHead, TInt aIndex) |
|
813 |
{ |
|
814 |
const TDesC8& rootname = Name(); |
|
815 |
TBuf8<KMaxFileName> fn = aPathName; |
|
816 |
TFileNameInfo fni; |
|
817 |
fni.Set(rootname, 0); |
|
818 |
fni.iVersion = iModuleVersion; |
|
819 |
TUint flags = (iAttr & ECodeSegAttExpVer) ? TFileNameInfo::EForceVer : 0; |
|
820 |
fni.GetName(fn, TFileNameInfo::EIncludeBaseExt | flags); |
|
821 |
__IF_DEBUG(Printf("Opening file %S", &fn)); |
|
822 |
TInt r = OpenFile8(aInfo.iFile, fn); |
|
823 |
__IF_DEBUG(Printf("Open file returns %d", r)); |
|
824 |
if (r != KErrNone) |
|
825 |
return r; |
|
826 |
TInt address = 0; |
|
827 |
r = aInfo.iFile.Seek(ESeekAddress, address); |
|
828 |
if (r!=KErrNotSupported) |
|
829 |
{ |
|
830 |
__IF_DEBUG(Printf("ROM file at %08x", address)); |
|
831 |
TUint att; |
|
832 |
r = aInfo.iFile.Att(att); |
|
833 |
if (r!=KErrNone) |
|
834 |
{ |
|
835 |
aInfo.Close(); |
|
836 |
return r; |
|
837 |
} |
|
838 |
if (att & KEntryAttXIP) |
|
839 |
{ |
|
840 |
const TRomImageHeader& rih = *(const TRomImageHeader*)address; |
|
841 |
__IF_DEBUG(Printf("XIP file")); |
|
842 |
SetXIP(&rih); |
|
843 |
if ((iAttr & ECodeSegAttExpVer) && iModuleVersion != rih.iModuleVersion) |
|
844 |
{ |
|
845 |
// version in file name does not match version in header |
|
846 |
aInfo.Close(); |
|
847 |
return KErrBadName; |
|
848 |
} |
|
849 |
iModuleVersion = rih.iModuleVersion; |
|
850 |
iS = rih.iS; |
|
851 |
iExportDirCount = (TUint16)rih.iExportDirCount; |
|
852 |
iExportDescType = (TUint8)KImageHdr_ExpD_Xip; |
|
853 |
iAttr |= rih.iFlags & (KRomImageFlagFixedAddressExe|KRomImageABIMask); |
|
854 |
__LDRTRACE(Dump("Cached Info XIP")); |
|
855 |
return KErrNone; |
|
856 |
} |
|
857 |
} |
|
858 |
TFileCacheRecord* t = this; |
|
859 |
r = E32ImageHeader::New(aInfo.iHeader, aInfo.iFile); |
|
860 |
if (r != KErrNone) |
|
861 |
{ |
|
862 |
aInfo.Close(); |
|
863 |
__IF_DEBUG(Printf("E32ImageHeader::New returns %d", r)); |
|
864 |
return r; |
|
865 |
} |
|
866 |
E32ImageHeader* h = aInfo.iHeader; |
|
867 |
if ((iAttr & ECodeSegAttExpVer) && iModuleVersion != h->iModuleVersion) |
|
868 |
{ |
|
869 |
// version in file name does not match version in header |
|
870 |
aInfo.Close(); |
|
871 |
return KErrBadName; |
|
872 |
} |
|
873 |
wordmove(iUid, &h->iUid1, sizeof(iUid)); |
|
874 |
iModuleVersion = h->ModuleVersion(); |
|
875 |
h->GetSecurityInfo(iS); |
|
876 |
iAttr |= (h->iFlags & ECodeSegAttFixed) | h->ABI(); |
|
877 |
if(h->iFlags&KImageNmdExpData) |
|
878 |
iAttr |= ECodeSegAttNmdExpData; |
|
879 |
TUint avail = iExportDirCount; |
|
880 |
iExportDirCount = (TUint16)h->iExportDirCount; |
|
881 |
iExportDescType = KImageHdr_ExpD_NoHoles; |
|
882 |
||
883 |
// get export description... |
|
884 |
E32ImageHeaderV* v = (E32ImageHeaderV*)h; |
|
885 |
iExportDescType = v->iExportDescType; |
|
886 |
TUint eds = v->iExportDescSize; |
|
887 |
if (eds + 2 > avail) |
|
888 |
{ |
|
889 |
// must reallocate this entry |
|
890 |
t = aDirHead->NewRecord(*this, eds); |
|
891 |
if (!t) |
|
892 |
{ |
|
893 |
aInfo.Close(); |
|
894 |
return KErrNoMemory; |
|
895 |
} |
|
896 |
aDirHead->iCache[aIndex] = t; |
|
897 |
} |
|
898 |
TUint8* xd = (TUint8*)t->ExportDescription(); |
|
899 |
xd[0] = (TUint8)eds; |
|
900 |
xd[1] = (TUint8)(eds>>8); |
|
901 |
memcpy(xd+2, v->iExportDesc, eds); |
|
902 |
||
903 |
__LDRTRACE(t->Dump("Cached Info")); |
|
904 |
return KErrNone; |
|
905 |
} |
|
906 |
||
907 |
RImageInfo& RImageInfo::operator=(const TFileCacheRecord& aRecord) |
|
908 |
{ |
|
909 |
wordmove(this, &aRecord, sizeof(TImageInfo)); |
|
910 |
if (aRecord.ExtrasValid()) |
|
911 |
{ |
|
912 |
if (aRecord.IsXIP()) |
|
913 |
{ |
|
914 |
iRomImageHeader = aRecord.RomImageHeader(); |
|
915 |
wordmove(iUid, &iRomImageHeader->iUid1, sizeof(iUid)); |
|
916 |
} |
|
917 |
else if (iExportDescType != KImageHdr_ExpD_NoHoles) |
|
918 |
{ |
|
919 |
const TUint8* xd = (TUint8*)aRecord.ExportDescription(); |
|
920 |
iExportDescSize = (TUint16)(xd[0] | (xd[1]<<8)); |
|
921 |
iExportDesc = xd + 2; |
|
922 |
} |
|
923 |
} |
|
924 |
return *this; |
|
925 |
} |
|
926 |
||
927 |
||
928 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
929 |
extern void memory_dump(const TAny* a, TUint l); |
|
930 |
||
931 |
void TFileCacheRecord::Dump(const char* aTitle) |
|
932 |
{ |
|
933 |
RDebug::Printf(aTitle); |
|
934 |
TUint32 uid1 = iUid[0]; |
|
935 |
TBool xip = (uid1 != (TUint32)KExecutableImageUidValue && uid1 != (TUint32)KDynamicLibraryUidValue); |
|
936 |
const TDesC8& name = Name(); |
|
937 |
if (xip) |
|
938 |
{ |
|
939 |
const TRomImageHeader* rih = RomImageHeader(); |
|
940 |
RDebug::Printf("Name: %S Ver %08x Attr %08x", &name, rih->iModuleVersion, iAttr); |
|
941 |
RDebug::Printf("UIDS %08x %08x %08x SID %08x CAP %08x %08x", rih->iUid1, rih->iUid2, rih->iUid3, |
|
942 |
rih->iS.iSecureId, rih->iS.iCaps[1], rih->iS.iCaps[0]); |
|
943 |
RDebug::Printf("ExportDirCount %d ExportDescType %02x", rih->iExportDirCount, iExportDescType); |
|
944 |
} |
|
945 |
else |
|
946 |
{ |
|
947 |
RDebug::Printf("Name: %S Ver %08x Attr %08x", &name, iModuleVersion, iAttr); |
|
948 |
RDebug::Printf("UIDS %08x %08x %08x SID %08x CAP %08x %08x", iUid[0], iUid[1], iUid[2], |
|
949 |
iS.iSecureId, iS.iCaps[1], iS.iCaps[0]); |
|
950 |
RDebug::Printf("ExportDirCount %d ExportDescType %02x", iExportDirCount, iExportDescType); |
|
951 |
if (iExportDescType != KImageHdr_ExpD_NoHoles) |
|
952 |
{ |
|
953 |
const TUint8* xd = ExportDescription(); |
|
954 |
TUint eds = (xd[1]<<8) | xd[0]; |
|
955 |
RDebug::Printf("ExportDescSize %04x", eds); |
|
956 |
memory_dump(xd+2, eds); |
|
957 |
} |
|
958 |
} |
|
959 |
} |
|
960 |
#endif |
|
961 |
||
962 |