1 /* Heap management routines (including unexec) for GNU Emacs on Windows NT.
2 Copyright (C) 1994, 2001-2023 Free Software Foundation, Inc.
3
4 This file is part of GNU Emacs.
5
6 GNU Emacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or (at
9 your option) any later version.
10
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
18
19 Geoff Voelker (voelker@cs.washington.edu) 7-29-94
20 */
21
22 #ifndef NTHEAP_H_
23 #define NTHEAP_H_
24
25 #include <windows.h>
26
27 /*
28 * Heap related stuff.
29 */
30
31 extern unsigned char *get_data_start (void);
32 extern unsigned char *get_data_end (void);
33 extern size_t reserved_heap_size;
34
35 extern void *mmap_realloc (void **, size_t);
36 extern void mmap_free (void **);
37 extern void *mmap_alloc (void **, size_t);
38
39 extern void report_temacs_memory_usage (void);
40
41 /* Emulation of Unix sbrk(). */
42 extern void *sbrk (ptrdiff_t size);
43
44 /* Initialize heap structures for sbrk on startup. */
45 extern void init_heap (bool);
46
47 /* ----------------------------------------------------------------- */
48 /* Useful routines for manipulating memory-mapped files. */
49
50 typedef struct file_data {
51 char *name;
52 unsigned long size;
53 HANDLE file;
54 HANDLE file_mapping;
55 unsigned char *file_base;
56 } file_data;
57
58 int open_input_file (file_data *p_file, char *name);
59 int open_output_file (file_data *p_file, char *name, unsigned long size);
60 void close_file_data (file_data *p_file);
61
62 /* Return pointer to section header for named section. */
63 IMAGE_SECTION_HEADER * find_section (const char *, IMAGE_NT_HEADERS *);
64
65 /* Return pointer to section header for section containing the given
66 relative virtual address. */
67 IMAGE_SECTION_HEADER * rva_to_section (DWORD_PTR, IMAGE_NT_HEADERS *);
68
69 #endif /* NTHEAP_H_ */