EXPORT_C void RKmsChannel::UsageAllowed(RProcess aUserProc, TKeyHandle aHandle, TInt aOperation, TBool& aAllowed, TRequestStatus& aStatus) /** Predicate function tests whether the supplied process can use the supplied key for the supplied operation. This API is defined for informational purposes only and is not used by the key management server. It's primary purpose is to test the key store drivers. @param aUserProc Process which wants to use the key. @param aHandle Identifies existing key in store. @param aOperation Numeric identifier for operation. Example operations include signing, but the actual meaning is not defined here. @param aAllowed On success this is set to whether or not the process can perform the requested operation with the key. Its value is undefined on failure. @param aStatus This object is completed when the request has finished. On completion it will contain KErrNone on success, any other error code on failure. In this context, "success" means can determine whether or not the operation is allowed. It does not necessarily mean the operation <em>is</em> allowed. */ { TUsageAllowedArgs uaa = {aUserProc.Handle(), aHandle, aOperation}; TUsageAllowedArgsPckg uaaPckg(uaa); DoRequest(EUsageAllowed, aStatus, (TAny*) &uaaPckg, (TAny*) &aAllowed); }
void CCmdSetpriority::DoRunL() { LoadMemoryAccessL(); TInt err = KErrNone; // Fix up priorities that we had to make different to kernel cos fshell can't handle negative arguments // See enum TThrdPriority in kern_priv.h for the meaning of these negative numbers switch(iPriority) { case 101: iPriority = -8; break; case 102: iPriority = -7; break; case 103: iPriority = -6; break; case 104: iPriority = -5; break; case 105: iPriority = -4; break; case 106: iPriority = -3; break; case 107: iPriority = -2; break; default: break; } if (iName) { TPtrC8 name8 = iName->Des().Collapse(); LeaveIfErr(iMemAccess.SetPriorityOverride(iPriority, name8), _L("Couldn't set priority override")); iNotifier = new(ELeave) CNewThreadNotifier(*this, iMemAccess); iNotifier->Start(); return; } if (iTids.Count() && iPids.Count()) { LeaveIfErr(KErrArgument, _L("You cannot specify both --tid and --pid - a single priority cannot be valid for thread and process.")); } for (TInt i = 0; i < iTids.Count(); i++) { TUint id = iTids[i]; RThread thread; err = iMemAccess.RThreadForceOpen(thread, id); if (!err) err = iMemAccess.SetThreadPriority(thread, iPriority); if (err) PrintError(err, _L("Couldn't set priority for thread %u"), id); thread.Close(); } for (TInt i = 0; i < iPids.Count(); i++) { TUint id = iPids[i]; // Get KProcessFlagPriorityControl flag RProcess process; err = process.Open(id); LeaveIfErr(err, _L("Couldn't open process with ID %u"), id); TBool priorityControlAllowed = EFalse; TPckg<TProcessKernelInfo> pkg(iProcInfo); err = iMemAccess.GetObjectInfoByHandle(EProcess, RThread().Id(), process.Handle(), pkg); if (err) { PrintWarning(_L("Couldn't get priority control flag setting (%d)\r\n"), err); } else { if (iProcInfo.iFlags & KProcessFlagPriorityControl) priorityControlAllowed = ETrue; } if (!priorityControlAllowed) { PrintError(KErrAccessDenied, _L("This process does not allow setting of its priority")); } else if (iPriority != EPriorityBackground && iPriority != EPriorityForeground) { PrintError(KErrAccessDenied, _L("The kernel will ignore requests to set a process priority that isn't Background (250) or Foreground (350). I can't see how to get round this even using memory access. Sorry.")); } process.SetPriority((TProcessPriority)iPriority); process.Close(); } Complete(KErrNone); }
// ---------------------------------------------------------------------------------------- // CTerminalControlServer::GetRunningProcessesL // ---------------------------------------------------------------------------------------- CBufFlat* CTerminalControlServer::GetRunningProcessesL( ) { RDEBUG("CTerminalControlServer::GetRunningProcessesL"); TFullName processName; TFindProcess findProcess; CBufFlat *buffer = CBufFlat::NewL(128); iProcessInfoArray->Reset(); while( KErrNone == findProcess.Next( processName ) ) { TTcProcessInfo info; RProcess process; if( KErrNone == process.Open( findProcess ) ) { // // Add process information to local array // info.iProcessName = processName; info.iFileName = process.FileName(); info.iHandle = process.Handle(); info.iId = process.Id(); info.iSecureId = process.SecureId(); info.iProtected = EFalse; process.GetMemoryInfo( info.iMemoryInfo ); User::IsRomAddress( info.iCodeInRom, (TAny*)(info.iMemoryInfo.iCodeBase) ); if( !info.iCodeInRom ) { User::IsRomAddress( info.iCodeInRom, (TAny*)(info.iMemoryInfo.iCodeBase) ); } iProcessInfoArray->AppendL( info ); // // Add process also to return buffer // /* TInt appendPosition = buffer->Size(); if(iProcessInfoArray->Count() >= 2) { TBuf8<sizeof(info.iProcessName)> proName; proName.Copy(info.iProcessName); buffer->InsertL(appendPosition, _L8("/")); buffer->InsertL(appendPosition+1, proName); } else { TBuf8<sizeof(info.iProcessName)> proName; proName.Copy(info.iProcessName); buffer->InsertL(appendPosition, proName); } } */ // Enumerate names from 1 TInt appendPosition = buffer->Size(); TBuf8<MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64> numBuf; TBuf8<sizeof(KFormatProcessNamePrefix)+20> nameBuf; numBuf.Num(iProcessInfoArray->Count()); nameBuf.Zero(); nameBuf.Append(KFormatProcessNamePrefix); nameBuf.Append(numBuf); if(iProcessInfoArray->Count() >= 2) { buffer->InsertL(appendPosition, _L8("/")); buffer->InsertL(appendPosition+1, nameBuf); } else { buffer->InsertL(appendPosition, nameBuf); } } } /* TUint32 flags = Exec::ProcessFlags(KCurrentProcessHandle); if (flags & KProcessFlagSystemPermanent) return ESystemPermanent; if (flags & KProcessFlagSystemCritical) return ESystemCritical; if (flags & KThreadFlagProcessPermanent) return EAllThreadsCritical; return ENotCritical; */ return buffer; }
// load an exe and check that it has the expected SMP unsafe count (check 1) // don't resume/delete it yet. void DoStartExe(RProcess& p, const TDesC &aFilename, TInt aExpectedUnsafe) { test_KErrNone(p.Create(aFilename, KNullDesC)); test_Equal(aExpectedUnsafe, ldd.ProcessSMPUnsafeCount(p.Handle())); }