comparison src/ntheap.h @ 209:41ff10fd062f r20-4b3

Import from CVS: tag r20-4b3
author cvs
date Mon, 13 Aug 2007 10:04:58 +0200
parents 15872534500d
children 70ad99077275
comparison
equal deleted inserted replaced
208:f427b8ec4379 209:41ff10fd062f
19 02111-1307, USA. 19 02111-1307, USA.
20 20
21 Geoff Voelker (voelker@cs.washington.edu) 7-29-94 */ 21 Geoff Voelker (voelker@cs.washington.edu) 7-29-94 */
22 22
23 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */ 23 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */
24 /* Synced with FSF Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> */
24 25
25 #ifndef NTHEAP_H_ 26 #ifndef NTHEAP_H_
26 #define NTHEAP_H_ 27 #define NTHEAP_H_
27 28
28 #include <windows.h> 29 #include <windows.h>
51 /* To prevent zero-initialized variables from being placed into the bss 52 /* To prevent zero-initialized variables from being placed into the bss
52 section, use non-zero values to represent an uninitialized state. */ 53 section, use non-zero values to represent an uninitialized state. */
53 #define UNINIT_PTR ((void *) 0xF0A0F0A0) 54 #define UNINIT_PTR ((void *) 0xF0A0F0A0)
54 #define UNINIT_LONG (0xF0A0F0A0L) 55 #define UNINIT_LONG (0xF0A0F0A0L)
55 56
57 enum {
58 OS_WIN95 = 1,
59 OS_NT
60 };
61
62 extern int os_subtype;
63
56 /* Emulation of Unix sbrk(). */ 64 /* Emulation of Unix sbrk(). */
57 extern void *sbrk (unsigned long size); 65 extern void *sbrk (unsigned long size);
58 66
59 /* Recreate the heap created during dumping. */ 67 /* Recreate the heap created during dumping. */
60 extern void recreate_heap (char *executable_path); 68 extern void recreate_heap (char *executable_path);
73 81
74 /* Round ADDRESS up to be aligned with ALIGN. */ 82 /* Round ADDRESS up to be aligned with ALIGN. */
75 extern unsigned char *round_to_next (unsigned char *address, 83 extern unsigned char *round_to_next (unsigned char *address,
76 unsigned long align); 84 unsigned long align);
77 85
86 /* ----------------------------------------------------------------- */
87 /* Useful routines for manipulating memory-mapped files. */
88
89 typedef struct file_data {
90 char *name;
91 unsigned long size;
92 HANDLE file;
93 HANDLE file_mapping;
94 unsigned char *file_base;
95 } file_data;
96
97 #define OFFSET_TO_RVA(var,section) \
98 (section->VirtualAddress + ((DWORD)(var) - section->PointerToRawData))
99
100 #define RVA_TO_OFFSET(var,section) \
101 (section->PointerToRawData + ((DWORD)(var) - section->VirtualAddress))
102
103 #define RVA_TO_PTR(var,section,filedata) \
104 ((void *)(RVA_TO_OFFSET(var,section) + (filedata).file_base))
105
106 int open_input_file (file_data *p_file, char *name);
107 int open_output_file (file_data *p_file, char *name, unsigned long size);
108 void close_file_data (file_data *p_file);
109
110 unsigned long get_section_size (PIMAGE_SECTION_HEADER p_section);
111
112 /* Return pointer to section header for named section. */
113 IMAGE_SECTION_HEADER * find_section (char * name, IMAGE_NT_HEADERS * nt_header);
114
115 /* Return pointer to section header for section containing the given
116 relative virtual address. */
117 IMAGE_SECTION_HEADER * rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header);
118
78 #endif /* NTHEAP_H_ */ 119 #endif /* NTHEAP_H_ */