Esempio n. 1
0
// Gets memory information of the process aproc
	int getMemoryInfo(RProcess& aproc,TDes&  aResult)
		{
		
		int res=KErrNone;
		#ifdef __WINSCW__
		aResult.AppendFormat(_L("     ?           ?      "));
		#else
		TModuleMemoryInfo mem;
		res=aproc.GetMemoryInfo(mem);
		aResult.AppendFormat(_L("%-11u %-10u"),mem.iCodeBase,(mem.iCodeSize + mem.iInitialisedDataSize+mem.iConstDataSize + mem.iUninitialisedDataSize)/512);
		#endif
		return res;
		}
int create_all_translation_caches()
	{
	TInt minsize = ROM_TRANSLATION_CACHE_SIZE + RAM_TRANSLATION_CACHE_SIZE + BIOS_TRANSLATION_CACHE_SIZE;
        TInt maxsize = ROM_TRANSLATION_CACHE_SIZE + RAM_TRANSLATION_CACHE_SIZE + BIOS_TRANSLATION_CACHE_SIZE + 3 * 4096;
	
	RProcess process;
	TModuleMemoryInfo  info;
	
	TInt error = process.GetMemoryInfo( info );
	if( error )
		return error;
	
	TUint32 programAddr = 0x10000000;//(TUint32) info.iCodeBase;
	programAddr += info.iCodeSize;
	
        TUint32 destAddr = programAddr - KDistanceFromCodeSection;
	
	g_code_chunk = new RChunk();

	TInt err = CreateChunkAt(destAddr,minsize, maxsize );
	
	TUint32 dynamiaddr = (TUint32) g_code_chunk->Base();
	
    DEBUG("CREATING HEAPS");
	g_code_heap = UserHeap::ChunkHeap(*g_code_chunk, minsize, 1, maxsize );
	if( g_code_heap != NULL )
	    {
	    DEBUG("ROM HEAP SUCCESS!");
	    rom_translation_cache = (u8*) g_code_heap->Alloc( ROM_TRANSLATION_CACHE_SIZE );
	    ram_translation_cache = (u8*) g_code_heap->Alloc( RAM_TRANSLATION_CACHE_SIZE );
	    bios_translation_cache = (u8*) g_code_heap->Alloc( BIOS_TRANSLATION_CACHE_SIZE );
	    if( rom_translation_cache == NULL)
	        DEBUG("ROM ALLOC FAIL!");
	    if( ram_translation_cache == NULL)
	        DEBUG("RAM ALLOC FAIL!");
	    if( bios_translation_cache == NULL)
	        DEBUG("BIOS ALLOC FAIL!");
	    }
	
	DEBUG("EVERYTHING DONE IN MEMORY HANDLING");
	
	rom_translation_ptr = rom_translation_cache;
	ram_translation_ptr = ram_translation_cache;
    bios_translation_ptr = bios_translation_cache;
    
    return 0;
	}
// ----------------------------------------------------------------------------------------
// 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;
}