toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/x86_misc.c

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 #include <stdio.h>
     2 #include <stdlib.h>
     3 #include <string.h>
     5 #include "libdis.h"
     6 #include "ia32_insn.h"
     7 #include "ia32_reg.h"		/* for ia32_reg wrapper */
     8 #include "ia32_settings.h"
     9 extern ia32_settings_t ia32_settings;
    11 #ifdef _MSC_VER
    12         #define snprintf        _snprintf
    13         #define inline          __inline
    14 #endif
    17 /* =========================================================== INIT/TERM */
    18 static DISASM_REPORTER __x86_reporter_func = NULL;
    19 static void * __x86_reporter_arg = NULL;
    21 int x86_init( enum x86_options options, DISASM_REPORTER reporter, void * arg )
    22 {
    23         ia32_settings.options = options;
    24         __x86_reporter_func = reporter;
    25 	__x86_reporter_arg = arg;
    27         return 1;
    28 }
    30 void x86_set_reporter( DISASM_REPORTER reporter, void * arg ) {
    31         __x86_reporter_func = reporter;
    32 	__x86_reporter_arg = arg;
    33 }
    35 void x86_set_options( enum x86_options options ){
    36         ia32_settings.options = options;
    37 }
    39 enum x86_options x86_get_options( void ) {
    40         return ia32_settings.options;
    41 }
    43 int x86_cleanup( void )
    44 {
    45         return 1;
    46 }
    48 /* =========================================================== ERRORS */
    49 void x86_report_error( enum x86_report_codes code, void *data ) {
    50         if ( __x86_reporter_func ) {
    51                 (*__x86_reporter_func)(code, data, __x86_reporter_arg);
    52         }
    53 }
    56 /* =========================================================== MISC */
    57 unsigned int x86_endian(void)        { return ia32_settings.endian;  }
    58 unsigned int x86_addr_size(void)     { return ia32_settings.sz_addr; }
    59 unsigned int x86_op_size(void)       { return ia32_settings.sz_oper; }
    60 unsigned int x86_word_size(void)     { return ia32_settings.sz_word; }
    61 unsigned int x86_max_insn_size(void) { return ia32_settings.max_insn; }
    62 unsigned int x86_sp_reg(void)        { return ia32_settings.id_sp_reg;      }
    63 unsigned int x86_fp_reg(void)        { return ia32_settings.id_fp_reg;      }
    64 unsigned int x86_ip_reg(void)        { return ia32_settings.id_ip_reg;      }
    65 unsigned int x86_flag_reg(void)        { return ia32_settings.id_flag_reg;  }
    67 /* wrapper function to hide the IA32 register fn */
    68 void x86_reg_from_id( unsigned int id, x86_reg_t * reg ) {
    69 	ia32_handle_register( reg, id );
    70 	return;
    71 }

mercurial