VMAssembler  v1.2
VMProtect 2 Virtual Instruction Assembler
parser.h
Go to the documentation of this file.
1 #pragma once
2 #include <cstdint>
3 #include <functional>
4 #include <iostream>
5 #include <vector>
6 
11 {
15  std::string name;
16 
20  bool has_imm;
21 
25  std::uintptr_t imm;
26 };
27 
32 {
36  std::string label_name;
37 
41  std::vector< _vinstr_meta > vinstrs;
42 };
43 
47 using callback_t = std::function< bool( _vlabel_meta * ) >;
48 
52 class parse_t
53 {
54  public:
59  static auto get_instance() -> parse_t *;
60 
66  void add_label( std::string label_name );
67 
73  void add_vinstr( std::string vinstr_name );
74 
81  void add_vinstr( std::string vinstr_name, std::uintptr_t imm_val );
82 
88  bool for_each( callback_t callback );
89 
90  private:
94  std::vector< _vlabel_meta > virt_labels;
95 
99  parse_t();
100 };
this singleton class contains all the information for parsed virtual instructions....
Definition: parser.h:53
void add_label(std::string label_name)
used by yacc file to add new labels...
Definition: parser.cpp:13
bool for_each(callback_t callback)
used to loop over every single label...
Definition: parser.cpp:30
void add_vinstr(std::string vinstr_name)
used by yacc file to add new virtual instruction with no imm...
Definition: parser.cpp:20
static auto get_instance() -> parse_t *
gets the one and only instance of this class...
Definition: parser.cpp:7
std::function< bool(_vlabel_meta *) > callback_t
used for parse_t::for_each...
Definition: parser.h:47
raw virtual instruction information extracted using lex and yacc...
Definition: parser.h:11
std::uintptr_t imm
the imm if any...
Definition: parser.h:25
bool has_imm
if the virtual instruction has a second operand or not (imm)...
Definition: parser.h:20
std::string name
virtual instruction name...
Definition: parser.h:15
raw label containing raw virtual instruction data extracted using lex and yacc...
Definition: parser.h:32
std::string label_name
label name...
Definition: parser.h:36
std::vector< _vinstr_meta > vinstrs
vector of raw virtual instruction data...
Definition: parser.h:41