Ejemplo n.º 1
0
FRAMEDATA*  CEndDevicePool::GetNextData(EUI64 * id)
{
    FRAMEDATA *head = NULL;
    ENDDEVICE			*pEndDevice;

    m_lockerPool.Lock();
    pEndDevice = FindEndDeviceByID(id);
    if (pEndDevice) LockEndDevice(pEndDevice);
    m_lockerPool.Unlock();

    if(pEndDevice) {
        head = GetNextData(pEndDevice);
        UnlockEndDevice(pEndDevice);
    }
    return head;
}
Ejemplo n.º 2
0
void DiskStreamer<DATUM>::Shutdown() {
  multi_buffer_.WorkerThreadShutdown();
  while (GetNextData(1).size() > 0);
}
Ejemplo n.º 3
0
void PS2KeyboardAnalyzer::WorkerThread()
{
	mData = GetAnalyzerChannelData( mSettings->mDataChannel );
	mClock = GetAnalyzerChannelData( mSettings->mClockChannel );

	//begin from here
	for( ; ; )
	{	
		//init all variables, these will be updated by the GetNextData function

		U64 DataPayload =0;
		U64 frame_starting_sample;
		U64 frame_ending_sample;
		
		bool DeviceTx = false;
		bool ParityError = false;
		bool ACKed = false;
		
		//get a data transmission
		GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, DataPayload, ParityError, ACKed);
		
		Frame frame;	
		frame.mStartingSampleInclusive = frame_starting_sample;

		U8 flags =0x00;
		
		//begin to analyze the frame based on direction of transmission
		if(DeviceTx)
		{
			if(mSettings->mDeviceType==0)
			{
				//transmission is from Device->Host, device is keyboard
				flags = flags | TX_DEVICE_TO_HOST;
				
				bool EndOfFrame = false;

				while(!EndOfFrame)
				{
					if(DataPayload==0xE0)
					{
						//extended key code
						flags = flags | EXTENDED_KEY;
						GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, DataPayload, ParityError, ACKed);
						EndOfFrame=false;
					}
					else if (DataPayload==0xEE)
					{
						flags = flags | DATA_FRAME;
						frame.mData2 = ECHO_FRAME;
						EndOfFrame = true;
					}
					else if (DataPayload==0xAA)
					{
						flags = flags | DATA_FRAME;
						frame.mData2 = BAT_FRAME;
						EndOfFrame = true;
					}
					else if (DataPayload==0xFA)
					{
						flags = flags | DATA_FRAME;
						frame.mData2 = ACK_FRAME;
						EndOfFrame = true;
					}
					else if(DataPayload==0xF0)
					{
						//break code
						flags = flags | BREAK_CODE;
						GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, DataPayload, ParityError, ACKed);
						EndOfFrame=false;
					}
					else if(DataPayload==0xE1)
					{
						//Pause/break key
						bool IsErrorInTx = false;
						bool finished = false;
						U64 compare_data[7] = {0x14,0x77,0xE1,0xF0,0x14,0xF0,0x77};
						int cnt=0;

						while(!IsErrorInTx && !finished)
						{
							GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, DataPayload, ParityError, ACKed);
							
							if(compare_data[cnt]!=DataPayload)
								IsErrorInTx = true;
							else
								cnt++;

							if(cnt>6)
								finished=true;
						}

						if(finished)
							flags = flags | PAUSE_BREAK;
						else
							flags = flags | ERROR_FRAME;
						
						EndOfFrame=true;
					}
					else if(DataPayload==0x12 && (flags&EXTENDED_KEY))
					{
						//Print Screen Make
						bool IsErrorInTx = false;
						bool finished = false;
						U64 compare_data[2] = {0xE0,0x7C};
						int cnt=0;

						while(!IsErrorInTx && !finished)
						{
							GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, DataPayload, ParityError, ACKed);
							
							if(compare_data[cnt]!=DataPayload)
								IsErrorInTx = true;
							else
								cnt++;

							if(cnt>1)
								finished=true;
						}

						if(finished)
						{
							flags = flags | PRINT_SCREEN | MAKE_CODE;
						}
						else
							flags = flags | ERROR_FRAME;
						
						EndOfFrame=true;
					}
					else if(DataPayload==0x7C && flags&BREAK_CODE && flags&EXTENDED_KEY)
					{
						//Print Screen Break
						bool IsErrorInTx = false;
						bool finished = false;
						U64 compare_data[3] = {0xE0,0xF0,0x12};
						int cnt=0;

						while(!IsErrorInTx && !finished)
						{
							GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, DataPayload, ParityError, ACKed);
							
							if(compare_data[cnt]!=DataPayload)
								IsErrorInTx = true;
							else
								cnt++;

							if(cnt>2)
								finished=true;
						}

						if(finished)
						{
							flags = flags | PRINT_SCREEN | BREAK_CODE;
						}
						else
							flags = flags | ERROR_FRAME;
						
						EndOfFrame=true;
					}
					else
					{
						//value
						EndOfFrame=true;
					}
				}

				frame.mData1 = DataPayload;
			}
			else
			{
				//device is a mouse, transmission from device to house
				flags = flags | TX_DEVICE_TO_HOST;
		
					if(DataPayload==0xFA)
					{
						flags = flags | DATA_FRAME;
						frame.mData2 = ACK_FRAME;
					}
					else if (DataPayload==0xAA)
					{
						flags = flags | DATA_FRAME;
						frame.mData2 = BAT_FRAME;
					}
					else if(DataPayload&0x08)
					{
						flags = flags | MOVEMENT_FRAME;

						U64 movement_packet[4] = {0x00, 0x00, 0x00, 0x00};
						movement_packet[0] = DataPayload;

						GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, movement_packet[1], ParityError, ACKed);

						GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, movement_packet[2], ParityError, ACKed);

						if(mSettings->mDeviceType==2)
							GetNextData(frame_starting_sample, frame_ending_sample, DeviceTx, movement_packet[3], ParityError, ACKed);					
						
						DataPayload = movement_packet[3]<<24 | movement_packet[2]<<16 | movement_packet[1]<<8 | movement_packet[0];
					}
					else
					{

					}
				frame.mData1 = DataPayload;
			}
		}
		else
		{
			//transmission is Host->Device
			flags = flags | TX_HOST_TO_DEVICE;
			frame.mData1 = DataPayload;

		}
		frame.mFlags = flags;
		frame.mEndingSampleInclusive = frame_ending_sample;
		
		mResults->AddFrame(frame);
		mResults->CommitResults();

		ReportProgress( frame.mEndingSampleInclusive );
		CheckIfThreadShouldExit();

	}

}