diff --git a/ShellcodeObfuscator/Obfuscator.cpp b/ShellcodeObfuscator/Obfuscator.cpp index 063755e..7aa818d 100644 --- a/ShellcodeObfuscator/Obfuscator.cpp +++ b/ShellcodeObfuscator/Obfuscator.cpp @@ -347,12 +347,30 @@ bool obf_gen_label(pobfuscator_t obf, pcode_link_t jmp, int32_t delta) bool obf_allocate_group_buffers(pobfuscator_t obf, FnAllocateMem AllocMem) { - + for (code_group_t& group : obf->groups) + { + group.base_address = (uint64_t)AllocMem(group.size_in_bytes); + if (!group.base_address) + return false; + } + return true; } bool obf_copy_groups_into_buffers(pobfuscator_t obf, FnMemCopy MemCopy) { - + for (uint32_t i = 0; i < obf->groups.size(); i) + { + pcode_group_t group = &obf->groups[i]; + uint64_t cur_addr = group->base_address; + for (pcode_link_t t = group->start; t && t->group == i; t = t->next) + { + if (!(t->flags & CLFLAG_IS_LABEL)) + { + MemCopy((void*)cur_addr, t->raw_data, t->raw_data_size); + cur_addr += t->raw_data_size; + } + } + } } #include diff --git a/ShellcodeObfuscator/Obfuscator.h b/ShellcodeObfuscator/Obfuscator.h index 78a6b5f..84736b7 100644 --- a/ShellcodeObfuscator/Obfuscator.h +++ b/ShellcodeObfuscator/Obfuscator.h @@ -46,7 +46,6 @@ typedef struct _obfuscator_t pcode_link_t code_start; pcode_link_t code_end; std::vector groups; - int32_t group_size; int32_t current_label_id; xed_machine_mode_enum_t machine_mode; xed_address_width_enum_t addr_width;