File: x86_init.3

package info (click to toggle)
libdisasm 0.23-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,460 kB
  • ctags: 1,988
  • sloc: sh: 9,233; ansic: 7,971; perl: 1,915; asm: 694; makefile: 192; ruby: 3
file content (115 lines) | stat: -rw-r--r-- 2,370 bytes parent folder | download | duplicates (5)
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
104
105
106
107
108
109
110
111
112
113
114
115
.TH "x86_init" "3" "0.21" "mammon_" "libdisasm"
.SH "NAME"
x86_init, x86_cleanup \- initialize and cleanup libdisasm
.SH "SYNOPSIS"
\fB#include <libdis.h>\fR
.br 
.LP 
\fBtypedef void (*\fRDISASM_REPORTER\fB)( enum x86_report_codes\fR code\fB, 
.br 
        void *\fR data\fB, void *\fR arg \fB);\fR
.LP 
\fBint x86_init( enum x86_options\fR options\fB, DISASM_REPORTER \fRreporter\fB, 
.br 
        void *\fR arg\fB);
.LP 
\fBint x86_cleanup(void);\fR
.LP 
.SH "DESCRIPTION"
.LP 
\fBenum x86_options {\fR
.br 
	opt_none= 0,
.br 
	opt_ignore_nulls=1,	/* ignore sequences of > 4 NULL bytes */
.br 
	opt_16_bit=2,		/* 16\-bit/DOS disassembly */
.br 
	opt_unknown
.br 
\fB};\fR
.LP 
\fBenum x86_report_codes {\fR
.br 
        report_disasm_bounds,
.br 
        report_insn_bounds, 
.br 
        report_invalid_insn,
.br 
        report_unknown
.br 
\fB};\fR
.LP 
.SH "EXAMPLES"
.LP 
The following provides a skeleton for initializing and terminating 
.br 
\fBlibdisasm\fR:
.LP 
void reporter( enum x86_report_codes code, void *data, void *arg ) {
.br 
        char * str = NULL;
.br 
        FILE *stream = (FILE *) arg;
.br 
        if (! stream ) stream = stderr;
.br 

.br 
        /* here would could examine the error and do something useful;
.br 
         * instead we just print that an error occurred */
.br 
        switch ( code ) {
.br 
                case report_disasm_bounds:
.br 
                        str = "Attempt to disassemble RVA "
.br 
                              "beyond end of buffer";
.br 
                        break;
.br 
                case report_insn_bounds:
.br 
                        str = "Instruction at RVA extends "
.br 
                              "beyond buffer";
.br 
                        break;
.br 
                case report_invalid_insn:
.br 
                        str = "Invalid opcode at RVA";
.br 
                        break;
.br 
                case report_unknown:
.br 
                        str = "Unknown Error";
.br 
                        break;
.br 
        }
.br 

.br 
        fprintf(stream, "ERROR \'%s:\' %p\n", str, data);
.br 
}
.LP 
int main( int argc, char **argv ) {
.br 
        x86_init(opt_none, reporter, stderr);
.LP 
        /* disassembler code goes here */
.LP 
        x86_cleanup();
.br 
}
.LP 
.SH "SEE ALSO"
.LP 
libdisasm(7), x86_disasm(3), x86_format_insn(3), x86dis(1)