| 1 | /* Heap management routines (including unexec) for GNU Emacs on Windows NT. |
| 2 | Copyright (C) 1994, 2001-2014 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 |
| 9 | (at 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 <http://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 | #define get_reserved_heap_size() reserved_heap_size |
| 31 | #define get_committed_heap_size() (get_data_end () - get_data_start ()) |
| 32 | #define get_heap_start() get_data_start () |
| 33 | #define get_heap_end() get_data_end () |
| 34 | |
| 35 | extern unsigned char *get_data_start (void); |
| 36 | extern unsigned char *get_data_end (void); |
| 37 | extern size_t reserved_heap_size; |
| 38 | extern BOOL using_dynamic_heap; |
| 39 | |
| 40 | /* Emulation of Unix sbrk(). */ |
| 41 | extern void *sbrk (ptrdiff_t size); |
| 42 | |
| 43 | /* Initialize heap structures for sbrk on startup. */ |
| 44 | extern void init_heap (void); |
| 45 | |
| 46 | /* Round the heap to this size. */ |
| 47 | extern void round_heap (size_t size); |
| 48 | |
| 49 | /* ----------------------------------------------------------------- */ |
| 50 | /* Useful routines for manipulating memory-mapped files. */ |
| 51 | |
| 52 | typedef struct file_data { |
| 53 | char *name; |
| 54 | unsigned long size; |
| 55 | HANDLE file; |
| 56 | HANDLE file_mapping; |
| 57 | unsigned char *file_base; |
| 58 | } file_data; |
| 59 | |
| 60 | int open_input_file (file_data *p_file, char *name); |
| 61 | int open_output_file (file_data *p_file, char *name, unsigned long size); |
| 62 | void close_file_data (file_data *p_file); |
| 63 | |
| 64 | /* Return pointer to section header for named section. */ |
| 65 | IMAGE_SECTION_HEADER * find_section (char * name, IMAGE_NT_HEADERS * nt_header); |
| 66 | |
| 67 | /* Return pointer to section header for section containing the given |
| 68 | relative virtual address. */ |
| 69 | IMAGE_SECTION_HEADER * rva_to_section (DWORD_PTR rva, IMAGE_NT_HEADERS * nt_header); |
| 70 | |
| 71 | #endif /* NTHEAP_H_ */ |