Skip to content
This repository
tree: 085501ad15
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 101 lines (92 sloc) 2.55 kb
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
#if !defined(BIN_API__)
#define BIN_API__
#include <stddef.h>
#include <stdint.h>

/*
* Some useful foward declarations for function protoypes here and elsewhere.
*/
struct tramp_st2_entry;
struct inline_tramp_st2_entry;

/*
* bin_init - Initialize the binary format specific layer.
*/
void
bin_init();

/*
* bin_find_symbol - find a symbol
*
* Given:
* - sym - a symbol name
* - size - optional out parameter
* - search_libs - 0 to search only ruby/libruby, 1 to search other
* libraries, too.
*
* This function will search for the symbol sym and return its address if
* found, or NULL if the symbol could not be found.
*
* Optionally, this function will set its out parameter size equal to the
* size of the symbol.
*/
void *
bin_find_symbol(const char *sym, size_t *size, int search_libs);

/*
* bin_find_symbol_name - find a symbol's name
*
* Given:
* - sym - a symbol address
*
* This function will search for the symbol sym and return its name if
* found, or NULL if the symbol could not be found.
*/
const char *
bin_find_symbol_name(void *sym);

/*
* bin_allocate_page - allocate a page suitable for trampolines
*
* This function will allocate a page of memory in the right area of the
* virtual address space and with the appropriate permissions for stage 2
* trampoline code to live and execute.
*/
void *
bin_allocate_page(void);

/*
* bin_type_size - Return size (in bytes) of a given type.
*
* Given:
* - type - a string representation of a type
*
* This function will return the size (in bytes) of the type. If no such type
* can be found, return 0.
*/
size_t
bin_type_size(const char *type);

/*
* bin_type_member_offset - Return the offset (in bytes) of member in type.
*
* Given:
* - type - a string representation of a type
* - member - a string representation of a field int he type
*
* This function will return the offset (in bytes) of member in type.
*
* On failure, this function returns -1.
*/
int
bin_type_member_offset(const char *type, const char *member);

/*
* bin_update_image - Update a binary image in memory
*
* Given:
* - trampee - the name of the symbol to hook
* - tramp - the stage 2 trampoline entry
* - orig_func - out parameter storing the address of the function that was
* originally being called.
*
* this function will update the binary image so that all calls to trampee will
* be routed to tramp.
*
* Returns 0 on success.
*/
int
bin_update_image(const char *trampee, struct tramp_st2_entry *tramp, void **orig_func);
#endif
Something went wrong with that request. Please try again.