3 #include "misc/String.h"
9 Operand::Operand(std::string operand_string
) {
10 Register reg
= Register::from_string(operand_string
);
11 if(reg
!= Register::INVALID
) {
12 operand_type
= REGISTER
;
14 data_size
= reg
.get_register_size();
17 if(std::isdigit(operand_string
[0])) {
18 Misc::String::to
<Word
>(operand_string
, address
);
19 operand_type
= MEMORY_ADDRESS
;
22 operand_type
= REGISTER_OFFSET
;
25 QWORD PTR [rip+0x200541]
27 if(Misc::String::begins_with(operand_string
, "QWORD")) data_size
= Register::SIZE_QWORD
;
28 else if(Misc::String::begins_with(operand_string
, "DWORD")) data_size
= Register::SIZE_DWORD
;
29 else if(Misc::String::begins_with(operand_string
, "WORD")) data_size
= Register::SIZE_WORD
;
30 else if(Misc::String::begins_with(operand_string
, "BYTE")) data_size
= Register::SIZE_BYTE
;
31 operand_string
.erase(0, operand_string
.find("[")+1);
33 if(operand_string
.find("+") != std::string::npos
) {
34 offset
= operand_string
.substr(operand_string
.find("+"));
35 operand_string
.erase(operand_string
.find("+"));
37 else if(operand_string
.find("-") != std::string::npos
) {
38 offset
= operand_string
.substr(operand_string
.find("-"));
39 operand_string
.erase(operand_string
.find("-"));
41 Misc::String::to
<SWord
>(offset
, this->offset
);
42 this->reg
= Register::from_string(operand_string
);
46 } // namespace Monitor
47 } // namespace Aesalon