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