diff --git a/src/main.cpp b/src/main.cpp index 515d28a..881f5ce 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -139,14 +139,14 @@ int main(int argc, char *argv[]) { // calculate the section size for storage in the PE file auto section_size = static_cast(packed.size() + sizeof(std::size_t)); - // re-acquire an NT header pointer since our buffer likely changed addresses - // from the resize - nt_header = reinterpret_cast(stub_data.data() + e_lfanew); - // pad the section data with 0s if we aren't on the file alignment boundary if (stub_data.size() % file_alignment != 0) stub_data.resize(align(stub_data.size(), file_alignment)); + // re-acquire an NT header pointer since our buffer likely changed addresses + // from the resize + nt_header = reinterpret_cast(stub_data.data() + e_lfanew); + // increment the number of sections in the file header auto section_index = nt_header->FileHeader.NumberOfSections; ++nt_header->FileHeader.NumberOfSections;