17 std::cout <<
"Trying to overwrite the optional header\n";
19 if (!vBuf || !opt_hdr_ptr)
return false;
20 if (!peconv::validate_ptr(vBuf, vBufSize, opt_hdr_ptr,
sizeof(IMAGE_OPTIONAL_HEADER_T))) {
24 opt_hdr_ptr->Magic = IMAGE_NT_OPTIONAL_HDR64_MAGIC;
27 opt_hdr_ptr->Magic = IMAGE_NT_OPTIONAL_HDR32_MAGIC;
30 if (opt_hdr_ptr->SectionAlignment == 0) {
31 opt_hdr_ptr->SectionAlignment =
PAGE_SIZE;
33 if (opt_hdr_ptr->FileAlignment == 0) {
34 opt_hdr_ptr->FileAlignment = 0x200;
36 if (opt_hdr_ptr->SizeOfHeaders == 0) {
37 opt_hdr_ptr->SizeOfHeaders = 0x400;