// this is custom security check implemented just for example purposes // check that client process has secure UID of our UI client application CPolicyServer::TCustomResult CExPolicy_Server::CustomSecurityCheckL(const RMessage2& aMsg, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/) { CPolicyServer::TCustomResult test; test=EFail;// by default we will fail the test RThread ClientThread; aMsg.Client(ClientThread);// get client thread if(ClientThread.Handle())// has handle --> is valid { RProcess ClientProcess; ClientThread.Process(ClientProcess);// then get the process TSecureId ProsID = ClientProcess.SecureId();// and check secure UID if(ProsID.iId == KUidPhoneManager.iUid || ProsID.iId == KUidLockScreen.iUid)// is it same as with client { test=EPass;// pass check if it is, othervise it will fail } } return test; }
int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) { RThread rthread; const TInt status = CreateUnique(NewThread, &rthread, args); if (status != KErrNone) { thread->handle = 0; SDL_SetError("Thread create error"); return(-1); } rthread.Resume(); thread->handle = rthread.Handle(); return(0); }
int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) { RThread rthread; const TInt status = CreateUnique(NewThread, &rthread, args); if (status != KErrNone) { delete(((RThread*)(thread->handle))); thread->handle = NULL; SDL_SetError("Not enough resources to create thread"); return(-1); } rthread.Resume(); thread->handle = rthread.Handle(); return(0); }
// --------------------------------------------------------------------------- // Starts monitoring thread // --------------------------------------------------------------------------- // TInt CSensrvThreadMonitor::StartMonitoring(const RThread& aThread) { COMPONENT_TRACE( ( _L( "Sensor Server - CSensrvThreadMonitor::StartMonitoring()" ) ) ); TInt err(KErrNone); if (aThread.Handle()) { // If for some reason old iThread is still active, kill it. if ( (iThread.Handle()) && (iThread.Handle() != RThread().Handle()) ) { ERROR_TRACE( ( _L( "Sensor Sever - CSensrvThreadMonitor::StartMonitoring - ERROR: Old thread was still active, killing it." ) ) ); iThread.LogonCancel(iStatus); iThread.Terminate(KErrCancel); iThread.Close(); } // Old cleanuptimer needs to be deleted delete iCleanupTimer; iCleanupTimer = NULL; err = iThread.Open(aThread.Id()); if (err == KErrNone) { iThread.Logon(iStatus); SetActive(); #if defined (COMPONENT_TRACE_FLAG) || defined(ERROR_TRACE_FLAG) iThreadName = iThread.Name(); #endif } } else { ERROR_TRACE( ( _L( "Sensor Server - CSensrvThreadMonitor::StartMonitoring - ERROR: NULL handle" ) ) ); err = KErrBadHandle; } COMPONENT_TRACE( ( _L( "Sensor Server - CSensrvThreadMonitor::StartMonitoring - return %d" ), err ) ); return err; }
/** * Opens a handle to the null thread. */ static TBool FindNullThread( RThread& aThread ) { TFindProcess fp( KNullThreadProcessName ); TFullName kernelName; if ( fp.Next( kernelName ) == KErrNone ) { kernelName.Append( KNullThreadName ); TFindThread ft( kernelName ); TFullName threadName; if ( ft.Next( threadName ) == KErrNone ) { if ( aThread.Open( threadName ) != KErrNone ) { return EFalse; } } } return ( aThread.Handle() != 0 ); }
TInt Initialise(TZipInfo& a) { TInt r=InitInfo(a); if (r!=KErrNone) return r; a.iFileBufSize=4*a.iInBufSize; TAny* pFileBuf=MALLOC(a.iFileBufSize); if (!pFileBuf) return KErrNoMemory; a.iFileBuf=(TUint8*)pFileBuf; RThread t; r=t.Create(KLitThreadName,UnzipThread,0x2000,NULL,&a); if (r!=KErrNone) { delete pFileBuf; a.iFileBuf=NULL; return r; } t.SetPriority(EPriorityLess); t.Logon(a.iThreadStatus); t.Resume(); a.iThreadHandle=t.Handle(); return KErrNone; }
// this is custom security check implemented just for example purposes // check that client process has secure UID of our UI client application CPolicyServer::TCustomResult CExPolicy_Server::CustomSecurityCheckL(const RMessage2& aMsg, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/) { if(iFile.SubSessionHandle()) { iFile.Write(_L8("Security test\n,")); } CPolicyServer::TCustomResult test; test=EFail;// by default we will fail the test RThread ClientThread; aMsg.Client(ClientThread);// get client thread if(ClientThread.Handle())// has handle --> is valid { RProcess ClientProcess; ClientThread.Process(ClientProcess);// then get the process TSecureId ProsID = ClientProcess.SecureId();// and check secure UID if(ProsID.iId == (TUint32)KMAINYTasksUid31.iUid || ProsID.iId == (TUint32)KMAINYTasksUid32.iUid || ProsID.iId == (TUint32)KMAINYTasksUid33.iUid || ProsID.iId == (TUint32)KMAINYTasksUid34.iUid)// is it same as with client { if(iFile.SubSessionHandle()) { iFile.Write(_L8("Passed\n,")); } test=EPass;// pass check if it is, othervise it will fail } } return test; }
/** Requests de-initialization of the OpenMAX IL core. It closes the session to the IL Core server. @return OMX_ERRORTYPE */ OMX_ERRORTYPE ROmxILCoreClientSession::DeinitAndClose() { DEBUG_PRINTF(_L8("ROmxILCoreClientSession::DeinitAndClose")); #ifdef SYMBIAN_PERF_TRACE_OMX_IL OstPrintf(TTraceContext(KTracePerformanceTraceUID, EPerFormanceTraceClassification), Ost_OMXIL_Performance::K_OMX_PerformanceTraceFormatMin, Ost_OMXIL_Performance::EMeasurementStart, MAKESTRING(E_DeInit)); #endif #ifdef SYMBIAN_PERF_TRACE_OMX_IL_OSTV1 OstTrace0( TRACE_API, _DeinitAndClose1, "OMX_Deinit >" ); #endif // Param 0 OMX_ERRORTYPE err = OMX_ErrorNone; TPckgBuf<OMX_ERRORTYPE> pckg0; // Param 1 TUint64 serverThreadId = 0; TPckgBuf<TUint64> pckg1; TIpcArgs arg(&pckg0, &pckg1); SendReceive(EOmxILCoreDeinit, arg); // Extract the output values returned from the server. err = pckg0(); serverThreadId = pckg1(); RHandleBase::Close(); // Release server handle so it will exit cleanly. XGlobalILCoreCache* pGlobalILCoreCache = XGlobalILCoreCache::IlCoreCache(); __ASSERT_ALWAYS(pGlobalILCoreCache != NULL, User::Panic(KOmxILCoreClientPanic, KErrNotReady)); pGlobalILCoreCache->SetServerHandle(KNullHandle); RThread serverThread; TInt ret = serverThread.Open(TThreadId(serverThreadId)); if ((KErrNone == ret) && (serverThread.Handle() != KNullHandle)) { DEBUG_PRINTF2(_L8("ROmxILCoreClientSession::DeinitAndClose : serverThread.Handle =[%d]"), serverThread.Handle()); TBool logoffFailed = EFalse; TRequestStatus logoffStatus; serverThread.Logon(logoffStatus); if (logoffStatus == KErrNoMemory) { logoffFailed = ETrue; } if (!logoffFailed) { if (logoffStatus == KRequestPending) { User::WaitForRequest(logoffStatus); } else { serverThread.LogonCancel(logoffStatus); User::WaitForRequest(logoffStatus); } } else { serverThread.Kill(KErrDied); } } serverThread.Close(); #if defined(SYMBIAN_PERF_TRACE_OMX_IL) || defined(SYMBIAN_PERF_TRACE_OMX_IL_OSTV1) OMX_ERRORTYPE omxError = OMX_ErrorNone; if(KErrNone != err) { omxError = OMX_ErrorUndefined; } #endif #ifdef SYMBIAN_PERF_TRACE_OMX_IL TBuf8<1> DeInitStr; OstPrintf(TTraceContext(KTracePerformanceTraceUID, EPerFormanceTraceClassification), Ost_OMXIL_Performance::K_OMX_PerformanceTraceFormat, Ost_OMXIL_Performance::EMeasurementEnd, MAKESTRING(E_DeInit), omxError,&DeInitStr); #endif #ifdef SYMBIAN_PERF_TRACE_OMX_IL_OSTV1 OstTrace1( TRACE_API, _DeinitAndClose2, "OMX_Deinit < ReturnVal=%u", omxError ); #endif return err; }
void* ThreadSelf() { RThread Thread; return (void *)Thread.Handle(); }