-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasm.c
30 lines (27 loc) · 945 Bytes
/
asm.c
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
#include <stdio.h>
#include <stdint.h>
#include <string.h>
typedef struct {
uint32_t Imm;
uint8_t Pre, Opc, Mod, Reg, Rm, Sca, Ind, Bas;
} Insn;
extern uint8_t DiAsm(const uint8_t *Code, Insn *Result);
int main(){
/* 775DE18D | 01 1C C5 34 12 00 00 | add dword ptr ds:[eax*8+1234],ebx | */
uint8_t Raw[] = {0x01, 0x1C, 0xC5, 0x34, 0x12, 0x00, 0x00};
Insn Instruction;
memset(&Instruction, 0x00, sizeof(Insn));
uint8_t Size = DiAsm(Raw, &Instruction);
printf("Size: %x\n" // 0x07
"Imm : %x\n" // 0x1234
"Pre : %x\n" // 0x00
"Opc : %x\n" // 0x01
"Mod : %x\n" // 0x00
"Reg : %x\n" // 0x03
"Rm : %x\n" // 0x04
"Sca : %x\n" // 0x03
"Ind : %x\n" // 0x00
"Bas : %x\n" // 0x05
, Size, Instruction.Imm, Instruction.Pre, Instruction.Opc, Instruction.Mod, Instruction.Reg, Instruction.Rm, Instruction.Sca, Instruction.Ind, Instruction.Bas);
return 0;
}