comparison src/unexnt.c @ 5495:1f0b15040456

Merge.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 01 May 2011 18:44:03 +0100
parents 308d34e9f07d
children
comparison
equal deleted inserted replaced
5494:861f2601a38b 5495:1f0b15040456
1 /* unexec for XEmacs on Windows NT. 1 /* unexec for XEmacs on Windows NT.
2 Copyright (C) 1994 Free Software Foundation, Inc. 2 Copyright (C) 1994 Free Software Foundation, Inc.
3 Copyright (C) 2002 Ben Wing. 3 Copyright (C) 2002, 2010 Ben Wing.
4 4
5 This file is part of XEmacs. 5 This file is part of XEmacs.
6 6
7 XEmacs is free software; you can redistribute it and/or modify it 7 XEmacs is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the 8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any 9 Free Software Foundation, either version 3 of the License, or (at your
10 later version. 10 option) any later version.
11 11
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT 12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details. 15 for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with XEmacs; see the file COPYING. If not, write to the Free 18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
19 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.
21
22 Geoff Voelker (voelker@cs.washington.edu) 8-12-94 */ 19 Geoff Voelker (voelker@cs.washington.edu) 8-12-94 */
23 20
24 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */ 21 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */
25 22
26 /* This file has been Mule-ized, Ben Wing, 4-13-02. */ 23 /* This file has been Mule-ized, Ben Wing, 4-13-02. */
523 HANDLE file; 520 HANDLE file;
524 unsigned long index, n_read; 521 unsigned long index, n_read;
525 522
526 file = qxeCreateFile (filename, GENERIC_READ, FILE_SHARE_READ, NULL, 523 file = qxeCreateFile (filename, GENERIC_READ, FILE_SHARE_READ, NULL,
527 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); 524 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
528 if (file == INVALID_HANDLE_VALUE) 525 assert (file != INVALID_HANDLE_VALUE);
529 ABORT ();
530 526
531 /* Seek to where the .bss section is tucked away after the heap... */ 527 /* Seek to where the .bss section is tucked away after the heap... */
532 index = heap_index_in_executable + get_committed_heap_size (); 528 index = heap_index_in_executable + get_committed_heap_size ();
533 if (SetFilePointer (file, index, NULL, FILE_BEGIN) == 0xFFFFFFFF) 529 if (SetFilePointer (file, index, NULL, FILE_BEGIN) == 0xFFFFFFFF)
534 ABORT (); 530 ABORT ();
535 531
536 /* Ok, read in the saved .bss section and initialize all 532 /* Ok, read in the saved .bss section and initialize all
537 uninitialized variables. */ 533 uninitialized variables. */
538 if (!ReadFile (file, bss_start, bss_size, &n_read, NULL)) 534 if (!ReadFile (file, bss_start, bss_size, &n_read, NULL))
551 void *file_base; 547 void *file_base;
552 unsigned long size, upper_size, n_read; 548 unsigned long size, upper_size, n_read;
553 549
554 file = qxeCreateFile (filename, GENERIC_READ, FILE_SHARE_READ, NULL, 550 file = qxeCreateFile (filename, GENERIC_READ, FILE_SHARE_READ, NULL,
555 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); 551 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
556 if (file == INVALID_HANDLE_VALUE) 552 assert (file != INVALID_HANDLE_VALUE);
557 ABORT ();
558 553
559 size = GetFileSize (file, &upper_size); 554 size = GetFileSize (file, &upper_size);
560 file_mapping = qxeCreateFileMapping (file, NULL, PAGE_WRITECOPY, 555 file_mapping = qxeCreateFileMapping (file, NULL, PAGE_WRITECOPY,
561 0, size, NULL); 556 0, size, NULL);
562 if (!file_mapping) 557 assert (file_mapping);
563 ABORT ();
564 558
565 size = get_committed_heap_size (); 559 size = get_committed_heap_size ();
566 file_base = MapViewOfFileEx (file_mapping, FILE_MAP_COPY, 0, 560 file_base = MapViewOfFileEx (file_mapping, FILE_MAP_COPY, 0,
567 heap_index_in_executable, size, 561 heap_index_in_executable, size,
568 get_heap_start ()); 562 get_heap_start ());