-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathVmReg.cpp
More file actions
executable file
·37 lines (30 loc) · 843 Bytes
/
VmReg.cpp
File metadata and controls
executable file
·37 lines (30 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "VmReg.h"
using namespace std;
const char* getRegisterName(DecodedRegister_t reg) {
static const char* registerIndex[] = {
"eflags",
"edi",
"esi",
"ebp",
"esp",
"ebx",
"edx",
"ecx",
"eax"
};
if(reg < 0 || reg > DecodedRegister_t::EAX)
return "???";
else
return registerIndex[reg];
}
DecodedRegister_t decodeVmRegisterReference(const uint8_t registerEncoded) {
unsigned long reference = registerEncoded;
reference = reference << 2;
reference -= 0x20;
reference ^= 0xFFFFFFFF;
reference += 1;
reference /= 4;
if(reference < 0 || reference > DecodedRegister_t::EAX)
return DecodedRegister_t::REG_UNKNOWN;
return (DecodedRegister_t)reference;
}