10 #include "../i/private.h"
15 struct PE_(rz_bin_pe_obj_t) *
bin;
19 bin = (
struct PE_(rz_bin_pe_obj_t) *)o->
bin_obj;
36 ((
struct PE_(rz_bin_pe_obj_t) *)bf->
o->
bin_obj);
67 struct PE_(rz_bin_pe_obj_t) *
bin = (
struct PE_(rz_bin_pe_obj_t) *)(bf->
o->
bin_obj);
124 static ut32 perm_of_section_perm(
ut64 perm) {
143 struct PE_(rz_bin_pe_obj_t) *
bin = (
struct PE_(rz_bin_pe_obj_t) *)bf->
o->
bin_obj;
160 if (
bin->nt_headers->optional_header.FileAlignment != 0) {
161 aligned_hdr_size =
RZ_ROUND(
bin->nt_headers->optional_header.SizeOfHeaders,
bin->nt_headers->optional_header.FileAlignment);
178 if (
map->psize >
bin->size) {
187 if (!
map->vsize &&
map->psize) {
201 struct PE_(rz_bin_pe_obj_t) *
bin = (
struct PE_(rz_bin_pe_obj_t) *)bf->
o->
bin_obj;
236 static void find_pe_overlay(
RzBinFile *bf) {
237 ut64 pe_overlay_size;
239 if (pe_overlay_offset) {
246 switch (
bin->nt_headers->file_header.Machine) {
255 static bool is_go_pclntab(
ut8 *magic) {
256 #define IS_GOPCLNTAB_1_2_LE(x) (x[0] == 0xfb && x[1] == 0xff && x[2] == 0xff && x[3] == 0xff && x[4] == 0x00 && x[5] == 0x00)
257 #define IS_GOPCLNTAB_1_2_BE(x) (x[3] == 0xfb && x[2] == 0xff && x[1] == 0xff && x[0] == 0xff && x[4] == 0x00 && x[5] == 0x00)
258 #define IS_GOPCLNTAB_1_16_LE(x) (x[0] == 0xfa && x[1] == 0xff && x[2] == 0xff && x[3] == 0xff && x[4] == 0x00 && x[5] == 0x00)
259 #define IS_GOPCLNTAB_1_16_BE(x) (x[3] == 0xfa && x[2] == 0xff && x[1] == 0xff && x[0] == 0xff && x[4] == 0x00 && x[5] == 0x00)
260 #define IS_GOPCLNTAB_1_18_LE(x) (x[0] == 0xf0 && x[1] == 0xff && x[2] == 0xff && x[3] == 0xff && x[4] == 0x00 && x[5] == 0x00)
261 #define IS_GOPCLNTAB_1_18_BE(x) (x[3] == 0xf0 && x[2] == 0xff && x[1] == 0xff && x[0] == 0xff && x[4] == 0x00 && x[5] == 0x00)
265 #undef IS_GOPCLNTAB_1_2_LE
266 #undef IS_GOPCLNTAB_1_2_BE
267 #undef IS_GOPCLNTAB_1_16_LE
268 #undef IS_GOPCLNTAB_1_16_BE
269 #undef IS_GOPCLNTAB_1_18_LE
270 #undef IS_GOPCLNTAB_1_18_BE
275 struct PE_(rz_bin_pe_obj_t) *
bin = (
struct PE_(rz_bin_pe_obj_t) *)bf->
o->
bin_obj;
288 if ((section_size -
pos) < 16) {
292 if ((magic[6] != 1 && magic[6] != 2 && magic[6] != 4) ||
293 (magic[7] != 4 && magic[7] != 8)) {
296 if (is_go_pclntab(magic)) {
312 ut64 go_pclntab_paddr = 0;
313 ut64 go_pclntab_vaddr = 0;
314 ut32 go_pclntab_size = 0;
342 ptr->
bits = file_bits;
352 if ((go_pclntab_paddr = find_go_pclntab(bf, &go_pclntab_size, &go_pclntab_vaddr))) {
359 ptr->
size = go_pclntab_size;
360 ptr->
bits = file_bits;
361 ptr->
vaddr = go_pclntab_vaddr;
362 ptr->
paddr = go_pclntab_paddr;
400 for (
I = 0;
n[
I];
I++) {
401 if (
n[
I] < 30 ||
n[
I] >= 0x7f) {
424 if (((
struct PE_(rz_bin_pe_obj_t) *)bf->
o->
bin_obj)->relocs) {
467 rel->
vaddr = newaddr;
477 struct PE_(rz_bin_pe_obj_t) *obj = bf->
o->
bin_obj;
497 for (
i = 0; !
libs[
i].last;
i++) {
506 struct PE_(rz_bin_pe_obj_t) *obj = bf->
o->
bin_obj;
518 rz_list_foreach (obj->resources, it,
rs) {
536 br->size =
rs->data->Size;
563 for (
i = 0; !
libs[
i].last;
i++) {
564 if (!strcmp(
libs[
i].
name,
"mscoree.dll")) {
579 for (
i = 0; !
libs[
i].last;
i++) {
580 if (!strcmp(
libs[
i].
name,
"msvbvm60.dll")) {
598 rz_list_foreach (relocs_list,
iter, rel) {
599 if (!strcmp(rel->
import->
name,
"__security_init_cookie")) {
608 rz_list_foreach (imports_list,
iter, imp) {
609 if (!strcmp(imp->
name,
"__security_init_cookie")) {
618 static inline bool haschr(
const struct PE_(rz_bin_pe_obj_t) *
bin,
ut16 dllCharacteristic) {
619 return bin->nt_headers->optional_header.DllCharacteristics & dllCharacteristic;
623 struct PE_(rz_bin_pe_obj_t) *
bin;
626 ut32 claimed_checksum, actual_checksum, pe_overlay;
640 if (is_dot_net(bf)) {
648 ret->
type =
strdup(
"DLL (Dynamic Link Library)");
711 return baddr + vaddr;
738 struct PE_(rz_bin_pe_obj_t) *
bin;
RZ_API RZ_OWN RzList * rz_bin_file_strings(RZ_NONNULL RzBinFile *bf, size_t min_length, bool raw_strings)
Generates a RzList struct containing RzBinString from a given RzBinFile.
RZ_API void rz_bin_file_hash_free(RzBinFileHash *fhash)
RZ_API void rz_bin_symbol_free(RzBinSymbol *sym)
RZ_API void rz_bin_map_free(RzBinMap *map)
RZ_API void rz_bin_import_free(RzBinImport *imp)
RZ_API void rz_bin_resource_free(RzBinResource *res)
RZ_API void rz_bin_section_free(RzBinSection *bs)
static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb)
static void destroy(RzBinFile *bf)
static ut64 baddr(RzBinFile *bf)
static Sdb * get_sdb(RzBinFile *bf)
static RzList * maps(RzBinFile *bf)
static RzBinAddr * binsym(RzBinFile *bf, RzBinSpecialSymbol sym)
static RzList * libs(RzBinFile *bf)
static ut64 get_offset(RzBinFile *bf, int type, int index)
RzList * entries(RzBinFile *bf)
RzBinInfo * info(RzBinFile *bf)
RzList * symbols(RzBinFile *bf)
RzList * imports(RzBinFile *bf)
RzList * sections(RzBinFile *bf)
RzList * relocs(RzBinFile *bf)
static ut64 get_vaddr(RzBinFile *bf, ut64 baddr, ut64 paddr, ut64 vaddr)
#define IS_GOPCLNTAB_1_2_LE(x)
#define IS_GOPCLNTAB_1_16_BE(x)
#define IS_GOPCLNTAB_1_18_BE(x)
#define IS_GOPCLNTAB_1_2_BE(x)
#define IS_GOPCLNTAB_1_18_LE(x)
#define IS_GOPCLNTAB_1_16_LE(x)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
static bool filter_import(ELFOBJ *bin, Elf_(Sym) *symbol, bool is_dynamic)
size_t map(int syms, int left, int len)
checking print the parsed form of the magic use in n conjunction with m to debug a new magic file n before installing it n output MIME type strings(--mime-type and\n"
" --mime-encoding)\n") OPT('s'
RZ_API char * sdb_fmt(const char *fmt,...)
RZ_API void Ht_() free(HtName_(Ht) *ht)
static void list(RzEgg *egg)
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
RZ_API bool rz_list_join(RZ_NONNULL RzList *list1, RZ_NONNULL RzList *list2)
Joins 2 list into one (list2 pointer needs to be freed by the user)
RZ_API RZ_BORROW RzListIter * rz_list_push(RZ_NONNULL RzList *list, void *item)
Alias for rz_list_append.
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
static bool is_thumb(RzBinFile *bf)
static void PE_() add_tls_callbacks(struct PE_(rz_bin_pe_obj_t) *bin, RzList *list)
RZ_API int sdb_ns_set(Sdb *s, const char *name, Sdb *r)
RZ_API Sdb * sdb_ns(Sdb *s, const char *name, int create)
RZ_API int sdb_num_set(Sdb *s, const char *key, ut64 v, ut32 cas)
RZ_API int sdb_bool_set(Sdb *db, const char *str, bool v, ut32 cas)
RZ_API ut64 sdb_num_get(Sdb *s, const char *key, ut32 *cas)
void *PE_() rz_bin_pe_free(RzBinPEObj *bin)
RzBinPEObj *PE_() rz_bin_pe_new_buf(RzBuffer *buf, bool verbose)
int PE_() rz_bin_pe_is_stripped_debug(RzBinPEObj *bin)
int PE_() rz_bin_pe_get_debug_data(RzBinPEObj *bin, SDebugInfo *res)
struct rz_bin_pe_export_t *PE_() rz_bin_pe_get_exports(RzBinPEObj *bin)
ut64 PE_() rz_bin_pe_get_clr_methoddef_offset(RzBinPEObj *bin, Pe_image_metadata_methoddef *methoddef)
int PE_() rz_bin_pe_is_big_endian(RzBinPEObj *bin)
struct rz_bin_pe_addr_t *PE_() rz_bin_pe_get_main_vaddr(RzBinPEObj *bin)
#define RZ_BIN_PE_SCN_IS_WRITABLE(x)
void PE_() rz_bin_pe_check_sections(RzBinPEObj *bin, struct rz_bin_pe_section_t **sects)
#define RZ_BIN_PE_SCN_IS_SHAREABLE(x)
struct rz_bin_pe_addr_t *PE_() rz_bin_pe_get_entrypoint(RzBinPEObj *bin)
int PE_() rz_bin_pe_is_stripped_local_syms(RzBinPEObj *bin)
#define RZ_BIN_PE_SCN_IS_EXECUTABLE(x)
#define RZ_BIN_PE_SCN_IS_READABLE(x)
char *PE_() rz_bin_pe_get_subsystem(RzBinPEObj *bin)
char *PE_() rz_bin_pe_get_machine(RzBinPEObj *bin)
char *PE_() rz_bin_pe_get_arch(RzBinPEObj *bin)
#define DBG_FILE_NAME_LEN
int PE_() bin_pe_get_claimed_checksum(RzBinPEObj *bin)
struct rz_bin_pe_import_t *PE_() rz_bin_pe_get_imports(RzBinPEObj *bin)
struct rz_bin_pe_lib_t *PE_() rz_bin_pe_get_libs(RzBinPEObj *bin)
int PE_() bin_pe_get_actual_checksum(RzBinPEObj *bin)
RZ_OWN RzList *PE_() rz_bin_pe_get_clr_symbols(RzBinPEObj *bin)
ut64 PE_() rz_bin_pe_get_image_base(RzBinPEObj *bin)
char *PE_() rz_bin_pe_get_cc(RzBinPEObj *bin)
int PE_() rz_bin_pe_is_stripped_relocs(RzBinPEObj *bin)
char *PE_() rz_bin_pe_get_os(RzBinPEObj *bin)
char *PE_() rz_bin_pe_get_class(RzBinPEObj *bin)
int PE_() rz_bin_pe_is_dll(RzBinPEObj *bin)
int PE_() rz_bin_pe_get_bits(RzBinPEObj *bin)
int PE_() bin_pe_is_authhash_valid(RzBinPEObj *bin)
int PE_() rz_bin_pe_is_stripped_line_nums(RzBinPEObj *bin)
const char *PE_() bin_pe_get_authentihash(RzBinPEObj *bin)
int PE_() bin_pe_get_overlay(RzBinPEObj *bin, ut64 *size)
#define IMAGE_DLLCHARACTERISTICS_GUARD_CF
#define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER
#define PE_IMAGE_FILE_MACHINE_ARMNT
#define IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY
#define PE_IMAGE_FILE_MACHINE_ARM
#define IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE
#define IMAGE_DLLCHARACTERISTICS_NO_BIND
#define IMAGE_DLLCHARACTERISTICS_APPCONTAINER
#define IMAGE_DLL_CHARACTERISTICS_NX_COMPAT
#define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION
#define IMAGE_DLLCHARACTERISTICS_NO_SEH
#define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE
#define IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA
#define rz_return_val_if_fail(expr, val)
#define RZ_BIN_DBG_RELOCS
#define RZ_BIN_DBG_STRIPPED
#define RZ_BIN_ENTRY_TYPE_TLS
#define RZ_BIN_TYPE_NOTYPE_STR
@ RZ_BIN_SPECIAL_SYMBOL_MAIN
#define RZ_BIN_ENTRY_TYPE_PROGRAM
#define RZ_BIN_BIND_GLOBAL_STR
#define RZ_BIN_TYPE_FUNC_STR
#define RZ_BIN_DBG_LINENUMS
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
static ut32 rz_read_le32(const void *src)
void(* RzListFree)(void *ptr)
RZ_API char * rz_str_ndup(RZ_NULLABLE const char *ptr, int len)
Create new copy of string ptr limited to size len.
RZ_API const char * rz_str_constpool_get(RzStrConstPool *pool, const char *str)
static void * rz_pvector_at(const RzPVector *vec, size_t index)
RZ_API int sdb_set(Sdb *s, const char *key, const char *val, ut32 cas)
#define br(opcode, mask, lose, flags)
char file_name[DBG_FILE_NAME_LEN]
char guidstr[GUIDSTR_LEN]
XX curplugin == o->plugin.
RZ_DEPRECATE Sdb * sdb
deprecated, put info in C structures instead of this
Description of a single memory mapping into virtual memory from a binary.
ut64 paddr
the paddr where the value should be patched into
ut64 vaddr
the vaddr where the value should be patched into
if(dbg->bits==RZ_SYS_BITS_64)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()