comparison src/unexnt.c @ 814:a634e3b7acc8

[xemacs-hg @ 2002-04-14 12:41:59 by ben] latest changes TODO.ben-mule-21-5: Update. make-docfile.c: Add basic support for handling ISO 2022 doc strings -- we parse the basic charset designation sequences so we know whether we're in ASCII and have to pay attention to end quotes and such. Reformat code according to coding standards. abbrev.el: Add `global-abbrev-mode', which turns on or off abbrev-mode in all buffers. Added `defining-abbrev-turns-on-abbrev-mode' -- if non-nil, defining an abbrev through an interactive function will automatically turn on abbrev-mode, either globally or locally depending on the command. This is the "what you'd expect" behavior. indent.el: general function for indenting a balanced expression in a mode-correct way. Works similar to indent-region in that a mode can specify a specific command to do the whole operation; if not, figure out the region using forward-sexp and indent each line using indent-according-to-mode. keydefs.el: Removed. Modify M-C-backslash to do indent-region-or-balanced-expression. Make S-Tab just insert a TAB char, like it's meant to do. make-docfile.el: Now that we're using the call-process-in-lisp, we need to load an extra file win32-native.el because we're running a bare temacs. menubar-items.el: Totally redo the Cmds menu so that most used commands appear directly on the menu and less used commands appear in submenus. The old way may have been very pretty, but rather impractical. process.el: Under Windows, don't ever use old-call-process-internal, even in batch mode. We can do processes in batch mode. subr.el: Someone recoded truncate-string-to-width, saying "the FSF version is too complicated and does lots of hard-to-understand stuff" but the resulting recoded version was *totally* wrong! it misunderstood the basic point of this function, which is work in *columns* not chars. i dumped ours and copied the version from FSF 21.1. Also added truncate-string-with-continuation-dots, since this idiom is used often. config.inc.samp, xemacs.mak: Separate out debug and optimize flags. Remove all vestiges of USE_MINIMAL_TAGBITS, USE_INDEXED_LRECORD_IMPLEMENTATION, and GUNG_HO, since those ifdefs have long been removed. Make error-checking support actually work. Some rearrangement of config.inc.samp to make it more logical. Remove callproc.c and ntproc.c from xemacs.mak, no longer used. Make pdump the default. lisp.h: Add support for strong type-checking of Bytecount, Bytebpos, Charcount, Charbpos, and others, by making them classes, overloading the operators to provide integer-like operation and carefully controlling what operations are allowed. Not currently enabled in C++ builds because there are still a number of compile errors, and it won't really work till we merge in my "8-bit-Mule" workspace, in which I make use of the new types Charxpos, Bytexpos, Memxpos, representing a "position" either in a buffer or a string. (This is especially important in the extent code.) abbrev.c, alloc.c, eval.c, buffer.c, buffer.h, editfns.c, fns.c, text.h: Warning fixes, some of them related to new C++ strict type checking of Bytecount, Charbpos, etc. dired.c: Caught an actual error due to strong type checking -- char len being passed when should be byte len. alloc.c, backtrace.h, bytecode.c, bytecode.h, eval.c, sysdep.c: Further optimize Ffuncall: -- process arg list at compiled-function creation time, converting into an array for extra-quick access at funcall time. -- rewrite funcall_compiled_function to use it, and inline this function. -- change the order of check for magic stuff in SPECBIND_FAST_UNSAFE to be faster. -- move the check for need to garbage collect into the allocation code, so only a single flag needs to be checked in funcall. buffer.c, symbols.c: add debug funs to check on mule optimization info in buffers and strings. eval.c, emacs.c, text.c, regex.c, scrollbar-msw.c, search.c: Fix evil crashes due to eistrings not properly reinitialized under pdump. Redo a bit some of the init routines; convert some complex_vars_of() into simple vars_of(), because they didn't need complex processing. callproc.c, emacs.c, event-stream.c, nt.c, process.c, process.h, sysdep.c, sysdep.h, syssignal.h, syswindows.h, ntproc.c: Delete. Hallelujah, praise the Lord, there is no god but Allah!!! fix so that processes can be invoked in bare temacs -- thereby eliminating any need for callproc.c. (currently only eliminated under NT.) remove all crufty and unnecessary old process code in ntproc.c and elsewhere. move non-callproc-specific stuff (mostly environment) into process.c, so callproc.c can be left out under NT. console-tty.c, doc.c, file-coding.c, file-coding.h, lstream.c, lstream.h: fix doc string handling so it works with Japanese, etc docs. change handling of "character mode" so callers don't have to manually set it (quite error-prone). event-msw.c: spacing fixes. lread.c: eliminate unused crufty vintage-19 "FSF defun hack" code. lrecord.h: improve pdump description docs. buffer.c, ntheap.c, unexnt.c, win32.c, emacs.c: Mule-ize some unexec and startup code. It was pseudo-Mule-ized before by simply always calling the ...A versions of functions, but that won't cut it -- eventually we want to be able to run properly even if XEmacs has been installed in a Japanese directory. (The current problem is the timing of the loading of the Unicode tables; this will eventually be fixed.) Go through and fix various other places where the code was not Mule-clean. Provide a function mswindows_get_module_file_name() to get our own name without resort to PATH_MAX and such. Add a big comment in main() about the problem with Unicode table load timing that I just alluded to. emacs.c: When error-checking is enabled (interpreted as "user is developing XEmacs"), don't ask user to "pause to read messages" when a fatal error has occurred, because it will wedge if we are in an inner modal loop (typically when a menu is popped up) and make us unable to get a useful stack trace in the debugger. text.c: Correct update_entirely_ascii_p_flag to actually work. lisp.h, symsinit.h: declarations for above changes.
author ben
date Sun, 14 Apr 2002 12:43:31 +0000
parents f846c2ef930d
children 804517e16990
comparison
equal deleted inserted replaced
813:9541922fb765 814:a634e3b7acc8
19 02111-1307, USA. 19 02111-1307, USA.
20 20
21 Geoff Voelker (voelker@cs.washington.edu) 8-12-94 */ 21 Geoff Voelker (voelker@cs.washington.edu) 8-12-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
25 /* This file has been Mule-ized, Ben Wing, 4-13-02. */
24 26
25 /* The linkers that come with MSVC >= 4.0 merge .bss into .data and reorder 27 /* The linkers that come with MSVC >= 4.0 merge .bss into .data and reorder
26 * uninitialised data so that the .data section looks like: 28 * uninitialised data so that the .data section looks like:
27 * 29 *
28 * crt0 initialised data 30 * crt0 initialised data
116 { 118 {
117 extern void mainCRTStartup (void); 119 extern void mainCRTStartup (void);
118 120
119 /* Cache system info, e.g., the NT page size. */ 121 /* Cache system info, e.g., the NT page size. */
120 cache_system_info (); 122 cache_system_info ();
123 /* Set OS type, so that tchar stuff below works */
124 init_win32_very_early ();
121 125
122 /* If we're a dumped version of emacs then we need to recreate 126 /* If we're a dumped version of emacs then we need to recreate
123 our heap and play tricks with our .bss section. Do this before 127 our heap and play tricks with our .bss section. Do this before
124 start up. (WARNING: Do not put any code before this section 128 start up. (WARNING: Do not put any code before this section
125 that relies upon malloc () and runs in the dumped version. It 129 that relies upon malloc () and runs in the dumped version. It
126 won't work.) */ 130 won't work.) */
127 if (heap_state == HEAP_UNLOADED) 131 if (heap_state == HEAP_UNLOADED)
128 { 132 {
129 char executable_path[PATH_MAX]; 133 Extbyte executable_path[MAX_PATH * MAX_XETCHAR_SIZE];
130 134
131 if (GetModuleFileNameA (NULL, executable_path, PATH_MAX) == 0) 135 /* Don't use mswindows_get_module_file_name() because it uses
136 xmalloc() */
137 if (qxeGetModuleFileName (NULL, executable_path, MAX_PATH) == 0)
132 { 138 {
133 exit (1); 139 exit (1);
134 } 140 }
135 141
136 /* #### This is super-bogus. When I rename xemacs.exe, 142 /* #### This is super-bogus. When I rename xemacs.exe,
137 the renamed file still loads its heap from xemacs.exe --kkm */ 143 the renamed file still loads its heap from xemacs.exe --kkm */
138 #if 0 144 #if 0
139 { 145 {
146 Extbyte *p;
147
140 /* To allow profiling, make sure executable_path names the .exe 148 /* To allow profiling, make sure executable_path names the .exe
141 file, not the file created by the profiler */ 149 file, not the file created by the profiler */
142 char *p = strrchr (executable_path, '\\'); 150 p = xetcsrchr (executable_path, '\\');
143 strcpy (p+1, PATH_PROGNAME ".exe"); 151 xetcscpy (p + 1, XETEXT (PATH_PROGNAME ".exe"));
144 } 152 }
145 #endif 153 #endif
146 154
147 recreate_heap (executable_path); 155 recreate_heap (executable_path);
148 heap_state = HEAP_LOADED; 156 heap_state = HEAP_LOADED;
166 mainCRTStartup (); 174 mainCRTStartup ();
167 } 175 }
168 176
169 /* Dump out .data and .bss sections into a new executable. */ 177 /* Dump out .data and .bss sections into a new executable. */
170 int 178 int
171 unexec (char *new_name, char *old_name, unsigned int start_data, 179 unexec (Intbyte *new_name, Intbyte *old_name, unsigned int start_data,
172 unsigned int start_bss, unsigned int entry_address) 180 unsigned int start_bss, unsigned int entry_address)
173 { 181 {
174 file_data in_file, out_file; 182 file_data in_file, out_file;
175 char out_filename[PATH_MAX], in_filename[PATH_MAX]; 183 Intbyte *out_filename = alloca_intbytes (qxestrlen (new_name) + 10);
184 Intbyte *in_filename = alloca_intbytes (qxestrlen (old_name) + 10);
176 unsigned long size; 185 unsigned long size;
177 char *ptr; 186 Intbyte *ptr;
178 HINSTANCE hImagehelp; 187 HINSTANCE hImagehelp;
179 188
180 /* Make sure that the input and output filenames have the 189 /* Make sure that the input and output filenames have the
181 ".exe" extension...patch them up if they don't. */ 190 ".exe" extension...patch them up if they don't. */
182 strcpy (in_filename, old_name); 191 qxestrcpy (in_filename, old_name);
183 ptr = in_filename + strlen (in_filename) - 4; 192 ptr = in_filename + qxestrlen (in_filename) - 4;
184 if (strcmp (ptr, ".exe")) 193 if (qxestrcmp (ptr, ".exe"))
185 strcat (in_filename, ".exe"); 194 qxestrcat (in_filename, ".exe");
186 195
187 strcpy (out_filename, new_name); 196 qxestrcpy (out_filename, new_name);
188 ptr = out_filename + strlen (out_filename) - 4; 197 ptr = out_filename + qxestrlen (out_filename) - 4;
189 if (strcmp (ptr, ".exe")) 198 if (qxestrcmp (ptr, ".exe"))
190 strcat (out_filename, ".exe"); 199 qxestrcat (out_filename, ".exe");
191 200
192 printf ("Dumping from %s\n", in_filename); 201 stdout_out ("Dumping from %s\n", in_filename);
193 printf (" to %s\n", out_filename); 202 stdout_out (" to %s\n", out_filename);
194 203
195 /* We need to round off our heap to NT's allocation unit (64KB). */ 204 /* We need to round off our heap to NT's allocation unit (64KB). */
196 round_heap (get_allocation_unit ()); 205 round_heap (get_allocation_unit ());
197 206
198 /* Open the undumped executable file. */ 207 /* Open the undumped executable file. */
199 if (!open_input_file (&in_file, in_filename)) 208 if (!open_input_file (&in_file, in_filename))
200 { 209 {
201 printf ("Failed to open %s (%d)...bailing.\n", 210 stdout_out ("Failed to open %s (%d)...bailing.\n",
202 in_filename, GetLastError ()); 211 in_filename, GetLastError ());
203 exit (1); 212 exit (1);
204 } 213 }
205 214
206 /* Get the interesting section info, like start and size of .bss... */ 215 /* Get the interesting section info, like start and size of .bss... */
207 get_section_info (&in_file); 216 get_section_info (&in_file);
208 217
209 /* The size of the dumped executable is the size of the original 218 /* The size of the dumped executable is the size of the original
210 executable plus the size of the heap and the size of the .bss section. */ 219 executable plus the size of the heap and the size of the .bss section. */
211 heap_index_in_executable = (unsigned long) 220 heap_index_in_executable = (unsigned long)
212 round_to_next ((unsigned char *) in_file.size, get_allocation_unit ()); 221 round_to_next ((UChar_Binary *) in_file.size, get_allocation_unit ());
213 size = heap_index_in_executable + get_committed_heap_size () + bss_size; 222 size = heap_index_in_executable + get_committed_heap_size () + bss_size;
214 if (!open_output_file (&out_file, out_filename, size)) 223 if (!open_output_file (&out_file, out_filename, size))
215 { 224 {
216 printf ("Failed to open %s (%d)...bailing.\n", 225 stdout_out ("Failed to open %s (%d)...bailing.\n",
217 out_filename, GetLastError ()); 226 out_filename, GetLastError ());
218 exit (1); 227 exit (1);
219 } 228 }
220 229
221 /* Set the flag (before dumping). */ 230 /* Set the flag (before dumping). */
222 heap_state = HEAP_UNLOADED; 231 heap_state = HEAP_UNLOADED;
234 DWORD headersum; 243 DWORD headersum;
235 DWORD checksum; 244 DWORD checksum;
236 pfnCheckSumMappedFile_t pfnCheckSumMappedFile; 245 pfnCheckSumMappedFile_t pfnCheckSumMappedFile;
237 246
238 dos_header = (PIMAGE_DOS_HEADER) out_file.file_base; 247 dos_header = (PIMAGE_DOS_HEADER) out_file.file_base;
239 nt_header = (PIMAGE_NT_HEADERS) ((char *) dos_header + dos_header->e_lfanew); 248 nt_header = (PIMAGE_NT_HEADERS) ((UChar_Binary *) dos_header +
249 dos_header->e_lfanew);
240 250
241 nt_header->OptionalHeader.CheckSum = 0; 251 nt_header->OptionalHeader.CheckSum = 0;
242 #if 0 252 #if 0
243 nt_header->FileHeader.TimeDateStamp = time (NULL); 253 nt_header->FileHeader.TimeDateStamp = time (NULL);
244 dos_header->e_cp = size / 512; 254 dos_header->e_cp = size / 512;
274 static void 284 static void
275 get_bss_info_from_map_file (file_data *p_infile, PUCHAR *p_bss_start, 285 get_bss_info_from_map_file (file_data *p_infile, PUCHAR *p_bss_start,
276 DWORD *p_bss_size) 286 DWORD *p_bss_size)
277 { 287 {
278 int n, start, len; 288 int n, start, len;
279 char map_filename[PATH_MAX]; 289 Intbyte *map_filename = alloca_intbytes (qxestrlen (p_infile->name) + 10);
280 char buffer[256]; 290 Extbyte buffer[256];
281 FILE *map; 291 FILE *map;
282 292
283 /* Overwrite the .exe extension on the executable file name with 293 /* Overwrite the .exe extension on the executable file name with
284 the .map extension. */ 294 the .map extension. */
285 strcpy (map_filename, p_infile->name); 295 qxestrcpy (map_filename, p_infile->name);
286 n = strlen (map_filename) - 3; 296 n = qxestrlen (map_filename) - 3;
287 strcpy (&map_filename[n], "map"); 297 qxestrcpy (&map_filename[n], "map");
288 298
289 map = fopen (map_filename, "r"); 299 map = qxe_fopen (map_filename, "r");
290 if (!map) 300 if (!map)
291 { 301 {
292 printf ("Failed to open map file %s, error %d...bailing out.\n", 302 stdout_out ("Failed to open map file %s, error %d...bailing out.\n",
293 map_filename, GetLastError ()); 303 map_filename, GetLastError ());
294 exit (-1); 304 exit (-1);
295 } 305 }
296 306
297 while (fgets (buffer, sizeof (buffer), map)) 307 while (fgets (buffer, sizeof (buffer), map))
298 { 308 {
299 if (!(strstr (buffer, ".bss") && strstr (buffer, "DATA"))) 309 if (!(strstr (buffer, ".bss") && strstr (buffer, "DATA")))
300 continue; 310 continue;
301 n = sscanf (buffer, " %*d:%x %x", &start, &len); 311 n = sscanf (buffer, " %*d:%x %x", &start, &len);
302 if (n != 2) 312 if (n != 2)
303 { 313 {
314 /* printf with external data, stdout_out with internal */
304 printf ("Failed to scan the .bss section line:\n%s", buffer); 315 printf ("Failed to scan the .bss section line:\n%s", buffer);
305 exit (-1); 316 exit (-1);
306 } 317 }
307 break; 318 break;
308 } 319 }
316 get_section_info (file_data *p_infile) 327 get_section_info (file_data *p_infile)
317 { 328 {
318 PIMAGE_DOS_HEADER dos_header; 329 PIMAGE_DOS_HEADER dos_header;
319 PIMAGE_NT_HEADERS nt_header; 330 PIMAGE_NT_HEADERS nt_header;
320 PIMAGE_SECTION_HEADER section, data_section; 331 PIMAGE_SECTION_HEADER section, data_section;
321 unsigned char *ptr; 332 UChar_Binary *ptr;
322 int i; 333 int i;
323 334
324 dos_header = (PIMAGE_DOS_HEADER) p_infile->file_base; 335 dos_header = (PIMAGE_DOS_HEADER) p_infile->file_base;
325 if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) 336 if (dos_header->e_magic != IMAGE_DOS_SIGNATURE)
326 { 337 {
327 printf ("Unknown EXE header in %s...bailing.\n", p_infile->name); 338 stdout_out ("Unknown EXE header in %s...bailing.\n", p_infile->name);
328 exit (1); 339 exit (1);
329 } 340 }
330 nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) + 341 nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) +
331 dos_header->e_lfanew); 342 dos_header->e_lfanew);
332 if (nt_header == NULL) 343 if (nt_header == NULL)
333 { 344 {
334 printf ("Failed to find IMAGE_NT_HEADER in %s...bailing.\n", 345 stdout_out ("Failed to find IMAGE_NT_HEADER in %s...bailing.\n",
335 p_infile->name); 346 p_infile->name);
336 exit (1); 347 exit (1);
337 } 348 }
338 349
339 /* Check the NT header signature ... */ 350 /* Check the NT header signature ... */
340 if (nt_header->Signature != IMAGE_NT_SIGNATURE) 351 if (nt_header->Signature != IMAGE_NT_SIGNATURE)
341 { 352 {
342 printf ("Invalid IMAGE_NT_SIGNATURE 0x%x in %s...bailing.\n", 353 stdout_out ("Invalid IMAGE_NT_SIGNATURE 0x%x in %s...bailing.\n",
343 nt_header->Signature, p_infile->name); 354 nt_header->Signature, p_infile->name);
344 } 355 }
345 356
346 /* Flip through the sections for .data and .bss ... */ 357 /* Flip through the sections for .data and .bss ... */
347 section = (PIMAGE_SECTION_HEADER) IMAGE_FIRST_SECTION (nt_header); 358 section = (PIMAGE_SECTION_HEADER) IMAGE_FIRST_SECTION (nt_header);
348 for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++) 359 for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++)
350 #ifndef DUMP_SEPARATE_SECTION 361 #ifndef DUMP_SEPARATE_SECTION
351 if (!strcmp (section->Name, ".bss")) 362 if (!strcmp (section->Name, ".bss"))
352 { 363 {
353 extern int my_ebss; /* From lastfile.c */ 364 extern int my_ebss; /* From lastfile.c */
354 365
355 ptr = (char *) nt_header->OptionalHeader.ImageBase + 366 ptr = (UChar_Binary *) nt_header->OptionalHeader.ImageBase +
356 section->VirtualAddress; 367 section->VirtualAddress;
357 bss_start = ptr; 368 bss_start = ptr;
358 bss_size = (char*)&my_ebss - (char*)bss_start; 369 bss_size = (UChar_Binary*) &my_ebss - (UChar_Binary*) bss_start;
359 } 370 }
360 371
361 if (!strcmp (section->Name, ".data")) 372 if (!strcmp (section->Name, ".data"))
362 #else 373 #else
363 if (!strcmp (section->Name, "xdata")) 374 if (!strcmp (section->Name, "xdata"))
364 #endif 375 #endif
365 { 376 {
366 extern char my_edata[]; /* From lastfile.c */ 377 extern Char_Binary my_edata[]; /* From lastfile.c */
367 378
368 /* The .data section. */ 379 /* The .data section. */
369 data_section = section; 380 data_section = section;
370 ptr = (char *) nt_header->OptionalHeader.ImageBase + 381 ptr = (UChar_Binary *) nt_header->OptionalHeader.ImageBase +
371 section->VirtualAddress; 382 section->VirtualAddress;
372 data_start_va = ptr; 383 data_start_va = ptr;
373 data_start_file = section->PointerToRawData; 384 data_start_file = section->PointerToRawData;
374 385
375 #ifndef DUMP_SEPARATE_SECTION 386 #ifndef DUMP_SEPARATE_SECTION
380 data_size = section->SizeOfRawData; 391 data_size = section->SizeOfRawData;
381 392
382 /* This code doesn't know how to grow the raw size of a section. */ 393 /* This code doesn't know how to grow the raw size of a section. */
383 if (section->SizeOfRawData < section->Misc.VirtualSize) 394 if (section->SizeOfRawData < section->Misc.VirtualSize)
384 { 395 {
385 printf ("The emacs data section is smaller than expected" 396 stdout_out ("The emacs data section is smaller than expected"
386 "...bailing.\n"); 397 "...bailing.\n");
387 exit (1); 398 exit (1);
388 } 399 }
389 #endif 400 #endif
390 } 401 }
391 section++; 402 section++;
405 extern int my_ebss; 416 extern int my_ebss;
406 417
407 get_bss_info_from_map_file (p_infile, &ptr, &bss_size); 418 get_bss_info_from_map_file (p_infile, &ptr, &bss_size);
408 bss_start = ptr + nt_header->OptionalHeader.ImageBase 419 bss_start = ptr + nt_header->OptionalHeader.ImageBase
409 + data_section->VirtualAddress; 420 + data_section->VirtualAddress;
410 bss_size = (char*)&my_ebss - (char*)bss_start; 421 bss_size = (UChar_Binary *) &my_ebss - (UChar_Binary *) bss_start;
411 } 422 }
412 #else 423 #else
413 bss_size = 0; 424 bss_size = 0;
414 #endif 425 #endif
415 } 426 }
416 427
417 428
418 /* The dump routines. */ 429 /* The dump routines. */
419 430
420 #ifdef DEBUG_XEMACS 431 #ifdef DEBUG_XEMACS
432 /* printf with external data, stdout_out with internal */
421 #define DUMP_MSG(x) printf x 433 #define DUMP_MSG(x) printf x
422 #else 434 #else
423 #define DUMP_MSG(x) 435 #define DUMP_MSG(x)
424 #endif 436 #endif
425 437
426 static void 438 static void
427 copy_executable_and_dump_data_section (file_data *p_infile, 439 copy_executable_and_dump_data_section (file_data *p_infile,
428 file_data *p_outfile) 440 file_data *p_outfile)
429 { 441 {
430 unsigned char *data_file, *data_va; 442 UChar_Binary *data_file, *data_va;
431 unsigned long size, index; 443 unsigned long size, index;
432 444
433 /* Get a pointer to where the raw data should go in the executable file. */ 445 /* Get a pointer to where the raw data should go in the executable file. */
434 data_file = (char *) p_outfile->file_base + data_start_file; 446 data_file = (UChar_Binary *) p_outfile->file_base + data_start_file;
435 447
436 /* Get a pointer to the raw data in our address space. */ 448 /* Get a pointer to the raw data in our address space. */
437 data_va = data_start_va; 449 data_va = data_start_va;
438 450
439 size = (DWORD) data_file - (DWORD) p_outfile->file_base; 451 size = (DWORD) data_file - (DWORD) p_outfile->file_base;
445 457
446 size = data_size; 458 size = data_size;
447 DUMP_MSG (("Dumping data section...\n")); 459 DUMP_MSG (("Dumping data section...\n"));
448 DUMP_MSG (("\t0x%08x Address in process.\n", data_va)); 460 DUMP_MSG (("\t0x%08x Address in process.\n", data_va));
449 DUMP_MSG (("\t0x%08x Offset in output file.\n", 461 DUMP_MSG (("\t0x%08x Offset in output file.\n",
450 (char*) data_file - (char *) p_outfile->file_base)); 462 (UChar_Binary *) data_file -
463 (UChar_Binary *) p_outfile->file_base));
451 DUMP_MSG (("\t0x%08x Size in bytes.\n", size)); 464 DUMP_MSG (("\t0x%08x Size in bytes.\n", size));
452 memcpy (data_file, data_va, size); 465 memcpy (data_file, data_va, size);
453 466
454 index = (DWORD) data_file + size - (DWORD) p_outfile->file_base; 467 index = (DWORD) data_file + size - (DWORD) p_outfile->file_base;
455 size = p_infile->size - index; 468 size = p_infile->size - index;
456 DUMP_MSG (("Copying rest of executable...\n")); 469 DUMP_MSG (("Copying rest of executable...\n"));
457 DUMP_MSG (("\t0x%08x Offset in input file.\n", index)); 470 DUMP_MSG (("\t0x%08x Offset in input file.\n", index));
458 DUMP_MSG (("\t0x%08x Offset in output file.\n", index)); 471 DUMP_MSG (("\t0x%08x Offset in output file.\n", index));
459 DUMP_MSG (("\t0x%08x Size in bytes.\n", size)); 472 DUMP_MSG (("\t0x%08x Size in bytes.\n", size));
460 memcpy ((char *) p_outfile->file_base + index, 473 memcpy ((UChar_Binary *) p_outfile->file_base + index,
461 (char *) p_infile->file_base + index, size); 474 (UChar_Binary *) p_infile->file_base + index, size);
462 } 475 }
463 476
464 static void 477 static void
465 dump_bss_and_heap (file_data *p_infile, file_data *p_outfile) 478 dump_bss_and_heap (file_data *p_infile, file_data *p_outfile)
466 { 479 {
467 unsigned char *heap_data; 480 UChar_Binary *heap_data;
468 unsigned long size, index; 481 unsigned long size, index;
469 482
470 DUMP_MSG (("Dumping heap onto end of executable...\n")); 483 DUMP_MSG (("Dumping heap onto end of executable...\n"));
471 484
472 index = heap_index_in_executable; 485 index = heap_index_in_executable;
473 size = get_committed_heap_size (); 486 size = get_committed_heap_size ();
474 heap_data = get_heap_start (); 487 heap_data = get_heap_start ();
475 488
476 DUMP_MSG (("\t0x%08x Heap start in process.\n", heap_data)); 489 DUMP_MSG (("\t0x%08x Heap start in process.\n", heap_data));
477 DUMP_MSG (("\t0x%08x Heap offset in executable.\n", index)); 490 DUMP_MSG (("\t0x%08x Heap offset in executable.\n", index));
478 DUMP_MSG (("\t0x%08x Heap size in bytes.\n", size)); 491 DUMP_MSG (("\t0x%08x Heap size in bytes.\n", size));
479 492
480 memcpy ((PUCHAR) p_outfile->file_base + index, heap_data, size); 493 memcpy ((PUCHAR) p_outfile->file_base + index, heap_data, size);
481 494
482 #ifndef DUMP_SEPARATE_SECTION 495 #ifndef DUMP_SEPARATE_SECTION
483 DUMP_MSG (("Dumping bss onto end of executable...\n")); 496 DUMP_MSG (("Dumping bss onto end of executable...\n"));
484 497
485 index += size; 498 index += size;
486 size = bss_size; 499 size = bss_size;
487 500
488 DUMP_MSG (("\t0x%08x BSS start in process.\n", bss_start)); 501 DUMP_MSG (("\t0x%08x BSS start in process.\n", bss_start));
489 DUMP_MSG (("\t0x%08x BSS offset in executable.\n", index)); 502 DUMP_MSG (("\t0x%08x BSS offset in executable.\n", index));
490 DUMP_MSG (("\t0x%08x BSS size in bytes.\n", size)); 503 DUMP_MSG (("\t0x%08x BSS size in bytes.\n", size));
491 memcpy ((char *) p_outfile->file_base + index, bss_start, size); 504 memcpy ((UChar_Binary *) p_outfile->file_base + index, bss_start, size);
492 #endif 505 #endif
493 } 506 }
494 507
495 #undef DUMP_MSG 508 #undef DUMP_MSG
496 509
498 511
499 512
500 /* Load the dumped .bss section into the .bss area of our address space. */ 513 /* Load the dumped .bss section into the .bss area of our address space. */
501 /* Already done if the .bss was part of a separate emacs data section */ 514 /* Already done if the .bss was part of a separate emacs data section */
502 void 515 void
503 read_in_bss (char *filename) 516 read_in_bss (Extbyte *filename)
504 { 517 {
505 #ifndef DUMP_SEPARATE_SECTION 518 #ifndef DUMP_SEPARATE_SECTION
506 HANDLE file; 519 HANDLE file;
507 unsigned long index, n_read; 520 unsigned long index, n_read;
508 521
509 file = CreateFile (filename, GENERIC_READ, FILE_SHARE_READ, NULL, 522 file = qxeCreateFile (filename, GENERIC_READ, FILE_SHARE_READ, NULL,
510 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); 523 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
511 if (file == INVALID_HANDLE_VALUE) 524 if (file == INVALID_HANDLE_VALUE)
512 abort (); 525 abort ();
513 526
514 /* 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... */
515 index = heap_index_in_executable + get_committed_heap_size (); 528 index = heap_index_in_executable + get_committed_heap_size ();
525 #endif 538 #endif
526 } 539 }
527 540
528 /* Map the heap dumped into the executable file into our address space. */ 541 /* Map the heap dumped into the executable file into our address space. */
529 void 542 void
530 map_in_heap (char *filename) 543 map_in_heap (Extbyte *filename)
531 { 544 {
532 HANDLE file; 545 HANDLE file;
533 HANDLE file_mapping; 546 HANDLE file_mapping;
534 void *file_base; 547 void *file_base;
535 unsigned long size, upper_size, n_read; 548 unsigned long size, upper_size, n_read;
536 549
537 file = CreateFileA (filename, GENERIC_READ, FILE_SHARE_READ, NULL, 550 file = qxeCreateFile (filename, GENERIC_READ, FILE_SHARE_READ, NULL,
538 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); 551 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
539 if (file == INVALID_HANDLE_VALUE) 552 if (file == INVALID_HANDLE_VALUE)
540 abort (); 553 abort ();
541 554
542 size = GetFileSize (file, &upper_size); 555 size = GetFileSize (file, &upper_size);
543 file_mapping = CreateFileMappingA (file, NULL, PAGE_WRITECOPY, 556 file_mapping = qxeCreateFileMapping (file, NULL, PAGE_WRITECOPY,
544 0, size, NULL); 557 0, size, NULL);
545 if (!file_mapping) 558 if (!file_mapping)
546 abort (); 559 abort ();
547 560
548 size = get_committed_heap_size (); 561 size = get_committed_heap_size ();
549 file_base = MapViewOfFileEx (file_mapping, FILE_MAP_COPY, 0, 562 file_base = MapViewOfFileEx (file_mapping, FILE_MAP_COPY, 0,