Ejemplo n.º 1
0
		HardwareBreakpoint::HardwareBreakpoint(HANDLE hThread, UINT_PTR address, HardwareBreakpoint_Type_Code type, HardwareBreakpoint_Size size) :
				Breakpoint(address),
				m_thread(hThread)
		{
			CONTEXT con = {CONTEXT_DEBUG_REGISTERS};
			SuspendThread(hThread);
			GetThreadContext(hThread, &con);

			if(CheckBreakpoint(con, address))
			{
				set_bit(con.Dr7, type, 16 + m_register * 4);
				set_bit(con.Dr7, size, 18 + m_register * 4);
				set_bit(con.Dr7, 1,  m_register * 2);

				con.ContextFlags = CONTEXT_DEBUG_REGISTERS;
			}

			SetThreadContext(hThread, &con);
			ResumeThread(hThread);
		}
Ejemplo n.º 2
0
static void FindInterval( ChewingData *pgdata, TreeDataType *ptd )
{
	int end, begin, pho_id;
	Phrase *p_phrase, *puserphrase, *pdictphrase;
	UsedPhraseMode i_used_phrase;
	uint16_t new_phoneSeq[ MAX_PHONE_SEQ_LEN ];

	for ( begin = 0; begin < pgdata->nPhoneSeq; begin++ ) {
		for ( end = begin; end < pgdata->nPhoneSeq; end++ ) {
			if ( ! CheckBreakpoint( begin, end + 1, pgdata->bArrBrkpt ) )
				continue;

			/* set new_phoneSeq */
			memcpy( 
				new_phoneSeq,
				&pgdata->phoneSeq[ begin ],
				sizeof( uint16_t ) * ( end - begin + 1 ) );
			new_phoneSeq[ end - begin + 1 ] = 0;
			puserphrase = pdictphrase = NULL;
			i_used_phrase = USED_PHRASE_NONE;

			/* check user phrase */
			if ( UserGetPhraseFirst( pgdata, new_phoneSeq ) &&
					CheckUserChoose( pgdata, new_phoneSeq, begin, end + 1,
					&p_phrase, pgdata->selectStr, pgdata->selectInterval, pgdata->nSelect ) ) {
				puserphrase = p_phrase;
			}

			/* check dict phrase */
			pho_id = TreeFindPhrase( pgdata, begin, end, pgdata->phoneSeq );
			if ( 
				( pho_id != -1 ) && 
				CheckChoose( 
					pgdata,
					pho_id, begin, end + 1, 
					&p_phrase, pgdata->selectStr,
					pgdata->selectInterval, pgdata->nSelect ) ) {
				pdictphrase = p_phrase;
			}

			/* add only one interval, which has the largest freqency
			 * but when the phrase is the same, the user phrase overrides 
			 * static dict
			 */
			if ( puserphrase != NULL && pdictphrase == NULL ) {
				i_used_phrase = USED_PHRASE_USER;
			}
			else if ( puserphrase == NULL && pdictphrase != NULL ) {
				i_used_phrase = USED_PHRASE_DICT;
			}
			else if ( puserphrase != NULL && pdictphrase != NULL ) {
				/* the same phrase, userphrase overrides */
				if ( ! strcmp(
					puserphrase->phrase, 
					pdictphrase->phrase ) ) {
					i_used_phrase = USED_PHRASE_USER;
				}
				else {
					if ( puserphrase->freq > pdictphrase->freq ) {
						i_used_phrase = USED_PHRASE_USER;
					}
					else {
						i_used_phrase = USED_PHRASE_DICT;
					}
				}
			}
			switch ( i_used_phrase ) {
				case USED_PHRASE_USER:
					AddInterval( ptd, begin, end, -1, puserphrase,
							IS_USER_PHRASE );
					break;
				case USED_PHRASE_DICT:
					AddInterval( ptd, begin, end, pho_id, pdictphrase,
							IS_DICT_PHRASE );
					break;
				case USED_PHRASE_NONE:
				default:
					break;
			}
			internal_release_Phrase(
				i_used_phrase,
				puserphrase,
				pdictphrase );
		}
	}
}