HCoop
/
bpt
/
emacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update copyright notices for 2013.
[bpt/emacs.git]
/
src
/
unexw32.c
diff --git
a/src/unexw32.c
b/src/unexw32.c
index
ebeb735
..
827ed66
100644
(file)
--- a/
src/unexw32.c
+++ b/
src/unexw32.c
@@
-1,12
+1,12
@@
/* unexec for GNU Emacs on Windows NT.
/* unexec for GNU Emacs on Windows NT.
- Copyright (C) 1994, 200
5
Free Software Foundation, Inc.
+ Copyright (C) 1994, 200
1-2013
Free Software Foundation, Inc.
This file is part of GNU Emacs.
This file is part of GNU Emacs.
-GNU Emacs is free software
;
you can redistribute it and/or modify
+GNU Emacs is free software
:
you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
-the Free Software Foundation
; either version 2, or (at your option)
-any later version.
+the Free Software Foundation
, either version 3 of the License, or
+
(at your option)
any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-14,14
+14,17
@@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
+along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
+/*
Geoff Voelker (voelker@cs.washington.edu) 8-12-94
*/
#include <config.h>
Geoff Voelker (voelker@cs.washington.edu) 8-12-94
*/
#include <config.h>
+#include "unexec.h"
+#include "lisp.h"
+#include "w32common.h"
+#include "w32.h"
#include <stdio.h>
#include <fcntl.h>
#include <stdio.h>
#include <fcntl.h>
@@
-67,23
+70,23
@@
void dump_bss_and_heap (file_data *p_infile, file_data *p_outfile);
/* Cached info about the .data section in the executable. */
PIMAGE_SECTION_HEADER data_section;
PCHAR data_start = 0;
/* Cached info about the .data section in the executable. */
PIMAGE_SECTION_HEADER data_section;
PCHAR data_start = 0;
-DWORD data_size = 0;
+DWORD
_PTR
data_size = 0;
/* Cached info about the .bss section in the executable. */
PIMAGE_SECTION_HEADER bss_section;
PCHAR bss_start = 0;
/* Cached info about the .bss section in the executable. */
PIMAGE_SECTION_HEADER bss_section;
PCHAR bss_start = 0;
-DWORD bss_size = 0;
-DWORD extra_bss_size = 0;
+DWORD
_PTR
bss_size = 0;
+DWORD
_PTR
extra_bss_size = 0;
/* bss data that is static might be discontiguous from non-static. */
PIMAGE_SECTION_HEADER bss_section_static;
PCHAR bss_start_static = 0;
/* bss data that is static might be discontiguous from non-static. */
PIMAGE_SECTION_HEADER bss_section_static;
PCHAR bss_start_static = 0;
-DWORD bss_size_static = 0;
-DWORD extra_bss_size_static = 0;
+DWORD
_PTR
bss_size_static = 0;
+DWORD
_PTR
extra_bss_size_static = 0;
PIMAGE_SECTION_HEADER heap_section;
#ifdef HAVE_NTGUI
PIMAGE_SECTION_HEADER heap_section;
#ifdef HAVE_NTGUI
-
HINSTANCE hinst = NULL
;
+
extern HINSTANCE hinst
;
HINSTANCE hprevinst = NULL;
LPSTR lpCmdLine = "";
int nCmdShow = 0;
HINSTANCE hprevinst = NULL;
LPSTR lpCmdLine = "";
int nCmdShow = 0;
@@
-123,8
+126,8
@@
_start (void)
is finished. */
#ifdef HAVE_NTGUI
/* determine WinMain args like crt0.c does */
is finished. */
#ifdef HAVE_NTGUI
/* determine WinMain args like crt0.c does */
- hinst = GetModuleHandle(NULL);
- lpCmdLine = GetCommandLine();
+ hinst = GetModuleHandle
(NULL);
+ lpCmdLine = GetCommandLine
();
nCmdShow = SW_SHOWDEFAULT;
#endif
mainCRTStartup ();
nCmdShow = SW_SHOWDEFAULT;
#endif
mainCRTStartup ();
@@
-231,7
+234,7
@@
find_section (char * name, IMAGE_NT_HEADERS * nt_header)
/* Return pointer to section header for section containing the given
relative virtual address. */
IMAGE_SECTION_HEADER *
/* 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)
+rva_to_section (DWORD
_PTR
rva, IMAGE_NT_HEADERS * nt_header)
{
PIMAGE_SECTION_HEADER section;
int i;
{
PIMAGE_SECTION_HEADER section;
int i;
@@
-246,7
+249,7
@@
rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
some very old exes (eg. gzip dated Dec 1993). Since
w32_executable_type relies on this function to work reliably,
we need to cope with this. */
some very old exes (eg. gzip dated Dec 1993). Since
w32_executable_type relies on this function to work reliably,
we need to cope with this. */
- DWORD real_size = max (section->SizeOfRawData,
+ DWORD
_PTR
real_size = max (section->SizeOfRawData,
section->Misc.VirtualSize);
if (rva >= section->VirtualAddress
&& rva < section->VirtualAddress + real_size)
section->Misc.VirtualSize);
if (rva >= section->VirtualAddress
&& rva < section->VirtualAddress + real_size)
@@
-259,7
+262,7
@@
rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
/* Return pointer to section header for section containing the given
offset in its raw data area. */
IMAGE_SECTION_HEADER *
/* Return pointer to section header for section containing the given
offset in its raw data area. */
IMAGE_SECTION_HEADER *
-offset_to_section (DWORD offset, IMAGE_NT_HEADERS * nt_header)
+offset_to_section (DWORD
_PTR
offset, IMAGE_NT_HEADERS * nt_header)
{
PIMAGE_SECTION_HEADER section;
int i;
{
PIMAGE_SECTION_HEADER section;
int i;
@@
-279,8
+282,8
@@
offset_to_section (DWORD offset, IMAGE_NT_HEADERS * nt_header)
/* Return offset to an object in dst, given offset in src. We assume
there is at least one section in both src and dst images, and that
the some sections may have been added to dst (after sections in src). */
/* Return offset to an object in dst, given offset in src. We assume
there is at least one section in both src and dst images, and that
the some sections may have been added to dst (after sections in src). */
-DWORD
-relocate_offset (DWORD offset,
+DWORD
_PTR
+relocate_offset (DWORD
_PTR
offset,
IMAGE_NT_HEADERS * src_nt_header,
IMAGE_NT_HEADERS * dst_nt_header)
{
IMAGE_NT_HEADERS * src_nt_header,
IMAGE_NT_HEADERS * dst_nt_header)
{
@@
-314,25
+317,25
@@
relocate_offset (DWORD offset,
}
#define OFFSET_TO_RVA(offset, section) \
}
#define OFFSET_TO_RVA(offset, section) \
-
(section->VirtualAddress + ((DWORD)(offset) - section
->PointerToRawData))
+
((section)->VirtualAddress + ((DWORD_PTR)(offset) - (section)
->PointerToRawData))
#define RVA_TO_OFFSET(rva, section) \
#define RVA_TO_OFFSET(rva, section) \
-
(section->PointerToRawData + ((DWORD)(rva) - section
->VirtualAddress))
+
((section)->PointerToRawData + ((DWORD_PTR)(rva) - (section)
->VirtualAddress))
#define RVA_TO_SECTION_OFFSET(rva, section) \
#define RVA_TO_SECTION_OFFSET(rva, section) \
-
((DWORD)(rva) - section
->VirtualAddress)
+
((DWORD_PTR)(rva) - (section)
->VirtualAddress)
/* Convert address in executing image to RVA. */
/* Convert address in executing image to RVA. */
-#define PTR_TO_RVA(ptr) ((DWORD
)(ptr) - (DWORD
) GetModuleHandle (NULL))
+#define PTR_TO_RVA(ptr) ((DWORD
_PTR)(ptr) - (DWORD_PTR
) GetModuleHandle (NULL))
#define RVA_TO_PTR(var,section,filedata) \
#define RVA_TO_PTR(var,section,filedata) \
- ((
void *)(RVA_TO_OFFSET
(var,section) + (filedata).file_base))
+ ((
unsigned char *)(RVA_TO_OFFSET
(var,section) + (filedata).file_base))
#define PTR_TO_OFFSET(ptr, pfile_data) \
((unsigned char *)(ptr) - (pfile_data)->file_base)
#define OFFSET_TO_PTR(offset, pfile_data) \
#define PTR_TO_OFFSET(ptr, pfile_data) \
((unsigned char *)(ptr) - (pfile_data)->file_base)
#define OFFSET_TO_PTR(offset, pfile_data) \
- ((pfile_data)->file_base + (DWORD)(offset))
+ ((pfile_data)->file_base + (DWORD
_PTR
)(offset))
/* Flip through the executable and cache the info necessary for dumping. */
/* Flip through the executable and cache the info necessary for dumping. */
@@
-341,7
+344,6
@@
get_section_info (file_data *p_infile)
{
PIMAGE_DOS_HEADER dos_header;
PIMAGE_NT_HEADERS nt_header;
{
PIMAGE_DOS_HEADER dos_header;
PIMAGE_NT_HEADERS nt_header;
- PIMAGE_SECTION_HEADER section;
int overlap;
dos_header = (PIMAGE_DOS_HEADER) p_infile->file_base;
int overlap;
dos_header = (PIMAGE_DOS_HEADER) p_infile->file_base;
@@
-350,7
+352,7
@@
get_section_info (file_data *p_infile)
printf ("Unknown EXE header in %s...bailing.\n", p_infile->name);
exit (1);
}
printf ("Unknown EXE header in %s...bailing.\n", p_infile->name);
exit (1);
}
- nt_header = (PIMAGE_NT_HEADERS) (((
unsigned long
) dos_header) +
+ nt_header = (PIMAGE_NT_HEADERS) (((
DWORD_PTR
) dos_header) +
dos_header->e_lfanew);
if (nt_header == NULL)
{
dos_header->e_lfanew);
if (nt_header == NULL)
{
@@
-489,7
+491,7
@@
copy_executable_and_dump_data (file_data *p_infile,
PIMAGE_NT_HEADERS dst_nt_header;
PIMAGE_SECTION_HEADER section;
PIMAGE_SECTION_HEADER dst_section;
PIMAGE_NT_HEADERS dst_nt_header;
PIMAGE_SECTION_HEADER section;
PIMAGE_SECTION_HEADER dst_section;
- DWORD offset;
+ DWORD
_PTR
offset;
int i;
int be_verbose = GetEnvironmentVariable ("DEBUG_DUMP", NULL, 0) > 0;
int i;
int be_verbose = GetEnvironmentVariable ("DEBUG_DUMP", NULL, 0) > 0;
@@
-542,17
+544,17
@@
copy_executable_and_dump_data (file_data *p_infile,
Note that dst is updated implicitly by each COPY_CHUNK. */
dos_header = (PIMAGE_DOS_HEADER) p_infile->file_base;
Note that dst is updated implicitly by each COPY_CHUNK. */
dos_header = (PIMAGE_DOS_HEADER) p_infile->file_base;
- nt_header = (PIMAGE_NT_HEADERS) (((
unsigned long
) dos_header) +
+ nt_header = (PIMAGE_NT_HEADERS) (((
DWORD_PTR
) dos_header) +
dos_header->e_lfanew);
section = IMAGE_FIRST_SECTION (nt_header);
dst = (unsigned char *) p_outfile->file_base;
COPY_CHUNK ("Copying DOS header...", dos_header,
dos_header->e_lfanew);
section = IMAGE_FIRST_SECTION (nt_header);
dst = (unsigned char *) p_outfile->file_base;
COPY_CHUNK ("Copying DOS header...", dos_header,
- (DWORD
) nt_header - (DWORD
) dos_header, be_verbose);
+ (DWORD
_PTR) nt_header - (DWORD_PTR
) dos_header, be_verbose);
dst_nt_header = (PIMAGE_NT_HEADERS) dst;
COPY_CHUNK ("Copying NT header...", nt_header,
dst_nt_header = (PIMAGE_NT_HEADERS) dst;
COPY_CHUNK ("Copying NT header...", nt_header,
- (DWORD
) section - (DWORD
) nt_header, be_verbose);
+ (DWORD
_PTR) section - (DWORD_PTR
) nt_header, be_verbose);
dst_section = (PIMAGE_SECTION_HEADER) dst;
COPY_CHUNK ("Copying section table...", section,
nt_header->FileHeader.NumberOfSections * sizeof (*section),
dst_section = (PIMAGE_SECTION_HEADER) dst;
COPY_CHUNK ("Copying section table...", section,
nt_header->FileHeader.NumberOfSections * sizeof (*section),
@@
-628,8
+630,8
@@
copy_executable_and_dump_data (file_data *p_infile,
}
if (section == heap_section)
{
}
if (section == heap_section)
{
- DWORD
heap_start = (DWORD
) get_heap_start ();
- DWORD heap_size = get_committed_heap_size ();
+ DWORD
_PTR heap_start = (DWORD_PTR
) get_heap_start ();
+ DWORD
_PTR
heap_size = get_committed_heap_size ();
/* Dump the used portion of the predump heap, adjusting the
section's size to the appropriate size. */
/* Dump the used portion of the predump heap, adjusting the
section's size to the appropriate size. */
@@
-725,8
+727,7
@@
copy_executable_and_dump_data (file_data *p_infile,
/* Dump out .data and .bss sections into a new executable. */
void
/* Dump out .data and .bss sections into a new executable. */
void
-unexec (char *new_name, char *old_name, void *start_data, void *start_bss,
- void *entry_address)
+unexec (const char *new_name, const char *old_name)
{
file_data in_file, out_file;
char out_filename[MAX_PATH], in_filename[MAX_PATH];
{
file_data in_file, out_file;
char out_filename[MAX_PATH], in_filename[MAX_PATH];
@@
-824,6
+825,3
@@
unexec (char *new_name, char *old_name, void *start_data, void *start_bss,
}
/* eof */
}
/* eof */
-
-/* arch-tag: fe1d3d1c-ef88-4917-ab22-f12ab16b3254
- (do not change this comment) */