sl@0
|
1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// f32\sfile\sf_lwins.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "sf_std.h"
|
sl@0
|
19 |
#include <f32image.h>
|
sl@0
|
20 |
#include "sf_image.h"
|
sl@0
|
21 |
#include <e32uid.h>
|
sl@0
|
22 |
#include <emulator.h>
|
sl@0
|
23 |
#include <e32wins.h>
|
sl@0
|
24 |
#include <stdlib.h>
|
sl@0
|
25 |
#include <hal.h>
|
sl@0
|
26 |
|
sl@0
|
27 |
_LIT(KDirSystemPrograms,"\\System\\Programs\\");
|
sl@0
|
28 |
_LIT(KDirSystemLibs,"\\System\\Libs\\");
|
sl@0
|
29 |
_LIT8(KRomSystemLibs,"z:\\system\\libs\\");
|
sl@0
|
30 |
|
sl@0
|
31 |
_LIT(KDirSysBin,"\\sys\\bin\\");
|
sl@0
|
32 |
_LIT8(KRomSysBin,"z:\\sys\\bin\\");
|
sl@0
|
33 |
_LIT(KDirSystemBin,"\\System\\Bin\\");
|
sl@0
|
34 |
_LIT8(KRomSystemBin,"z:\\system\\Bin\\");
|
sl@0
|
35 |
|
sl@0
|
36 |
#ifdef _DEBUG
|
sl@0
|
37 |
extern TRequestStatus* ProcessDestructStatPtr;
|
sl@0
|
38 |
extern TBool ProcessCreated;
|
sl@0
|
39 |
#endif
|
sl@0
|
40 |
|
sl@0
|
41 |
|
sl@0
|
42 |
/******************************************************************************
|
sl@0
|
43 |
* Executable file find routines for WINS
|
sl@0
|
44 |
******************************************************************************/
|
sl@0
|
45 |
|
sl@0
|
46 |
TInt GetPEInfo(TProcessCreateInfo& aInfo)
|
sl@0
|
47 |
//
|
sl@0
|
48 |
// Extract the Uids, etc from the PE file
|
sl@0
|
49 |
//
|
sl@0
|
50 |
{
|
sl@0
|
51 |
TBuf<MAX_PATH> ifilename;
|
sl@0
|
52 |
ifilename.Copy(aInfo.iFileName);
|
sl@0
|
53 |
TBuf<MAX_PATH> filename;
|
sl@0
|
54 |
TInt r = MapEmulatedFileName(filename, ifilename);
|
sl@0
|
55 |
if (r == KErrNone)
|
sl@0
|
56 |
{
|
sl@0
|
57 |
Emulator::RImageFile pefile;
|
sl@0
|
58 |
r = pefile.Open((LPCTSTR)filename.PtrZ()); //SL: Added cast
|
sl@0
|
59 |
if (r == KErrNone)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
pefile.GetInfo(aInfo);
|
sl@0
|
62 |
// Overide capabilities in image
|
sl@0
|
63 |
for(TInt i=0; i<SCapabilitySet::ENCapW; i++)
|
sl@0
|
64 |
{
|
sl@0
|
65 |
aInfo.iS.iCaps[i] |= DisabledCapabilities[i];
|
sl@0
|
66 |
aInfo.iS.iCaps[i] &= AllCapabilities[i];
|
sl@0
|
67 |
}
|
sl@0
|
68 |
pefile.Close();
|
sl@0
|
69 |
}
|
sl@0
|
70 |
}
|
sl@0
|
71 |
return r;
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
TBool CheckIsDirectoryName(TProcessCreateInfo& aInfo)
|
sl@0
|
75 |
//
|
sl@0
|
76 |
// Attempt to get file attributes from Windows if attributes can't be found
|
sl@0
|
77 |
// just assume not a directory otherwise check the directory bit
|
sl@0
|
78 |
// Only intended for use by FindBin, FindDll and FindExe
|
sl@0
|
79 |
//
|
sl@0
|
80 |
{
|
sl@0
|
81 |
TBuf<MAX_PATH> ifilename;
|
sl@0
|
82 |
ifilename.Copy(aInfo.iFileName);
|
sl@0
|
83 |
TBuf<MAX_PATH> filename;
|
sl@0
|
84 |
if (MapEmulatedFileName(filename, ifilename) != KErrNone)
|
sl@0
|
85 |
return EFalse; // just return EFalse as the error will be picked up later
|
sl@0
|
86 |
|
sl@0
|
87 |
DWORD attr = Emulator::GetFileAttributes((LPCTSTR)filename.PtrZ());
|
sl@0
|
88 |
if (attr != -1 && (attr & FILE_ATTRIBUTE_DIRECTORY))
|
sl@0
|
89 |
return ETrue;
|
sl@0
|
90 |
return EFalse;
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
TInt FindBin(E32Image& aImage)
|
sl@0
|
94 |
//
|
sl@0
|
95 |
// WINS find Binary in system bin
|
sl@0
|
96 |
// System directories on all drives Y-A,Z
|
sl@0
|
97 |
//
|
sl@0
|
98 |
{
|
sl@0
|
99 |
__IF_DEBUG(Printf("FindBin"));
|
sl@0
|
100 |
|
sl@0
|
101 |
TInt len=aImage.iFileName.Length();
|
sl@0
|
102 |
// check if it's a bare drive letter with no path
|
sl@0
|
103 |
if (len>=3 && aImage.iFileName[1]==':' && aImage.iFileName[2]!='\\')
|
sl@0
|
104 |
{
|
sl@0
|
105 |
if (len + KRomSysBin().Length()-2 <= aImage.iFileName.MaxLength())
|
sl@0
|
106 |
aImage.iFileName.Insert(2,KRomSysBin().Mid(2));
|
sl@0
|
107 |
}
|
sl@0
|
108 |
|
sl@0
|
109 |
// Ensure consistent error codes with h/w, see DEF092502
|
sl@0
|
110 |
// Unlike Symbian on h/w targets, on Windows searching
|
sl@0
|
111 |
// for a driectory, including "." and "..", will return KErrorAccessDenied
|
sl@0
|
112 |
if (CheckIsDirectoryName(aImage))
|
sl@0
|
113 |
return KErrNotFound;
|
sl@0
|
114 |
|
sl@0
|
115 |
// first try and find it in the given directory
|
sl@0
|
116 |
TInt r=GetPEInfo(aImage);
|
sl@0
|
117 |
|
sl@0
|
118 |
// Next : if looking at z:\sys\bin then look for it in emulator path
|
sl@0
|
119 |
if (r == KErrNotFound || r == KErrPathNotFound)
|
sl@0
|
120 |
{
|
sl@0
|
121 |
if (aImage.iFileName.FindF(KRomSysBin) == 0)
|
sl@0
|
122 |
{
|
sl@0
|
123 |
aImage.iFileName.Delete(0, KRomSysBin().Length());
|
sl@0
|
124 |
r = GetPEInfo(aImage);
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
if (r==KErrNotFound || r == KErrPathNotFound)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
// Now try finding it in the EPOC scheme of things
|
sl@0
|
130 |
TBuf<MAX_PATH> ifilename;
|
sl@0
|
131 |
ifilename.Copy(aImage.iFileName);
|
sl@0
|
132 |
TFindFile ff(gTheLoaderFs);
|
sl@0
|
133 |
r=ff.FindByDir(ifilename,KDirSysBin);
|
sl@0
|
134 |
if (r==KErrNone)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
aImage.iFileName.Copy(ff.File());
|
sl@0
|
137 |
__IF_DEBUG(Printf("Found file %S",&aImage.iFileName));
|
sl@0
|
138 |
r=GetPEInfo(aImage);
|
sl@0
|
139 |
}
|
sl@0
|
140 |
else
|
sl@0
|
141 |
{
|
sl@0
|
142 |
// Last chance look in emulator path for driveless things
|
sl@0
|
143 |
if (aImage.iFileName.FindF(KRomSysBin().Mid(2)) == 0)
|
sl@0
|
144 |
{
|
sl@0
|
145 |
aImage.iFileName.Delete(0, KRomSysBin().Length()-2);
|
sl@0
|
146 |
r = GetPEInfo(aImage);
|
sl@0
|
147 |
}
|
sl@0
|
148 |
else
|
sl@0
|
149 |
{
|
sl@0
|
150 |
__IF_DEBUG(Printf("Filename %S not found in ?:\\sys\\bin",&aImage.iFileName));
|
sl@0
|
151 |
r=KErrNotFound;
|
sl@0
|
152 |
}
|
sl@0
|
153 |
}
|
sl@0
|
154 |
}
|
sl@0
|
155 |
}
|
sl@0
|
156 |
|
sl@0
|
157 |
if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
|
sl@0
|
158 |
return r;
|
sl@0
|
159 |
|
sl@0
|
160 |
// Next : if looking at z:\system\bin then look for it in emulator path
|
sl@0
|
161 |
if (r == KErrNotFound || r == KErrPathNotFound)
|
sl@0
|
162 |
{
|
sl@0
|
163 |
if (aImage.iFileName.FindF(KRomSystemBin) == 0)
|
sl@0
|
164 |
{
|
sl@0
|
165 |
aImage.iFileName.Delete(0, KRomSystemBin().Length());
|
sl@0
|
166 |
r = GetPEInfo(aImage);
|
sl@0
|
167 |
}
|
sl@0
|
168 |
|
sl@0
|
169 |
if (r==KErrNotFound || r == KErrPathNotFound)
|
sl@0
|
170 |
{
|
sl@0
|
171 |
// Now try finding it in the EPOC scheme of things
|
sl@0
|
172 |
TBuf<MAX_PATH> ifilename;
|
sl@0
|
173 |
ifilename.Copy(aImage.iFileName);
|
sl@0
|
174 |
TFindFile ff(gTheLoaderFs);
|
sl@0
|
175 |
r=ff.FindByDir(ifilename,KDirSystemBin);
|
sl@0
|
176 |
if (r==KErrNone)
|
sl@0
|
177 |
{
|
sl@0
|
178 |
aImage.iFileName.Copy(ff.File());
|
sl@0
|
179 |
__IF_DEBUG(Printf("Found file %S",&aImage.iFileName));
|
sl@0
|
180 |
r=GetPEInfo(aImage);
|
sl@0
|
181 |
}
|
sl@0
|
182 |
else
|
sl@0
|
183 |
{
|
sl@0
|
184 |
__IF_DEBUG(Printf("Filename %S not found",&aImage.iFileName));
|
sl@0
|
185 |
r=KErrNotFound;
|
sl@0
|
186 |
}
|
sl@0
|
187 |
}
|
sl@0
|
188 |
}
|
sl@0
|
189 |
return r;
|
sl@0
|
190 |
}
|
sl@0
|
191 |
|
sl@0
|
192 |
|
sl@0
|
193 |
TInt FindExe(E32Image& aImage)
|
sl@0
|
194 |
//
|
sl@0
|
195 |
// WINS find executable
|
sl@0
|
196 |
// System directories on all drives Y-A,Z
|
sl@0
|
197 |
//
|
sl@0
|
198 |
{
|
sl@0
|
199 |
__IF_DEBUG(Printf("FindExe"));
|
sl@0
|
200 |
|
sl@0
|
201 |
TInt len = aImage.iFileName.Length();
|
sl@0
|
202 |
// check if it's a bare drive letter with no path
|
sl@0
|
203 |
if (len >= 3 && aImage.iFileName[1]==':' && aImage.iFileName[2]!='\\')
|
sl@0
|
204 |
{
|
sl@0
|
205 |
if (len + KRomSysBin().Length()-2 <= aImage.iFileName.MaxLength())
|
sl@0
|
206 |
aImage.iFileName.Insert(2,KRomSysBin().Mid(2));
|
sl@0
|
207 |
}
|
sl@0
|
208 |
// Ensure consistent error codes with h/w, see DEF092502
|
sl@0
|
209 |
// Unlike Symbian on h/w targets, on Windows searching
|
sl@0
|
210 |
// for a driectory, including "." and "..", will return KErrorAccessDenied
|
sl@0
|
211 |
if (CheckIsDirectoryName(aImage))
|
sl@0
|
212 |
return KErrNotFound;
|
sl@0
|
213 |
|
sl@0
|
214 |
// first try and find it in the given directory
|
sl@0
|
215 |
TInt r=GetPEInfo(aImage);
|
sl@0
|
216 |
|
sl@0
|
217 |
// Next : if looking at z:\sys\bin then look for it in emulator path
|
sl@0
|
218 |
if (r == KErrNotFound || r == KErrPathNotFound)
|
sl@0
|
219 |
{
|
sl@0
|
220 |
if (aImage.iFileName.FindF(KRomSysBin) == 0)
|
sl@0
|
221 |
{
|
sl@0
|
222 |
aImage.iFileName.Delete(0, KRomSysBin().Length());
|
sl@0
|
223 |
r = GetPEInfo(aImage);
|
sl@0
|
224 |
}
|
sl@0
|
225 |
|
sl@0
|
226 |
if (r==KErrNotFound || r == KErrPathNotFound)
|
sl@0
|
227 |
{
|
sl@0
|
228 |
// Now try finding it in the EPOC scheme of things
|
sl@0
|
229 |
TBuf<MAX_PATH> ifilename;
|
sl@0
|
230 |
ifilename.Copy(aImage.iFileName);
|
sl@0
|
231 |
TFindFile ff(gTheLoaderFs);
|
sl@0
|
232 |
r=ff.FindByDir(ifilename,KDirSysBin);
|
sl@0
|
233 |
if (r==KErrNone)
|
sl@0
|
234 |
{
|
sl@0
|
235 |
aImage.iFileName.Copy(ff.File());
|
sl@0
|
236 |
__IF_DEBUG(Printf("Found file %S",&aImage.iFileName));
|
sl@0
|
237 |
r=GetPEInfo(aImage);
|
sl@0
|
238 |
}
|
sl@0
|
239 |
else
|
sl@0
|
240 |
{
|
sl@0
|
241 |
__IF_DEBUG(Printf("Filename %S not found in ?:\\sys\\bin",&aImage.iFileName));
|
sl@0
|
242 |
r=KErrNotFound;
|
sl@0
|
243 |
}
|
sl@0
|
244 |
}
|
sl@0
|
245 |
}
|
sl@0
|
246 |
|
sl@0
|
247 |
if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
|
sl@0
|
248 |
return r;
|
sl@0
|
249 |
|
sl@0
|
250 |
// Next : if looking at z:\system\libs then look for it in emulator path
|
sl@0
|
251 |
if (r == KErrNotFound || r == KErrPathNotFound)
|
sl@0
|
252 |
{
|
sl@0
|
253 |
if (aImage.iFileName.FindF(KRomSystemLibs) == 0)
|
sl@0
|
254 |
{
|
sl@0
|
255 |
aImage.iFileName.Delete(0, KRomSystemLibs().Length());
|
sl@0
|
256 |
r = GetPEInfo(aImage);
|
sl@0
|
257 |
}
|
sl@0
|
258 |
|
sl@0
|
259 |
if (r==KErrNotFound || r == KErrPathNotFound)
|
sl@0
|
260 |
{
|
sl@0
|
261 |
// Now try finding it in the EPOC scheme of things
|
sl@0
|
262 |
TBuf<MAX_PATH> ifilename;
|
sl@0
|
263 |
ifilename.Copy(aImage.iFileName);
|
sl@0
|
264 |
TFindFile ff(gTheLoaderFs);
|
sl@0
|
265 |
r=ff.FindByDir(ifilename,KDirSystemPrograms);
|
sl@0
|
266 |
if (r==KErrNone)
|
sl@0
|
267 |
{
|
sl@0
|
268 |
aImage.iFileName.Copy(ff.File());
|
sl@0
|
269 |
__IF_DEBUG(Printf("Found file %S",&aImage.iFileName));
|
sl@0
|
270 |
r=GetPEInfo(aImage);
|
sl@0
|
271 |
}
|
sl@0
|
272 |
else
|
sl@0
|
273 |
{
|
sl@0
|
274 |
__IF_DEBUG(Printf("Filename %S not found",&aImage.iFileName));
|
sl@0
|
275 |
r=KErrNotFound;
|
sl@0
|
276 |
}
|
sl@0
|
277 |
}
|
sl@0
|
278 |
}
|
sl@0
|
279 |
return r;
|
sl@0
|
280 |
}
|
sl@0
|
281 |
|
sl@0
|
282 |
// WINS FindDll
|
sl@0
|
283 |
TInt FindDll(E32Image& aImage, const TDesC8* aPath)
|
sl@0
|
284 |
//
|
sl@0
|
285 |
// Search for a dll in the following sequence ...
|
sl@0
|
286 |
// 1. Supplied path parameter
|
sl@0
|
287 |
// 2. System directories on all drives
|
sl@0
|
288 |
//
|
sl@0
|
289 |
{
|
sl@0
|
290 |
|
sl@0
|
291 |
TInt len = aImage.iFileName.Length();
|
sl@0
|
292 |
// check if it's a bare drive letter with no path
|
sl@0
|
293 |
if (len >=3 && aImage.iFileName[1]==':' && aImage.iFileName[2]!='\\')
|
sl@0
|
294 |
{
|
sl@0
|
295 |
if (len + KRomSysBin().Length()-2 <= aImage.iFileName.MaxLength())
|
sl@0
|
296 |
aImage.iFileName.Insert(2,KRomSysBin().Mid(2));
|
sl@0
|
297 |
}
|
sl@0
|
298 |
|
sl@0
|
299 |
// Ensure consistent error codes with h/w, see DEF092502
|
sl@0
|
300 |
// Unlike Symbian on h/w targets, on Windows searching
|
sl@0
|
301 |
// for a driectory, including "." and "..", will return KErrorAccessDenied
|
sl@0
|
302 |
if (CheckIsDirectoryName(aImage))
|
sl@0
|
303 |
return KErrNotFound;
|
sl@0
|
304 |
|
sl@0
|
305 |
TInt r=GetPEInfo(aImage);
|
sl@0
|
306 |
|
sl@0
|
307 |
// Next : if looking at z:\system\libs then look for it in emulator path
|
sl@0
|
308 |
if (r == KErrNotFound || r == KErrPathNotFound)
|
sl@0
|
309 |
{
|
sl@0
|
310 |
if (aImage.iFileName.FindF(KRomSysBin) == 0)
|
sl@0
|
311 |
{
|
sl@0
|
312 |
aImage.iFileName.Delete(0, KRomSysBin().Length());
|
sl@0
|
313 |
r = GetPEInfo(aImage);
|
sl@0
|
314 |
}
|
sl@0
|
315 |
|
sl@0
|
316 |
if(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
|
sl@0
|
317 |
if (r == KErrNotFound || r == KErrPathNotFound)
|
sl@0
|
318 |
if (aImage.iFileName.FindF(KRomSystemLibs) == 0)
|
sl@0
|
319 |
{
|
sl@0
|
320 |
aImage.iFileName.Delete(0, KRomSystemLibs().Length());
|
sl@0
|
321 |
r = GetPEInfo(aImage);
|
sl@0
|
322 |
}
|
sl@0
|
323 |
|
sl@0
|
324 |
TBuf<MAX_PATH> ifilename;
|
sl@0
|
325 |
ifilename.Copy(aImage.iFileName);
|
sl@0
|
326 |
if (r==KErrNotFound || r == KErrPathNotFound)
|
sl@0
|
327 |
{
|
sl@0
|
328 |
// Now try finding it in the EPOC scheme of things
|
sl@0
|
329 |
TFindFile ff(gTheLoaderFs);
|
sl@0
|
330 |
__IF_DEBUG(Printf("FindDll aDllName %S, aPath %S",&aImage.iFileName,aPath?aPath:&KNullDesC8));
|
sl@0
|
331 |
if (aPath && aPath->Length()!=0)
|
sl@0
|
332 |
{
|
sl@0
|
333 |
TBuf<MAX_PATH> ipath;
|
sl@0
|
334 |
ipath.Copy(*aPath);
|
sl@0
|
335 |
r=ff.FindByPath(ifilename, &ipath);
|
sl@0
|
336 |
if (r==KErrNone)
|
sl@0
|
337 |
{
|
sl@0
|
338 |
aImage.iFileName.Copy(ff.File());
|
sl@0
|
339 |
__IF_DEBUG(Printf("Found file %S",&aImage.iFileName));
|
sl@0
|
340 |
r=GetPEInfo(aImage);
|
sl@0
|
341 |
}
|
sl@0
|
342 |
}
|
sl@0
|
343 |
|
sl@0
|
344 |
if (r!=KErrNone)
|
sl@0
|
345 |
{
|
sl@0
|
346 |
r=ff.FindByDir(ifilename,KDirSysBin);
|
sl@0
|
347 |
if (r==KErrNone)
|
sl@0
|
348 |
{
|
sl@0
|
349 |
aImage.iFileName.Copy(ff.File());
|
sl@0
|
350 |
__IF_DEBUG(Printf("Found file %S",&aImage.iFileName));
|
sl@0
|
351 |
r=GetPEInfo(aImage);
|
sl@0
|
352 |
}
|
sl@0
|
353 |
}
|
sl@0
|
354 |
|
sl@0
|
355 |
if(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
|
sl@0
|
356 |
if (r!=KErrNone)
|
sl@0
|
357 |
{
|
sl@0
|
358 |
r=ff.FindByDir(ifilename,KDirSystemLibs);
|
sl@0
|
359 |
if (r==KErrNone)
|
sl@0
|
360 |
{
|
sl@0
|
361 |
aImage.iFileName.Copy(ff.File());
|
sl@0
|
362 |
__IF_DEBUG(Printf("Found file %S",&aImage.iFileName));
|
sl@0
|
363 |
r=GetPEInfo(aImage);
|
sl@0
|
364 |
}
|
sl@0
|
365 |
}
|
sl@0
|
366 |
|
sl@0
|
367 |
if(r!=KErrNone)
|
sl@0
|
368 |
{
|
sl@0
|
369 |
__IF_DEBUG(Printf("Filename %S not found",&aImage.iFileName));
|
sl@0
|
370 |
r=KErrNotFound;
|
sl@0
|
371 |
}
|
sl@0
|
372 |
}
|
sl@0
|
373 |
}
|
sl@0
|
374 |
return r;
|
sl@0
|
375 |
}
|
sl@0
|
376 |
|
sl@0
|
377 |
/******************************************************************************
|
sl@0
|
378 |
* WINS specific E32Image functions
|
sl@0
|
379 |
******************************************************************************/
|
sl@0
|
380 |
|
sl@0
|
381 |
TInt E32Image::ProcessFileName()
|
sl@0
|
382 |
//
|
sl@0
|
383 |
// Get the properly capitalised file name and root name
|
sl@0
|
384 |
//
|
sl@0
|
385 |
{
|
sl@0
|
386 |
|
sl@0
|
387 |
TFileNameInfo fni;
|
sl@0
|
388 |
TInt r = fni.Set(iFileName, 0);
|
sl@0
|
389 |
if (r!=KErrNone)
|
sl@0
|
390 |
return r;
|
sl@0
|
391 |
iRootNameOffset = fni.iBasePos;
|
sl@0
|
392 |
iRootNameLength = fni.iLen - fni.iBasePos;
|
sl@0
|
393 |
iExtOffset = fni.iExtPos;
|
sl@0
|
394 |
// TBuf<MAX_PATH> filename;
|
sl@0
|
395 |
// TInt r=MapEmulatedFileName(filename, iFileName);
|
sl@0
|
396 |
// if (r!=KErrNone)
|
sl@0
|
397 |
// return r;
|
sl@0
|
398 |
// WIN32_FIND_DATA w32fd;
|
sl@0
|
399 |
// HANDLE h=Emulator::FindFirstFile(filename.PtrZ(), &w32fd);
|
sl@0
|
400 |
// if (h==0)
|
sl@0
|
401 |
// return Emulator::LastError();
|
sl@0
|
402 |
// TPtrC real_filename((const TText*)&w32fd.cFileName[0]);
|
sl@0
|
403 |
// FindClose(h);
|
sl@0
|
404 |
// iFileName.SetLength(slash+1);
|
sl@0
|
405 |
// iFileName+=real_filename;
|
sl@0
|
406 |
__IF_DEBUG(Printf("ProcessFileName: %S,%d,%d,%d",&iFileName,iRootNameOffset,iRootNameLength,iExtOffset));
|
sl@0
|
407 |
return KErrNone;
|
sl@0
|
408 |
}
|
sl@0
|
409 |
|
sl@0
|
410 |
TInt E32Image::LoadProcess(const RLdrReq& aReq)
|
sl@0
|
411 |
{
|
sl@0
|
412 |
__IF_DEBUG(Printf("E32Image::LoadProcess %S",&aReq.iFileName));
|
sl@0
|
413 |
|
sl@0
|
414 |
iFileName=*aReq.iFileName;
|
sl@0
|
415 |
TInt r=FindExe(*this);
|
sl@0
|
416 |
if (r!=KErrNone)
|
sl@0
|
417 |
r=FindBin(*this);
|
sl@0
|
418 |
if (r==KErrNone)
|
sl@0
|
419 |
r=ProcessFileName();
|
sl@0
|
420 |
if (r==KErrNone)
|
sl@0
|
421 |
r=CheckUids(iUids, aReq.iRequestedUids);
|
sl@0
|
422 |
if (r!=KErrNone)
|
sl@0
|
423 |
return r;
|
sl@0
|
424 |
r = aReq.iMsg->Client((RThread&)aReq.iClientThread);
|
sl@0
|
425 |
if (r!=KErrNone)
|
sl@0
|
426 |
return r;
|
sl@0
|
427 |
iClientHandle=aReq.iClientThread.Handle();
|
sl@0
|
428 |
#ifdef _DEBUG
|
sl@0
|
429 |
iDestructStat = ProcessDestructStatPtr;
|
sl@0
|
430 |
#endif
|
sl@0
|
431 |
iFlags |= EDataUnpaged; // Data paging is not supported on the emulator
|
sl@0
|
432 |
r=E32Loader::ProcessCreate(*this, aReq.iCmd);
|
sl@0
|
433 |
__IF_DEBUG(Printf("Done E32Loader::ProcessCreate %d",r));
|
sl@0
|
434 |
if (r!=KErrNone)
|
sl@0
|
435 |
return r;
|
sl@0
|
436 |
#ifdef _DEBUG
|
sl@0
|
437 |
ProcessCreated = ETrue;
|
sl@0
|
438 |
#endif
|
sl@0
|
439 |
iClientProcessHandle=iProcessHandle;
|
sl@0
|
440 |
r=E32Loader::ProcessLoaded(*this);
|
sl@0
|
441 |
return r;
|
sl@0
|
442 |
}
|
sl@0
|
443 |
|
sl@0
|
444 |
// Load a code segment, plus all imports if main loadee
|
sl@0
|
445 |
TInt E32Image::LoadCodeSeg(const RLdrReq& aReq)
|
sl@0
|
446 |
{
|
sl@0
|
447 |
__IF_DEBUG(Printf("E32Image::LoadCodeSeg %S",aReq.iFileName));
|
sl@0
|
448 |
|
sl@0
|
449 |
const TDesC8& reqName=*aReq.iFileName;
|
sl@0
|
450 |
const TDesC8* searchPath=aReq.iPath;
|
sl@0
|
451 |
|
sl@0
|
452 |
iFileName=reqName;
|
sl@0
|
453 |
TInt r=FindDll(*this, searchPath);
|
sl@0
|
454 |
if (r!=KErrNone)
|
sl@0
|
455 |
r=FindBin(*this);
|
sl@0
|
456 |
// Hack to support EXEDLLs which are DLLs but have EXE file extentions
|
sl@0
|
457 |
if(r==KErrNotFound)
|
sl@0
|
458 |
{
|
sl@0
|
459 |
if(iFileName.Right(4).CompareF(_L8(".DLL"))==0)
|
sl@0
|
460 |
{
|
sl@0
|
461 |
TUint8* p = (TUint8*)iFileName.Ptr() + iFileName.Length() - 3;
|
sl@0
|
462 |
*p++ = 'E';
|
sl@0
|
463 |
*p++ = 'X';
|
sl@0
|
464 |
*p++ = 'E';
|
sl@0
|
465 |
r=FindDll(*this, searchPath);
|
sl@0
|
466 |
if (r!=KErrNone)
|
sl@0
|
467 |
r=FindBin(*this);
|
sl@0
|
468 |
}
|
sl@0
|
469 |
}
|
sl@0
|
470 |
if (r==KErrNone)
|
sl@0
|
471 |
r=ProcessFileName();
|
sl@0
|
472 |
if (r==KErrNone)
|
sl@0
|
473 |
r=CheckUids(iUids, aReq.iRequestedUids);
|
sl@0
|
474 |
|
sl@0
|
475 |
if(r==KErrNone)
|
sl@0
|
476 |
{
|
sl@0
|
477 |
if(this == iMain)
|
sl@0
|
478 |
{
|
sl@0
|
479 |
// Check that we can legally load the DLL into the process
|
sl@0
|
480 |
r=aReq.CheckSecInfo(iS);
|
sl@0
|
481 |
}
|
sl@0
|
482 |
}
|
sl@0
|
483 |
if (r!=KErrNone)
|
sl@0
|
484 |
return r;
|
sl@0
|
485 |
|
sl@0
|
486 |
__IF_DEBUG(Printf("Checking uids for %S", &iFileName));
|
sl@0
|
487 |
if (iUids[0]!=KDynamicLibraryUid && iUids[0]!=KExecutableImageUid)
|
sl@0
|
488 |
return KErrNotSupported;
|
sl@0
|
489 |
r=CheckAlreadyLoaded();
|
sl@0
|
490 |
if (r!=KErrNone || iAlreadyLoaded)
|
sl@0
|
491 |
{
|
sl@0
|
492 |
__IF_DEBUG(Printf("<LoadCodeSeg AlreadyLoaded %d",r));
|
sl@0
|
493 |
return r; // already loaded, either share or give up
|
sl@0
|
494 |
}
|
sl@0
|
495 |
__IF_DEBUG(Printf("CodeSeg create"));
|
sl@0
|
496 |
r=E32Loader::CodeSegCreate(*this);
|
sl@0
|
497 |
if (r==KErrNone)
|
sl@0
|
498 |
r=E32Loader::CodeSegLoaded(*this);
|
sl@0
|
499 |
|
sl@0
|
500 |
__IF_DEBUG(Printf("<LoadCodeSeg, r=%d",r));
|
sl@0
|
501 |
return r;
|
sl@0
|
502 |
}
|
sl@0
|
503 |
|
sl@0
|
504 |
//__DATA_CAGING__
|
sl@0
|
505 |
TInt ReadCapabilities(RLdrReq& aReq)
|
sl@0
|
506 |
//
|
sl@0
|
507 |
// Wins version
|
sl@0
|
508 |
//
|
sl@0
|
509 |
{
|
sl@0
|
510 |
E32Image* e=new E32Image;
|
sl@0
|
511 |
if (!e)
|
sl@0
|
512 |
return KErrNoMemory;
|
sl@0
|
513 |
e->iMain=e;
|
sl@0
|
514 |
e->iFileName=*aReq.iFileName;
|
sl@0
|
515 |
TInt r=GetPEInfo(*e);
|
sl@0
|
516 |
if (r==KErrNotFound || r == KErrPathNotFound)
|
sl@0
|
517 |
{
|
sl@0
|
518 |
// z:\sys\bin\* may be found in emulator path
|
sl@0
|
519 |
if (e->iFileName.FindF(KRomSysBin) == 0)
|
sl@0
|
520 |
{
|
sl@0
|
521 |
e->iFileName.Delete(0, KRomSysBin().Length());
|
sl@0
|
522 |
r = GetPEInfo(*e);
|
sl@0
|
523 |
}
|
sl@0
|
524 |
}
|
sl@0
|
525 |
|
sl@0
|
526 |
if(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
|
sl@0
|
527 |
if (r==KErrNotFound || r == KErrPathNotFound)
|
sl@0
|
528 |
{
|
sl@0
|
529 |
// z:\system\bin\* may be found in emulator path
|
sl@0
|
530 |
if (e->iFileName.FindF(KRomSystemBin) == 0)
|
sl@0
|
531 |
{
|
sl@0
|
532 |
e->iFileName.Delete(0, KRomSystemBin().Length());
|
sl@0
|
533 |
r = GetPEInfo(*e);
|
sl@0
|
534 |
}
|
sl@0
|
535 |
}
|
sl@0
|
536 |
TPtrC8 caps((const TUint8*)&e->iS.iCaps, sizeof(e->iS.iCaps));
|
sl@0
|
537 |
if (r==KErrNone)
|
sl@0
|
538 |
r=aReq.iMsg->Write(2, caps);
|
sl@0
|
539 |
delete e;
|
sl@0
|
540 |
return r;
|
sl@0
|
541 |
}
|
sl@0
|
542 |
|
sl@0
|
543 |
TInt GetModuleInfo(RLdrReq& aReq)
|
sl@0
|
544 |
//
|
sl@0
|
545 |
// Read capabilities from file found
|
sl@0
|
546 |
//
|
sl@0
|
547 |
{
|
sl@0
|
548 |
__IF_DEBUG(Printf("ReadModuleInfo %S",aReq.iFileName));
|
sl@0
|
549 |
TFileNameInfo& fi = aReq.iFileNameInfo;
|
sl@0
|
550 |
TInt r = KErrNotSupported;
|
sl@0
|
551 |
|
sl@0
|
552 |
// must specify a fully qualified name
|
sl@0
|
553 |
if (fi.DriveLen() && fi.PathLen())
|
sl@0
|
554 |
{
|
sl@0
|
555 |
E32Image* e=new E32Image;
|
sl@0
|
556 |
if (!e)
|
sl@0
|
557 |
return KErrNoMemory;
|
sl@0
|
558 |
e->iMain = e;
|
sl@0
|
559 |
e->iFileName = *aReq.iFileName;
|
sl@0
|
560 |
r = GetPEInfo(*e);
|
sl@0
|
561 |
if (r==KErrNotFound || r == KErrPathNotFound)
|
sl@0
|
562 |
{
|
sl@0
|
563 |
// z:\system\bin\* may be found in emulator path
|
sl@0
|
564 |
if (e->iFileName.FindF(KRomSysBin) == 0)
|
sl@0
|
565 |
{
|
sl@0
|
566 |
e->iFileName.Delete(0, KRomSysBin().Length());
|
sl@0
|
567 |
r = GetPEInfo(*e);
|
sl@0
|
568 |
}
|
sl@0
|
569 |
|
sl@0
|
570 |
if(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
|
sl@0
|
571 |
if(r!=KErrNone)
|
sl@0
|
572 |
if (e->iFileName.FindF(KRomSystemBin) == 0)
|
sl@0
|
573 |
{
|
sl@0
|
574 |
e->iFileName.Delete(0, KRomSystemBin().Length());
|
sl@0
|
575 |
r = GetPEInfo(*e);
|
sl@0
|
576 |
}
|
sl@0
|
577 |
}
|
sl@0
|
578 |
if (r == KErrNone)
|
sl@0
|
579 |
{
|
sl@0
|
580 |
RLibrary::TInfo ret_info;
|
sl@0
|
581 |
memclr(&ret_info,sizeof(ret_info));
|
sl@0
|
582 |
ret_info.iModuleVersion = e->iModuleVersion;
|
sl@0
|
583 |
ret_info.iUids = e->iUids;
|
sl@0
|
584 |
*(SSecurityInfo*)&ret_info.iSecurityInfo = e->iS;
|
sl@0
|
585 |
TPckgC<RLibrary::TInfo> ret_pckg(ret_info);
|
sl@0
|
586 |
r = aReq.iMsg->Write(2, ret_pckg);
|
sl@0
|
587 |
}
|
sl@0
|
588 |
delete e;
|
sl@0
|
589 |
}
|
sl@0
|
590 |
return r;
|
sl@0
|
591 |
}
|
sl@0
|
592 |
|
sl@0
|
593 |
TInt GetInfoFromHeader(const RLoaderMsg& /*aMsg*/)
|
sl@0
|
594 |
{
|
sl@0
|
595 |
TInt r;
|
sl@0
|
596 |
r = KErrNotSupported;
|
sl@0
|
597 |
return r;
|
sl@0
|
598 |
}
|
sl@0
|
599 |
|
sl@0
|
600 |
|
sl@0
|
601 |
|