Release 960805
[wine] / library / sup.c
1 #include <stdio.h>
2 #include <unistd.h>
3 #include "windows.h"
4 #include "arch.h"
5 #include "neexe.h"
6
7 /*
8  * Header loading routines for WineLib.
9  */
10
11 /* LOADSHORT Calls LOAD and swaps the high and the low bytes */
12
13 #define LOAD(x)  read (fd, &TAB->x, sizeof (TAB->x))
14 #define LOADSHORT(x) LOAD(x); TAB->x = CONV_SHORT (TAB->x);
15 #define LOADLONG(x) LOAD(x);  TAB->x = CONV_LONG (TAB->x);
16
17 void load_mz_header (int fd, struct mz_header_s *mz_header)
18 {
19 #define TAB mz_header
20         LOAD (mz_magic);
21     LOAD (dont_care);
22     LOADSHORT (ne_offset);
23 }
24
25 void load_ne_header (int fd, struct ne_header_s *ne_header)
26 {
27 #undef TAB
28 #define TAB ne_header
29     LOAD (ne_magic);
30     LOADSHORT (linker_version);
31     LOADSHORT (linker_revision);
32     LOADSHORT (entry_tab_offset);
33     LOADSHORT (entry_tab_length);
34     LOAD (reserved1);
35     LOADSHORT (format_flags);
36     LOADSHORT (auto_data_seg);
37     LOADSHORT (local_heap_length);
38     LOADSHORT (stack_length);
39     LOADSHORT (ip);
40     LOADSHORT (cs);
41     LOADSHORT (sp);
42     LOADSHORT (ss);
43     LOADSHORT (n_segment_tab);
44     LOADSHORT (n_mod_ref_tab);
45     LOADSHORT (nrname_tab_length);
46     LOADSHORT (segment_tab_offset);
47     LOADSHORT (resource_tab_offset);
48     LOADSHORT (rname_tab_offset);
49     LOADSHORT (moduleref_tab_offset);
50     LOADSHORT (iname_tab_offset);
51     LOADLONG (nrname_tab_offset);
52     LOADSHORT (n_mov_entry_points);
53     LOADSHORT (align_shift_count);
54     LOADSHORT (n_resource_seg);
55     LOAD (operating_system);
56     LOAD (additional_flags);
57     LOADSHORT (fastload_offset);
58     LOADSHORT (fastload_length);
59     LOADSHORT (reserved2);
60     LOADSHORT (expect_version);
61 }
62
63 /*
64  * Typeinfo loading routines for non PC-architectures.
65  */
66
67 int load_typeinfo (int fd, struct resource_typeinfo_s *typeinfo)
68 {
69 #undef TAB
70 #define TAB typeinfo
71     LOADSHORT (type_id);
72     LOADSHORT (count);
73     LOADLONG  (reserved);
74     return 1;
75 }
76
77 int load_nameinfo (int fd, struct resource_nameinfo_s *nameinfo)
78 {
79 #undef TAB
80 #define TAB nameinfo
81     LOADSHORT (offset);
82     LOADSHORT (length);
83     LOADSHORT (flags);
84     LOADSHORT (id);
85     LOADSHORT (handle);
86     LOADSHORT (usage);
87     return 0;
88 }