aboutsummaryrefslogtreecommitdiffstats
path: root/src/unexw32.c
diff options
context:
space:
mode:
authorKaroly Lorentey2005-06-15 12:57:51 +0000
committerKaroly Lorentey2005-06-15 12:57:51 +0000
commitef85512e51f043d73788f00a2aed13cccde0682c (patch)
treefc1fa1378533250f260ef8eaa9a84ae882d9df84 /src/unexw32.c
parent8736257554f49445f7b4402ac7a9436b38ce6452 (diff)
parentef88a9999004e6c26148c8d280d6a41f623d7249 (diff)
downloademacs-ef85512e51f043d73788f00a2aed13cccde0682c.tar.gz
emacs-ef85512e51f043d73788f00a2aed13cccde0682c.zip
Merged from miles@gnu.org--gnu-2005 (patch 80-82, 350-422)
Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-350 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-351 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-352 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-353 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-354 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-355 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-356 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-357 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-358 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-359 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-360 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-361 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-362 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-363 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-364 Remove "-face" suffix from widget faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-365 Remove "-face" suffix from custom faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-366 Remove "-face" suffix from change-log faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-367 Remove "-face" suffix from compilation faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-368 Remove "-face" suffix from diff-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-369 lisp/longlines.el (longlines-visible-face): Face removed * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-370 Remove "-face" suffix from woman faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371 Remove "-face" suffix from whitespace-highlight face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-372 Remove "-face" suffix from ruler-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-373 Remove "-face" suffix from show-paren faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-374 Remove "-face" suffix from log-view faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375 Remove "-face" suffix from smerge faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-376 Remove "-face" suffix from show-tabs faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-377 Remove "-face" suffix from highlight-changes faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-378 Remove "-face" suffix from and downcase info faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-379 Remove "-face" suffix from pcvs faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-380 Update uses of renamed pcvs faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-381 Tweak ChangeLog * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-382 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-383 Remove "-face" suffix from strokes-char face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-384 Remove "-face" suffix from compare-windows face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-385 Remove "-face" suffix from calendar faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-386 Remove "-face" suffix from diary-button face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-387 Remove "-face" suffix from testcover faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-388 Remove "-face" suffix from viper faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-389 Remove "-face" suffix from org faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-390 Remove "-face" suffix from sgml-namespace face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-391 Remove "-face" suffix from table-cell face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-392 Remove "-face" suffix from tex-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-393 Remove "-face" suffix from texinfo-heading face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-394 Remove "-face" suffix from flyspell faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-395 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-396 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-397 Remove "-face" suffix from gomoku faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398 Remove "-face" suffix from mpuz faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-399 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-400 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-401 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-402 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-403 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-404 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-405 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-406 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-407 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-408 Remove "-face" suffix from Buffer-menu-buffer face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-409 Remove "-face" suffix from antlr-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-410 Remove "-face" suffix from ebrowse faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-411 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-412 Remove "-face" suffix from flymake faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-413 Remove "-face" suffix from idlwave faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-414 Remove "-face" suffix from sh-script faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-415 Remove "-face" suffix from vhdl-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-416 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-417 Remove "-face" suffix from which-func face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-418 Remove "-face" suffix from cperl-mode faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-419 Remove "-face" suffix from ld-script faces * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-420 Fix cperl-mode font-lock problem * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-421 Tweak which-func face * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-422 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-80 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-81 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-82 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-350
Diffstat (limited to 'src/unexw32.c')
-rw-r--r--src/unexw32.c59
1 files changed, 38 insertions, 21 deletions
diff --git a/src/unexw32.c b/src/unexw32.c
index b1838644965..ebeb7355673 100644
--- a/src/unexw32.c
+++ b/src/unexw32.c
@@ -1,5 +1,5 @@
1/* unexec for GNU Emacs on Windows NT. 1/* unexec for GNU Emacs on Windows NT.
2 Copyright (C) 1994 Free Software Foundation, Inc. 2 Copyright (C) 1994, 2005 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -325,6 +325,9 @@ relocate_offset (DWORD offset,
325/* Convert address in executing image to RVA. */ 325/* Convert address in executing image to RVA. */
326#define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL)) 326#define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL))
327 327
328#define RVA_TO_PTR(var,section,filedata) \
329 ((void *)(RVA_TO_OFFSET(var,section) + (filedata).file_base))
330
328#define PTR_TO_OFFSET(ptr, pfile_data) \ 331#define PTR_TO_OFFSET(ptr, pfile_data) \
329 ((unsigned char *)(ptr) - (pfile_data)->file_base) 332 ((unsigned char *)(ptr) - (pfile_data)->file_base)
330 333
@@ -488,27 +491,34 @@ copy_executable_and_dump_data (file_data *p_infile,
488 PIMAGE_SECTION_HEADER dst_section; 491 PIMAGE_SECTION_HEADER dst_section;
489 DWORD offset; 492 DWORD offset;
490 int i; 493 int i;
494 int be_verbose = GetEnvironmentVariable ("DEBUG_DUMP", NULL, 0) > 0;
491 495
492#define COPY_CHUNK(message, src, size) \ 496#define COPY_CHUNK(message, src, size, verbose) \
493 do { \ 497 do { \
494 unsigned char *s = (void *)(src); \ 498 unsigned char *s = (void *)(src); \
495 unsigned long count = (size); \ 499 unsigned long count = (size); \
496 printf ("%s\n", (message)); \ 500 if (verbose) \
497 printf ("\t0x%08x Offset in input file.\n", s - p_infile->file_base); \ 501 { \
498 printf ("\t0x%08x Offset in output file.\n", dst - p_outfile->file_base); \ 502 printf ("%s\n", (message)); \
499 printf ("\t0x%08x Size in bytes.\n", count); \ 503 printf ("\t0x%08x Offset in input file.\n", s - p_infile->file_base); \
504 printf ("\t0x%08x Offset in output file.\n", dst - p_outfile->file_base); \
505 printf ("\t0x%08x Size in bytes.\n", count); \
506 } \
500 memcpy (dst, s, count); \ 507 memcpy (dst, s, count); \
501 dst += count; \ 508 dst += count; \
502 } while (0) 509 } while (0)
503 510
504#define COPY_PROC_CHUNK(message, src, size) \ 511#define COPY_PROC_CHUNK(message, src, size, verbose) \
505 do { \ 512 do { \
506 unsigned char *s = (void *)(src); \ 513 unsigned char *s = (void *)(src); \
507 unsigned long count = (size); \ 514 unsigned long count = (size); \
508 printf ("%s\n", (message)); \ 515 if (verbose) \
509 printf ("\t0x%08x Address in process.\n", s); \ 516 { \
510 printf ("\t0x%08x Offset in output file.\n", dst - p_outfile->file_base); \ 517 printf ("%s\n", (message)); \
511 printf ("\t0x%08x Size in bytes.\n", count); \ 518 printf ("\t0x%08x Address in process.\n", s); \
519 printf ("\t0x%08x Offset in output file.\n", dst - p_outfile->file_base); \
520 printf ("\t0x%08x Size in bytes.\n", count); \
521 } \
512 memcpy (dst, s, count); \ 522 memcpy (dst, s, count); \
513 dst += count; \ 523 dst += count; \
514 } while (0) 524 } while (0)
@@ -539,13 +549,14 @@ copy_executable_and_dump_data (file_data *p_infile,
539 dst = (unsigned char *) p_outfile->file_base; 549 dst = (unsigned char *) p_outfile->file_base;
540 550
541 COPY_CHUNK ("Copying DOS header...", dos_header, 551 COPY_CHUNK ("Copying DOS header...", dos_header,
542 (DWORD) nt_header - (DWORD) dos_header); 552 (DWORD) nt_header - (DWORD) dos_header, be_verbose);
543 dst_nt_header = (PIMAGE_NT_HEADERS) dst; 553 dst_nt_header = (PIMAGE_NT_HEADERS) dst;
544 COPY_CHUNK ("Copying NT header...", nt_header, 554 COPY_CHUNK ("Copying NT header...", nt_header,
545 (DWORD) section - (DWORD) nt_header); 555 (DWORD) section - (DWORD) nt_header, be_verbose);
546 dst_section = (PIMAGE_SECTION_HEADER) dst; 556 dst_section = (PIMAGE_SECTION_HEADER) dst;
547 COPY_CHUNK ("Copying section table...", section, 557 COPY_CHUNK ("Copying section table...", section,
548 nt_header->FileHeader.NumberOfSections * sizeof (*section)); 558 nt_header->FileHeader.NumberOfSections * sizeof (*section),
559 be_verbose);
549 560
550 /* Align the first section's raw data area, and set the header size 561 /* Align the first section's raw data area, and set the header size
551 field accordingly. */ 562 field accordingly. */
@@ -555,7 +566,9 @@ copy_executable_and_dump_data (file_data *p_infile,
555 for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++) 566 for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++)
556 { 567 {
557 char msg[100]; 568 char msg[100];
558 sprintf (msg, "Copying raw data for %s...", section->Name); 569 /* Windows section names are fixed 8-char strings, only
570 zero-terminated if the name is shorter than 8 characters. */
571 sprintf (msg, "Copying raw data for %.8s...", section->Name);
559 572
560 dst_save = dst; 573 dst_save = dst;
561 574
@@ -568,7 +581,7 @@ copy_executable_and_dump_data (file_data *p_infile,
568 /* Can always copy the original raw data. */ 581 /* Can always copy the original raw data. */
569 COPY_CHUNK 582 COPY_CHUNK
570 (msg, OFFSET_TO_PTR (section->PointerToRawData, p_infile), 583 (msg, OFFSET_TO_PTR (section->PointerToRawData, p_infile),
571 section->SizeOfRawData); 584 section->SizeOfRawData, be_verbose);
572 /* Ensure alignment slop is zeroed. */ 585 /* Ensure alignment slop is zeroed. */
573 ROUND_UP_DST_AND_ZERO (dst_nt_header->OptionalHeader.FileAlignment); 586 ROUND_UP_DST_AND_ZERO (dst_nt_header->OptionalHeader.FileAlignment);
574 587
@@ -577,7 +590,8 @@ copy_executable_and_dump_data (file_data *p_infile,
577 { 590 {
578 dst = dst_save 591 dst = dst_save
579 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (data_start), dst_section); 592 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (data_start), dst_section);
580 COPY_PROC_CHUNK ("Dumping initialized data...", data_start, data_size); 593 COPY_PROC_CHUNK ("Dumping initialized data...",
594 data_start, data_size, be_verbose);
581 dst = dst_save + dst_section->SizeOfRawData; 595 dst = dst_save + dst_section->SizeOfRawData;
582 } 596 }
583 if (section == bss_section) 597 if (section == bss_section)
@@ -586,7 +600,8 @@ copy_executable_and_dump_data (file_data *p_infile,
586 data size as necessary. */ 600 data size as necessary. */
587 dst = dst_save 601 dst = dst_save
588 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (bss_start), dst_section); 602 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (bss_start), dst_section);
589 COPY_PROC_CHUNK ("Dumping bss data...", bss_start, bss_size); 603 COPY_PROC_CHUNK ("Dumping bss data...", bss_start,
604 bss_size, be_verbose);
590 ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment); 605 ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment);
591 dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile); 606 dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile);
592 /* Determine new size of raw data area. */ 607 /* Determine new size of raw data area. */
@@ -601,7 +616,8 @@ copy_executable_and_dump_data (file_data *p_infile,
601 section's raw data size as necessary. */ 616 section's raw data size as necessary. */
602 dst = dst_save 617 dst = dst_save
603 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (bss_start_static), dst_section); 618 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (bss_start_static), dst_section);
604 COPY_PROC_CHUNK ("Dumping static bss data...", bss_start_static, bss_size_static); 619 COPY_PROC_CHUNK ("Dumping static bss data...", bss_start_static,
620 bss_size_static, be_verbose);
605 ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment); 621 ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment);
606 dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile); 622 dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile);
607 /* Determine new size of raw data area. */ 623 /* Determine new size of raw data area. */
@@ -619,7 +635,8 @@ copy_executable_and_dump_data (file_data *p_infile,
619 section's size to the appropriate size. */ 635 section's size to the appropriate size. */
620 dst = dst_save 636 dst = dst_save
621 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (heap_start), dst_section); 637 + RVA_TO_SECTION_OFFSET (PTR_TO_RVA (heap_start), dst_section);
622 COPY_PROC_CHUNK ("Dumping heap...", heap_start, heap_size); 638 COPY_PROC_CHUNK ("Dumping heap...", heap_start, heap_size,
639 be_verbose);
623 ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment); 640 ROUND_UP_DST (dst_nt_header->OptionalHeader.FileAlignment);
624 dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile); 641 dst_section->PointerToRawData = PTR_TO_OFFSET (dst_save, p_outfile);
625 /* Determine new size of raw data area. */ 642 /* Determine new size of raw data area. */
@@ -654,7 +671,7 @@ copy_executable_and_dump_data (file_data *p_infile,
654 COPY_CHUNK 671 COPY_CHUNK
655 ("Copying remainder of executable...", 672 ("Copying remainder of executable...",
656 OFFSET_TO_PTR (offset, p_infile), 673 OFFSET_TO_PTR (offset, p_infile),
657 p_infile->size - offset); 674 p_infile->size - offset, be_verbose);
658 675
659 /* Final size for new image. */ 676 /* Final size for new image. */
660 p_outfile->size = DST_TO_OFFSET (); 677 p_outfile->size = DST_TO_OFFSET ();