---
name: "x86_init"
section: "3"
platform: "linux"
package: "libdisasm-dev"
version: "0.23-7"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/x86_init"
---

# x86\_init(3)

initialize and cleanup libdisasm

## NAME

x86\_init, x86\_cleanup - initialize and cleanup libdisasm

## SYNOPSIS

**#include \<libdis.h\>**\

**typedef void (\***DISASM\_REPORTER**)( enum x86\_report\_codes** code**,** \
\
         **void \*** data**, void \*** arg **);**

**int x86\_init( enum x86\_options** options**, DISASM\_REPORTER** reporter**,** \
\
         **void \*** arg**);**

**int x86\_cleanup(void);**

## DESCRIPTION

**enum x86\_options {**\
\
 	opt\_none= 0,\
\
 	opt\_ignore\_nulls=1,	/\* ignore sequences of \> 4 NULL bytes \*/\
\
 	opt\_16\_bit=2,		/\* 16-bit/DOS disassembly \*/\
\
 	opt\_unknown\
 **};**

**enum x86\_report\_codes {**\
\
         report\_disasm\_bounds,\
\
         report\_insn\_bounds, \
\
         report\_invalid\_insn,\
\
         report\_unknown\
 **};**

## EXAMPLES

The following provides a skeleton for initializing and terminating \
 **libdisasm**:

void reporter( enum x86\_report\_codes code, void \*data, void \*arg ) {\
\
         char \* str = NULL;\
\
         FILE \*stream = (FILE \*) arg;\
\
         if (! stream ) stream = stderr;\

        /\* here would could examine the error and do something useful;\
\
          \* instead we just print that an error occurred \*/\
\
         switch ( code ) {\
\
                 case report\_disasm\_bounds:\
\
                         str = "Attempt to disassemble RVA "\
\
                               "beyond end of buffer";\
\
                         break;\
\
                 case report\_insn\_bounds:\
\
                         str = "Instruction at RVA extends "\
\
                               "beyond buffer";\
\
                         break;\
\
                 case report\_invalid\_insn:\
\
                         str = "Invalid opcode at RVA";\
\
                         break;\
\
                 case report\_unknown:\
\
                         str = "Unknown Error";\
\
                         break;\
\
         }\

        fprintf(stream, "ERROR ´%s:´ %p0, str, data);\
 }

int main( int argc, char \*\*argv ) {\
\
         x86\_init(opt\_none, reporter, stderr);

        /\* disassembler code goes here \*/

        x86\_cleanup();\
 }

## SEE ALSO

[libdisasm(7)](/libdisasm/7.md), [x86\_disasm(3)](/x86_disasm/3.md), [x86\_format\_insn(3)](/x86_format_insn/3.md), [x86dis(1)](/x86dis/1.md)
