MCPcopy Create free account
hub / github.com/connorjaydunn/BinaryShield / x86MovHandler

Function x86MovHandler

src/vm.cpp:83–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81 }
82
83 bool x86MovHandler(Instruction* instruction)
84 {
85 std::vector<ZydisDecodedOperand> operandInfo = instruction->getOperandInfo();
86
87 switch (operandInfo[0].type)
88 {
89 case ZYDIS_OPERAND_TYPE_REGISTER:
90 {
91 switch (operandInfo[1].type)
92 {
93 case ZYDIS_OPERAND_TYPE_REGISTER:
94 {
95 if (operandInfo[0].size == 32)
96 zeroRegister(instruction, operandInfo[0].reg.value);
97 emitPushRegister(instruction, operandInfo[1].reg.value, operandInfo[0].size);
98 emitPopRegister(instruction, operandInfo[0].reg.value, operandInfo[0].size);
99 return 1;
100 }
101 case ZYDIS_OPERAND_TYPE_IMMEDIATE:
102 {
103 if (operandInfo[0].size == 32)
104 zeroRegister(instruction, operandInfo[0].reg.value);
105 emitPushImmediate(instruction, operandInfo[1].imm.value.s, operandInfo[0].size);
106 emitPopRegister(instruction, operandInfo[0].reg.value, operandInfo[0].size);
107 return 1;
108 }
109 case ZYDIS_OPERAND_TYPE_MEMORY:
110 {
111 calculateEffectiveAddress(instruction, operandInfo[1].mem);
112 if (operandInfo[0].size == 32)
113 zeroRegister(instruction, operandInfo[0].reg.value);
114 emitRead(instruction, operandInfo[0].size);
115 emitPopRegister(instruction, operandInfo[0].reg.value, operandInfo[0].size);
116 return 1;
117 }
118 case ZYDIS_OPERAND_TYPE_POINTER: return 0;
119 case ZYDIS_OPERAND_TYPE_UNUSED: return 0;
120 }
121 }
122 case ZYDIS_OPERAND_TYPE_IMMEDIATE: return 0;
123 case ZYDIS_OPERAND_TYPE_MEMORY:
124 {
125 calculateEffectiveAddress(instruction, operandInfo[0].mem);
126 emitPopRegister(instruction, R0, 64);
127
128 switch (operandInfo[1].type)
129 {
130 case ZYDIS_OPERAND_TYPE_REGISTER:
131 {
132 emitPushRegister(instruction, operandInfo[1].reg.value, operandInfo[0].size);
133 emitPushRegister(instruction, R0, 64);
134 emitWrite(instruction, operandInfo[0].size);
135 return 1;
136 }
137 case ZYDIS_OPERAND_TYPE_IMMEDIATE:
138 {
139 emitPushImmediate(instruction, operandInfo[1].imm.value.s, operandInfo[0].size);
140 emitPushRegister(instruction, R0, 64);

Calls 8

zeroRegisterFunction · 0.85
emitPushRegisterFunction · 0.85
emitPopRegisterFunction · 0.85
emitPushImmediateFunction · 0.85
emitReadFunction · 0.85
emitWriteFunction · 0.85
getOperandInfoMethod · 0.80

Tested by

no test coverage detected