⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mguardezboot.cpp,v

📁 symbian s60手机上的短信拦截源代码。
💻 CPP,V
字号:
head	1.1;branch	1.1.1;access;symbols	v1_0:1.1.1.1	xueyw:1.1.1	v111:1.1.1.1	MGuard:1.1.1	arelease:1.1.1.1	avendor:1.1.1;locks; strict;comment	@// @;1.1date	2007.07.24.10.59.30;	author administrator;	state Exp;branches	1.1.1.1;next	;deltatype	text;permissions	644;1.1.1.1date	2007.07.24.10.59.30;	author administrator;	state Exp;branches;next	;deltatype	text;permissions	644;desc@@1.1log@Initial revision@text@/** ============================================================================*  Name     : from MGuardEzboot.cpp*  Part of  : MGuardEzBoot*  Created  : July 9 2007 by xueyw*  Implementation notes:*     *  Version  :*  Copyright: * ============================================================================*/#include <e32std.h>#include <e32base.h>#include <e32def.h>#include <f32file.h>#include <apacmdln.h>#include <apgcli.h>#include <apmrec.h> #include <apmstd.h>#include "MGuardEzBoot.h"//	Recognition Definitions//	The MIME Type that will be recognized_LIT8(KEzbMimeType,"text/vnd.mezboot");//	The file extension that shall be used by data we are recognizing_LIT(KEzbFileExtension,".boot");//	The data header that identifies EZBoot data_LIT8(KEzbDataHeader,"MEZBoot:");//	The priority of the recognizer, can be EHigh, ENormal, ELow#define KEzRecognizerPriority CApaDataRecognizerType::ENormal//	The size of the data buffer that will be passed to the recognizer//	so that it performs the recognition#define KEzRecognizerBufferSize 7//	The recognizer UIDconst TUid KUidEzBoot={KUidRecog};//	Boot Definitions//	The application we want to boot (here the EZBoot server)_LIT(KEzBootExe,"\\system\\programs\\mguardmain.exe");//	The thread name that will used to launch the above EXE_LIT(KBootUpThreadName,"MEzBootThr");//	DLL entry point.GLDEF_C TInt E32Dll( TDllReason /*aReason*/ )	{	return KErrNone ;	}//----------------------------------------------------------------------------//	Recognizer instanciation. This function MUST be the first one defined //	for the recognizer.//	return a pointer on a new allocated recognizer instance//----------------------------------------------------------------------------//EXPORT_C CApaDataRecognizerType *CreateRecognizer()	{	// Create a recognizer instance	CApaDataRecognizerType *me = new CMGuardEzBootRecog();	// Start all the boot code under a trap harness	// This is pure boot code and has (normally) nothing to do 	// in a recognizer...	CMGuardEzBootRecog::BootUp();	return me;	}//----------------------------------------------------------------------------//	Recognizer Constructor. //	Initialise the internal data member iCountDataTypes with the number of //	MIME types that will be recognized. Set the recognizer priority.//----------------------------------------------------------------------------//CMGuardEzBootRecog::CMGuardEzBootRecog():CApaDataRecognizerType( KUidEzBoot, KEzRecognizerPriority )	{	iCountDataTypes = 1;	}//----------------------------------------------------------------------------//	Returns the size of the data buffer that will be passed to the recognition//	function (used by the recognition framework)//	see DoRecognizeL()//	return size of the data buffer//----------------------------------------------------------------------------//TUint CMGuardEzBootRecog::PreferredBufSize()	{	return KEzRecognizerBufferSize;	}//----------------------------------------------------------------------------//	Returns the MIME type that our recognizer is able to manage//	(used by the recognition framework)//	param aIndex: the index of the MIME type to return (will be always 1 for//	                a recognizer that handles a single MIME type)//	return a MIME type//----------------------------------------------------------------------------//TDataType CMGuardEzBootRecog::SupportedDataTypeL( TInt /*aIndex*/ ) const	{	return TDataType( KEzbMimeType );	}//----------------------------------------------------------------------------//	The recognition function. The result of the recognition is stored in //	the iConfidence data member.//	param aName:   the name of the file that contain the data to analyze//	param aBuffer: the data buffer//	see PreferredBufSize()//----------------------------------------------------------------------------//void CMGuardEzBootRecog::DoRecognizeL( TDesC& aName, const TDesC8& aBuffer )	{	//	Initialise the result status	iConfidence = ENotRecognized;	iDataType   = TDataType( KEzbMimeType );	//	Check that we got the required amount of data	if( aBuffer.Length() < KEzRecognizerBufferSize )		return;	//	Check that the file name corresponds to our criteria	TBool nameOK(EFalse);	nameOK = NameRecognized( aName );	//	Check that the data corresponds to our criteria	TBool headerOK(EFalse);	headerOK = HeaderRecognized( aBuffer );            	//	Conclude: 	// - if file name and data are OK then the data are certainly recognized	// - if only the data are recognized, then this is only a possibility	// - else the data have not been recognized	if( nameOK && headerOK )		{		iConfidence = ECertain;		}	else if( !nameOK && headerOK )		{		iConfidence = EPossible;		}	else		{		return;		}	}//----------------------------------------------------------------------------//	The file name recognition function. This functions checks whether the //	provided filename matches our criteria (here we want it to have the .boot//	extension)//	param aName: the name to check//	return ETrue if the file is OK//----------------------------------------------------------------------------//TBool CMGuardEzBootRecog::NameRecognized( const TDesC& aName )	{ 	TBool res=EFalse;	if(aName.Length()>5)		{		TInt dotPos = aName.LocateReverse( '.' );		if ( dotPos != KErrNotFound )			{			TInt extLength = aName.Length() - dotPos;			HBufC* ext = aName.Right( extLength ).AllocL();			CleanupStack::PushL( ext );			if ( ext->CompareF(KEzbFileExtension) == 0 )				{				res = ETrue;				}			CleanupStack::PopAndDestroy(); // ext			}		}	return(res);	}//----------------------------------------------------------------------------//	The data recognition function. This functions checks whether the //	provided data starts with our data header//	extension//	param aBuf: the data buffer to check//	return ETrue if the data are OK//----------------------------------------------------------------------------//TBool CMGuardEzBootRecog::HeaderRecognized( const TDesC8& aBuf )	{ 	if( aBuf.Find(KEzbDataHeader)==0 )		{		return ETrue;		}	return EFalse;	}//----------------------------------------------------------------------------//	The Boot code (non leaving). Create a new thread and kicks the real//	boot code. //	see BootUpKick()//----------------------------------------------------------------------------//void CMGuardEzBootRecog::BootUp()	{	// Create a new thread	RThread* bootThread = new RThread();	if( bootThread )		{		TInt res=KErrNone;		// and Start it		res = bootThread->Create(KBootUpThreadName,			CMGuardEzBootRecog::BootUpKick,			KDefaultStackSize,			KMinHeapSize,			KMinHeapSize,			NULL,			EOwnerThread );		if( res==KErrNone )			{			bootThread->Resume();			bootThread->Close();			}		else			{			delete bootThread;			}		}	}//----------------------------------------------------------------------------//	The threaded boot code (non leaving). Actually just create a cleanup//	stack and call a non-leaving implementation of the boot code//	see BootUp()//	see BootUpKickL()//	param aParam: not used but required as a thread entry point//	return thread result//----------------------------------------------------------------------------//TInt CMGuardEzBootRecog::BootUpKick( TAny* /*aParam*/ )	{	TInt err=KErrNoMemory;	// Create a cleanup stack...	CTrapCleanup *cleanup = CTrapCleanup::New();	if( cleanup )		{		//... and Kick under a trap harness		TRAP( err, CMGuardEzBootRecog::BootUpKickL() );		delete cleanup;		}	return err;	}//----------------------------------------------------------------------------//	The Boot code. //----------------------------------------------------------------------------//void CMGuardEzBootRecog::BootUpKickL()	{	// Get the full path (including drive letter)	// to the boot server	RFs fs;	User::LeaveIfError( fs.Connect() );	CleanupClosePushL( fs );	TFindFile findFile( fs );	User::LeaveIfError( findFile.FindByDir( KEzBootExe, KNullDesC ) );	// Connect to the Apparc server	// and start our server	RApaLsSession ls;	User::LeaveIfError( ls.Connect() );	CleanupClosePushL( ls );	CApaCommandLine *cmd = CApaCommandLine::NewLC();	cmd->SetLibraryNameL( findFile.File() );	cmd->SetCommandL( EApaCommandOpen );	User::LeaveIfError( ls.StartApp(*cmd) );	// Delete all stuff on the cleanup stack	CleanupStack::PopAndDestroy( 3 );	}@1.1.1.1log@no message@text@@

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -