void RemoveContainerL() { if ( iContainer ) { AppUi()->RemoveFromViewStack( *this, iContainer ); } RPointerArray<MSettingFactory> deactivated; for (TInt ordinal = 0; ordinal < iItemDefs.Count(); ordinal++) { TItemDef def = iItemDefs[ ordinal ]; MSettingFactory* factory = def.iFactory; if ( deactivated.Find( factory) == KErrNotFound ) { factory->DeactivateL(); deactivated.AppendL( factory ); } } deactivated.Close(); delete iListbox; iListbox = NULL; if ( iSettingItemArray ) iSettingItemArray->ResetAndDestroy(); delete iSettingItemArray; iSettingItemArray = NULL; delete iContainer; iContainer = NULL; }
// ========================================================================== // METHOD: DoReleaseLogFileHandler // // DESIGN: // ========================================================================== void CDebugLogTlsData::DoReleaseLogFileHandler( CLogFileHandler* aHandler, RDebugLog* aObject ) { TInt index = aHandler->iObjects.FindL( aObject ); if( index >= 0 ) { //#ifdef __MAKE_COPY_OF_NAMES delete aHandler->iObjectNames[index]; aHandler->iObjectNames.Remove(index); //#endif aHandler->iObjects.Remove( index ); if( aHandler->iObjects.Count() == 0 ) { iFiles.Remove( iFiles.Find(aHandler) ); delete aHandler; } // end if } else { // Something is wrong. The most likely case is incorrect usage of the debug log macros. _LIT8( KDummyFuncName, "***" ); _LIT8( KErrorText, "INCORRECT DEBUG LOG USAGE!" ); aObject->Write( KDummyFuncName, KErrorText ); } } // END DoReleaseLogFileHandler
void UpdateListBoxL() { iSettingItemArray->ResetAndDestroy(); RPointerArray<MSettingFactory> activated; for (TInt ordinal = 0; ordinal < iItemDefs.Count(); ordinal++) { TItemDef def = iItemDefs[ ordinal ]; MSettingFactory* factory = def.iFactory; if ( activated.Find( factory) == KErrNotFound ) { factory->ActivateL(); activated.AppendL( factory ); } CAknSettingItem* item = factory->CreateItemL( def.iIdentifier, ordinal ); iSettingItemArray->InsertL( ordinal, item ); //item->SetParentListBox( iListbox ); } activated.Close(); iSettingItemArray->RecalculateVisibleIndicesL(); // Calling HandleItemAdditional redraws whole list. iListbox->HandleItemAdditionL(); iListbox->UpdateScrollBarsL(); }
// --------------------------------------------------------------------------- // CTestStartupListUpdater::CheckStartListDoesNotContainL() // --------------------------------------------------------------------------- // TInt CTestStartupListUpdater::CheckStartListDoesNotContainL( CStifItemParser& aItem ) { _LIT( KTestName, "NotInStartList" ); Print( 0, KTestStartFormat, &KTestName ); TInt testResult = KErrNone; RPointerArray<HBufC> startupList; CleanupResetAndDestroyPushL( startupList ); GetStartupListL( startupList ); TIdentityRelation<HBufC> compareFileNames( FileNamesEqual ); TPtrC param; while( aItem.GetNextString ( param ) == KErrNone ) { HBufC* buf = param.AllocLC(); if( startupList.Find( buf, compareFileNames ) >= 0 ) { testResult = KErrAlreadyExists; } CleanupStack::PopAndDestroy( buf ); Print( 1, KTestParamFormatArg, &KTestName, ¶m, testResult ); } CleanupStack::PopAndDestroy( &startupList ); Print( 0, KTestDoneFormat, &KTestName ); return testResult; }
void CGlxMediaListsTestCollectionPlugin::RemoveItemL(const TGlxMediaId& aId, RPointerArray<CItem>& aDatabase) { TIdentityRelation<CItem> match(&MatchById); CItem* mediaToCompare = new (ELeave) CItem(); CleanupStack::PushL(mediaToCompare); mediaToCompare->iId = TGlxMediaId(aId); TInt index = aDatabase.Find(mediaToCompare, match); delete aDatabase[index]; aDatabase.Remove(index); CleanupStack::PopAndDestroy(mediaToCompare); }
// --------------------------------------------------------------------------- // Adds callback for line status change controlling // The callback will be called when serious read error is detected // --------------------------------------------------------------------------- // TInt CDunStream::AddConnMonCallback( MDunConnMon* aCallback, TDunOperationType aOperationType ) { FTRACE(FPrint( _L("CDunStream::AddConnMonCallback()" ) )); RPointerArray<MDunConnMon>* callbacks = NULL; if ( aOperationType == EDunOperationTypeRead ) { callbacks = &iCallbacksR; } else if ( aOperationType == EDunOperationTypeWrite ) { callbacks = &iCallbacksW; } else { FTRACE(FPrint( _L("CDunStream::AddConnMonCallback() (ERROR) complete" ) )); return KErrGeneral; } if ( !aCallback ) { FTRACE(FPrint( _L("CDunStream::AddConnMonCallback() (aCallback) not initialized!" ) )); return KErrGeneral; } TInt retTemp = callbacks->Find( aCallback ); if ( retTemp != KErrNotFound ) { FTRACE(FPrint( _L("CDunStream::AddCallback() (already exists) complete" ) )); return KErrAlreadyExists; } retTemp = callbacks->Append( aCallback ); if ( retTemp != KErrNone ) { FTRACE(FPrint( _L("CDunStream::AddCallback() (append failed!) complete" ) )); return retTemp; } FTRACE(FPrint( _L("CDunStream::AddCallback() complete" ) )); return KErrNone; }
//----------------------------------------------------------------------------- //Function Name : void* DlSymByDependencyOrdering(const void* aHandle, // const char* aName) //Description : To search for Symbol named name in statically dependent dll // on aSymInfoHeader, is dependencies, also dependencies of // dependencies using Dependency-ordering. //Return Value : Valid address if name found otherwise NULL //----------------------------------------------------------------------------- void* DlSymByDependencyOrdering(const void* aHandle,const char* aName) { //Get 0th ordinal datastructure of dll denoted by handle. LoadedDlls()->Lock(); TInt idx = LoadedDlls()->Find(aHandle); //check if handle not found if ( KErrNotFound == idx ) { LoadedDlls()->UnLock(); SetError(KDlSymErrBadHandle); return NULL; } TDllEntry& dllEntry = LoadedDlls()->At(idx); TE32ExpSymInfoHdr* symInfoHeader = dllEntry.iSymbolHeader; // The below 'if' condition prevents the symbol lookup on non-STDDLL // Check for the symbol information, if not found // return with KDlSymErrNoSupport if( !dllEntry.iSymbolHeader ) { LoadedDlls()->UnLock(); SetError(KDlSymErrNoSupport); return NULL; } TBuf8<KMaxFileName> fileName; fileName.Copy(dllEntry.iLibrary.FileName()); //Queue for using Breadthfirst search / Dependency ordering. RPointerArray<TE32ExpSymInfoHdr> dependentDllQue; //add first item in queue TInt err = dependentDllQue.Append(symInfoHeader); if ( KErrNone != err ) { LoadedDlls()->UnLock(); dependentDllQue.Close(); SetError(KDlSymErrNoMemory); return NULL; } TUint8* dependencyTableOffset; TE32ExpSymInfoHdr* tempSymInfoHeader = NULL; //Array of searched dlls. Used to check circular dependency RPointerArray<TE32ExpSymInfoHdr> searchedDlls; void* symAddr = NULL; //Breath First search for Dependancy ordering. while(dependentDllQue.Count()) { symInfoHeader = dependentDllQue[0]; dependentDllQue.Remove(0); // The below 'if' condition prevents the symbol lookup on dependent non-STDDLL if(!symInfoHeader) { continue; } //Search in this dll's symbol table symAddr = SearchName(symInfoHeader, aName); if( symAddr ) { LoadedDlls()->UnLock(); dependentDllQue.Close(); searchedDlls.Close(); return symAddr; } //Insert this to searched list err = searchedDlls.Append(symInfoHeader); if ( KErrNone != err ) { LoadedDlls()->UnLock(); dependentDllQue.Close(); searchedDlls.Close(); SetError(KDlSymErrNoMemory); return NULL; } //Add list of dependencies dependencyTableOffset = (TUint8*) symInfoHeader + symInfoHeader->iDepDllZeroOrdTableOffset; //Add at last to make it Queue, needed for Dependency ordering for (TInt i = 0; i < symInfoHeader->iDllCount; i++) { //get i'th dependency tempSymInfoHeader = *( (TE32ExpSymInfoHdr**) (dependencyTableOffset + (KFourByteOffset*i))); //check i'th dependency is OE dll e.i. equal to zero or not //and also its not already searched if ( tempSymInfoHeader && searchedDlls.Find(tempSymInfoHeader) == KErrNotFound ) { err = dependentDllQue.Append(tempSymInfoHeader); if ( KErrNone != err ) { LoadedDlls()->UnLock(); dependentDllQue.Close(); searchedDlls.Close(); SetError(KDlSymErrNoMemory); return NULL; } } } } LoadedDlls()->UnLock(); dependentDllQue.Close(); searchedDlls.Close(); //Symbol not found return NULL SetError(KDlSymErrNotFound); return NULL; }
//----------------------------------------------------------------------------- //Function Name : TInt SearchSymbolByLoadordering(TE32ExpSymInfoHdr* symInfoHeader // , char* aFileName, const char* aName, // RPointerArray<TE32ExpSymInfoHdr>& aSearchedDlls, // void*& aSymAddress) //Description : To search for Symbol named name in statically dependent dll // on aSymInfoHeader, it may be belonging to EXE or a DLL, also // dependencies of dependencies using Load-ordering. It also sets // valid address in aSymAddress if name found, and all sll it searched in // aSearchedDlls param. //Return Value : KErrNone if symbol found otherwise system wide error codes. //----------------------------------------------------------------------------- TInt SearchSymbolByLoadordering(const TE32ExpSymInfoHdr* aSymInfoHeader, const char* aName, RPointerArray<TE32ExpSymInfoHdr>& aSearchedDlls, void*& aSymAddress) { //This is used as stack for Load-ordering or Depthfirst search. RPointerArray<TE32ExpSymInfoHdr> dependentDllStack; aSymAddress = NULL; //Add exe on the stack TInt err = dependentDllStack.Append(aSymInfoHeader); if ( KErrNone != err ) { dependentDllStack.Close(); return KErrNoMemory; } TE32ExpSymInfoHdr* symInfoHeader; //temporary pointer to TUint8* dependencyTableOffset; TE32ExpSymInfoHdr* tempSymInfoHeader = NULL; TInt lastIdx = 0; //Retunn address would be stored in this void* symAddr = NULL; //Depth First search for Load-ordering. Intentional use of "=" while ( lastIdx >= 0 ) { //Take first dll on the stack i.e. topmost symInfoHeader = dependentDllStack[lastIdx]; //Remove from stack dependentDllStack.Remove(lastIdx); if(!symInfoHeader) { //skip non-std binaries... lastIdx = dependentDllStack.Count() - 1; continue; } //Search in current dll Symbol table. symAddr = SearchName(symInfoHeader, aName); //Check if Symbol is found if( symAddr ) { dependentDllStack.Close(); aSymAddress = symAddr; return KErrNone; } //Add this dll to list of searched dlls err = aSearchedDlls.Append(symInfoHeader); if ( KErrNone != err ) { dependentDllStack.Close(); return KErrNoMemory; } dependencyTableOffset = (TUint8*) symInfoHeader + symInfoHeader->iDepDllZeroOrdTableOffset; //All all the dependent dll for current dll/exe for (TInt i = symInfoHeader->iDllCount - 1; i >= 0; --i) { tempSymInfoHeader = *((TE32ExpSymInfoHdr**) (dependencyTableOffset + (KFourByteOffset * i))); if ( tempSymInfoHeader && aSearchedDlls.Find(tempSymInfoHeader) == KErrNotFound ) { err = dependentDllStack.Append(tempSymInfoHeader); if ( KErrNone != err ) { dependentDllStack.Close(); return KErrNoMemory; } } } lastIdx = dependentDllStack.Count() - 1; } dependentDllStack.Close(); return KErrNotFound; }
//----------------------------------------------------------------------------- //Function Name : void* DlSymByDependencyOrdering(const void* aHandle, // const char* aName) //Description : To search for symbol named name in statically dependent dll // on aSymInfoHeader, is dependencies, also dependencies of // dependencies using Dependency-ordering. //Return Value : Valid address if name found otherwise NULL //----------------------------------------------------------------------------- void* DlSymByDependencyOrdering(const void* aHandle,const char* aName) { //Get 0th ordinal datastructure of dll denoted by handle. LoadedDlls()->Lock(); TInt idx = LoadedDlls()->Find(aHandle); //check if handle not found if ( KErrNotFound == idx ) { LoadedDlls()->UnLock(); SetError(KDlSymErrBadHandle); return NULL; } TDllEntry& dllEntry = LoadedDlls()->At(idx); // The below 'if' condition prevents the symbol lookup on non-STDDLL // Check for the symbol information, if not found // return with KDlSymErrNoSupport if( !dllEntry.iSymbolHeader ) { LoadedDlls()->UnLock(); SetError(KDlSymErrNoSupport); return NULL; } TBuf8<KMaxFileName> fileName; if(CnvUtfConverter::ConvertFromUnicodeToUtf8(fileName,dllEntry.iLibrary.FileName()) != 0) { LoadedDlls()->UnLock(); return NULL; } TE32ExpSymInfoHdr* symInfoHeader = dllEntry.iSymbolHeader; //Queue for using Breadthfirst search / Dependency ordering. RArray<TImageData> dependentDllQue; TImageData imageData((char*)fileName.PtrZ(), symInfoHeader); //add first item in queue TInt err = dependentDllQue.Append(imageData); if ( KErrNone != err ) { LoadedDlls()->UnLock(); dependentDllQue.Close(); SetError(KDlSymErrNoMemory); return NULL; } char* curDll = NULL; char* dependentDll = NULL; HMODULE handleToDll = NULL; TBuf<KMaxFileName> dependentfileName; TE32ExpSymInfoHdr* tempSymInfoHeader = NULL; void* symAddr = NULL; TPtrC8 tempPtr; //Array of searched dlls. Used to check circular dependency //this is array of pointer to name of dll in image RPointerArray<TE32ExpSymInfoHdr> searchedDlls; //Breath First search for Dependancy ordering. while(dependentDllQue.Count()) { imageData = dependentDllQue[0]; curDll = imageData.iFileName; symInfoHeader = imageData.iSymInfoHeader; dependentDllQue.Remove(0); // The below 'if' condition prevents the symbol lookup on dependent non-STDDLL if(!symInfoHeader) { continue; } tempPtr.Set((unsigned char*)curDll, strlen(curDll)); dependentfileName.Copy(tempPtr); TParsePtr pParser(dependentfileName); dependentfileName = pParser.NameAndExt(); //Search in this dll's symbol table handleToDll = Emulator::GetModuleHandle(dependentfileName.PtrZ()); symAddr = Emulator::GetProcAddress(handleToDll,aName); //check if symbol is found if( symAddr ) { LoadedDlls()->UnLock(); dependentDllQue.Close(); searchedDlls.Close(); return symAddr; } //Insert this to searched list err = searchedDlls.Append(symInfoHeader); if ( KErrNone != err ) { LoadedDlls()->UnLock(); dependentDllQue.Close(); searchedDlls.Close(); SetError(KDlSymErrNoMemory); return NULL; } //Add list of dependencies dependentDll = (char*) symInfoHeader + sizeof(TE32ExpSymInfoHdr); //Add at last to make it Queue, needed for Dependency ordering for (TInt i = 0; i < symInfoHeader->iDllCount; i++) { tempPtr.Set((unsigned char*)dependentDll, strlen(dependentDll)); dependentfileName.Copy(tempPtr); //get i'th dependency handleToDll = Emulator::GetModuleHandle(dependentfileName.PtrZ()); Emulator::TModule aModule((HINSTANCE)handleToDll); tempSymInfoHeader = (TE32ExpSymInfoHdr*)aModule.Section(KWin32SectionName_NmdExpData); //check i'th dependency is OE dll e.i. equal to zero or not //and also its not already searched if ( tempSymInfoHeader && searchedDlls.Find(tempSymInfoHeader) == KErrNotFound ) { imageData.iFileName = dependentDll; imageData.iSymInfoHeader = tempSymInfoHeader; err = dependentDllQue.Append(imageData); if ( KErrNone != err ) { LoadedDlls()->UnLock(); dependentDllQue.Close(); searchedDlls.Close(); SetError(KDlSymErrNoMemory); return NULL; } } //advance to next dependent dll dependentDll += tempPtr.Length() + 1; } } LoadedDlls()->UnLock(); dependentDllQue.Close(); searchedDlls.Close(); //Symbol not found return NULL SetError(KDlSymErrNotFound); return NULL; }
//----------------------------------------------------------------------------- //Function Name : TInt SearchSymbolByLoadordering(TE32ExpSymInfoHdr* symInfoHeader // , char* aFileName, const char* aName, // RPointerArray<TE32ExpSymInfoHdr>& aSearchedDlls, // void*& aSymAddress) //Description : To search for symbol named name in statically dependent dll // on aSymInfoHeader, it may be belonging to EXE or a DLL, also // dependencies of dependencies using Load-ordering. It also sets // valid address in aSymAddress if name found, and all sll it searched in // aSearchedDlls param. //Return Value : KErrNone if symbol found otherwise system wide error codes. //----------------------------------------------------------------------------- TInt SearchSymbolByLoadordering(const TE32ExpSymInfoHdr* symInfoHeader, const char* aFileName, const char* aName, RPointerArray<TE32ExpSymInfoHdr>& aSearchedDlls, void*& aSymAddress) { //This is used as stack for Load-ordering or Depthfirst search. RArray<TImageData> dependentDllStack; //here on emulator we need two things one is Name to find symbol in that list, //second is TE32ExpSymInfoHdr to find dependencies TImageData imageData((char*)aFileName, (TE32ExpSymInfoHdr*)symInfoHeader); aSymAddress = NULL; //Add exe on the stack TInt err = dependentDllStack.Append(imageData); if ( KErrNone != err ) { dependentDllStack.Close(); return KErrNoMemory; } TE32ExpSymInfoHdr* tempSymInfoHeader = NULL; TInt lastIdx = 0; char* curDll = NULL; char* dependentDll = NULL; HMODULE handleToDll = NULL; TPtrC8 tempPtr; TBuf<KMaxFileName> dependentfileName; //Retunn address would be stored in this void* symAddr = NULL; //user to maintain load ordering RArray<TImageData> curDependentDll; TImageData tempImageData; //Depth First search for Load-ordering. while ( lastIdx >= 0 ) { //Take first dll on the stack i.e. topmost imageData = dependentDllStack[lastIdx]; symInfoHeader = imageData.iSymInfoHeader; //Remove from stack dependentDllStack.Remove(lastIdx); if(!symInfoHeader) { //skip non-std binaries... lastIdx = dependentDllStack.Count() - 1; continue; } curDll = imageData.iFileName; tempPtr.Set((unsigned char*)curDll, strlen(curDll)); dependentfileName.Copy(tempPtr); TParsePtr pParser(dependentfileName); dependentfileName = pParser.NameAndExt(); //Search in this dll's symbol table handleToDll = Emulator::GetModuleHandle(dependentfileName.PtrZ()); symAddr = Emulator::GetProcAddress(handleToDll,aName); //Check if Symbol is found if( symAddr ) { dependentDllStack.Close(); aSymAddress = symAddr; return KErrNone; } //Add this dll to list of searched dlls err = aSearchedDlls.Append(symInfoHeader); if ( KErrNone != err ) { dependentDllStack.Close(); return KErrNoMemory; } dependentDll = (char*) symInfoHeader + sizeof(TE32ExpSymInfoHdr); //if this image is an exe - the these would be some symbols if ( symInfoHeader->iSymCount ) {//skip all symbol addresse char* curSymbolStr = dependentDll + (KFourByteOffset * symInfoHeader->iSymCount); //skip all symbol names for (TInt i = 0; i < symInfoHeader->iSymCount; ++i ) { curSymbolStr += strlen(curSymbolStr) + 1; } //initialise first dependent dll name dependentDll = curSymbolStr; } //Store names of all dependent dlls of current dll/exe store there name in //curDependentDll. This is done to maintain load ordering. for (TInt i = 0; i < symInfoHeader->iDllCount; ++i) { tempPtr.Set((unsigned char*)dependentDll, strlen(dependentDll)); dependentfileName.Copy(tempPtr); handleToDll = Emulator::GetModuleHandle(dependentfileName.PtrZ()); Emulator::TModule aModule((HINSTANCE)handleToDll); tempSymInfoHeader = (TE32ExpSymInfoHdr*)aModule.Section(KWin32SectionName_NmdExpData); if ( tempSymInfoHeader && aSearchedDlls.Find(tempSymInfoHeader) == KErrNotFound ) { tempImageData.iFileName = dependentDll; tempImageData.iSymInfoHeader = tempSymInfoHeader; err = curDependentDll.Append(tempImageData); if ( KErrNone != err ) { dependentDllStack.Close(); curDependentDll.Close(); return KErrNoMemory; } } //advance to next dependent dll dependentDll += tempPtr.Length() + 1; } //add in load order to dependentDllStack for (TInt i = curDependentDll.Count() - 1; i >= 0; --i) { err = dependentDllStack.Append(curDependentDll[i]); if ( KErrNone != err ) { dependentDllStack.Close(); curDependentDll.Close(); return KErrNoMemory; } } curDependentDll.Close(); lastIdx = dependentDllStack.Count() - 1; } dependentDllStack.Close(); return KErrNotFound; }