Esempio n. 1
0
// -----------------------------------------------------------------------------
// CEcmtMMCEvent::OpenMMCDoor
// Public Method to set MMC card seem to be as removed
// -----------------------------------------------------------------------------
//
void CEcmtMMCEvent::OpenMMCDoor()
	{
	_LIT(KECust,"ecust.dll");
    const TInt KECustUidValue=0x1000008d;
    const TUid KECustUid={KECustUidValue};

	RFs fs;
	User::LeaveIfError(fs.Connect());
	
	RLibrary library;
		// Dynamically load DLL
	User::LeaveIfError(library.Load(KECust));
	if (library.Type()[1] != KECustUid)
		{
		User::Leave(KErrGeneral);
		}
	
	TLibraryFunction MediaChangeCallBack = library.Lookup(6);
	MediaChangeCallBack();
	
	TLibraryFunction MediaDoorOpenPtr = library.Lookup(7);
	TBool* value = (TBool*) MediaDoorOpenPtr();
	*value = ETrue;
	library.Close();	
	fs.Close();
    }
TDriveNumber CFileServPlugin::GetSystemDrive()
	{
	TDriveNumber defaultSysDrive(EDriveC);
	RFs fileServer;
	TVersionName version(fileServer.Version().Name());
	if (fileServer.Version().iMajor >= 2 &&
		fileServer.Version().iBuild >= 1100)
		{
		_LIT(KFileSrvDll, "efsrv.dll");

		RLibrary pluginLibrary;
		TInt pluginErr = pluginLibrary.Load(KFileSrvDll);

		if (pluginErr == KErrNone)
			{
			typedef TDriveNumber(*fun1)();
			fun1 sysdrive;

	#ifdef __EABI__
			sysdrive = (fun1)pluginLibrary.Lookup(336);
	#else
			sysdrive = (fun1)pluginLibrary.Lookup(304);
	#endif
			defaultSysDrive = sysdrive();
			}
		pluginLibrary.Close();
		}
	
	return defaultSysDrive;
	}
Esempio n. 3
0
/**
@SYMTestCaseID          SYSLIB-FATCHARSETCONV-CT-1777
@SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for conversions from/to Unicode, using a function pointer
@SYMTestExpectedResults Test must not fail
*/
void CT_CP949::TestL()
	{
    INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1777 "));
	RLibrary lib;

	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
	// load the dll
	TInt returnValue = lib.Load(KName,serverUid);
	test(returnValue==0);

	// get a pointer to the specified ordinal function and call it
	TLibraryFunction function1 = lib.Lookup(1);
	TLibraryFunction function2 = lib.Lookup(2);
	TLibraryFunction function3 = lib.Lookup(3);

	//cast the function pointer f to a function of type void with two arguments
	typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);
	TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1);

	typedef void (*TConvertToUnicodeL)(TDes16&, const TDesC8&);
	TConvertToUnicodeL aConvertToUnicodeL = reinterpret_cast <TConvertToUnicodeL> (function2);

	typedef TBool (*TIsLegalShortNameCharacter)(TUint);
	TIsLegalShortNameCharacter aIsLegalShortNameCharacter = reinterpret_cast <TIsLegalShortNameCharacter> (function3);


	TBuf8<20> foreign1;
	TBuf16<15> unicode2;

	const TDesC16& unicode1(Uni_1);
	TRAPD(err,(*aConvertFromUnicodeL)(foreign1, unicode1)); 	//testing conversion from Unicode
	test(err==0);
	TInt error = foreign1.Compare(CP949_1);
	test(error==0);
	foreign1.Zero();

	const TDesC8& foreign2(CP949_2);
	(*aConvertToUnicodeL)(unicode2,foreign2); 	//testing conversion to Unicode
	error = unicode2.Compare(Uni_2);
	test(error==0);
	unicode2.Zero();


	//testing for legal short name character
	TInt result = (*aIsLegalShortNameCharacter)(0x005F); //testing for existent character
	test(result==1);
	result = (*aIsLegalShortNameCharacter)(0x003F); //testing for illegal character
	test(result==0);
	result = (*aIsLegalShortNameCharacter)(0x2999); //testing for non-existent character
	test(result==0);
	result = (*aIsLegalShortNameCharacter)(0xAC02); //testing for double byte character
	test(result==1);

	lib.Close();
	}
Esempio n. 4
0
Bool gf_modules_load_library(ModuleInstance *inst)
{
	const TUid KGPACModuleUid= {0x10000080};
	char s_path[GF_MAX_PATH];
	HBufC *path;
	TInt e;

	if (inst->lib_handle) return 1;

	sprintf(s_path, "%s%c%s", inst->plugman->dir, GF_PATH_SEPARATOR, inst->szName);

	path = HBufC::NewL( User::StringLength( ( TUint8* ) s_path) + 1 );
	path->Des().Copy( TPtrC8(( TText8* ) s_path) );

	RLibrary* pLibrary = new RLibrary();
	e = pLibrary->Load(*path);
	delete path;

	if (e != KErrNone) {
		GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[core] Cannot load library %s: %d", s_path, e));
		delete pLibrary;
		goto err_exit;
	}
	/*check UID 2 is GPAC's identifier*/
	if (pLibrary->Type()[1] != KGPACModuleUid) {
		GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[core] Invalid library UID %x", (u32) pLibrary->Type()[1].iUid));
		pLibrary->Close();
		delete pLibrary;
		goto err_exit;
	}
	inst->query_func = (QueryInterfaces) pLibrary->Lookup(1);
	inst->load_func = (LoadInterface) pLibrary->Lookup(2);
	inst->destroy_func = (ShutdownInterface) pLibrary->Lookup(3);

	if ((inst->query_func==NULL) || (inst->load_func==NULL) || (inst->destroy_func==NULL) ) {
		GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[core] Library %s has invalid interfaces", inst->szName));
		pLibrary->Close();
		delete pLibrary;
		goto err_exit;
	}

	//store library handle
	inst->lib_handle = (void*) pLibrary;
	//GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Core] Module %s loaded\n", inst->szName));
	return 1;

err_exit:
	gf_cfg_set_key(inst->plugman->cfg, "SymbianDLLs", inst->szName, "no");
	return 0;
}
// ----------------------------------------------------------------------------
// CSamplerPluginLoader::LoadRlibraryL
// ----------------------------------------------------------------------------
//
void CSamplerPluginLoader::LoadRlibraryL(CArrayPtrFlat<CSamplerPluginInterface>* aPluginArray)
    {
    LOGSTRING("CSamplerPluginLoader rlibrary loading");
                // Load dll
    iPluginArray = aPluginArray;
    RLibrary aLib;
    TInt ret = aLib.Load(_L("PIProfilerGenerals.dll"),_L("c:\\sys\\bin"));

    LOGSTRING2("RLibrary load returns %d", ret);
    User::LeaveIfError(ret);
    const TInt KNewLOrdinal = 2;
    TLibraryFunction NewL =aLib.Lookup(KNewLOrdinal);

    if(!NewL)
        {
        RDebug::Printf("library.lookup returns null");    
        }
    else
        {
        LOGSTRING2("library.lookup returns 0x%x", NewL);
        //CGeneralsPlugin* mydll=(CGeneralsPlugin*)NewL();
        CSamplerPluginInterface* mydll=(CSamplerPluginInterface*)NewL();
        //Generals plugin loaded, samplers enabled.
        CleanupStack::PushL( mydll );
        //InsertPluginInOrderL( mydll, aPluginArray);
        CleanupStack::Pop(mydll);
        // call engine to finalize the startup
        //TRAPD(result, iObserver->HandleSamplerControllerReadyL(););
        NotifyProgress();

        //Begin CActive asynchronous loop.
        CompleteOwnRequest();
        }
    LOGSTRING("RLibrary and plugins loaded");
    }
Esempio n. 6
0
/**
@SYMTestCaseID          SYSLIB-FATCHARSETCONV-CT-1847-0002
@SYMTestCaseDesc	    Tests API behaviours of UnicodeConv class as part of INC090073
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for correct character conversion on certain chinese characters for CP936
@SYMTestExpectedResults Test must not fail
*/
void CT_CP949::TestINC090073L()
	{
    INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FATCHARSETCONV-CT-1847-0002 "));
 	_LIT16(unicode, "\x715C\x7A37\x61A9\x80B1\x86A3\x6B46\x6615");
	_LIT8(CP932Code, "\xE9\xF2\xF2\xC3\xCC\xA8\xCE\xDD\xCD\xF7\xFD\xE4\xFD\xDA");

	RLibrary lib;

	const TUidType serverUid(KNullUid,KNullUid,KPluginUid);
	// load the dll
	TInt returnValue = lib.Load(KName,serverUid);
	test(returnValue==0);

	// get a pointer to the specified ordinal function and call it
	TLibraryFunction function1 = lib.Lookup(1);


	//cast the function pointer f to a function of type void with two arguments
	typedef void (*TConvertFromUnicodeL)(TDes8&, const TDesC16&);
	TConvertFromUnicodeL aConvertFromUnicodeL = reinterpret_cast <TConvertFromUnicodeL> (function1);

	TBuf8<15> foreign1;

	foreign1.Zero();
	const TDesC16& unicode1(unicode);
	TRAPD(err,(*aConvertFromUnicodeL)(foreign1, unicode1)); 	//testing conversion from Unicode
	test(err==0);
	TInt error = foreign1.Compare(CP932Code);
	test(error==0);
	foreign1.Zero();

	lib.Close();
	}
Esempio n. 7
0
static TInt StartServer()
//
// Start the server process or thread
//
	{
	const TUidType serverUid(KNullUid,KNullUid,KServerUid3);

#ifdef __CDLSERVER_NO_PROCESSES__
	//
	// In EKA1 WINS the server is a DLL, the exported entrypoint returns a TInt
	// which represents the real entry-point for the server thread
	//
	RLibrary lib;
	TInt r=lib.Load(KCdlServerDllImg,serverUid);
	if (r!=KErrNone)
		return r;
	TLibraryFunction ordinal1=lib.Lookup(1);
	TThreadFunction serverFunc=reinterpret_cast<TThreadFunction>(ordinal1());
	//
	// To deal with the unique thread (+semaphore!) naming in EPOC, and that we may
	// be trying to restart a server that has just exited we attempt to create a
	// unique thread name for the server.
	// This uses Math::Random() to generate a 32-bit random number for the name
	//
	TName name(KCdlServerName);
	name.AppendNum(Math::Random(),EHex);
	RThread server;
	r=server.Create(name,serverFunc,
					KCdlServerStackSize,
					NULL,&lib,NULL,
					KCdlServerInitHeapSize,KCdlServerMaxHeapSize,EOwnerProcess);
	lib.Close();	// if successful, server thread has handle to library now
#else
	//
	// EPOC and EKA2 is easy, we just create a new server process. Simultaneous launching
	// of two such processes should be detected when the second one attempts to
	// create the server object, failing with KErrAlreadyExists.
	//
	RProcess server;
	TInt r=server.Create(KCdlServerExeImg,KNullDesC,serverUid);
#endif
	if (r!=KErrNone)
		return r;
	TRequestStatus stat;
	server.Rendezvous(stat);
	if (stat!=KRequestPending)
		server.Kill(0);		// abort startup
	else
		server.Resume();	// logon OK - start the server
	User::WaitForRequest(stat);		// wait for start or death
	// we can't use the 'exit reason' if the server panicked as this
	// is the panic 'reason' and may be '0' which cannot be distinguished
	// from KErrNone
	r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
	server.Close();
	return r;
	}
Esempio n. 8
0
   void InitLib(){
      if(!lib_loaded){
         mca_Pause = NULL;
         mca_GetPosition = NULL;
         mca_SetPosition = NULL;
         const TUid ss_dll_uid = { 0x1000008d };
         const TUidType uid(KNullUid, ss_dll_uid, KNullUid);
         if(!lib_mca.Load(_L("mediaclientaudio.dll"), uid)){
            lib_loaded = true;
#ifdef _DEBUG
            *(TLibraryFunction*)&mca_Pause = lib_mca.Lookup(55);
            *(TLibraryFunction*)&mca_GetPosition = lib_mca.Lookup(30);
            *(TLibraryFunction*)&mca_SetPosition = lib_mca.Lookup(72);
#else
            mca_Pause = (t_Pause)lib_mca.Lookup(54);
            mca_GetPosition = (t_GetPosition)lib_mca.Lookup(29);
            mca_SetPosition = (t_SetPosition)lib_mca.Lookup(71);
#endif
         }
      }
   }
// -----------------------------------------------------------------------------
// MceServerStarter::CreateServerProcess
// -----------------------------------------------------------------------------
//
TInt MceServerStarter::CreateServerProcess (RSemaphore& aSemaphore)
	{
	const TUidType serverUid (KNullUid, KNullUid, KServerUid3);


#if ((defined (__WINS__) || defined(__WINSCW__)) && !defined (EKA2))

	RLibrary lib;
    RETURN_IF_ERROR (lib.Load(KMceServerFilename,serverUid))

    //  Get the WinsMain function
	TLibraryFunction functionWinsMain = lib.Lookup (1);

    //  Call it and cast the result to a thread function
	TThreadFunction serverThreadFunction = 
        reinterpret_cast<TThreadFunction> (functionWinsMain());

	TName threadName (KSipServerName);

	// Append a random number to make it unique
	threadName.AppendNum (Math::Random(), EHex);

	RThread server;
    TInt err = server.Create (threadName,
                              serverThreadFunction, // thread's main function
                              KDefaultStackSize,
                              NULL,
                              &lib,
                              NULL,
                              KServerMinHeapSize,
                              KServerMaxHeapSize,
                              EOwnerProcess );

	lib.Close ();	// if successful, server thread has handle to library now
    RETURN_IF_ERROR (err)

	server.SetPriority (EPriorityMore);

#else // HW build

	RProcess server;
	RETURN_IF_ERROR (server.Create( KMceServerName, KNullDesC, serverUid ) )

#endif


	server.Resume ();
	aSemaphore.Wait();
	TInt exitReason = server.ExitReason();
	server.Close ();

    return exitReason;
	}
Esempio n. 10
0
TVerdict CApStartTestStep::doTestStepPreambleL()
	{
	// Load the CApaStarter implementation
	RLibrary lib;
	User::LeaveIfError(lib.Load(KApStartDLL)); // load the library
	CleanupClosePushL(lib);		
	TLibraryFunction ord1 = lib.Lookup(1); // This is the NewL function
	TFuncNewL funcL = reinterpret_cast<TFuncNewL>(ord1);
	iAppStart = static_cast<CApaStarter*> (funcL());	
	CleanupStack::PopAndDestroy(&lib);
		
	return CTestStep::doTestStepPreambleL();	
	}
Esempio n. 11
0
TBool CUIManager::CheckPenEnabled()
	{
	TBool penEnabled = EFalse;

	RLibrary avkonDll;
	if (avkonDll.Load(_L( "avkon.dll" )) == KErrNone)
		{
#ifdef __WINS__
		TLibraryFunction PenEnabled = avkonDll.Lookup(3184);
#else
		TLibraryFunction PenEnabled = avkonDll.Lookup( 4251 );
#endif

		if (PenEnabled != NULL)
			{
			penEnabled = PenEnabled();
			}

		avkonDll.Close();
		}
	return penEnabled;

	}
Esempio n. 12
0
// -----------------------------------------------------------------------------
// CHtiFramework::WaitNormalState
// Delays HTI startup until device reaches normal state.
// -----------------------------------------------------------------------------
void CHtiFramework::WaitNormalState( TInt aMaxWaitTime, TInt aStartUpDelay )
    {
    HTI_LOG_FUNC_IN("CHtiFramework::WaitNormalState");
    // First make sure that EComServer is running before continuing
    TFullName processName;
    TFindProcess finder( KEComServerMatchPattern );
    while ( finder.Next( processName ) != KErrNone )
        {
        HTI_LOG_TEXT( "HTI waiting for EComServer startup" );
        finder.Find( KEComServerMatchPattern );
        User::After( 1000000 ); // wait 1 second
        }
    HTI_LOG_TEXT( "EComServer process found - HTI startup continuing" );

    if ( aMaxWaitTime > 0 )
        {
        TInt err = KErrNone;
        RFs fs;
        err = fs.Connect();
        if ( err == KErrNone )
            {
            RLibrary library;
            err = library.Load( KHtiStartupWaitDllName );
            HTI_LOG_FORMAT( "StartupWait library load returned %d", err );
            if ( err == KErrNone &&
                 library.Type()[1] == KHtiStartupWaitInterfaceUid )
                {
                HTI_LOG_TEXT( "StartupWait DLL found" );
                TLibraryFunction entry = library.Lookup( 1 );
                if ( entry != NULL )
                    {
                    MHtiStartupWaitInterface* startupWait =
                        ( MHtiStartupWaitInterface* ) entry();
                    err = startupWait->WaitForStartup( aMaxWaitTime );
                    HTI_LOG_FORMAT( "StartupWait returned %d", err );
                    delete startupWait;
                    startupWait = NULL;
                    }
                }
            library.Close();
            }
        }

    HTI_LOG_FORMAT( "HTI Starting after %d seconds", aStartUpDelay );
    User::After( aStartUpDelay * 1000 * 1000 );

    HTI_LOG_FUNC_OUT( "CHtiFramework::WaitNormalState" );
    }
Esempio n. 13
0
/**
Gets the dll handle to SwpPolicy and initializes the SwpPolicy
*/
void CSsmSwpPolicyServer::CallSetDllHandleAndInitializeL(const RMessage2& aMessage, const TInt aSessionIndex)
	{
	__ASSERT_DEBUG(IN_RANGE(aSessionIndex, iSessionInfoArray.Count()), PanicNow(KSsmSwpPolicyBadIdx, KSsmSwpPolicySrvArrayIndexInvalid));

	RLibrary library;
	// Sets the swp policy library handle.  Library is owned by the CSsmSwpRequestHandler.
	library.SetHandle(aMessage.Int0());

	DEBUGPRINT1(_L("CSsmSwpPolicyServer: SwpPolicy handle is set"));
	iSessionInfoArray[aSessionIndex].iSwpPolicy = reinterpret_cast<MSsmSwpPolicy*>(library.Lookup(1)());

	DEBUGPRINT1(_L("CSsmSwpPolicyServer: Create CSsmSwpPolicyStepCompletion active object"));
	iSessionInfoArray[aSessionIndex].iSsmSwpPolicyStepCompletion = CSsmSwpPolicyStepCompletion::NewL(iSessionInfoArray[aSessionIndex].iSwpPolicy, *this, aSessionIndex);

	// aMessage will be completed in CSsmSwpPolicyStepCompletion's RunL method,
	// when the Initialization of the swp policy is completed.
	iSessionInfoArray[aSessionIndex].iSsmSwpPolicyStepCompletion->StartInitialize(aMessage);
	}
Esempio n. 14
0
extern "C" TLinAddr GetEka1ExeEntryPoint()
	{
	TLinAddr a = 0;
	RLibrary l;
	TInt r = l.Load(KEka1EntryStubName, KNullDesC, TUidType(KDynamicLibraryUid, KEka1EntryStubUid));
	if (r == KErrNone)
		r = l.Duplicate(RThread(), EOwnerProcess);
	if (r == KErrNone)
		{
		a = (TLinAddr)l.Lookup(1);
		if (!a)
			r = KErrNotSupported;
		}
	if (r != KErrNone)
		RThread().Kill(r);
	Exec::SetReentryPoint(a);
	return a;
	}
void MainL()
	{
	TInt err=KErrNone;
	
	// figure out which test we're supposed to be running
	HBufC* dllName=GetDllNameL();
	
	HBufC* logFileName=GetDesParameterL(KLogFileNameTransferSlot);
	
	TBool shouldPass;
	err = User::GetTIntParameter(KShouldPassTransferSlot, shouldPass);
	TInt testNumber;
	err = User::GetTIntParameter(KTestNumberTransferSlot, testNumber);

	// session
	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);
		
	//logfile
	RFile logFile;
	User::LeaveIfError(logFile.Replace(fs, *logFileName, 0));
	CleanupClosePushL(logFile);
	
	// load library
	RLibrary lib;
	User::LeaveIfError(lib.Load(*dllName));
	CleanupClosePushL(lib);
	
	//runtests
	TLibraryFunction testFactory=lib.Lookup(1);
	MCapabilityTestFactory* factory=reinterpret_cast<MCapabilityTestFactory*>(testFactory());
	factory->Test(testNumber)->SetExpectPermissionDenied(!shouldPass);
	
	TRAP(err, factory->Test(testNumber)->RunTestL(logFile));

	delete factory;
	CleanupStack::PopAndDestroy(3, &fs); // lib, logFile, fs
	
	User::LeaveIfError(err);
	}
Esempio n. 16
0
EXPORT_C TInt StartC32()
  /**
   * Start the Rootserver and services, 
   * this function in C32 is DEPRECATED and will be removed
   * in the near future.
   *
   * Instead one should link to c32root.dll and use the 
   * StartC32() from that library.
   *
   * @return TInt - An error code
   */
  	{
	C32_STATIC_LOG(KC32Warning,_L8("WARNING: StartC32() CALLED IN C32.DLL. THIS IS DEPRECATED. MUST USE C32ROOT.DLL!!"));

	RLibrary library;
	TInt res = library.Load(KRootServerDll);

    if (res!=KErrNone && res!=KErrAlreadyExists)
		{
		C32_STATIC_LOG2(KC32Warning, _L8("StartC32 from C32.DLL: Unable to load RS DLL %d."), res);

        return res;
		}

	C32_STATIC_LOG(KC32Bootup,      _L8("StartC32 from C32.DLL: Loaded RS library."));

    TLibraryFunction StartC32Entry=library.Lookup(StartC32EntryOrdinal);
    
    if (StartC32Entry==NULL)
		{
		C32_STATIC_LOG2(KC32Warning, _L8("StartC32 from C32.DLL: Unable to load StartC32 ordinal %d."), StartC32EntryOrdinal);
        return KErrNoMemory;
		}

	C32_STATIC_LOG(KC32Bootup, _L8("StartC32 from C32.DLL: Calling StartC32 ordinal from RS."));

	res = StartC32Entry();
	library.Close();
  	return res;
	}
Esempio n. 17
0
/* \internal
 *
 * Uses link-time symbol preemption to capture a call from the application
 * startup. On return, there is some kind of heap allocator installed on the
 * thread.
*/
TInt UserHeap::SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo)
{
    TInt r = KErrNone;

#ifndef __WINS__
    // attempt to create the fast allocator through a known export ordinal in qtcore.dll
    RLibrary qtcore;
    if (qtcore.Load(QtCoreLibName) == KErrNone)
    {
        const int qt_symbian_SetupThreadHeap_eabi_ordinal = 3713;
        TLibraryFunction libFunc = qtcore.Lookup(qt_symbian_SetupThreadHeap_eabi_ordinal);
        if (libFunc)
        {
            typedef int (*TSetupThreadHeapFunc)(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo);
            TSetupThreadHeapFunc p_qt_symbian_SetupThreadHeap = TSetupThreadHeapFunc(libFunc);
            r = (*p_qt_symbian_SetupThreadHeap)(aNotFirst, aInfo);
        }
        qtcore.Close();
        if (libFunc)
            return r;
    }
#endif

    // no fast allocator support - use default allocator creation
    if (!aInfo.iAllocator && aInfo.iHeapInitialSize>0)
        {
        // new heap required
        RHeap* pH = NULL;
        r = UserHeap::CreateThreadHeap(aInfo, pH);
        }
    else if (aInfo.iAllocator)
        {
        // sharing a heap
        RAllocator* pA = aInfo.iAllocator;
        pA->Open();
        User::SwitchAllocator(pA);
        r = KErrNone;
        }
    return r;
}
Esempio n. 18
0
EXPORT_C MDrmKeyStorage* DrmKeyStorageNewL()
    {
    RLibrary library;
    MDrmKeyStorage* storage;
    TInt r;
    TStorageConstructor constructor;
    
    r = library.Load(KBb5KeyStorageName);
    if (r != KErrNone)
        {
        r = library.Load(KStdKeyStorageName);
        }
    User::LeaveIfError(r);
    constructor = reinterpret_cast<TStorageConstructor>(
        library.Lookup(KConstructorOrdinal));
    if (constructor == NULL)
        {
        User::Leave(KErrNotFound);
        }
    storage = reinterpret_cast<MDrmKeyStorage*>(constructor(library));
    return storage;
    }
Esempio n. 19
0
TInt E32Main()
	{
	test.Title();

	test.Start(_L("Test retrieving 0th ordinal and therefore named symbol export data"));
	
	E32EpocExpSymInfoHdr tmpHdr;
	E32EpocExpSymInfoHdr *readHdr;
	RLibrary library;

	// The values for the header of the dll with a 0th ordinal
	tmpHdr.iSize = 0x1a4;
	tmpHdr.iFlags = 0x0;
	tmpHdr.iSymCount = 0xc;	
	tmpHdr.iSymbolTblOffset = 0x1c;
	tmpHdr.iStringTableSz = 0x134;
	tmpHdr.iStringTableOffset = 0x64;
	tmpHdr.iDllCount = 0x3;	
	tmpHdr.iDepDllZeroOrdTableOffset = 0x198;
	test(library.Load(_L("t_oedll.dll")) == KErrNone);
	test.Next(_L("Attempt to retrieve named symbol data from t_oedll.dll"));
	readHdr = (E32EpocExpSymInfoHdr*)library.Lookup(0);
	test(readHdr!=NULL);
	test.Next(_L("Verify export data of t_oedll.dll at the 0th ordinal is that expected"));
	VerifyHdr(tmpHdr, *readHdr);
	library.Close();

	test.Next(_L("Verify lookup on dll without oe export data returns NULL"));
	test(library.Load(_L("t_dll1.dll")) == KErrNone);
	readHdr = (E32EpocExpSymInfoHdr*)library.Lookup(0);
	test(readHdr == NULL);
	library.Close();

	// The values for the header of the exe of the current process with a 0th ordinal
	tmpHdr.iSize = 0x48;
	tmpHdr.iFlags = 0x0;
	tmpHdr.iSymCount = 0x2;
	tmpHdr.iSymbolTblOffset = 0x1c;
	tmpHdr.iStringTableSz = 0x14;
	tmpHdr.iStringTableOffset = 0x28;
	tmpHdr.iDllCount = 0x3;
	tmpHdr.iDepDllZeroOrdTableOffset = 0x3c;
	test.Next(_L("Attempt to retrieve named symbol data from current process"));
	readHdr = (E32EpocExpSymInfoHdr*)(RProcess::ExeExportData());
	test(readHdr!=NULL);
	test.Next(_L("Verify export data at th 0th ordinal of this exe is that expected"));

//#define PRINT_ZEROTH
#ifdef PRINT_ZEROTH
	test.Printf(_L("iSize=%08x;iFlags=%08x;iSymCount=%08x;iSymbolTblOffset=%08x\n"),readHdr->iSize,readHdr->iFlags,readHdr->iSymCount,readHdr->iSymbolTblOffset);
	test.Printf(_L("iStringTableSz=%08x,iStringTableOffset=%08x,iDllCount=%08x,iDepDllZeroOrdTableOffset=%08x\n"), readHdr->iStringTableSz, readHdr->iStringTableOffset,readHdr->iDllCount,readHdr->iDepDllZeroOrdTableOffset);
#endif
	VerifyHdr(tmpHdr, *readHdr);

	test.Next(_L("Verify static dependency t_oedll1 has been fixed up correctly"));
	test(myfoo()==0x1234);

	// Get the 0th ordinal data from the dependency t_oedll1 and verify it
	readHdr=(E32EpocExpSymInfoHdr *)((TUint32)readHdr+readHdr->iDepDllZeroOrdTableOffset);
	TUint32 readHdrEnd = (TUint32)readHdr + 12;
	// This stdexe only links one stddll so the only non-NULL entry in iDepDllZeroOrdTable
	// should point to 0th ordinal of t_oedll1
	while (*(TUint32*)readHdr == NULL && (TUint32)readHdr < readHdrEnd)
		{
		readHdr=(E32EpocExpSymInfoHdr *)(((TUint32*)readHdr)+1);
		}

#ifdef PRINT_ZEROTH
	test.Printf(_L("iSize=%08x;iFlags=%08x;iSymCount=%08x;iSymbolTblOffset=%08x\n"),(*(E32EpocExpSymInfoHdr**)readHdr)->iSize,(*(E32EpocExpSymInfoHdr**)readHdr)->iFlags,(*(E32EpocExpSymInfoHdr**)readHdr)->iSymCount,(*(E32EpocExpSymInfoHdr**)readHdr)->iSymbolTblOffset);
	test.Printf(_L("iStringTableSz=%08x,iStringTableOffset=%08x,iDllCount=%08x,iDepDllZeroOrdTableOffset=%08x\n"), (*(E32EpocExpSymInfoHdr**)readHdr)->iStringTableSz, (*(E32EpocExpSymInfoHdr**)readHdr)->iStringTableOffset,(*(E32EpocExpSymInfoHdr**)readHdr)->iDllCount,(*(E32EpocExpSymInfoHdr**)readHdr)->iDepDllZeroOrdTableOffset);
#endif

	tmpHdr.iSize = 0x1a4;
	tmpHdr.iFlags = 0x0;
	tmpHdr.iSymCount = 0xc;	
	tmpHdr.iSymbolTblOffset = 0x1c;
	tmpHdr.iStringTableSz = 0x134;
	tmpHdr.iStringTableOffset = 0x64;
	tmpHdr.iDllCount = 0x3;	
	tmpHdr.iDepDllZeroOrdTableOffset = 0x198;
	VerifyHdr(tmpHdr,**(E32EpocExpSymInfoHdr**)readHdr);
	
	test.End();
	return KErrNone;
	}
Esempio n. 20
0
/** Implementation of MStartupCommand interface.
This function retrieves the DLL name and ordinal number from its 
CSystemStartupDllInfo data member. It attempts to load the DLL 
and call the specified function. 

@see MStartupCommand.
*/
void CDllStarter::Execute(TRequestStatus& aStatus)
	{
	aStatus = KRequestPending; 
	DEBUGPRINT1(_L("SysStart: CDllStarter::Execute"));
	
	// Find the name of the DLL to be loaded from the information 
	// already retrieved from the SSC file.
	TFileName dllName =iDllInfo->DllName();
	_LIT(KExtension, ".dll");
	dllName.Append(KExtension);
    
    // Initialise variables
    _LIT(KSysBin, "z:\\sys\\bin\\");
	RLibrary lib;
	TInt err = KErrGeneral; 
	TBool dllLoaded = EFalse; 
	
	TUint8 ordinal = iDllInfo->Ordinal();
 
	// The DLL may not be found or the DLL function may return an error 
	// code. The number of times to re-attempt is specified in the SSC file.
	TInt attemptsRequired = iDllInfo->NoOfRetries() + 1; 
  
 	while ((err != KErrNone)   && (attemptsRequired-- >0))
	 	{
		// Search for and load the DLL. 	 
       	if ((err = lib.Load(dllName, KSysBin)) == KErrNone)
 			{ 
 			DEBUGPRINT2(_L("SysStart: dll loaded - %S"), &dllName);
 			dllLoaded = ETrue;		 
 			}
 		else
			{
			DEBUGPRINT3(_L("SysStart: Unable to load DLL - %S, error - %d"), &dllName, err);
			}
			
  		// Call the function in the Dll
  		if (dllLoaded)
  			{	
  			// Identify the function to be called according to the ordinal 
 			// number specified in the SSC file.
 			TLibraryFunction ordinalfunction = lib.Lookup(ordinal);
 				
 			if (ordinalfunction != NULL)
 				{	
 				Dllfunctiontype getDllFunction = reinterpret_cast<Dllfunctiontype>(ordinalfunction);
  		 		DEBUGPRINT2(_L("SysStart: Calling function at ordinal %d."), ordinal);
  		 		err = (*getDllFunction)(iDllInfo->DllBuffer());
 				}
 			else
 				{
 				DEBUGPRINT2(_L("Sysstart: No function at specified ordinal %d"), ordinal);
 				err = KErrNotFound;
 				// No function exists at the ordinal specified so 
 				// there is no point in re-attempting execution.
 				attemptsRequired = 0;
 				}
  			}
	 	}
 	
				 	
	// Take action on error condition
	if (err != KErrNone) 
		{	
 		// Check required behaviour on failure specified in SSC
 		if (iDllInfo->FailOnError())
 			{ 
			err = RestartSys::RestartSystem();
			if (KErrNone != err)
				{
				DEBUGPRINT2(_L("Sysstart: Restart System Call failed with error %d"), err);
 				PanicNow(KPanicDllStarter, ERestartSystemCallFailed);
				}
			User::After(5000000); // required by RestartSys API, see comments in RestartSys::RestartSystem()
 			}			 
		}
 
 	lib.Close();
  
	TRequestStatus* requestStatus = &aStatus;
	User::RequestComplete(requestStatus, err);
	}
Esempio n. 21
0
//-----------------------------------------------------------------------------
//Function Name : void* __dlopen_r(const char* filename, int flag)
//Description   : To open the given dll filename.
//Return Value  : Valid handle value if no error, Null if dll couldn't be loaded 
//-----------------------------------------------------------------------------
void* __dlopen_r(const char* filename,const int flag)
	{
	//convert filename to TFileName
	TPtrC8 ptr8( (unsigned char*)filename);
	TFileName fileNameBuf;
	CnvUtfConverter::ConvertToUnicodeFromUtf8(fileNameBuf, ptr8);
	TParsePtr filePathName(fileNameBuf);
	
	//if file name contains wild character
	if ( filePathName.IsWild() )
		{
		SetError(KDlOpenErrNoSupport);
		return NULL;
		}
	//to load dll	
	RLibrary library;	
	TInt err;
	TBool isLibraryLoaded = EFalse;
	RFs fs;
	err = fs.Connect();
	if ( KErrNone == err )
		{
		TUint tempAtt;
		//if path is there load from this path
		if ( filePathName.PathPresent() )
			{
			err = fs.Att(filePathName.FullName(), tempAtt);
			fs.Close();	
			if ( KErrNotFound != err && KErrPathNotFound != err)
				{
				err = library.Load(filePathName.FullName());
				if ( KErrNone != err )
					{
					SetError(KDlOpenErrLoading);
					return NULL;
					}
				isLibraryLoaded = ETrue;	
				}
			}
		else//if there is no path its only file name
			{
			TPtrC fileName(filePathName.NameAndExt());
			char* envPathName = getenv("LD_LIBRARY_PATH");
			if ( envPathName )
				{
				TPtrC8 tempPtr8((unsigned char*)envPathName);
				TFileName envPathBuf;
				CnvUtfConverter::ConvertToUnicodeFromUtf8(envPathBuf, tempPtr8);
				TPtrC envPath(envPathBuf);
				TChar delim(';');
				TFileName fileToLoad;
				TInt pos = envPath.Locate(delim);
				//if delim does not found and still envPath contains value
				//i.e. this one is last path without delim(';') so take 
				//this also, for this length is checked
				while ( KErrNotFound != pos || envPath.Length())
					{
					//if there is no delim
					if (KErrNotFound == pos )
						{// so last path without delim
						pos = envPath.Length();
						}
					TPtrC thisPath(envPath.Left(pos));
					fileToLoad = thisPath;
					fileToLoad.Trim();
					//to check ";;" and ";   ;"
					if (fileToLoad.Length())
						{
						//if path does not conatin trailing \ add one
						if ( L'\\' != fileToLoad[fileToLoad.Length()-1] )
							{
							fileToLoad.Append(TChar(L'\\'));					
							}
						fileToLoad.Append(fileName);
					
						err = fs.Att(fileToLoad, tempAtt);
						if ( KErrNotFound != err && KErrPathNotFound != err)
							{
							//load file from this path
							err = library.Load(fileToLoad);
							if ( KErrNone == err )
								{
								// dll loaded successfully from thispath
								isLibraryLoaded = ETrue;	
								break;
								}	
							}
						}
					if ( pos == envPath.Length())		
						{
						break;
						}
					else
						{
						envPath.Set(envPath.Mid(pos + 1));
						}
					pos = envPath.Locate(delim);
					}
				fs.Close();	
				}
			else//load dll if only name is there and LD_LIBRARY_PATH path not set
				{
				fs.Close();	
				TInt err = library.Load(filePathName.NameAndExt());
				if ( KErrNone != err )
					{
					SetError(KDlOpenErrLoading);
					return NULL;
					}
				isLibraryLoaded = ETrue;		
				}
			}
	
		//if library is loaded	
		if ( isLibraryLoaded )	
			{
			//handle value to return 
			void* handle  = NULL;
			//lock list before any operation
			LoadedDlls()->Lock();
			//is this dll already there
			TInt listIdx = LoadedDlls()->Find(library);
			//if not already open
			if ( KErrNotFound == listIdx )
				{				
				TDllEntry dllEntry(library, flag);
				dllEntry.iSymbolHeader = (TE32ExpSymInfoHdr*)library.Lookup(0);
				
				err = dllEntry.iLibrary.Duplicate(RThread());	
				//Close the library irrespective of the result of duplicate
				library.Close();
				if ( KErrNone != err )
					{
					SetError(KDlOpenErrLoading);
					LoadedDlls()->UnLock();
					return NULL;
					}
				//add to list	
				err = LoadedDlls()->Add(dllEntry);
				handle = (void*) dllEntry.iLibrary.Handle();
				LoadedDlls()->UnLock();
				if ( KErrNone != err )
					{
					SetError(KDlOpenErrNoMemory);
					dllEntry.iLibrary.Close();
					return NULL;
					}
				}
			else//if this dll is already in list.
				{
				//close library we already have loaded
				library.Close();
				TDllEntry& dllEntry = LoadedDlls()->At(listIdx);
				//if flag is RTLD_GLOBAL store it otherwise ignore
				//as RTLD_LAZY and RTLD_NOW both means RTLD_NOW
				//so can be ignored. RTLD_LOCAL does not change previous flag
				if ( flag & RTLD_GLOBAL )
					{
					dllEntry.iFlags |= RTLD_GLOBAL;
					}
				dllEntry.iRefCount++;	
				handle = (void*) dllEntry.iLibrary.Handle();
				LoadedDlls()->UnLock();	
				}	
			return handle;			
			}
		}
	SetError(KDlOpenErrLoading);
	return NULL;		
	}
EXPORT_C void CCryptoSpiStateApi::EnumerateCharacteristicsL(RPointerArray<CCharacteristicsAndPluginName>& aCharacteristicsDll, TInt32 aInterface, TBool aExtended)
	{
	if (aInterface==0)
		{
		TInt interfaceCount=sizeof(KInterfacesUids)/sizeof(KInterfacesUids[0]);
		for (TInt i=0;i<interfaceCount;i++)
			{
			CryptoSpiUtil::RetrieveCharacteristicsL(KInterfacesUids[i].iUid, aCharacteristicsDll);
			}
		}
	else
		{
		CryptoSpiUtil::RetrieveCharacteristicsL(aInterface, aCharacteristicsDll);
		}
		
	if (aExtended)
		{
		TInt count=aCharacteristicsDll.Count();
		for (TInt i=0;i<count;i++)
			{
			RLibrary lib;
			CryptoSpiUtil::LoadPluginDllLC(lib, aCharacteristicsDll[i]->iDllName);
			GetExtendedCharacteristicsFuncL getExtendedCharFuncL=(GetExtendedCharacteristicsFuncL)lib.Lookup(EGetExtendedCharacteristicOrdinal);
			if (getExtendedCharFuncL)
				{
				TUid implementationUid={aCharacteristicsDll[i]->iCharacteristic->iImplementationUid};
				getExtendedCharFuncL(implementationUid, aCharacteristicsDll[i]->iExtendedCharacteristic);
				}
			CleanupStack::PopAndDestroy(&lib);
			}
		}
	}
Esempio n. 23
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
//
EXPORT_C void CSymbianUnitTestRunner::ExecuteTestsL(
    const MDesCArray& aTestDllNames,
    TBool aMemoryAllocationFailureSimulation,
    const TDesC& aOutputFileName,
    const TDesC& aOutputFormat,
    const CDesCArray& aTestCaseNames,
    TInt  aTimeout )
    {
    //init logger
    TBuf<50> version;
    version.Format(KLogVersion, SUT_MAJOR_VERSION, SUT_MINOR_VERSION, SUT_BUILD_VERSION);
    SUT_LOG_START(version);
    
    iTestCount = 0;
    
    MSymbianUnitTestInterface::TFailureSimulation failureSimulation = 
        MSymbianUnitTestInterface::ENoFailureSimulation;
    if ( aMemoryAllocationFailureSimulation )
        {
        failureSimulation = 
            MSymbianUnitTestInterface::EMemAllocFailureSimulation;
        }
    
    for ( TInt i = 0; i < aTestDllNames.MdcaCount(); i++ )
        {
        TPtrC16 testDllName( aTestDllNames.MdcaPoint( i ) );
        RLibrary library;
        TInt ret;
        ret = library.Load( testDllName );
        if ( ret != KErrNone )
            {
            iUiCallBack.InfoMsg( KFailedToFindDll, testDllName );
            SUT_LOG_FORMAT(KFailedToFindDll, &testDllName);
            //User::Leave( KErrNotFound );
            User::Leave( ret );
            } 
        CleanupClosePushL( library );
        // The second UID of the dll to be used must be compatible
        if ( library.Type()[ 1 ] != KSymbianUnitTestDllUid )
            {
            iUiCallBack.InfoMsg( KNonCompatibleUIDs );
            User::Leave( KErrNotFound );
            }  
        TLibraryFunction entryFunction = library.Lookup( 1 );
        if ( !entryFunction )
            {
            iUiCallBack.InfoMsg( KExportFuncNotFound );
            User::Leave( KErrNotFound );
            }
        
        MSymbianUnitTestInterface* test = 
            reinterpret_cast< MSymbianUnitTestInterface* >( 
                entryFunction() );
        TCleanupItem cleanupItem( DeleteTest, test );
        CleanupStack::PushL( cleanupItem );
        iTestCount += test->TestCaseCount();
        test->ExecuteL( *this, *iResult, failureSimulation, aTestCaseNames, aTimeout);
        CleanupStack::PopAndDestroy(); // cleanupItem
        
        CleanupStack::PopAndDestroy( &library ); 
        }
    
    CSymbianUnitTestOutputFormatter* outputFormatter = 
        SymbianUnitTestOutputFactory::CreateOutputLC( 
            aOutputFileName, aOutputFormat );
    outputFormatter->PrintL( *iResult );
    CleanupStack::PopAndDestroy( outputFormatter );    
    SUT_LOG_INFO(KLogFinish);
    }
/**
@SYMTestCaseID		SYSLIB-BAFL-CT-4023    
@SYMREQ  	    	REQ8170, REQ8172		
@SYMTestCaseDesc    DummyAPIs
@SYMTestPriority    HIGH
@SYMTestStatus      Implemented
@SYMTestActions    	An attempt should be made to call each remove method as if it was still 
@SYMTestActions    	present in the System Utils dummy apis 3, 7, 8, 9, 11 – 20, 25 - 40 for winsc 
@SYMTestActions    	and 1 – 8, 12, 16 – 20, 25 - 40 for eabi.					 
@SYMTestExpectedResults Trace should be logged explaining that unsupported method calls have 
@SYMTestExpectedResults	been made, but no errors should occur. Trace is only logged if 
@SYMTestExpectedResults	_DEBUG is  defined
*/
TVerdict CSysUtilsDummyAPIsStep::doTestStepL()
	{

	TUidType uidType(KDynamicLibraryUid, KSharedLibraryUid,
			TUid::Uid (KSysUtilDllUid3));

	RLibrary library;
	TInt err = library.Load (_L("sysutil.dll"),uidType);
	if ( err == KErrNone)
		{
		__ASSERT_ALWAYS(err==KErrNone,User::Panic(_L("Failed to load sysutil.dll, error: %d."),err));
#ifdef __WINSCW__

		TLibraryFunction ordinalfunction = library.Lookup (3);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (7);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (8);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (9);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (11);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (12);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (13);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (14);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (15);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (16);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (17);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (18);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (19);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (20);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();
		
		ordinalfunction = library.Lookup (15);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (16);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (17);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (18);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (19);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (20);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();
		
		ordinalfunction = library.Lookup (25);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (26);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (27);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (28);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (29);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (30);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();
		
		ordinalfunction = library.Lookup (31);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (32);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (33);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (34);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (35);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (36);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();
		
		ordinalfunction = library.Lookup (37);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (38);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (39);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (40);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

#else 
		//eabi
		TLibraryFunction ordinalfunction = library.Lookup(1);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction)();

		ordinalfunction = library.Lookup(2);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction)();

		ordinalfunction = library.Lookup(3);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction)();

		ordinalfunction = library.Lookup(4);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction)();

		ordinalfunction = library.Lookup(5);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction)();

		ordinalfunction = library.Lookup(6);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction)();

		ordinalfunction = library.Lookup(7);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction)();

		ordinalfunction = library.Lookup(8);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction)();

		ordinalfunction = library.Lookup(12);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction)();

		ordinalfunction = library.Lookup(16);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction)();

		ordinalfunction = library.Lookup(17);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction)();

		ordinalfunction = library.Lookup(18);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction)();

		ordinalfunction = library.Lookup(19);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction)();

		ordinalfunction = library.Lookup(20);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction)();
		
		ordinalfunction = library.Lookup (25);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (26);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (27);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (28);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (29);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (30);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();
		
		ordinalfunction = library.Lookup (31);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (32);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (33);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (34);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (35);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (36);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();
		
		ordinalfunction = library.Lookup (37);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (38);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (39);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();

		ordinalfunction = library.Lookup (40);
		__ASSERT_ALWAYS(ordinalfunction!=NULL,User::Panic(_L("Failed to find ordinal in sysutil.dll."),KErrGeneral));
		(*ordinalfunction) ();
#endif

		}
	else
		{
		ERR_PRINTF1 (_L("DummyAPI failed"));
		SetTestStepResult (EFail);
		}

	return TestStepResult ();
	}
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
static TInt CreateLockServerProcess()
    {
    TInt result;

	const TUidType serverUid(KNullUid, KNullUid, KCrashServerUid3);

#ifdef __WINS__

	RLibrary lib;
	result = lib.Load(KCrashServerImg, serverUid);
    if (result != KErrNone)
        {
        return  result;
        }

    //  Get the WinsMain function
	TLibraryFunction functionWinsMain = lib.Lookup(1);

    //  Call it and cast the result to a thread function
	TThreadFunction serverThreadFunction = reinterpret_cast<TThreadFunction>(functionWinsMain());

	TName threadName(KCrashServerName);

	// Append a random number to make it unique
	threadName.AppendNum(Math::Random(), EHex);

	RThread server;

	result = server.Create(threadName,   // create new server thread
							 serverThreadFunction, // thread's main function
							 KDefaultStackSize,
							 NULL,
							 &lib,
							 NULL,
							 KServerMinHeapSize,
							 KServerMaxHeapSize,
							 EOwnerProcess);

	lib.Close();	// if successful, server thread has handle to library now

    if (result != KErrNone)
        {
        return  result;
        }

	server.SetPriority(EPriorityMore);


#else

	RProcess server;

	result = server.Create(KCrashServerImg, _L(""), serverUid);
    if (result != KErrNone)
        {
        return  result;
        }

#endif

	server.Resume();
    server.Close();

    return  KErrNone;
    }
EXPORT_C void StartServerL(const TDesC& aServerName, TUid aServerUid3, const TDesC& aServerFileName)
#endif
{
	CALLSTACKITEM_N(_CL(""), _CL("StartServer"));

	TBuf<50> mutexname; MakeServerMutexName(mutexname, aServerName);
	RAMutex mutex; mutex.GlobalLA(mutexname);
	
	TFindServer findServer(aServerName);
	TFullName name;
	
	if (findServer.Next(name) == KErrNone)
        {
		return;
        }
	
#if defined(__WINS__)
	RAThread serverthread;
#else
	RAProcess serverthread;
#endif
	TBuf<50> semaphorename; MakeServerSemaphoreName(semaphorename, aServerName);
	RSemaphore semaphore;
	if (semaphore.CreateGlobal(semaphorename, 0)!=KErrNone) {
		User::LeaveIfError(semaphore.OpenGlobal(semaphorename));
	}

#if defined(__WINS__)
	CreateServerProcessLA(aServerName, aFunction, serverthread);
#else
	CreateServerProcessLA(aServerName, aServerUid3, aServerFileName, serverthread);
#endif
	
	TTimeIntervalMicroSeconds32 w(10*1000);
	TInt i=0;
	TInt result=KErrTimedOut;
	while (i < 17) { 
		// a couple of minutes, in case there's some db conversion or the like
#ifdef __S60V3__
		if (semaphore.Wait(w.Int())==KErrNone) {
#else
		if ( semaphore.Count()>0) {
#endif
			result=KErrNone;
			break;
		}
		TExitType etype=serverthread.ExitType();
		if (etype!=EExitPending) {
			// server died
			result=KErrServerTerminated;
			break;
		}
#ifndef __S60V3__
		User::After(w);
#endif
		w=w.Int()*2;
		i++;
	}
	if (result!=KErrNone) {
		User::Leave(result);
	}

	semaphore.Close();
}

#if defined(__WINS__)
void CreateServerProcessLA(const TDesC& aServerName, TThreadFunction aFunction,
				RAThread& aThreadInto)
#else
#  if defined(__WINS__)
void CreateServerProcessLA(const TDesC& aServerName, TUid aServerUid3, 
				    const TDesC& aServerFileName,
				RAThread& aThreadInto)
#  else
void CreateServerProcessLA(const TDesC& aServerName, TUid aServerUid3, 
				    const TDesC& aServerFileName,
				RAProcess& aThreadInto)
#  endif
#endif
{
	CALLSTACKITEM_N(_CL(""), _CL("CreateServerProcess"));

	TInt result;
	
	
#if defined(__WINS__)
	
//#  if !defined(EKA2)
#if 0
	const TUidType serverUid(KNullUid, KNullUid, aServerUid3);
	RLibrary lib;
	TInt err=lib.Load(aServerFileName, _L("z:\\system\\programs"), serverUid);
	if (err!=KErrNone) {
		err=lib.Load(aServerFileName);
	}
	User::LeaveIfError(err);
	
	//  Get the WinsMain function
	TLibraryFunction functionWinsMain = lib.Lookup(1);
	
	//  Call it and cast the result to a thread function
	TThreadFunction serverThreadFunction = reinterpret_cast<TThreadFunction>(functionWinsMain());
#  else
	TThreadFunction serverThreadFunction = aFunction;
#  endif
	
	TName threadName(aServerName);
	
	// Append a random number to make it unique
	threadName.AppendNum(Math::Random(), EHex);
	
#  if 0
//#  if !defined(EKA2)
	aThreadInto.CreateLA(threadName,   // create new server thread
		serverThreadFunction, // thread's main function
		KDefaultStackSize,
		NULL,  // parameters
		&lib,
		NULL,
		KServerMinHeapSize,
		KServerMaxHeapSize,
		EOwnerProcess);
	lib.Close();    // if successful, server thread has handle to library now
	
#  else
	aThreadInto.CreateLA(threadName, serverThreadFunction, 
		KDefaultStackSize,
		KServerMinHeapSize, KServerMaxHeapSize, 0, EOwnerProcess);

#  endif
	
	aThreadInto.SetPriority(EPriorityMore);
	
#else
	
	const TUidType serverUid(KNullUid, KNullUid, aServerUid3);
	aThreadInto.CreateLA(aServerFileName, _L(""), serverUid);
	
#endif
	
	aThreadInto.Resume();
	
}
Esempio n. 27
0
void CAppStarter::StartL()
	{
	TFileName newname = iExeFileName;

	TThreadId threadId = 0;

	switch(iAppType)
		{
		case EApplicationType:
			{
			TApaAppInfo info;
			if(iSession.GetAppInfo(info,TUid::Uid(iAppUid)) != KErrNone)
				{
				After(KRetryWait);
				return;
				}
			
			if(iViewless)
				{
				TRAPD(err, TryStartViewlessAppL(info, threadId));
				if (err != KErrNone)
					{
					After(KRetryWait);
					return; //ignore error
					}
				}
			else if (info.iUid!=KNullUid)
				{
				if(iSession.StartDocument(newname, TUid::Uid(iAppUid), threadId) != KErrNone)
					{
					After(KRetryWait);
					return;
					}
				}
			else
				{
				iState = EAppFailed;
				Next();
				}
			}
			break;
		case EExecutableType:
			{
			newname.Append(KExtension);
			if(iSession.StartDocument(newname, TUid::Uid(0), threadId) != KErrNone)
				{
				After(KRetryWait);
				return;
				}
			}
			break;
		case ECmdLnArgExecutableType:
			{
			ASSERT( !iMonitoring); // Not imlpemented yet
#if defined(__WINS__) || defined(__WINSCW__)
			TName libName = iDllFileName;
			libName.Append(KExtension);
			RLibrary lib;
			TInt error = lib.Load(libName);
			if (error!=KErrNone)
				{
				After(KRetryWait);
				return;
				}
			TThreadFunction serverFunc=reinterpret_cast<TThreadFunction>(lib.Lookup(1));
			RThread server;
			error=server.Create(libName,serverFunc, iStackSize, iCmdLineArgs, &lib,NULL,
								iMinHeapSize,iMaxHeapSize,EOwnerProcess);
			lib.Close();	// if successful, server thread has handle to library now
#else
			RProcess server;
			TInt error = server.Create(newname, *iCmdLineArgs);
#endif
			if( error != KErrNone)
				{
				After(KRetryWait);
				return;
				}
			server.Resume();
			server.Close();
			}
			break;
		default:
			iState = EAppFailed;
			Next();
		}
	
	if (iMonitoring)
		{
		CThreadWatcher *threadWatcher=NULL;
		TRAPD(err, threadWatcher = CThreadWatcher::NewL(iAppType, threadId, newname, iStarter, iAppUid, iViewless));
		if (err == KErrNone) //ignore errors
			iQue->AddLast(*threadWatcher);
		}
	iState = EAppStarted;
	Next();
	}
Esempio n. 28
0
TInt E32Main()

	{

	test.Title();



	test.Start(_L("Test retrieving 0th ordinal and therefore named symbol export data"));

	

	E32EmulExpSymInfoHdr tmpHdr;

	E32EmulExpSymInfoHdr *readHdr;

	RLibrary library;



	// The values for the header of the dll with a 0th ordinal

	tmpHdr.iSymCount = 0x0;

	tmpHdr.iDllCount = 0x3;

	test(library.Load(_L("t_oedll.dll")) == KErrNone);

	test.Next(_L("Attempt to retrieve named symbol data from t_oedll.dll"));

	readHdr = (E32EmulExpSymInfoHdr*)library.Lookup(0);

	test(readHdr!=NULL);

//#define PRINT_ZEROTH

#ifdef PRINT_ZEROTH

	test.Printf(_L("iSymCount=%08x;iDllCounts=%08x\n"),readHdr->iSymCount,readHdr->iDllCount);

#endif

	test.Next(_L("Verify export data of t_oedll.dll is that expected"));

	VerifyHdr(tmpHdr, *readHdr);

	library.Close();



	test.Next(_L("Verify lookup on dll without oe export data returns NULL"));

	test(library.Load(_L("t_dll1.dll")) == KErrNone);

	readHdr = (E32EmulExpSymInfoHdr*)library.Lookup(0);

	test(readHdr == NULL);

	library.Close();



	// The values for the header of the exe of the current process with a 0th ordinal

	tmpHdr.iSymCount = 0x3;

	tmpHdr.iDllCount = 0x5;

	test.Next(_L("Attempt to retrieve named symbol data from current process"));

	readHdr = (E32EmulExpSymInfoHdr*)(RProcess::ExeExportData());

	test(readHdr!=NULL);

	test.Next(_L("Verify export data 0th ordinal data of this exe is that expected"));

#ifdef PRINT_ZEROTH

	test.Printf(_L("iSymCount=%08x;iDllCounts=%08x;\n"),readHdr->iSymCount,readHdr->iDllCount);

#endif

	VerifyHdr(tmpHdr, *readHdr);



/*

On Emulator can't examine fixups & depdencies via export data as data not included

in E32EmulExpSymInfoHdr.  This is all handled by the MS loader.



*/

	test.End();

	return KErrNone;

	}