⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ccx.h

📁 F:反汇编源码代码学习disasm.ZIP
💻 H
📖 第 1 页 / 共 2 页
字号:
/* standard clib */                     
# include <stdio.h> 
# include <stdarg.h>
# include <string.h>
# include <malloc.h>
# include <mem.h>

typedef void               *LPVOID;
typedef char                CHAR;
typedef short               WCHAR;
typedef short               SHORT;
typedef long                LONG;
typedef unsigned short      USHORT;
typedef unsigned long       DWORD;
typedef int                 BOOL;
typedef unsigned char       BYTE;
typedef unsigned short      WORD;
typedef BYTE               *PBYTE;
typedef WORD               *PWORD;
typedef DWORD              *PDWORD;
/* memory management functions */                   
# define p_calloc(x,y)  calloc((long)(x),(long)(y))
# define p_free(x)    free((VOID *)(x))
# define p_memleft()  32000

/* default defs */
# define VALUE int
# define BEGIN 
# define END 
# define TOKEN char            /* and TOKEN, if not int and char */
# define PARAM long            /* VALUE=synthetic, PARAM=inherited */
# define MAXPROGRAMSIZE 4096 
# define READBUFFERSIZE 2048   /* 20K (chars) is often too big in DOS*/
# define STACKSIZE 1           /* NOT NEEDED ANY MORE UNLESS OLD STYLE VV(n) */
                               /* ATTRIBUTE REFS ARE BEING SUPPORTED */
                               /* If set, it is very difficult to overun 2K ! */
/* msdos defns */
# define CONTEXTSTACKSIZE 1024
# define C_STACKSIZE 0x7FFF    /* expect to need as large a stack as possible */

                            /* compatibility */
# define STACKTOKENS 0      /* Don't put tokens on the attribute stack */
                            /* unless you are sure there is one! */
# define OLDATTRIBUTES 0    /* Don't generate code which supports $1, $2, ... */
                            /* (The $named attr. refs. are supported anyway) */

# define MAXARGS 16         /* number of params catered for */
                            /* DON'T change it! */

/* yylex hooks */
extern  int        yyfirsttime;
extern  int        yytchar;            /* the last thing yylex saw     */
extern  int        yylineno;        /* line count */
extern  int        goteof;
extern  PBYTE      yyfp, yypmax;
/* I'll put in the decls for the yystuff here, in case they're needed */
extern  int        yylen;
extern  int        yylex();
extern  VALUE      yylval;
extern  TOKEN     *yybuffer;    /* hook into the cc.c file */


/* local defs */
# define OPCODE char
# define VOID void

/* typedefs */
typedef PARAM status;            /* STATUS is returned by a PARSER */
# define STATUS status

typedef STATUS  PARSER();        /* PARSER returns a STATUS */
# define TOPARSER *(PARSER*)
# define TOVALUE (VALUE)
typedef VOID    ACTION();        /* VALUE stack manipulation */
typedef int boolean;             /* BOOLEAN is returned by a PREDICATE */
# define BOOLEAN boolean
typedef BOOLEAN PREDICATE();     /* PREDICATE returns a BOOLEAN */

typedef struct {            /* an INSTRUCTION consists of ... */
    OPCODE  opcode;         /* an OPCODE as opcode and ... */
    union {                 /* an ACTION or  ... */
        ACTION  *act;       /* a literal as operand. */
        TOKEN   tok;        /* The opcode selects the */
        VALUE   val;
        PARAM   par;
        } operand;             /* interpretation of the operand. */
}       INSTRUCTION;
typedef union {                /* The VALUE stack actually contains */
        VALUE val;        /* STACKVALUES, which may be either */
        TOKEN tok;        /* VALUEs or TOKENs. TOKENs are */
        PARAM par;        /* ... */
        } STACKVALUE;            /* pushed when literals are hit. */
typedef struct{             /* all the info required for a REWIND */
        TOKEN     *pstr;
        STACKVALUE *value;
        int pc;
        int lineno;
        /* INSTRUCTION instr;*/ /* will introduce for optimization */
        } FRAME;
typedef struct {
int     readbuffersize,      /* READBUFFERSIZE */
        maxprogramsize,      /* MAXPROGRAMSIZE */
        stacksize,           /* STACKSIZE */
        contextstacksize,    /* CONTEXTSTACKSIZE */
        stacktokens,         /* (boolean) support tokens as attrs for old code*/
        oldattributes;       /* (boolean) generate yacc style attr. refs */
}       PRECC_DATA;

#define M  50
#define MM M*2+1

typedef struct __key_ {
int     class;
int     c_pos;
int     c_ref;
} _key_, *PKEY;

typedef struct _Bnode {
    int            n;
    struct _Bnode *ptr[MM+1];
    _key_          key[MM];
}   Bnode;

/* instruction destructors and constructors */
# define Action(x) ((x).operand.act)
# define Token(x)  ((x).operand.tok)
# define Param(x)  ((x).operand.par)
# define Opcode(x) ((x).opcode)
# define Value(x)  ((x).operand.val)

/* status macros */
# define BADSTATUS(x)  (!(x))        /* BADSTATUS(x) is a PREDICATE */
# define GOODSTATUS(x) (x)           /* as is GOODSTATUS(x) */
# define INSTATUS(x) ( (PARAM) ( (long)(x) - ( (0>(int)(x)) ? 0 : 1 ) ) )
                                     /* success deconstructor */
# define OK(x) ( (STATUS) ( ( (0>(int)(x)) ? 0 : 1 ) + (long)(x) ) )
                                     /* success constructor */
# define KO(x) 0                     /* failure constructor */
# define SUCCESS OK(1)
# define FAILURE KO(0)


/* input stream manipulations */
                    /* MARK has to be first line in a */
                    /* routine. 'string' is a reserved */
                    /* local variable, as is 'count'. */
                    /* The MARK sets string and count to */
                    /* the current parse point and pc. */

#define MARK {\
fsave(p_frame);\
fpush(p_frame);\
}

                    /* REWIND resets the parse point and */
                    /* to the MARK at the head of the fn.*/
                    /* provided that a new line hasn't   */
                    /* already been read, in which case  */
                    /* just go back as far as possible */

#define REWIND {\
fpop(p_frame);\
frestore(p_frame);\
}
                    /* MOVEON budges the high-water mark */
                    /* maxp up to the current parse pt. */

/* 
 * maxp+1 is the first address I have not yet written into. The TOKEN
 * space should be occupied by a 0. maxp is the last position  I have
 * written into.
 *
 * pstr is the current TOKEN position. Notice that I am going to have to
 * read one TOKEN into *pstr to start up?
 *
 * We start with pstr=maxp=&buffer, and *buffer=first token.
 */

#define MOVEON get1token()

/* RELEASE destroys the frame */

# define RELEASE fpop(p_frame)

/* parsing activity control */
int isGoodAddress(int);

/* hooks to link disassembler and printing */
extern int        i_opclass;        /* needed to report instruction */

/* hooks to link pedump and parser and printing */

extern LPVOID     lpFile;
extern LPVOID     lpMap;
extern int        imagebaseRVA; /* image base of the file + code RVA */
extern int        CodeOffset;    /* starting point of code   */
extern int        CodeSize;      /* size of code             */
extern int        vCodeOffset;   /* starting point of code   */
extern int        vCodeSize;     /* size of code             */
extern int        MapSize;       /* size of code map         */
extern int        maxRVA;        /* the largest RVA of sections */
extern int        maxRVAsize;    /* size of that section */

extern char      *piNameBuff;	// import module name buffer
extern char      *pfNameBuff;	// import functions in the module name buffer
extern char      *peNameBuff;	// export function name buffer
extern char      *pmNameBuff;   // menu name buffer
extern char      *pdNameBuff;	// dialog name buffer
extern int        piNameBuffSize;	// import module name buffer
extern int        pfNameBuffSize;	// import functions in the module name buffer
extern int        peNameBuffSize;	// export function name buffer
extern int        pmNameBuffSize;   // menu name buffer
extern int        pdNameBuffSize;	// dialog name buffer

/* hooks to link disassembler and parser and printing */
extern int        nextMode;
extern int        NumberOfBytesProcessed;
extern int        addressOveride;	/* address size overide  */
extern int        operandOveride;   /* operand size overide..*/
extern int        label_start_pos;  /* label start position of case jump block */
extern int        min_label; 
extern int        cur_position;
extern int        labelClass;
extern int        finished;
extern int        a_loc;
extern int        a_loc_save;
extern int        i_psp;
extern int        i_col;
extern Bnode     *lhead;   	    // label data B-Tree header
extern int        lbtn;         // label data B-Tree control number
extern Bnode     *vhead;   	    // value data B-Tree header
extern int        vbtn;         // value data B-Tree control number

/* the secret parse string and stacks */
extern TOKEN     *pstr;         /* parsed stream */
extern TOKEN     *maxp;         /* maximal parse point in stream */
extern TOKEN     *buffer;       /* where the pstr points to */
extern TOKEN     *yybuffer;     /* points to the buffer */
extern VALUE     *lvbuff; /* corresponding yylvals */
extern VALUE     *plval;        /* and pointer */
extern INSTRUCTION *program;
extern int pc;                  /* program counter - counts up from 0 */
extern int passcount;           /* number of cuts */
extern int fatalError;
extern int errorcount;          /* number of errors */
extern int dummy;
extern STACKVALUE  *stack;      /* the evaluation stack - either VALUEs or TOKENs */
extern STACKVALUE  *value;      /* top of evaluation stack */
extern FRAME     *fstack;       /* top of frame stack ... */
extern FRAME     *fptr;         /* and pointer. */
extern FRAME      p_frame;      /* a frame cache */
extern INSTRUCTION instr;       /* single instruction cache */
extern int call_mode;           /* 0 for auto-calling convention, 1=manual */
extern int p_argc;              /* main() arg count  */
extern char **p_argv;           /* main() arg vector */
extern PRECC_DATA precc_data;   /* all command line parameters kept here */
extern PARSER *p_entry;
extern int     p_enargs;
extern PARAM   p_eargv[MAXARGS];
extern char   *p_infile,        /* stdin name (eventually "-" if not a file) */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -