X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Funexnt.c;h=60c8fe4d6bf9054e5d8e8f27e3437cd32d12121e;hb=f2025090f01da2850dd72008074d6b8dc33c0113;hp=ac4b78e784bb3e19883e3858b64d19ecaa23a2ae;hpb=6883ee56ec887c2c48abe5b06b5e66aa74031910;p=chise%2Fxemacs-chise.git diff --git a/src/unexnt.c b/src/unexnt.c index ac4b78e..60c8fe4 100644 --- a/src/unexnt.c +++ b/src/unexnt.c @@ -261,38 +261,6 @@ unexec (char *new_name, char *old_name, void *start_data, void *start_bss, int -open_input_file (file_data *p_file, char *filename) -{ - HANDLE file; - HANDLE file_mapping; - void *file_base; - unsigned long size, upper_size; - - file = CreateFile (filename, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); - if (file == INVALID_HANDLE_VALUE) - return FALSE; - - size = GetFileSize (file, &upper_size); - file_mapping = CreateFileMapping (file, NULL, PAGE_READONLY, - 0, size, NULL); - if (!file_mapping) - return FALSE; - - file_base = MapViewOfFile (file_mapping, FILE_MAP_READ, 0, 0, size); - if (file_base == 0) - return FALSE; - - p_file->name = filename; - p_file->size = size; - p_file->file = file; - p_file->file_mapping = file_mapping; - p_file->file_base = file_base; - - return TRUE; -} - -int open_output_file (file_data *p_file, char *filename, unsigned long size) { HANDLE file; @@ -322,16 +290,6 @@ open_output_file (file_data *p_file, char *filename, unsigned long size) return TRUE; } -/* Close the system structures associated with the given file. */ -void -close_file_data (file_data *p_file) -{ - UnmapViewOfFile (p_file->file_base); - CloseHandle (p_file->file_mapping); - CloseHandle (p_file->file); -} - - /* Routines to manipulate NT executable file sections. */ #ifndef DUMP_SEPARATE_SECTION @@ -375,27 +333,6 @@ get_bss_info_from_map_file (file_data *p_infile, PUCHAR *p_bss_start, } #endif -/* Return pointer to section header for section containing the given - relative virtual address. */ -IMAGE_SECTION_HEADER * -rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header) -{ - PIMAGE_SECTION_HEADER section; - int i; - - section = IMAGE_FIRST_SECTION (nt_header); - - for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++) - { - if (rva >= section->VirtualAddress - && rva < section->VirtualAddress + section->SizeOfRawData) - return section; - section++; - } - return NULL; -} - - /* Flip through the executable and cache the info necessary for dumping. */ static void get_section_info (file_data *p_infile) @@ -549,7 +486,7 @@ copy_executable_and_dump_data_section (file_data *p_infile, static void dump_bss_and_heap (file_data *p_infile, file_data *p_outfile) { - unsigned char *heap_data, *bss_data; + unsigned char *heap_data; unsigned long size, index; DUMP_MSG (("Dumping heap onto end of executable...\n")); @@ -565,16 +502,15 @@ dump_bss_and_heap (file_data *p_infile, file_data *p_outfile) memcpy ((PUCHAR) p_outfile->file_base + index, heap_data, size); #ifndef DUMP_SEPARATE_SECTION - printf ("Dumping bss onto end of executable...\n"); + DUMP_MSG (("Dumping bss onto end of executable...\n")); index += size; size = bss_size; - bss_data = bss_start; - DUMP_MSG (("\t0x%08x BSS start in process.\n", bss_data)); + DUMP_MSG (("\t0x%08x BSS start in process.\n", bss_start)); DUMP_MSG (("\t0x%08x BSS offset in executable.\n", index)); DUMP_MSG (("\t0x%08x BSS size in bytes.\n", size)); - memcpy ((char *) p_outfile->file_base + index, bss_data, size); + memcpy ((char *) p_outfile->file_base + index, bss_start, size); #endif }