Skip to content

Commit b290b63

Browse files
committed
Upgraded Zydis version
1 parent 477bca1 commit b290b63

File tree

5 files changed

+25
-21
lines changed

5 files changed

+25
-21
lines changed

chum/source/binary.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,13 @@ void binary::print(bool const verbose) {
200200
std::uint32_t instr_offset = 0;
201201
for (auto const& instr : bb->instructions) {
202202
ZydisDecodedInstruction decoded_instr;
203-
ZydisDecodedOperand decoded_operands[ZYDIS_MAX_OPERAND_COUNT_VISIBLE];
203+
ZydisDecodedOperand decoded_operands[ZYDIS_MAX_OPERAND_COUNT];
204204

205205
ZydisDecoderDecodeFull(&decoder_, instr.bytes, instr.length,
206-
&decoded_instr, decoded_operands, ZYDIS_MAX_OPERAND_COUNT_VISIBLE,
207-
ZYDIS_DFLAG_VISIBLE_OPERANDS_ONLY);
206+
&decoded_instr, decoded_operands);
208207

209208
char buffer[128] = { 0 };
210-
ZydisFormatterFormatInstructionEx(&formatter_, &decoded_instr,
209+
ZydisFormatterFormatInstruction(&formatter_, &decoded_instr,
211210
decoded_operands, decoded_instr.operand_count_visible, buffer,
212211
128, 0, &symbols_);
213212

chum/source/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int main() {
6060

6161
//transform(*bin);
6262

63-
bin->print();
63+
bin->print(true);
6464

6565
if (!bin->create("C:\\Users\\realj\\Desktop\\chum-output.exe")) {
6666
std::printf("[!] Failed to create output binary.\n");

chum/source/pe-builder.cpp

+19-14
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,25 @@ std::vector<std::uint8_t> pe_builder::create() const {
9090

9191
std::vector<std::uint32_t> sym_to_rva(bin_.symbols().size(), 0);
9292

93-
for (auto const bb : bin_.basic_blocks()) {
94-
sym_to_rva[bb->sym_id.value] = current_virtual_address + instr_offset;
95-
96-
for (auto const& instr : bb->instructions) {
97-
contents.insert(end(contents),
98-
std::begin(instr.bytes), std::begin(instr.bytes) + instr.length);
99-
instr_offset += instr.length;
100-
}
101-
102-
contents.push_back(0xCC);
103-
contents.push_back(0xCC);
104-
contents.push_back(0xCC);
105-
instr_offset += 3;
106-
}
93+
sym_to_rva[bin_.entrypoint()->sym_id.value] = current_virtual_address + instr_offset;
94+
contents.push_back(0xEB);
95+
contents.push_back(0xFE);
96+
instr_offset += 2;
97+
98+
//for (auto const bb : bin_.basic_blocks()) {
99+
// sym_to_rva[bb->sym_id.value] = current_virtual_address + instr_offset;
100+
101+
// for (auto const& instr : bb->instructions) {
102+
// contents.insert(end(contents),
103+
// std::begin(instr.bytes), std::begin(instr.bytes) + instr.length);
104+
// instr_offset += instr.length;
105+
// }
106+
107+
// contents.push_back(0xCB);
108+
// contents.push_back(0xCB);
109+
// contents.push_back(0xCB);
110+
// instr_offset += 2;
111+
//}
107112

108113
// The code section is the last section (after the data blocks).
109114
auto const code_section = section_header(contents, data_blocks.size());

extern/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# zydis
22
option(ZYDIS_BUILD_EXAMPLES "" OFF)
33
option(ZYDIS_BUILD_TOOLS "" OFF)
4-
add_subdirectory(zydis)
4+
add_subdirectory(zydis)

extern/zydis

Submodule zydis updated 101 files

0 commit comments

Comments
 (0)