forked from akerou/fvp
-
Notifications
You must be signed in to change notification settings - Fork 2
/
hcbrebuilder.h
63 lines (49 loc) · 1.58 KB
/
hcbrebuilder.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef HCBREBUILDER_H
#define HCBREBUILDER_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "hcb_global.h"
extern _OP_DEF opdef[];
#define MAX_IDXCOUNT 8192
#define HASH_MODULO 257
#define HASH_BUCKETSIZE 128
class HcbRebuilder
{
public:
HcbRebuilder() {}
int rebuild(const char *txname, const char *hcbname);
private:
typedef enum { IDX_JMP, IDX_FUNC, IDX_IMPORT, IDX_PTR } IDX_TYPE;
typedef struct
{
char *name;
int offset;
} JMPOFFSET;
typedef struct
{
unsigned char *hcbbuf, *hcbp;
JMPOFFSET *labels[4];
unsigned int numlabels[4];
unsigned int *hashlabels;
unsigned int *hashidnum;
unsigned short *hashcounts;
unsigned int numFunc;
unsigned char *curFuncp;
unsigned char *importp;
} BUILD;
int remapImportList(BUILD *b);
int readFinalItems(BUILD *b, char *txp, char *txend);
int scanPropertyLine(const char *propname, char *txp, char *txend, int *nextline);
int parseLine(BUILD *b, char *txp, char *txend);
int genOpcodeData(BUILD *b, char *txp, char *txend);
int getOpcodeId(char *txp, const char *endp);
int resolveJumpOffsets(BUILD *b, int mode, unsigned char *p, unsigned char *endp);
int manageLabel(BUILD *b, char *val, int mode, IDX_TYPE type);
unsigned int hashstring(unsigned char *s);
int bytesUntilNextLine(const char *p, const char *endp);
int bytesUntilCRLF(const char *p, const char *endp);
int bytesWhitespace(const char *p, const char *endp);
};
#endif // HCBREBUILDER_H