Changeset View
Changeset View
Standalone View
Standalone View
elfcopy/pe.c
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | create_pe(struct elfcopy *ecp, int ifd, int ofd) | ||||
PE_Scn *ps; | PE_Scn *ps; | ||||
PE_SecHdr psh; | PE_SecHdr psh; | ||||
PE_CoffHdr pch; | PE_CoffHdr pch; | ||||
PE_OptHdr poh; | PE_OptHdr poh; | ||||
PE_Object po; | PE_Object po; | ||||
PE_Buffer *pb; | PE_Buffer *pb; | ||||
const char *name; | const char *name; | ||||
size_t indx; | size_t indx; | ||||
time_t timestamp; | |||||
int elferr; | int elferr; | ||||
if (ecp->otf == ETF_EFI || ecp->oem == EM_X86_64) | if (ecp->otf == ETF_EFI || ecp->oem == EM_X86_64) | ||||
po = PE_O_PE32P; | po = PE_O_PE32P; | ||||
else | else | ||||
po = PE_O_PE32; | po = PE_O_PE32; | ||||
if ((e = elf_begin(ifd, ELF_C_READ, NULL)) == NULL) | if ((e = elf_begin(ifd, ELF_C_READ, NULL)) == NULL) | ||||
Show All 19 Lines | case EM_386: | ||||
break; | break; | ||||
case EM_X86_64: | case EM_X86_64: | ||||
pch.ch_machine = IMAGE_FILE_MACHINE_AMD64; | pch.ch_machine = IMAGE_FILE_MACHINE_AMD64; | ||||
break; | break; | ||||
default: | default: | ||||
pch.ch_machine = IMAGE_FILE_MACHINE_UNKNOWN; | pch.ch_machine = IMAGE_FILE_MACHINE_UNKNOWN; | ||||
break; | break; | ||||
} | } | ||||
pch.ch_timestamp = (uint32_t) time(NULL); | if (elftc_timestamp(×tamp) != 0) | ||||
err(EXIT_FAILURE, "elftc_timestamp"); | |||||
pch.ch_timestamp = (uint32_t) timestamp; | |||||
if (pe_update_coff_header(pe, &pch) < 0) | if (pe_update_coff_header(pe, &pch) < 0) | ||||
err(EXIT_FAILURE, "pe_update_coff_header() failed"); | err(EXIT_FAILURE, "pe_update_coff_header() failed"); | ||||
/* Setup PE optional header. */ | /* Setup PE optional header. */ | ||||
memset(&poh, 0, sizeof(poh)); | memset(&poh, 0, sizeof(poh)); | ||||
if (ecp->otf == ETF_EFI) | if (ecp->otf == ETF_EFI) | ||||
poh.oh_subsystem = IMAGE_SUBSYSTEM_EFI_APPLICATION; | poh.oh_subsystem = IMAGE_SUBSYSTEM_EFI_APPLICATION; | ||||
poh.oh_entry = (uint32_t) eh.e_entry; | poh.oh_entry = (uint32_t) eh.e_entry; | ||||
▲ Show 20 Lines • Show All 131 Lines • Show Last 20 Lines |