os/kernelhwsrv/userlibandfileserver/fileserver/sfile/sf_lwins.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/sfile/sf_lwins.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,601 @@
     1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// f32\sfile\sf_lwins.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "sf_std.h"
    1.22 +#include <f32image.h>
    1.23 +#include "sf_image.h"
    1.24 +#include <e32uid.h>
    1.25 +#include <emulator.h>
    1.26 +#include <e32wins.h>
    1.27 +#include <stdlib.h>
    1.28 +#include <hal.h>
    1.29 +
    1.30 +_LIT(KDirSystemPrograms,"\\System\\Programs\\");
    1.31 +_LIT(KDirSystemLibs,"\\System\\Libs\\");
    1.32 +_LIT8(KRomSystemLibs,"z:\\system\\libs\\");
    1.33 +
    1.34 +_LIT(KDirSysBin,"\\sys\\bin\\");
    1.35 +_LIT8(KRomSysBin,"z:\\sys\\bin\\");
    1.36 +_LIT(KDirSystemBin,"\\System\\Bin\\");
    1.37 +_LIT8(KRomSystemBin,"z:\\system\\Bin\\");
    1.38 +
    1.39 +#ifdef _DEBUG
    1.40 +extern TRequestStatus* ProcessDestructStatPtr;
    1.41 +extern TBool ProcessCreated;
    1.42 +#endif
    1.43 +
    1.44 +
    1.45 +/******************************************************************************
    1.46 + * Executable file find routines for WINS
    1.47 + ******************************************************************************/
    1.48 +
    1.49 +TInt GetPEInfo(TProcessCreateInfo& aInfo)
    1.50 +//
    1.51 +// Extract the Uids, etc from the PE file
    1.52 +//
    1.53 +	{
    1.54 +	TBuf<MAX_PATH> ifilename;
    1.55 +	ifilename.Copy(aInfo.iFileName);
    1.56 +	TBuf<MAX_PATH> filename;
    1.57 +	TInt r = MapEmulatedFileName(filename, ifilename);
    1.58 +	if (r == KErrNone)
    1.59 +		{
    1.60 +		Emulator::RImageFile pefile;
    1.61 +		r = pefile.Open((LPCTSTR)filename.PtrZ()); //SL: Added cast
    1.62 +		if (r == KErrNone)
    1.63 +			{
    1.64 +			pefile.GetInfo(aInfo);
    1.65 +			// Overide capabilities in image
    1.66 +			for(TInt i=0; i<SCapabilitySet::ENCapW; i++)
    1.67 +				{
    1.68 +				aInfo.iS.iCaps[i] |= DisabledCapabilities[i];
    1.69 +				aInfo.iS.iCaps[i] &= AllCapabilities[i];
    1.70 +				}
    1.71 +			pefile.Close();
    1.72 +			}
    1.73 +		}
    1.74 +	return r;
    1.75 +	}
    1.76 +
    1.77 +TBool CheckIsDirectoryName(TProcessCreateInfo& aInfo)
    1.78 +//
    1.79 +// Attempt to get file attributes from Windows if attributes can't be found 
    1.80 +// just assume not a directory otherwise check the directory bit
    1.81 +// Only intended for use by FindBin, FindDll and FindExe
    1.82 +//
    1.83 +	{	
    1.84 +	TBuf<MAX_PATH> ifilename;
    1.85 +	ifilename.Copy(aInfo.iFileName);
    1.86 +	TBuf<MAX_PATH> filename;
    1.87 +	if (MapEmulatedFileName(filename, ifilename) != KErrNone)
    1.88 +		return EFalse; // just return EFalse as the error will be picked up later
    1.89 +	
    1.90 +	DWORD attr = Emulator::GetFileAttributes((LPCTSTR)filename.PtrZ());
    1.91 +	if (attr != -1 && (attr & FILE_ATTRIBUTE_DIRECTORY))
    1.92 +		return ETrue;
    1.93 +	return EFalse;
    1.94 +	}
    1.95 +
    1.96 +TInt FindBin(E32Image& aImage)
    1.97 +//
    1.98 +// WINS find Binary in system bin
    1.99 +// System directories on all drives Y-A,Z
   1.100 +//
   1.101 +	{
   1.102 +	__IF_DEBUG(Printf("FindBin"));
   1.103 +
   1.104 +	TInt len=aImage.iFileName.Length();
   1.105 +	// check if it's a bare drive letter with no path
   1.106 +	if (len>=3 && aImage.iFileName[1]==':' && aImage.iFileName[2]!='\\')
   1.107 +		{
   1.108 +		if (len + KRomSysBin().Length()-2 <= aImage.iFileName.MaxLength())
   1.109 +			aImage.iFileName.Insert(2,KRomSysBin().Mid(2));
   1.110 +		}
   1.111 +	
   1.112 +	// Ensure consistent error codes with h/w, see DEF092502
   1.113 +	// Unlike Symbian on h/w targets, on Windows searching 
   1.114 +	// for a driectory, including "." and "..", will return KErrorAccessDenied
   1.115 +	if (CheckIsDirectoryName(aImage))
   1.116 +		return KErrNotFound;	
   1.117 +	
   1.118 +	// first try and find it in the given directory
   1.119 +	TInt r=GetPEInfo(aImage);
   1.120 +
   1.121 +	// Next : if looking at z:\sys\bin then look for it in emulator path
   1.122 +	if (r == KErrNotFound || r == KErrPathNotFound)
   1.123 +		{
   1.124 +		if (aImage.iFileName.FindF(KRomSysBin) == 0)
   1.125 +			{
   1.126 +			aImage.iFileName.Delete(0, KRomSysBin().Length());
   1.127 +			r = GetPEInfo(aImage);
   1.128 +			}
   1.129 +
   1.130 +		if (r==KErrNotFound || r == KErrPathNotFound)
   1.131 +			{
   1.132 +			//	Now try finding it in the EPOC scheme of things
   1.133 +			TBuf<MAX_PATH> ifilename;
   1.134 +			ifilename.Copy(aImage.iFileName);
   1.135 +			TFindFile ff(gTheLoaderFs);
   1.136 +			r=ff.FindByDir(ifilename,KDirSysBin);
   1.137 +			if (r==KErrNone)
   1.138 +				{
   1.139 +				aImage.iFileName.Copy(ff.File());
   1.140 +				__IF_DEBUG(Printf("Found file %S",&aImage.iFileName));
   1.141 +				r=GetPEInfo(aImage);
   1.142 +				}
   1.143 +			else
   1.144 +				{
   1.145 +				// Last chance look in emulator path for driveless things
   1.146 +				if (aImage.iFileName.FindF(KRomSysBin().Mid(2)) == 0)
   1.147 +					{
   1.148 +					aImage.iFileName.Delete(0, KRomSysBin().Length()-2);
   1.149 +					r = GetPEInfo(aImage);
   1.150 +					}
   1.151 +				else 
   1.152 +					{
   1.153 +					__IF_DEBUG(Printf("Filename %S not found in ?:\\sys\\bin",&aImage.iFileName));
   1.154 +					r=KErrNotFound;
   1.155 +					}
   1.156 +				}
   1.157 +			}
   1.158 +		}
   1.159 +
   1.160 +	if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
   1.161 +		return r;
   1.162 +
   1.163 +	// Next : if looking at z:\system\bin then look for it in emulator path
   1.164 +	if (r == KErrNotFound || r == KErrPathNotFound)
   1.165 +		{
   1.166 +		if (aImage.iFileName.FindF(KRomSystemBin) == 0)
   1.167 +			{
   1.168 +			aImage.iFileName.Delete(0, KRomSystemBin().Length());
   1.169 +			r = GetPEInfo(aImage);
   1.170 +			}
   1.171 +
   1.172 +		if (r==KErrNotFound || r == KErrPathNotFound)
   1.173 +			{
   1.174 +			//	Now try finding it in the EPOC scheme of things
   1.175 +			TBuf<MAX_PATH> ifilename;
   1.176 +			ifilename.Copy(aImage.iFileName);
   1.177 +			TFindFile ff(gTheLoaderFs);
   1.178 +			r=ff.FindByDir(ifilename,KDirSystemBin);
   1.179 +			if (r==KErrNone)
   1.180 +				{
   1.181 +				aImage.iFileName.Copy(ff.File());
   1.182 +				__IF_DEBUG(Printf("Found file %S",&aImage.iFileName));
   1.183 +				r=GetPEInfo(aImage);
   1.184 +				}
   1.185 +			else
   1.186 +				{
   1.187 +				__IF_DEBUG(Printf("Filename %S not found",&aImage.iFileName));
   1.188 +				r=KErrNotFound;
   1.189 +				}
   1.190 +			}
   1.191 +		}
   1.192 +	return r;
   1.193 +	}
   1.194 +
   1.195 +
   1.196 +TInt FindExe(E32Image& aImage)
   1.197 +//
   1.198 +// WINS find executable
   1.199 +// System directories on all drives Y-A,Z
   1.200 +//
   1.201 +	{
   1.202 +	__IF_DEBUG(Printf("FindExe"));
   1.203 +
   1.204 +	TInt len  = aImage.iFileName.Length();
   1.205 +	// check if it's a bare drive letter with no path
   1.206 +	if (len >= 3 && aImage.iFileName[1]==':' && aImage.iFileName[2]!='\\')
   1.207 +		{
   1.208 +		if (len + KRomSysBin().Length()-2 <= aImage.iFileName.MaxLength())
   1.209 +			aImage.iFileName.Insert(2,KRomSysBin().Mid(2));
   1.210 +		}
   1.211 +	// Ensure consistent error codes with h/w, see DEF092502
   1.212 +	// Unlike Symbian on h/w targets, on Windows searching 
   1.213 +	// for a driectory, including "." and "..", will return KErrorAccessDenied
   1.214 +	if (CheckIsDirectoryName(aImage))
   1.215 +		return KErrNotFound;
   1.216 +	
   1.217 +	// first try and find it in the given directory
   1.218 +	TInt r=GetPEInfo(aImage);
   1.219 +
   1.220 +	// Next : if looking at z:\sys\bin then look for it in emulator path
   1.221 +	if (r == KErrNotFound || r == KErrPathNotFound)
   1.222 +		{
   1.223 +		if (aImage.iFileName.FindF(KRomSysBin) == 0)
   1.224 +			{
   1.225 +			aImage.iFileName.Delete(0, KRomSysBin().Length());
   1.226 +			r = GetPEInfo(aImage);
   1.227 +			}
   1.228 +
   1.229 +		if (r==KErrNotFound || r == KErrPathNotFound)
   1.230 +			{
   1.231 +			//	Now try finding it in the EPOC scheme of things
   1.232 +			TBuf<MAX_PATH> ifilename;
   1.233 +			ifilename.Copy(aImage.iFileName);
   1.234 +			TFindFile ff(gTheLoaderFs);
   1.235 +			r=ff.FindByDir(ifilename,KDirSysBin);
   1.236 +			if (r==KErrNone)
   1.237 +				{
   1.238 +				aImage.iFileName.Copy(ff.File());
   1.239 +				__IF_DEBUG(Printf("Found file %S",&aImage.iFileName));
   1.240 +				r=GetPEInfo(aImage);
   1.241 +				}
   1.242 +			else
   1.243 +				{
   1.244 +				__IF_DEBUG(Printf("Filename %S not found in ?:\\sys\\bin",&aImage.iFileName));
   1.245 +				r=KErrNotFound;
   1.246 +				}
   1.247 +			}
   1.248 +		}
   1.249 +
   1.250 +	if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
   1.251 +		return r;
   1.252 +
   1.253 +	// Next : if looking at z:\system\libs then look for it in emulator path
   1.254 +	if (r == KErrNotFound || r == KErrPathNotFound)
   1.255 +		{
   1.256 +		if (aImage.iFileName.FindF(KRomSystemLibs) == 0)
   1.257 +			{
   1.258 +			aImage.iFileName.Delete(0, KRomSystemLibs().Length());
   1.259 +			r = GetPEInfo(aImage);
   1.260 +			}
   1.261 +
   1.262 +		if (r==KErrNotFound || r == KErrPathNotFound)
   1.263 +			{
   1.264 +			//	Now try finding it in the EPOC scheme of things
   1.265 +			TBuf<MAX_PATH> ifilename;
   1.266 +			ifilename.Copy(aImage.iFileName);
   1.267 +			TFindFile ff(gTheLoaderFs);
   1.268 +			r=ff.FindByDir(ifilename,KDirSystemPrograms);
   1.269 +			if (r==KErrNone)
   1.270 +				{
   1.271 +				aImage.iFileName.Copy(ff.File());
   1.272 +				__IF_DEBUG(Printf("Found file %S",&aImage.iFileName));
   1.273 +				r=GetPEInfo(aImage);
   1.274 +				}
   1.275 +			else
   1.276 +				{
   1.277 +				__IF_DEBUG(Printf("Filename %S not found",&aImage.iFileName));
   1.278 +				r=KErrNotFound;
   1.279 +				}
   1.280 +			}
   1.281 +		}
   1.282 +	return r;
   1.283 +	}
   1.284 +
   1.285 +// WINS FindDll
   1.286 +TInt FindDll(E32Image& aImage, const TDesC8* aPath)
   1.287 +//
   1.288 +// Search for a dll in the following sequence ...
   1.289 +// 1. Supplied path parameter
   1.290 +// 2. System directories on all drives
   1.291 +//
   1.292 +	{
   1.293 +
   1.294 +	TInt len = aImage.iFileName.Length();
   1.295 +	// check if it's a bare drive letter with no path
   1.296 +	if (len >=3 && aImage.iFileName[1]==':' && aImage.iFileName[2]!='\\')
   1.297 +		{
   1.298 +		if (len + KRomSysBin().Length()-2 <= aImage.iFileName.MaxLength())
   1.299 +			aImage.iFileName.Insert(2,KRomSysBin().Mid(2));
   1.300 +		}
   1.301 +	
   1.302 +	// Ensure consistent error codes with h/w, see DEF092502
   1.303 +	// Unlike Symbian on h/w targets, on Windows searching 
   1.304 +	// for a driectory, including "." and "..", will return KErrorAccessDenied
   1.305 +	if (CheckIsDirectoryName(aImage))
   1.306 +		return KErrNotFound;
   1.307 +	
   1.308 +	TInt r=GetPEInfo(aImage);
   1.309 +
   1.310 +	// Next : if looking at z:\system\libs then look for it in emulator path
   1.311 +	if (r == KErrNotFound || r == KErrPathNotFound)
   1.312 +		{
   1.313 +		if (aImage.iFileName.FindF(KRomSysBin) == 0)
   1.314 +			{
   1.315 +			aImage.iFileName.Delete(0, KRomSysBin().Length());
   1.316 +			r = GetPEInfo(aImage);
   1.317 +			}
   1.318 +
   1.319 +		if(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
   1.320 +			if (r == KErrNotFound || r == KErrPathNotFound)
   1.321 +				if (aImage.iFileName.FindF(KRomSystemLibs) == 0)
   1.322 +					{
   1.323 +					aImage.iFileName.Delete(0, KRomSystemLibs().Length());
   1.324 +					r = GetPEInfo(aImage);
   1.325 +					}
   1.326 +
   1.327 +		TBuf<MAX_PATH> ifilename;
   1.328 +		ifilename.Copy(aImage.iFileName);
   1.329 +		if (r==KErrNotFound || r == KErrPathNotFound)
   1.330 +			{
   1.331 +			//	Now try finding it in the EPOC scheme of things
   1.332 +			TFindFile ff(gTheLoaderFs);
   1.333 +			__IF_DEBUG(Printf("FindDll aDllName %S, aPath %S",&aImage.iFileName,aPath?aPath:&KNullDesC8));
   1.334 +			if (aPath && aPath->Length()!=0)
   1.335 +				{
   1.336 +				TBuf<MAX_PATH> ipath;
   1.337 +				ipath.Copy(*aPath);
   1.338 +				r=ff.FindByPath(ifilename, &ipath);
   1.339 +				if (r==KErrNone)
   1.340 +					{
   1.341 +					aImage.iFileName.Copy(ff.File());
   1.342 +					__IF_DEBUG(Printf("Found file %S",&aImage.iFileName));
   1.343 +					r=GetPEInfo(aImage);
   1.344 +					}
   1.345 +				}
   1.346 +
   1.347 +			if (r!=KErrNone)
   1.348 +				{
   1.349 +				r=ff.FindByDir(ifilename,KDirSysBin);
   1.350 +				if (r==KErrNone)
   1.351 +					{
   1.352 +					aImage.iFileName.Copy(ff.File());
   1.353 +					__IF_DEBUG(Printf("Found file %S",&aImage.iFileName));
   1.354 +					r=GetPEInfo(aImage);
   1.355 +					}
   1.356 +				}
   1.357 +
   1.358 +			if(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
   1.359 +				if (r!=KErrNone)
   1.360 +					{
   1.361 +					r=ff.FindByDir(ifilename,KDirSystemLibs);
   1.362 +					if (r==KErrNone)
   1.363 +						{
   1.364 +						aImage.iFileName.Copy(ff.File());
   1.365 +						__IF_DEBUG(Printf("Found file %S",&aImage.iFileName));
   1.366 +						r=GetPEInfo(aImage);
   1.367 +						}
   1.368 +					}
   1.369 +
   1.370 +			if(r!=KErrNone)
   1.371 +				{
   1.372 +				__IF_DEBUG(Printf("Filename %S not found",&aImage.iFileName));
   1.373 +				r=KErrNotFound;
   1.374 +				}
   1.375 +			}
   1.376 +		}
   1.377 +	return r;
   1.378 +	}
   1.379 +
   1.380 +/******************************************************************************
   1.381 + * WINS specific E32Image functions
   1.382 + ******************************************************************************/
   1.383 +
   1.384 +TInt E32Image::ProcessFileName()
   1.385 +//
   1.386 +// Get the properly capitalised file name and root name
   1.387 +//
   1.388 +	{
   1.389 +
   1.390 +	TFileNameInfo fni;
   1.391 +	TInt r = fni.Set(iFileName, 0);
   1.392 +	if (r!=KErrNone)
   1.393 +		return r;
   1.394 +	iRootNameOffset = fni.iBasePos;
   1.395 +	iRootNameLength = fni.iLen - fni.iBasePos;
   1.396 +	iExtOffset = fni.iExtPos;
   1.397 +//	TBuf<MAX_PATH> filename;
   1.398 +//	TInt r=MapEmulatedFileName(filename, iFileName);
   1.399 +//	if (r!=KErrNone)
   1.400 +//		return r;
   1.401 +//	WIN32_FIND_DATA w32fd;
   1.402 +//	HANDLE h=Emulator::FindFirstFile(filename.PtrZ(), &w32fd);
   1.403 +//	if (h==0)
   1.404 +//		return Emulator::LastError();
   1.405 +//	TPtrC real_filename((const TText*)&w32fd.cFileName[0]);
   1.406 +//	FindClose(h);
   1.407 +//	iFileName.SetLength(slash+1);
   1.408 +//	iFileName+=real_filename;
   1.409 +	__IF_DEBUG(Printf("ProcessFileName: %S,%d,%d,%d",&iFileName,iRootNameOffset,iRootNameLength,iExtOffset));
   1.410 +	return KErrNone;
   1.411 +	}
   1.412 +
   1.413 +TInt E32Image::LoadProcess(const RLdrReq& aReq)
   1.414 +	{
   1.415 +	__IF_DEBUG(Printf("E32Image::LoadProcess %S",&aReq.iFileName));
   1.416 +
   1.417 +	iFileName=*aReq.iFileName;
   1.418 +	TInt r=FindExe(*this);
   1.419 +	if (r!=KErrNone)
   1.420 +		r=FindBin(*this);
   1.421 +	if (r==KErrNone)
   1.422 +		r=ProcessFileName();
   1.423 +	if (r==KErrNone)
   1.424 +		r=CheckUids(iUids, aReq.iRequestedUids);
   1.425 +	if (r!=KErrNone)
   1.426 +		return r;
   1.427 +	r = aReq.iMsg->Client((RThread&)aReq.iClientThread);
   1.428 +	if (r!=KErrNone)
   1.429 +		return r;
   1.430 +	iClientHandle=aReq.iClientThread.Handle();
   1.431 +#ifdef _DEBUG
   1.432 +	iDestructStat = ProcessDestructStatPtr;
   1.433 +#endif
   1.434 +	iFlags |= EDataUnpaged;	// Data paging is not supported on the emulator
   1.435 +	r=E32Loader::ProcessCreate(*this, aReq.iCmd);
   1.436 +	__IF_DEBUG(Printf("Done E32Loader::ProcessCreate %d",r));
   1.437 +	if (r!=KErrNone)
   1.438 +		return r;
   1.439 +#ifdef _DEBUG
   1.440 +	ProcessCreated = ETrue;
   1.441 +#endif
   1.442 +	iClientProcessHandle=iProcessHandle;
   1.443 +	r=E32Loader::ProcessLoaded(*this);
   1.444 +	return r;
   1.445 +	}
   1.446 +
   1.447 +// Load a code segment, plus all imports if main loadee
   1.448 +TInt E32Image::LoadCodeSeg(const RLdrReq& aReq)
   1.449 +	{
   1.450 +	__IF_DEBUG(Printf("E32Image::LoadCodeSeg %S",aReq.iFileName));
   1.451 +
   1.452 +	const TDesC8& reqName=*aReq.iFileName;
   1.453 +	const TDesC8* searchPath=aReq.iPath;
   1.454 +		
   1.455 +	iFileName=reqName;
   1.456 +	TInt r=FindDll(*this, searchPath);
   1.457 +	if (r!=KErrNone)
   1.458 +		r=FindBin(*this);
   1.459 +	// Hack to support EXEDLLs which are DLLs but have EXE file extentions
   1.460 +	if(r==KErrNotFound)
   1.461 +		{
   1.462 +		if(iFileName.Right(4).CompareF(_L8(".DLL"))==0)
   1.463 +			{
   1.464 +			TUint8* p = (TUint8*)iFileName.Ptr() + iFileName.Length() - 3;
   1.465 +			*p++ = 'E';
   1.466 +			*p++ = 'X';
   1.467 +			*p++ = 'E';
   1.468 +			r=FindDll(*this, searchPath);
   1.469 +			if (r!=KErrNone)
   1.470 +				r=FindBin(*this);
   1.471 +			}
   1.472 +		}
   1.473 +	if (r==KErrNone)
   1.474 +		r=ProcessFileName();
   1.475 +	if (r==KErrNone)
   1.476 +		r=CheckUids(iUids, aReq.iRequestedUids);
   1.477 +
   1.478 +	if(r==KErrNone)
   1.479 +		{
   1.480 +		if(this == iMain)
   1.481 +			{
   1.482 +			// Check that we can legally load the DLL into the process
   1.483 +			r=aReq.CheckSecInfo(iS);
   1.484 +			}
   1.485 +		}
   1.486 +	if (r!=KErrNone)
   1.487 +		return r;
   1.488 +		
   1.489 +	__IF_DEBUG(Printf("Checking uids for %S", &iFileName));
   1.490 +	if (iUids[0]!=KDynamicLibraryUid && iUids[0]!=KExecutableImageUid)
   1.491 +	    return KErrNotSupported;
   1.492 +	r=CheckAlreadyLoaded();
   1.493 +	if (r!=KErrNone || iAlreadyLoaded)
   1.494 +		{
   1.495 +		__IF_DEBUG(Printf("<LoadCodeSeg AlreadyLoaded %d",r));
   1.496 +		return r;		// already loaded, either share or give up
   1.497 +		}
   1.498 +	__IF_DEBUG(Printf("CodeSeg create"));
   1.499 +	r=E32Loader::CodeSegCreate(*this);
   1.500 +	if (r==KErrNone)
   1.501 +		r=E32Loader::CodeSegLoaded(*this);
   1.502 +
   1.503 +	__IF_DEBUG(Printf("<LoadCodeSeg, r=%d",r));
   1.504 +	return r;
   1.505 +	}
   1.506 +
   1.507 +//__DATA_CAGING__
   1.508 +TInt ReadCapabilities(RLdrReq& aReq)
   1.509 +//	
   1.510 +//	Wins version
   1.511 +//
   1.512 +	{
   1.513 +	E32Image* e=new E32Image;
   1.514 +	if (!e)
   1.515 +		return KErrNoMemory;
   1.516 +	e->iMain=e;
   1.517 +	e->iFileName=*aReq.iFileName;
   1.518 +	TInt r=GetPEInfo(*e);
   1.519 +	if (r==KErrNotFound || r == KErrPathNotFound)
   1.520 +		{
   1.521 +		//	z:\sys\bin\* may be found in emulator path
   1.522 +		if (e->iFileName.FindF(KRomSysBin) == 0)
   1.523 +			{
   1.524 +			e->iFileName.Delete(0, KRomSysBin().Length());
   1.525 +			r = GetPEInfo(*e);
   1.526 +			}
   1.527 +		}
   1.528 +
   1.529 +	if(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
   1.530 +		if (r==KErrNotFound || r == KErrPathNotFound)
   1.531 +			{
   1.532 +			//	z:\system\bin\* may be found in emulator path
   1.533 +			if (e->iFileName.FindF(KRomSystemBin) == 0)
   1.534 +				{
   1.535 +				e->iFileName.Delete(0, KRomSystemBin().Length());
   1.536 +				r = GetPEInfo(*e);
   1.537 +				}
   1.538 +			}
   1.539 +	TPtrC8 caps((const TUint8*)&e->iS.iCaps, sizeof(e->iS.iCaps));
   1.540 +	if (r==KErrNone)
   1.541 +		r=aReq.iMsg->Write(2, caps);
   1.542 +	delete e;
   1.543 +	return r;
   1.544 +	}
   1.545 +
   1.546 +TInt GetModuleInfo(RLdrReq& aReq)
   1.547 +//
   1.548 +//	Read capabilities from file found
   1.549 +//
   1.550 +	{
   1.551 +	__IF_DEBUG(Printf("ReadModuleInfo %S",aReq.iFileName));
   1.552 +	TFileNameInfo& fi = aReq.iFileNameInfo;
   1.553 +	TInt r = KErrNotSupported;
   1.554 +
   1.555 +	// must specify a fully qualified name
   1.556 +	if (fi.DriveLen() && fi.PathLen())
   1.557 +		{
   1.558 +		E32Image* e=new E32Image;
   1.559 +		if (!e)
   1.560 +			return KErrNoMemory;
   1.561 +		e->iMain = e;
   1.562 +		e->iFileName = *aReq.iFileName;
   1.563 +		r = GetPEInfo(*e);
   1.564 +		if (r==KErrNotFound || r == KErrPathNotFound)
   1.565 +			{
   1.566 +			//	z:\system\bin\* may be found in emulator path
   1.567 +			if (e->iFileName.FindF(KRomSysBin) == 0)
   1.568 +				{
   1.569 +				e->iFileName.Delete(0, KRomSysBin().Length());
   1.570 +				r = GetPEInfo(*e);
   1.571 +				}
   1.572 +
   1.573 +			if(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin))
   1.574 +				if(r!=KErrNone)
   1.575 +					if (e->iFileName.FindF(KRomSystemBin) == 0)
   1.576 +						{
   1.577 +						e->iFileName.Delete(0, KRomSystemBin().Length());
   1.578 +						r = GetPEInfo(*e);
   1.579 +						}
   1.580 +			}
   1.581 +		if (r == KErrNone)
   1.582 +			{
   1.583 +			RLibrary::TInfo ret_info;
   1.584 +			memclr(&ret_info,sizeof(ret_info));
   1.585 +			ret_info.iModuleVersion = e->iModuleVersion;
   1.586 +			ret_info.iUids = e->iUids;
   1.587 +			*(SSecurityInfo*)&ret_info.iSecurityInfo = e->iS;
   1.588 +			TPckgC<RLibrary::TInfo> ret_pckg(ret_info);
   1.589 +			r = aReq.iMsg->Write(2, ret_pckg);
   1.590 +			}
   1.591 +		delete e;
   1.592 +		}
   1.593 +	return r;
   1.594 +	}
   1.595 +
   1.596 +TInt GetInfoFromHeader(const RLoaderMsg& /*aMsg*/)
   1.597 +	{
   1.598 +	TInt r;
   1.599 +	r = KErrNotSupported;
   1.600 +	return r;
   1.601 +	}
   1.602 +
   1.603 +
   1.604 +