diff --git a/executable.cpp b/executable.cpp index 22d3bce..5ec01e0 100644 --- a/executable.cpp +++ b/executable.cpp @@ -31,14 +31,14 @@ unassemblize::Executable::Executable(const char *file_name, OutputFormats format m_dataAlignment(sizeof(uint32_t)), m_codePad(0x90), // NOP m_dataPad(0x00), - m_verbose(verbose) + m_verbose(verbose), + m_addBase(false) { if (m_verbose) { printf("Loading section info...\n"); } bool checked_image_base = false; - bool add_image_base = false; for (auto it = m_binary->sections().begin(); it != m_binary->sections().end(); ++it) { if (!it->name().empty() && it->size() != 0) { @@ -47,11 +47,11 @@ unassemblize::Executable::Executable(const char *file_name, OutputFormats format // Check on first section incase binary is huge and later sections start higher than imagebase. if (!checked_image_base && it->virtual_address() <= m_binary->imagebase()) { - add_image_base = true; + m_addBase = true; } // For PE format virtual_address appears to be an offset, in ELF/Mach-O it appears to be absolute. - if (add_image_base) { + if (m_addBase) { section.address = m_binary->imagebase() + it->virtual_address(); } else { section.address = it->virtual_address(); diff --git a/executable.h b/executable.h index 57d6d55..de3c970 100644 --- a/executable.h +++ b/executable.h @@ -121,6 +121,7 @@ class Executable uint8_t m_codePad; uint8_t m_dataPad; bool m_verbose; + bool m_addBase; static const char s_symbolSection[]; static const char s_sectionsSection[]; diff --git a/function.cpp b/function.cpp index 4a505ef..fc4c56f 100644 --- a/function.cpp +++ b/function.cpp @@ -342,6 +342,11 @@ static ZyanStatus UnasmFormatterFormatOperandMEM( char hex_buff[32]; const unassemblize::Executable::Symbol &symbol = func->executable().get_symbol(address); + if ((context->operand->mem.type == ZYDIS_MEMOP_TYPE_MEM) || (context->operand->mem.type == ZYDIS_MEMOP_TYPE_VSIB)) { + ZYAN_CHECK(formatter->func_print_typecast(formatter, buffer, context)); + } + ZYAN_CHECK(formatter->func_print_segment(formatter, buffer, context)); + if (!symbol.name.empty()) { ZYAN_CHECK(ZydisFormatterBufferAppend(buffer, ZYDIS_TOKEN_SYMBOL)); ZyanString *string;