コード例 #1
0
VOID Instruction(INS ins, VOID *v)
{
    INT32 xedEtension = INS_Extension(ins);
    if (xedEtension==XED_EXTENSION_AVX ||
        xedEtension==XED_EXTENSION_SSE ||
        xedEtension==XED_EXTENSION_SSE2 ||
        xedEtension==XED_EXTENSION_SSE3 ||
        xedEtension==XED_EXTENSION_SSE4 ||
        xedEtension==XED_EXTENSION_SSE4A ||
        xedEtension==XED_EXTENSION_SSSE3 ||
        xedEtension==XED_EXTENSION_X87
        )
    {
        numInstruction++;
        xed_iclass_enum_t iclass = (xed_iclass_enum_t) INS_Opcode(ins);
        //if (numInstruction<=1)
        {
        //printf ("InstrumentingX# %d:  IP: %x   instruction: %s\n", numInstruction, INS_Address(ins), INS_Disassemble(ins).c_str());
        INS_InsertCall(ins, IPOINT_BEFORE, (AFUNPTR)VerifyFpContext,
                   IARG_INST_PTR,
                   IARG_CONTEXT,
                   IARG_END);
        INS_InsertCall(ins, IPOINT_AFTER, (AFUNPTR)VerifyFpContext,
                   IARG_INST_PTR,
                   IARG_CONTEXT,
                   IARG_END);
        }
    }
}
コード例 #2
0
ファイル: MyPinTool.cpp プロジェクト: Qilewuqiong/devilheart
/******************************************************************
 Title:instruction
 Function:Pin calls this function every time a new instruction is 
 executed
 Input:
 RTN rtn:The current instruction.
 VOID *v:The second argument.
 Output:
 VOID
******************************************************************/
VOID instruction(INS ins, VOID *v)
{
	/*fprintf(trace,insName.c_str());
	fprintf(trace,"\n");
	decode(ins);*/
	if(flag==0&&hasFound==0)
		return;
	else
		hasFound=1;
	if(flag==1&&hasFound==1){
		fprintf(output,"****************************************************\n");
		fprintf(output,"Before the application\n");
		ADDRINT baseAdd = getAddr();
		ADDRINT length = getSizeL();
		memManager->markTaintedBlock(baseAdd,length);
		memManager->printState(output);
		flag=0;
	}
	OPCODE opcode  = INS_Opcode(ins);
	UINT32 operandCount = INS_OperandCount(ins);
	UINT insExt = INS_Extension(ins);
	unsigned int realOpcode = opcode&0xffff;
	OperandKind kind = getOperandKind(ins);
	unsigned int insKind = INSNUM(realOpcode,kind);
	handleIns(insKind,ins);
}
コード例 #3
0
 static bool check_for_sse_memop(INS ins, bool& is_read, sse_aligner_t* pthis) 
 {
     // return true if the instruction is SSEx and reads/writes memory
     xed_extension_enum_t extension = static_cast<xed_extension_enum_t>(INS_Extension(ins));
     if (extension == XED_EXTENSION_SSE ||
         extension == XED_EXTENSION_SSE2 ||
         extension == XED_EXTENSION_SSE3 ||
         extension == XED_EXTENSION_SSSE3 ||
         extension == XED_EXTENSION_SSE4)
     {
         if (pthis->realign_loads && INS_IsMemoryRead(ins))
         {
             is_read = true;
             return true;
         }
         if (pthis->realign_stores && INS_IsMemoryWrite(ins)) 
         {
             is_read = false;
             return true;
         }
     }
     return false;
 }
コード例 #4
0
ファイル: MyPinTool.cpp プロジェクト: Qilewuqiong/devilheart
VOID decode(INS ins)
{
	OPCODE opcode  = INS_Opcode(ins);
	UINT32 operandCount = INS_OperandCount(ins);
	UINT insExt = INS_Extension(ins);
	unsigned int realOpcode = opcode&0xffff;
	unsigned int insKind = INSNUM(realOpcode,1);
	/*for(int i = 0;i<operandCount;i++){
		if(INS_OperandIsAddressGenerator(ins,i))
			fprintf(trace,"operand%d is address generator\n",i);
		else if(::INS_OperandIsMemory(ins,i))
			fprintf(trace,"operand%d is address\n",i);
		else if(::INS_OperandIsImmediate(ins,i))
			fprintf(trace,"operand%d is immediate\n",i);
		else if(::INS_OperandIsReg(ins,i))
			fprintf(trace,"operand%d is register\n",i);
		else if(INS_OperandIsBranchDisplacement(ins,i))
			fprintf(trace,"operand%d is branch displacement\n",i);
		else fprintf(trace,"operand%d is other type\n",i);
	}*/
	/*fprintf(trace,"Opcode:%d | operand count:%d\n",realOpcode,operandCount);
	OperandKind kind = getOperandKind(ins);
	fprintf(trace,"insNum:%d\n",INSNUM(opcode,kind));*/
}