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; }
/** Attempt to load the library with the supplied name @param aLibrary Library object used to load the DLL @param aLibraryFilename file name of library to load @leave KErrNotSupported If UID2 of the DLL is not KStatePolicyDllTypeUidValue @leave KErrNotFound If the requested policy DLL file is missing. @leave KErrCorrupt Or any other system wide error code that the fileserver can raise. */ void CSsmSwpPolicyResolver::LoadLibraryLC(RLibrary& aLibrary, const TDesC& aLibraryFilename) const { CleanupClosePushL(aLibrary); const TInt fileErr = aLibrary.Load(aLibraryFilename); if (fileErr != KErrNone) { DEBUGPRINT3(_L("Failed to load library file %S, file error-code: %d"), &aLibraryFilename, fileErr); User::Leave(fileErr); } if (aLibrary.Type()[1] != KSsmSwpPolicyDllTypeUid) { DEBUGPRINT4(_L("Wrong type (uid2) in swp policy library dll %S. Expected %x found %x"), &aLibraryFilename, KSsmSwpPolicyDllTypeUid, aLibrary.Type()[1]); User::Leave(KErrNotSupported); } }
// ----------------------------------------------------------------------------- // 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(); }
// ----------------------------------------------------------------------------- // 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" ); }
GLDEF_C TInt E32Main() // // Test Uid handling. // { test.Title(); // test.Start(_L("Uid tests")); testUid(); // test.Next(_L("Checked Uid tests")); testCheckedUid(); // test.Next(_L("Check this process's Uids")); test(RProcess().Type()[1]==TUid::Uid(0x22222222)); test(RProcess().Type()[2]==TUid::Uid(0x33333333)); test.Next(_L("Load Uid DLL")); RLibrary lib; TInt r=lib.Load(_L("T_DUID.DLL")); test(r==KErrNone); test.Next(_L("Test FileName")); test.Printf(lib.FileName()); test.Printf(_L("\n")); #if defined(__WINS__) if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) test(lib.FileName().CompareF(_L("Z:\\Sys\\Bin\\T_DUID.DLL"))==0); else test(lib.FileName().CompareF(_L("Z:\\System\\Bin\\T_DUID.DLL"))==0); #else if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) test(lib.FileName().MatchF(_L("?:\\Sys\\Bin\\T_DUID.DLL"))!=KErrNotFound); else test(lib.FileName().MatchF(_L("?:\\System\\Bin\\T_DUID.DLL"))!=KErrNotFound); #endif test.Next(_L("Check DLL Uid")); test(lib.Type()[1]==TUid::Uid(0x12345678)); test(lib.Type()[2]==TUid::Uid(0x87654321)); lib.Close(); test.End(); return(KErrNone); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // 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); }