diff options
| author | Andrew Innes | 2000-08-22 22:44:39 +0000 |
|---|---|---|
| committer | Andrew Innes | 2000-08-22 22:44:39 +0000 |
| commit | 49dc9682b7a2d79221c9652abe469b5eaccf440a (patch) | |
| tree | 85a3e7fa3a90e2a8259882fcaf80a527a3bd5fb1 /src | |
| parent | a5e73edce64c7ce518eb84d9bae019ab2e18ead8 (diff) | |
| download | emacs-49dc9682b7a2d79221c9652abe469b5eaccf440a.tar.gz emacs-49dc9682b7a2d79221c9652abe469b5eaccf440a.zip | |
Change PUCHAR to PCHAR.
(PTR_TO_OFFSET): Cast ptr to unsigned char *.
(relocate_offset):
(get_section_info):
(copy_executable_and_dump_data): Remove unnecessary static defs.
(copy_executable_and_dump_data): Fix compile warnings.
(unexec): Ignore old_name, and use the actual location
of the current executable instead. Base new_name on this.
Diffstat (limited to 'src')
| -rw-r--r-- | src/unexw32.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/src/unexw32.c b/src/unexw32.c index 0d150cf34db..7b907beda6e 100644 --- a/src/unexw32.c +++ b/src/unexw32.c | |||
| @@ -67,17 +67,17 @@ void dump_bss_and_heap (file_data *p_infile, file_data *p_outfile); | |||
| 67 | 67 | ||
| 68 | /* Cached info about the .data section in the executable. */ | 68 | /* Cached info about the .data section in the executable. */ |
| 69 | PIMAGE_SECTION_HEADER data_section; | 69 | PIMAGE_SECTION_HEADER data_section; |
| 70 | PUCHAR data_start = 0; | 70 | PCHAR data_start = 0; |
| 71 | DWORD data_size = 0; | 71 | DWORD data_size = 0; |
| 72 | 72 | ||
| 73 | /* Cached info about the .bss section in the executable. */ | 73 | /* Cached info about the .bss section in the executable. */ |
| 74 | PIMAGE_SECTION_HEADER bss_section; | 74 | PIMAGE_SECTION_HEADER bss_section; |
| 75 | PUCHAR bss_start = 0; | 75 | PCHAR bss_start = 0; |
| 76 | DWORD bss_size = 0; | 76 | DWORD bss_size = 0; |
| 77 | DWORD extra_bss_size = 0; | 77 | DWORD extra_bss_size = 0; |
| 78 | /* bss data that is static might be discontiguous from non-static. */ | 78 | /* bss data that is static might be discontiguous from non-static. */ |
| 79 | PIMAGE_SECTION_HEADER bss_section_static; | 79 | PIMAGE_SECTION_HEADER bss_section_static; |
| 80 | PUCHAR bss_start_static = 0; | 80 | PCHAR bss_start_static = 0; |
| 81 | DWORD bss_size_static = 0; | 81 | DWORD bss_size_static = 0; |
| 82 | DWORD extra_bss_size_static = 0; | 82 | DWORD extra_bss_size_static = 0; |
| 83 | 83 | ||
| @@ -284,7 +284,7 @@ offset_to_section (DWORD offset, IMAGE_NT_HEADERS * nt_header) | |||
| 284 | /* Return offset to an object in dst, given offset in src. We assume | 284 | /* Return offset to an object in dst, given offset in src. We assume |
| 285 | there is at least one section in both src and dst images, and that | 285 | there is at least one section in both src and dst images, and that |
| 286 | the some sections may have been added to dst (after sections in src). */ | 286 | the some sections may have been added to dst (after sections in src). */ |
| 287 | static DWORD | 287 | DWORD |
| 288 | relocate_offset (DWORD offset, | 288 | relocate_offset (DWORD offset, |
| 289 | IMAGE_NT_HEADERS * src_nt_header, | 289 | IMAGE_NT_HEADERS * src_nt_header, |
| 290 | IMAGE_NT_HEADERS * dst_nt_header) | 290 | IMAGE_NT_HEADERS * dst_nt_header) |
| @@ -331,14 +331,14 @@ relocate_offset (DWORD offset, | |||
| 331 | #define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL)) | 331 | #define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL)) |
| 332 | 332 | ||
| 333 | #define PTR_TO_OFFSET(ptr, pfile_data) \ | 333 | #define PTR_TO_OFFSET(ptr, pfile_data) \ |
| 334 | ((char *)(ptr) - (pfile_data)->file_base) | 334 | ((unsigned char *)(ptr) - (pfile_data)->file_base) |
| 335 | 335 | ||
| 336 | #define OFFSET_TO_PTR(offset, pfile_data) \ | 336 | #define OFFSET_TO_PTR(offset, pfile_data) \ |
| 337 | ((pfile_data)->file_base + (DWORD)(offset)) | 337 | ((pfile_data)->file_base + (DWORD)(offset)) |
| 338 | 338 | ||
| 339 | 339 | ||
| 340 | /* Flip through the executable and cache the info necessary for dumping. */ | 340 | /* Flip through the executable and cache the info necessary for dumping. */ |
| 341 | static void | 341 | void |
| 342 | get_section_info (file_data *p_infile) | 342 | get_section_info (file_data *p_infile) |
| 343 | { | 343 | { |
| 344 | PIMAGE_DOS_HEADER dos_header; | 344 | PIMAGE_DOS_HEADER dos_header; |
| @@ -481,7 +481,7 @@ get_section_info (file_data *p_infile) | |||
| 481 | 481 | ||
| 482 | /* The dump routines. */ | 482 | /* The dump routines. */ |
| 483 | 483 | ||
| 484 | static void | 484 | void |
| 485 | copy_executable_and_dump_data (file_data *p_infile, | 485 | copy_executable_and_dump_data (file_data *p_infile, |
| 486 | file_data *p_outfile) | 486 | file_data *p_outfile) |
| 487 | { | 487 | { |
| @@ -617,7 +617,7 @@ copy_executable_and_dump_data (file_data *p_infile, | |||
| 617 | } | 617 | } |
| 618 | if (section == heap_section) | 618 | if (section == heap_section) |
| 619 | { | 619 | { |
| 620 | DWORD heap_start = get_heap_start (); | 620 | DWORD heap_start = (DWORD) get_heap_start (); |
| 621 | DWORD heap_size = get_committed_heap_size (); | 621 | DWORD heap_size = get_committed_heap_size (); |
| 622 | 622 | ||
| 623 | /* Dump the used portion of the predump heap, adjusting the | 623 | /* Dump the used portion of the predump heap, adjusting the |
| @@ -719,18 +719,28 @@ unexec (char *new_name, char *old_name, void *start_data, void *start_bss, | |||
| 719 | file_data in_file, out_file; | 719 | file_data in_file, out_file; |
| 720 | char out_filename[MAX_PATH], in_filename[MAX_PATH]; | 720 | char out_filename[MAX_PATH], in_filename[MAX_PATH]; |
| 721 | unsigned long size; | 721 | unsigned long size; |
| 722 | char *ptr; | 722 | char *p; |
| 723 | char *q; | ||
| 724 | |||
| 725 | /* Ignore old_name, and get our actual location from the OS. */ | ||
| 726 | if (!GetModuleFileName (NULL, in_filename, MAX_PATH)) | ||
| 727 | abort (); | ||
| 728 | dostounix_filename (in_filename); | ||
| 729 | strcpy (out_filename, in_filename); | ||
| 730 | |||
| 731 | /* Change the base of the output filename to match the requested name. */ | ||
| 732 | if ((p = strrchr (out_filename, '/')) == NULL) | ||
| 733 | abort (); | ||
| 734 | /* The filenames have already been expanded, and will be in Unix | ||
| 735 | format, so it is safe to expect an absolute name. */ | ||
| 736 | if ((q = strrchr (new_name, '/')) == NULL) | ||
| 737 | abort (); | ||
| 738 | strcpy (p, q); | ||
| 723 | 739 | ||
| 724 | /* Make sure that the input and output filenames have the | 740 | /* Make sure that the output filename has the ".exe" extension...patch |
| 725 | ".exe" extension...patch them up if they don't. */ | 741 | it up if not. */ |
| 726 | strcpy (in_filename, old_name); | 742 | p = out_filename + strlen (out_filename) - 4; |
| 727 | ptr = in_filename + strlen (in_filename) - 4; | 743 | if (strcmp (p, ".exe")) |
| 728 | if (strcmp (ptr, ".exe")) | ||
| 729 | strcat (in_filename, ".exe"); | ||
| 730 | |||
| 731 | strcpy (out_filename, new_name); | ||
| 732 | ptr = out_filename + strlen (out_filename) - 4; | ||
| 733 | if (strcmp (ptr, ".exe")) | ||
| 734 | strcat (out_filename, ".exe"); | 744 | strcat (out_filename, ".exe"); |
| 735 | 745 | ||
| 736 | printf ("Dumping from %s\n", in_filename); | 746 | printf ("Dumping from %s\n", in_filename); |