/* * Copyright 2002-2019 Intel Corporation. * * This software is provided to you as Sample Source Code as defined in the accompanying * End User License Agreement for the Intel(R) Software Development Products ("Agreement") * section 1.L. * * This software and the related documents are provided as is, with no express or implied * warranties, other than those that are expressly stated in the License. */ #include #include #include #include "pin.H" ADDRINT newTLS = 0; ADDRINT newTLSSize = 0x80; void AllocateNewTLS() { newTLS = (ADDRINT)malloc(newTLSSize); } ADDRINT ProcessAddress(ADDRINT baseAddr, ADDRINT fullAddr, VOID *ip) { ADDRINT displacement = fullAddr - baseAddr; return newTLS + displacement; } void Instruction(INS ins, VOID *v) { RTN rtn = INS_Rtn(ins); if (RTN_Valid(rtn) && ((RTN_Name(rtn) == "SegAccessRtn") || (RTN_Name(rtn) == "SegAccessStrRtn"))) { REG segReg = INS_SegmentRegPrefix(ins); if ((segReg != REG_SEG_GS) && (segReg != REG_SEG_FS)) return; REG baseReg = (segReg == REG_SEG_GS)? REG_SEG_GS_BASE : REG_SEG_FS_BASE; for (UINT32 memopIdx=0; memopIdx