📄 parser.h
字号:
// parser.cpp
// Copyright (C) 2008 Willow Schlanger
#ifndef l_crudcom__parser_h__included
#define l_crudcom__parser_h__included
#include <list>
#include <map>
#include <stdexcept>
#include <cstddef>
#include <fstream>
#include <iostream>
#include "../x86s/types.h"
#include "../x86s/x86s_common.h"
#include "../x86s/x86s_decode.h"
#include "../crudasm/asmwriter.h"
#include <set>
#include <cstdio>
#define ICODE_PEEP_SIZE 4 /* must be > 1, and must be a power of 2 */
namespace x86s {
struct metadata_t
{
U1 size : 4; // been here? 1 for invalid opcodes, bytes_left for insn's that overhang image size.
U1 local : 1; // part of current procedure?
U1 entry : 1; // is this the start of a procedure?
U1 branch : 1;
U1 decompiled : 1;
void clear(bool clear_entry)
{
size = 0;
local = 0;
if(clear_entry)
entry = 0;
decompiled = 0;
branch = 0;
}
};
struct memory_t
{
U1 *image;
metadata_t *meta;
U8 image_size;
U8 image_base; // origin -- image[0] is really here
U8 cs_base; // offset in image that cs:0 corresponds to [?]
U8 rip_mask;
};
struct parser_call_t
{
bool decompile;
std::set<U8> calls;
parser_call_t()
{
decompile = true;
}
};
typedef std::map<U8, parser_call_t> call_graph_t;
class parser_t
{
memory_t &memory;
public:
int dsz;
call_graph_t xgraph;
parser_t(memory_t &mem, int dsz_t);
// Call this between reparsing.
void reset();
// After calling reset, call this at least once.
void add_entrypoint(U8 target);
// Then call this to do the parsing.
// Returns true if reparsing is necessary.
bool parse();
private:
bool reparse;
void do_parse(U8 target);
std::set<U8> wanted_procs;
};
} // namespace x86s
#endif // l_crudcom__parser_h__included
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -