MCPcopy Create free account
hub / github.com/GJDuck/e9patch / decodePrefix

Function decodePrefix

src/e9patch/e9x86_64.cpp:61–98  ·  view source on GitHub ↗

* Decode an instruction prefix. */

Source from the content-addressed store, hash-verified

59 * Decode an instruction prefix.
60 */
61static int decodePrefix(const uint8_t *bytes, unsigned size, uint8_t &rex,
62 bool &addr32)
63{
64 int i;
65 rex = 0;
66 addr32 = false;
67 for (i = 0; i < (int)size; i++)
68 {
69 switch (bytes[i])
70 {
71 case 0x67: // Address-size override
72 addr32 = true;
73 // Fallthrough
74 case 0xf0: // LOCK
75 case 0xf2: // REPNE/REPNZ
76 case 0xf3: // REP or REPE/REPZ
77 case 0x2e: // CS segment override
78 case 0x36: // SS segment override
79 case 0x3e: // DS segment override
80 case 0x26: // ES segment override
81 case 0x64: // FS segment override
82 case 0x65: // GS segment override
83 case 0x66: // Operand-size override
84 continue;
85
86 // REX prefixes:
87 case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45:
88 case 0x46: case 0x47: case 0x48: case 0x49: case 0x4a: case 0x4b:
89 case 0x4c: case 0x4d: case 0x4e: case 0x4f:
90 rex = bytes[i];
91 continue;
92 default:
93 break;
94 }
95 break;
96 }
97 return i;
98}
99
100/*
101 * Decode an instruction opcode.

Callers 3

relocateInstrFunction · 0.85
getInstrPCRelativeIndexFunction · 0.85
getCFTInfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected