-
Notifications
You must be signed in to change notification settings - Fork 3
/
parameters.y
executable file
·104 lines (84 loc) · 1.72 KB
/
parameters.y
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
%{
#include <stdio.h>
#include "syscalls.h"
#include "hashtable.h"
int pplex(void);
void pperror(char*);
struct parameter_type params[MAX_PARAM_COUNT];
int pcount = 0;
extern int pplineno;
%}
%union {char *s; int d;}
%token POUNDDEF POUNDUNK TOKEN_NTSYSAPI TOKEN_WINAPI
%token TOKEN_LPAREN TOKEN_RPAREN TOKEN_COMMA TOKEN_STAR TOKEN_SEMI
%token TOKEN_CDECL
%token <s> TOKEN_NTSTATUS
%token <s> WORD
%token <d> NUMBER
%%
goodline:
goodline line
| line
;
line: preamble apidec
;
preamble: TOKEN_NTSYSAPI wordlist TOKEN_WINAPI
| TOKEN_NTSYSAPI wordlist TOKEN_CDECL
;
wordlist: wordlist WORD
| wordlist TOKEN_STAR
| WORD
| TOKEN_NTSTATUS
;
apidec: WORD TOKEN_LPAREN paramlist TOKEN_RPAREN TOKEN_SEMI
{
int i;
struct nt_syscall_info *call_info = NULL;
call_info = (struct nt_syscall_info*)
hashtable_search(nt_syscall_table, $1);
if(call_info != NULL)
{
call_info->parameter_count = pcount;
for(i = 0; i < pcount; i++)
{
call_info->params[i].type = params[i].type;
call_info->params[i].indirection =
params[i].indirection;
/*printf("Param Type: %s, indirections: %d\n",*/
/*call_info->params[i].type,*/
/*call_info->params[i].indirection);*/
}
/*printf("%s: %d params\n", $1, pcount);*/
}
pcount = 0;
}
;
paramlist: paramlist TOKEN_COMMA param
| paramlist TOKEN_COMMA
| param
|
;
param: param TOKEN_STAR
{
params[pcount-1].indirection++;
}
| param WORD
| param TOKEN_NTSTATUS
| WORD
{
params[pcount].indirection = 0;
params[pcount].type= $1;
pcount++;
}
| TOKEN_NTSTATUS
{
params[pcount].indirection = 0;
params[pcount].type = $1;
pcount++;
}
;
%%
void pperror(char *s)
{
fprintf(stderr, "error: %s, line: %d\n", s, pplineno);
}